aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-01-10 00:12:57 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-10 00:12:57 +0800
commit802d468fe9f97763dc298236a5a79b8f835407d7 (patch)
treef3d8d68f31a408a6a7f4e9087b630ea96371a8b0 /libempathy
parentb52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be (diff)
downloadgsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.tar
gsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.tar.gz
gsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.tar.bz2
gsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.tar.lz
gsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.tar.xz
gsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.tar.zst
gsoc2013-empathy-802d468fe9f97763dc298236a5a79b8f835407d7.zip
Add request muc channels to the dispatcher
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2143
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-dispatcher.c77
-rw-r--r--libempathy/empathy-dispatcher.h14
2 files changed, 78 insertions, 13 deletions
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index c4fa0e147..c1ff62f14 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -1401,7 +1401,6 @@ dispatcher_connection_new_requested_channel (EmpathyDispatcher *dispatcher,
out:
dispatcher_flush_outstanding_operations (request_data->dispatcher,
conn_data);
-
}
static void
@@ -1432,12 +1431,8 @@ empathy_dispatcher_call_with_contact_id (McAccount *account,
}
static void
-dispatcher_chat_with_contact_cb (EmpathyContact *contact, gpointer user_data)
+dispatcher_request_channel (DispatcherRequestData *request_data)
{
- DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
-
- request_data->handle = empathy_contact_get_handle (contact);
-
tp_cli_connection_call_request_channel (request_data->connection, -1,
request_data->channel_type,
request_data->handle_type,
@@ -1446,6 +1441,16 @@ dispatcher_chat_with_contact_cb (EmpathyContact *contact, gpointer user_data)
request_data, NULL, G_OBJECT (request_data->dispatcher));
}
+static void
+dispatcher_chat_with_contact_cb (EmpathyContact *contact, gpointer user_data)
+{
+ DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
+
+ request_data->handle = empathy_contact_get_handle (contact);
+
+ dispatcher_request_channel (request_data);
+}
+
void
empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
EmpathyDispatcherRequestCb *callback, gpointer user_data)
@@ -1491,6 +1496,66 @@ empathy_dispatcher_chat_with_contact_id (McAccount *account, const gchar
g_object_unref (dispatcher);
}
+
+static void
+dispatcher_request_handles_cb (TpConnection *connection,
+ const GArray *handles, const GError *error, gpointer user_data,
+ GObject *object)
+{
+ DispatcherRequestData *request_data = (DispatcherRequestData *) user_data;
+
+ if (error != NULL)
+ {
+ EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object);
+ EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
+ ConnectionData *cd;
+
+ cd = g_hash_table_lookup (priv->connections, request_data->connection);
+
+ if (request_data->cb)
+ request_data->cb (NULL, error, request_data->user_data);
+
+ cd->outstanding_requests = g_list_remove (cd->outstanding_requests,
+ request_data);
+
+ free_dispatcher_request_data (request_data);
+
+ dispatcher_flush_outstanding_operations (dispatcher, cd);
+ return;
+ }
+
+ request_data->handle = g_array_index (handles, guint, 0);
+ dispatcher_request_channel (request_data);
+}
+
+void
+empathy_dispatcher_join_muc (McAccount *account, const gchar *roomname,
+ EmpathyDispatcherRequestCb *callback, gpointer user_data)
+{
+ EmpathyDispatcher *dispatcher = empathy_get_dispatcher();
+ EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher);
+ DispatcherRequestData *request_data;
+ TpConnection *connection = g_hash_table_lookup (priv->accounts, account);
+ ConnectionData *connection_data =
+ g_hash_table_lookup (priv->connections, connection);
+ const gchar *names[] = { roomname, NULL };
+
+ /* Don't know the room handle yet */
+ request_data = new_dispatcher_request_data (dispatcher, connection,
+ TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_ROOM, 0, NULL,
+ NULL, callback, user_data);
+
+ connection_data->outstanding_requests = g_list_prepend
+ (connection_data->outstanding_requests, request_data);
+
+ tp_cli_connection_call_request_handles (connection, -1,
+ TP_HANDLE_TYPE_ROOM, names,
+ dispatcher_request_handles_cb, request_data, NULL,
+ G_OBJECT (dispatcher));
+
+ g_object_unref (dispatcher);
+}
+
#if 0
typedef struct {
GFile *gfile;
diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h
index e1617c33b..d43dcf89d 100644
--- a/libempathy/empathy-dispatcher.h
+++ b/libempathy/empathy-dispatcher.h
@@ -68,35 +68,35 @@ typedef void (EmpathyDispatcherRequestCb) (
GType empathy_dispatcher_get_type (void) G_GNUC_CONST;
+/* Requesting 1 to 1 stream media channels */
void empathy_dispatcher_call_with_contact (EmpathyContact *contact,
EmpathyDispatcherRequestCb *callback, gpointer user_data);
void empathy_dispatcher_call_with_contact_id (McAccount *account,
const gchar *contact_id, EmpathyDispatcherRequestCb *callback,
gpointer user_data);
+/* Requesting 1 to 1 text channels */
void empathy_dispatcher_chat_with_contact_id (McAccount *account,
const gchar *contact_id, EmpathyDispatcherRequestCb *callback,
gpointer user_data);
void empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
EmpathyDispatcherRequestCb *callback, gpointer user_data);
-void empathy_dispatcher_chat_with_contact_id (McAccount *account,
- const gchar *contact_id, EmpathyDispatcherRequestCb *callback,
- gpointer user_data);
-void empathy_dispatcher_chat_with_contact (EmpathyContact *contact,
- EmpathyDispatcherRequestCb *callback, gpointer user_data);
-
+/* Request a file channel to a specific contact */
void empathy_dispatcher_send_file_to_contact (EmpathyContact *contact,
const gchar *filename, guint64 size, guint64 date,
const gchar *content_type, EmpathyDispatcherRequestCb *callback,
gpointer user_data);
+/* Request a muc channel */
+void empathy_dispatcher_join_muc (McAccount *account,
+ const gchar *roomname, EmpathyDispatcherRequestCb *callback,
+ gpointer user_data);
/* Get the dispatcher singleton */
EmpathyDispatcher * empathy_get_dispatcher (void);
GType empathy_dispatcher_tube_get_type (void);
-
/* tube stuff */
EmpathyDispatcherTube *empathy_dispatcher_tube_ref (EmpathyDispatcherTube *tube);
void empathy_dispatcher_tube_unref (EmpathyDispatcherTube *tube);