コード例 #1
0
 public void LoadApp()
 {
     feedsManager   = new FeedsManager();
     displayManager = new DisplayManager(feedsManager, wb_display, lb_last_updated_at);
     displayManager.UpdateTiles(pn_tiles);
     LoadListBox(ltb_feeds, this.feedsManager.GetFeedsFromConfig().ToArray());
 }
コード例 #2
0
        public void Load()
        {
            DateTime       loadstart   = DateTime.Now;
            List <RssFeed> newRssFeeds = new List <RssFeed>();

            try
            {
                IFeedsManager fs     = new FeedsManager();
                IFeedFolder   folder = (IFeedFolder)fs.GetFolder(Properties.Settings.Default.ImagePathOverride);
                foreach (IFeed feed in CommonFeedListUtils.CommonFeedList(folder))
                {
                    System.Diagnostics.Debug.Print("Found feed {0} with {1} items.",
                                                   feed.Name, ((IFeedsEnum)feed.Items).Count);
                    try
                    {
                        RssFeed rssFeed = RssFeed.FromApi(feed);

                        // Only add this feed if it contains items
                        if (rssFeed != null)
                        {
                            System.Diagnostics.Debug.Print("Feed has {0} items with enclosures.", rssFeed.Items.Count);
                            if (rssFeed.Items.Count > 0)
                            {
                                newRssFeeds.Add(rssFeed);
                            }
                        }
                        else
                        {
                            System.Diagnostics.Debug.Print("Feed is null.");
                        }
                    }
                    catch (System.Runtime.InteropServices.COMException ex)
                    {
                        System.Diagnostics.Debug.Print("Failed to get RSS feed '{0}' from API; skipping feed. Error: {1} ", feed.Name, ex.ToString());
                        // Ignore exception, meaning ignore this feed and continue with next feed.
                    }
                }
            }
            finally
            {
                // Collect garbage so that all the COM objects are released which
                // closes the backing structured storage files.
                GC.Collect();
            }

            if (newRssFeeds.Count == 0)
            {
                // There were no suitable feeds, hence get default feeds from resources.
                System.Diagnostics.Debug.Print("There were no suitable feeds, hence get default feeds from resources.");
                RssFeed rssFeed = RssFeed.FromText(Properties.Resources.DefaultRSSText);
                newRssFeeds.Add(rssFeed);
            }

            this.rssFeeds = newRssFeeds;
            // reset current indexes
            currentFeedIndex = -1;
            currentItemIndex = -1;
            MoveNext();
            lastRefresh = loadstart;
        }
コード例 #3
0
        // Verify that folder exists
        private bool ExistsFolder(string name)
        {
            // This code is encapsulated here because it will cause an exception
            // _as the stack is constructed_ if the Interop.Feeds.dll is not installed properly.
            IFeedsManager fm = new FeedsManager();

            return(fm.ExistsFolder(name));
        }
コード例 #4
0
        public void DelayedInitialize()
        {
            download_manager       = new DownloadManager(2, tmp_download_path);
            download_manager_iface = new DownloadManagerInterface(download_manager);
            download_manager_iface.Initialize();

            feeds_manager = new FeedsManager(ServiceManager.DbConnection, download_manager, null);

            // Migrate data from 0.13.2 podcast tables, if they exist
            MigrateLegacyIfNeeded();

            // Move incomplete downloads to the new cache location
            try {
                MigrateDownloadCache();
            } catch (Exception e) {
                Hyena.Log.Exception("Couldn't migrate podcast download cache", e);
            }

            InitializeInterface();
            feeds_manager.PodcastStorageDirectory   = source.BaseDirectory;
            feeds_manager.FeedManager.ItemAdded    += OnItemAdded;
            feeds_manager.FeedManager.ItemChanged  += OnItemChanged;
            feeds_manager.FeedManager.ItemRemoved  += OnItemRemoved;
            feeds_manager.FeedManager.FeedsChanged += OnFeedsChanged;

            if (DatabaseConfigurationClient.Client.Get <int> ("Podcast", "Version", 0) < 7)
            {
                Banshee.Library.LibrarySource music_lib = ServiceManager.SourceManager.MusicLibrary;
                if (music_lib != null)
                {
                    string  old_path = Path.Combine(music_lib.BaseDirectory, "Podcasts");
                    string  new_path = source.BaseDirectory;
                    SafeUri old_uri  = new SafeUri(old_path);
                    SafeUri new_uri  = new SafeUri(new_path);
                    if (old_path != null && new_path != null && old_path != new_path &&
                        Banshee.IO.Directory.Exists(old_path) && !Banshee.IO.Directory.Exists(new_path))
                    {
                        Banshee.IO.Directory.Move(new SafeUri(old_path), new SafeUri(new_path));
                        ServiceManager.DbConnection.Execute(String.Format(
                                                                "UPDATE {0} SET LocalPath = REPLACE(LocalPath, ?, ?) WHERE LocalPath IS NOT NULL",
                                                                FeedEnclosure.Provider.TableName), old_path, new_path);
                        ServiceManager.DbConnection.Execute(
                            "UPDATE CoreTracks SET Uri = REPLACE(Uri, ?, ?) WHERE Uri LIKE 'file://%' AND PrimarySourceId = ?",
                            old_uri.AbsoluteUri, new_uri.AbsoluteUri, source.DbId);
                        Hyena.Log.DebugFormat("Moved Podcasts from {0} to {1}", old_path, new_path);
                    }
                }
                DatabaseConfigurationClient.Client.Set <int> ("Podcast", "Version", 7);
            }

            ServiceManager.PlayerEngine.ConnectEvent(OnPlayerEvent, PlayerEvent.StateChange);
            ServiceManager.Get <DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;

            RefreshFeeds();

            // Every 10 minutes try to refresh again
            refresh_timeout_id = Application.RunTimeout(1000 * 60 * 10, RefreshFeeds);
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: ijat/byteflood
        private void OperationOnRssItem(object sender, RoutedEventArgs e)
        {
            RssUrlEntry entry = null;

            MenuItem source = (MenuItem)e.Source;

            entry = (RssUrlEntry)source.CommandParameter;

            switch (source.Tag.ToString())
            {
            case "Refresh":
                FeedsManager.ForceUpdate(entry);
                break;

            case "Remove":
                FeedsManager.Remove(entry);
                break;

            case "Edit":
                var query = new UI.AddRSSFeed()
                {
                    Owner = this, Icon = this.Icon, Title = "Edit rss feed"
                };
                query.AllowUrlChange = false;
                query.Url            = entry.Url;
                query.CustomAlias    = entry.Alias;
                query.LoadFilters(entry.Filters.ToArray());
                query.AutoDownload                = entry.AutoDownload;
                query.DownloadPath                = entry.DownloadDirectory;
                query.UpdateIntervalType          = entry.IsCustomtUpdateInterval ? 1 : 0;
                query.ManualUpdateIntervalSeconds = entry.CustomUpdateInterval.TotalSeconds.ToString();

                if (query.ShowDialog() == true)
                {
                    entry.Alias                   = query.CustomAlias;
                    entry.AutoDownload            = query.AutoDownload == true;
                    entry.Filters                 = query.Filters;
                    entry.DownloadDirectory       = string.IsNullOrWhiteSpace(query.DownloadPath) ? App.Settings.DefaultDownloadPath : query.DownloadPath;
                    entry.CustomUpdateInterval    = new TimeSpan(0, 0, query.CustomIntervalSeconds);
                    entry.IsCustomtUpdateInterval = query.UpdateIntervalType == 1;
                    entry.NotifyUpdate();
                    FeedsManager.Save();
                }
                break;

            case "View":
                UI.FeedViewer fv = new UI.FeedViewer()
                {
                    Owner = this, Icon = this.Icon, DataContext = entry
                };
                fv.Show();
                break;
            }
        }
コード例 #6
0
        public MainViewModel()
        {
            this.m_currentItemProperty = new NotifyProperty <FeedViewModel>(this, nameof(CurrentItem));

            IFeedsManager feedsManager = new FeedsManager();
            IFeedFolder   root         = ((IFeedFolder)feedsManager.GetFolder(""));

            FeedFolderViewModel rootWrapper = new FeedFolderViewModel(root);

            this.RootItems = rootWrapper.Subitems;
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: ijat/byteflood
        private async void Commands_AddRssFeed(object sender, ExecutedRoutedEventArgs e)
        {
            var query = new UI.AddRSSFeed()
            {
                Icon = this.Icon, Owner = this
            };

            if (query.ShowDialog() == true)
            {
                if (string.IsNullOrWhiteSpace(query.Url))
                {
                    MessageBox.Show(this, "Url cannot be empty.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (!query.Url.StartsWith("http://") || !query.Url.StartsWith("https://"))
                {
                    query.Url = "http://" + query.Url;
                }

                var rss_entry = new RssUrlEntry()
                {
                    Url                     = query.Url,
                    Alias                   = query.CustomAlias,
                    AutoDownload            = query.AutoDownload == true,
                    Filters                 = query.Filters,
                    DownloadDirectory       = string.IsNullOrWhiteSpace(query.DownloadPath) ? App.Settings.DefaultDownloadPath : query.DownloadPath,
                    IsCustomtUpdateInterval = query.UpdateIntervalType == 1,
                    CustomUpdateInterval    = new TimeSpan(0, 0, query.CustomIntervalSeconds),
                    DefaultSettings         = App.Settings.DefaultTorrentProperties
                };

                if (await rss_entry.TestAsync())
                {
                    FeedsManager.Add(rss_entry);
                }
                else
                {
                    MessageBox.Show(
                        this,
                        "This RSS entry seem to be invalid. \n\n If your internet connection is down, try adding it when it's up again.",
                        "Error",
                        MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #8
0
        public void Dispose()
        {
            lock (sync) {
                if (disposing | disposed)
                {
                    return;
                }
                else
                {
                    disposing = true;
                }
            }

            Application.IdleTimeoutRemove(refresh_timeout_id);
            refresh_timeout_id = 0;

            ServiceManager.PlayerEngine.DisconnectEvent(OnPlayerEvent);
            ServiceManager.Get <DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
            ServiceManager.Get <Network> ().StateChanged -= OnNetworkStateChanged;

            if (download_manager_iface != null)
            {
                download_manager_iface.Dispose();
                download_manager_iface = null;
            }

            if (feeds_manager != null)
            {
                feeds_manager.Dispose();
                feeds_manager = null;
            }

            if (download_manager != null)
            {
                download_manager.Dispose();
                download_manager = null;
            }

            DisposeInterface();

            lock (sync) {
                disposing = false;
                disposed  = true;
            }
        }
コード例 #9
0
        /// <summary>
        ///		Modifica las Urls de vídeo e imagen de las categorías
        /// </summary>
        private void UpdateUrls(CategoryModelCollection categories)
        {
            FeedsManager manager = new FeedsManager();

            // Modifica las Url de las entradas de las categorías
            foreach (CategoryModel category in categories)
            {
                foreach (EntryModel entry in category.Entries)
                {
                    string videoCode = entry.GetUrlVideoCode();

                    if (!string.IsNullOrWhiteSpace(videoCode))
                    {
                        // Modifica la Url de la imagen
                        if (string.IsNullOrWhiteSpace(entry.UrlImage))
                        {
                            entry.UrlImage = manager.GetUriThumbnailYouTube(videoCode)?.ToString();
                        }
                    }
                }
            }
        }
コード例 #10
0
        public void Refresh()
        {
            if (lastRefresh == DateTime.MinValue)
            {
                // we never successfully loaded the CFL, so let's do it again
                Load();
                return;
            }

            IFeedsManager fs = new FeedsManager();

            try
            {
                IFeedFolder folder = (IFeedFolder)fs.GetFolder(Properties.Settings.Default.ImagePathOverride);
                foreach (IFeed feed in CommonFeedListUtils.LastWriteSince(folder, lastRefresh))
                {
                    RssFeed rssFeed = null;
                    try
                    {
                        // This feed was updated or is new, let's get it.
                        rssFeed = RssFeed.FromApi(feed);
                    }
                    catch (System.Runtime.InteropServices.COMException ex)
                    {
                        System.Diagnostics.Debug.Print("Failed to get RSS feed '{0}' from API; skipping feed. Error: {1} ", feed.Name, ex.ToString());
                        continue;  // Skip this feed.
                    }

                    // If the feed has no items with picture enclosures then skip it.
                    if (rssFeed == null || rssFeed.Items.Count == 0)
                    {
                        System.Diagnostics.Debug.Print("Feed '{0}' does not have any picture enclosures; skipping feed.", feed.Name);
                        continue;
                    }

                    // Before we add it let's see if we have an old version of the feed.
                    int index = rssFeeds.FindIndex(delegate(RssFeed f) { return(f.Path == rssFeed.Path); });
                    if (index == -1)
                    {
                        // This must be a new feed, let's append it to the list.
                        rssFeeds.Add(rssFeed);
                    }
                    else
                    {
                        // We have an existing feed with the same path. Let's insert it
                        // where the previous feed is at.
                        rssFeeds.Insert(index, rssFeed);

                        // Remove previous feed.
                        rssFeeds.RemoveAt(index + 1);

                        // Assure that current indexes are not out of bounds.
                        ValidateIndexes();
                    }
                }
            }
            finally
            {
                GC.Collect(); // Release all COM objects and their file handles.
                lastRefresh = DateTime.Now;
            }
        }
コード例 #11
0
 // Verify that folder exists
 private bool ExistsFolder(string name)
 {
     // This code is encapsulated here because it will cause an exception
     // _as the stack is constructed_ if the Interop.Feeds.dll is not installed properly.
     IFeedsManager fm = new FeedsManager();
     return fm.ExistsFolder(name);
 }
コード例 #12
0
        public void Refresh()
        {
            if (lastRefresh == DateTime.MinValue)
            {
                // we never successfully loaded the CFL, so let's do it again
                Load();
                return;
            }

            IFeedsManager fs = new FeedsManager();

            try
            {
                IFeedFolder folder = (IFeedFolder)fs.GetFolder(Properties.Settings.Default.ImagePathOverride);
                foreach (IFeed feed in CommonFeedListUtils.LastWriteSince(folder, lastRefresh))
                {
                    RssFeed rssFeed = null;
                    try
                    {
                        // This feed was updated or is new, let's get it.
                        rssFeed = RssFeed.FromApi(feed);
                    }
                    catch (System.Runtime.InteropServices.COMException ex)
                    {
                        System.Diagnostics.Debug.Print("Failed to get RSS feed '{0}' from API; skipping feed. Error: {1} ", feed.Name, ex.ToString());
                        continue;  // Skip this feed.
                    }

                    // If the feed has no items with picture enclosures then skip it.
                    if (rssFeed == null || rssFeed.Items.Count == 0)
                    {
                        System.Diagnostics.Debug.Print("Feed '{0}' does not have any picture enclosures; skipping feed.", feed.Name);
                        continue;
                    }

                    // Before we add it let's see if we have an old version of the feed.
                    int index = rssFeeds.FindIndex(delegate(RssFeed f) { return (f.Path == rssFeed.Path); });
                    if (index == -1)
                    {
                        // This must be a new feed, let's append it to the list.
                        rssFeeds.Add(rssFeed);
                    }
                    else
                    {
                        // We have an existing feed with the same path. Let's insert it
                        // where the previous feed is at.
                        rssFeeds.Insert(index, rssFeed);

                        // Remove previous feed.
                        rssFeeds.RemoveAt(index + 1);

                        // Assure that current indexes are not out of bounds.
                        ValidateIndexes();
                    }
                }
            }
            finally
            {
                GC.Collect(); // Release all COM objects and their file handles.
                lastRefresh = DateTime.Now;
            }
        }
コード例 #13
0
        public void Load()
        {
            DateTime loadstart = DateTime.Now;
            List<RssFeed> newRssFeeds = new List<RssFeed>();

            try
            {
                IFeedsManager fs = new FeedsManager();
                IFeedFolder folder = (IFeedFolder)fs.GetFolder(Properties.Settings.Default.ImagePathOverride);
                foreach (IFeed feed in CommonFeedListUtils.CommonFeedList(folder))
                {
                    System.Diagnostics.Debug.Print("Found feed {0} with {1} items.",
                        feed.Name, ((IFeedsEnum)feed.Items).Count);
                    try
                    {
                        RssFeed rssFeed = RssFeed.FromApi(feed);

                        // Only add this feed if it contains items
                        if (rssFeed != null)
                        {
                            System.Diagnostics.Debug.Print("Feed has {0} items with enclosures.", rssFeed.Items.Count);
                            if (rssFeed.Items.Count > 0)
                                newRssFeeds.Add(rssFeed);
                        }
                        else
                            System.Diagnostics.Debug.Print("Feed is null.");
                    }
                    catch (System.Runtime.InteropServices.COMException ex)
                    {
                        System.Diagnostics.Debug.Print("Failed to get RSS feed '{0}' from API; skipping feed. Error: {1} ", feed.Name, ex.ToString());
                        // Ignore exception, meaning ignore this feed and continue with next feed.
                    }
                }
            }
            finally
            {
                // Collect garbage so that all the COM objects are released which
                // closes the backing structured storage files.
                GC.Collect();
            }

            if (newRssFeeds.Count == 0)
            {
                // There were no suitable feeds, hence get default feeds from resources.
                System.Diagnostics.Debug.Print("There were no suitable feeds, hence get default feeds from resources.");
                RssFeed rssFeed = RssFeed.FromText(Properties.Resources.DefaultRSSText);
                newRssFeeds.Add(rssFeed);
            }

            this.rssFeeds = newRssFeeds;
            // reset current indexes
            currentFeedIndex = -1;
            currentItemIndex = -1;
            MoveNext();
            lastRefresh = loadstart;
        }