Ejemplo n.º 1
0
        // loads the feed
        public Feed(RssFeed feed)
        {
            this.name = feed.Channel.Title;
            this.url = feed.URL;
            this.etag = feed.ETag;
            this.last_modified = feed.LastModified;

            for (int i=feed.Channel.Items.Count-1; i>=0; i--)
                items.Add (new Item (feed.Channel.Items [i]));

            UpdateStatus ();
        }
Ejemplo n.º 2
0
        // load the feed
        void loadFeed()
        {
            feed = null;

            try {
                feed = new RssFeed (custom_url.Text, null, null);

                if (feed.Channel != null)
                {
                    loading = false;
                    Application.Invoke (delegate{ this.Destroy (); });
                    retVal = 1;
                    return;
                }
            }
            catch (Exception e)
            {
                parent.Fuse.ThrowWarning ("News.loadFeed:: Could not load the feed - " + custom_url.Text, e.ToString ());
            }

            failRespond ();
        }
Ejemplo n.º 3
0
 // return a value indicating that the loading failed
 void failRespond()
 {
     feed = null;
     loading = false;
     Application.Invoke (delegate{ this.Destroy (); });
     retVal = 2;
 }
Ejemplo n.º 4
0
        // adds the new feed items
        void addNewItems(Feed feed, RssFeed rss_feed)
        {
            // only add in new items. backwards
            for (int i=rss_feed.Channel.Items.Count-1; i>=0; i--)
            {
                RssItem rss_item = rss_feed.Channel.Items [i];

                bool exists = false;
                foreach (Item item in feed.Items)
                    if (item.Title == rss_item.Title && item.Url == rss_item.Link && item.GUID == rss_item.Guid && item.PubDate == rss_item.PubDate)
                        exists = true;

                // the list doesnt have the news item
                if (!exists)
                {
                    Item new_item = new Item (rss_item);
                    new_item.IsNew = true;

                    // add in the new item
                    Application.Invoke (delegate {
                        feed.Items.Add (new_item);
                        parent.DataManager.AddItem (feed, new_item);
                    });
                }
            }

            // update the feed
            Application.Invoke (delegate {
                feed.UpdateStatus ();
                parent.DataManager.UpdateFeed (feed);
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Refreshes the specified news feed.
        /// </summary>
        public void Refresh(Feed feed)
        {
            feed.Updating = true;
            Application.Invoke (delegate{ news_tree.QueueDraw (); });

            //clear new item count
            foreach (Item item in feed.Items)
                item.IsNew = false;

            //update feed
            try
            {
                RssFeed rss_feed = new RssFeed (feed.Url, feed.ETag, feed.LastModified);

                if (rss_feed.Channel != null)
                    addNewItems (feed, rss_feed);

            }
            catch (Exception e)
            {
                parent.Fuse.ThrowWarning ("News.Refresh:: Could not update the feed - " + feed.Url, e.ToString ());
            }

            feed.Updating = false;

            //update view
            Application.Invoke (delegate{

                news_tree.QueueDraw ();

                TreeIter iter;
                if (news_tree.Selection.GetSelected (out iter))
                {
                    Feed node = (Feed) news_store.GetValue (iter, 0);
                    if (node.Url == feed.Url)
                        news_viewer.Refresh ();
                }

            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Adds a feed into the news store.
        /// </summary>
        public void AddFeed(RssFeed rss_feed)
        {
            Feed feed = new Feed (rss_feed);

            if (news_store.IterNChildren () > 0)
                news_store.AppendValues (new Feed ("ROW_SEP", "", "", "", false));

            news_store.AppendValues (feed);
            parent.DataManager.AddFeed (feed);
        }