Ejemplo n.º 1
0
        public void ComplexGenerationExample()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<book xml:lang='en'/>");
            XmlElement book = doc.DocumentElement;
            foreach (XmlAttribute attr in book.Attributes)
            {
                System.Console.WriteLine(attr.Name);
            }

            XmlElement root = doc.DocumentElement;

            DiscoInfo info = new DiscoInfo(doc);
            info.AddFeature("http://jabber.org/protocol/muc");
            info.AddFeature("http://jabber.org/protocol/disco#info");
            info.AddFeature("http://jabber.org/protocol/disco#items");
            info.AddIdentity("client", "pc", "Psi 0.9.1", "en");
            info.AddIdentity("client", "pc", "\u03a8 0.9.1", "el");
            Data x = info.CreateExtension();
            x.FormType = "urn:xmpp:dataforms:softwareinfo";
            x.AddField("ip_version").Vals = new string[] { "ipv4", "ipv6" };
            x.AddField("os").Val = "Mac";
            x.AddField("os_version").Val = "10.5.1";
            x.AddField("software").Val = "Psi";
            x.AddField("software_version").Val = "0.11";

            DiscoNode dn = new DiscoNode(new JID(null, "placeholder", null), null);
            dn.AddInfo(info);

            CapsManager cm = new CapsManager(dn);
            Assert.AreEqual("8lu+88MRxmKM7yO3MEzY7YmTsWs=", cm.Ver);
        }
Ejemplo n.º 2
0
        private void con_OnIq(object sender, IQ iq)
        {
            if (iq.Query != null)
            {
                if (iq.Query is DiscoInfo && iq.Type == IqType.get)
                {
                    /*
                     * <iq type='get'
                     *  from='[email protected]/orchard'
                     *  to='plays.shakespeare.lit'
                     *  id='info1'>
                     * <query xmlns='http://jabber.org/protocol/disco#info'/>
                     * </iq>
                     */
                    iq.SwitchDirection();
                    iq.Type = IqType.result;

                    DiscoInfo di = iq.Query as DiscoInfo;

                    if (ClientName != null)
                    {
                        di.AddIdentity(new DiscoIdentity(ClientCategory.ToString(), this.ClientName, "client"));
                    }

                    foreach (string feature in ClientFeatures)
                    {
                        di.AddFeature(new DiscoFeature(feature));
                    }

                    xmppCon.Send(iq);
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Take the info for this entity, and fill it in to the given DiscoInfo protocol element.
 /// Node, identities, and features get filled in.
 /// </summary>
 /// <param name="info">The empty info element to fill in.</param>
 public void FillInInfo(DiscoInfo info)
 {
     info.Node = NodeVer;
     foreach (Ident id in Identities)
         info.AddIdentity(id.Category, id.Type, id.Name, id.Lang);
     foreach (string uri in Features)
         info.AddFeature(uri);
 }
Ejemplo n.º 4
0
        private IQ CreateDiscoInfoResponse(string id)
        {
            IQ returnIq = new IQ(doc);

            returnIq.SetAttribute("id", id);
            returnIq.SetAttribute("from", jid);
            returnIq.SetAttribute("type", "result");

            DiscoInfo info = new DiscoInfo(doc);

            info.AddIdentity("server", "im", "jabber2 4.2.16.6", null);
            info.AddFeature(URI.DISCO_ITEMS);
            info.AddFeature(URI.DISCO_INFO);

            returnIq.Query = info;

            return(returnIq);
        }
Ejemplo n.º 5
0
        public override void Configure(IDictionary <string, string> properties)
        {
            DiscoInfo.AddIdentity(new DiscoIdentity("text", Name, "Multicast Service"));

            DiscoInfo.AddFeature(new DiscoFeature(Uri.ADDRESS));

            Handlers.Add(new MulticastHandler());
            Handlers.Add(new VCardHandler());
            Handlers.Add(new ServiceDiscoHandler(Jid));
        }
Ejemplo n.º 6
0
        public override void Configure(IDictionary <string, string> properties)
        {
            base.Configure(properties);

            DiscoInfo.AddIdentity(new DiscoIdentity("text", Name, "conference"));
            DiscoInfo.AddFeature(new DiscoFeature(Uri.MUC));
            DiscoInfo.AddFeature(new DiscoFeature(Features.FEAT_MUC_ROOMS));

            Handlers.Add(new MucStanzaHandler(this));
            Handlers.Add(new VCardHandler());
            Handlers.Add(new ServiceDiscoHandler(Jid));
        }
Ejemplo n.º 7
0
 private void UpdateDiscoInfo()
 {
     DiscoInfo.RemoveAllChildNodes();
     DiscoInfo.AddIdentity(new DiscoIdentity("text", RoomSettings.Title, "conference"));
     DiscoInfo.AddFeature(new DiscoFeature(Uri.MUC));
     DiscoInfo.AddFeature(new DiscoFeature(Features.FEAT_MUC_ROOMINFO));
     DiscoInfo.AddFeature(new DiscoFeature(Features.FEAT_MUC_ROOMCONFIG));
     foreach (var feature in RoomSettings.GetFeatures())
     {
         DiscoInfo.AddFeature(feature);
     }
 }
Ejemplo n.º 8
0
        public void ComplexGenerationExample()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<book xml:lang='en'/>");
            XmlElement book = doc.DocumentElement;

            foreach (XmlAttribute attr in book.Attributes)
            {
                System.Console.WriteLine(attr.Name);
            }

            XmlElement root = doc.DocumentElement;

            DiscoInfo info = new DiscoInfo(doc);

            info.AddFeature("http://jabber.org/protocol/muc");
            info.AddFeature("http://jabber.org/protocol/disco#info");
            info.AddFeature("http://jabber.org/protocol/disco#items");
            info.AddIdentity("client", "pc", "Psi 0.9.1", "en");
            info.AddIdentity("client", "pc", "\u03a8 0.9.1", "el");
            Data x = info.CreateExtension();

            x.FormType = "urn:xmpp:dataforms:softwareinfo";
            x.AddField("ip_version").Vals      = new string[] { "ipv4", "ipv6" };
            x.AddField("os").Val               = "Mac";
            x.AddField("os_version").Val       = "10.5.1";
            x.AddField("software").Val         = "Psi";
            x.AddField("software_version").Val = "0.11";

            DiscoNode dn = new DiscoNode(new JID(null, "placeholder", null), null);

            dn.AddInfo(info);

            CapsManager cm = new CapsManager(dn);

            Assert.AreEqual("8lu+88MRxmKM7yO3MEzY7YmTsWs=", cm.Ver);
        }
Ejemplo n.º 9
0
 private void DiscoveryFearures(IList <IXmppHandler> handlers)
 {
     foreach (var handler in handlers)
     {
         foreach (XmppHandlerAttribute attribute in handler.GetType().GetCustomAttributes(typeof(XmppHandlerAttribute), true))
         {
             var nameSpace = ElementFactory.GetElementNamespace(attribute.XmppElementType);
             if (!string.IsNullOrEmpty(nameSpace) && !DiscoInfo.HasFeature(nameSpace))
             {
                 DiscoInfo.AddFeature(new DiscoFeature(nameSpace));
             }
         }
     }
 }
Ejemplo n.º 10
0
        public MucRoomMember(MucRoom room, Jid memberJid, Jid realJid, XmppStream stream, XmppHandlerContext context)
        {
            if (room == null)
            {
                throw new ArgumentNullException("room");
            }
            if (memberJid == null)
            {
                throw new ArgumentNullException("memberJid");
            }
            if (realJid == null)
            {
                throw new ArgumentNullException("realJid");
            }
            if (context == null)
            {
                throw new ArgumentNullException("sender");
            }
            this.room    = room;
            this.stream  = stream;
            this.context = context;
            this.sender  = context.Sender;

            //Register disconect
            context.SessionManager.SessionUnavailable += SessionManager_SessionUnavailable;

            ParentService = room;
            RealJid       = realJid;
            Jid           = memberJid;
            Name          = memberJid.Resource;
            presenceType  = PresenceType.unavailable;
            //Create handler
            lock (Handlers)
            {
                Handlers.Add(new MucRoomMemberStanzaHandler(this));
                Handlers.Add(new MucRoomMemberDiscoHandler(Jid, RealJid));
            }
            DiscoInfo.AddIdentity(new DiscoIdentity("text", Name, "member"));
            DiscoInfo.AddFeature(new DiscoFeature(Core.protocol.Uri.DISCO_INFO));
            DiscoInfo.AddFeature(new DiscoFeature(Core.protocol.Uri.DISCO_ITEMS));
        }
Ejemplo n.º 11
0
        private IQ CreateDiscoInfoResponse(string id)
        {
            IQ returnIq = new IQ(doc);
            returnIq.SetAttribute("id", id);
            returnIq.SetAttribute("from", jid);
            returnIq.SetAttribute("type", "result");

            DiscoInfo info = new DiscoInfo(doc);
            info.AddIdentity("server", "im", "jabber2 4.2.16.6", null);
            info.AddFeature(URI.DISCO_ITEMS);
            info.AddFeature(URI.DISCO_INFO);

            returnIq.Query = info;

            return returnIq;
        }
Ejemplo n.º 12
0
 public void AddFeature(string var)
 {
     disco_info.AddFeature(var);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Take the info for this entity, and fill it in to the given DiscoInfo protocol element.
 /// Node, identities, and features get filled in.
 /// </summary>
 /// <param name="info">The empty info element to fill in.</param>
 public void FillInInfo(DiscoInfo info)
 {
     foreach (Ident id in Identities)
         info.AddIdentity(id.Category, id.Type, id.Name, id.Lang);
     foreach (string uri in Features)
         info.AddFeature(uri);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Retourne notre DiscoInfo
        /// </summary>
        /// <returns>DiscoInfo</returns>
        public static DiscoInfo getDiscoInfo()
        {
            DiscoInfo di = new DiscoInfo();

            di.AddIdentity(new DiscoIdentity("pc", "client", "nJim"));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.CLIENT));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.DISCO_INFO));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.IQ_AVATAR));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.VCARD));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.VCARD_UPDATE));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.X_AVATAR));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.X_DELAY));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.IQ_VERSION));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.IQ_TIME));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.IQ_LAST));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.PING));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.IQ_PRIVACY));
            di.AddFeature(new DiscoFeature(agsXMPP.Uri.STORAGE_BOOKMARKS));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/mood"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/mood+notify"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/tune"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/tune+notify"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/geoloc"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/geoloc+notify"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/activity"));
            di.AddFeature(new DiscoFeature("http://jabber.org/protocol/activity+notify"));
            return(di);
        }