]> git.0d.be Git - empathy.git/commitdiff
Allow to set the Service of newly created account (#629734)
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Fri, 17 Sep 2010 14:27:39 +0000 (16:27 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 29 Sep 2010 10:54:37 +0000 (12:54 +0200)
libempathy-gtk/empathy-protocol-chooser.c
libempathy/empathy-account-settings.c
libempathy/empathy-account-settings.h
src/empathy-auto-salut-account-helper.c

index c3cea3eb78bc0027df0d6b534b8c290eb78b8568..689f6a28a94115d95ecd8cdbe4eb084d25feee5e 100644 (file)
@@ -582,7 +582,7 @@ empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self)
    * "Yahoo!"
    */
   str = g_strdup_printf (_("New %s account"), display_name);
-  settings = empathy_account_settings_new (cm->name, proto->name, str);
+  settings = empathy_account_settings_new (cm->name, proto->name, service, str);
 
   g_free (str);
 
index 1278bb441a7b51f0b694bb1d0dc5ee1e7a5dc9a2..9643920cb7b9af21c99053289e8506a206fa368e 100644 (file)
@@ -43,6 +43,7 @@ enum {
   PROP_ACCOUNT = 1,
   PROP_CM_NAME,
   PROP_PROTOCOL,
+  PROP_SERVICE,
   PROP_DISPLAY_NAME,
   PROP_DISPLAY_NAME_OVERRIDDEN,
   PROP_READY
@@ -62,6 +63,7 @@ struct _EmpathyAccountSettingsPriv
   TpAccount *account;
   gchar *cm_name;
   gchar *protocol;
+  gchar *service;
   gchar *display_name;
   gchar *icon_name;
   gboolean display_name_overridden;
@@ -123,6 +125,9 @@ empathy_account_settings_set_property (GObject *object,
       case PROP_PROTOCOL:
         priv->protocol = g_value_dup_string (value);
         break;
+      case PROP_SERVICE:
+        priv->service = g_value_dup_string (value);
+        break;
       case PROP_DISPLAY_NAME:
         priv->display_name = g_value_dup_string (value);
         break;
@@ -155,6 +160,9 @@ empathy_account_settings_get_property (GObject *object,
       case PROP_PROTOCOL:
         g_value_set_string (value, priv->protocol);
         break;
+      case PROP_SERVICE:
+        g_value_set_string (value, priv->service);
+        break;
       case PROP_DISPLAY_NAME:
         g_value_set_string (value, priv->display_name);
         break;
@@ -180,11 +188,14 @@ empathy_account_settings_constructed (GObject *object)
     {
       g_free (priv->cm_name);
       g_free (priv->protocol);
+      g_free (priv->service);
 
       priv->cm_name =
         g_strdup (tp_account_get_connection_manager (priv->account));
       priv->protocol =
         g_strdup (tp_account_get_protocol (priv->account));
+      priv->service =
+        g_strdup (tp_account_get_service (priv->account));
       priv->icon_name = g_strdup
         (tp_account_get_icon_name (priv->account));
     }
@@ -248,6 +259,13 @@ empathy_account_settings_class_init (
       NULL,
       G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
+  g_object_class_install_property (object_class, PROP_SERVICE,
+    g_param_spec_string ("service",
+      "Service",
+      "The service of this account, or NULL",
+      NULL,
+      G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
   g_object_class_install_property (object_class, PROP_DISPLAY_NAME,
     g_param_spec_string ("display-name",
       "display-name",
@@ -329,6 +347,7 @@ empathy_account_settings_finalize (GObject *object)
   /* free any data held directly by the object here */
   g_free (priv->cm_name);
   g_free (priv->protocol);
+  g_free (priv->service);
   g_free (priv->display_name);
   g_free (priv->icon_name);
 
@@ -440,11 +459,13 @@ empathy_account_settings_managers_ready_cb (GObject *object,
 EmpathyAccountSettings *
 empathy_account_settings_new (const gchar *connection_manager,
     const gchar *protocol,
+    const gchar *service,
     const char *display_name)
 {
   return g_object_new (EMPATHY_TYPE_ACCOUNT_SETTINGS,
       "connection-manager", connection_manager,
       "protocol", protocol,
+      "service", service,
       "display-name", display_name,
       NULL);
 }
@@ -502,6 +523,14 @@ empathy_account_settings_get_protocol (EmpathyAccountSettings *settings)
   return priv->protocol;
 }
 
+const gchar *
+empathy_account_settings_get_service (EmpathyAccountSettings *settings)
+{
+  EmpathyAccountSettingsPriv *priv = GET_PRIV (settings);
+
+  return priv->service;
+}
+
 gchar *
 empathy_account_settings_get_icon_name (EmpathyAccountSettings *settings)
 {
@@ -1189,6 +1218,9 @@ empathy_account_settings_do_create_account (EmpathyAccountSettings *settings)
   tp_asv_set_string (properties, TP_IFACE_ACCOUNT ".Icon",
       priv->icon_name);
 
+  if (priv->service != NULL)
+    tp_asv_set_string (properties, TP_PROP_ACCOUNT_SERVICE, priv->service);
+
   tp_account_manager_create_account_async (priv->account_manager,
     priv->cm_name, priv->protocol, priv->display_name,
     priv->parameters, properties,
index 7b1a4d6f97482cb18baa17ff38389f5c8f1ba744..d3276e1a5d31cb5d8f559ce77a30b4bc411bf349 100644 (file)
@@ -63,6 +63,7 @@ GType empathy_account_settings_get_type (void);
 EmpathyAccountSettings * empathy_account_settings_new (
     const gchar *connection_manager,
     const gchar *protocol,
+    const gchar *service,
     const char *display_name);
 
 EmpathyAccountSettings * empathy_account_settings_new_for_account (
@@ -74,6 +75,9 @@ const gchar *empathy_account_settings_get_cm (EmpathyAccountSettings *settings);
 const gchar *empathy_account_settings_get_protocol (
     EmpathyAccountSettings *settings);
 
+const gchar *empathy_account_settings_get_service (
+    EmpathyAccountSettings *settings);
+
 TpAccount *empathy_account_settings_get_account (
     EmpathyAccountSettings *settings);
 
index 57d39879e2b68dbc0352a778455999d9655cc030..409b6936c66ef741385226b1d4c49dc98b8849f1 100644 (file)
@@ -79,7 +79,7 @@ create_salut_account_settings (void)
   GError *error = NULL;
 #endif
 
-  settings = empathy_account_settings_new ("salut", "local-xmpp",
+  settings = empathy_account_settings_new ("salut", "local-xmpp", NULL,
       _("People nearby"));
 
 #if HAVE_EDS