[Telepathy-commits] [telepathy-mission-control/master] Add a flag parameter to mc_account_channelrequest

Alberto Mardegan alberto.mardegan at nokia.com
Mon Nov 17 00:05:22 PST 2008


Add a flag parameter to mc_account_channelrequest(): currently the only
supported flag is USE_EXISTING, which if set will make libmcclient use the
EnsureChannel method.
---
 examples/mc-example-3.c          |    2 +-
 libmcclient/mc-account-request.c |   29 ++++++++++++++++++++---------
 libmcclient/mc-account.h         |    7 +++++++
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/examples/mc-example-3.c b/examples/mc-example-3.c
index 9655494..50db866 100644
--- a/examples/mc-example-3.c
+++ b/examples/mc-example-3.c
@@ -112,7 +112,7 @@ request_channel (McAccount *account, GQuark type, const gchar *contact)
     MC_ACCOUNT_CRD_SET (&req, target_id, contact);
     MC_ACCOUNT_CRD_SET (&req, target_handle_type, TP_HANDLE_TYPE_CONTACT);
     id = mc_account_channelrequest (account, &req, time(0),
-				    NULL,
+				    NULL, 0,
 				    channel_request_cb,
 				    g_strdup ("ciao"), g_free,
 				    to);
diff --git a/libmcclient/mc-account-request.c b/libmcclient/mc-account-request.c
index 0c1516a..ec15bee 100644
--- a/libmcclient/mc-account-request.c
+++ b/libmcclient/mc-account-request.c
@@ -196,12 +196,19 @@ _mc_account_channelrequests_class_init (McAccountClass *klass)
  */
 
 /**
+ * McAccountChannelrequestFlags:
+ * @MC_ACCOUNT_CR_FLAG_USE_EXISTING: allow requesting of an existing channel
+ * (EnsureChannel will be called).
+ */
+
+/**
  * mc_account_channelrequest:
  * @account: the #McAccount.
  * @req_data: a #McAccountChannelrequestData struct with the requested fields
  * set.
  * @user_action_time: the time at which user action occurred, or %0.
  * @handler: well-known name of the preferred handler, or %NULL.
+ * @flags: a combination of #McAccountChannelrequestFlags.
  * @callback: called when something happens to the request.
  * @user_data: user data to be passed to @callback.
  * @destroy: called with the user_data as argument, after the request has
@@ -220,6 +227,7 @@ guint
 mc_account_channelrequest (McAccount *account,
                            const McAccountChannelrequestData *req_data,
                            time_t user_action_time, const gchar *handler,
+                           McAccountChannelrequestFlags flags,
                            McAccountChannelrequestCb callback,
                            gpointer user_data, GDestroyNotify destroy,
                            GObject *weak_object)
@@ -282,8 +290,8 @@ mc_account_channelrequest (McAccount *account,
     }
 
     id = mc_account_channelrequest_ht (account, properties, user_action_time,
-                                        handler, callback, user_data, destroy,
-                                        weak_object);
+                                        handler, flags, callback, user_data,
+                                        destroy, weak_object);
     g_hash_table_destroy (properties);
     return id;
 }
@@ -294,6 +302,7 @@ mc_account_channelrequest (McAccount *account,
  * @properties: a #GHashTable with the requested channel properties.
  * @user_action_time: the time at which user action occurred, or %0.
  * @handler: well-known name of the preferred handler, or %NULL.
+ * @flags: a combination of #McAccountChannelrequestFlags.
  * @callback: called when something happens to the request.
  * @user_data: user data to be passed to @callback.
  * @destroy: called with the user_data as argument, after the request has
@@ -325,6 +334,7 @@ guint
 mc_account_channelrequest_ht (McAccount *account,
                               GHashTable *properties,
                               time_t user_action_time, const gchar *handler,
+                              McAccountChannelrequestFlags flags,
                               McAccountChannelrequestCb callback,
                               gpointer user_data, GDestroyNotify destroy,
                               GObject *weak_object)
@@ -356,13 +366,14 @@ mc_account_channelrequest_ht (McAccount *account,
         g_object_weak_ref (weak_object,
                            (GWeakNotify)on_weak_object_destroy, account);
     }
-    mc_cli_account_interface_channelrequests_call_create (account, -1,
-                                                          properties,
-                                                          user_action_time,
-                                                          handler,
-                                                          request_create_cb,
-                                                          req, NULL,
-                                                          NULL);
+    if (flags & MC_ACCOUNT_CR_FLAG_USE_EXISTING)
+        mc_cli_account_interface_channelrequests_call_ensure_channel
+            (account, -1, properties, user_action_time, handler,
+             request_create_cb, req, NULL, NULL);
+    else
+        mc_cli_account_interface_channelrequests_call_create
+            (account, -1, properties, user_action_time, handler,
+             request_create_cb, req, NULL, NULL);
 
     props->requests = g_list_prepend (props->requests, req);
     return GPOINTER_TO_UINT (req);
diff --git a/libmcclient/mc-account.h b/libmcclient/mc-account.h
index c33edc0..1652f87 100644
--- a/libmcclient/mc-account.h
+++ b/libmcclient/mc-account.h
@@ -254,10 +254,16 @@ typedef void (*McAccountChannelrequestCb) (McAccount *account,
                                            gpointer user_data,
                                            GObject *weak_object);
 
+typedef enum
+{
+    MC_ACCOUNT_CR_FLAG_USE_EXISTING = 0,  /* if set, call EnsureChannel */
+} McAccountChannelrequestFlags;
+
 guint mc_account_channelrequest (McAccount *account,
                                  const McAccountChannelrequestData *req_data,
                                  time_t user_action_time,
                                  const gchar *handler,
+                                 McAccountChannelrequestFlags flags,
                                  McAccountChannelrequestCb callback,
                                  gpointer user_data,
                                  GDestroyNotify destroy,
@@ -267,6 +273,7 @@ guint mc_account_channelrequest_ht (McAccount *account,
                                     GHashTable *properties,
                                     time_t user_action_time,
                                     const gchar *handler,
+                                    McAccountChannelrequestFlags flags,
                                     McAccountChannelrequestCb callback,
                                     gpointer user_data,
                                     GDestroyNotify destroy,
-- 
1.5.6.5




More information about the Telepathy-commits mailing list