--- pidgin-encryption-3.0.orig/state_ui.c +++ pidgin-encryption-3.0/state_ui.c @@ -268,6 +268,8 @@ static GtkIMHtmlSmiley * create_smiley_if_absent(GtkIMHtml *imhtml) { GtkIMHtmlSmiley * smiley; const char* category = gtk_imhtml_get_protocol_name(imhtml); + + if (!category) return NULL; /* make sure that the category we're about to use to add (based on the protocol name) */ /* already exists. If it doesn't, just use the default category so it isn't created. */ --- pidgin-encryption-3.0.orig/debian/changelog +++ pidgin-encryption-3.0/debian/changelog @@ -0,0 +1,346 @@ +pidgin-encryption (3.0-6~karmic~ppa1) karmic; urgency=low + + * Backport to karmic + - use source format (1.0) + + -- Micah Gersten Thu, 21 Jan 2010 15:50:29 -0600 + +pidgin-encryption (3.0-6) unstable; urgency=low + + * debian/patches: drop patch to fix scrambled header. It was clearly + not meant to interoperate with other versions and shouldn't have + been included in the first place. (closes: #564770) + + -- Leo Costela Tue, 12 Jan 2010 19:49:01 +0100 + +pidgin-encryption (3.0-5) unstable; urgency=low + + * debian/control: policy 3.8.3 (no changes) + * convert to 3.0 (quilt) + * debian/{compat,control}: bump to dh 7 + * debian/patches: add patch to fix scrambled header + (closes: #557581) (thanks Rafi Rubin) + * debian/rules: replace dh_clean -k with dh_prep + + -- Leo Costela Wed, 23 Dec 2009 00:47:16 +0100 + +pidgin-encryption (3.0-4) unstable; urgency=low + + * debian/control: policy 3.8.1 (no changes) + * debian/{control,rules}: add quilt support + * debian/patches: add log_crash.patch (closes: #525501) + + -- Leo Costela Sun, 10 May 2009 18:26:58 +0200 + +pidgin-encryption (3.0-3) unstable; urgency=medium (FTBFS) + + * debian/watch: added + * debian/control: policy 3.7.3 (no changes) + * debian/rules: remove non-needed configure options, pkg-config should + handle them correctly (closes: #456831) + + -- Leo Costela Sun, 23 Dec 2007 22:07:09 +0100 + +pidgin-encryption (3.0-2) unstable; urgency=low + + * debian/control: + - updated URL + - add Homepage field + - add Enhances field + * debian/copyright: update software name + * debian/rules: updated to account for removal of gtklog.patch + + -- Leo Costela Sun, 09 Sep 2007 01:17:22 +0200 + +pidgin-encryption (3.0-1) unstable; urgency=low + + * New upstream release + - Fixed ICQ key-negotiation hangs (closes: #407071) + - Fixed memory leaks (closes: #387807, #387810, #387816) + - Segfault for those who used gaim-encryption 3.0-beta7 with gaim + 2.0-beta6 no longer a problem (actually fixed in the never-packaged + 3.0-beta8) (closes: #410764, #413643) + * debian/rules, debian/control: renamed pidgin-plugin, following gaim's + renaming, scheme + * removed no longer needed patch gtklog.patch + + -- Leo Costela Sat, 12 May 2007 02:39:56 -0300 + +gaim-encryption (3.0~beta7-1) unstable; urgency=low + + * New upstream release + + -- Leo Costela Thu, 16 Nov 2006 20:11:59 -0200 + +gaim-encryption (3.0~beta6-1) unstable; urgency=medium + + * new upstream release (closes: #394298, #394637, #394760) + * debian/rules,debian/patches/gtklog.patch: compensate for gaim's Debian-only patch + * urgency medium because it's RC + + -- Leo Costela Wed, 25 Oct 2006 10:44:45 -0300 + + +gaim-encryption (3.0~beta5-3) unstable; urgency=low + + * Migrate to Unstable (Gaim beta is already in) + (closes: #340246, #362683, #313707, #348229) + * Ack NMU (thanks Alexander Wirt!) (closes: #337127) + * Change the version to use the new '~' character (should ease things up when + 3.0-final is released...) + + -- Leo Costela Thu, 28 Aug 2006 01:58:01 -0300 + +gaim-encryption (3.0+beta5-2) experimental; urgency=low + + * debian/rules: apply Lionel Porcheron's patch, minus the watch file for now (thanks!) + + -- Leo Costela Tue, 22 Aug 2006 21:08:36 -0300 + +gaim-encryption (3.0+beta5-1) experimental; urgency=low + + * New upstream version (closes: #362683) + + -- Leo Costela Tue, 16 May 2006 11:50:17 -0300 + +gaim-encryption (2.38-3.1) unstable; urgency=medium + + * Non-maintainer upload. + * Add a manual fix for colons in len check (Closes: #33712) + Thanks to Max Kellermann for the patch + + -- Alexander Wirt Sat, 16 Sep 2006 20:50:55 +0200 + +gaim-encryption (2.38-3) unstable; urgency=low + + * debian/rules: remove bashisms (closes: #375444) + + -- Leo Costela Tue, 27 Jun 2006 23:01:13 -0300 + +gaim-encryption (2.38-2) unstable; urgency=low + + * Changed deps to accomodate Mozilla to XULrunner lib migration + (Closes: #364372) + * Updated policy to 3.7.2 (no changes) + + -- Leo Costela Fri, 12 May 2006 20:45:59 -0300 + +gaim-encryption (2.38-1) unstable; urgency=low + + * New upstream version + * Fixed Gaim version check (Closes: #313345) + + -- Leo Costela Mon, 13 Jun 2005 14:35:57 -0300 + +gaim-encryption (2.37-1) unstable; urgency=low + + * New upstream version + * Change deps/build-deps to gaim >= 1:1.3 + * This version should end the popup about compatibility warnings + + -- Leo Costela Fri, 13 May 2005 10:36:46 -0300 + +gaim-encryption (2.36-5) unstable; urgency=low + + * Rebuild with gaim 1.30, to avoid warnings (it's a "feature" according to + upstream) + + -- Leo Costela Wed, 11 May 2005 17:46:26 -0300 + +gaim-encryption (2.36-4) unstable; urgency=low + + * depend on gaim >= 1:1.2 (sorry, forgot the epoch) (closes: #305719) + + -- Leo Costela Thu, 21 Apr 2005 16:02:27 -0300 + +gaim-encryption (2.36-3) unstable; urgency=low + + * re-compile with new version of Gaim to make the warning go away (while I + don't come up with a permanent fix) (closes: #303732) + * depend on gaim >= 1.2 (closes: #302838) + + -- Leo Costela Fri, 08 Apr 2005 10:22:25 -0300 + +gaim-encryption (2.36-2) unstable; urgency=low + + * re-compile with new version of Gaim to make the warning go away (while I + don't come up with a permanent fix) + * fix build-depends (I don't know how that slipped through) + (closes: #301014) + + -- Leo Costela Wed, 23 Mar 2005 10:31:16 -0300 + +gaim-encryption (2.36-1) unstable; urgency=low + + * New upstream release + + -- Leo Costela Sun, 20 Mar 2005 19:42:33 -0300 + +gaim-encryption (2.35-1) unstable; urgency=low + + * New upstream release + + -- Leo Costela Sun, 27 Feb 2005 22:27:29 -0300 + +gaim-encryption (2.34-1) unstable; urgency=low + + * New upstream release + * First upload to unstable (closes: #206421) + + -- Leo Costela Sun, 24 Jan 2005 08:48:23 -0300 + +gaim-encryption (2.33-1) experimental; urgency=low + + * Now builds with gaim-dev from unstable + + -- Leo Costela Sun, 23 Jan 2005 19:41:05 -0300 + +gaim-encryption (2.32-2) experimental; urgency=low + + * Filled deps, build-deps still unsure + + -- Leo Costela Fri, 14 Jan 2005 09:12:32 -0300 + +gaim-encryption (2.32-1) experimental; urgency=low + + * First official package to experimental + + -- Leo Costela Thu, 13 Jan 2005 22:50:29 -0300 + +gaim-encryption (1.1.1+2.32-1) personal; urgency=low + + * New upstream release of Gaim + + -- Leo Costela Mon, 03 Jan 2005 09:36:09 -0300 + +gaim-encryption (1.1.0+2.32-1) personal; urgency=low + + * New upstream release of Gaim and Gaim-encryption (missed one release, I + know, sorry!) + + -- Leo Costela Mon, 06 Dec 2004 10:05:52 -0300 + +gaim-encryption (1.0.1+2.31-1) personal; urgency=low + + * New upstream release of Gaim + + -- Leo Costela Tue, 13 Oct 2004 00:51:46 -0300 + +gaim-encryption (1.0.0+2.31-1) personal; urgency=low + + * New upstream release of Gaim and Gaim-encryption + + -- Leo Costela Mon, 20 Sep 2004 15:00:54 -0300 + +gaim-encryption (0.82.1+2.30-1) personal; urgency=low + + * New upstream release of Gaim and Gaim-encryption + + -- Leo Costela Thu, 03 Sep 2004 20:27:56 -0300 + +gaim-encryption (0.81+2.29-1) personal; urgency=low + + * New upstream release of Gaim and Gaim-encryption + * modified debian/rules to adapt to new build method + + -- Leo Costela Thu, 11 Aug 2004 15:14:07 -0300 + +gaim-encryption (0.80+2.28-1) personal; urgency=low + + * New upstream release of Gaim and Gaim-encryption + + -- Leo Costela Thu, 29 Jul 2004 16:38:19 -0300 + +gaim-encryption (0.78+2.26-1) personal; urgency=low + + * New upstream release of Gaim and Gaim-encryption + + -- Leo Costela Tue, 01 Jun 2004 12:48:44 -0300 + +gaim-encryption (0.77+2.25-1) personal; urgency=low + + * New upstream releases of Gaim-encryption + + -- Leo Costela Mon, 26 Apr 2004 19:31:55 -0300 + +gaim-encryption (0.76+2.24-1) personal; urgency=low + + * New upstream releases of Gaim-encryption + * Fix the constant segfaulting when using crypto + + -- Leo Costela Fri, 16 Apr 2004 18:01:39 -0300 + +gaim-encryption (0.76+2.23-1) personal; urgency=low + + * New upstream releases of Gaim and Gaim-encryption + * Fix the problems with MSN, Yahoo, IRC, NOT BACKWARD COMPATIBLE + + -- Leo Costela Sat, 10 Apr 2004 22:39:36 -0300 + +gaim-encryption (0.76+2.22-1) personal; urgency=low + + * New upstream releases of Gaim and Gaim-encryption + + -- Leo Costela Mon, 5 Apr 2004 20:11:32 -0300 + +gaim-encryption (0.75+2.21-2) personal; urgency=low + + * Apply security patch from FreeBSD security team + + -- Leo Costela Thu, 27 Nov 2003 20:52:43 -0300 + +gaim-encryption (0.75+2.21-1) personal; urgency=low + + * New upstream release gaim-encryption + * Rebuild to with correct dependency on libnss3 and libnspr4 (closes the bug + in which the plugin didn't load) + + -- Leo Costela Thu, 27 Nov 2003 20:52:43 -0300 + +gaim-encryption (0.75+2.20-1) personal; urgency=low + + * New upstream releases of gaim + gaim-encryption + + -- Leo Costela Thu, 27 Nov 2003 20:52:43 -0300 + +gaim-encryption (0.74+2.18-1) personal; urgency=low + + * New upstream releases of gaim + gaim-encryption + + -- Leo Costela Thu, 27 Nov 2003 20:52:43 -0300 + +gaim-encryption (0.72+2.17-1) personal; urgency=low + + * New upstream releases of gaim + gaim-encryption + + -- Leo Costela Mon, 10 Nov 2003 19:21:46 -0300 + +gaim-encryption (0.71+2.15-1) personal; urgency=low + + * New upstream releases of gaim + gaim-encryption + + -- Leo Costela Mon, 20 Oct 2003 21:34:35 -0300 + +gaim-encryption (0.68+2.10-1) personal; urgency=low + + * New upstream release + + -- Leo Costela Wed, 10 Sep 2003 13:49:22 -0300 + +gaim-encryption (0.66+2.04-1) personal; urgency=low + + * New upstream release + + -- Leo Costela Wed, 13 Aug 2003 11:54:20 -0300 + +gaim-encryption (0.66+2.00-1) personal; urgency=low + + * New upstream release + + -- Leo Costela Mon, 21 Jul 2003 09:33:44 -0300 + +gaim-encryption (0.64+2.00beta1-1) personal; urgency=low + + * First Debian package + + -- Leo Costela Mon, 14 Jul 2003 15:06:51 -0300 --- pidgin-encryption-3.0.orig/debian/copyright +++ pidgin-encryption-3.0/debian/copyright @@ -0,0 +1,21 @@ +pidgin-encryption was packaged for Debian by Leo Costela +on Mon, 14 Jun 2003 15:21:54 -0300 +Based on packaging work done for gaim. + +Author: © 2003-2007 Bill Tompkins + +Downloaded from: +http://pidgin-encrypt.sourceforge.net + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of +the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +On Debian systems, the complete text of the GNU General Public +License can be found in /usr/share/common-licenses/GPL file. --- pidgin-encryption-3.0.orig/debian/rules +++ pidgin-encryption-3.0/debian/rules @@ -0,0 +1,52 @@ +#!/usr/bin/make -f + +#export DH_VERBOSE=1 + +clean: + dh_testdir + dh_testroot + [ ! -f Makefile ] || $(MAKE) distclean + rm -f build-stamp config.sub config.guess + dh_clean + +autotools: + rm -f config.sub config.guess + ln -s /usr/share/misc/config.sub config.sub + ln -s /usr/share/misc/config.guess config.guess + +build: build-stamp +build-stamp: autotools + dh_testdir + ./configure --prefix=/usr + $(MAKE) + touch build-stamp + +install: build + dh_testdir + dh_testroot + dh_prep + $(MAKE) install DESTDIR=$(CURDIR)/debian/pidgin-encryption + rm -f $(CURDIR)/debian/pidgin-encryption/usr/lib/pidgin/*.la + rm -f $(CURDIR)/debian/pidgin-encryption/usr/lib/pidgin/*.a + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installchangelogs CHANGELOG + dh_link + dh_strip + dh_compress + dh_fixperms + dh_pidgin + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install autotools --- pidgin-encryption-3.0.orig/debian/watch +++ pidgin-encryption-3.0/debian/watch @@ -0,0 +1,3 @@ +version=3 + +http://sf.net/pidgin-encrypt/pidgin-encryption-(.+)\.tar\.gz --- pidgin-encryption-3.0.orig/debian/docs +++ pidgin-encryption-3.0/debian/docs @@ -0,0 +1,5 @@ +ABOUT-NLS +NOTES +README +TODO +WISHLIST --- pidgin-encryption-3.0.orig/debian/compat +++ pidgin-encryption-3.0/debian/compat @@ -0,0 +1 @@ +7 --- pidgin-encryption-3.0.orig/debian/control +++ pidgin-encryption-3.0/debian/control @@ -0,0 +1,16 @@ +Source: pidgin-encryption +Section: net +Priority: optional +Maintainer: Leo Costela +Build-Depends: debhelper (>= 7.0.50), libnss3-dev, libnspr4-dev, pidgin-dev (>= 2.0.0), libgtk2.0-dev, autotools-dev +Standards-Version: 3.8.3 +Homepage: http://pidgin-encrypt.sourceforge.net + +Package: pidgin-encryption +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Enhances: pidgin +Description: pidgin plugin that provides transparent encryption + Provides transparent encryption to all protocols supported by Pidgin. + Can be activated on a per user basis or even automatically detected. + Uses a private/public key system based on Mozilla's NSS. --- pidgin-encryption-3.0.orig/debian/patches/fix_header_escaping.patch +++ pidgin-encryption-3.0/debian/patches/fix_header_escaping.patch @@ -0,0 +1,64 @@ +--- pidgin-encryption-3.0.orig/encrypt.c 2007-05-06 23:37:55.000000000 -0400 ++++ pidgin-encryption-3.0.new/encrypt.c 2009-11-22 22:28:34.052010351 -0500 +@@ -1114,21 +1114,21 @@ static void PE_headers_init() { + notify_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + + g_hash_table_insert(header_table, g_strdup("prpl-toc"), +- g_strdup("*** Encrypted with the Gaim-Encryption plugin ")); + g_hash_table_insert(notify_table, g_strdup("prpl-toc"), + g_strdup("")); + + g_hash_table_insert(header_table, g_strdup("prpl-oscar"), +- g_strdup("*** Encrypted with the Gaim-Encryption plugin ")); + g_hash_table_insert(notify_table, g_strdup("prpl-oscar"), + g_strdup("")); + + g_hash_table_insert(header_table, g_strdup("prpl-aim"), +- g_strdup("*** Encrypted with the Gaim-Encryption plugin ")); + g_hash_table_insert(notify_table, g_strdup("prpl-aim"), +@@ -1136,7 +1136,7 @@ static void PE_headers_init() { + + /* If jabber stops stripping HTML, we can go back to these headers */ + /* g_hash_table_insert(header_table, g_strdup("prpl-jabber"), */ +-/* g_strdup("*** Encrypted with the Gaim-Encryption plugin ")); */ + /* g_hash_table_insert(notify_table, g_strdup("prpl-jabber"), */ +@@ -1144,22 +1144,22 @@ static void PE_headers_init() { + + + g_hash_table_insert(header_table, g_strdup("prpl-jabber"), +- g_strdup("*** Encrypted with the Gaim-Encryption plugin ")); ++ g_strdup("--- Encrypted with the Gaim-Encryption plugin ")); + g_hash_table_insert(footer_table, g_strdup("prpl-jabber"), + g_strdup(" ")); + g_hash_table_insert(notify_table, g_strdup("prpl-jabber"), + g_strdup(" ")); + +- header_default = g_strdup("*** Encrypted :"); ++ header_default = g_strdup("--- Encrypted :"); + } + +-/* #define CRYPT_HEADER "*** Encrypted with the Gaim-Encryption plugin " */ + /* #define CRYPT_NOTIFY_HEADER "" */ + + // Jabber seems to turn our double quotes into single quotes at times, so define + // the same headers, only with single quotes. Lengths MUST be the same as above +-/* #define CRYPT_HEADER_MANGLED "*** Encrypted with the Gaim-Encryption plugin " */ + + + --- pidgin-encryption-3.0.orig/debian/patches/log_crash.patch +++ pidgin-encryption-3.0/debian/patches/log_crash.patch @@ -0,0 +1,11 @@ +--- pidgin-encryption-3.0.orig/state_ui.c 2007-05-07 02:15:27.000000000 +0200 ++++ pidgin-encryption-3.0.new/state_ui.c 2009-04-26 17:08:02.000000000 +0200 +@@ -268,6 +268,8 @@ + static GtkIMHtmlSmiley * create_smiley_if_absent(GtkIMHtml *imhtml) { + GtkIMHtmlSmiley * smiley; + const char* category = gtk_imhtml_get_protocol_name(imhtml); ++ ++ if (!category) return NULL; + + /* make sure that the category we're about to use to add (based on the protocol name) */ + /* already exists. If it doesn't, just use the default category so it isn't created. */ --- pidgin-encryption-3.0.orig/debian/patches/series +++ pidgin-encryption-3.0/debian/patches/series @@ -0,0 +1 @@ +log_crash.patch --- pidgin-encryption-3.0.orig/debian/patches/.dpkg-source-applied +++ pidgin-encryption-3.0/debian/patches/.dpkg-source-applied @@ -0,0 +1 @@ +log_crash.patch --- pidgin-encryption-3.0.orig/.pc/.version +++ pidgin-encryption-3.0/.pc/.version @@ -0,0 +1 @@ +2 --- pidgin-encryption-3.0.orig/.pc/applied-patches +++ pidgin-encryption-3.0/.pc/applied-patches @@ -0,0 +1 @@ +log_crash.patch --- pidgin-encryption-3.0.orig/.pc/log_crash.patch/state_ui.c +++ pidgin-encryption-3.0/.pc/log_crash.patch/state_ui.c @@ -0,0 +1,460 @@ +#include "pidgin-encryption-config.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "state_ui.h" +#include "state.h" +#include "encrypt.h" +#include "nls.h" + +#ifdef _WIN32 +#include "win32/win32dep.h" +#endif + +/* Icons */ +#include "icon_out_lock.xpm" +#include "icon_out_unlock.xpm" +#include "icon_out_capable.xpm" +#include "icon_in_lock.xpm" +#include "icon_in_unlock.xpm" + +#define PIXMAP_TX_UNENCRYPTED "Pidgin-Encryption_Out_Unencrypted" +#define PIXMAP_TX_CAPABLE "Pidgin-Encryption_Out_Capable" +#define PIXMAP_TX_ENCRYPTED "Pidgin-Encryption_Out_Encrypted" +#define PIXMAP_RX_UNENCRYPTED "Pidgin-Encryption_In_Unencrypted" +#define PIXMAP_RX_ENCRYPTED "Pidgin-Encryption_In_Encrypted" + +static GHashTable * tx_encrypt_menus = 0; +static GHashTable * rx_encrypt_iconlist = 0; +static gchar * smiley_filepath = 0; + +struct _TxMenuButtons { + GtkWidget *unencrypted; /* each is a iconmenu item with one corresponding submenu item */ + GtkWidget *capable; + GtkWidget *encrypted; +}; +typedef struct _TxMenuButtons TxMenuButtons; + +static TxMenuButtons * get_txbuttons_for_win(PidginWindow *win); +static GtkIMHtmlSmiley * create_smiley_if_absent(GtkIMHtml *imhtml); +static void enable_encrypt_cb(GtkWidget* item, PidginWindow* win); +static void disable_encrypt_cb(GtkWidget* item, PidginWindow* win); +static void remove_txbuttons_cb( GtkWidget *widget, gpointer data ); +static void remove_rx_icon_cb( GtkWidget *widget, gpointer data); + + + +static TxMenuButtons * get_txbuttons_for_win(PidginWindow *win) { + TxMenuButtons *tx_menubuttons; + GtkWidget *submenuitem, *menuitem; + GtkWidget *menu; + GtkWidget *image; + + tx_menubuttons = g_hash_table_lookup(tx_encrypt_menus, win); + + if (!tx_menubuttons) { + GtkWidget *menubar = win->menu.menubar; + int newMenuPos = 0; /* Where to insert our 3 new menu items: at current pos of menu tray */ + + if (menubar == NULL) { + return NULL; + } + + { + GList * list = gtk_container_get_children(GTK_CONTAINER(menubar)); + GList * iter = list; + while (iter) { + if (PIDGIN_IS_MENU_TRAY(iter->data)) { + iter = 0; + } else { + ++newMenuPos; + iter = iter->next; + } + } + g_list_free(list); + } + + tx_menubuttons = g_malloc(sizeof(TxMenuButtons)); + + /* 'not capable' icon on menu with "Enable Encryption" as sole menu possibility */ + menu = gtk_menu_new(); + + submenuitem = gtk_menu_item_new_with_label (_("Enable Encryption")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), submenuitem); + gtk_widget_show(submenuitem); + g_signal_connect(G_OBJECT(submenuitem), "activate", G_CALLBACK(enable_encrypt_cb), win); + + image = gtk_image_new_from_stock(PIXMAP_TX_UNENCRYPTED, GTK_ICON_SIZE_MENU); + menuitem = gtk_image_menu_item_new_with_label(""); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); + + gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, newMenuPos); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_widget_show(menuitem); + + tx_menubuttons->unencrypted = menuitem; + + /* 'capable' icon on menu with "Enable Encryption" as sole menu possibility */ + menu = gtk_menu_new(); + + submenuitem = gtk_menu_item_new_with_label (_("Enable Encryption")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), submenuitem); + gtk_widget_show(submenuitem); + g_signal_connect(G_OBJECT(submenuitem), "activate", G_CALLBACK(enable_encrypt_cb), win); + + image = gtk_image_new_from_stock(PIXMAP_TX_CAPABLE, GTK_ICON_SIZE_MENU); + menuitem = gtk_image_menu_item_new_with_label(""); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); + + gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, newMenuPos); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_widget_hide(menuitem); + + tx_menubuttons->capable = menuitem; + + + /* 'encrypted' icon on menu with "Disable Encryption" as sole menu possibility */ + menu = gtk_menu_new(); + + submenuitem = gtk_menu_item_new_with_label (_("Disable Encryption")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), submenuitem); + gtk_widget_show(submenuitem); + g_signal_connect(G_OBJECT(submenuitem), "activate", G_CALLBACK(disable_encrypt_cb), win); + + image = gtk_image_new_from_stock(PIXMAP_TX_ENCRYPTED, GTK_ICON_SIZE_MENU); + menuitem = gtk_image_menu_item_new_with_label(""); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); + + gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, newMenuPos); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_widget_hide(menuitem); + + tx_menubuttons->encrypted = menuitem; + + g_hash_table_insert(tx_encrypt_menus, win, tx_menubuttons); + + g_signal_connect (G_OBJECT(win->window), "destroy", G_CALLBACK(remove_txbuttons_cb), win); + + purple_debug(PURPLE_DEBUG_MISC, "pidgin-encryption", + "Adding menu item to win %p, item %p\n", + win, tx_menubuttons); + } + return tx_menubuttons; +} + +static void remove_txbuttons_cb( GtkWidget *widget, gpointer data ) { + purple_debug(PURPLE_DEBUG_INFO, "pidgin-encryption", + "Got callback for destroyed window %p %p\n", data, widget); + g_hash_table_remove(tx_encrypt_menus, data); +} + +static void remove_rx_icon_cb( GtkWidget *widget, gpointer data ) { + purple_debug(PURPLE_DEBUG_INFO, "pidgin-encryption", + "Got callback for destroyed window %p %p\n", data, widget); + g_hash_table_remove(rx_encrypt_iconlist, data); +} + +void PE_state_ui_init() { + smiley_filepath = g_build_filename(DATADIR, "pixmaps", "pidgin", + "pidgin-encryption", "crypto.png", NULL); + + tx_encrypt_menus = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); + + rx_encrypt_iconlist = g_hash_table_new(g_direct_hash, g_direct_equal); +} + +void PE_state_ui_delete() { + g_hash_table_destroy(tx_encrypt_menus); + g_hash_table_destroy(rx_encrypt_iconlist); + + g_free(smiley_filepath); +} + +void PE_set_tx_encryption_icon(PurpleConversation* conv, + gboolean do_encrypt, gboolean is_capable) { + PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + PidginWindow *win; + TxMenuButtons *buttons; + + /* we now get called based on conversation changes before the gtkconv has */ + /* been set up for the conversation. If that is going on, just bail until */ + /* things are set up right */ + + if (!gtkconv) return; + + win = pidgin_conv_get_window(gtkconv); + g_return_if_fail(win != NULL); + + /* ensure that the conv we are adding for is actually the active one */ + if (pidgin_conv_window_get_active_gtkconv(win)->active_conv != conv) { + return; + } + + buttons = get_txbuttons_for_win(win); + g_return_if_fail(buttons != NULL); + + if (do_encrypt) { + gtk_widget_hide(buttons->unencrypted); + gtk_widget_hide(buttons->capable); + gtk_widget_show(buttons->encrypted); + } else if (is_capable) { + gtk_widget_hide(buttons->unencrypted); + gtk_widget_show(buttons->capable); + gtk_widget_hide(buttons->encrypted); + } else { + gtk_widget_show(buttons->unencrypted); + gtk_widget_hide(buttons->capable); + gtk_widget_hide(buttons->encrypted); + } +} + +void PE_set_rx_encryption_icon(PurpleConversation *conv, gboolean encrypted) { + PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + PidginWindow *win; + + GtkWidget *tray; + GtkWidget *rx_encrypted_icon; + + /* we now get called based on conversation changes before the gtkconv has */ + /* been set up for the conversation. If that is going on, just bail until */ + /* things are set up right */ + + if (!gtkconv) return; + + win = pidgin_conv_get_window(gtkconv); + g_return_if_fail(win != NULL); + tray = win->menu.tray; + + /* ensure that the conv we are adding for is actually the active one */ + if (pidgin_conv_window_get_active_gtkconv(win)->active_conv != conv) { + return; + } + + + rx_encrypted_icon = g_hash_table_lookup(rx_encrypt_iconlist, win); + + if (!rx_encrypted_icon) { + rx_encrypted_icon = gtk_image_new_from_stock("Pidgin-Encryption_In_Encrypted", GTK_ICON_SIZE_MENU); + + pidgin_menu_tray_append(PIDGIN_MENU_TRAY(tray), rx_encrypted_icon, + _("The last message received was encrypted with the Pidgin-Encryption plugin")); + + g_hash_table_insert(rx_encrypt_iconlist, win, rx_encrypted_icon); + g_signal_connect (G_OBJECT(win->window), "destroy", G_CALLBACK(remove_rx_icon_cb), win); + + } else { + purple_debug(PURPLE_DEBUG_MISC, "pidgin-encryption", + "Using pre-existing menu icon for conv %p, win %p, item %p\n", + conv, win, rx_encrypted_icon); + } + + if (encrypted) { + gtk_widget_show(rx_encrypted_icon); + } else { + gtk_widget_hide(rx_encrypted_icon); + } +} + +/* returns the new Smiley if created, or NULL if it was already there */ +static GtkIMHtmlSmiley * create_smiley_if_absent(GtkIMHtml *imhtml) { + GtkIMHtmlSmiley * smiley; + const char* category = gtk_imhtml_get_protocol_name(imhtml); + + /* make sure that the category we're about to use to add (based on the protocol name) */ + /* already exists. If it doesn't, just use the default category so it isn't created. */ + if (g_hash_table_lookup(imhtml->smiley_data, category) == NULL) { + category = NULL; + } + + smiley = gtk_imhtml_smiley_get(imhtml, category, CRYPTO_SMILEY); + + if (smiley) { + /* We're not creating it, because it was already there. Tell the caller that */ + return NULL; + } + + /* This may leak. How does it get cleaned up? */ + smiley = g_new0(GtkIMHtmlSmiley, 1); + smiley->file = smiley_filepath; + smiley->smile = CRYPTO_SMILEY; + smiley->loader = NULL; + smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; + + gtk_imhtml_associate_smiley(imhtml, category, smiley); + return smiley; +} + +static void enable_encrypt_cb(GtkWidget* item, PidginWindow* win) { + PidginConversation *gtkconv; + PurpleConversation *conv; + + g_return_if_fail(win != NULL); + gtkconv = pidgin_conv_window_get_active_gtkconv(win); + + g_return_if_fail(gtkconv != NULL); + + conv = gtkconv->active_conv; + + g_return_if_fail(conv != NULL); + + purple_debug(PURPLE_DEBUG_MISC, "pidgin-encryption", "Enable encryption on conv %p\n", conv); + PE_set_tx_encryption(conv, TRUE); +} + +static void disable_encrypt_cb(GtkWidget* item, PidginWindow* win) { + PidginConversation *gtkconv; + PurpleConversation *conv; + + g_return_if_fail(win != NULL); + gtkconv = pidgin_conv_window_get_active_gtkconv(win); + + g_return_if_fail(gtkconv != NULL); + + conv = gtkconv->active_conv; + + g_return_if_fail(conv != NULL); + + purple_debug(PURPLE_DEBUG_MISC, "pidgin-encryption", "Disable encryption on conv %p\n", conv); + PE_set_tx_encryption(conv, FALSE); +} + +void PE_add_smiley(PurpleConversation* conv) { + GtkIMHtmlSmiley * smiley; + GtkIMHtml * imhtml; + + PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + + if (!gtkconv) return; + + create_smiley_if_absent( GTK_IMHTML(gtkconv->entry) ); + + imhtml = GTK_IMHTML(gtkconv->imhtml); + + smiley = create_smiley_if_absent(imhtml); + + /* if the smiley was created this time, the value of the new smiley was returned */ + /* given that, we want to iterate through and use the smiley everywhere */ + if (smiley) { + GtkTextIter cur_iter, cur_plus_offset_iter; + gboolean offset_is_ok; + const char* category = gtk_imhtml_get_protocol_name(imhtml); + + /* Go through the buffer and replace our smiley text with the smiley */ + gtk_text_buffer_get_start_iter(imhtml->text_buffer, &cur_iter); + + cur_plus_offset_iter = cur_iter; + offset_is_ok = gtk_text_iter_forward_chars(&cur_plus_offset_iter, CRYPTO_SMILEY_LEN); + while (offset_is_ok) { + char *buffer_text = gtk_text_buffer_get_text(imhtml->text_buffer, &cur_iter, + &cur_plus_offset_iter, FALSE); + if (strcmp(buffer_text, CRYPTO_SMILEY) == 0) { + gtk_text_buffer_delete(imhtml->text_buffer, &cur_iter, &cur_plus_offset_iter); + gtk_imhtml_insert_smiley_at_iter(imhtml, category, CRYPTO_SMILEY, &cur_iter); + } else { + gtk_text_iter_forward_chars(&cur_iter, 1); + } + cur_plus_offset_iter = cur_iter; + offset_is_ok = gtk_text_iter_forward_chars(&cur_plus_offset_iter, CRYPTO_SMILEY_LEN); + g_free(buffer_text); + } + } +} + +void PE_log_displaying_cb(PidginLogViewer *viewer, PurpleLog *log, gpointer data) { + create_smiley_if_absent( GTK_IMHTML(viewer->imhtml) ); +} + + + +void PE_remove_decorations(PurpleConversation *conv) { + PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); + PidginWindow *win; + TxMenuButtons *tx_menubuttons; + GtkWidget *rx_encrypted_icon; + + if (!gtkconv) return; + + win = pidgin_conv_get_window(gtkconv); + g_return_if_fail(win != NULL); + + tx_menubuttons = g_hash_table_lookup(tx_encrypt_menus, win); + if (tx_menubuttons) { + gtk_widget_destroy(tx_menubuttons->unencrypted); + gtk_widget_destroy(tx_menubuttons->encrypted); + gtk_widget_destroy(tx_menubuttons->capable); + g_hash_table_remove(tx_encrypt_menus, win); + } + + rx_encrypted_icon = g_hash_table_lookup(rx_encrypt_iconlist, win); + if (rx_encrypted_icon) { + gtk_widget_destroy(rx_encrypted_icon); + g_hash_table_remove(rx_encrypt_iconlist, win); + } +} + +void PE_pixmap_init() { + /* Here we make a "stock" icon factory to make our icons, and inform GTK */ + int i; + GdkPixbuf *pixbuf; + GtkIconSet *icon_set; + + static const GtkStockItem items[] = { + { "Pidgin-Encryption_Encrypted", "_GTK!", (GdkModifierType)0, 0, NULL }, + { "Pidgin-Encryption_Unencrypted", "_GTK!", (GdkModifierType)0, 0, NULL }, + { "Pidgin-Encryption_Capable", "_GTK!", (GdkModifierType)0, 0, NULL } + }; + + static struct StockPixmap{ + const char * name; + char ** xpm_data; + } const item_names [] = { + { PIXMAP_TX_ENCRYPTED, icon_out_lock_xpm }, + { PIXMAP_TX_UNENCRYPTED, icon_out_unlock_xpm }, + { PIXMAP_TX_CAPABLE, icon_out_capable_xpm }, + { PIXMAP_RX_ENCRYPTED, icon_in_lock_xpm }, + { PIXMAP_RX_UNENCRYPTED, icon_in_unlock_xpm }, + }; + + GtkIconFactory *factory; + + gtk_stock_add (items, G_N_ELEMENTS (items)); + + factory = gtk_icon_factory_new(); + gtk_icon_factory_add_default(factory); + + for (i = 0; i < G_N_ELEMENTS(item_names); i++) { + pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)item_names[i].xpm_data); + icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); + gtk_icon_factory_add (factory, item_names[i].name, icon_set); + gtk_icon_set_unref (icon_set); + g_object_unref (G_OBJECT (pixbuf)); + } + + g_object_unref(factory); +} + +void PE_error_window(const char* message) { + GtkWidget *dialog, *label, *okay_button; + dialog = gtk_dialog_new(); + label = gtk_label_new(message); + + okay_button = gtk_button_new_with_label(_("Ok")); + gtk_signal_connect_object (GTK_OBJECT (okay_button), "clicked", + GTK_SIGNAL_FUNC (gtk_widget_destroy), dialog); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), + okay_button); + + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), + label); + gtk_widget_show_all (dialog); + +}