2 * Copyright (C) 2009 Collabora Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * Authors: Jonny Lamb <jonny.lamb@collabora.co.uk>
19 * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
23 #include "empathy-import-utils.h"
25 #include <tp-account-widgets/tpaw-connection-managers.h>
26 #include <tp-account-widgets/tpaw-utils.h>
28 #include "empathy-import-pidgin.h"
29 #include "empathy-utils.h"
31 EmpathyImportAccountData *
32 empathy_import_account_data_new (const gchar *source)
34 EmpathyImportAccountData *data;
36 g_return_val_if_fail (!TPAW_STR_EMPTY (source), NULL);
38 data = g_slice_new0 (EmpathyImportAccountData);
39 data->settings = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
40 (GDestroyNotify) tp_g_value_slice_free);
41 data->source = g_strdup (source);
42 data->protocol = NULL;
43 data->connection_manager = NULL;
44 data->enabled = FALSE;
50 empathy_import_account_data_free (EmpathyImportAccountData *data)
54 if (data->protocol != NULL)
55 g_free (data->protocol);
56 if (data->connection_manager != NULL)
57 g_free (data->connection_manager);
58 if (data->settings != NULL)
59 g_hash_table_unref (data->settings);
60 if (data->source != NULL)
61 g_free (data->source);
63 g_slice_free (EmpathyImportAccountData, data);
67 empathy_import_accounts_to_import (void)
69 return empathy_import_pidgin_accounts_to_import ();
73 empathy_import_accounts_load (EmpathyImportApplication id)
75 if (id == EMPATHY_IMPORT_APPLICATION_PIDGIN)
76 return empathy_import_pidgin_load ();
78 return empathy_import_pidgin_load ();
82 empathy_import_protocol_is_supported (const gchar *protocol,
83 TpConnectionManager **cm)
85 TpawConnectionManagers *manager;
88 gboolean proto_is_supported = FALSE;
90 manager = tpaw_connection_managers_dup_singleton ();
91 cms = tpaw_connection_managers_get_cms (manager);
93 for (l = cms; l; l = l->next)
96 TpConnectionManager *tp_cm = l->data;
97 if (tp_connection_manager_has_protocol (tp_cm,
98 (const gchar*) protocol))
100 if (!tp_strdiff (protocol, "irc")
101 && !tp_strdiff (tp_connection_manager_get_name (tp_cm), "haze"))
104 if (!proto_is_supported)
107 proto_is_supported = TRUE;
112 /* we have more than one CM for this protocol,
113 * select the one which is not haze.
115 if (!tp_strdiff (tp_connection_manager_get_name ((*cm)), "haze"))
123 g_object_unref (manager);
125 return proto_is_supported;