Example #1
0
static const gchar *
_get_manager_for_protocol (EmpathyConnectionManagers *managers,
    const gchar *protocol)
{
  GList *cms = empathy_connection_managers_get_cms (managers);
  GList *l;
  TpConnectionManager *haze = NULL;
  TpConnectionManager *cm = NULL;

  for (l = cms; l; l = l->next)
    {
      TpConnectionManager *tp_cm = l->data;

      /* Only use haze if no other cm provides this protocol */
      if (!tp_strdiff (tp_connection_manager_get_name (tp_cm), "haze"))
        {
          haze = tp_cm;
          continue;
        }

      if (tp_connection_manager_has_protocol (tp_cm, protocol))
        {
          cm = tp_cm;
          goto out;
        }
    }

  if (haze != NULL && tp_connection_manager_has_protocol (haze, protocol))
    return tp_connection_manager_get_name (haze);

out:
  return cm != NULL ? tp_connection_manager_get_name (cm) : NULL;
}
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));
}
gboolean
empathy_import_protocol_is_supported (const gchar *protocol,
    TpConnectionManager **cm)
{
  EmpathyConnectionManagers *manager;
  GList *cms;
  GList *l;
  gboolean proto_is_supported = FALSE;

  manager = empathy_connection_managers_dup_singleton ();
  cms = empathy_connection_managers_get_cms (manager);

  for (l = cms; l; l = l->next)
    {

      TpConnectionManager *tp_cm = l->data;
      if (tp_connection_manager_has_protocol (tp_cm,
          (const gchar*) protocol))
        {
          if (!tp_strdiff (protocol, "irc")
              && !tp_strdiff (tp_cm->name, "haze"))
              continue;

          if (!proto_is_supported)
            {
              *cm = tp_cm;
              proto_is_supported = TRUE;

              continue;
            }

          /* we have more than one CM for this protocol,
           * select the one which is not haze.
           */
          if (!tp_strdiff ((*cm)->name, "haze"))
            {
              *cm = tp_cm;
              break;
            }
        }
    }

  g_object_unref (manager);

  return proto_is_supported;
}