예제 #1
0
        public void DelayedInitialize()
        {
            // FIXME: Support sources other than the music and the video library (e.g. podcasts, audiobooks, etc)
            // The SourceWatcher uses LibraryImportManager which is specific to music/video.
            // To support other sources we need a separate importer for each of them.

            /*
             * ServiceManager.SourceManager.SourceAdded += OnSourceAdded;
             * ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
             *
             * foreach (var library in ServiceManager.SourceManager.FindSources<LibrarySource> ()) {
             *  AddLibrary (library);
             * }
             */
            AddLibrary(ServiceManager.SourceManager.MusicLibrary);

            if (ServiceManager.SourceManager.MusicLibrary.Count == 0)
            {
                new Banshee.Collection.RescanPipeline(ServiceManager.SourceManager.MusicLibrary, tracks => {
                    string msg = String.Format(
                        Catalog.GetPluralString(
                            // singular form unused b/c we know it's > 1, but we still need GetPlural
                            "Library Watcher extension just detected an action that would trigger the removal of one track from your music library.",
                            "Library Watcher extension just detected an action that would trigger the removal of {0} tracks from your music library.",
                            tracks),
                        tracks);

                    return(TrackActions.ConfirmRemove(msg));
                });
            }
        }
예제 #2
0
        private void RateLimitedSync()
        {
            syncing = true;

            bool sync_playlists = false;

            if (dap.SupportsPlaylists)
            {
                lock (library_syncs_mutex) {
                    foreach (DapLibrarySync library_sync in library_syncs)
                    {
                        if (library_sync.Library.SupportsPlaylists)
                        {
                            sync_playlists = true;
                            break;
                        }
                    }
                }
            }

            if (sync_playlists)
            {
                dap.RemovePlaylists();
            }

            foreach (DapLibrarySync library_sync in Libraries)
            {
                try {
                    library_sync.Sync();
                } catch (DapLibrarySync.PossibleUserErrorException e) {
                    var    tracks_to_remove = e.TracksToRemove;
                    string msg = String.Format(
                        Catalog.GetPluralString(
                            // singular form unused b/c we know it's > 1, but we still need GetPlural
                            "The sync operation will remove one track from your device.",
                            "The sync operation will remove {0} tracks from your device.",
                            tracks_to_remove),
                        tracks_to_remove);

                    if (TrackActions.ConfirmRemove(msg))
                    {
                        library_sync.Sync(true);
                    }
                }
            }

            if (sync_playlists)
            {
                dap.SyncPlaylists();
            }

            syncing = false;
        }