protected internal Avatar(Contact contact)
            : this()
        {
            this.contact = contact;

            avatars = DBusUtility.GetProxy <IAvatars> (Connection.Bus, Connection.BusName, Connection.ObjectPath);
        }
Exemple #2
0
        public Contact(UInt32 contactUInt, Account account)
        {
            ContactUInt = contactUInt;
            Account     = account;

            IContacts       contacts             = Bus.Session.GetObject <IContacts> (Account.connectionBusIFace, Account.connectionPath);
            ISimplePresence presence             = Bus.Session.GetObject <ISimplePresence> (Account.connectionBusIFace, Account.connectionPath);
            IAvatars        avatars              = Bus.Session.GetObject <IAvatars> (Account.connectionBusIFace, Account.connectionPath);
            Properties      connectionProperties = Bus.Session.GetObject <Properties> (Account.connectionBusIFace, Account.connectionPath);

            // TODO: géré les protocols sans IAvatars
            IDictionary <uint, string> tokens = avatars.GetKnownAvatarTokens(new uint[] { ContactUInt });
            string strTmp = "";

            if (tokens.TryGetValue(contactUInt, out strTmp) && strTmp.Length > 0)
            {
                // ajout du préfix "_3" si le premier token commence par un nombre
                if (Regex.IsMatch(strTmp.Substring(0, 1), "[0-9]"))
                {
                    strTmp = "_3" + strTmp;
                }
            }
            AvatarToken = strTmp;
            SimplePresence sTmp;

            presence.GetPresences(new uint[] { ContactUInt }).TryGetValue(ContactUInt, out sTmp);
            SimplePresence = sTmp;

            IDictionary <string, object> tmp;

            string[] itf = (string[])connectionProperties.Get(EmpathyPlugin.CONNECTION_CONTACT_IFACE, "ContactAttributeInterfaces");
            // FIXME: cette interface fait planter DBus avec MSN, on remet un interface bidon
            int idx = Array.IndexOf(itf, EmpathyPlugin.CONNECTION_CAPABILITIES_IFACE);

            if (idx != -1)
            {
                itf[idx] = EmpathyPlugin.CONNECTION_IFACE;
            }

            IDictionary <uint, IDictionary <string, object> > allAttributes =
                contacts.GetContactAttributes(new uint[] { ContactUInt }, itf, false);

            allAttributes.TryGetValue(ContactUInt, out tmp);
            Attributes = tmp;
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (avatars != null)
                {
                    try {
                        avatars.AvatarRetrieved -= OnAvatarRetrieved;
                    }
                    catch (Exception) {}
                }

                Clear();

                avatars = null;
                contact = null;
            }
        }
        internal protected Avatar(Contact contact) : this()
        {
            this.contact = contact;

            avatars = DBusUtility.GetProxy <IAvatars> (Connection.Bus, Connection.BusName, Connection.ObjectPath);
        }