예제 #1
0
        protected void LogError(string path, string msg)
        {
            ThreadAssist.ProxyToMain(delegate {
                ErrorSource error_source = ServiceManager.SourceManager.MusicLibrary.ErrorSource;
                error_source.AddMessage(path, msg);

                Log.Error(path, msg, false);
            });
        }
예제 #2
0
 private void OnTrackTranscodeError(TrackInfo track)
 {
     ErrorSource.AddMessage(Catalog.GetString("Error converting file"), track.Uri.ToString());
     IncrementAddedTracks();
 }
 private void LogError(string path, string msg)
 {
     ErrorSource.AddMessage(path, msg);
     Log.Error(path, msg, false);
 }
예제 #4
0
        private void PerformSyncThreadCycle()
        {
            while (tracks_to_add.Count > 0)
            {
                IpodTrackInfo track = null;
                lock (sync_mutex) {
                    track = tracks_to_add.Dequeue();
                }

                try {
                    track.CommitToIpod(ipod_device);
                    tracks_map[track.TrackId] = track;
                } catch (Exception e) {
                    Log.Exception("Cannot save track to iPod", e);
                }
            }

            // TODO sync updated metadata to changed tracks

            while (tracks_to_remove.Count > 0)
            {
                IpodTrackInfo track = null;
                lock (sync_mutex) {
                    track = tracks_to_remove.Dequeue();
                }

                if (tracks_map.ContainsKey(track.TrackId))
                {
                    tracks_map.Remove(track.TrackId);
                }

                try {
                    if (track.IpodTrack != null)
                    {
                        ipod_device.TrackDatabase.RemoveTrack(track.IpodTrack);
                    }
                } catch (Exception e) {
                    Log.Exception("Cannot remove track from iPod", e);
                }
            }

            // Remove playlists on the device
            List <IPod.Playlist> device_playlists = new List <IPod.Playlist> (ipod_device.TrackDatabase.Playlists);

            foreach (IPod.Playlist playlist in device_playlists)
            {
                if (!playlist.IsOnTheGo)
                {
                    ipod_device.TrackDatabase.RemovePlaylist(playlist);
                }
            }
            device_playlists.Clear();

            if (SupportsPlaylists)
            {
                // Add playlists from Banshee to the device
                foreach (Source child in Children)
                {
                    PlaylistSource from = child as PlaylistSource;
                    if (from != null && from.Count > 0)
                    {
                        IPod.Playlist playlist = ipod_device.TrackDatabase.CreatePlaylist(from.Name);
                        foreach (int track_id in ServiceManager.DbConnection.QueryEnumerable <int> (String.Format(
                                                                                                        "SELECT CoreTracks.TrackID FROM {0} WHERE {1}",
                                                                                                        from.DatabaseTrackModel.ConditionFromFragment, from.DatabaseTrackModel.Condition)))
                        {
                            playlist.AddTrack(tracks_map[track_id].IpodTrack);
                        }
                    }
                }
            }

            try {
                ipod_device.TrackDatabase.SaveStarted         += OnIpodDatabaseSaveStarted;
                ipod_device.TrackDatabase.SaveEnded           += OnIpodDatabaseSaveEnded;
                ipod_device.TrackDatabase.SaveProgressChanged += OnIpodDatabaseSaveProgressChanged;
                ipod_device.Save();
            } catch (InsufficientSpaceException) {
                ErrorSource.AddMessage(Catalog.GetString("Out of space on device"), Catalog.GetString("Please manually remove some songs"));
            } catch (Exception e) {
                Log.Exception("Failed to save iPod database", e);
            } finally {
                ipod_device.TrackDatabase.SaveStarted         -= OnIpodDatabaseSaveStarted;
                ipod_device.TrackDatabase.SaveEnded           -= OnIpodDatabaseSaveEnded;
                ipod_device.TrackDatabase.SaveProgressChanged -= OnIpodDatabaseSaveProgressChanged;
            }
        }