Beispiel #1
0
/**
 * empathy_account_get_connection:
 * @account: a #EmpathyAccount
 *
 * Get the connection of the account, or NULL if account is offline or the
 * connection is not yet ready. This function does not return a new ref.
 *
 * Returns: the connection of the account.
 **/
TpConnection *
empathy_account_get_connection (EmpathyAccount *account)
{
  EmpathyAccountPriv *priv = GET_PRIV (account);

  if (priv->connection != NULL &&
      tp_connection_is_ready (priv->connection))
    return priv->connection;

  return NULL;
}
/**
 * empathy_account_manager_get_connection:
 * @manager: a #EmpathyAccountManager
 * @account: a #McAccount
 *
 * Get the connection of the accounts, or NULL if account is offline or the
 * connection is not yet ready. This function does not return a new ref.
 *
 * Returns: the connection of the accounts.
 **/
TpConnection *
empathy_account_manager_get_connection (EmpathyAccountManager *manager,
                                        McAccount *account)
{
  EmpathyAccountManagerPriv *priv;
  AccountData *data;

  g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);
  g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);

  priv = GET_PRIV (manager);

  data = g_hash_table_lookup (priv->accounts, account);
  if (data && data->connection && tp_connection_is_ready (data->connection))
    return data->connection;

  return NULL;
}
/**
 * empathy_account_manager_dup_connections:
 * @manager: a #EmpathyAccountManager
 *
 * Get a #GList of all ready #TpConnection. The list must be freed with
 * g_list_free, and its elements must be unreffed.
 *
 * Returns: the list of connections
 **/
GList *
empathy_account_manager_dup_connections (EmpathyAccountManager *manager)
{
  EmpathyAccountManagerPriv *priv;
  GHashTableIter iter;
  gpointer connection;
  GList *ret = NULL;

  g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL);

  priv = GET_PRIV (manager);

  g_hash_table_iter_init (&iter, priv->connections);
  while (g_hash_table_iter_next (&iter, &connection, NULL))
    if (connection != NULL && tp_connection_is_ready (connection))
      ret = g_list_prepend (ret, g_object_ref (connection));

  return ret;
}