Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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);
            }

            source = new PodcastSource ();
            ServiceManager.SourceManager.AddSource (source);

            InitializeInterface ();

            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 (
                                "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);

                ServiceManager.Get<Network> ().StateChanged += OnNetworkStateChanged;
            });

            source.UpdateFeedMessages ();
        }