Example #1
0
        public virtual void Announce(string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }


            try {
                foreach (Account account in locator.GetConnections())
                {
                    object obj = DBusUtility.GetProperty(account.BusType,
                                                         Constants.ACCOUNTMANAGER_IFACE,
                                                         account.AccountObjectPath,
                                                         Constants.ACCOUNT_IFACE,
                                                         "CurrentPresence");
                    SimplePresence presence = (SimplePresence)System.Convert.ChangeType(obj, typeof(SimplePresence));

                    presence.StatusMessage = message;
                    DBusUtility.SetProperty(account.BusType,
                                            Constants.ACCOUNTMANAGER_IFACE,
                                            account.AccountObjectPath,
                                            Constants.ACCOUNT_IFACE,
                                            "RequestedPresence",
                                            presence);
                }
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
            }
        }
    public void GetPresences(uint[] @contacts, out IDictionary <uint, SimplePresence> @presence)
    {
        Dictionary <uint, SimplePresence> presences = new Dictionary <uint, SimplePresence>();

        presences[2] = new SimplePresence {
            Type = ConnectionPresenceType.Offline, Status = "offline", StatusMessage = ""
        };
        presence = presences;
    }
Example #3
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;
        }
	public void GetPresences (uint[] @contacts, out IDictionary<uint,SimplePresence> @presence)
	{
		Dictionary<uint,SimplePresence> presences = new Dictionary<uint,SimplePresence>();
		presences[2] = new SimplePresence { Type = ConnectionPresenceType.Offline, Status = "offline", StatusMessage = "" };
		presence = presences;
	}