public void UpdateFrom(AllFeed allFeed)
        {
            AvailablePlugins.Clear();

            foreach( var item in allFeed.Items)
            {
                var viewModel = new FeedItemViewModel
                {
                    Title = item.Title
                };
                AvailablePlugins.Add(viewModel);
            }
        }
Esempio n. 2
0
        private void HandleFinishedDownloading(AllFeed allFeed, DownloadState state)
        {
            if (mainControl != null)
            {
                GlueCommands.Self.DoOnUiThread(() =>
               {
                   viewModel.UpdateFrom(allFeed);

                   mainControl.AllFeed = allFeed;
                   mainControl.DownloadState = state;
               });
            }
        }
Esempio n. 3
0
        public static void StartDownloadingInformation(string url, Action <AllFeed, DownloadState> callback)
        {
            Thread thread = new Thread(() =>
            {
                AllFeed toReturn     = null;
                DownloadState result = DownloadState.Error;
                try
                {
                    // Create a request for the URL.
                    WebRequest request = WebRequest.Create(url);
                    // If required by the server, set the credentials.
                    request.Credentials = CredentialCache.DefaultCredentials;
                    // Get the response.
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                        using (Stream dataStream = response.GetResponseStream())
                            using (StreamReader reader = new StreamReader(dataStream))
                            {
                                // Read the content.
                                string responseFromServer = reader.ReadToEnd();
                                toReturn = new AllFeed();
                                //toReturn = FileManager.XmlDeserializeFromString<AllFeed>(responseFromServer);
                                XDocument doc = XDocument.Parse(responseFromServer);

                                foreach (var xElement in doc.Element("rss").Element("channel").Elements("item"))
                                {
                                    RssItem newItem = RssItem.FromXElement(xElement);
                                    toReturn.Items.Add(newItem);
                                }
                            }

                    result = DownloadState.InformationDownloaded;
                }
                catch (Exception e)
                {
                    result = DownloadState.Error;
                }
                callback(toReturn, result);
            });

            thread.Start();
        }
Esempio n. 4
0
        public static void StartDownloadingInformation(string url, Action<AllFeed, DownloadState> callback)
        {
            Thread thread = new Thread(() =>
            {
                AllFeed toReturn = null;
                DownloadState result = DownloadState.Error;
                try
                {
                    // Create a request for the URL. 		
                    WebRequest request = WebRequest.Create(url);
                    // If required by the server, set the credentials.
                    request.Credentials = CredentialCache.DefaultCredentials;
                    // Get the response.
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream dataStream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(dataStream))
                    {
                        // Read the content. 
                        string responseFromServer = reader.ReadToEnd();
                        toReturn = new AllFeed();
                        //toReturn = FileManager.XmlDeserializeFromString<AllFeed>(responseFromServer);
                        XDocument doc = XDocument.Parse(responseFromServer);

                        foreach (var xElement in doc.Element("rss").Element("channel").Elements("item"))
                        {
                            RssItem newItem = RssItem.FromXElement(xElement);
                            toReturn.Items.Add(newItem);
                        }
                    }

                    result = DownloadState.InformationDownloaded;
                }
                catch (Exception e)
                {
                    result = DownloadState.Error;
                }
                callback(toReturn, result);
            });

            thread.Start();
        }
Esempio n. 5
0
        private RssItem GetItemFor(AllFeed feed, PluginContainer SelectedPlugin)
        {
            string folder = 
                FileManager.RemovePath(
                 FileManager.GetDirectory(SelectedPlugin.AssemblyLocation));
            folder = folder.Replace("/", "");
            if (!folder.ToLowerInvariant().EndsWith("plugin"))
            {
                folder += "plugin";
            }
            folder = folder.ToLower();

            RssItem itemToReturn = null;
                
            string whatToLookFor = folder + ".plug";

            // We're going to narrow things down a bit here:
            whatToLookFor = ">" + whatToLookFor + @"</a>";
            
            foreach (var item in feed.Items)
            {
                var description = item.Description.ToLower();

                if (description.Contains(whatToLookFor))
                {
                    itemToReturn = item;
                    break;
                }
            }

            return itemToReturn;
        }
Esempio n. 6
0
        private void FinishedDownloadingInformation(AllFeed feed, Plugins.DownloadState downloadState)
        {
            if (downloadState == Plugins.DownloadState.InformationDownloaded)
            {
                string timeDownloaded = feed.Items[0].PublishedDate;
                DateTime dateTime = System.DateTime.Parse(timeDownloaded);
                LastUpdate = dateTime;
            }


            this.DownloadState = downloadState;

        }