It is often desirable for a Jabber/XMPP application (commonly but not necessarily a client) to take different actions depending on the capabilities of another application from which it receives presence information. Examples include:

Showing a different set of icons depending on the capabilities of other clients. Not sending XHTML-IM content to plaintext clients such as cell phones. Allowing the initiation of Voice over IP (VoIP) sessions only to clients that support VoIP. Not showing a "Send a File" button if another user's client does not support File Transfer.

Recently, some existing Jabber clients have begun sending Software Version requests to each entity from which they receive presence. That solution is impractical on a larger scale, particularly for users or applications with large rosters. This document proposes a more robust and scalable solution: namely, a presence-based mechanism for exchanging information about entity capabilities.

Inheritance: Element
        public DiscoInfo Get(Capabilities capabilities)
        {
            DiscoInfo discoInfo;

            _cache.TryGetValue(GetCapsString(capabilities), out discoInfo);

            return discoInfo;
        }
Exemple #2
0
 /// <summary>
 /// Retourne les fonctionnalit� du client
 /// </summary>
 /// <returns>Fonctionnalit�s</returns>
 public static Capabilities getCapabilities()
 {
     agsXMPP.protocol.extensions.caps.Capabilities caps = new agsXMPP.protocol.extensions.caps.Capabilities(Queries.DiscoInfoToVersion(Queries.getDiscoInfo()), "http://microphage71.hostarea.org/caps");
     caps.AddExtension("mood");
     caps.AddExtension("tune");
     caps.AddExtension("geoloc");
     caps.AddExtension("activity");
     caps.AddExtension("cs");
     caps.AddExtension("ep-notify");
     return caps;
 }
Exemple #3
0
 /// <summary>
 /// Retourne les fonctionnalité du client
 /// </summary>
 /// <returns>Fonctionnalités</returns>
 public static Capabilities getCapabilities()
 {
     agsXMPP.protocol.extensions.caps.Capabilities caps = new agsXMPP.protocol.extensions.caps.Capabilities(Queries.DiscoInfoToVersion(Queries.getDiscoInfo()), "http://microphage71.hostarea.org/caps");
     caps.AddExtension("mood");
     caps.AddExtension("tune");
     caps.AddExtension("geoloc");
     caps.AddExtension("activity");
     caps.AddExtension("cs");
     caps.AddExtension("ep-notify");
     return(caps);
 }
 public void AddToCache(Capabilities capabilities, DiscoInfo discoInfo)
 {
     if (discoInfo.GetFeatures().Length > 0)
     {
         lock (_cacheLock)
         {
             string caps = GetCapsString(capabilities);
             _cache[GetCapsString(capabilities)] = discoInfo;
             Database.SaveCapsCache(caps, discoInfo.ToString());
         }
     }
 }
Exemple #5
0
        internal Presence()
        {
            agsXMPP.protocol.client.Presence pres = new agsXMPP.protocol.client.Presence();
            pres.Show = agsXMPP.protocol.client.ShowType.xa;
            pres.Status = "Away from the computer.";
            pres.Priority = 5;

            Capabilities caps = new Capabilities();
            caps.Node = "http://www.ag-software.de/caps";
            caps.Version = "1.1.0";
            // don't use the follwing anymore, its deprecated
            caps.Extensions = new string[] { "rtf", "html-im", "crypt"};

            Avatar avatar = new Avatar();
            avatar.Hash = "1bb12134f2528c4617fcc393180ddcfcc8462311";

            pres.AddChild(caps);
            pres.AddChild(avatar);
                        
            Console.WriteLine("Custom Presence Packet:");
            Program.Print(pres);           
        }
        static string GetCapsString(Capabilities capabilities)
        {
            if (string.IsNullOrEmpty(capabilities.Version))
            {
                return capabilities.Version;
            }

            string[] extensions = capabilities.Extensions;

            if (extensions != null && extensions.Length > 0)
            {
                Array.Sort(extensions);

                return string.Format("{0}#{1}<{2}", capabilities.Node,
                                     capabilities.Version,
                                     string.Join("<", extensions));
            }
            else
            {
                return String.Empty;
            }
        }
Exemple #7
0
        internal Disco()
        {
            /*
                <iq from='[email protected]/orchard'
                    id='disco1'
                    to='[email protected]/balcony'
                    type='result'>
                  <query xmlns='http://jabber.org/protocol/disco#info'/>
                    <identity category='client' type='pc'/>
                    <feature var='http://jabber.org/protocol/disco#info'/>
                    <feature var='http://jabber.org/protocol/disco#items'/>
                    <feature var='http://jabber.org/protocol/muc'/>
                  </query>
                </iq>
             */

            DiscoInfoIq diiq = new DiscoInfoIq();
            diiq.Id = "disco1";
            diiq.To = new agsXMPP.Jid("[email protected]/balcony");
            diiq.Type = agsXMPP.protocol.client.IqType.result;

            diiq.Query.AddIdentity(new DiscoIdentity("pc", "client"));

            diiq.Query.AddFeature(new DiscoFeature(agsXMPP.Uri.DISCO_INFO));
            diiq.Query.AddFeature(new DiscoFeature(agsXMPP.Uri.DISCO_ITEMS));
            diiq.Query.AddFeature(new DiscoFeature(agsXMPP.Uri.MUC));

            Program.Print(diiq);

            // Build caps from this disco info
            Capabilities caps = new Capabilities();
            caps.Node = "http://www.ag-software.de/miniclient/caps";
            caps.SetVersion(diiq.Query);

            Program.Print(caps);
        }
Exemple #8
0
 void RequestCapabilities(Jid jid, Capabilities caps)
 {
     string hash = caps.Node + "#" + caps.Version;
     RequestCapabilities(jid, hash);
 }
        private void OnContactPresence(Presence presence, Capabilities capabilities)
        {
            lock (_items._syncObject)
            {
                Contact contact = FindContact(presence.From);

                if (contact == null)
                {
                    if (JidUtil.BareEquals(presence.From, Account.Instance.Self.Jid))
                    {
                        // it's me from another client
                        Events.Instance.OnEvent(this, new EventInfo(
                                                          String.Format(Resources.Event_AnotherClient,
                                                                        presence.From.Resource, presence.Priority,
                                                                        Account.Instance.Self.Jid, presence.Show)));

                        if (presence.Priority > Account.Instance.MyPriority)
                        {
                            Events.Instance.OnEvent(this, new EventInfo(
                                                              String.Format(Resources.Event_AnotherClientHigher,
                                                                            presence.From.Resource)));
                        }
                        else
                        {
                            Events.Instance.OnEvent(this, new EventInfo(
                                                              String.Format(Resources.Event_AnotherClientLower,
                                                                            presence.From.Resource)));
                        }
                    }
                    else
                    {
                        Events.Instance.OnEvent(this,
                                                new EventError(String.Format(Resources.Event_UnknownPresence,
                                                                             presence.From, presence.Nickname), null));
                    }
                }
                else
                {
                    if (contact.Presence == null
                        || contact.Presence.Show != presence.Show)
                    {
                        // only if showtype changes
                        EventPresenceChanged eventPresenceChanged =
                            new EventPresenceChanged(contact, contact.Presence, presence);

                        Events.Instance.OnEvent(this, eventPresenceChanged);
                    }

                    contact.Presence = presence;

                    if (capabilities != null)
                    {
                        contact.Caps = capabilities;
                    }

                    if (!contact.HasDiscoRecieved)
                    {
                        AskForDisco(contact);
                    }
                }
            }
        }
        public SelfContact()
        {
            Version.Name = "xeus";
            Version.Ver = "2.0 RC0";
            Version.Os = Environment.OSVersion.ToString();

            _updateTimer.AutoReset = false;
            _updateTimer.Elapsed += _updateTimer_Elapsed;

            _idleTimer.AutoReset = true;
            _idleTimer.Elapsed += _idleTimer_Elapsed;
            _idleTimer.Start();

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.BYTESTREAMS));
            //_caps.AddExtension("bs");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.CAPS));
            //_caps.AddExtension("caps");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.COMMANDS));
            //_caps.AddExtension("cmd");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.CHATSTATES));
            //_caps.AddExtension("cs");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.DISCO_INFO));
            //_caps.AddExtension("di");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.VCARD_UPDATE));
            //_caps.AddExtension("vcup");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.VCARD));
            //_caps.AddExtension("vc");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.IQ_LAST));
            //_caps.AddExtension("las");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.MUC_ADMIN));
            //_caps.AddExtension("adm");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.MUC_OWNER));
            //_caps.AddExtension("own");

            _discoInfo.AddFeature(new DiscoFeature(agsXMPP.Uri.MUC_USER));
            //_caps.AddExtension("usr");

            _discoInfo.AddFeature(new DiscoFeature("urn:xmpp:time"));

               _caps = new Capabilities(TextUtil.GenerateVerAttribute(_discoInfo), "http://xeus.net/#2.0");

            _discoInfo.AddIdentity(_identity);
        }