Example #1
0
static void
cm_manager_prepared_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  if (!empathy_connection_managers_prepare_finish (
      EMPATHY_CONNECTION_MANAGERS (source), result, NULL))
    {
      g_warning ("Failed to prepare connection managers singleton");
      gtk_main_quit ();
      return;
    }

  empathy_accounts_import (TP_ACCOUNT_MANAGER (user_data),
    EMPATHY_CONNECTION_MANAGERS (source));

  maybe_show_accounts_ui (TP_ACCOUNT_MANAGER (user_data));
}
static void
import_widget_cms_prepare_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyImportWidget *self = user_data;

  if (!empathy_connection_managers_prepare_finish (
        EMPATHY_CONNECTION_MANAGERS (source), result, NULL))
    return;

  import_widget_set_up_account_list (self);
}
static void
protocol_chooser_cms_prepare_cb (GObject *source,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyConnectionManagers *cms = EMPATHY_CONNECTION_MANAGERS (source);
  EmpathyProtocolChooser *protocol_chooser = user_data;

  if (!empathy_connection_managers_prepare_finish (cms, result, NULL))
    return;

  protocol_chooser_add_cms_list (protocol_chooser,
      empathy_connection_managers_get_cms (cms));
}
static void
empathy_connection_managers_get_property (GObject *object,
    guint prop_id,
    GValue *value,
    GParamSpec *pspec)
{
  EmpathyConnectionManagers *self = EMPATHY_CONNECTION_MANAGERS (object);
  EmpathyConnectionManagersPriv *priv = GET_PRIV (self);

  switch (prop_id)
    {
      case PROP_READY:
        g_value_set_boolean (value, priv->ready);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}
static void
empathy_connection_managers_dispose (GObject *object)
{
  EmpathyConnectionManagers *self = EMPATHY_CONNECTION_MANAGERS (object);
  EmpathyConnectionManagersPriv *priv = GET_PRIV (self);

  if (priv->dispose_has_run)
    return;

  priv->dispose_has_run = TRUE;

  if (priv->dbus != NULL)
    g_object_unref (priv->dbus);
  priv->dbus = NULL;

  empathy_connection_managers_free_cm_list (self);

  /* release any references held by the object here */

  if (G_OBJECT_CLASS (empathy_connection_managers_parent_class)->dispose)
    G_OBJECT_CLASS (empathy_connection_managers_parent_class)->dispose (object);
}
static void
empathy_connection_managers_listed_cb (TpConnectionManager * const *cms,
    gsize n_cms,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  EmpathyConnectionManagers *self =
    EMPATHY_CONNECTION_MANAGERS (weak_object);
  EmpathyConnectionManagersPriv *priv = GET_PRIV (self);
  TpConnectionManager * const *iter;

  empathy_connection_managers_free_cm_list (self);

  if (error != NULL)
    {
      DEBUG ("Failed to get connection managers: %s", error->message);
      goto out;
    }

  for (iter = cms ; iter != NULL && *iter != NULL; iter++)
    {
      /* only list cms that didn't hit errors */
      if (tp_connection_manager_is_ready (*iter))
        priv->cms = g_list_prepend (priv->cms, g_object_ref (*iter));
    }

out:
  g_object_ref (weak_object);
  if (!priv->ready)
    {
      priv->ready = TRUE;
      g_object_notify (weak_object, "ready");
    }
  g_signal_emit (weak_object, signals[UPDATED], 0);
  g_object_unref (weak_object);
}
EmpathyConnectionManagers *
empathy_connection_managers_dup_singleton (void)
{
  return EMPATHY_CONNECTION_MANAGERS (
      g_object_new (EMPATHY_TYPE_CONNECTION_MANAGERS, NULL));
}