TpAccountManager

TpAccountManager — proxy object for the Telepathy account manager

Synopsis

#include <telepathy-glib/telepathy-glib.h>

struct              TpAccountManager;
struct              TpAccountManagerClass;
TpAccountManager *  tp_account_manager_new              (TpDBusDaemon *bus_daemon);
TpAccountManager *  tp_account_manager_new_with_factory (TpClientFactory *factory);
void                tp_account_manager_init_known_interfaces
                                                        (void);
void                tp_account_manager_set_default      (TpAccountManager *manager);
gboolean            tp_account_manager_can_set_default  (void);
TpAccountManager *  tp_account_manager_dup              (void);
void                tp_account_manager_create_account_async
                                                        (TpAccountManager *manager,
                                                         const gchar *connection_manager,
                                                         const gchar *protocol,
                                                         const gchar *display_name,
                                                         GHashTable *parameters,
                                                         GHashTable *properties,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
TpAccount *         tp_account_manager_create_account_finish
                                                        (TpAccountManager *manager,
                                                         GAsyncResult *result,
                                                         GError **error);
GList *             tp_account_manager_dup_usable_accounts
                                                        (TpAccountManager *manager);
TpConnectionPresenceType tp_account_manager_get_most_available_presence
                                                        (TpAccountManager *manager,
                                                         gchar **status,
                                                         gchar **message);
void                tp_account_manager_set_all_requested_presences
                                                        (TpAccountManager *manager,
                                                         TpConnectionPresenceType type,
                                                         const gchar *status,
                                                         const gchar *message);
void                tp_account_manager_enable_restart   (TpAccountManager *manager);

#define             TP_ACCOUNT_MANAGER_FEATURE_CORE

Object Hierarchy

  GObject
   +----TpProxy
         +----TpAccountManager

Signals

  "account-disabled"                               : Run Last
  "account-enabled"                                : Run Last
  "account-removed"                                : Run Last
  "account-usability-changed"                      : Run Last
  "most-available-presence-changed"                : Run Last

Description

The TpAccountManager object is used to communicate with the Telepathy AccountManager service.

A new TpAccountManager object can be created with tp_account_manager_dup().

To list the existing valid accounts, the client should first prepare the TP_ACCOUNT_MANAGER_FEATURE_CORE feature using tp_proxy_prepare_async(), then call tp_account_manager_dup_valid_accounts().

The "account-validity-changed" signal is emitted to notify of the validity of an account changing. New accounts are also indicated by the emission of this signal on an account that did not previously exist. (The rationale behind indicating new accounts by an account validity change signal is that clients interested in this kind of thing should be connected to this signal anyway: an account having just become valid is effectively a new account to a client.)

The "account-removed" signal is emitted when existing accounts are removed.

Details

struct TpAccountManager

struct TpAccountManager;

The Telepathy Account Manager stores real-time communication accounts and their configuration, places accounts online on request, and manipulates accounts' presence, nicknames and avatars.

TpAccountManager is the "top level" object. Since 0.16 it always has a non-NULL "factory", and its "factory" will be propagated to all other objects like TpAccountManager -> TpAccount -> TpConnection -> TpContact and TpChannel. This means that desired features set on that factory will be prepared on all those objects. If a "factory" is not specified when the TpAccountManager is constructed, it will use a TpAutomaticClientFactory.

Example 2. TpAccountManager example

1
FIXME: MISSING XINCLUDE CONTENT


Since 0.7.32


struct TpAccountManagerClass

struct TpAccountManagerClass {
};

The class of a TpAccount.


tp_account_manager_new ()

TpAccountManager *  tp_account_manager_new              (TpDBusDaemon *bus_daemon);

Convenience function to create a new account manager proxy. The returned TpAccountManager is not guaranteed to be prepared on return. Its "factory" will be a new TpAutomaticClientFactory for bus_daemon.

Use tp_account_manager_dup() instead if you want an account manager proxy on the starter or session bus (which is almost always the right thing for Telepathy).

bus_daemon :

Proxy for the D-Bus daemon

Returns :

a new reference to an account manager proxy

tp_account_manager_new_with_factory ()

TpAccountManager *  tp_account_manager_new_with_factory (TpClientFactory *factory);

Convenience function to create a new account manager proxy. The returned TpAccountManager is not guaranteed to be ready on return.

Should be used only by applications having their own TpClientFactory subclass. Usually this should be done at application startup and followed by a call to tp_account_manager_set_default() to ensure other libraries/plugins will use this custom factory as well.

factory :

a TpClientFactory

Returns :

a new reference to an account manager proxy

tp_account_manager_init_known_interfaces ()

void                tp_account_manager_init_known_interfaces
                                                        (void);

Ensure that the known interfaces for TpAccountManager have been set up. This is done automatically when necessary, but for correct overriding of library interfaces by local extensions, you should call this function before calling tp_proxy_or_subclass_hook_on_interface_add() with first argument TP_TYPE_ACCOUNT_MANAGER.

Since 0.7.32


tp_account_manager_set_default ()

void                tp_account_manager_set_default      (TpAccountManager *manager);

Define the TpAccountManager singleton that will be returned by tp_account_manager_dup().

This function may only be called before the first call to tp_account_manager_dup(), and may not be called more than once. Applications which use a custom TpClientFactory and want the default TpAccountManager to use that factory should call this after calling tp_account_manager_new_with_factory().

Only a weak reference is taken on manager. It is the caller's responsibility to keep it alive. If manager is disposed after calling this function, the next call to tp_account_manager_dup() will return a newly created TpAccountManager.

Note that manager must use the default TpDBusDaemon as returned by tp_dbus_daemon_dup().

manager :

a TpAccountManager

Since 0.15.5


tp_account_manager_can_set_default ()

gboolean            tp_account_manager_can_set_default  (void);

Check if tp_account_manager_set_default() has already successfully been called.

Returns :

TRUE if tp_account_manager_set_default() has already successfully been called in this process, FALSE otherwise.

Since 0.19.6


tp_account_manager_dup ()

TpAccountManager *  tp_account_manager_dup              (void);

Returns an account manager proxy on the D-Bus daemon on which this process was activated (if it was launched by D-Bus service activation), or the session bus (otherwise). This account manager will always have the result of tp_dbus_daemon_dup() as its "dbus-daemon".

The returned TpAccountManager is cached; the same TpAccountManager object will be returned by this function repeatedly, as long as at least one reference exists. Note that the returned TpAccountManager is not guaranteed to be ready on return.

If tp_account_manager_set_default() has been called successfully, that TpAccountManager will be returned. Otherwise, a new TpAccountManager will be created the first time this function is called, using a new TpAutomaticClientFactory as its "factory".

Returns :

an account manager proxy on the starter or session bus, or NULL if it wasn't possible to get a dbus daemon proxy for the appropriate bus. [transfer full]

Since 0.9.0


tp_account_manager_create_account_async ()

void                tp_account_manager_create_account_async
                                                        (TpAccountManager *manager,
                                                         const gchar *connection_manager,
                                                         const gchar *protocol,
                                                         const gchar *display_name,
                                                         GHashTable *parameters,
                                                         GHashTable *properties,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

Requests an asynchronous create of an account on the account manager manager. When the operation is finished, callback will be called. You can then call tp_account_manager_create_account_finish() to get the result of the operation.

The TpAccount returned by tp_account_manager_create_account_finish() will already have TP_ACCOUNT_FEATURE_CORE prepared, along with all features previously passed to tp_simple_client_factory_add_account_features() for the account manager's "factory".

It is usually better to use TpAccountRequest instead, particularly when using high-level language bindings.

manager :

a TpAccountManager

connection_manager :

the name of a connection manager

protocol :

the name of a protocol

display_name :

the display name for the account

parameters :

parameters for the new account. [element-type utf8 GObject.Value][transfer none]

properties :

properties for the new account. [element-type utf8 GObject.Value][transfer none]

callback :

a callback to call when the request is satisfied

user_data :

data to pass to callback

Since 0.9.0


tp_account_manager_create_account_finish ()

TpAccount *         tp_account_manager_create_account_finish
                                                        (TpAccountManager *manager,
                                                         GAsyncResult *result,
                                                         GError **error);

Finishes an async create account operation, and returns a new TpAccount object. It has TP_ACCOUNT_FEATURE_CORE prepared, along with all features previously passed to tp_simple_client_factory_add_account_features() for the account manager's "factory".

The caller must keep a ref to the returned object using g_object_ref() if it is to be kept beyond the lifetime of result.

manager :

a TpAccountManager

result :

a GAsyncResult

error :

a GError to be filled

Returns :

a new TpAccount which was just created on success, otherwise NULL. [transfer none]

Since 0.9.0


tp_account_manager_dup_usable_accounts ()

GList *             tp_account_manager_dup_usable_accounts
                                                        (TpAccountManager *manager);

Returns a newly allocated GList of reffed valid accounts in manager. The list must be freed with g_list_free_full() and g_object_unref() after used.

The returned TpAccounts are guaranteed to have TP_ACCOUNT_FEATURE_CORE prepared, along with all features previously passed to tp_simple_client_factory_add_account_features() for the account manager's "factory".

The list of valid accounts returned is not guaranteed to have been retrieved until TP_ACCOUNT_MANAGER_FEATURE_CORE is prepared (tp_proxy_prepare_async() has returned). Until this feature has been prepared, an empty list (NULL) will be returned.

manager :

a TpAccountManager

Returns :

a newly allocated GList of reffed valid accounts in manager. [element-type TelepathyGLib.Account][transfer full]

Since 0.19.9


tp_account_manager_get_most_available_presence ()

TpConnectionPresenceType tp_account_manager_get_most_available_presence
                                                        (TpAccountManager *manager,
                                                         gchar **status,
                                                         gchar **message);

Gets the most available presence over all accounts in manager. This function does not average presences across all accounts, but it merely finds the "most available" presence. As a result, there is a guarantee that there exists at least one account in manager with the returned presence.

If no accounts are enabled or usable the output will be (TP_CONNECTION_PRESENCE_TYPE_OFFLINE, "offline", "").

Since 0.17.5, if the only connected accounts does not implement TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE, the output will be (TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, "available", "").

The return value of this function is not guaranteed to have been retrieved until tp_proxy_prepare_async() has finished; until then, the value will be the same as if no accounts are enabled or usable.

manager :

a TpAccountManager

status :

a string to fill with the actual status. [out][transfer full]

message :

a string to fill with the actual status message. [out][transfer full]

Returns :

the most available presence across all accounts

Since 0.9.0


tp_account_manager_set_all_requested_presences ()

void                tp_account_manager_set_all_requested_presences
                                                        (TpAccountManager *manager,
                                                         TpConnectionPresenceType type,
                                                         const gchar *status,
                                                         const gchar *message);

Iterates through the accounts in manager and requests the presence (type, status and message). Note that the presence requested here is merely a request, and if might not be satisfiable.

You can find the most available presence across all accounts by calling tp_account_manager_get_most_available_presence().

Setting a requested presence on all accounts will have no effect until tp_proxy_prepare_async() (or the older tp_account_manager_prepare_async()) has finished.

manager :

a TpAccountManager

type :

a presence type to request

status :

a status to request

message :

a status message to request

Since 0.9.0


tp_account_manager_enable_restart ()

void                tp_account_manager_enable_restart   (TpAccountManager *manager);

Enable autostarting the account manager D-Bus service. This means that the account manager will be restarted if it disappears from the bus.

manager :

a TpAccountManager

TP_ACCOUNT_MANAGER_FEATURE_CORE

#define             TP_ACCOUNT_MANAGER_FEATURE_CORE

Expands to a call to a function that returns a quark for the "core" feature on a TpAccountManager.

When this feature is prepared, the list of accounts have been retrieved and are available for use, and change-notification has been set up. Additionally, since 0.16 the TpAccount objects returned by tp_account_manager_dup_usable_accounts() have their features prepared as configured by the "factory"; in particular, they will all have TP_ACCOUNT_FEATURE_CORE.

One can ask for a feature to be prepared using the tp_proxy_prepare_async() function, and waiting for it to callback.

Since 0.9.0

Signal Details

The "account-disabled" signal

void                user_function                      (TpAccountManager *manager,
                                                        TpAccount        *account,
                                                        gpointer          user_data)      : Run Last

Emitted when an account from manager is disabled.

manager :

a TpAccountManager

account :

a TpAccount

user_data :

user data set when the signal handler was connected.

Since 0.9.0


The "account-enabled" signal

void                user_function                      (TpAccountManager *manager,
                                                        TpAccount        *account,
                                                        gpointer          user_data)      : Run Last

Emitted when an account from manager is enabled.

account is guaranteed to have TP_ACCOUNT_FEATURE_CORE prepared, along with all the features previously passed to the "factory"'s tp_client_factory_add_account_features().

manager :

a TpAccountManager

account :

a TpAccount

user_data :

user data set when the signal handler was connected.

Since 0.9.0


The "account-removed" signal

void                user_function                      (TpAccountManager *manager,
                                                        TpAccount        *account,
                                                        gpointer          user_data)      : Run Last

Emitted when an account is removed from manager.

manager :

a TpAccountManager

account :

a TpAccount

user_data :

user data set when the signal handler was connected.

Since 0.9.0


The "account-usability-changed" signal

void                user_function                      (TpAccountManager *manager,
                                                        TpAccount        *account,
                                                        gboolean          usable,
                                                        gpointer          user_data)      : Run Last

Emitted when the usability on account changes.

This signal is also used to indicate a new account that did not previously exist has been added (with usable set to TRUE).

If usable is TRUE, account is guaranteed to have TP_ACCOUNT_FEATURE_CORE prepared, along with all the features previously passed to the "factory"'s tp_client_factory_add_account_features().

manager :

a TpAccountManager

account :

a TpAccount

usable :

TRUE if the account is now usable

user_data :

user data set when the signal handler was connected.

Since 0.9.0


The "most-available-presence-changed" signal

void                user_function                      (TpAccountManager *manager,
                                                        guint             presence,
                                                        gchar            *status,
                                                        gchar            *message,
                                                        gpointer          user_data)      : Run Last

Emitted when the most available presence on manager changes.

manager :

a TpAccountManager

presence :

new presence type

status :

new status

message :

new status message

user_data :

user data set when the signal handler was connected.

Since 0.9.0

See Also

TpAccount