예제 #1
0
        public void OnDatabaseTrackAdded(object o, DAAP.TrackArgs args)
        {
            DaapTrackInfo track = new DaapTrackInfo(args.Track, this);

            track.Save();
        }
예제 #2
0
        private void OnClientUpdated(object o, EventArgs args)
        {
            try {
                if (database == null && client.Databases.Count > 0) {
                    database = client.Databases[0];
                    DaapService.ProxyServer.RegisterDatabase (database);
                    database.TrackAdded += OnDatabaseTrackAdded;
                    database.TrackRemoved += OnDatabaseTrackRemoved;

                    SetStatus (String.Format (Catalog.GetPluralString (
                        "Loading {0} track", "Loading {0} tracks", database.TrackCount),
                        database.TrackCount), false
                    );

                    // Notify (eg reload the source before sync is done) at most 5 times
                    int notify_every = Math.Max (250, (database.Tracks.Count / 4));
                    notify_every -= notify_every % 250;

                    int count = 0;
                    DaapTrackInfo daap_track = null;

                    HyenaSqliteConnection conn = ServiceManager.DbConnection;
                    conn.BeginTransaction ();
                    foreach (DAAP.Track track in database.Tracks) {
                        daap_track = new DaapTrackInfo (track, this);

                        // Only notify once in a while because otherwise the source Reloading slows things way down
                        if (++count % notify_every == 0) {
                            conn.CommitTransaction ();
                            daap_track.Save (true);
                            conn.BeginTransaction ();
                        } else {
                            daap_track.Save (false);
                        }
                    }
                    conn.CommitTransaction ();

                    // Save the last track once more to trigger the NotifyTrackAdded
                    if (daap_track != null) {
                        daap_track.Save ();
                    }

                    SetStatus (Catalog.GetString ("Loading playlists"), false);
                    AddPlaylistSources ();
                    connected = true;
                    Reload ();
                    HideStatus ();
                }

                Name = client.Name;

                UpdateIcon ();
                OnUpdated ();
            } catch (Exception e) {
                Log.Error ("Caught exception while loading daap share", e);
                ThreadAssist.ProxyToMain (delegate {
                    HideStatus ();
                    ShowErrorView (DaapErrorType.UserDisconnect);
                });
            }
        }
예제 #3
0
        private void OnClientUpdated(object o, EventArgs args)
        {
            try {
                if (database == null && client.Databases.Count > 0)
                {
                    database = client.Databases[0];
                    DaapService.ProxyServer.RegisterDatabase(database);
                    database.TrackAdded   += OnDatabaseTrackAdded;
                    database.TrackRemoved += OnDatabaseTrackRemoved;

                    SetStatus(String.Format(Catalog.GetPluralString(
                                                "Loading {0} track", "Loading {0} tracks", database.TrackCount),
                                            database.TrackCount), false
                              );

                    // Notify (eg reload the source before sync is done) at most 5 times
                    int notify_every = Math.Max(250, (database.Tracks.Count / 4));
                    notify_every -= notify_every % 250;

                    int           count      = 0;
                    DaapTrackInfo daap_track = null;

                    HyenaSqliteConnection conn = ServiceManager.DbConnection;
                    conn.BeginTransaction();
                    foreach (DAAP.Track track in database.Tracks)
                    {
                        daap_track = new DaapTrackInfo(track, this);

                        // Only notify once in a while because otherwise the source Reloading slows things way down
                        if (++count % notify_every == 0)
                        {
                            conn.CommitTransaction();
                            daap_track.Save(true);
                            conn.BeginTransaction();
                        }
                        else
                        {
                            daap_track.Save(false);
                        }
                    }
                    conn.CommitTransaction();

                    // Save the last track once more to trigger the NotifyTrackAdded
                    if (daap_track != null)
                    {
                        daap_track.Save();
                    }

                    SetStatus(Catalog.GetString("Loading playlists"), false);
                    AddPlaylistSources();
                    connected = true;
                    Reload();
                    HideStatus();
                }

                Name = client.Name;

                UpdateIcon();
                OnUpdated();
            } catch (Exception e) {
                Hyena.Log.Exception("Caught exception while loading daap share", e);
                ThreadAssist.ProxyToMain(delegate {
                    HideStatus();
                    ShowErrorView(DaapErrorType.UserDisconnect);
                });
            }
        }
예제 #4
0
 public void OnDatabaseTrackAdded(object o, DAAP.TrackArgs args)
 {
     DaapTrackInfo track = new DaapTrackInfo (args.Track, this);
     track.Save ();
 }