public DiscoItem AddDiscoItem()
        {
            DiscoItem item = new DiscoItem();

            AddChild(item);
            return(item);
        }
Example #2
0
        public Service(DiscoItem discoItem, bool isToplevel)
        {
            _discoItem = discoItem;
            _isToplevel = isToplevel;

            if (_isToplevel)
            {
                Account.Instance.AddDiscoInfoPrioritized(_discoItem);

                _askedForDiscovery = true;
            }
        }
Example #3
0
        public DiscoItem[] GetDiscoItems()
        {
            var nl    = SelectElements(typeof(DiscoItem));
            var items = new DiscoItem[nl.Count];
            var i     = 0;

            foreach (Element e in nl)
            {
                items[i] = (DiscoItem)e;
                i++;
            }
            return(items);
        }
Example #4
0
 public DiscoItem[] GetDiscoItems()
 {
     ElementList nl = SelectElements(typeof(DiscoItem));
     DiscoItem[] items = new DiscoItem[nl.Count];
     int i = 0;
     foreach (Element e in nl)
     {
         items[i] = (DiscoItem) e;
         i++;
     }
     return items;
 }
Example #5
0
 public void AddDiscoItem(DiscoItem item)
 {
     AddChild(item);
 }
Example #6
0
 public DiscoItem AddDiscoItem()
 {
     DiscoItem item = new DiscoItem();
     AddChild(item);
     return item;
 }
Example #7
0
 public static bool CompareDiscoItem( DiscoItem discoItem, DiscoItem discoItem2 )
 {
     return Equals( discoItem.Jid, discoItem2.Jid )
         && discoItem.Node == discoItem2.Node ;
 }
 public void AddDiscoItem(DiscoItem item)
 {
     AddChild(item);
 }
Example #9
0
            //RECIEVED:
            //<iq xmlns="jabber:client" id="agsXMPP_5" type="get" to="localhost">
            //    <query xmlns="http://jabber.org/protocol/disco#items" />
            //</iq>

            //RESPONSE:
            //<iq xmlns="jabber:client" from="localhost" to="test@localhost/MF" type="result" id="agsXMPP_5">
            //    <query xmlns="http://jabber.org/protocol/disco#items">
            //        <item name="Coversant XMPP Administractive Gateway" jid="administration.localhost" />
            //        <item jid="administration.localhost" node="http://winfessor.com/protocol/administration/policy" />
            //        <item name="pubsub - Publish Subscribe Gateway" jid="pubsub.localhost" />
            //        <item name="Open S2S Sessions" jid="s2s.localhost" />
            //        <item name="conference - Multi User Chat" jid="conference.localhost" />
            //        <item name="SoapBox User Directory" jid="users.localhost" />
            //        <item name="jabber - Default Jabber Gateway" jid="localhost" />
            //        <item jid="localhost" node="http://jabber.org/protocol/commands" />
            //    </query>
            //</iq>
            private void ProcessDiscoItemsIQ(IQ iq)
            {

                DiscoItemsIq discoItemsIq = new DiscoItemsIq(IqType.result);
                discoItemsIq.Namespace = agsXMPP.Uri.CLIENT;
                discoItemsIq.Id = iq.Id;
                discoItemsIq.From = iq.To;
                discoItemsIq.To = this.m_ClientAccount.JID;

                ///*******此处为配置扩展******************
                ///当前仅实现服务发现
                ///***************************************
                DiscoItem discoItem = null;
                foreach (BaseService service in this.m_Server.ServiceList)
                {

                    discoItem = new DiscoItem();
                    discoItem.Name = service.Name;
                    discoItem.Jid = service.JID;

                    if (iq.To.Bare.ToLower().Contains(service.JID.Bare.ToLower()))
                    {

                        discoItemsIq.Query.RemoveAllChildNodes();

                        if (service.ServiceType == ServiceType.GroupChat)
                        {
                            MucService muc = service as MucService;
                            if (service.JID.Bare.ToLower() == iq.To.Bare.ToLower())
                            {
                                //<iq from='macbeth.shakespeare.lit'
                                //    id='disco2'
                                //    to='[email protected]/pda'
                                //    type='result'>
                                //  <query xmlns='http://jabber.org/protocol/disco#items'>
                                //    <item jid='*****@*****.**'
                                //          name='A Lonely Heath'/>
                                //    <item jid='*****@*****.**'
                                //          name='A Dark Cave'/>
                                //    <item jid='*****@*****.**'
                                //          name='The Palace'/>
                                //    <item jid='*****@*****.**'
                                //          name='Macbeth&apos;s Castle'/>
                                //  </query>
                                //</iq>


                                foreach (KeyValuePair<string, ChatRoom> item in muc.GetRooms())
                                {
                                    discoItem = new DiscoItem();
                                    discoItem.Name = item.Key;
                                    discoItem.Jid = item.Value.JID;

                                    discoItemsIq.Query.AddDiscoItem(discoItem);

                                }


                            }
                            else if (iq.To.Bare.ToLower().EndsWith("@" + service.JID.Bare.ToLower()))
                            {

                            }
                            else
                            {

                            }

                        }
                        else if (service.ServiceType == ServiceType.ContactSearch)
                        {

                        }
                        else if (service.ServiceType == ServiceType.FileTransfer)
                        {

                        }
                        else
                        {

                        }

                        break;
                    }
                    else
                    {
                        discoItemsIq.Query.AddDiscoItem(discoItem);
                    }

                }

                Send(discoItemsIq);

            }
 public RegisteredService(DiscoItem discoItem)
     : base(discoItem, false)
 {
     _askedForDiscovery = true;
 }
Example #11
0
 public static string GetKey(DiscoItem discoItem)
 {
     if (string.IsNullOrEmpty(discoItem.Node))
     {
         return
             string.Format("{0}/", discoItem.Jid.ToString().ToLowerInvariant());
     }
     else
     {
         return
             string.Format("{0}/{1}", discoItem.Jid.ToString().ToLowerInvariant(),
                           discoItem.Node.ToLowerInvariant());
     }
 }