diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2009-09-14 18:08:59 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2009-09-14 18:08:59 +0800 |
commit | 3ee3162a25751ce528cf84661b2d515820b15cfb (patch) | |
tree | 7914730ce92aa230695fd76176d047882b95f7e9 /src | |
parent | ddcb7848002b70bc8950d45a9079582a8787c394 (diff) | |
download | gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.tar gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.tar.gz gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.tar.bz2 gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.tar.lz gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.tar.xz gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.tar.zst gsoc2013-empathy-3ee3162a25751ce528cf84661b2d515820b15cfb.zip |
Move protocol_is_supported() to empathy-import-utils
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-import-utils.c | 44 | ||||
-rw-r--r-- | src/empathy-import-utils.h | 4 | ||||
-rw-r--r-- | src/empathy-import-widget.c | 31 |
3 files changed, 53 insertions, 26 deletions
diff --git a/src/empathy-import-utils.c b/src/empathy-import-utils.c index f84b20609..520f056f4 100644 --- a/src/empathy-import-utils.c +++ b/src/empathy-import-utils.c @@ -21,6 +21,7 @@ #include <telepathy-glib/util.h> +#include <libempathy/empathy-connection-managers.h> #include <libempathy/empathy-utils.h> #include "empathy-import-utils.h" @@ -74,3 +75,46 @@ empathy_import_accounts_load (EmpathyImportApplication id) 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; +} diff --git a/src/empathy-import-utils.h b/src/empathy-import-utils.h index 8c971a04d..20af25a91 100644 --- a/src/empathy-import-utils.h +++ b/src/empathy-import-utils.h @@ -22,6 +22,7 @@ #ifndef __EMPATHY_IMPORT_UTILS_H__ #define __EMPATHY_IMPORT_UTILS_H__ +#include <telepathy-glib/connection-manager.h> #include <glib.h> G_BEGIN_DECLS @@ -51,6 +52,9 @@ void empathy_import_account_data_free (EmpathyImportAccountData *data); 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__ */ diff --git a/src/empathy-import-widget.c b/src/empathy-import-widget.c index 17f196229..34f94e551 100644 --- a/src/empathy-import-widget.c +++ b/src/empathy-import-widget.c @@ -101,31 +101,6 @@ import_widget_account_id_in_list (GList *accounts, 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) { @@ -143,10 +118,14 @@ 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); |