aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-04-13 20:39:13 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-04-13 20:39:13 +0800
commit213318adaf231512a98183394bf968ebd6c1a857 (patch)
treec0d14096dbffb7f5e22b143282780b38b5d0a30d
parent97ae7e9c570dd2165190d2549a42081963d79be3 (diff)
downloadgsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.tar
gsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.tar.gz
gsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.tar.bz2
gsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.tar.lz
gsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.tar.xz
gsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.tar.zst
gsoc2013-empathy-213318adaf231512a98183394bf968ebd6c1a857.zip
Fix disconnection of AccountStatusChanged signal.
svn path=/trunk/; revision=932
-rw-r--r--libempathy-gtk/empathy-account-chooser.c8
-rw-r--r--libempathy-gtk/empathy-accounts-dialog.c8
-rw-r--r--libempathy-gtk/empathy-chat.c7
-rw-r--r--libempathy/empathy-contact-manager.c14
-rw-r--r--libempathy/empathy-tp-contact-factory.c8
-rw-r--r--libempathy/empathy-utils.c31
-rw-r--r--libempathy/empathy-utils.h3
-rw-r--r--src/empathy-main-window.c7
8 files changed, 45 insertions, 41 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index 6b731ff73..f46f4cec6 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -47,6 +47,7 @@ typedef struct {
gboolean has_all_option;
EmpathyAccountChooserFilterFunc filter;
gpointer filter_data;
+ gpointer token;
} EmpathyAccountChooserPriv;
typedef struct {
@@ -151,10 +152,7 @@ account_chooser_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (priv->monitor,
account_chooser_account_deleted_cb,
chooser);
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
- "AccountStatusChanged",
- G_CALLBACK (account_chooser_status_changed_cb),
- chooser);
+ empathy_disconnect_account_status_changed (priv->token);
g_object_unref (priv->mc);
g_object_unref (priv->monitor);
@@ -223,7 +221,7 @@ empathy_account_chooser_new (void)
g_signal_connect (priv->monitor, "account-deleted",
G_CALLBACK (account_chooser_account_deleted_cb),
chooser);
- empathy_connect_to_account_status_changed (priv->mc,
+ priv->token = empathy_connect_to_account_status_changed (priv->mc,
G_CALLBACK (account_chooser_status_changed_cb),
chooser, NULL);
diff --git a/libempathy-gtk/empathy-accounts-dialog.c b/libempathy-gtk/empathy-accounts-dialog.c
index 6f4421b88..0ea4416a3 100644
--- a/libempathy-gtk/empathy-accounts-dialog.c
+++ b/libempathy-gtk/empathy-accounts-dialog.c
@@ -84,6 +84,7 @@ typedef struct {
MissionControl *mc;
McAccountMonitor *monitor;
+ gpointer token;
} EmpathyAccountsDialog;
enum {
@@ -962,10 +963,7 @@ accounts_dialog_destroy_cb (GtkWidget *widget,
g_signal_handlers_disconnect_by_func (dialog->monitor,
accounts_dialog_account_enabled_cb,
dialog);
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (dialog->mc),
- "AccountStatusChanged",
- G_CALLBACK (accounts_dialog_status_changed_cb),
- dialog);
+ empathy_disconnect_account_status_changed (dialog->token);
/* Delete incomplete accounts */
accounts = mc_accounts_list ();
@@ -1074,7 +1072,7 @@ empathy_accounts_dialog_show (GtkWindow *parent)
g_signal_connect (dialog->monitor, "account-disabled",
G_CALLBACK (accounts_dialog_account_enabled_cb),
dialog);
- empathy_connect_to_account_status_changed (dialog->mc,
+ dialog->token = empathy_connect_to_account_status_changed (dialog->mc,
G_CALLBACK (accounts_dialog_status_changed_cb),
dialog, NULL);
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 0328c4ee9..fce7856c4 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -77,6 +77,7 @@ struct _EmpathyChatPriv {
guint composing_stop_timeout_id;
guint block_events_timeout_id;
TpHandleType handle_type;
+ gpointer token;
GtkWidget *widget;
GtkWidget *hpaned;
@@ -1405,9 +1406,7 @@ chat_finalize (GObject *object)
chat_composing_remove_timeout (chat);
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged",
- G_CALLBACK (chat_status_changed_cb),
- chat);
+ empathy_disconnect_account_status_changed (priv->token);
g_object_unref (priv->mc);
g_object_unref (priv->log_manager);
g_object_unref (priv->store);
@@ -1537,7 +1536,7 @@ empathy_chat_init (EmpathyChat *chat)
priv->sent_messages_index = -1;
priv->mc = empathy_mission_control_new ();
- empathy_connect_to_account_status_changed (priv->mc,
+ priv->token = empathy_connect_to_account_status_changed (priv->mc,
G_CALLBACK (chat_status_changed_cb),
chat, NULL);
diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c
index a151dbd26..cad19293e 100644
--- a/libempathy/empathy-contact-manager.c
+++ b/libempathy/empathy-contact-manager.c
@@ -38,6 +38,7 @@
struct _EmpathyContactManagerPriv {
GHashTable *lists;
MissionControl *mc;
+ gpointer token;
};
static void empathy_contact_manager_class_init (EmpathyContactManagerClass *klass);
@@ -188,11 +189,7 @@ contact_manager_finalize (GObject *object)
{
EmpathyContactManagerPriv *priv = GET_PRIV (object);
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
- "AccountStatusChanged",
- G_CALLBACK (contact_manager_status_changed_cb),
- object);
-
+ empathy_disconnect_account_status_changed (priv->token);
g_hash_table_foreach (priv->lists,
contact_manager_disconnect_foreach,
object);
@@ -224,10 +221,9 @@ empathy_contact_manager_init (EmpathyContactManager *manager)
(GDestroyNotify) g_object_unref);
priv->mc = empathy_mission_control_new ();
-
- empathy_connect_to_account_status_changed (priv->mc,
- G_CALLBACK (contact_manager_status_changed_cb),
- manager, NULL);
+ priv->token = empathy_connect_to_account_status_changed (priv->mc,
+ G_CALLBACK (contact_manager_status_changed_cb),
+ manager, NULL);
/* Get ContactList for existing connections */
accounts = mission_control_get_online_connections (priv->mc, NULL);
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index 678e53b36..1c7c33f76 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -44,6 +44,7 @@ struct _EmpathyTpContactFactoryPriv {
GList *contacts;
EmpathyContact *user;
+ gpointer token;
};
static void empathy_tp_contact_factory_class_init (EmpathyTpContactFactoryClass *klass);
@@ -1196,10 +1197,7 @@ tp_contact_factory_finalize (GObject *object)
object,
mc_account_get_normalized_name (priv->account));
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc),
- "AccountStatusChanged",
- G_CALLBACK (tp_contact_factory_status_changed_cb),
- object);
+ empathy_disconnect_account_status_changed (priv->token);
for (l = priv->contacts; l; l = l->next) {
g_object_weak_unref (G_OBJECT (l->data),
@@ -1277,7 +1275,7 @@ empathy_tp_contact_factory_init (EmpathyTpContactFactory *tp_factory)
EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory);
priv->mc = empathy_mission_control_new ();
- empathy_connect_to_account_status_changed (priv->mc,
+ priv->token = empathy_connect_to_account_status_changed (priv->mc,
G_CALLBACK (tp_contact_factory_status_changed_cb),
tp_factory, NULL);
}
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 46fb97027..3876cdf48 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -639,16 +639,16 @@ typedef void (*AccountStatusChangedFunc) (MissionControl *mc,
McPresence presence,
TpConnectionStatusReason reason,
const gchar *unique_name,
- gpointer *user_data);
+ gpointer user_data);
typedef struct {
AccountStatusChangedFunc handler;
gpointer user_data;
GClosureNotify free_func;
+ MissionControl *mc;
} AccountStatusChangedData;
typedef struct {
- MissionControl *mc;
TpConnectionStatus status;
McPresence presence;
TpConnectionStatusReason reason;
@@ -665,6 +665,7 @@ account_status_changed_data_free (gpointer ptr,
if (data->free_func) {
data->free_func (data->user_data, closure);
}
+ g_object_unref (data->mc);
g_slice_free (AccountStatusChangedData, data);
}
@@ -673,7 +674,7 @@ account_status_changed_invoke_callback (gpointer data)
{
InvocationData *invocation_data = data;
- invocation_data->data->handler (invocation_data->mc,
+ invocation_data->data->handler (invocation_data->data->mc,
invocation_data->status,
invocation_data->presence,
invocation_data->reason,
@@ -697,18 +698,18 @@ account_status_changed_cb (MissionControl *mc,
InvocationData *invocation_data;
invocation_data = g_slice_new (InvocationData);
- invocation_data->mc = mc;
invocation_data->status = status;
invocation_data->presence = presence;
invocation_data->reason = reason;
invocation_data->unique_name = g_strdup (unique_name);
invocation_data->data = data;
+
g_idle_add_full (G_PRIORITY_HIGH,
account_status_changed_invoke_callback,
invocation_data, NULL);
}
-void
+gpointer
empathy_connect_to_account_status_changed (MissionControl *mc,
GCallback handler,
gpointer user_data,
@@ -716,16 +717,30 @@ empathy_connect_to_account_status_changed (MissionControl *mc,
{
AccountStatusChangedData *data;
- g_return_if_fail (IS_MISSIONCONTROL (mc));
- g_return_if_fail (handler != NULL);
+ g_return_val_if_fail (IS_MISSIONCONTROL (mc), NULL);
+ g_return_val_if_fail (handler != NULL, NULL);
data = g_slice_new (AccountStatusChangedData);
-
data->handler = (AccountStatusChangedFunc) handler;
data->user_data = user_data;
data->free_func = free_func;
+ data->mc = g_object_ref (mc);
+
dbus_g_proxy_connect_signal (DBUS_G_PROXY (mc), "AccountStatusChanged",
G_CALLBACK (account_status_changed_cb),
data, account_status_changed_data_free);
+
+ return data;
+}
+
+void
+empathy_disconnect_account_status_changed (gpointer token)
+{
+ AccountStatusChangedData *data = token;
+
+ dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (data->mc),
+ "AccountStatusChanged",
+ G_CALLBACK (account_status_changed_cb),
+ data);
}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 2b14374fb..421031704 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -102,10 +102,11 @@ void empathy_run_until_ready_full (gpointer object,
gpointer user_data,
GMainLoop **loop);
McAccount * empathy_channel_get_account (TpChannel *channel);
-void empathy_connect_to_account_status_changed (MissionControl *mc,
+gpointer empathy_connect_to_account_status_changed (MissionControl *mc,
GCallback handler,
gpointer user_data,
GClosureNotify free_func);
+void empathy_disconnect_account_status_changed (gpointer token);
G_END_DECLS
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 5c46d7f7c..065c6fcc8 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -73,6 +73,7 @@ typedef struct {
EmpathyContactListStore *list_store;
MissionControl *mc;
EmpathyChatroomManager *chatroom_manager;
+ gpointer token;
GtkWidget *window;
GtkWidget *main_vbox;
@@ -239,7 +240,7 @@ empathy_main_window_show (void)
g_object_unref (glade);
window->mc = empathy_mission_control_new ();
- empathy_connect_to_account_status_changed (window->mc,
+ window->token = empathy_connect_to_account_status_changed (window->mc,
G_CALLBACK (main_window_status_changed_cb),
window, NULL);
@@ -374,9 +375,7 @@ main_window_destroy_cb (GtkWidget *widget,
/* Save user-defined accelerators. */
main_window_accels_save ();
- dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (window->mc), "AccountStatusChanged",
- G_CALLBACK (main_window_status_changed_cb),
- window);
+ empathy_disconnect_account_status_changed (window->token);
if (window->size_timeout_id) {
g_source_remove (window->size_timeout_id);