changeset 27831:61a7929a97b5

propagate from branch 'im.pidgin.pidgin' (head 01e9055ea70771c842b561dca3b64027ac37dc69) to branch 'im.pidgin.pidgin.yaz' (head 1935d190b5b45854f9f401440607bcf876962f25)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 01 May 2008 15:24:43 +0000
parents 8ad9c318613f (diff) c18e82b59f02 (current diff)
children b8f28a250c22
files pidgin/gtkprefs.c
diffstat 6 files changed, 228 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 30 16:12:02 2008 +0000
+++ b/ChangeLog	Thu May 01 15:24:43 2008 +0000
@@ -14,10 +14,16 @@
 	* Added a plugin (not built by default) which adds a Send button back
 	  to the conversation window. People without physical keyboards have a
 	  hard time with the lack of the button.
-	* Clicking on the buddyicon in the conversation window toggles the size of
-	  the icon between small and large.
-	* The settings of a chat (e.g. Handle in an XMPP chat, or Exchange in an
-	  AIM chat) can be edited from its context menu in the buddy list.
+	* Clicking on the buddyicon in the conversation window toggles the
+	  size of the icon between small and large.
+	* The settings of a chat (e.g. Handle in an XMPP chat, or Exchange in
+	  an AIM chat) can be edited from its context menu in the buddy list.
+	* Add a "Present conversation window" preference to the Message
+	  Notification plugin, the "Raise conversation window" option does not
+	  unminimize windows or draw attention to them when they are on other
+	  workspaces the "Present" option should.
+	* Add a preference to set Escape as the keyboard shortcut for closing
+	  the conversation window.
 
 	General:
 	* The configure script now dies on more absent dependencies.  The
--- a/libpurple/protocols/jabber/auth.c	Wed Apr 30 16:12:02 2008 +0000
+++ b/libpurple/protocols/jabber/auth.c	Thu May 01 15:24:43 2008 +0000
@@ -54,6 +54,11 @@
 				PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
 				_("Server requires TLS/SSL for login.  No TLS/SSL support found."));
 			return TRUE;
+		} else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE)) {
+			purple_connection_error_reason (js->gc,
+				 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
+				_("You require encryption, but no TLS/SSL support found."));
+			return TRUE;
 		}
 	}
 
--- a/libpurple/protocols/jabber/usermood.c	Wed Apr 30 16:12:02 2008 +0000
+++ b/libpurple/protocols/jabber/usermood.c	Thu May 01 15:24:43 2008 +0000
@@ -147,7 +147,7 @@
 
 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) {
 	JabberStream *js;
-	int max_mood_idx;
+	const int max_mood_idx = sizeof(moodstrings) / sizeof(moodstrings[0]) - 1;
 	int selected_mood = purple_request_fields_get_choice(fields, "mood");
 
 	if (!PURPLE_CONNECTION_IS_VALID(gc)) {
@@ -157,9 +157,6 @@
 
 	js = gc->proto_data;
 
-	/* This is ugly, but protects us from unexpected values. */
-	for (max_mood_idx = 0; moodstrings[max_mood_idx]; max_mood_idx++);
-
 	if (selected_mood < 0 || selected_mood >= max_mood_idx) {
 		purple_debug_error("jabber", "Invalid mood index (%d) selected.\n", selected_mood);
 		return;
--- a/pidgin/gtkprefs.c	Wed Apr 30 16:12:02 2008 +0000
+++ b/pidgin/gtkprefs.c	Thu May 01 15:24:43 2008 +0000
@@ -825,6 +825,107 @@
 		gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
 }
 
+
+#define CONVERSATION_CLOSE_ACCEL_PATH "<main>/Conversation/Close"
+
+/* Filled in in keyboard_shortcuts(). */
+static GtkAccelKey ctrl_w = { 0, 0, 0 };
+static GtkAccelKey escape = { 0, 0, 0 };
+
+static guint escape_closes_conversation_cb_id = 0;
+
+static gboolean
+accel_is_escape(GtkAccelKey *k)
+{
+	return (k->accel_key == escape.accel_key
+		&& k->accel_mods == escape.accel_mods);
+}
+
+/* Update the tickybox in Preferences when the keybinding for Conversation ->
+ * Close is changed via Gtk.
+ */
+static void
+conversation_close_accel_changed_cb (GtkAccelMap    *object,
+                                     gchar          *accel_path,
+                                     guint           accel_key,
+                                     GdkModifierType accel_mods,
+                                     gpointer        checkbox_)
+{
+	GtkToggleButton *checkbox = GTK_TOGGLE_BUTTON(checkbox_);
+	GtkAccelKey new = { accel_key, accel_mods, 0 };
+
+	g_signal_handler_block(checkbox, escape_closes_conversation_cb_id);
+	gtk_toggle_button_set_active(checkbox, accel_is_escape(&new));
+	g_signal_handler_unblock(checkbox, escape_closes_conversation_cb_id);
+}
+
+
+static void
+escape_closes_conversation_cb(GtkWidget *w,
+                              gpointer unused)
+{
+	gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
+	gboolean changed;
+	GtkAccelKey *new_key = active ? &escape : &ctrl_w;
+
+	changed = gtk_accel_map_change_entry(CONVERSATION_CLOSE_ACCEL_PATH,
+		new_key->accel_key, new_key->accel_mods, TRUE);
+
+	/* If another path is already bound to the new accelerator,
+	 * _change_entry tries to delete that binding (because it was passed
+	 * replace=TRUE).  If that other path is locked, then _change_entry
+	 * will fail.  We don't ever lock any accelerator paths, so this case
+	 * should never arise.
+	 */
+	if(!changed)
+		purple_notify_warning (NULL, NULL,
+			_("IT'S A LION! GET IN THE CAR!"), NULL);
+
+	/* TODO: create pidgin_accels_schedule_save */
+	pidgin_save_accels_cb(NULL, 0, 0, NULL, NULL);
+}
+
+
+/* Creates preferences for keyboard shortcuts that it's hard to change with the
+ * standard Gtk accelerator-changing mechanism.
+ */
+static void
+keyboard_shortcuts(GtkWidget *page)
+{
+	GtkWidget *vbox = pidgin_make_frame(page, _("Keyboard Shortcuts"));
+	GtkWidget *checkbox;
+	GtkAccelKey current = { 0, 0, 0 };
+	GtkAccelMap *map = gtk_accel_map_get();
+
+	/* Maybe it would be better just to hardcode the values?
+	 * -- resiak, 2007-04-30
+	 */
+	if (ctrl_w.accel_key == 0)
+	{
+		gtk_accelerator_parse ("<Control>w", &(ctrl_w.accel_key),
+			&(ctrl_w.accel_mods));
+		g_assert(ctrl_w.accel_key != 0);
+
+		gtk_accelerator_parse ("Escape", &(escape.accel_key),
+			&(escape.accel_mods));
+		g_assert(escape.accel_key != 0);
+	}
+
+	checkbox = gtk_check_button_new_with_mnemonic(
+		_("Cl_ose conversations with the Escape key"));
+	gtk_accel_map_lookup_entry(CONVERSATION_CLOSE_ACCEL_PATH, &current);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
+		accel_is_escape(&current));
+
+	escape_closes_conversation_cb_id = g_signal_connect(checkbox,
+		"clicked", G_CALLBACK(escape_closes_conversation_cb), NULL);
+
+	g_signal_connect(map, "changed::" CONVERSATION_CLOSE_ACCEL_PATH,
+		G_CALLBACK(conversation_close_accel_changed_cb), checkbox);
+
+	gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
+}
+
 static GtkWidget *
 interface_page(void)
 {
@@ -907,6 +1008,10 @@
 
 	g_list_free(names);
 
+
+	keyboard_shortcuts(ret);
+
+
 	gtk_widget_show_all(ret);
 	g_object_unref(sg);
 	return ret;
--- a/pidgin/plugins/notify.c	Wed Apr 30 16:12:02 2008 +0000
+++ b/pidgin/plugins/notify.c	Thu May 01 15:24:43 2008 +0000
@@ -112,7 +112,7 @@
 
 /* notification set/unset */
 static int notify(PurpleConversation *conv, gboolean increment);
-static void notify_win(PidginWindow *purplewin);
+static void notify_win(PidginWindow *purplewin, PurpleConversation *conv);
 static void unnotify(PurpleConversation *conv, gboolean reset);
 static int unnotify_cb(GtkWidget *widget, gpointer data,
                        PurpleConversation *conv);
@@ -141,6 +141,9 @@
 /* raise function */
 static void handle_raise(PidginWindow *purplewin);
 
+/* present function */
+static void handle_present(PurpleConversation *conv);
+
 /****************************************/
 /* Begin doing stuff below this line... */
 /****************************************/
@@ -193,14 +196,14 @@
 			purple_conversation_set_data(conv, "notify-message-count", GINT_TO_POINTER(count));
 		}
 
-		notify_win(purplewin);
+		notify_win(purplewin, conv);
 	}
 
 	return 0;
 }
 
 static void
-notify_win(PidginWindow *purplewin)
+notify_win(PidginWindow *purplewin, PurpleConversation *conv)
 {
 	if (count_messages(purplewin) <= 0)
 		return;
@@ -215,6 +218,8 @@
 		handle_urgent(purplewin, TRUE);
 	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_raise"))
 		handle_raise(purplewin);
+	if (purple_prefs_get_bool("/plugins/gtk/X11/notify/method_present"))
+		handle_present(conv);
 }
 
 static void
@@ -564,6 +569,12 @@
 }
 
 static void
+handle_present(PurpleConversation *conv)
+{
+	purple_conversation_present(conv);
+}
+
+static void
 type_toggle_cb(GtkWidget *widget, gpointer data)
 {
 	gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
@@ -771,6 +782,14 @@
 	g_signal_connect(G_OBJECT(toggle), "toggled",
 	                 G_CALLBACK(method_toggle_cb), "method_raise");
 
+	/* Present conversation method button */
+	toggle = gtk_check_button_new_with_mnemonic(_("_Present conversation window"));
+	gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
+	                             purple_prefs_get_bool("/plugins/gtk/X11/notify/method_present"));
+	g_signal_connect(G_OBJECT(toggle), "toggled",
+	                 G_CALLBACK(method_toggle_cb), "method_present");
+
 	/*---------- "Notification Removals" ----------*/
 	frame = pidgin_make_frame(ret, _("Notification Removal"));
 	vbox = gtk_vbox_new(FALSE, 5);
@@ -945,6 +964,7 @@
 	purple_prefs_add_bool("/plugins/gtk/X11/notify/method_count", FALSE);
 	purple_prefs_add_bool("/plugins/gtk/X11/notify/method_count_xprop", FALSE);
 	purple_prefs_add_bool("/plugins/gtk/X11/notify/method_raise", FALSE);
+	purple_prefs_add_bool("/plugins/gtk/X11/notify/method_present", FALSE);
 	purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_focus", TRUE);
 	purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_click", FALSE);
 	purple_prefs_add_bool("/plugins/gtk/X11/notify/notify_type", TRUE);
--- a/pidgin/win32/nsis/pidgin-installer.nsi	Wed Apr 30 16:12:02 2008 +0000
+++ b/pidgin/win32/nsis/pidgin-installer.nsi	Thu May 01 15:24:43 2008 +0000
@@ -49,6 +49,7 @@
 !include "WordFunc.nsh"
 !insertmacro VersionCompare
 !insertmacro WordFind
+!insertmacro un.WordFind
 
 ;--------------------------------
 ;Defines
@@ -549,23 +550,18 @@
 
 ;--------------------------------
 ;URI Handling
-SectionGroup /e $(URI_HANDLERS_SECTION_TITLE) SecURIHandlers
-  Section /o "aim:" SecURI_AIM
-    Push "aim"
-    Call RegisterURIHandler
-  SectionEnd
-  Section /o "msnim:" SecURI_MSNIM
-    Push "msnim"
+
+!macro URI_SECTION proto
+  Section /o "${proto}:" SecURI_${proto}
+    Push "${proto}"
     Call RegisterURIHandler
   SectionEnd
-  Section /o "myim:" SecURI_MYIM
-    Push "myim"
-    Call RegisterURIHandler
-  SectionEnd
-  Section /o "ymsgr:" SecURI_YMSGR
-    Push "ymsgr"
-    Call RegisterURIHandler
-  SectionEnd
+!macroend
+SectionGroup /e $(URI_HANDLERS_SECTION_TITLE) SecURIHandlers
+  !insertmacro URI_SECTION "aim"
+  !insertmacro URI_SECTION "msnim"
+  !insertmacro URI_SECTION "myim"
+  !insertmacro URI_SECTION "ymsgr"
 SectionGroupEnd
 
 ;--------------------------------
@@ -694,7 +690,19 @@
     ; The WinPrefs plugin may have left this behind..
     DeleteRegValue HKCU "${STARTUP_RUN_KEY}" "Pidgin"
     DeleteRegValue HKLM "${STARTUP_RUN_KEY}" "Pidgin"
-    ; Remove Language preference info (TODO: check if NSIS removes this)
+    ; Remove Language preference info
+    DeleteRegValue HKCU "${PIDGIN_REG_KEY}" "Installer Language"
+
+    ; Remove any URI handlers
+    ; I can't think of an easy way to maintain a list in a single place
+    Push "aim"
+    Call un.UnregisterURIHandler
+    Push "msnim"
+    Call un.UnregisterURIHandler
+    Push "myim"
+    Call un.UnregisterURIHandler
+    Push "ymsgr"
+    Call un.UnregisterURIHandler
 
     Delete "$INSTDIR\ca-certs\Equifax_Secure_CA.pem"
     Delete "$INSTDIR\ca-certs\GTE_CyberTrust_Global_Root.pem"
@@ -903,12 +911,12 @@
   ReadRegStr $R3 HKCR "$R2" ""
   IfErrors default_on ;there is no current handler
 
-  ; Check if Pidgin is the current handler
-  ClearErrors
-  ReadRegStr $R3 HKCR "$R2\shell\Open\command" ""
-  IfErrors end_loop
-  ${WordFind} "$R3" "pidgin.exe" "E+1{" $R3
-  IfErrors end_loop default_on
+  Push $R2
+  Call CheckIfPidginIsCurrentURIHandler
+  Pop $R3
+
+  ; If Pidgin isn't the current handler, we don't steal it automatically
+  IntCmp $R3 0 end_loop
 
   ;We default the URI handler checkbox on
   default_on:
@@ -926,9 +934,58 @@
   Pop $R0
 FunctionEnd ;SelectURIHandlerSections
 
+; Check if Pidgin is the current handler
+; Returns a boolean on the stack
+!macro CheckIfPidginIsCurrentURIHandlerMacro UN
+Function ${UN}CheckIfPidginIsCurrentURIHandler
+  Exch $R0
+  ClearErrors
+
+  ReadRegStr $R0 HKCR "$R0\shell\Open\command" ""
+  IfErrors 0 +3
+    IntOp $R0 0 + 0
+    Goto done
+
+  !ifdef __UNINSTALL__
+  ${un.WordFind} "$R0" "pidgin.exe" "E+1{" $R0
+  !else
+  ${WordFind} "$R0" "pidgin.exe" "E+1{" $R0
+  !endif
+  IntOp $R0 0 + 1
+  IfErrors 0 +2
+    IntOp $R0 0 + 0
+
+  done:
+  Exch $R0
+FunctionEnd
+!macroend
+!insertmacro CheckIfPidginIsCurrentURIHandlerMacro ""
+!insertmacro CheckIfPidginIsCurrentURIHandlerMacro "un."
+
+; If Pidgin is the current URI handler for the specified protocol, remove it.
+Function un.UnregisterURIHandler
+  Exch $R0
+  Push $R1
+
+  Push $R0
+  Call un.CheckIfPidginIsCurrentURIHandler
+  Pop $R1
+
+  ; If Pidgin isn't the current handler, leave it as-is
+  IntCmp $R1 0 done
+
+  ;Unregister the URI handler
+  DetailPrint "Unregistering $R0 URI Handler"
+  DeleteRegKey HKCR "$R0"
+
+  done:
+  Pop $R1
+  Pop $R0
+FunctionEnd
 
 Function RegisterURIHandler
   Exch $R0
+  DetailPrint "Registering $R0 URI Handler"
   DeleteRegKey HKCR "$R0"
   WriteRegStr HKCR "$R0" "" "URL:$R0"
   WriteRegStr HKCR "$R0" "URL Protocol" ""
@@ -1198,12 +1255,14 @@
   StrCpy $SPELLCHECK_SEL ""
 
   ;Try to copy the old Gaim installer Lang Reg. key
+  ;(remove it after we're done to prevent this being done more than once)
   ClearErrors
   ReadRegStr $R0 HKCU "${PIDGIN_REG_KEY}" "Installer Language"
   IfErrors 0 +5
   ClearErrors
-  ReadRegStr $R0 HKCU "SOFTWARE\gaim" "Installer Language"
-  IfErrors +2
+  ReadRegStr $R0 HKCU "${OLD_GAIM_REG_KEY}" "Installer Language"
+  IfErrors +3
+  DeleteRegValue HKCU "${OLD_GAIM_REG_KEY}" "Installer Language"
   WriteRegStr HKCU "${PIDGIN_REG_KEY}" "Installer Language" "$R0"
 
   !insertmacro SetSectionFlag ${SecSpellCheck} ${SF_RO}
@@ -1321,6 +1380,7 @@
 Function un.onInit
   Call un.RunCheck
   StrCpy $name "Pidgin ${PIDGIN_VERSION}"
+;LogSet on
 
   ; Get stored language preference
   !insertmacro MUI_UNGETLANGUAGE