2 * empathy-accounts-plugin.c
4 * Copyright (C) 2012 Collabora Ltd. <http://www.collabora.co.uk/>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "empathy-accounts-plugin.h"
25 #include "empathy-client-factory.h"
26 #include "empathy-uoa-utils.h"
28 #include "empathy-accounts-plugin-widget.h"
30 G_DEFINE_TYPE (EmpathyAccountsPlugin, empathy_accounts_plugin, AP_TYPE_PLUGIN)
33 widget_done_cb (EmpathyAccountsPluginWidget *widget,
36 ap_plugin_emit_finished (plugin);
40 empathy_accounts_plugin_build_widget (ApPlugin *plugin)
45 account = ap_plugin_get_account (plugin);
46 empathy_uoa_manager_set_default (ag_account_get_manager (account));
48 widget = empathy_accounts_plugin_widget_new (account);
50 g_signal_connect (widget, "done",
51 G_CALLBACK (widget_done_cb), plugin);
57 store_delete_cb (AgAccount *account,
61 GSimpleAsyncResult *result = user_data;
65 g_debug ("Failed to delete account with ID '%u': %s",
66 account->id, error->message);
68 g_simple_async_result_set_from_error (result, error);
71 g_simple_async_result_complete (result);
72 g_object_unref (result);
76 empathy_accounts_plugin_delete_account (ApPlugin *plugin,
77 GAsyncReadyCallback callback,
81 GSimpleAsyncResult *result;
83 result = g_simple_async_result_new (G_OBJECT (plugin),
84 callback, user_data, ap_plugin_delete_account);
86 account = ap_plugin_get_account (plugin);
88 ag_account_delete (account);
89 ag_account_store (account, store_delete_cb, result);
93 empathy_accounts_plugin_act_headless (ApPlugin *plugin)
98 empathy_accounts_plugin_class_init (
99 EmpathyAccountsPluginClass *klass)
101 ApPluginClass *pclass = AP_PLUGIN_CLASS (klass);
103 pclass->build_widget = empathy_accounts_plugin_build_widget;
104 pclass->delete_account = empathy_accounts_plugin_delete_account;
105 pclass->act_headless = empathy_accounts_plugin_act_headless;
109 empathy_accounts_plugin_init (EmpathyAccountsPlugin *self)
111 if (tp_account_manager_can_set_default ())
113 EmpathyClientFactory *factory;
114 TpAccountManager *am;
116 factory = empathy_client_factory_dup ();
117 am = tp_account_manager_new_with_factory (
118 TP_SIMPLE_CLIENT_FACTORY (factory));
119 tp_account_manager_set_default (am);
121 g_object_unref (factory);
128 ap_module_get_object_type (void)
130 return EMPATHY_TYPE_ACCOUNTS_PLUGIN;