Inheritance: IDisposable
Beispiel #1
0
        internal bool Disconnect(bool logout)
        {
            // Stop currently playing track if its from us.
            try {
                if (ServiceManager.PlayerEngine.CurrentState == Banshee.MediaEngine.PlayerState.Playing)
                {
                    DatabaseTrackInfo track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
                    if (track != null && track.PrimarySource == this)
                    {
                        ServiceManager.PlayerEngine.Close();
                    }
                }
            } catch {}

            connected = false;

            // Remove tracks associated with this source, since we don't want
            // them after we unmap - we'll refetch.
            PurgeTracks();

            if (client != null)
            {
                if (logout)
                {
                    client.Logout();
                }

                client.Dispose();
                client   = null;
                database = null;
            }

            if (database != null)
            {
                try {
                    DaapService.ProxyServer.UnregisterDatabase(database);
                } catch {}
                database.TrackAdded   -= OnDatabaseTrackAdded;
                database.TrackRemoved -= OnDatabaseTrackRemoved;
                database = null;
            }

            List <Source> children = new List <Source> (Children);

            foreach (Source child in children)
            {
                if (child is Banshee.Sources.IUnmapableSource)
                {
                    (child as Banshee.Sources.IUnmapableSource).Unmap();
                }
            }

            ClearChildSources();

            return(true);
        }
Beispiel #2
0
        private void ShowErrorView(DaapErrorType error_type)
        {
            PurgeTracks();
            Reload();
            client = null;
            DaapErrorView error_view = new DaapErrorView(this, error_type);

            error_view.Show();
            Properties.Set <Banshee.Sources.Gui.ISourceContents> ("Nereid.SourceContents", error_view);
            HideStatus();
        }
Beispiel #3
0
        protected override void Run()
        {
            try {
                NativeDaap.Client tmp_client = new NativeDaap.Client(address, port);
                service = new Service(address, port, tmp_client.Name, tmp_client.AuthenticationMethod != AuthenticationMethod.None);
            } catch (WebException) {
                // On error, create a dummy service
                service = new Service(address, port, server, false);
            }

            OnFinished();
        }
Beispiel #4
0
        public override void Activate()
        {
            if (client != null || is_activating)
            {
                return;
            }

            ClearErrorView();

            is_activating = true;
            base.Activate();

            SetStatus(String.Format(Catalog.GetString("Connecting to {0}"), service.Name), false);

            ThreadAssist.Spawn(delegate {
                try {
                    client          = new DAAP.Client(service);
                    client.Updated += OnClientUpdated;

                    if (client.AuthenticationMethod == DAAP.AuthenticationMethod.None)
                    {
                        client.Login();
                    }
                    else
                    {
                        ThreadAssist.ProxyToMain(PromptLogin);
                    }
                } catch (Exception e) {
                    ThreadAssist.ProxyToMain(delegate {
                        ShowErrorView(DaapErrorType.BrokenAuthentication);
                    });
                    Hyena.Log.Exception(e);
                }

                is_activating = false;
            });
        }
Beispiel #5
0
 internal Database(Client client, ContentNode dbNode)
     : this()
 {
     this.client = client;
     Parse (dbNode);
 }
Beispiel #6
0
 private void ShowErrorView(DaapErrorType error_type)
 {
     PurgeTracks ();
     Reload ();
     client = null;
     DaapErrorView error_view = new DaapErrorView (this, error_type);
     error_view.Show ();
     Properties.Set<Banshee.Sources.Gui.ISourceContents> ("Nereid.SourceContents", error_view);
     HideStatus ();
 }
Beispiel #7
0
        internal bool Disconnect(bool logout)
        {
            // Stop currently playing track if its from us.
            try {
                if (ServiceManager.PlayerEngine.CurrentState == Banshee.MediaEngine.PlayerState.Playing) {
                    DatabaseTrackInfo track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
                    if (track != null && track.PrimarySource == this) {
                        ServiceManager.PlayerEngine.Close ();
                    }
                }
            } catch {}

            connected = false;

            // Remove tracks associated with this source, since we don't want
            // them after we unmap - we'll refetch.
            PurgeTracks ();

            if (client != null) {
                if (logout) {
                    client.Logout ();
                }

                client.Dispose ();
                client = null;
                database = null;
            }

            if (database != null) {
                try {
                    DaapService.ProxyServer.UnregisterDatabase (database);
                } catch {}
                database.TrackAdded -= OnDatabaseTrackAdded;
                database.TrackRemoved -= OnDatabaseTrackRemoved;
                database = null;
            }

            List<Source> children = new List<Source> (Children);
            foreach (Source child in children) {
                if (child is Banshee.Sources.IUnmapableSource) {
                    (child as Banshee.Sources.IUnmapableSource).Unmap ();
                }
            }

            ClearChildSources ();

            return true;
        }
Beispiel #8
0
        public override void Activate()
        {
            if (client != null || is_activating) {
                return;
            }

            ClearErrorView ();

            is_activating = true;
            base.Activate ();

            SetStatus (String.Format (Catalog.GetString ("Connecting to {0}"), service.Name), false);

            ThreadAssist.Spawn (delegate {
                try {
                    client = new DAAP.Client (service);
                    client.Updated += OnClientUpdated;

                    if (client.AuthenticationMethod == DAAP.AuthenticationMethod.None) {
                        client.Login ();
                    } else {
                        ThreadAssist.ProxyToMain (PromptLogin);
                    }
                } catch(Exception e) {
                    ThreadAssist.ProxyToMain (delegate {
                        ShowErrorView (DaapErrorType.BrokenAuthentication);
                    });
                    Log.Error (e);
                }

                is_activating = false;
            });
        }
        protected override void Run()
        {
            try {
                NativeDaap.Client tmp_client = new NativeDaap.Client (address, port);
                service = new Service (address, port, tmp_client.Name, tmp_client.AuthenticationMethod != AuthenticationMethod.None);
            } catch (WebException) {
                // On error, create a dummy service
                service = new Service (address, port, server, false);
            }

            OnFinished ();
        }