Esempio n. 1
0
        public bool PublishGeoInfo(geoloc item)
        {
            string strGeoInfo = Utility.GetXMLStringFromObject(item);

            PubSubIQ iq = new PubSubIQ();

            iq.Type           = IQType.set.ToString();
            iq.To             = null; /// null for personal eventing pub sub
            iq.From           = XMPPClient.JID;
            iq.PubSub.Publish = new Publish()
            {
                Node = "http://jabber.org/protocol/geoloc", Item = new PubSubItem()
            };
            iq.PubSub.Publish.Item.SetNodeFromObject(item);
            iq.PubSub.Publish.Item.Id = "lastlocation";

            ListSentIQs.Add(iq.ID);
            try
            {
                XMPPClient.SendObject(iq);
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
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);
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public void QueryServiceItems()
 {
     IQItemRequest = new ServiceDiscoveryIQ();
     IQItemRequest.ServiceDiscoveryItemQuery = new ServiceDiscoveryItemQuery();
     IQItemRequest.From = XMPPClient.JID;
     IQItemRequest.To   = XMPPClient.Domain;
     IQItemRequest.Type = IQType.get.ToString();
     XMPPClient.SendObject(IQItemRequest);
 }
Esempio n. 5
0
        // Look for subscribe message to subscribe to presence
        public override bool NewIQ(IQ iq)
        {
            //// XEP-0030
            ///<iq type='get' from='[email protected]/orchard' to='plays.shakespeare.lit' id='info1'>
            ///   <query xmlns='http://jabber.org/protocol/disco#info'/>
            ///</iq>

            if ((iq is ServiceDiscoveryIQ) && (iq.Type == IQType.get.ToString()))
            {
                ServiceDiscoveryIQ response = new ServiceDiscoveryIQ();
                response.To   = iq.From;
                response.From = XMPPClient.JID;
                response.ID   = iq.ID;
                response.Type = IQType.result.ToString();
                response.ServiceDiscoveryInfoQuery          = new ServiceDiscoveryInfoQuery();
                response.ServiceDiscoveryInfoQuery.Features = XMPPClient.OurServiceDiscoveryFeatureList.ToArray();

                XMPPClient.SendObject(response);
                return(true);
            }
            else if ((IQInfoRequest != null) && (IQInfoRequest.ID == iq.ID))
            {
                if (iq is ServiceDiscoveryIQ)
                {
                    ServiceDiscoveryIQ response = iq as ServiceDiscoveryIQ;

                    if ((response.ServiceDiscoveryInfoQuery != null) && (response.ServiceDiscoveryInfoQuery.Features != null) && (response.ServiceDiscoveryInfoQuery.Features.Length > 0))
                    {
                        XMPPClient.ServerServiceDiscoveryFeatureList.Features.Clear();
                        XMPPClient.ServerServiceDiscoveryFeatureList.Features.AddRange(response.ServiceDiscoveryInfoQuery.Features);
                    }
                    if ((response.ServiceDiscoveryInfoQuery != null) && (response.ServiceDiscoveryInfoQuery.Identities != null) && (response.ServiceDiscoveryInfoQuery.Identities.Length > 0))
                    {
                    }
                }
                return(true);
            }
            else if ((IQItemRequest != null) && (IQItemRequest.ID == iq.ID))
            {
                if (iq is ServiceDiscoveryIQ)
                {
                    ServiceDiscoveryIQ response = iq as ServiceDiscoveryIQ;

                    if ((response.ServiceDiscoveryItemQuery != null) && (response.ServiceDiscoveryItemQuery.Items != null) && (response.ServiceDiscoveryItemQuery.Items.Length > 0))
                    {
                        XMPPClient.ServerServiceDiscoveryFeatureList.Items.AddRange(response.ServiceDiscoveryItemQuery.Items);
                        System.Threading.ThreadPool.QueueUserWorkItem(QueryItemsForProxy);
                    }
                }
                return(true);
            }

            return(base.NewIQ(iq));
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public bool PublishAvatarData(byte [] bImageData, int nWidth, int nHeight)
        {
            // publish avatar data node
            avatardata data = new avatardata();

            data.ImageData = bImageData;
            //string strAvatarInfo = Utility.GetXMLStringFromObject(data);

            string strHash = XMPPClient.AvatarStorage.WriteAvatar(bImageData);

            PubSubIQ iq = new PubSubIQ();

            iq.Type           = IQType.set.ToString();
            iq.To             = null; /// null for personal eventing pub sub
            iq.From           = XMPPClient.JID;
            iq.PubSub.Publish = new Publish()
            {
                Node = "urn:xmpp:avatar:data", Item = new PubSubItem()
            };
            iq.PubSub.Publish.Item.SetNodeFromObject(data);

            ListSentIQs.Add(iq.ID);
            XMPPClient.SendObject(iq);


            // publish avatar meta data node
            avatarmetadata metadata = new avatarmetadata();

            metadata.ImageInfo.ByteLength = bImageData.Length;
            metadata.ImageInfo.Width      = nWidth;
            metadata.ImageInfo.Height     = nHeight;
            //string strAvatarMetaData = Utility.GetXMLStringFromObject(metadata);

            PubSubIQ iqmeta = new PubSubIQ();

            iqmeta.Type           = IQType.set.ToString();
            iqmeta.To             = null; /// null for personal eventing pub sub
            iqmeta.From           = XMPPClient.JID;
            iqmeta.PubSub.Publish = new Publish()
            {
                Node = "urn:xmpp:avatar:metadata", Item = new PubSubItem()
                {
                    Id = strHash
                }
            };
            iqmeta.PubSub.Publish.Item.SetNodeFromObject(metadata);

            ListSentIQs.Add(iqmeta.ID);
            XMPPClient.SendObject(iqmeta);

            return(true);
        }
Esempio n. 8
0
        public void GetAllItems(string strSubId)
        {
            IQGetAll              = new PubSubIQ();
            IQGetAll.Type         = IQType.set.ToString();
            IQGetAll.To           = new JID(string.Format("pubsub.{0}", XMPPClient.Domain));
            IQGetAll.From         = XMPPClient.JID;
            IQGetAll.PubSub.Items = new PubSubItems()
            {
                Node = Node, subid = strSubId
            };


            XMPPClient.SendObject(IQGetAll);
        }
Esempio n. 9
0
        public bool SendReceive(int nTimeoutMs)
        {
            TimeoutMs = nTimeoutMs;
            if (SerializationMethod == XMPP.SerializationMethod.MessageXMLProperty)
            {
                XMPPClient.SendXMPP(SendIQ);
            }
            else
            {
                XMPPClient.SendObject(SendIQ);
            }

            Success = GotIQEvent.WaitOne(TimeoutMs);
            return(Success);
        }
Esempio n. 10
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. 11
0
        public void DownloadDataNode(JID jidto, string strNodeName, string strItem)
        {
            PubSubIQ iq = new PubSubIQ();

            iq.Type           = IQType.set.ToString();
            iq.To             = null; /// null for personal eventing pub sub
            iq.From           = XMPPClient.JID;
            iq.PubSub.Publish = new Publish()
            {
                Node = strNodeName, Item = new PubSubItem()
                {
                    Id = strNodeName
                }
            };

            ListSentIQs.Add(iq.ID);
            XMPPClient.SendObject(iq);
        }
Esempio n. 12
0
        public void DeleteItem(string strItemId, T item)
        {
            PubSubIQ iq = new PubSubIQ();

            iq.Type                 = IQType.set.ToString();
            iq.To                   = new JID(string.Format("pubsub.{0}", XMPPClient.Domain));
            iq.From                 = XMPPClient.JID;
            iq.PubSub.Retract       = new Retract();
            iq.PubSub.Retract.Node  = Node;
            iq.PubSub.Retract.Items = new PubSubItem[] { new PubSubItem()
                                                         {
                                                             Id = strItemId
                                                         } };

            ListSentIQs.Add(iq);

            XMPPClient.SendObject(iq);
        }
Esempio n. 13
0
        public void UpdateItem(string strItemId, T item)
        {
            PubSubIQ iq = new PubSubIQ();

            iq.Type                = IQType.set.ToString();
            iq.To                  = new JID(string.Format("pubsub.{0}", XMPPClient.Domain));
            iq.From                = XMPPClient.JID;
            iq.PubSub.Publish      = new Publish();
            iq.PubSub.Publish.Node = Node;
            iq.PubSub.Publish.Item = new PubSubItem()
            {
                Id = strItemId
            };
            iq.PubSub.Publish.Item.SetNodeFromObject(item);

            ListSentIQs.Add(iq);

            XMPPClient.SendObject(iq);
        }
Esempio n. 14
0
        public bool PublishTuneInfo(TuneItem item)
        {
            //string strTuneXML = Utility.GetXMLStringFromObject(item);


            PubSubIQ iq = new PubSubIQ();

            iq.Type           = IQType.set.ToString();
            iq.To             = null; /// null for personal eventing pub sub
            iq.From           = XMPPClient.JID;
            iq.PubSub.Publish = new Publish()
            {
                Node = "http://jabber.org/protocol/tune", Item = new PubSubItem()
            };
            iq.PubSub.Publish.Item.SetNodeFromObject(item);

            ListSentIQs.Add(iq.ID);

            XMPPClient.SendObject(iq);
            return(true);
        }
Esempio n. 15
0
 public override void  Start()
 {
     XMPPClient.SendObject(RosterIQ);
 }