aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-29 07:01:47 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-31 00:28:46 +0800
commitb3acc55a8c6401de41cfc320081e1aa0be17c27a (patch)
tree26d37041c5e8fab5ace650d4d9a4421ac233d126 /src
parent943dbb3303c06cfa35d0d89a5765ce5430dfba69 (diff)
downloadgsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.tar
gsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.tar.gz
gsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.tar.bz2
gsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.tar.lz
gsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.tar.xz
gsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.tar.zst
gsoc2013-empathy-b3acc55a8c6401de41cfc320081e1aa0be17c27a.zip
Add a simple abstraction for implementing handlers
Implement an EmpathyHandler object which can be used to easily add extra Client.Handler heads on D-Bus.
Diffstat (limited to 'src')
-rw-r--r--src/empathy.c59
1 files changed, 55 insertions, 4 deletions
diff --git a/src/empathy.c b/src/empathy.c
index 38fd56c54..f7017bd96 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -558,6 +558,57 @@ account_manager_ready_cb (EmpathyAccountManager *manager,
}
}
+static EmpathyDispatcher *
+setup_dispatcher (void)
+{
+ EmpathyDispatcher *d;
+ GPtrArray *filters;
+ struct {
+ const gchar *channeltype;
+ TpHandleType handletype;
+ } types[] = {
+ /* Text channels with handle types none, contact and room */
+ { TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_NONE },
+ { TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_CONTACT },
+ { TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_ROOM },
+ /* file transfer to contacts */
+ { TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT },
+ /* stream media to contacts */
+ { TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA, TP_HANDLE_TYPE_CONTACT },
+ /* stream tubes to contacts and rooms */
+ { TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_HANDLE_TYPE_CONTACT },
+ { TP_IFACE_CHANNEL_TYPE_STREAM_TUBE, TP_HANDLE_TYPE_ROOM },
+ /* d-bus tubes to contacts and rooms */
+ { TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, TP_HANDLE_TYPE_CONTACT },
+ { TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, TP_HANDLE_TYPE_ROOM },
+ /* roomlists */
+ { TP_IFACE_CHANNEL_TYPE_ROOM_LIST, TP_HANDLE_TYPE_NONE },
+ };
+ GStrv capabilities = { NULL };
+ int i;
+
+ filters = g_ptr_array_new ();
+
+ for (i = 0 ; i < G_N_ELEMENTS (types); i++)
+ {
+ GHashTable *asv;
+
+ asv = tp_asv_new (
+ TP_IFACE_CHANNEL ".ChannelType", G_TYPE_STRING, types[i].channeltype,
+ TP_IFACE_CHANNEL ".TargetHandleType", G_TYPE_INT, types[i].handletype,
+ NULL);
+
+ g_ptr_array_add (filters, asv);
+ }
+
+ d = empathy_dispatcher_new (PACKAGE_NAME, filters, capabilities);
+
+ g_ptr_array_foreach (filters, (GFunc) g_hash_table_destroy, NULL);
+ g_ptr_array_free (filters, TRUE);
+
+ return d;
+}
+
int
main (int argc, char *argv[])
{
@@ -699,6 +750,10 @@ main (int argc, char *argv[])
g_signal_connect (account_manager, "notify::ready",
G_CALLBACK (account_manager_ready_cb), NULL);
+ /* Handle channels */
+ dispatcher = setup_dispatcher ();
+ g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);
+
migrate_config_to_xdg_dir ();
/* Setting up UI */
@@ -708,10 +763,6 @@ main (int argc, char *argv[])
g_signal_connect (unique_app, "message-received",
G_CALLBACK (unique_app_message_cb), window);
- /* Handle channels */
- dispatcher = empathy_dispatcher_dup_singleton ();
- g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);
-
/* Logging */
log_manager = empathy_log_manager_dup_singleton ();
empathy_log_manager_observe (log_manager, dispatcher);