]> git.0d.be Git - empathy.git/commitdiff
tp-chat: set Private and InviteOnly props on conference channels
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 24 Sep 2012 08:38:05 +0000 (10:38 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 25 Sep 2012 07:31:55 +0000 (09:31 +0200)
Only the person invited are suppose to join these channels so tweak their
settings to make them more secure.

https://bugzilla.gnome.org/show_bug.cgi?id=684675

libempathy/empathy-tp-chat.c

index 39ed8e2ab82fa4ea63db96498bba3122fb5acac0..4857243c126d89626dd76f243e89709bd944f8de 100644 (file)
@@ -134,19 +134,46 @@ tp_chat_async_cb (TpChannel *proxy,
     DEBUG ("Error %s: %s", (gchar *) user_data, error->message);
 }
 
+static void
+update_config_cb (TpChannel *proxy,
+    const GError *error,
+    gpointer user_data,
+    GObject *weak_object)
+{
+  if (error != NULL)
+    DEBUG ("Failed to change config of the room: %s", error->message);
+}
+
 static void
 create_conference_cb (GObject *source,
     GAsyncResult *result,
     gpointer user_data)
 {
+  TpChannel *channel;
   GError *error = NULL;
+  GHashTable *props;
 
-  if (!tp_account_channel_request_create_channel_finish (
-      TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error))
+  channel = tp_account_channel_request_create_and_observe_channel_finish (
+      TP_ACCOUNT_CHANNEL_REQUEST (source), result, &error);
+  if (channel == NULL)
     {
       DEBUG ("Failed to create conference channel: %s", error->message);
       g_error_free (error);
+      return;
     }
+
+  /* Make the channel more confidential as only people invited are supposed to
+   * join it. */
+  props = tp_asv_new (
+      "Private", G_TYPE_BOOLEAN, TRUE,
+      "InviteOnly", G_TYPE_BOOLEAN, TRUE,
+      NULL);
+
+  tp_cli_channel_interface_room_config_call_update_configuration (channel, -1,
+      props, update_config_cb, NULL, NULL, NULL);
+
+  g_object_unref (channel);
+  g_hash_table_unref (props);
 }
 
 void
@@ -199,7 +226,7 @@ empathy_tp_chat_add (EmpathyTpChat *self,
 
       /* Although this is a MUC, it's anonymous, so CreateChannel is
        * valid. */
-      tp_account_channel_request_create_channel_async (req,
+      tp_account_channel_request_create_and_observe_channel_async (req,
           EMPATHY_CHAT_BUS_NAME, NULL, create_conference_cb, NULL);
 
       g_object_unref (req);