public ContactPlaylistSource(IDictionary <string, object> [] playlist, string name, ContactSource parent)
            : this(name, parent)
        {
            if (playlist == null) {
                throw new ArgumentNullException ("playlist");
            }

            AddTracks (playlist);
        }
        public ContactTrackInfo(IDictionary <string, object> track, ContactSource source)
            : this()
        {
            if (track == null) {
                throw new ArgumentNullException ("track");
            }
            else if (source == null) {
                throw new ArgumentNullException ("source");
            }

            //TimeSpan = double
            //DateTime = long
            //Uri = string

            if (track.ContainsKey ("TrackId")) {
                this.ExternalId = (long) (int) track["TrackId"];    // needed for playlists
            } else {
                ExternalId = -1;
            }

            MediaAttributes = TrackMediaAttributes.AudioStream | TrackMediaAttributes.Music;

            // dictionary key will match up to keyValuePair key = ExportName
            // of ExportableAttribute
            foreach (KeyValuePair<string, PropertyInfo> iter in GetExportableProperties (typeof (TrackInfo))) {
                try {
                    PropertyInfo property = iter.Value;
                    Type type = property.PropertyType;

                    if (track.ContainsKey (iter.Key) && property.CanWrite) {
                        if (type.Equals (typeof (DateTime))) {
                            property.SetValue (this, new DateTime ((long) track[iter.Key]), null);
                        } else if (type.Equals (typeof (TimeSpan))) {
                            property.SetValue (this, TimeSpan.FromSeconds ((double) track[iter.Key]), null);
                        } else if (type.Equals (typeof (SafeUri))) {
                            property.SetValue (this, new SafeUri ((string) track[iter.Key]), null);
                        } else if (type.Equals (typeof (TrackMediaAttributes))) {
                            // ignoring
                        } else {
                            property.SetValue (this, Convert.ChangeType (track[iter.Key], type), null);
                        }
                    }

                } catch (Exception e) {
                    Log.Exception (e);
                }
            }

            PrimarySource = source;
            remote_path = LocalPath ?? String.Empty;

            string ext = Path.GetExtension (LocalPath);

            Uri = new SafeUri (String.Format (
                "{0}{1}/{2}", TelepathyService.ProxyServer.HttpBaseAddress, this.ExternalId, ext.Substring (1)));
        }
        public ContactPlaylistSource(string name, ContactSource parent)
            : base(name, parent)
        {
            if (parent == null) {
                throw new ArgumentNullException ("parent");
            }

            this.parent = parent;
            Save ();
        }
        public ContactTrackInfo(DatabaseTrackInfo track, ContactSource source)
            : this()
        {
            if (track == null) {
                throw new ArgumentNullException ("track");
            }
            else if (source == null) {
                throw new ArgumentNullException ("source");
            }

            this.TrackId = track.TrackId;
            this.ExternalId = track.ExternalId;
            this.AlbumTitle = track.AlbumTitle;
            this.ArtistName = track.ArtistName;
            this.TrackNumber = track.TrackNumber;
            this.TrackTitle = track.TrackTitle;
            this.Uri = track.Uri;

            PrimarySource = source;
        }
        private void AddContactSource (Contact contact)
        {
            if (contact.SupportedChannels.GetChannelInfo <DBusTubeChannelInfo> (MetadataProviderService.BusName) != null) {
                ContactSource source = new ContactSource (contact);
                container.AddChildSource (source);
                source_map[contact.Connection.AccountObjectPath].Add (contact, source);
            }

            contact.ContactServicesChanged += OnContactServicesChanged;
        }