Telepathy Idle: implementing Connection.Interface.ContactInfo
Connection.Interface.ContactInfo is an interface for requesting information about a contact on a given connection. Or in IRC parlance, Telepathy clients need this interface for displaying the WHOIS information. This interface was not implemented in Idle, which prevented Empathy and friends from offering the
/whois command to the user.
However, this is going to change with the upcoming release of Telepathy Idle 0.1.10.
Clients should invoke the RequestContactInfo method on the ContactInfo interface and pass the handle of the target nick. In return they will receive a list of Contact_Info_Fields, where each field is modelled on a single vCard field as defined in RFC 2426. However, due to the quirky nature of IRC and to fit in all the little variations implemented by the different IRC daemons, Idle uses quite a few non-standard fields.
Here is a brief explanation of each field as used by Idle:
- fn: The contact’s full name returned by the RPL_WHOISUSER or 311 numeric as defined in RFC 2812.
- nickname: The account name of the target nick. On Freenode, a user’s account name and primary nick are the same. This field is only present if the nick has identified itself to the server.
- x-host: The value can have more than one component. The first component is the hostname from which the nick is connected to the server, and the optional second component is the IP address. This field is only present if the user had issued a WHOIS against her own nick.
- x-idle-time: The number of seconds for which the contact has been idle returned by the RPL_WHOISIDLE or 317 numeric defined in RFC 2812.
- x-irc-channel: There can be multiple occurrences of this field. Each field specifies a channel that the user is present in. Any special role played by the user in a channel will be indicated by vCard field parameters. eg., ‘role=@’ or ‘role=+’ to show that the user is a channel operator or has been granted permission to speak on a moderated channel respectively. This information is obtained from the RPL_WHOISCHANNELS or 319 numeric defined in RFC 2812.
- x-irc-operator: True, if the nick is an IRC operator as returned by the RPL_WHOISOPERATOR or 313 numeric defined in RFC 2812. Please note that channel operators are not the same as IRC operators.
- x-irc-registered-nick: True, if the nick has been registered. This is related to the nickname field in that every registered nick might not have a nickname but the opposite is true.
- x-irc-secure-connection: True. if the nick is connected to its server over a secure connection.
- x-irc-server: The value has two components. The first is the hostname of the server to which the target nick is connected and the second is some information about the server. This information is obtained from the RPL_WHOISSERVER or 312 numeric defined in RFC 2812.
- x-presence-status-identifier: Value is “away” if the user has set an away message, otherwise it is “available”. This is meant as a well-known string identifier for the x-presence-type values as specified in Connection.Interface.SimplePresence.
- x-presence-status-message: The away message set by the user returned by the RPL_AWAY or 301 numeric as defined in RFC 2812.
- x-presence-type: Modelled on Connection_Presence_Type, the value is ‘3’ if the user has set an away message, otherwise it is ‘2’.
Here is a complete vCard returned by RequestContactInfo in Python-like syntax:
[ ('fn', , ['Debarshi Ray']), ('x-irc-channel', , ['#glug-nith']), ('x-irc-channel', ['role=@'], ['#solang']), ('x-irc-channel', , ['#telepathy']), ('x-irc-server', , ['lindbohm.freenode.net', 'Stockholm, Sweden']), ('x-irc-secure-connection', , ['true']), ('x-idle-time', , ['42']), ('nickname', , ['debarshi']), ('x-presence-type', , ['2']), ('x-presence-status-identifier', , ['available']), ('x-presence-status-message', , ['']), ('x-irc-operator', , ['false']), ('x-irc-registered-nick', , ['true']) ]