pidgin: 2e94ea15: gg: Allow the user to choose whether to ...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Sun May 1 23:31:38 EDT 2011


----------------------------------------------------------------------
Revision: 2e94ea15a78df7b7f3afb0c117bd8e1b86e849b1
Parent:   a32f894365b6b8b057cff5ca6d1ded07eee418b6
Author:   tomkiewicz at o2.pl
Date:     05/01/11 23:12:09
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2e94ea15a78df7b7f3afb0c117bd8e1b86e849b1

Changelog: 

gg: Allow the user to choose whether to use SSL/TLS support.  Fixes #13894.

Changes against parent a32f894365b6b8b057cff5ca6d1ded07eee418b6

  patched  libpurple/protocols/gg/gg.c

-------------- next part --------------
============================================================
--- libpurple/protocols/gg/gg.c	a53140027d029f1ca15f7628ce608e8dcd00eb6d
+++ libpurple/protocols/gg/gg.c	bf3dc2bdd23f0c8b823d1f93e2a4c1cefc80dc1e
@@ -1845,6 +1845,9 @@ static void ggp_async_login_handler(gpoi
 		case GG_STATE_RESOLVING:
 			purple_debug_info("gg", "GG_STATE_RESOLVING\n");
 			break;
+		case GG_STATE_RESOLVING_GG:
+			purple_debug_info("gg", "GG_STATE_RESOLVING_GG\n");
+			break;
 		case GG_STATE_CONNECTING_HUB:
 			purple_debug_info("gg", "GG_STATE_CONNECTING_HUB\n");
 			break;
@@ -1860,6 +1863,9 @@ static void ggp_async_login_handler(gpoi
 		case GG_STATE_READING_REPLY:
 			purple_debug_info("gg", "GG_STATE_READING_REPLY\n");
 			break;
+		case GG_STATE_TLS_NEGOTIATION:
+			purple_debug_info("gg", "GG_STATE_TLS_NEGOTIATION\n");
+			break;
 		default:
 			purple_debug_error("gg", "unknown state = %d\n",
 					 info->session->state);
@@ -1880,10 +1886,11 @@ static void ggp_async_login_handler(gpoi
 	purple_input_remove(gc->inpa);
 
 	/** XXX I think that this shouldn't be done if ev->type is GG_EVENT_CONN_FAILED or GG_EVENT_CONN_SUCCESS -datallah */
-	gc->inpa = purple_input_add(info->session->fd,
-				  (info->session->check == 1) ? PURPLE_INPUT_WRITE
-							      : PURPLE_INPUT_READ,
-				  ggp_async_login_handler, gc);
+	if (info->session->fd >= 0)
+		gc->inpa = purple_input_add(info->session->fd,
+			(info->session->check == 1) ? PURPLE_INPUT_WRITE :
+				PURPLE_INPUT_READ,
+			ggp_async_login_handler, gc);
 
 	switch (ev->type) {
 		case GG_EVENT_NONE:
@@ -2096,6 +2103,7 @@ static void ggp_login(PurpleAccount *acc
 	struct gg_login_params *glp;
 	GGPInfo *info;
 	const char *address;
+	const gchar *encryption_type;
 
 	if (ggp_setup_proxy(account) == -1)
 		return;
@@ -2129,11 +2137,13 @@ static void ggp_login(PurpleAccount *acc
 
 	glp->async = 1;
 	glp->status = ggp_to_gg_status(status, &glp->status_descr);
-#if defined(USE_GNUTLS) || !defined(USE_INTERNAL_LIBGADU)
-	glp->tls = 1;
-#else
-	glp->tls = 0;
-#endif
+	
+	encryption_type = purple_account_get_string(account, "encryption", "none");
+	purple_debug_info("gg", "Requested encryption type: %s\n", encryption_type);
+	if (strcmp(encryption_type, "opportunistic_tls") == 0)
+		glp->tls = 1;
+	else
+		glp->tls = 0;
 	purple_debug_info("gg", "TLS enabled: %d\n", glp->tls);
 
 	if (!info->status_broadcasting)
@@ -2780,6 +2790,7 @@ static void init_plugin(PurplePlugin *pl
 static void init_plugin(PurplePlugin *plugin)
 {
 	PurpleAccountOption *option;
+	GList *encryption_options = NULL;
 
 	option = purple_account_option_string_new(_("Nickname"),
 			"nick", _("Gadu-Gadu User"));
@@ -2791,6 +2802,26 @@ static void init_plugin(PurplePlugin *pl
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
 			option);
 
+#define ADD_VALUE(list, desc, v) { \
+	PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
+	kvp->key = g_strdup((desc)); \
+	kvp->value = g_strdup((v)); \
+	list = g_list_append(list, kvp); \
+}
+
+	ADD_VALUE(encryption_options, _("Don't use encryption"), "none");
+	ADD_VALUE(encryption_options, _("Use encryption if available"),
+		"opportunistic_tls");
+#if 0
+	/* TODO */
+	ADD_VALUE(encryption_options, _("Require encryption"), "require_tls");
+#endif
+
+	option = purple_account_option_list_new(_("Connection security"),
+		"encryption", encryption_options);
+	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
+		option);
+
 	my_protocol = plugin;
 
 	gg_debug_handler = purple_gg_debug_handler;


More information about the Commits mailing list