Ejemplo n.º 1
0
 public void UnsubscribeToPresence(JID jidto)
 {
     PresenceMessage pres = new PresenceMessage(null);
     pres.To = jidto;
     pres.From = null;
     pres.Type = "unsubscribe";
     pres.Show = null;
     pres.Status = null;
     pres.PresenceStatus.PresenceType = PresenceType.unsubscribe;
     XMPPClient.SendObject(pres);
 }
Ejemplo n.º 2
0
        /// <summary>
        ///  Allow the remote user to see our presence, we should add them to our roster as well at this poitn?
        /// </summary>
        /// <param name="pres"></param>
        public void AcceptUserPresence(PresenceMessage pres, string strNickName, string strGroup)
        {
            pres.PresenceStatus.PresenceType = PresenceType.subscribed;
            pres.Type = "subscribed";
            pres.To = pres.From.BareJID;
            pres.From = null;

            XMPPClient.SendObject(pres);
        }
Ejemplo n.º 3
0
        /// <presence id="AWAQt-31" from="[email protected]/calculon" to="[email protected]/phone"><status>Away</status><priority>0</priority><show>away</show></presence>
        public override bool NewPresence(PresenceMessage pres)
        {
            if ( (pres.Type == "") || (pres.Type == "unavailable") )
            {
                /// Means avialbe
                ///
                RosterItem  item = XMPPClient.FindRosterItem(pres.From);
                if (item != null)
                {
                    item.SetPresence(pres);
                }
            }
            //<presence from="[email protected]/calculon" to="*****@*****.**" type="subscribe"/>
            else if (pres.Type == "subscribe")
            {
                Answer answer = XMPPClient.ShouldSubscribeUser(pres);

                if (answer == Answer.Yes)
                {
                    AcceptUserPresence(pres, "", "");
                }
                else if (answer == Answer.No) /// reject if the user has responded
                {
                    DeclineUserPresence(pres);
                }

            }
            else if (pres.Type == "subscribed")
            {
            }
            else
            {
                RosterItem item = XMPPClient.FindRosterItem(pres.From);
                if (item != null)
                {
                    item.SetPresence(pres);
                    //item.Presence = pres.PresenceStatus;

                    /// Commented out because no one seems to support this method
                    //if (pres.AvatarHash != null)
                    //{
                    //    if (pres.AvatarHash.Hash != null)
                    //    {
                    //        /// May have a new avatar, check against our current file system
                    //        ///
                    //        if (XMPPClient.AvatarStorage.AvatarExist(pres.AvatarHash.Hash) == false)
                    //           DownloadAvatarJabberIQMethod(pres.From);
                    //    }
                    //}

                    if (pres.VCardUpdate != null)
                    {
                        if (pres.VCardUpdate.PhotoHash != null)
                        {

                            //byte [] bURL = Convert.FromBase64String(pres.VCardUpdate.PhotoHash);
                            //string strURL = System.Text.UTF8Encoding.UTF8.GetString(bURL, 0, bURL.Length);
                            //item.AvatarImagePath = strURL;

                            /// XEP-153 - vcard-based avatars... sha1 hash of the current avatar
                            if ((XMPPClient.AvatarStorage.AvatarExist(pres.VCardUpdate.PhotoHash) == false) && (XMPPClient.AutomaticallyDownloadAvatars == true) )
                                RequestVCARD(pres.From);
                            else
                            {
                                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ThreadedUpdateAvatarImageHash),
                                    new RosterItemImageHash() {RosterItem = item, ImageHash=pres.VCardUpdate.PhotoHash});
                                //item.AvatarImagePath = pres.VCardUpdate.PhotoHash;
                            }

                            //RequestVCARD(pres.From);

                            /// or XEP-0008 IQ based avatars
                            ///

                            /// or XEP- jaber fldlkjsl
                            //string strRelativeImage = string.Format("Avatars/{0}", pres.VCardUpdate.PhotoHash);
                            ///// See if this file exists, if it doesn't, download the file
                            /////
                            //if (System.IO.File.Exists(strRelativeImage) == true)
                            //    item.AvatarImagePath = strRelativeImage;
                            //else
                            //    //XMPPClient.PersonalEventingLogic.DownloadDataNode(jidfrom, "urn:xmpp:avatar:data", strItem);
                            //    XMPPClient.DownloadAvatar(pres.From, pres.VCardUpdate.PhotoHash);
                        }
                    }

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

                }
            }

            return true;
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Deny the remote user the ability to see our presence
 /// </summary>
 /// <param name="pres"></param>
 public void DeclineUserPresence(PresenceMessage pres)
 {
     pres.PresenceStatus.PresenceType = PresenceType.unsubscribed;
     pres.Type = "unsubscribed";
     pres.To = pres.From.BareJID;
     pres.From = null;
     XMPPClient.SendObject(pres);
 }
Ejemplo n.º 6
0
 public virtual bool NewPresence(PresenceMessage iq)
 {
     return false;
 }
Ejemplo n.º 7
0
 public void DeclineUserPresence(PresenceMessage pres)
 {
     PresenceLogic.DeclineUserPresence(pres);
 }
Ejemplo n.º 8
0
 public void AcceptUserPresence(PresenceMessage pres, string strNickName, string strGroup)
 {
     PresenceLogic.AcceptUserPresence(pres, strNickName, strGroup);
 }
Ejemplo n.º 9
0
 public virtual bool NewPresence(PresenceMessage iq)
 {
     return(false);
 }