summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-04-06 10:32:58 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-04-06 10:36:34 +0100
commitd208ffca52be5d0a0e585db8ea6d592ce84edfaa (patch)
tree2950dbd745c51506c93185419cfec15d099a9913
parentb2304457ef55403509d7c4df85d968dc12410be1 (diff)
meta-porter: clean up porter closing callbacks
They all share more code now, the signal handler disconnection is in its own function and the porter timeouts are no longer removed. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--wocky/wocky-meta-porter.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/wocky/wocky-meta-porter.c b/wocky/wocky-meta-porter.c
index 5eff152..1b5b6f9 100644
--- a/wocky/wocky-meta-porter.c
+++ b/wocky/wocky-meta-porter.c
@@ -179,44 +179,34 @@ porter_timeout_cb (gpointer d)
return FALSE;
}
+static void porter_closing_cb (WockyPorter *porter, PorterData *data);
static void porter_remote_closed_cb (WockyPorter *porter, PorterData *data);
+static void porter_remote_error_cb (WockyPorter *porter, GQuark domain,
+ gint code, const gchar *msg, PorterData *data);
static void
-porter_closing_cb (WockyPorter *porter,
+disconnect_porter_signal_handlers (WockyPorter *porter,
PorterData *data)
{
- DEBUG ("porter to '%s' closing, remove it from our records", data->jid);
-
- if (data->timeout_id > 0)
- g_source_remove (data->timeout_id);
-
- data->timeout_id = 0;
-
g_signal_handlers_disconnect_by_func (porter,
porter_remote_closed_cb, data);
g_signal_handlers_disconnect_by_func (porter,
porter_closing_cb, data);
-
- if (data->porter != NULL)
- g_object_unref (data->porter);
- data->porter = NULL;
+ g_signal_handlers_disconnect_by_func (porter,
+ porter_remote_error_cb, data);
}
static void
-porter_remote_closed_cb (WockyPorter *porter,
+porter_closing_cb (WockyPorter *porter,
PorterData *data)
{
- DEBUG ("porter closed by remote, remove it from our records");
-
- if (data->timeout_id > 0)
- g_source_remove (data->timeout_id);
+ DEBUG ("porter to '%s' closing, remove it from our records", data->jid);
- data->timeout_id = 0;
+ /* Don't stop the porter timeout here because that means if a
+ * connection is never opened to the contact again the PorterData
+ * struct will stick around until the meta porter is disposed. */
- g_signal_handlers_disconnect_by_func (porter,
- porter_remote_closed_cb, data);
- g_signal_handlers_disconnect_by_func (porter,
- porter_closing_cb, data);
+ disconnect_porter_signal_handlers (porter, data);
if (data->porter != NULL)
g_object_unref (data->porter);
@@ -224,14 +214,23 @@ porter_remote_closed_cb (WockyPorter *porter,
}
static void
+porter_remote_closed_cb (WockyPorter *porter,
+ PorterData *data)
+{
+ DEBUG ("porter closed by remote, remove it from our records");
+ porter_closing_cb (porter, data);
+}
+
+static void
porter_remote_error_cb (WockyPorter *porter,
GQuark domain,
gint code,
const gchar *msg,
PorterData *data)
{
+ DEBUG ("remote error in porter, close it");
wocky_porter_force_close_async (porter, NULL, NULL, NULL);
- porter_remote_closed_cb (porter, data);
+ porter_closing_cb (porter, data);
}
static void