private void AddFeed(string uri, string title) { // TODO replace autodownload w/ actual default preference FeedsManager.Instance.FeedManager.CreateFeed(uri, title, FeedAutoDownload.None, 0); source.NotifyUser(); source.UpdateFeedMessages(); }
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); } source = new PodcastSource(); ServiceManager.SourceManager.AddSource(source); InitializeInterface(); var preference = source.PreferencesPage["library-location"]["library-location"] as SchemaPreference <string>; preference.ValueChanged += delegate(Root obj) { feeds_manager.PodcastStorageDirectory = preference.Value; }; ThreadAssist.SpawnFromMain(delegate { 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(String.Format( "UPDATE CoreTracks SET Uri = REPLACE ({0}, ?, ?)" + "WHERE {0} LIKE 'file://%' AND PrimarySourceId = ?", Banshee.Query.BansheeQuery.UriField.Column), 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); ServiceManager.Get <Network> ().StateChanged += OnNetworkStateChanged; }); source.UpdateFeedMessages(); }