summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-02-03 13:47:18 +0000
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-02-03 13:47:18 +0000
commita68ca09705b73ea229186671e97bcddc76e51866 (patch)
tree9dd9a1be7506598cd6db545411d6b65927d05aba
parentb678ca070fbaac25b10f5794215f58771f3c4a25 (diff)
ChannelFactory registration to TplObserver
* added getter/setter for TplChannelFactory to the Observer * added Channel Factory registration phase into src/telepathy-logger.c
-rw-r--r--src/telepathy-logger.c7
-rw-r--r--telepathy-logger/channel-factory.h3
-rw-r--r--telepathy-logger/log-manager.h3
-rw-r--r--telepathy-logger/observer.c33
-rw-r--r--telepathy-logger/observer.h4
5 files changed, 45 insertions, 5 deletions
diff --git a/src/telepathy-logger.c b/src/telepathy-logger.c
index 9820f740f..8acb6eb67 100644
--- a/src/telepathy-logger.c
+++ b/src/telepathy-logger.c
@@ -27,7 +27,9 @@
static GMainLoop *loop = NULL;
-int main(int argc, char *argv[])
+int
+main(int argc,
+ char *argv[])
{
TplObserver *observer;
GError *error = NULL;
@@ -35,10 +37,13 @@ int main(int argc, char *argv[])
g_type_init ();
tpl_channel_factory_init ();
+ g_debug ("Initialising TPL Channel Factory");
tpl_channel_factory_add ("org.freedesktop.Telepathy.Channel.Type.Text",
(TplChannelConstructor) tpl_channel_text_new);
observer = tpl_observer_new ();
+ g_debug ("Registering channel factory");
+ tpl_observer_set_channel_factory (observer, tpl_channel_factory_build);
if (tpl_observer_register_dbus (observer, &error) == FALSE)
{
g_debug ("Error during D-Bus registration: %s", error->message);
diff --git a/telepathy-logger/channel-factory.h b/telepathy-logger/channel-factory.h
index d9dcc7bfa..224f1b567 100644
--- a/telepathy-logger/channel-factory.h
+++ b/telepathy-logger/channel-factory.h
@@ -31,6 +31,9 @@
typedef TplChannel* (*TplChannelConstructor) (TpConnection *conn,
const gchar *object_path, GHashTable *tp_chan_props, TpAccount *tp_acc,
GError **error);
+typedef TplChannel* (*TplChannelFactory) (const gchar *chan_type,
+ TpConnection *conn, const gchar *object_path, GHashTable *tp_chan_props,
+ TpAccount *tp_acc, GError **error);
void tpl_channel_factory_init (void);
void tpl_channel_factory_deinit (void);
diff --git a/telepathy-logger/log-manager.h b/telepathy-logger/log-manager.h
index 95af6e769..bc083b256 100644
--- a/telepathy-logger/log-manager.h
+++ b/telepathy-logger/log-manager.h
@@ -110,8 +110,7 @@ void tpl_log_manager_get_filtered_messages_async (TplLogManager *manager,
guint num_messages, TplLogMessageFilter filter, gpointer filter_user_data,
GAsyncReadyCallback callback, gpointer user_data);
-GList *tpl_log_manager_get_chats (TplLogManager *manager,
- TpAccount *account);
+GList *tpl_log_manager_get_chats (TplLogManager *manager, TpAccount *account);
void tpl_log_manager_get_chats_async (TplLogManager *manager,
TpAccount *account, GAsyncReadyCallback callback, gpointer user_data);
diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c
index 4cf364b7b..9b2a47150 100644
--- a/telepathy-logger/observer.c
+++ b/telepathy-logger/observer.c
@@ -81,6 +81,7 @@ static void tpl_observer_dispose (GObject * obj);
static void observer_iface_init (gpointer, gpointer);
static void got_tpl_channel_text_ready_cb (GObject *obj, GAsyncResult *result,
gpointer user_data);
+static TplChannelFactory tpl_observer_get_channel_factory (TplObserver *self);
static GHashTable *tpl_observer_get_channel_map (TplObserver *self);
@@ -91,6 +92,7 @@ struct _TplObserverPriv
GHashTable *channel_map;
TplLogManager *logmanager;
gboolean dbus_registered;
+ TplChannelFactory channel_factory;
};
typedef struct
@@ -135,6 +137,7 @@ tpl_observer_observe_channels (TpSvcClientObserver *self,
TpAccount *tp_acc;
TpConnection *tp_conn;
TpDBusDaemon *tp_bus_daemon;
+ TplChannelFactory chan_factory;
TplConf *conf;
GError *error = NULL;
ObservingContext *observing_ctx = NULL;
@@ -143,6 +146,8 @@ tpl_observer_observe_channels (TpSvcClientObserver *self,
g_return_if_fail (!TPL_STR_EMPTY (account) );
g_return_if_fail (!TPL_STR_EMPTY (connection) );
+ chan_factory = tpl_observer_get_channel_factory (TPL_OBSERVER (self));
+
/* Check if logging if enabled globally and for the given account_path,
* return imemdiatly if it's not */
conf = tpl_conf_dup();
@@ -212,8 +217,7 @@ tpl_observer_observe_channels (TpSvcClientObserver *self,
chan_type = g_value_get_string (g_hash_table_lookup (map,
TP_PROP_CHANNEL_CHANNEL_TYPE));
- tpl_chan = tpl_channel_factory_build (chan_type, tp_conn, path, map, tp_acc,
- &error);
+ tpl_chan = chan_factory (chan_type, tp_conn, path, map, tp_acc, &error);
if (tpl_chan == NULL)
{
g_debug ("%s", error->message);
@@ -589,3 +593,28 @@ tpl_observer_unregister_channel (TplObserver *self,
g_free (key);
return retval;
}
+
+
+static TplChannelFactory
+tpl_observer_get_channel_factory (TplObserver *self)
+{
+ g_return_val_if_fail (TPL_IS_OBSERVER (self), NULL);
+
+ return GET_PRIV (self)->channel_factory;
+}
+
+
+void
+tpl_observer_set_channel_factory (TplObserver *self,
+ TplChannelFactory factory)
+{
+ TplObserverPriv *priv = GET_PRIV (self);
+
+ g_return_if_fail (TPL_IS_OBSERVER (self));
+ g_return_if_fail (factory != NULL);
+ g_return_if_fail (factory != NULL);
+ g_return_if_fail (priv->channel_factory == NULL);
+
+ priv->channel_factory = factory;
+
+}
diff --git a/telepathy-logger/observer.h b/telepathy-logger/observer.h
index e5f4e9496..78113ac88 100644
--- a/telepathy-logger/observer.h
+++ b/telepathy-logger/observer.h
@@ -26,6 +26,7 @@
#include <telepathy-glib/dbus-properties-mixin.h>
#include <telepathy-logger/channel.h>
+#include <telepathy-logger/channel-factory.h>
#define TPL_OBSERVER_WELL_KNOWN_BUS_NAME \
"org.freedesktop.Telepathy.Client.TelepathyLogger"
@@ -64,6 +65,9 @@ gboolean tpl_observer_register_channel (TplObserver *self,
gboolean tpl_observer_unregister_channel (TplObserver *self,
TplChannel *channel);
gboolean tpl_observer_register_dbus (TplObserver *self, GError **error);
+void tpl_observer_set_channel_factory (TplObserver *self,
+ TplChannelFactory factory);
+
G_END_DECLS
#endif // __TPL_OBSERVER_H__