Tag Archives: XMPP

QXmpp 0.3.0 Release

I’m glad to release the next version of QXmpp, version 0.3.0. It comes packed with a number new features, bug fixes and improvements.

Here is a list of new features in QXmpp 0.3.0, please look at the changelog for exhaustive list:

  • XEP-0153: vCard-Based Avatars
  • XEP-0202: Entity Time
  • Managers for all the XEPs
  • More examples:
    example_9_vCard: vCard handling
    GuiClient: Graphical chat client, test bench for QXmpp functionalities
    example_8_server: Server capability
  • Server framework: Yes you can write a server now look at the example example_8_server
  • Add support for DNS SRV lookups, meaning you can connect to nearly all servers using only a JID and a password. No need to explicitly specify the server information.
  • Add QXMPP_VERSION and QXmppVersion() for compile and run time version checks.
  • Improve code documentation coverage and quality.
  • Completely remove dependency on QtGui, making it easier to write console applications.

QXmpp 0.3.0 Release Details:

Project Page | Changelog | Readme | API Documentation | Download

As usual, thanks to the authors, community and the users who have been driving the project.

About QXmpp:

QXmpp is a cross-platform C++ XMPP client (and server!) library based on Qt and C++. It is an open source project licensed under a permissive license LGPL. As of today, the project is around two years old.

XML Namespaces

Namespaces

Namespaces are used to prevent name conflicts or name collisions by containing the names under another names. This another name, i.e. name of the abstract container, is called namespace.

Example:

  • farming:crop
  • image_editing:crop

Here crop identifier has more than one meaning. Usage of this identifier without a namespaces is ambiguous. By using proper namespaces or containing them in separate namespaces (or categories), farming and image_editing gives unique names and hence prevents the naming collisions.

More Examples:

  • computer_keyboard:key
  • cryptography:key
  • lock:key
  • surface:flat
  • real_estate:flat

In Programming Languages

Namespaces exist in programming languages also. Wherein these are used to prevent collisions between the identifiers such as variables, classes, functions etc.

For example, two libraries lib1 and lib2, might use the same name for a function which returns version of the library say getVersion().

A call to this function will create ambiguity in an environment where both the libraries are used. This can be prevented by containing these functions in separate namespaces.

namespace lib1   // defines the function in the namespace lib1
{
 string getVersion();
}

namespace lib2   // defines the function in the namespace lib2
{
 string getVersion();
}

Now users can make following calls without any disambiguation.

//
// unambiguous calls by using qualified names
//
string lib1Version = lib1::getVersion(); // points to lib1

string lib2Version = lib2::getVersion(); // points to lib2

XML Namespaces

Coming back to the topic of XML Namespaces. Identifiers in XML  such as elements and attributes can also face name conflicts. In the following example the first element represents key-press on a keyboard. Whereas the second element is a representation of key in the context of cryptography.

<key>
 <name>D</name>
</key>

<key>
 <private>AdfgkloPjad</private>
 <public>hpkrpioHml</public>
</key>

Declaration

A namespace is declared by using the XML reserved attribute xmlns . The declaration can be done on any element of the XML document. Two syntaxes are available to define the attributes:

  • xmlns:prefix=URI
  • xmlns=URI

The first one associates the prefix with URI and prefix: can be prefixed to the elements or attributes in the scope of declaration of the namespace. The second method declares a default namespace and all the elements and attributes in the scope of declaration are contained in the given URI. Lets look at both the methods with examples.

xmlns:prefix=URI, Defining Prefix based Namespaces

XML attribute

xmlns:lock=”http://www.dahiya.co.in/lock-key”

defines a namespace lock and associates it with the URI=”http://www.dahiya.co.in/lock-key”. The prefix lock: can now be used in the current and its child elements.

<lock:key xmlns:lock="http://www.dahiya.co.in/lock-key">
 <lock:name>D</lock:name>
</lock:key>

<crypto:key xmlns:crypto="http://www.dahiya.co.in/crypto-key">
 <crypto:private>AdfgkloPjad</crypto:private>
 <crypto:public>hpkrpioHml</crypto:public>
</crypto:key>

The declaration can be done in the parent elements as well because the declaration has a scope of current elements and children.

<root xmlns:lock="http://www.dahiya.co.in/lock-key" xmlns:crypto="http://www.dahiya.co.in/crypto-key">

<lock:key>
 <lock:name>D</lock:name>
</lock:key>

<crypto:key>
 <crypto:private>ASKDIMBJ</crypto:private>
 <crypto:public>ASKDIMBJ</crypto:public>
</crypto:key>

</root>

xmlns=URI, Default Namespaces

XML attribute

xmlns=”http://www.dahiya.co.in/lock”

defines the default namespace for the elements and attributes that lack any namespace prefixes. This default namespace has a scope of current and child elements.

<key xmlns="http://www.dahiya.co.in/lock-key">
 <name>D</name>
</key>

<key xmlns="http://www.dahiya.co.in/crypto-key">
 <private>ASKDIMBJ</private>
 <public>ASKDIMBJ</public>
</key>

Redefining Namespaces

Namespace can be redefined by using the same syntaxes with new URI.

  • xmlns=New-URI
  • xmlns:prefix=New-URI

Unsetting Namespaces

Unsetting of the namespaces can be done by using empty URIs.

  • xmlns=”"
  • xmlns:prefix=”"

Note that after unsetting the prefix based namespace, the prefix should not be used.

Namespace Names

The XML specifications doesn’t say that the namespace names must be URIs. But the use of URLs (type of URI) in the form of http:// is quite common. It is not required that the given URL should host anything. The whole idea is to have a unique namespace. Domain name is a unique ID, namespaces created using domain name will come out unique. In the above examples I have used my domain to create namespaces.

  • http://www.dahiya.co.in/lock-key
  • http://www.dahiya.co.in/crypto-key

A little off the topic but worth mentioning, Java has a convention of using reversed-domain-name to name the packages. The motive is to have a unique name for every package. This prevents packages name conflicts if everyone follows the convention.

  • com.sun.team1.network
  • com.sun.team2.network
  • com.apple.quicktime.v2
  • edu.cmu.cs.bovik.cheese

XML Namespaces in Real Use

XMPP uses XML namespaces. Following IQ stanzas use default namespace to differentiate various type of IQ stanzas.

<iq type='get' from='romeo@montague.net/orchard' to='plays.shakespeare.lit' id='info1'>
 xmlns='http://jabber.org/protocol/disco#info'/>

<iq type='get' from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony' id='version_1'/>

<iq from='romeo@montague.net/orchard' id='last1' to='juliet@capulet.com' type='get'>
 <query xmlns='jabber:iq:last'/>
</iq>

QXmpp 0.2.0 Release

Last year, I founded an open source project QXmpp. It is an XMPP client library based on Qt. It is licensed under a permissive license LGPL. The project is now more than a year old. The very first public release QXmpp 0.1.0 was made on June 14, 2009. And last Sunday, we released QXmpp 0.2.0.

QXmpp 0.2.0 comes with numerous features (many XEPs and new authentication schemes), many bug fixes, architectural improvements and Doxygen documentation. Have a look at the Changelog for a complete list of new features and changes in this release.

Thanks to the authors, group and our users who have contributed in the form of patches, bug reports and suggestions.

QXmpp 0.2.0 Release:

Project Page | Changelog | Readme | API Documentation | Download