Index: FiSH.c
===================================================================
--- FiSH.c	(revision 1)
+++ FiSH.c	(working copy)
@@ -5,7 +5,7 @@
 
 
 // encrypt a message and store in bf_dest (using key for target)
-static int FiSH_encrypt(char *msg_ptr, const char *target, char *bf_dest)
+static int FiSH_encrypt(const SERVER_REC *server, char *msg_ptr, const char *target, char *bf_dest)
 {
 	unsigned char contactName[100]="", theKey[150]="", ini_outgoing[10]="";
 
@@ -32,6 +32,21 @@
 		}
 	}
 
+#if IRSSI_VERSION >= 810
+	// recode message again, last time it was the encrypted message...
+	if(settings_get_bool("recode"))
+	{
+		/* do the recode */
+		char *recoded;
+		recoded = recode_out(SERVER(server), msg_ptr, target);
+		strncpy(msg_ptr, recoded, sizeof(msg_ptr)); 
+		ZeroMemory(recoded, strlen(recoded));
+		g_free(recoded);
+	}
+#else
+		// no support for recode, keep this for backward compability
+#endif
+	
 	encrypt_string(theKey, msg_ptr, bf_dest, strlen(msg_ptr));
 	ZeroMemory(theKey, sizeof(theKey));
 
@@ -41,7 +56,7 @@
 
 
 // decrypt a base64 cipher text (using key for target)
-static int FiSH_decrypt(char *msg_ptr, char *msg_bak, const char *target)
+static int FiSH_decrypt(const SERVER_REC *server, char *msg_ptr, char *msg_bak, const char *target)
 {
 	unsigned char contactName[100], theKey[150]="", bf_dest[1000]="";
 	unsigned char ini_incoming[10]="", myMark[20]="", mark_pos[20]="";
@@ -119,6 +134,22 @@
 		}
 	}
 
+#if IRSSI_VERSION >= 810
+	// recode message again, last time it was the encrypted message...
+	if(settings_get_bool("recode"))
+	{
+		/* do the recode */
+		char *recoded;
+		recoded = recode_in(SERVER(server), bf_dest, target);
+		strncpy(bf_dest, recoded, sizeof(bf_dest)); 
+		ZeroMemory(recoded, strlen(recoded));
+		g_free(recoded);
+	}
+#else
+		// no support for recode, keep this for backward compability
+#endif
+
+			
 	strcpy(msg_bak, bf_dest);	// copy decrypted message back (overwriting the base64 cipher text)
 	ZeroMemory(bf_dest, sizeof(bf_dest));
 
@@ -150,7 +181,7 @@
 	}
 	else strcpy(contactName, nick);
 
-	if(FiSH_decrypt(msg, msg, contactName))
+	if(FiSH_decrypt(server, msg, msg, contactName))
 	{
 		signal_stop();
 		signal_emit(signal_get_emitted(), 5, server, msg_bak, nick, addr, target);
@@ -182,7 +213,7 @@
 		}
 	}
 
-	if(FiSH_encrypt(msg, target, bf_dest)==0)
+	if(FiSH_encrypt(server, msg, target, bf_dest)==0)
 	{	// send plain-text (no key found)
 		irc_send_cmdv(server, "PRIVMSG %s :%s", target, msg);
 		return;
@@ -239,7 +270,7 @@
 	if(*target=='#' || *target=='&') contactPtr=target;
 	else contactPtr=nick;
 
-	if(FiSH_decrypt(msg, msg, contactPtr))
+	if(FiSH_decrypt(server, msg, msg, contactPtr))
 	{
 		signal_stop();
 		signal_emit(signal_get_emitted(), 5, server, msg, nick, address, target);
@@ -250,7 +281,7 @@
 
 static void decrypt_action(SERVER_REC *server, char *msg, char *nick, char *address, char *target)
 {
-	if(FiSH_decrypt(msg, msg, target))
+	if(FiSH_decrypt(server, msg, msg, target))
 	{
 		signal_stop();
 		signal_emit(signal_get_emitted(), 5, server, msg, nick, address, target);
@@ -261,7 +292,7 @@
 
 static void decrypt_topic(SERVER_REC *server, char *channel, char *topic, char *nick, char *address)
 {
-	if(FiSH_decrypt(topic, topic, channel))
+	if(FiSH_decrypt(server, topic, topic, channel))
 	{
 		signal_stop();
 		signal_emit(signal_get_emitted(), 5, server, channel, topic, nick, address);
@@ -272,7 +303,7 @@
 
 static void topic_changed(CHANNEL_REC *chan_rec)
 {
-	FiSH_decrypt(chan_rec->topic, chan_rec->topic, chan_rec->name);
+	FiSH_decrypt(NULL, chan_rec->topic, chan_rec->topic, chan_rec->name);
 }
 
 
@@ -307,7 +338,7 @@
 	if(ptr==NULL) return;
 	ptr++;
 
-	FiSH_decrypt(ptr, ptr, channel);
+	FiSH_decrypt(server, ptr, ptr, channel);
 }
 
 
@@ -332,7 +363,7 @@
 		goto notice_error;
 	}
 
-	if(FiSH_encrypt(msg, target, bf_dest)==0)
+	if(FiSH_encrypt(server, msg, target, bf_dest)==0)
 	{
 		printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /notice+ error: Encryption disabled or no key found for %s.", target);
 		goto notice_error;
@@ -378,7 +409,7 @@
 	}
 
 	// encrypt a message (using key for target)
-	if(FiSH_encrypt((char *)data, target, bf_dest)==0)
+	if(FiSH_encrypt(server, (char *)data, target, bf_dest)==0)
 	{
 		printtext(server, target, MSGLEVEL_CRAP, "\002FiSH:\002 /topic+ error: Encryption disabled or no key found for %s.", target);
 		goto topic_error;
Index: module.h
===================================================================
--- module.h	(revision 1)
+++ module.h	(working copy)
@@ -9,6 +9,9 @@
 #include "channels.h"
 #include "window-items.h"
 
+#if IRSSI_VERSION >= 810
+#include "recode.h"
+#endif
 
 #define MODULE_NAME "fish"
 
Index: Makefile
===================================================================
--- Makefile	(revision 1)
+++ Makefile	(working copy)
@@ -2,6 +2,9 @@
 glib_dir = $(HOME)/glib-1.2.10
 irssi_dir = $(HOME)/irssi-0.8.9
 
+
+irssi_version = $(shell awk -F '[=.-]' '{if($$0 ~ "^ VERSION=") print $$3$$4}' $(irssi_dir)/configure )
+
 all:	note
 
 	@make misc
@@ -86,7 +89,7 @@
 
 
 FiSH:
-	gcc -I. -I$(glib_dir) -I$(glib_dir)/include -I$(glib_dir)/glib -I$(irssi_dir) -I$(irssi_dir)/src -I$(irssi_dir)/src/core -I$(irssi_dir)/src/fe-common/core -static -O2 -Wall -c FiSH.c -fPIC -DPIC -o FiSH.o
+	gcc -I. -I$(glib_dir) -I$(glib_dir)/include -I$(glib_dir)/glib -I$(irssi_dir) -I$(irssi_dir)/src -I$(irssi_dir)/src/core -I$(irssi_dir)/src/fe-common/core -static -O2 -Wall -c FiSH.c -fPIC -DPIC -o FiSH.o -DIRSSI_VERSION=$(irssi_version)
 	gcc -static -shared FiSH.o SHA-256.o base64.o blowfish.o cfgopts.o DH1080.o miracl.a -o libfish.so
 
 

