Esempio n. 1
0
 public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
 {
     if (track.PrimarySource == this && track.Uri.Scheme.StartsWith ("http")) {
         foreach (double percent in database.DownloadTrack ((int)track.ExternalId, track.MimeType, uri.AbsolutePath)) {
             job.DetailedProgress = percent;
         }
     }
 }
Esempio n. 2
0
 public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
 {
     if (track_map.ContainsKey (track.TrackId)) {
         track_map[track.TrackId].Download (uri.LocalPath, delegate (ulong current, ulong total, IntPtr data) {
             job.DetailedProgress = (double) current / total;
             return 0;
         });
     } else {
         throw new Exception ("Error copying track from MTP device");
     }
 }
Esempio n. 3
0
 public virtual void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
 {
     Log.WarningFormat ("CopyTrackTo not implemented for source {0}", this);
 }
 public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
 {
     if (track.PrimarySourceId == DbId) {
         Banshee.IO.File.Copy (track.Uri, uri, false);
     }
 }
Esempio n. 5
0
        private void Reset ()
        {
            lock (queue) {
                if (user_job != null) {
                    user_job.CancelRequested -= OnCancelRequested;
                    user_job.Finished -= OnFinished;
                    user_job.Finish ();
                    user_job = null;
                }

                if (transcoder != null) {
                    transcoder.Finish ();
                    transcoder = null;
                }

                foreach (TranscodeContext context in queue) {
                    context.CancelledHandler ();
                }

                if (transcoding) {
                    current_context.CancelledHandler ();
                    transcoding = false;
                }

                queue.Clear ();
            }
        }
 public override void CopyTrackTo (DatabaseTrackInfo track, SafeUri uri, BatchUserJob job)
 {
     Banshee.IO.File.Copy (track.Uri, uri, false);
 }
Esempio n. 7
0
        protected virtual void DeleteTrackList(CachedList<DatabaseTrackInfo> list)
        {
            is_deleting = true;
            DeleteTrackJob.Total += list.Count;
            var skip_deletion = new List<DatabaseTrackInfo> ();

            // Remove from file system
            foreach (DatabaseTrackInfo track in list) {
                if (track == null) {
                    DeleteTrackJob.Completed++;
                    continue;
                }

                if (DeleteTrackJob.IsCancelRequested) {
                    skip_deletion.Add (track);
                    continue;
                }

                try {
                    DeleteTrackJob.Status = String.Format ("{0} - {1}", track.ArtistName, track.TrackTitle);
                    if (!DeleteTrack (track)) {
                        skip_deletion.Add (track);
                    }
                } catch (Exception e) {
                    Log.Error (e);
                    ErrorSource.AddMessage (e.Message, track.Uri.ToString ());
                }

                DeleteTrackJob.Completed++;
                if (DeleteTrackJob.Completed % 10 == 0 && !DeleteTrackJob.IsFinished) {
                    OnTracksDeleted ();
                }
            }

            if (!DeleteTrackJob.IsFinished || DeleteTrackJob.IsCancelRequested) {
                delete_track_job.Finish ();
            }
            delete_track_job = null;
            is_deleting = false;

            if (skip_deletion.Count > 0) {
                list.Remove (skip_deletion);
                skip_deletion.Clear ();
            }

            // Remove from database
            if (list.Count > 0) {
                ServiceManager.DbConnection.Execute (remove_list_command, DateTime.Now, list.CacheId, list.CacheId);
            }

            ThreadAssist.ProxyToMain (delegate {
                OnTracksDeleted ();
                OnUserNotifyUpdated ();
                OnUpdated ();
            });
        }
Esempio n. 8
0
        protected virtual void AddTrackList(object cached_list)
        {
            CachedList<DatabaseTrackInfo> list = cached_list as CachedList<DatabaseTrackInfo>;
            is_adding = true;
            AddTrackJob.Total += list.Count;

            foreach (DatabaseTrackInfo track in list) {
                if (AddTrackJob.IsCancelRequested) {
                    AddTrackJob.Finish ();
                    IncrementAddedTracks ();
                    break;
                }

                if (track == null) {
                    IncrementAddedTracks ();
                    continue;
                }

                try {
                    AddTrackJob.Status = String.Format ("{0} - {1}", track.ArtistName, track.TrackTitle);
                    AddTrackAndIncrementCount (track);
                } catch (Exception e) {
                    IncrementAddedTracks ();
                    Log.Error (e);
                    ErrorSource.AddMessage (e.Message, track.Uri.ToString ());
                }
            }
            if (!AddTrackJob.IsFinished) {
                AddTrackJob.Finish ();
            }
            add_track_job = null;
            is_adding = false;
        }