Esempio n. 1
0
        public void SetPresence(PresenceStatus status, Capabilities caps, string strImageHash)
        {
            PresenceMessage pres = new PresenceMessage(null);

            pres.From           = XMPPClient.JID;
            pres.To             = null;
            pres.PresenceStatus = status;
            pres.Capabilities   = caps;

            if ((strImageHash != null) && (strImageHash.Length > 0))
            {
                pres.VCardUpdate           = new VCardUpdate();
                pres.VCardUpdate.PhotoHash = strImageHash;
            }
            XMPPClient.SendObject(pres);
        }
Esempio n. 2
0
        public void SetPresence(PresenceMessage pres)
        {
            /// Hack for now to show who can do audio
            ///
            bool bCanDoAudio         = false;
            bool IsKnownGoogleClient = false;

            if (pres.Capabilities != null)
            {
                if (pres.Capabilities.Extensions != null)
                {
                    if (pres.Capabilities.Extensions.IndexOf("voice-v1") >= 0)
                    {
                        bCanDoAudio = true;
                    }
                }

                if (pres.Capabilities.Node != null)
                {
                    if (pres.Capabilities.Node == "http://www.android.com/gtalk/client/caps2")
                    {
                        IsKnownGoogleClient = true;
                    }
                    else if (pres.Capabilities.Node == "http://talkgadget.google.com/client/caps")
                    {
                        IsKnownGoogleClient = true;
                    }
                }
            }

            if ((pres.From.Resource != null) && (pres.From.Resource.Length > 0))
            {
                RosterItemPresenceInstance instance = FindInstance(pres.From);
                if (instance != null)
                {
                    instance.Presence = pres.PresenceStatus;
                    if (pres.PresenceStatus.PresenceType == PresenceType.unavailable)
                    {
                        //lock (m_lockClientInstances)
                        //{
                        m_listClientInstances.Remove(instance);
                        //}

                        FirePropertyChanged("ClientInstances");
                        FirePropertyChanged("Name");
                    }
                }
                else
                {
                    instance                     = new RosterItemPresenceInstance(pres.From);
                    instance.Presence            = pres.PresenceStatus;
                    instance.CanClientDoAudio    = bCanDoAudio;
                    instance.IsKnownGoogleClient = IsKnownGoogleClient;
                    //lock (m_lockClientInstances)
                    //{
                    m_listClientInstances.Add(instance);
                    //}
                    FirePropertyChanged("ClientInstances");
                    FirePropertyChanged("Name");
                }
            }


            /// Get the precense of the most available and latest client instance
            ///
            PresenceStatus beststatus = pres.PresenceStatus;

            if (pres.PresenceStatus.PresenceType != PresenceType.available)
            {
                RosterItemPresenceInstance[] instances = null;
                lock (m_lockClientInstances)
                {
                    foreach (RosterItemPresenceInstance instance in m_listClientInstances)
                    {
                        if (instance.Presence.PresenceType == PresenceType.available)
                        {
                            beststatus = instance.Presence;
                            break;
                        }
                    }
                }
            }

            Presence = beststatus;


            //System.Diagnostics.Debug.WriteLine(item.ToString());
            XMPPClient.FireListChanged(1);
        }