[empathy: 2/14] Move the code ensuring a requested sms channel to empathy-request-util as empathy-dispatcher has bee



commit b41c1f0e4b8277feee45703d283591adaed6305b
Author: Chandni Verma <chandniverma2112 gmail com>
Date:   Wed May 4 00:59:12 2011 +0530

    Move the code ensuring a requested sms channel to empathy-request-util
    as empathy-dispatcher has been deleted in master

 libempathy-gtk/empathy-individual-menu.c |    2 +-
 libempathy/empathy-request-util.c        |   55 +++++++++++++++++------------
 libempathy/empathy-request-util.h        |    5 +++
 3 files changed, 38 insertions(+), 24 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index 70846c7..576d3b9 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -561,7 +561,7 @@ empathy_individual_sms_menu_item_activated (GtkMenuItem *item,
 {
   g_return_if_fail (EMPATHY_IS_CONTACT (contact));
 
-  empathy_dispatcher_sms_contact_id (
+  empathy_sms_contact_id (
       empathy_contact_get_account (contact),
       empathy_contact_get_id (contact),
       gtk_get_current_event_time ());
diff --git a/libempathy/empathy-request-util.c b/libempathy/empathy-request-util.c
index ea885da..6472230 100644
--- a/libempathy/empathy-request-util.c
+++ b/libempathy/empathy-request-util.c
@@ -58,9 +58,11 @@ ensure_text_channel_cb (GObject *source,
     }
 }
 
-void
-empathy_chat_with_contact_id (TpAccount *account,
-    const gchar *contact_id,
+static void
+create_text_channel (TpAccount *account,
+    TpHandleType target_handle_type,
+    const gchar *target_id,
+    gboolean sms_channel,
     gint64 timestamp)
 {
   GHashTable *request;
@@ -69,39 +71,46 @@ empathy_chat_with_contact_id (TpAccount *account,
   request = tp_asv_new (
       TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
         TP_IFACE_CHANNEL_TYPE_TEXT,
-      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT,
-      TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, contact_id,
+      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, target_handle_type,
+      TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, target_id,
       NULL);
 
+  if (sms_channel)
+    tp_asv_set_boolean (request,
+        TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, TRUE);
+
   req = tp_account_channel_request_new (account, request, timestamp);
 
-  tp_account_channel_request_ensure_channel_async (req, EMPATHY_CHAT_BUS_NAME,
-      NULL, ensure_text_channel_cb, NULL);
+  tp_account_channel_request_ensure_channel_async (req, NULL, NULL,
+      ensure_text_channel_cb, NULL);
 
   g_hash_table_unref (request);
   g_object_unref (req);
 }
 
 void
+empathy_chat_with_contact_id (TpAccount *account,
+    const gchar *contact_id,
+    gint64 timestamp)
+{
+	create_text_channel (account, TP_HANDLE_TYPE_CONTACT,
+        contact_id, FALSE, timestamp);
+}
+
+void
 empathy_join_muc (TpAccount *account,
     const gchar *room_name,
     gint64 timestamp)
 {
-  GHashTable *request;
-  TpAccountChannelRequest *req;
-
-  request = tp_asv_new (
-      TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
-        TP_IFACE_CHANNEL_TYPE_TEXT,
-      TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM,
-      TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, room_name,
-      NULL);
-
-  req = tp_account_channel_request_new (account, request, timestamp);
-
-  tp_account_channel_request_ensure_channel_async (req, EMPATHY_CHAT_BUS_NAME,
-      NULL, ensure_text_channel_cb, NULL);
+	create_text_channel (account, TP_HANDLE_TYPE_ROOM,
+        room_name, FALSE, timestamp);
+}
 
-  g_hash_table_unref (request);
-  g_object_unref (req);
+void
+empathy_sms_contact_id (TpAccount *account,
+    const gchar *contact_id,
+    gint64 timestamp)
+{
+  create_text_channel (account, TP_HANDLE_TYPE_CONTACT,
+      contact_id, TRUE, timestamp);
 }
diff --git a/libempathy/empathy-request-util.h b/libempathy/empathy-request-util.h
index afb8013..49b98a4 100644
--- a/libempathy/empathy-request-util.h
+++ b/libempathy/empathy-request-util.h
@@ -52,6 +52,11 @@ void empathy_join_muc (TpAccount *account,
   const gchar *roomname,
   gint64 timestamp);
 
+/* Request a sms channel */
+void empathy_sms_contact_id (TpAccount *account,
+  const gchar *contact_id,
+  gint64 timestamp);
+
 G_END_DECLS
 
 #endif /* __EMPATHY_DISPATCHER_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]