#include <telepathy-glib/util.h>
+#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-utils.h>
#include "empathy-import-utils.h"
return empathy_import_pidgin_load ();
}
+
+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 (!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;
+}
#ifndef __EMPATHY_IMPORT_UTILS_H__
#define __EMPATHY_IMPORT_UTILS_H__
+#include <telepathy-glib/connection-manager.h>
#include <glib.h>
G_BEGIN_DECLS
gboolean empathy_import_accounts_to_import (void);
GList *empathy_import_accounts_load (EmpathyImportApplication id);
+gboolean empathy_import_protocol_is_supported (const gchar *protocol,
+ TpConnectionManager **cm);
+
G_END_DECLS
#endif /* __EMPATHY_IMPORT_UTILS_H__ */
return FALSE;
}
-static gboolean
-protocol_is_supported (EmpathyImportWidget *self,
- EmpathyImportAccountData *data)
-{
- EmpathyImportWidgetPriv *priv = GET_PRIV (self);
- GList *cms = empathy_connection_managers_get_cms (priv->cms);
- GList *l;
- gboolean proto_is_supported = FALSE;
-
- for (l = cms; l; l = l->next)
- {
- TpConnectionManager *tp_cm = l->data;
- const gchar *cm_name = tp_connection_manager_get_name (tp_cm);
- if (tp_connection_manager_has_protocol (tp_cm,
- (const gchar*) data->protocol))
- {
- data->connection_manager = g_strdup (cm_name);
- proto_is_supported = TRUE;
- break;
- }
- }
-
- return proto_is_supported;
-}
-
static void
import_widget_add_accounts_to_model (EmpathyImportWidget *self)
{
EmpathyImportAccountData *data = l->data;
gboolean import;
GList *accounts;
+ TpConnectionManager *cm = NULL;
- if (!protocol_is_supported (self, data))
+ if (!empathy_import_protocol_is_supported (data->protocol, &cm))
continue;
+ data->connection_manager = g_strdup (
+ tp_connection_manager_get_name (cm));
+
value = g_hash_table_lookup (data->settings, "account");
accounts = empathy_account_manager_dup_accounts (manager);