public void Dispose()
        {
            lock (sync) {
                if (manager != null) {
                    manager.Group.Started -= OnManagerStartedHandler;
                    manager.Group.Stopped -= OnManagerStoppedHandler;
                    manager.Group.ProgressChanged -= OnManagerProgressChangedHandler;
                    manager.Group.StatusChanged -= OnManagerStatusChangedHandler;

                    manager = null;
                }
            }

            Gtk.Application.Invoke (delegate {
                lock (sync) {
                    if (downloadJob != null) {
                        downloadJob.CancelRequested -= OnCancelRequested;
                        downloadJob.Finish ();
                        downloadJob = null;
                        //SourceManager.RemoveSource (downloadSource);
                        //downloadSource = null;
                    }
                }
            });
        }
        public DownloadManagerInterface(DownloadManager manager)
        {
            if (manager == null) {
                throw new ArgumentNullException ("manager");
            }

            this.manager = manager;
        }
Exemple #3
0
        public EnclosureManager(DownloadManager downloadManager)
        {
            download_manager = downloadManager;
            download_manager.Tasks.TaskAdded += OnDownloadTaskAdded;
            download_manager.Tasks.TaskRemoved += OnDownloadTaskRemoved;
            download_manager.Group.TaskStatusChanged += OnDownloadTaskStatusChangedHandler;

            queued_downloads = new Dictionary<FeedEnclosure, HttpFileDownloadTask> ();

            download_handle = new ManualResetEvent (true);
        }
Exemple #4
0
        public FeedsManager(HyenaSqliteConnection connection, DownloadManager downloadManager, string podcast_base_dir)
        {
            // Hack to work around Feeds being needy and having to call all our internal methods, instead
            // of us just listening for their events.
            Instance = this;
            this.connection = connection;
            this.podcast_base_dir = podcast_base_dir;

            feed_manager = new FeedManager ();
            enclosure_manager = new EnclosureManager (downloadManager);

            Feed.Init ();
            FeedItem.Init ();
            FeedEnclosure.Init ();

            command_queue = new AsyncCommandQueue ();
        }
        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;
            }
        }
        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 ();
        }
Exemple #7
0
        public void Dispose(AutoResetEvent disposeHandle)
        {
            disposed = true;

            List<HttpFileDownloadTask> tasks = null;

            lock (sync) {
                if (queued_downloads.Count > 0) {
                    tasks = new List<HttpFileDownloadTask> (queued_downloads.Values);
                }
            }

            if (tasks != null) {
                foreach (HttpFileDownloadTask t in tasks) {
                    t.Stop ();
                }

                download_handle.WaitOne ();
            }

            if (download_handle != null) {
                download_handle.Close ();
                download_handle = null;
            }

            if (download_manager != null) {
                download_manager.Tasks.TaskAdded -= OnDownloadTaskAdded;
                download_manager.Tasks.TaskRemoved -= OnDownloadTaskRemoved;
                download_manager = null;
            }
        }
 public void Dispose()
 {
     ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
     download_manager.Dispose ();
     download_manager_iface.Dispose ();
     download_manager = null;
     download_manager_iface = null;
 }
        public void Initialize()
        {
            tasks = new Dictionary<string, HttpFileDownloadTask> ();

            import_manager = new LibraryImportManager (true);
            import_manager.ImportResult += HandleImportResult;

            if (download_manager == null)
                download_manager = new DownloadManager (2, tmp_download_path);

            if (download_manager_iface == null) {
                download_manager_iface = new DownloadManagerInterface (download_manager);
                download_manager_iface.Initialize ();
            }

            ServiceManager.Get<DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
        }