示例#1
0
        public void SetStatus(ConnectionPresenceType status, string message)
        {
            ISimplePresence simplePresence = Bus.Session.GetObject <ISimplePresence> (connectionBusIFace, connectionPath);
//			Properties simplePresenceProperties = Bus.Session.GetObject<Properties> (connectionBusIFace, connectionPath);
//			IDictionary<string, object> lstStatus = (IDictionary<string, object>) simplePresenceProperties.Get("org.freedesktop.Telepathy.Connection.Interface.SimplePresence", "Statuses");

            List <BaseStatus> possibleStatusLst = EmpathyStatus.GetStatusList(status);

            // TODO: utiliser SimplePresence au lieu de Presence
            IPresence presence = Bus.Session.GetObject <IPresence> (connectionBusIFace, connectionPath);
            IDictionary <string, StatusSpec> lstStatus = presence.GetStatuses();

            foreach (BaseStatus oneStatus in possibleStatusLst)
            {
                StatusSpec statusSpec;
                if (lstStatus.TryGetValue(oneStatus.ToString(), out statusSpec))
                {
                    if (statusSpec.MaySetOnSelf)
                    {
                        simplePresence.SetPresence(oneStatus.ToString(), message);
                        return;
                    }
                }
            }
        }