[PATCH][TMUT] Add port and auth_mech to the UI



Hi,

   The attached allows to change port and authentication mechanism of an account using the account manager UI for testing purposes. This particularly makes it possible to send emails using gmail smtp server with tmut.

   I'm not very fluent in GTK+ so there might be some glitches but overall it serves its purpose.

Regards,

--
Martin
Index: src/tmut-account-editor.c
===================================================================
--- src/tmut-account-editor.c	(revision 92)
+++ src/tmut-account-editor.c	(working copy)
@@ -52,7 +52,7 @@
 
 	GtkWidget *name_entry, *hostname_entry, *enabled_checkbutton,
 		  *proto_entry, *type_entry, *user_entry, *options_entry,
-		  *from_entry;
+		  *port_entry, *auth_mech_entry, *from_entry;
 };
 
 #define TMUT_ACCOUNT_EDITOR_GET_PRIVATE(o) \
@@ -116,6 +116,22 @@
 	return g_strsplit (str?str:"", ",", -1);
 }
 
+gint
+tmut_account_editor_get_port (TMutAccountEditor *self)
+{
+	TMutAccountEditorPriv *priv = TMUT_ACCOUNT_EDITOR_GET_PRIVATE (self);
+	return atoi(gtk_entry_get_text (GTK_ENTRY (priv->port_entry)));
+}
+
+const gchar* 
+tmut_account_editor_get_auth_mech (TMutAccountEditor *self)
+{
+	TMutAccountEditorPriv *priv = TMUT_ACCOUNT_EDITOR_GET_PRIVATE (self);
+	const gchar *mech = gtk_entry_get_text (GTK_ENTRY (priv->auth_mech_entry));
+	
+	return mech[0] == '\0' ? NULL : mech;
+}
+
 TnyAccount *
 tmut_account_editor_get_account (TMutAccountEditor *self)
 {
@@ -191,6 +207,13 @@
 		gtk_entry_set_text (GTK_ENTRY (priv->options_entry), 
 			options_string->str);
 
+		gchar tmp[32] = {0};
+		g_snprintf(tmp, sizeof(tmp) - 1, "%d", tny_account_get_port (account));
+		gtk_entry_set_text (GTK_ENTRY (priv->port_entry), tmp);
+
+		gtk_entry_set_text (GTK_ENTRY (priv->auth_mech_entry), 
+			tny_account_get_secure_auth_mech (account)?tny_account_get_secure_auth_mech (account):"");
+
 		g_string_free (options_string, TRUE);
 
 	} else {
@@ -204,6 +227,8 @@
 		gtk_entry_set_text (GTK_ENTRY (priv->type_entry), "store");
 		gtk_entry_set_text (GTK_ENTRY (priv->user_entry), _("user.name"));
 		gtk_entry_set_text (GTK_ENTRY (priv->options_entry), _("use_ssl=wrapped"));
+		gtk_entry_set_text (GTK_ENTRY (priv->port_entry), "-1");
+		gtk_entry_set_text (GTK_ENTRY (priv->auth_mech_entry), "");
 	}
 }
 
@@ -291,6 +316,20 @@
 	(GtkAttachOptions) (0), 0, 0);
 	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
+	label = gtk_label_new (_("Port"));
+	gtk_widget_show (label);
+	gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7,
+	(GtkAttachOptions) (GTK_FILL),
+	(GtkAttachOptions) (0), 0, 0);
+	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
+	label = gtk_label_new (_("Auth mech"));
+	gtk_widget_show (label);
+	gtk_table_attach (GTK_TABLE (table), label, 0, 1, 7, 8,
+	(GtkAttachOptions) (GTK_FILL),
+	(GtkAttachOptions) (0), 0, 0);
+	gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+
 	priv->name_entry = gtk_entry_new ();
 	gtk_widget_show (priv->name_entry);
 	gtk_table_attach (GTK_TABLE (table), priv->name_entry, 1, 2, 0, 1,
@@ -337,6 +376,18 @@
 		(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
 		(GtkAttachOptions) (0), 0, 0);
 
+	priv->port_entry = gtk_entry_new ();
+	gtk_widget_show (priv->port_entry);
+	gtk_table_attach (GTK_TABLE (table), priv->port_entry, 1, 2, 6, 7,
+		(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+		(GtkAttachOptions) (0), 0, 0);
+
+	priv->auth_mech_entry = gtk_entry_new ();
+	gtk_widget_show (priv->auth_mech_entry);
+	gtk_table_attach (GTK_TABLE (table), priv->auth_mech_entry, 1, 2, 7, 8,
+		(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+		(GtkAttachOptions) (0), 0, 0);
+
 	gtk_widget_show (table);
 
 
Index: src/tmut-account-editor.h
===================================================================
--- src/tmut-account-editor.h	(revision 92)
+++ src/tmut-account-editor.h	(working copy)
@@ -64,6 +64,8 @@
 const gchar* tmut_account_editor_get_user (TMutAccountEditor *self);
 const gchar* tmut_account_editor_get_from (TMutAccountEditor *self);
 gchar** tmut_account_editor_get_options (TMutAccountEditor *self);
+gint tmut_account_editor_get_port (TMutAccountEditor *self);
+const gchar* tmut_account_editor_get_auth_mech (TMutAccountEditor *self);
 TnyAccount *tmut_account_editor_get_account (TMutAccountEditor *self);
 
 
Index: src/tmut-account-store.c
===================================================================
--- src/tmut-account-store.c	(revision 92)
+++ src/tmut-account-store.c	(working copy)
@@ -212,6 +212,8 @@
 	g_key_file_set_value (keyfile, "tmut", "hostname", hostname);
 	g_key_file_set_value (keyfile, "tmut", "user", user);
 	g_key_file_set_value (keyfile, "tmut", "type", type);
+	g_key_file_set_value (keyfile, "tmut", "auht_mech", mech);
+	g_key_file_set_integer (keyfile, "tmut", "port", port);
 
 
 	if (options) {
@@ -222,8 +224,6 @@
 			options, options_len);
 	}
 
-	/* todo: port and mech */
-
 	file = fopen (filen, "w");
 
 	if (file) {
Index: src/tmut-account-manager.c
===================================================================
--- src/tmut-account-manager.c	(revision 92)
+++ src/tmut-account-manager.c	(working copy)
@@ -78,9 +78,9 @@
 		tmut_account_editor_get_proto (editor), 
 		tmut_account_editor_get_account_type (editor), 
 		tmut_account_editor_get_user (editor), 
-		NULL, 
+		tmut_account_editor_get_auth_mech (editor), 
 		tmut_account_editor_get_from (editor),
-		-1,
+		tmut_account_editor_get_port (editor),
 		(const char **) options);
 
 	g_strfreev (options);
@@ -102,9 +102,9 @@
 		tmut_account_editor_get_hostname (editor), 
 		tmut_account_editor_get_proto (editor), 
 		tmut_account_editor_get_user (editor), 
-		NULL, 
+		tmut_account_editor_get_auth_mech (editor), 
 		tmut_account_editor_get_from (editor),
-		-1,
+		tmut_account_editor_get_port (editor),
 		(const char **) options);
 
 	g_strfreev (options);


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