Methods
Connect | () | → | nothing | |
Disconnect | () | → | nothing | |
InspectHandles | (u: Handle_Type, au: Handles) | → | as: Identifiers | |
RequestHandles | (u: Handle_Type, as: Identifiers) | → | au: Handles | |
AddClientInterest | (as: Tokens) | → | nothing | |
RemoveClientInterest | (as: Tokens) | → | nothing |
Signals
SelfHandleChanged | (u: Self_Handle) | |
ConnectionError | (s: Error, a{sv}: Details) | |
StatusChanged | (u: Status, u: Reason) |
Properties
Interfaces | as (DBus_Interface_List) | Read only | ||
Protocol | s (Protocol_Name) | Read only | ||
SelfHandle | u (Contact_Handle) | Read only | ||
Status | u (Connection_Status) | Read only |
Contact Attributes
im.telepathy1.Connection/contact-id | s |
Types
Handle | Simple Type | u | |
Contact_Handle | Simple Type | u | |
Room_Handle | Simple Type | u | |
Handle_Type | Enum | u | |
Connection_Status | Enum | u | |
Connection_Status_Reason | Enum | u |
Description
This models a connection to a single user account on a communication service. Its basic capability is to provide the facility to request and receive channels of differing types (such as text channels or streaming media channels) which are used to carry out further communication.
In order to allow Connection objects to be discovered by new clients,
the object path and well-known bus name MUST be of the form
/im/telepathy1/Connection/cmname/proto/account
and
im.telepathy1.Connection.cmname.proto.account
where:
- cmname is the same Connection_Manager_Name that appears in the connection manager's object path and well-known bus name
- proto is the Protocol_Name as seen in Protocols, but with "-" replaced with "_" to get a valid object path/bus name
- account is some non-empty sequence of ASCII letters, digits and underscores not starting with a digit
account SHOULD be formed such that any valid distinct connection instance on this protocol has a distinct name. This might be formed by including the server name followed by the user name (escaped via some suitable mechanism like telepathy-glib's tp_escape_as_identifier() function to preserve uniqueness); on protocols where connecting multiple times is permissable, a per-connection identifier might be necessary to ensure uniqueness.
Clients MAY parse the object path to determine the connection manager name and the protocol, but MUST NOT attempt to parse the account part. Connection managers MAY use any unique string for this part.
As well as the methods and signatures below, arbitrary interfaces may be provided by the Connection object to represent extra connection-wide functionality, such as the Connection.Interface.Presence for receiving and reporting presence information, and Connection.Interface.Aliasing for connections where contacts may set and change an alias for themselves. These interfaces can be discovered using the Interfaces property.
Contacts, rooms, and server-stored lists (such as subscribed contacts, block lists, or allow lists) on a service are all represented by immutable handles, which are unsigned non-zero integers which are valid only for the lifetime of the connection object, and are used throughout the protocol where these entities are represented, allowing simple testing of equality within clients.
Zero as a handle value is sometimes used as a "null" value to mean the absence of a contact, room, etc.
Handles have per-type uniqueness, meaning that every (handle type, handle number) tuple is guaranteed to be unique within a connection for the lifetime of the connection and that a handle alone (without its type) is meaningless or ambiguous.
Methods
Connect () → nothing
Request that the connection be established. This will be done asynchronously and errors will be returned by emitting StatusChanged signals.
Calling this method on a Connection that is already connecting or connected is allowed, and has no effect.
Disconnect () → nothing
InspectHandles (u: Handle_Type, au: Handles) → as: Identifiers
Parameters
- Handle_Type — u (Handle_Type)
- Handles — au (Handle_List)
Returns
- Identifiers — as
Possible Errors
- Disconnected
- Invalid Argument
- Invalid Handle
Rationale:
RequestHandles (u: Handle_Type, as: Identifiers) → au: Handles
Parameters
- Handle_Type — u (Handle_Type)
- Identifiers — as
Returns
- Handles — au (Handle_List)
Request several handles from the connection manager which represent a number of contacts, rooms or server-stored lists on the service.
Possible Errors
- Disconnected
- Invalid Handle
- Not Implemented
Rationale:
Rationale:
Rationale:
AddClientInterest (as: Tokens) → nothing
Parameters
- Tokens — as
Interfaces or parts of interfaces in which to register an interest, represented by either a DBus_Interface, or a string prefixed with a DBus_Interface.
If the Connection does not support one of these tokens, this is not considered to be an error; the unsupported token is simply ignored.
Register a client's interest in notifications related to one or more interfaces.
Groups of notifications are identified by a token which is either a D-Bus interface name, or a string that starts with a D-Bus interface name. The meaning of each token is given by that D-Bus interface, which MUST define it in its documentation.
Rationale:
Initially, all interests are in entire interface, but allowing other strings allows subscription to part of an interface; for instance, an interest in ...MailNotification/count could track the number of messages without caring about their detailed content.
For each token with which this method interacts, the Connection tracks an "interest count" (like a reference count) for each unique bus name that has called this method. When a client calls this method, for each token, the interest count for its unique bus name is incremented; when RemoveClientInterest is called, all interest counts for that unique bus name are decremented. If the unique bus name leaves the bus (for instance, if the client crashes or exits), all interest counts for that unique bus name are set to zero.
The Connection can then use these reference counts to avoid subscribing to protocol-level notifications unless at least one client has a non-zero interest count for the relevant token.
Rationale:
This method exists to reduce memory and network overhead when there is no active subscription.
One situation where this is useful is Location1: on XMPP, location updates are received
over PEP. If the Connection advertises the
geoloc+notify
capability, it will be sent location
updates for all contacts. To avoid consuming resources for this,
the connection should avoid advertising that capability until
a client has expressed an interest in contacts' locations.
Another example of a protocol that benefits from this method is the Google XMPP Mail Notification extension, which can be used to implement MailNotification1. In this protocol, the CM receives a notification that something has changed, but to get more information, the CM must request this information. Knowing that nobody is currently interested in this information, the CM can avoid generating useless network traffic. Similarly, the CM may free the list of unread messages to reduce memory overhead.
If this method is called for an interface that might require protocol-level subscription, but the connection cannot set up that subscription yet (for instance because the Status is not Connected yet), the Connection MUST remember the client's interest, and attempt to subscribe to the appropriate protocol feature when this becomes possible.
Clients MAY ignore any errors raised by this method; it is intended to be called with the reply ignored.
Rationale:
The only reason it could fail is if it's unimplemented, in which case the only thing the client can usefully do is to proceed as if it had succeeded.
RemoveClientInterest (as: Tokens) → nothing
Parameters
- Tokens — as
Interfaces or parts of interfaces that were previously passed to AddClientInterest.
Release an interest registered using AddClientInterest. See that method's documentation for details.
Clients MAY ignore any errors raised by this method; it is intended to be called with the reply ignored.
Rationale:
The only reasons it could fail are if it's unimplemented, or if the client's reference-counting is wrong and it has tried to remove a client interest that it did not add. In both cases, there's nothing the client could do about it.
Signals
SelfHandleChanged (u: Self_Handle)
Parameters
- Self_Handle — u (Contact_Handle)
ConnectionError (s: Error, a{sv}: Details)
Parameters
- Error — s (DBus_Error_Name)
- Details — a{sv} (String_Variant_Map)
- debug-message (s)
- Debugging information on the change, corresponding to the message part of a D-Bus error message, which SHOULD NOT be displayed to users under normal circumstances
- server-message (s)
- A human-readable message from the server explaining what happened. This may be in the user's native language, or in the server operator's native language, or even in Lojban.
- user-requested (b), expected-hostname (s), certificate-hostname (s)
- The same details defined in TLS_Certificate_Rejection.
im.telepathy1.Error.ConnectionRefused
for Connection_Status_Reason_Network_Error)
or a protocol-specific or connection-manager-specific error in a
suitable namespace.
Rationale:
Additional information about the error, which may include the following well-known keys:
Emitted when an error occurs that renders this connection unusable.
Whenever this signal is emitted, it MUST immediately be followed by a StatusChanged signal with status Connection_Status_Disconnected and an appropriate reason code.
Connection managers SHOULD emit this signal on disconnection, but need not do so. Clients MUST support connection managers that emit StatusChanged(Disconnected, ...) without first emitting ConnectionError.
Rationale:
This signal provides additional information about the reason for disconnection. The reason for connection is always straightforward - it was requested - so it does not need further explanation. However, on errors, it can be useful to provide additional information.
The Connection_Status_Reason is not given here, since it will be signalled in StatusChanged. A reasonable client implementation would be to store the information given by this signal until StatusChanged is received, at which point the information given by this signal can be used to supplement the StatusChanged signal.
StatusChanged (u: Status, u: Reason)
Parameters
- Status — u (Connection_Status)
- Reason — u (Connection_Status_Reason)
Properties
Interfaces — as (DBus_Interface_List)
The set of optional interfaces supported by this connection. Before the connection status changes to CONNECTED, this property may change at any time, but it is guaranteed that interfaces will only be added, not removed. After the connection status changes to CONNECTED, this property cannot change further.
There is no explicit change notification; reasonable behaviour for a client would be to retrieve the interfaces list once initially, and once more when it becomes CONNECTED.
Rationale:
In some connection managers, certain capabilities of a connection are known to be implemented for all connections (e.g. support for Presence), and some interfaces (like Presence) can even be used before connecting. Other capabilities may or may not exist, depending on server functionality; by the time the connection goes CONNECTED, the connection manager is expected to have evaluated the server's functionality and enabled any extra interfaces for the remainder of the Connection's lifetime.
SelfHandle — u (Contact_Handle)
Status — u (Connection_Status)
The current status of the connection. Change notification is via the StatusChanged signal.
If retrieval of property succeeds and yields the value Disconnected, this indicates that the connection has not yet been established. If connection has been attempted and failed, the Connection object SHOULD be removed from the bus entirely, meaning that retrieval of this property SHOULD fail.
Contact Attributes
im.telepathy1.Connection/contact-id — s
The same string that would be returned by InspectHandles. As a special case, this is always present in the result of GetContactAttributes, whether it was explicitly requested or not.
Types
Contact_Handle — u
Room_Handle — u
Handle_Type — u
- None (0)
- Contact (1)
- Room (2)
Connection_Status — u
- Connected (0)
- Connecting (1)
- Disconnected (2)
Connection_Status_Reason — u
A reason why the status of the connection changed. Apart from Requested, the values of this enumeration only make sense as reasons why the status changed to Disconnected.
- None_Specified (0)
- Requested (1)
- Network_Error (2)
- Authentication_Failed (3)
- Encryption_Error (4)
- Name_In_Use (5)
- If the status change is from Connecting to Disconnected
and the 'register' parameter to RequestConnection was present
and true, the requested account could not be created on the
server because it already exists.
The equivalent D-Bus error is
im.telepathy1.Error.RegistrationExists
. - If the status change is from Connecting to Disconnected
but the 'register' parameter is absent or false, the connection
manager could not connect to the specified account because
a connection to that account already exists.
The equivalent D-Bus error is
im.telepathy1.Error.AlreadyConnected
.Rationale:
In some protocols, like XMPP (when connecting with the same JID and resource as an existing connection), the existing connection "wins" and the new one fails to connect. - If the status change is from Connected to Disconnected,
the existing connection was automatically disconnected because
a new connection to the same account (perhaps from a different
client or location) was established.
The equivalent D-Bus error is
im.telepathy1.Error.ConnectionReplaced
.Rationale:
In some protocols, like MSNP (when connecting twice with the same Passport), the new connection "wins" and the existing one is automatically disconnected. - Cert_Not_Provided (6)
- Cert_Untrusted (7)
- Cert_Expired (8)
- Cert_Not_Activated (9)
- Cert_Hostname_Mismatch (10)
- Cert_Fingerprint_Mismatch (11)
- Cert_Self_Signed (12)
- Cert_Other_Error (13)
- Cert_Revoked (14)
- Cert_Insecure (15)
- Cert_Limit_Exceeded (16)
There is no reason set for this state change. Unknown status reasons SHOULD be treated like this reason.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Disconnected
.
The change is in response to a user request. Changes to the Connecting or Connected status SHOULD always indicate this reason; changes to the Disconnected status SHOULD indicate this reason if and only if the disconnection was requested by the user.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cancelled
.
There was an error sending or receiving on the network socket.
When the status changes from Connecting to Disconnected for this
reason, the equivalent D-Bus error is either
im.telepathy1.Error.NetworkError
,
im.telepathy1.Error.ConnectionRefused
,
im.telepathy1.Error.ConnectionFailed
or some more specific error.
When the status changes from Connected to Disconnected for this
reason, the equivalent D-Bus error is either
im.telepathy1.Error.NetworkError
,
im.telepathy1.Error.ConnectionLost
or some more specific error.
The username or password was invalid.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.AuthenticationFailed
.
There was an error negotiating SSL on this connection, or encryption was unavailable and require-encryption was set when the connection was created.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.EncryptionNotAvailable
if encryption was not available at all, or
im.telepathy1.Error.EncryptionError
if encryption failed.
In general, this reason indicates that the requested account name or other identification could not be used due to conflict with another connection. It can be divided into three cases:
The server did not provide a SSL certificate.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.NotProvided
.
The server's SSL certificate is signed by an untrusted certifying authority. This error SHOULD NOT be used to represent a self-signed certificate: use the more specific Cert_Self_Signed reason for that.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.Untrusted
.
The server's SSL certificate has expired.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.Expired
.
The server's SSL certificate is not yet valid.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.NotActivated
.
The server's SSL certificate did not match its hostname.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.HostnameMismatch
.
The server's SSL certificate does not have the expected fingerprint.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.FingerprintMismatch
.
The server's SSL certificate is self-signed.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.SelfSigned
.
There was some other error validating the server's SSL certificate.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.Invalid
.
The server's SSL certificate has been revoked.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.Revoked
.
The server's SSL certificate uses an insecure algorithm, or is cryptographically weak.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.Insecure
.
The length in bytes of the server certificate, or the depth of the sever certificate chain exceed the limits imposed by the crypto library.
When disconnected for this reason, the equivalent D-Bus error is
im.telepathy1.Error.Cert.LimitExceeded