private void OnActivityReady(object sender, EventArgs args)
        {
            DBusActivity activity = sender as DBusActivity;

            Hyena.Log.DebugFormat("ContactSource OnReady for {0}", Contact.Name);

            // TODO decide if this is the right place for this
            // one contact may not stream, so the tube may not be
            // necessary. But, the OnReady and OnPermissionRequired events
            // only get raised for one contact.
            RequestStreamTube();

            if (activity.InitiatorHandle != Contact.Connection.SelfHandle)
            {
                RegisterActivityServices();

                // tube was not ready at the time user clicked source
                // so it was put into waiting state
                if (CurrentState == State.Waiting)
                {
                    LoadData();
                }
            }
            else
            {
                RegisterActivityServices(false);
                LoadData();
            }
        }
示例#2
0
        public override void Queue()
        {
            IContactSource source = ServiceManager.SourceManager.ActiveSource as IContactSource;

            if (!source.IsDownloadingAllowed)
            {
                return;
            }

            DBusActivity activity = Contact.DispatchManager.Get <DBusActivity> (Contact, MetadataProviderService.BusName);

            if (activity != null)
            {
                IMetadataProviderService service = activity.GetDBusObject <IMetadataProviderService> (MetadataProviderService.BusName, MetadataProviderService.ObjectPath);
                if (service != null)
                {
                    base.Queue();
                    ThreadAssist.Spawn(delegate {
                        lock (sync) {
                            try {
                                service.DownloadFile(long.Parse(Key.Name), "audio/mpeg");
                            }
                            catch (Exception e) {
                                Log.Warning(e);
                            }
                        }
                    });
                }
            }
        }
示例#3
0
        protected override void ProcessNewChannel(string object_path,
                                                  uint initiator_handle,
                                                  uint target_handle,
                                                  ChannelDetails c)
        {
            string  service_name = (string)c.Properties[Constants.CHANNEL_TYPE_DBUSTUBE + ".ServiceName"];
            Contact contact      = Connection.Roster.GetContact(target_handle);

            DBusTubeChannel tube = null;

            try {
                tube = new DBusTubeChannel(this.Connection,
                                           object_path,
                                           initiator_handle,
                                           target_handle,
                                           service_name);

                DBusActivity    activity = new DBusActivity(contact, tube);
                DispatchManager dm       = Connection.DispatchManager;
                dm.Add(contact, activity.Service, activity, false);
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
                if (tube != null)
                {
                    tube.Dispose();
                }
            }
        }
示例#4
0
        public PlaylistProvider(DBusActivity activity, int id) : base()
        {
            lock (class_lock) {
                instance_count++;
                myindex = instance_count;
            }

            //myservice = service;
            this.activity = activity;
            Id            = id;
        }
        public MetadataProvider(DBusActivity activity, LibraryType type) : base()
        {
            lock (class_lock) {
                instance_count++;
                myindex = instance_count;
            }

            //this.myservice = service;
            this.activity = activity;
            this.Id       = (int)type;
        }
示例#6
0
        public MetadataProviderService (DBusActivity activity)
        {
            if (activity == null) {
                throw new ArgumentNullException ("activity");
            }

            this.activity = activity;

            ContactContainerSource.DownloadingAllowedChanged += (o, a) => OnDownloadingAllowedChanged (DownloadsAllowed ());
            ContactContainerSource.StreamingAllowedChanged += (o, a) => OnStreamingAllowedChanged (StreamingAllowed ());
        }
示例#7
0
        public MetadataProviderService(DBusActivity activity)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }

            this.activity = activity;

            ContactContainerSource.DownloadingAllowedChanged += (o, a) => OnDownloadingAllowedChanged(DownloadsAllowed());
            ContactContainerSource.StreamingAllowedChanged   += (o, a) => OnStreamingAllowedChanged(StreamingAllowed());
        }
        public PlaylistProvider(DBusActivity activity, int id)
            : base()
        {
            lock (class_lock) {
                instance_count++;
                myindex = instance_count;
            }

            //myservice = service;
            this.activity = activity;
            Id = id;
        }
        private void OnActivityResponseRequired(object sender, EventArgs args)
        {
            DBusActivity activity = sender as DBusActivity;

            Hyena.Log.DebugFormat("OnActivityResponseRequired from {0} for {1}", activity.Contact.Handle, activity.Contact.Name);

            if (activity.InitiatorHandle != Contact.Connection.SelfHandle)
            {
                Hyena.Log.DebugFormat("{0} handle {1} accepting tube from ContactSource", Contact.Name, Contact.Handle);
                OnResponseRequired(EventArgs.Empty);
            }
        }
        public MetadataProvider(DBusActivity activity, LibraryType type)
            : base()
        {
            lock (class_lock) {
                instance_count++;
                myindex = instance_count;
            }

            //this.myservice = service;
            this.activity = activity;
            this.Id = (int) type;
        }
        private void OnDispatched(object sender, EventArgs args)
        {
            Hyena.Log.Debug("TubeManager.OnDispatched:");

            DBusActivity activity = sender as DBusActivity;

            if (IsActivityMatch(activity))
            {
                Hyena.Log.Debug("Registering event handlers for dispatched activity...");
                activity.ResponseRequired += OnActivityResponseRequired;
                activity.Ready            += OnActivityReady;
                activity.Closed           += OnActivityClosed;

                CurrentActivity = activity;
            }
        }
        private void OnCancelBrowseRequest(object o, EventArgs args)
        {
            // FIXME https://bugs.freedesktop.org/show_bug.cgi?id=22337
            ContactSource source = ServiceManager.SourceManager.ActiveSource as ContactSource;

            if (source != null)
            {
                Contact      contact  = source.Contact;
                DBusActivity activity = contact.DispatchManager.Get <DBusActivity> (contact, MetadataProviderService.BusName);

                if (activity != null)
                {
                    if (activity.State == ActivityState.RemotePending)
                    {
                        activity.Close();
                    }
                }
            }
        }
        private void OnActivityClosed(object sender, EventArgs args)
        {
            DBusActivity activity = sender as DBusActivity;

            ResetState();

            if (activity.InitiatorHandle == Contact.Connection.SelfHandle)
            {
                StopStreaming(Contact);

                // the tube was closed before the library was fully downloaded
                // this seems to occur randomly
                if (!download_monitor.ProcessingFinished())
                {
                    OnError(new TubeManagerErrorEventArgs(ErrorReason.ClosedBeforeDownloaded));
                }
            }

            OnClosed(EventArgs.Empty);
            UnregisterHandlers();
        }
        protected override void ProcessNewChannel(string object_path,
                                                   uint initiator_handle,
                                                   uint target_handle,
                                                   ChannelDetails c)
        {
            string service_name = (string) c.Properties[Constants.CHANNEL_TYPE_DBUSTUBE + ".ServiceName"];
            Contact contact = Connection.Roster.GetContact (target_handle);

            DBusTubeChannel tube = null;
            try {
                tube = new DBusTubeChannel (this.Connection,
                                            object_path,
                                            initiator_handle,
                                            target_handle,
                                            service_name);

                DBusActivity activity = new DBusActivity (contact, tube);
                DispatchManager dm = Connection.DispatchManager;
                dm.Add (contact, activity.Service, activity, false);
            }
            catch (Exception e) {
                Console.WriteLine (e.ToString ());
                if (tube != null) {
                    tube.Dispose ();
                }
            }
        }
示例#15
0
 public MetadataProviderService (DBusActivity activity, bool permission) : this (activity)
 {
     this.permission_granted = permission;
 }
示例#16
0
 public MetadataProviderService(DBusActivity activity, bool permission) : this(activity)
 {
     this.permission_granted = permission;
 }
 private bool IsActivityMatch(DBusActivity activity)
 {
     return(activity != null &&
            activity.Contact.Equals(Contact) &&
            activity.Service.Equals(MetadataProviderService.BusName));
 }