summaryrefslogtreecommitdiff
path: root/src/im-factory.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/im-factory.c')
-rw-r--r--src/im-factory.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/im-factory.c b/src/im-factory.c
index d55619a94..810a647f2 100644
--- a/src/im-factory.c
+++ b/src/im-factory.c
@@ -39,7 +39,6 @@
#include "tp-channel-factory-iface.h"
static void gabble_im_factory_iface_init (gpointer g_iface, gpointer iface_data);
-static LmHandlerResult im_factory_message_cb (LmMessageHandler*, LmConnection*, LmMessage*, gpointer);
G_DEFINE_TYPE_WITH_CODE (GabbleImFactory, gabble_im_factory, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_FACTORY_IFACE, gabble_im_factory_iface_init));
@@ -84,19 +83,11 @@ gabble_im_factory_constructor (GType type, guint n_props,
GObjectConstructParam *props)
{
GObject *obj;
- GabbleImFactoryPrivate *priv;
+ /* GabbleImFactoryPrivate *priv; */
obj = G_OBJECT_CLASS (gabble_im_factory_parent_class)->
constructor (type, n_props, props);
- priv = GABBLE_IM_FACTORY_GET_PRIVATE (obj);
-
- g_assert(priv->conn != NULL);
- g_assert(priv->conn->lmconn != NULL);
-
- priv->message_cb = lm_message_handler_new (im_factory_message_cb, obj, NULL);
- lm_connection_register_message_handler (priv->conn->lmconn, priv->message_cb,
- LM_MESSAGE_TYPE_MESSAGE,
- LM_HANDLER_PRIORITY_LAST);
+ /* priv = GABBLE_IM_FACTORY_GET_PRIVATE (obj); */
return obj;
}
@@ -321,6 +312,23 @@ gabble_im_factory_iface_close_all (TpChannelFactoryIface *iface)
}
static void
+gabble_im_factory_iface_connecting (TpChannelFactoryIface *iface)
+{
+ GabbleImFactory *fac = GABBLE_IM_FACTORY (iface);
+ GabbleImFactoryPrivate *priv = GABBLE_IM_FACTORY_GET_PRIVATE (fac);
+
+ g_debug ("%s: adding callbacks", G_STRFUNC);
+
+ g_assert (priv->message_cb == NULL);
+
+ priv->message_cb = lm_message_handler_new (im_factory_message_cb, fac, NULL);
+ lm_connection_register_message_handler (priv->conn->lmconn, priv->message_cb,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_LAST);
+}
+
+
+static void
gabble_im_factory_iface_connected (TpChannelFactoryIface *iface)
{
/* nothing to do */
@@ -334,12 +342,12 @@ gabble_im_factory_iface_disconnected (TpChannelFactoryIface *iface)
g_debug ("%s: removing callbacks", G_STRFUNC);
- if (priv->message_cb)
- {
- lm_connection_unregister_message_handler (priv->conn->lmconn, priv->message_cb,
- LM_MESSAGE_TYPE_MESSAGE);
- priv->message_cb = NULL;
- }
+ g_assert (priv->message_cb != NULL);
+
+ lm_connection_unregister_message_handler (priv->conn->lmconn, priv->message_cb,
+ LM_MESSAGE_TYPE_MESSAGE);
+ lm_message_handler_unref (priv->message_cb);
+ priv->message_cb = NULL;
}
struct _ForeachData
@@ -409,6 +417,7 @@ gabble_im_factory_iface_init (gpointer g_iface,
TpChannelFactoryIfaceClass *klass = (TpChannelFactoryIfaceClass *) g_iface;
klass->close_all = gabble_im_factory_iface_close_all;
+ klass->connecting = gabble_im_factory_iface_connecting;
klass->connected = gabble_im_factory_iface_connected;
klass->disconnected = gabble_im_factory_iface_disconnected;
klass->foreach = gabble_im_factory_iface_foreach;