changeset 23131:9aa105267f46

Show the custom smileys only on accounts that support it. References #1187.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 07 May 2008 18:13:14 +0000
parents 9c0a47402f7a
children 85c595142be6
files libpurple/connection.h libpurple/protocols/msn/msn.c libpurple/protocols/msnp9/msn.c pidgin/gtkconv.c pidgin/gtkimhtml.c pidgin/gtkimhtmltoolbar.c
diffstat 6 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/connection.h	Wed May 07 04:05:19 2008 +0000
+++ b/libpurple/connection.h	Wed May 07 18:13:14 2008 +0000
@@ -43,6 +43,7 @@
 	PURPLE_CONNECTION_NO_FONTSIZE = 0x0020, /**< Connection does not send/receive font sizes */
 	PURPLE_CONNECTION_NO_URLDESC = 0x0040,  /**< Connection does not support descriptions with links */ 
 	PURPLE_CONNECTION_NO_IMAGES = 0x0080,  /**< Connection does not support sending of images */
+	PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY = 0x0100, /**< Connection supports sending and receiving custom smileys */
 
 } PurpleConnectionFlags;
 
--- a/libpurple/protocols/msn/msn.c	Wed May 07 04:05:19 2008 +0000
+++ b/libpurple/protocols/msn/msn.c	Wed May 07 18:13:14 2008 +0000
@@ -892,7 +892,8 @@
 	session = msn_session_new(account);
 
 	gc->proto_data = session;
-	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC;
+	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR |
+		PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
 
 	msn_session_set_login_step(session, MSN_LOGIN_STEP_START);
 
--- a/libpurple/protocols/msnp9/msn.c	Wed May 07 04:05:19 2008 +0000
+++ b/libpurple/protocols/msnp9/msn.c	Wed May 07 18:13:14 2008 +0000
@@ -763,7 +763,8 @@
 	session = msn_session_new(account);
 
 	gc->proto_data = session;
-	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC;
+	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR |
+		PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC | PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY;
 
 	msn_session_set_login_step(session, MSN_LOGIN_STEP_START);
 
--- a/pidgin/gtkconv.c	Wed May 07 04:05:19 2008 +0000
+++ b/pidgin/gtkconv.c	Wed May 07 18:13:14 2008 +0000
@@ -6375,6 +6375,11 @@
 		if(conv->features & PURPLE_CONNECTION_NO_IMAGES)
 			buttons &= ~GTK_IMHTML_IMAGE;
 
+		if (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)
+			buttons |= GTK_IMHTML_CUSTOM_SMILEY;
+		else
+			buttons &= ~GTK_IMHTML_CUSTOM_SMILEY;
+
 		gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons);
 		if (account != NULL)
 			gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), purple_account_get_protocol_id(account));
--- a/pidgin/gtkimhtml.c	Wed May 07 04:05:19 2008 +0000
+++ b/pidgin/gtkimhtml.c	Wed May 07 18:13:14 2008 +0000
@@ -5263,6 +5263,11 @@
 	if (flags & PURPLE_CONNECTION_NO_IMAGES)
 		buttons &= ~GTK_IMHTML_IMAGE;
 
+	if (flags & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)
+		buttons |= GTK_IMHTML_CUSTOM_SMILEY;
+	else
+		buttons &= ~GTK_IMHTML_CUSTOM_SMILEY;
+
 	gtk_imhtml_set_format_functions(imhtml, buttons);
 }
 
--- a/pidgin/gtkimhtmltoolbar.c	Wed May 07 04:05:19 2008 +0000
+++ b/pidgin/gtkimhtmltoolbar.c	Wed May 07 18:13:14 2008 +0000
@@ -718,7 +718,6 @@
 	GtkWidget *dialog;
 	GtkWidget *smiley_table = NULL;
 	GSList *smileys, *unique_smileys = NULL;
-	GSList *custom_smileys = NULL;
 
 	if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
 		destroy_smiley_dialog(toolbar);
@@ -740,13 +739,17 @@
 		smileys = smileys->next;
 	}
 
-	custom_smileys = pidgin_smileys_get_all();
+	if (toolbar->imhtml &&
+			(gtk_imhtml_get_format_functions(GTK_IMHTML(toolbar->imhtml)) & GTK_IMHTML_CUSTOM_SMILEY)) {
+		GSList *custom_smileys = NULL;
+		custom_smileys = pidgin_smileys_get_all();
 
-	while (custom_smileys) {
-		GtkIMHtmlSmiley *smiley = custom_smileys->data;
-		unique_smileys = g_slist_append(unique_smileys, smiley);
-		
-		custom_smileys = custom_smileys->next;
+		while (custom_smileys) {
+			GtkIMHtmlSmiley *smiley = custom_smileys->data;
+			unique_smileys = g_slist_append(unique_smileys, smiley);
+
+			custom_smileys = custom_smileys->next;
+		}
 	}
 
 	dialog = pidgin_create_dialog(_("Smile!"), 0, "smiley_dialog", FALSE);