aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-irc-network-chooser.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-irc-network-chooser.c b/libempathy-gtk/empathy-irc-network-chooser.c
index 7a6bd7898..0f147d887 100644
--- a/libempathy-gtk/empathy-irc-network-chooser.c
+++ b/libempathy-gtk/empathy-irc-network-chooser.c
@@ -118,6 +118,34 @@ unset_server_params (EmpathyIrcNetworkChooser *self)
empathy_account_settings_unset (priv->settings, "use-ssl");
}
+static gchar *
+dup_network_service (EmpathyIrcNetwork *network)
+{
+ /* Account.Service follows the same restriction as CM.Protocol
+ * http://telepathy.freedesktop.org/spec/Connection_Manager.html#Simple-Type:Protocol
+ */
+#define VALID G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS
+ gchar *service;
+ gchar *result = NULL;
+
+ service = g_strdup (empathy_irc_network_get_name (network));
+ service = g_strstrip (service);
+
+ /* Service has to start with a letter */
+ if (!g_ascii_isalpha (service[0]))
+ {
+ g_free (service);
+ return NULL;
+ }
+
+ service = g_strcanon (service, VALID, '-');
+
+ result = g_ascii_strdown (service, -1);
+ g_free (service);
+
+ return result;
+}
+
static void
update_server_params (EmpathyIrcNetworkChooser *self)
{
@@ -139,6 +167,7 @@ update_server_params (EmpathyIrcNetworkChooser *self)
gchar *address;
guint port;
gboolean ssl;
+ gchar *service;
g_object_get (server,
"address", &address,
@@ -153,7 +182,13 @@ update_server_params (EmpathyIrcNetworkChooser *self)
DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
empathy_account_settings_set_boolean (priv->settings, "use-ssl", ssl);
+ /* Set Account.Service */
+ service = dup_network_service (priv->network);
+ DEBUG ("Setting Service to %s", service);
+ empathy_account_settings_set_service (priv->settings, service);
+
g_free (address);
+ g_free (service);
}
else
{