[Pkg-privacy-commits] [irssi-plugin-otr] 40/267: Abstraction from irssi and generic cmd handler.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.

commit e8f608daff33118cca040b1ff7b8d13bbbc6ecbb
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Fri Jan 23 20:39:03 2009 +0100

    Abstraction from irssi and generic cmd handler.
---
 CMakeLists.txt          | 103 ++++++++++++++++-------------
 Packaging-DEB.cmake     |   2 +-
 Packaging-RPM.cmake     |   2 +-
 Packaging.cmake         |   2 +-
 otr.c => irssi_otr.c    | 172 +++++++++++++++++++++++++++++++-----------------
 irssi_otr.h             |  37 +++++++++++
 otr.h                   |  90 ++++++++++---------------
 otr_ops.c               |  30 ++++-----
 otrutil.c => otr_util.c | 153 +++++++++++++++++++-----------------------
 ui.c                    |  49 --------------
 10 files changed, 329 insertions(+), 311 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 24e9451..2064f95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,6 +98,14 @@ ENDIF (LIBOTR_VERSION LESS "3.1.0")
 
 FIND_PACKAGE(LibGcrypt REQUIRED)
 
+# includes
+
+SET(IRSSIOTR_INCLUDE_DIRS
+  ${PROJECT_SOURCE_DIR} 
+  ${PROJECT_BINARY_DIR} 
+  ${GLIB_INCLUDE_DIRS} 
+  ${LIBOTR_INCLUDE_DIRS})
+
 # irssi public headers
 
 FIND_PATH(IRSSI_INCLUDE_DIR NAMES irssi/src/core/module.h)
@@ -106,20 +114,40 @@ MARK_AS_ADVANCED(IRSSI_INCLUDE_DIR)
 IF(NOT IRSSI_INCLUDE_DIR)
   MESSAGE(FATAL_ERROR "Couldn't find irssi headers, "
     "usually installed in /usr/include/irssi")
-ENDIF(NOT IRSSI_INCLUDE_DIR)
+ELSE(NOT IRSSI_INCLUDE_DIR)
+  SET(HAVE_IRSSI 1)
+  SET(IRSSIOTR_INCLUDE_DIRS
+    ${IRSSIOTR_INCLUDE_DIRS}
+    ${IRSSI_INCLUDE_DIR}/irssi
+    ${IRSSI_INCLUDE_DIR}/irssi/src
+    ${IRSSI_INCLUDE_DIR}/irssi/src/core
+    ${PROJECT_BINARY_DIR}/irssi-headers
+    ${PROJECT_SOURCE_DIR}/irssi-headers)
+
+  # irssi statusbar header
+
+  CHECK_INCLUDE_FILES("glib.h;common.h;fe-text/statusbar-item.h" HAVE_IRSSISBAR_H)
+
+  # Bad hack
+
+  IF (NOT HAVE_IRSSISBAR_H)
+    MESSAGE(STATUS "Need to fetch irssi header statusbar-item.h (you don't have it yet)")
+    IF (NOT WGET_EXECUTABLE)
+      FIND_PACKAGE(Wget REQUIRED)
+    ENDIF (NOT WGET_EXECUTABLE)
+    EXECUTE_PROCESS(COMMAND "mkdir" -p irssi-headers/fe-text)
+    EXECUTE_PROCESS(COMMAND "bash" "-c"
+      "${WGET_EXECUTABLE} '--post-data=revision=4936&root=irssi' \\
+      'http://svn.irssi.org/cgi-bin/viewvc.cgi/irssi/trunk/src/fe-text/statusbar-item.h' || exit 1"
+      ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY irssi-headers/fe-text
+      RESULT_VARIABLE IISBAR_RET)
+    IF(NOT IISBAR_RET EQUAL 0)
+      MESSAGE(FATAL_ERROR "Couldn't check out irssi headers from SVN")
+    ENDIF(NOT IISBAR_RET EQUAL 0)
+    SET(HAVE_IRSSISBAR_H 1 CACHE INTERNAL "Having irssi headers" FORCE)
+  ENDIF (NOT HAVE_IRSSISBAR_H)
 
-# includes
-
-SET(IRSSIOTR_INCLUDE_DIRS
-  ${PROJECT_SOURCE_DIR} 
-  ${PROJECT_BINARY_DIR} 
-  ${GLIB_INCLUDE_DIRS} 
-  ${LIBOTR_INCLUDE_DIRS} 
-  ${IRSSI_INCLUDE_DIR}/irssi
-  ${IRSSI_INCLUDE_DIR}/irssi/src
-  ${IRSSI_INCLUDE_DIR}/irssi/src/core
-  ${PROJECT_BINARY_DIR}/irssi-headers
-  ${PROJECT_SOURCE_DIR}/irssi-headers)
+ENDIF(NOT IRSSI_INCLUDE_DIR)
 
 include_directories(${IRSSIOTR_INCLUDE_DIRS})
 SET(CMAKE_REQUIRED_INCLUDES ${IRSSIOTR_INCLUDE_DIRS})
@@ -131,29 +159,6 @@ SET(CMAKE_REQUIRED_DEFINITIONS -DHAVE_CONFIG_H ${LIBGCRYPT_CFLAGS})
 
 CHECK_INCLUDE_FILE(glib/gregex.h HAVE_GREGEX_H)
 
-# irssi headers
-
-CHECK_INCLUDE_FILES("glib.h;common.h;fe-text/statusbar-item.h" HAVE_IRSSISBAR_H)
-
-# Bad hack
-
-IF (NOT HAVE_IRSSISBAR_H)
-  MESSAGE(STATUS "Need to fetch irssi header statusbar-item.h (you don't have it yet)")
-  IF (NOT WGET_EXECUTABLE)
-    FIND_PACKAGE(Wget REQUIRED)
-  ENDIF (NOT WGET_EXECUTABLE)
-  EXECUTE_PROCESS(COMMAND "mkdir" -p irssi-headers/fe-text)
-  EXECUTE_PROCESS(COMMAND "bash" "-c"
-    "${WGET_EXECUTABLE} '--post-data=revision=4936&root=irssi' \\
-    'http://svn.irssi.org/cgi-bin/viewvc.cgi/irssi/trunk/src/fe-text/statusbar-item.h' || exit 1"
-    ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY irssi-headers/fe-text
-    RESULT_VARIABLE IISBAR_RET)
-  IF(NOT IISBAR_RET EQUAL 0)
-    MESSAGE(FATAL_ERROR "Couldn't check out irssi headers from SVN")
-  ENDIF(NOT IISBAR_RET EQUAL 0)
-  SET(HAVE_IRSSISBAR_H 1 CACHE INTERNAL "Having irssi headers" FORCE)
-ENDIF (NOT HAVE_IRSSISBAR_H)
-
 # check for strsignal
 
 CHECK_FUNCTION_EXISTS(strsignal HAVE_STRSIGNAL)
@@ -192,23 +197,27 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/otr-formats.c
 
 # lib
 
-ADD_LIBRARY(otr SHARED otr.c otrutil.c otr_ops.c otr_key.c ui.c ${PROJECT_BINARY_DIR}/otr-formats.c)
-
-TARGET_LINK_LIBRARIES(otr ${GLIB_LIBRARIES} ${LIBOTR_LIBRARIES})
-
 # Now that took some time to figure out...
 
 IF(APPLE)
   SET(APPLE_LDFLAGS "-single_module -undefined dynamic_lookup")
-  SET_TARGET_PROPERTIES(otr PROPERTIES SUFFIX ".so")
 ENDIF(APPLE)
 
 FOREACH(X ${LIBGCRYPT_LDFLAGS} ${GLIB_LDFLAGS} ${APPLE_LDFLAGS})
   SET(MAIN_LDFLAGS "${MAIN_LDFLAGS} ${X}")
 ENDFOREACH(X ${LIBGCRYPT_LDFLAGS} ${GLIB_LDFLAGS} ${APPLE_LDFLAGS})
 
-SET_TARGET_PROPERTIES(otr PROPERTIES 
-  LINK_FLAGS "${MAIN_LDFLAGS}")
+IF(HAVE_IRSSI)
+  ADD_LIBRARY(irssiotr SHARED irssi_otr.c otr_util.c otr_ops.c otr_key.c ${PROJECT_BINARY_DIR}/otr-formats.c)
+  TARGET_LINK_LIBRARIES(irssiotr ${GLIB_LIBRARIES} ${LIBOTR_LIBRARIES})
+  SET_TARGET_PROPERTIES(irssiotr PROPERTIES 
+    COMPILE_FLAGS -DTARGET_IRSSI
+    OUTPUT_NAME "otr"
+    LINK_FLAGS "${MAIN_LDFLAGS}")
+  IF(APPLE)
+    SET_TARGET_PROPERTIES(irssiotr PROPERTIES SUFFIX ".so")
+  ENDIF(APPLE)
+ENDIF(HAVE_IRSSI)
 
 # cscope
 
@@ -220,13 +229,13 @@ ADD_CSCOPE_TARGET("${CSANDHS}" "${IRSSIOTR_INCLUDE_DIRS}")
 IF(CMAKE_INSTALL_TYPE MATCHES "package-.*")
   INCLUDE(Packaging.cmake)
 ELSEIF(CMAKE_INSTALL_TYPE MATCHES "home")
-  INSTALL(TARGETS otr DESTINATION "$ENV{HOME}/.irssi/modules")
+  INSTALL(TARGETS irssiotr DESTINATION "$ENV{HOME}/.irssi/modules")
 ELSE(CMAKE_INSTALL_TYPE MATCHES "package-.*")
-  INSTALL(TARGETS otr DESTINATION lib${LIB_SUFFIX}/irssi/modules)
+  INSTALL(TARGETS irssiotr DESTINATION lib${LIB_SUFFIX}/irssi/modules)
   INSTALL(FILES README LICENSE DESTINATION ${DOCDIR})
 ENDIF(CMAKE_INSTALL_TYPE MATCHES "package-.*")
 
 # Source tarball
 ADD_CUSTOM_TARGET(src-tarball 
-  ${PROJECT_SOURCE_DIR}/mksrcpackage.sh ${PROJECT_SOURCE_DIR} ${IRSSIOTR_VERSION}
-  DEPENDS otr)
+  ${PROJECT_SOURCE_DIR}/mksrcpackage.sh ${PROJECT_SOURCE_DIR} 
+  ${IRSSIOTR_VERSION})
diff --git a/Packaging-DEB.cmake b/Packaging-DEB.cmake
index c06b166..88cd52f 100644
--- a/Packaging-DEB.cmake
+++ b/Packaging-DEB.cmake
@@ -1,4 +1,4 @@
-INSTALL(TARGETS otr DESTINATION lib${LIB_SUFFIX}/irssi/modules)
+INSTALL(TARGETS irssiotr DESTINATION lib${LIB_SUFFIX}/irssi/modules)
 INSTALL(FILES README LICENSE DESTINATION ${DOCDIR})
 
 SET(CPACK_GENERATOR DEB)
diff --git a/Packaging-RPM.cmake b/Packaging-RPM.cmake
index 46d8e0c..d560e81 100644
--- a/Packaging-RPM.cmake
+++ b/Packaging-RPM.cmake
@@ -1,4 +1,4 @@
-INSTALL(TARGETS otr DESTINATION lib${LIB_SUFFIX}/irssi/modules)
+INSTALL(TARGETS irssiotr DESTINATION lib${LIB_SUFFIX}/irssi/modules)
 INSTALL(FILES README DESTINATION ${DOCDIR})
 
 SET(CPACK_GENERATOR RPM)
diff --git a/Packaging.cmake b/Packaging.cmake
index b572b16..3dfea56 100644
--- a/Packaging.cmake
+++ b/Packaging.cmake
@@ -21,7 +21,7 @@ ELSEIF(CMAKE_INSTALL_TYPE STREQUAL "package-deb")
   CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
   INCLUDE(Packaging-DEB.cmake)
 ELSEIF(CMAKE_INSTALL_TYPE STREQUAL "package-tgz")
-  INSTALL(TARGETS otr DESTINATION irssi/lib/modules)
+  INSTALL(TARGETS irssiotr DESTINATION irssi/lib/modules)
   INSTALL(FILES README LICENSE DESTINATION ${DOCDIR})
 ELSE(CMAKE_INSTALL_TYPE STREQUAL "package-rpm")
   MESSAGE(FATAL_ERROR "Unknown build type '${CMAKE_INSTALL_TYPE}'")
diff --git a/otr.c b/irssi_otr.c
similarity index 72%
rename from otr.c
rename to irssi_otr.c
index f824763..2ef0cef 100644
--- a/otr.c
+++ b/irssi_otr.c
@@ -25,6 +25,11 @@ int debug = FALSE;
 GRegex *regex_nickignore = NULL;
 #endif
 
+void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg) {
+	ircctx->send_message(
+		ircctx,recipient,msg,GPOINTER_TO_INT(SEND_TARGET_NICK));
+}
+
 /*
  * Pipes all outgoing private messages through OTR
  */
@@ -90,21 +95,67 @@ static void cmd_otr(const char *data,void *server,WI_ITEM_REC *item)
 	}
 }
 
+/* used to handle a bunch of commands */
+static void cmd_generic(const char *cmd, const char *args, WI_ITEM_REC *item)
+{
+	QUERY_REC *query = QUERY(item);
+
+	if (*args == '\0')
+		args = NULL;
+
+	if (!(query&&query->server&&query->server->connrec))
+		query = NULL;
+
+	if (strcmp(cmd,"finish")==0) {
+		if (args) {
+			otr_finish(NULL,NULL,args,TRUE);
+			statusbar_items_redraw("otr");
+		} else if (query) {
+			otr_finish(query->server,query->name,NULL,TRUE);
+			statusbar_items_redraw("otr");
+		} else
+			otr_noticest(TXT_CMD_QNOTFOUND);
+	} else if (strcmp(cmd,"trust")==0) {
+		if (args) {
+			otr_trust(NULL,NULL,args);
+			statusbar_items_redraw("otr");
+		} else if (query) {
+			otr_trust(query->server,query->name,NULL);
+			statusbar_items_redraw("otr");
+		} else
+			otr_noticest(TXT_CMD_QNOTFOUND);
+	} else if (strcmp(cmd,"authabort")==0) {
+		if (args) {
+			otr_authabort(NULL,NULL,args);
+			statusbar_items_redraw("otr");
+		} else if (query) {
+			otr_authabort(query->server,query->name,NULL);
+			statusbar_items_redraw("otr");
+		} else
+			otr_noticest(TXT_CMD_QNOTFOUND);
+	} else if (strcmp(cmd,"auth")==0) {
+		if (!args) {
+			otr_notice(query->server,query->name,
+				   TXT_CMD_AUTH);
+		} else {
+			char *second = strchr(args,' ');
+			char *add = strchr(args,'@');
+			if (add&&second&&(add<second)) {
+				*(second+1) = '\0';
+				otr_auth(NULL,NULL,args,second);
+				*second = ' ';
+			} else
+				otr_auth(query->server,query->name,NULL,args);
+		}
+	}
+}
+
 /*
  * /otr finish [peername]
  */
 static void cmd_finish(const char *data, void *server, WI_ITEM_REC *item)
 {
-	QUERY_REC *query = QUERY(item);
-	if (*data != '\0') {
-		otr_finish(NULL,NULL,data,TRUE);
-		statusbar_items_redraw("otr");
-	} else if (query&&query->server&&query->server->connrec) {
-		otr_finish(query->server,query->name,NULL,TRUE);
-		statusbar_items_redraw("otr");
-	} else
-		otr_notice(item ? item->server : NULL,query ? query->name : NULL,
-			   TXT_CMD_QNOTFOUND);
+	cmd_generic("finish",data,item);
 }
 
 /*
@@ -112,16 +163,7 @@ static void cmd_finish(const char *data, void *server, WI_ITEM_REC *item)
  */
 static void cmd_trust(const char *data, void *server, WI_ITEM_REC *item)
 {
-	QUERY_REC *query = QUERY(item);
-	if (*data != '\0') {
-		otr_trust(NULL,NULL,data);
-		statusbar_items_redraw("otr");
-	} else if (query&&query->server&&query->server->connrec) {
-		otr_trust(query->server,query->name,NULL);
-		statusbar_items_redraw("otr");
-	} else
-		otr_notice(item->server,query ? query->name : NULL,
-			   TXT_CMD_QNOTFOUND);
+	cmd_generic("trust",data,item);
 }
 
 /*
@@ -142,32 +184,7 @@ static void cmd_genkey(const char *data, void *server, WI_ITEM_REC *item)
  */
 static void cmd_auth(const char *data, void *server, WI_ITEM_REC *item)
 {
-	WI_ITEM_REC *wi = active_win->active;
-	QUERY_REC *query = QUERY(wi);
-	char *secret;
-
-	if ((secret = strchr(data,' '))) {
-		*secret = '\0';
-		if (!strchr(data,'@')) {
-			/* it's not an account name after all */
-			*secret = ' ';
-			secret = NULL;
-		} else
-			secret++;
-	}
-
-	if (secret) {
-		otr_auth(NULL,NULL,data,secret);
-		*(secret-1) = ' ';
-	} else if (query&&query->server&&query->server->connrec) {
-		if (!data||(*data=='\0')) {
-			otr_notice(server,query->name,
-				   TXT_CMD_AUTH);
-			return;
-		}
-		otr_auth(query->server,query->name,NULL,data);
-	}
-
+	cmd_generic("auth",data,item);
 }
 
 /*
@@ -175,16 +192,7 @@ static void cmd_auth(const char *data, void *server, WI_ITEM_REC *item)
  */
 static void cmd_authabort(const char *data, void *server, WI_ITEM_REC *item)
 {
-	WI_ITEM_REC *wi = active_win->active;
-	QUERY_REC *query = QUERY(wi);
-
-	if (*data != '\0') {
-		otr_authabort(NULL,NULL,data);
-		statusbar_items_redraw("otr");
-	} else if (query&&query->server&&query->server->connrec) {
-		otr_authabort(query->server,query->name,NULL);
-		statusbar_items_redraw("otr");
-	}
+	cmd_generic("authabort",data,item);
 }
 
 /*
@@ -307,9 +315,9 @@ void otr_init(void)
 	command_bind("otr contexts", NULL, (SIGNAL_FUNC) cmd_contexts);
 	command_bind("otr version", NULL, (SIGNAL_FUNC) cmd_version);
 
-	settings_add_str("otr", "otr_policy","*@localhost opportunistic,*bitlbee* opportunistic,*@im.* opportunistic");
-	settings_add_str("otr", "otr_policy_known","* always");
-	settings_add_str("otr", "otr_ignore","xmlconsole[0-9]*");
+	settings_add_str("otr", "otr_policy",IO_DEFAULT_POLICY);
+	settings_add_str("otr", "otr_policy_known",IO_DEFAULT_POLICY_KNOWN);
+	settings_add_str("otr", "otr_ignore",IO_DEFAULT_IGNORE);
 	read_settings();
 	signal_add("setup changed", (SIGNAL_FUNC) read_settings);
 
@@ -351,3 +359,49 @@ void otr_deinit(void)
 
 	theme_unregister();
 }
+
+IRC_CTX *server_find_address(char *address)
+{
+        GSList *tmp;
+
+        g_return_val_if_fail(address != NULL, NULL);
+        if (*address == '\0') return NULL;
+
+        for (tmp = servers; tmp != NULL; tmp = tmp->next) {
+                SERVER_REC *server = tmp->data;
+
+                if (g_strcasecmp(server->connrec->address, address) == 0)
+                        return server;
+        }
+
+        return NULL;
+}
+
+char *lvlstring[] = { 
+	"NOTICE",
+	"DEBUG"
+};
+
+
+void otr_log(IRC_CTX *server, const char *nick, 
+	     int level, const char *format, ...) {
+	va_list params;
+	va_start( params, format );
+	char msg[LOGMAX], *s = msg;
+
+	if ((level==LVL_DEBUG)&&!debug)
+		return;
+
+	s += sprintf(s,"%s","%9OTR%9");
+
+	if (level!=LVL_NOTICE)	
+		s += sprintf(s,"(%s)",lvlstring[level]);
+
+	s += sprintf(s,": ");
+
+	if( vsnprintf( s, LOGMAX, format, params ) < 0 )
+		sprintf( s, "internal error parsing error string (BUG)" );
+	va_end( params );
+
+	printtext(server, nick, MSGLEVEL_MSGS, msg);
+}
diff --git a/irssi_otr.h b/irssi_otr.h
new file mode 100644
index 0000000..e3c85e1
--- /dev/null
+++ b/irssi_otr.h
@@ -0,0 +1,37 @@
+#include <common.h>
+#include <core/commands.h>
+#include <core/modules.h>
+#include <core/servers.h>
+#include <core/signals.h>
+#include <core/levels.h>
+#include <core/queries.h>
+#include <fe-common/core/printtext.h>
+#include <fe-common/core/fe-windows.h>
+#include <fe-common/core/module-formats.h>
+#include <core/modules.h>
+#include <core/settings.h>
+
+#include <fe-text/statusbar-item.h>
+
+#define IRC_CTX SERVER_REC
+
+/* no need for duplication */
+#define IRCCTX_DUP(ircctx) ircctx
+#define IRCCTX_ADDR(ircctx) ircctx->connrec->address
+#define IRCCTX_NICK(ircctx) ircctx->nick
+
+#define otr_noticest(formatnum,...) \
+	printformat(NULL,NULL,MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__)
+
+#define otr_notice(ircctx,nick,formatnum,...) \
+		printformat(ircctx,nick,MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__);
+
+#define otr_infost(formatnum,...) \
+	printformat(NULL,NULL,MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__)
+
+#define otr_info(server,nick,formatnum,...) \
+	printformat(ircctx,nick,MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__)
+
+#define otr_debug(ircctx,nick,formatnum,...) { \
+	if (debug) \
+		printformat(ircctx,nick,MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__); }
diff --git a/otr.h b/otr.h
index c9ff3e1..60bbca8 100644
--- a/otr.h
+++ b/otr.h
@@ -18,6 +18,8 @@
  */
 
 #include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
 
 /* OTR */
 
@@ -26,29 +28,31 @@
 #include <libotr/message.h>
 #include <libotr/privkey.h>
 
-/* irssi */
-
-#include <common.h>
-#include <core/commands.h>
-#include <core/modules.h>
-#include <core/servers.h>
-#include <core/signals.h>
-#include <core/levels.h>
-#include <core/queries.h>
-#include <fe-common/core/printtext.h>
-#include <fe-common/core/fe-windows.h>
-#include <fe-common/core/module-formats.h>
-#include <core/modules.h>
-#include <core/settings.h>
-
-#include <fe-text/statusbar-item.h>
-
 /* glib */
 
 #include <glib.h>
 #include <glib/gprintf.h>
 #include <glib/gstdio.h>
 
+/* irssi */
+
+#ifdef TARGET_IRSSI
+#include <irssi_otr.h>
+#endif
+
+/* log stuff */
+
+#define LOGMAX 1024
+
+#define LVL_NOTICE  0
+#define LVL_DEBUG   1
+
+#define otr_logst(level,format,...) \
+	otr_log(NULL,NULL,level,format, ## __VA_ARGS__)
+
+void otr_log(IRC_CTX *server, const char *to, 
+	     int level, const char *format, ...);
+
 /* own */
 
 #include "io-config.h"
@@ -70,11 +74,16 @@
 #define TMPKEYFILE "/otr/otr.key.tmp"
 #define FPSFILE    "/otr/otr.fp"
 
+/* some defaults */
+#define IO_DEFAULT_POLICY "*@localhost opportunistic,*bitlbee* opportunistic,*@im.* opportunistic, *serv at irc.* never"
+#define IO_DEFAULT_POLICY_KNOWN "* always"
+#define IO_DEFAULT_IGNORE "xmlconsole[0-9]*"
+
 /* one for each OTR context (=communication pair) */
 struct co_info {
 	char *msgqueue;			/* holds partially reconstructed base64
 					   messages */
-	SERVER_REC *server;		/* irssi server object for this peer */
+	IRC_CTX *ircctx;		/* irssi server object for this peer */
 	int received_smp_init;		/* received SMP init msg */
 	int smp_failed;			/* last SMP failed */
 	char better_msg_two[256];	/* what the second line of the "better"
@@ -109,6 +118,9 @@ struct plistentry {
 /* used by the logging functions below */
 extern int debug;
 
+void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg);
+IRC_CTX *server_find_address(char *address);
+
 /* init stuff */
 
 int otrlib_init();
@@ -118,17 +130,17 @@ void otr_setpolicies(const char *policies, int known);
 
 /* basic send/receive/status stuff */
 
-char *otr_send(SERVER_REC *server,const char *msg,const char *to);
-char *otr_receive(SERVER_REC *server,const char *msg,const char *from);
+char *otr_send(IRC_CTX *server,const char *msg,const char *to);
+char *otr_receive(IRC_CTX *server,const char *msg,const char *from);
 int otr_getstatus(char *mynick, char *nick, char *server);
 ConnContext *otr_getcontext(const char *accname,const char *nick,int create,void *data);
 
 /* user interaction */
 
-void otr_trust(SERVER_REC *server, char *nick, const char *peername);
-void otr_finish(SERVER_REC *server, char *nick, const char *peername, int inquery);
-void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *secret);
-void otr_authabort(SERVER_REC *server, char *nick, const char *peername);
+void otr_trust(IRC_CTX *server, char *nick, const char *peername);
+void otr_finish(IRC_CTX *server, char *nick, const char *peername, int inquery);
+void otr_auth(IRC_CTX *server, char *nick, const char *peername, const char *secret);
+void otr_authabort(IRC_CTX *server, char *nick, const char *peername);
 struct ctxlist_ *otr_contexts();
 
 
@@ -140,33 +152,3 @@ void key_load();
 void fps_load();
 void otr_writefps();
 
-/* log stuff */
-
-#define LOGMAX 1024
-
-#define LVL_NOTICE  0
-#define LVL_DEBUG   1
-
-#define otr_logst(level,format,...) \
-	otr_log(NULL,NULL,level,format, ## __VA_ARGS__)
-
-#define otr_noticest(formatnum,...) \
-	printformat(NULL,NULL,MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__)
-
-#define otr_notice(server,nick,formatnum,...) \
-	printformat(server,nick,MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__)
-
-#define otr_infost(formatnum,...) \
-	printformat(NULL,NULL,MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__)
-
-#define otr_info(server,nick,formatnum,...) \
-	printformat(server,nick,MSGLEVEL_CRAP, formatnum, ## __VA_ARGS__)
-
-#define otr_debug(server,nick,formatnum,...) { \
-	if (debug) \
-		printformat(server,nick, \
-			    MSGLEVEL_MSGS, formatnum, ## __VA_ARGS__); \
-}
-
-void otr_log(SERVER_REC *server, const char *to, 
-	     int level, const char *format, ...);
diff --git a/otr_ops.c b/otr_ops.c
index bd16486..38bab3f 100644
--- a/otr_ops.c
+++ b/otr_ops.c
@@ -23,7 +23,7 @@ OtrlMessageAppOps otr_ops;
 extern OtrlUserState otr_state;
 extern GSList *plistunknown,*plistknown;
 
-OtrlPolicy IO_DEFAULT_POLICY =
+OtrlPolicy IO_DEFAULT_OTR_POLICY =
 	OTRL_POLICY_MANUAL|OTRL_POLICY_WHITESPACE_START_AKE;
 
 /*
@@ -33,7 +33,7 @@ OtrlPolicy ops_policy(void *opdata, ConnContext *context)
 {
 	struct co_info *coi = context->app_data;
 	char *server = strchr(context->accountname,'@')+1;
-	OtrlPolicy op = IO_DEFAULT_POLICY;
+	OtrlPolicy op = IO_DEFAULT_OTR_POLICY;
 	GSList *pl;
 	char fullname[1024];
 
@@ -93,19 +93,19 @@ void ops_create_privkey(void *opdata, const char *accountname,
 void ops_inject_msg(void *opdata, const char *accountname,
 		    const char *protocol, const char *recipient, const char *message)
 {
-	SERVER_REC *a_serv;
+	IRC_CTX *a_serv;
 	char *msgcopy = g_strdup(message);
 
 	/* OTR sometimes gives us multiple lines 
 	 * (e.g. the default query (a.k.a. "better") message) */
 	g_strdelimit (msgcopy,"\n",' ');
 	a_serv = opdata;
-	if (!a_serv)
+	if (!a_serv) {
 		otr_notice(a_serv,recipient,TXT_OPS_INJECT,
 			   accountname,recipient,message);
-	else
-		a_serv->send_message(a_serv, recipient, msgcopy,
-				     GPOINTER_TO_INT(SEND_TARGET_NICK));
+	} else {
+		irc_send_message(a_serv, recipient, msgcopy);
+	}
 	g_free(msgcopy);
 }
 
@@ -118,11 +118,11 @@ void ops_notify(void *opdata, OtrlNotifyLevel level, const char *accountname,
 		const char *secondary)
 {
 	ConnContext *co = otr_getcontext(accountname,username,FALSE,NULL);
-	SERVER_REC *server = opdata;
+	IRC_CTX *server = opdata;
 	struct co_info *coi;
 	if (co) {
 		coi = co->app_data;
-		server = coi->server;
+		server = coi->ircctx;
 	} else 
 		otr_notice(server,username,TXT_OPS_NOTIFY_BUG);
 
@@ -160,12 +160,12 @@ int ops_display_msg(void *opdata, const char *accountname,
 		    const char *msg)
 {
 	ConnContext *co = otr_getcontext(accountname,username,FALSE,opdata);
-	SERVER_REC *server = opdata;
+	IRC_CTX *server = opdata;
 	struct co_info *coi;
 
 	if (co) {
 		coi = co->app_data;
-		server = coi->server;
+		server = coi->ircctx;
 	} else 
 		otr_notice(server,username,TXT_OPS_DISPLAY_BUG);
 
@@ -189,7 +189,7 @@ void ops_secure(void *opdata, ConnContext *context)
 	char * trust = context->active_fingerprint->trust ? : "";
 	char ownfp[45],peerfp[45];
 
-	otr_notice(coi->server,
+	otr_notice(coi->ircctx,
 		   context->username,TXT_OPS_SEC);
 	if (*trust!='\0')
 		return;
@@ -200,7 +200,7 @@ void ops_secure(void *opdata, ConnContext *context)
 	otrl_privkey_hash_to_human(peerfp,
 				   context->active_fingerprint->fingerprint);
 
-	otr_notice(coi->server,context->username,TXT_OPS_FPCOMP,
+	otr_notice(coi->ircctx,context->username,TXT_OPS_FPCOMP,
 		   otrl_privkey_fingerprint(otr_state,
 					    ownfp,
 					    context->accountname,
@@ -215,7 +215,7 @@ void ops_secure(void *opdata, ConnContext *context)
 void ops_insecure(void *opdata, ConnContext *context)
 {
 	struct co_info *coi = context->app_data;
-	otr_notice(coi->server,
+	otr_notice(coi->ircctx,
 		   context->username,TXT_OPS_INSEC);
 }
 
@@ -225,7 +225,7 @@ void ops_insecure(void *opdata, ConnContext *context)
 void ops_still_secure(void *opdata, ConnContext *context, int is_reply)
 {
 	struct co_info *coi = context->app_data;
-	otr_notice(coi->server,
+	otr_notice(coi->ircctx,
 		   context->username,is_reply ?
 		   TXT_OPS_STILL_REPLY :
 		   TXT_OPS_STILL_NO_REPLY);
diff --git a/otrutil.c b/otr_util.c
similarity index 81%
rename from otrutil.c
rename to otr_util.c
index ecf1f58..75ae683 100644
--- a/otrutil.c
+++ b/otr_util.c
@@ -92,6 +92,8 @@ void context_free_app_info(void *data)
 	if (coi->msgqueue) {
 		g_free(coi->msgqueue);
 	}
+	if (coi->ircctx)
+		g_free(coi->ircctx);
 }
 
 /*
@@ -100,14 +102,14 @@ void context_free_app_info(void *data)
  */
 void context_add_app_info(void *data,ConnContext *co)
 {
-	SERVER_REC *server = data;
+	IRC_CTX *ircctx = IRCCTX_DUP(data);
 	struct co_info *coi = g_malloc(sizeof(struct co_info));
 
 	memset(coi,0,sizeof(struct co_info));
 	co->app_data = coi;
 	co->app_data_free = context_free_app_info;
 
-	coi->server = server;
+	coi->ircctx = ircctx;
 	sprintf(coi->better_msg_two,formats[TXT_OTR_BETTER_TWO].def,co->accountname);
 }
 
@@ -139,10 +141,10 @@ ConnContext *otr_getcontext(const char *accname,const char *nick,
  * Returns NULL if OTR handled the message and 
  * the original message otherwise.
  */
-char *otr_send(SERVER_REC *server, const char *msg,const char *to)
+char *otr_send(IRC_CTX *ircctx, const char *msg,const char *to)
 {
-	const char *nick = server->nick;
-	const char *address = server->connrec->address;
+	const char *nick = IRCCTX_NICK(ircctx);
+	const char *address = IRCCTX_ADDR(ircctx);
 	gcry_error_t err;
 	char *newmessage = NULL;
 	ConnContext *co;
@@ -153,7 +155,7 @@ char *otr_send(SERVER_REC *server, const char *msg,const char *to)
 	err = otrl_message_sending(
 		otr_state, 
 		&otr_ops, 
-		server, 
+		ircctx, 
 		accname,
 		PROTOCOLID, 
 		to, 
@@ -161,10 +163,10 @@ char *otr_send(SERVER_REC *server, const char *msg,const char *to)
 		NULL, 
 		&newmessage, 
 		context_add_app_info, 
-		server);
+		ircctx);
 
 	if (err != 0) {
-		otr_notice(server,to,TXT_SEND_FAILED,msg);
+		otr_notice(ircctx,to,TXT_SEND_FAILED,msg);
 		return NULL;
 	}
 
@@ -173,23 +175,23 @@ char *otr_send(SERVER_REC *server, const char *msg,const char *to)
 
 	/* OTR message. Need to do fragmentation */
 
-	if (!(co = otr_getcontext(accname,to,FALSE,server))) {
-		otr_notice(server,to,TXT_SEND_CHANGE);
+	if (!(co = otr_getcontext(accname,to,FALSE,ircctx))) {
+		otr_notice(ircctx,to,TXT_SEND_CHANGE);
 		return NULL;
 	}
 
 	err = otrl_message_fragment_and_send(
 		&otr_ops, 
-		server, 
+		ircctx, 
 		co,
 		newmessage, 
 		OTRL_FRAGMENT_SEND_ALL, 
 		NULL);
 
 	if (err != 0) {
-		otr_notice(server,to,TXT_SEND_FRAGMENT,msg);
+		otr_notice(ircctx,to,TXT_SEND_FRAGMENT,msg);
 	} else
-		otr_debug(server,to,TXT_SEND_CONVERTED,newmessage);
+		otr_debug(ircctx,to,TXT_SEND_CONVERTED,newmessage);
 
 	return NULL;
 }
@@ -292,27 +294,10 @@ int otr_getstatus(char *mynick, char *nick, char *server)
 	}
 }
 
-SERVER_REC *server_find_address(char *address)
-{
-        GSList *tmp;
-
-        g_return_val_if_fail(address != NULL, NULL);
-        if (*address == '\0') return NULL;
-
-        for (tmp = servers; tmp != NULL; tmp = tmp->next) {
-                SERVER_REC *server = tmp->data;
-
-                if (g_strcasecmp(server->connrec->address, address) == 0)
-                        return server;
-        }
-
-        return NULL;
-}
-
 /*
  * Finish the conversation.
  */
-void otr_finish(SERVER_REC *server, char *nick, const char *peername, int inquery)
+void otr_finish(IRC_CTX *ircctx, char *nick, const char *peername, int inquery)
 {
 	ConnContext *co;
 	char accname[128];
@@ -323,14 +308,14 @@ void otr_finish(SERVER_REC *server, char *nick, const char *peername, int inquer
 		pserver = strchr(peername,'@');
 		if (!pserver)
 			return;
-		server = server_find_address(pserver+1);
-		if (!server)
+		ircctx = server_find_address(pserver+1);
+		if (!ircctx)
 			return;
 		*pserver = '\0';
 		nick = (char*)peername;
 	}
 
-	sprintf((char*)accname, "%s@%s", server->nick, server->connrec->address);
+	sprintf((char*)accname, "%s@%s", IRCCTX_NICK(ircctx), IRCCTX_ADDR(ircctx));
 
 	if (!(co = otr_getcontext(accname,nick,FALSE,NULL))) {
 		if (inquery)
@@ -341,10 +326,10 @@ void otr_finish(SERVER_REC *server, char *nick, const char *peername, int inquer
 		return;
 	}
 
-	otrl_message_disconnect(otr_state,&otr_ops,server,accname,
+	otrl_message_disconnect(otr_state,&otr_ops,ircctx,accname,
 				PROTOCOLID,nick);
 
-	otr_info(inquery ? server : NULL,
+	otr_info(inquery ? ircctx : NULL,
 		   inquery ? nick : NULL,
 		   TXT_CMD_FINISH,nick);
 
@@ -362,7 +347,7 @@ void otr_finish(SERVER_REC *server, char *nick, const char *peername, int inquer
 /*
  * Trust our peer.
  */
-void otr_trust(SERVER_REC *server, char *nick, const char *peername)
+void otr_trust(IRC_CTX *ircctx, char *nick, const char *peername)
 {
 	ConnContext *co;
 	char accname[128];
@@ -373,14 +358,14 @@ void otr_trust(SERVER_REC *server, char *nick, const char *peername)
 		pserver = strchr(peername,'@');
 		if (!pserver)
 			return;
-		server = server_find_address(pserver+1);
-		if (!server)
+		ircctx = server_find_address(pserver+1);
+		if (!ircctx)
 			return;
 		*pserver = '\0';
 		nick = (char*)peername;
 	}
 
-	sprintf((char*)accname, "%s@%s", server->nick, server->connrec->address);
+	sprintf((char*)accname, "%s@%s", IRCCTX_NICK(ircctx), IRCCTX_ADDR(ircctx));
 
 	if (!(co = otr_getcontext(accname,nick,FALSE,NULL))) {
 		otr_noticest(TXT_CTX_NOT_FOUND,
@@ -395,7 +380,7 @@ void otr_trust(SERVER_REC *server, char *nick, const char *peername)
 	coi = co->app_data;
 	coi->smp_failed = FALSE;
 
-	otr_notice(server,nick,TXT_FP_TRUST,nick);
+	otr_notice(ircctx,nick,TXT_FP_TRUST,nick);
 
 	if (peername)
 		*pserver = '@';
@@ -404,7 +389,7 @@ void otr_trust(SERVER_REC *server, char *nick, const char *peername)
 /*
  * Abort any ongoing SMP authentication.
  */
-void otr_abort_auth(ConnContext *co, SERVER_REC *server, const char *nick)
+void otr_abort_auth(ConnContext *co, IRC_CTX *ircctx, const char *nick)
 {
 	struct co_info *coi;
 
@@ -412,18 +397,18 @@ void otr_abort_auth(ConnContext *co, SERVER_REC *server, const char *nick)
 
 	coi->received_smp_init = FALSE;
 
-	otr_notice(server,nick,
+	otr_notice(ircctx,nick,
 		   co->smstate->nextExpected!=OTRL_SMP_EXPECT1 ? 
 		   TXT_AUTH_ABORTED_ONGOING :
 		   TXT_AUTH_ABORTED);
 
-	otrl_message_abort_smp(otr_state,&otr_ops,server,co);
+	otrl_message_abort_smp(otr_state,&otr_ops,ircctx,co);
 }
 
 /*
  * implements /otr authabort
  */
-void otr_authabort(SERVER_REC *server, char *nick, const char *peername)
+void otr_authabort(IRC_CTX *ircctx, char *nick, const char *peername)
 {
 	ConnContext *co;
 	char accname[128];
@@ -433,14 +418,14 @@ void otr_authabort(SERVER_REC *server, char *nick, const char *peername)
 		pserver = strchr(peername,'@');
 		if (!pserver)
 			return;
-		server = server_find_address(pserver+1);
-		if (!server)
+		ircctx = server_find_address(pserver+1);
+		if (!ircctx)
 			return;
 		*pserver = '\0';
 		nick = (char*)peername;
 	}
 
-	sprintf((char*)accname, "%s@%s", server->nick, server->connrec->address);
+	sprintf((char*)accname, "%s@%s", IRCCTX_NICK(ircctx), IRCCTX_ADDR(ircctx));
 
 	if (!(co = otr_getcontext(accname,nick,FALSE,NULL))) {
 		otr_noticest(TXT_CTX_NOT_FOUND,
@@ -450,7 +435,7 @@ void otr_authabort(SERVER_REC *server, char *nick, const char *peername)
 		return;
 	}
 
-	otr_abort_auth(co,server,nick);
+	otr_abort_auth(co,ircctx,nick);
 
 	if (peername)
 		*pserver = '@';
@@ -459,7 +444,7 @@ void otr_authabort(SERVER_REC *server, char *nick, const char *peername)
 /*
  * Initiate or respond to SMP authentication.
  */
-void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *secret)
+void otr_auth(IRC_CTX *ircctx, char *nick, const char *peername, const char *secret)
 {
 	ConnContext *co;
 	char accname[128];
@@ -470,14 +455,14 @@ void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *
 		pserver = strchr(peername,'@');
 		if (!pserver)
 			return;
-		server = server_find_address(pserver+1);
-		if (!server)
+		ircctx = server_find_address(pserver+1);
+		if (!ircctx)
 			return;
 		*pserver = '\0';
 		nick = (char*)peername;
 	}
 
-	sprintf((char*)accname, "%s@%s", server->nick, server->connrec->address);
+	sprintf((char*)accname, "%s@%s", IRCCTX_NICK(ircctx), IRCCTX_ADDR(ircctx));
 
 	if (!(co = otr_getcontext(accname,nick,FALSE,NULL))) {
 		otr_noticest(TXT_CTX_NOT_FOUND,
@@ -491,7 +476,7 @@ void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *
 
 	/* Aborting an ongoing auth */
 	if (co->smstate->nextExpected!=OTRL_SMP_EXPECT1)
-		otr_abort_auth(co,server,nick);
+		otr_abort_auth(co,ircctx,nick);
 
 	coi->smp_failed = FALSE;
 
@@ -508,7 +493,7 @@ void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *
 		otrl_message_initiate_smp(
 			otr_state, 
 			&otr_ops,
-			server,
+			ircctx,
 			co,
 			(unsigned char*)secret,
 			strlen(secret));
@@ -516,12 +501,12 @@ void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *
 		otrl_message_respond_smp(
 			otr_state,
 			&otr_ops,
-			server,
+			ircctx,
 			co,
 			(unsigned char*)secret,
 			strlen(secret));
 
-	otr_notice(server,nick,
+	otr_notice(ircctx,nick,
 		   coi->received_smp_init ?
 		   TXT_AUTH_RESPONDING :
 		   TXT_AUTH_INITIATED);
@@ -538,18 +523,18 @@ void otr_auth(SERVER_REC *server, char *nick, const char *peername, const char *
  */
 void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co, 
 		     struct co_info *coi, 
-		     SERVER_REC *server, const char *from) 
+		     IRC_CTX *ircctx, const char *from) 
 {
 	int abort = FALSE;
 
 	OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
 	if (tlv) {
 		if (co->smstate->nextExpected != OTRL_SMP_EXPECT1) {
-			otr_notice(server,from,TXT_AUTH_HAVE_OLD,
+			otr_notice(ircctx,from,TXT_AUTH_HAVE_OLD,
 				   from);
 			abort = TRUE;
 		} else {
-			otr_notice(server,from,TXT_AUTH_PEER,
+			otr_notice(ircctx,from,TXT_AUTH_PEER,
 				   from);
 			coi->received_smp_init = TRUE;
 		}
@@ -558,12 +543,12 @@ void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co,
 	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
 	if (tlv) {
 		if (co->smstate->nextExpected != OTRL_SMP_EXPECT2) {
-			otr_notice(server,from,
+			otr_notice(ircctx,from,
 				   TXT_AUTH_PEER_REPLY_WRONG,
 				   from);
 			abort = TRUE;
 		} else {
-			otr_notice(server,from,
+			otr_notice(ircctx,from,
 				   TXT_AUTH_PEER_REPLIED,
 				   from);
 			co->smstate->nextExpected = OTRL_SMP_EXPECT4;
@@ -573,17 +558,17 @@ void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co,
 	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
 	if (tlv) {
 		if (co->smstate->nextExpected != OTRL_SMP_EXPECT3) {
-			otr_notice(server,from,
+			otr_notice(ircctx,from,
 				   TXT_AUTH_PEER_WRONG_SMP3,
 				   from);
 			abort = TRUE;
 		} else {
 			char *trust = co->active_fingerprint->trust;
-			if (trust&&(*trust!='\0'))
-				otr_notice(server,from,
+			if (trust&&(*trust!='\0')) {
+				otr_notice(ircctx,from,
 					   TXT_AUTH_SUCCESSFUL);
-			else {
-				otr_notice(server,from,
+			} else {
+				otr_notice(ircctx,from,
 					   TXT_AUTH_FAILED);
 				coi->smp_failed = TRUE;
 			}
@@ -595,19 +580,19 @@ void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co,
 	tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
 	if (tlv) {
 		if (co->smstate->nextExpected != OTRL_SMP_EXPECT4) {
-			otr_notice(server,from,
+			otr_notice(ircctx,from,
 				   TXT_AUTH_PEER_WRONG_SMP4,
 				   from);
 			abort = TRUE;
 		} else {
 			char *trust = co->active_fingerprint->trust;
-			if (trust&&(*trust!='\0'))
-				otr_notice(server,from,
+			if (trust&&(*trust!='\0')) {
+				otr_notice(ircctx,from,
 					   TXT_AUTH_SUCCESSFUL);
-			else {
+			} else {
 				/* unreachable since 4 is never sent out on
 				 * error */
-				otr_notice(server,from,
+				otr_notice(ircctx,from,
 					   TXT_AUTH_FAILED);
 				coi->smp_failed = TRUE;
 			}
@@ -616,11 +601,11 @@ void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co,
 		}
 	}
 	if (abort)
-		otr_abort_auth(co,server,from);
+		otr_abort_auth(co,ircctx,from);
 
 	tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
 	if (tlv)
-		otr_notice(server,from,TXT_PEER_FINISHED,from);
+		otr_notice(ircctx,from,TXT_PEER_FINISHED,from);
 
 	statusbar_items_redraw("otr");
 }
@@ -630,7 +615,7 @@ void otr_handle_tlvs(OtrlTLV *tlvs, ConnContext *co,
  * Returns NULL if its an OTR protocol message and 
  * the (possibly) decrypted message otherwise.
  */
-char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
+char *otr_receive(IRC_CTX *ircctx, const char *msg,const char *from)
 {
 	int ignore_message;
 	char *newmessage = NULL;
@@ -640,9 +625,9 @@ char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
 	struct co_info *coi;
 	OtrlTLV *tlvs;
 
-	sprintf(accname, "%s@%s", server->nick, server->connrec->address);
+	sprintf(accname, "%s@%s", IRCCTX_NICK(ircctx), IRCCTX_ADDR(ircctx));
 
-	if (!(co = otr_getcontext(accname,from,TRUE,server))) {
+	if (!(co = otr_getcontext(accname,from,TRUE,ircctx))) {
 		otr_noticest(TXT_CTX_NOT_CREATE,
 			     accname,from);
 		return NULL;
@@ -655,7 +640,7 @@ char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
 	 */
 	if ((strcmp(msg,coi->better_msg_two)==0)||
 	    (strcmp(msg,formats[TXT_OTR_BETTER_THREE].def)==0)) {
-		otr_debug(server,from,TXT_RECEIVE_IGNORE_QUERY);
+		otr_debug(ircctx,from,TXT_RECEIVE_IGNORE_QUERY);
 		return NULL;
 	}
 
@@ -675,7 +660,7 @@ char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
 		    (msg[strlen(msg)-1]!=','))
 			return NULL;
 
-		otr_debug(server,from,TXT_RECEIVE_DEQUEUED,
+		otr_debug(ircctx,from,TXT_RECEIVE_DEQUEUED,
 			  strlen(coi->msgqueue));
 
 		msg = coi->msgqueue;
@@ -691,14 +676,14 @@ char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
 		   (msg[strlen(msg)-1]!=',')) {
 		coi->msgqueue = malloc(4096*sizeof(char));
 		strcpy(coi->msgqueue,msg);
-		otr_debug(server,from,TXT_RECEIVE_QUEUED,strlen(msg));
+		otr_debug(ircctx,from,TXT_RECEIVE_QUEUED,strlen(msg));
 		return NULL;
 	}
 
 	ignore_message = otrl_message_receiving(
 		otr_state,
 		&otr_ops,
-		server,
+		ircctx,
 		accname, 
 		PROTOCOLID, 
 		from, 
@@ -709,16 +694,16 @@ char *otr_receive(SERVER_REC *server, const char *msg,const char *from)
 		NULL);
 
 	if (tlvs) 
-		otr_handle_tlvs(tlvs,co,coi,server,from);
+		otr_handle_tlvs(tlvs,co,coi,ircctx,from);
 	
 	if (ignore_message) {
-		otr_debug(server,from,
+		otr_debug(ircctx,from,
 			  TXT_RECEIVE_IGNORE, strlen(msg),accname,from,msg);
 		return NULL;
 	}
 
 	if (newmessage)
-		otr_debug(server,from,TXT_RECEIVE_CONVERTED);
+		otr_debug(ircctx,from,TXT_RECEIVE_CONVERTED);
 
 	return newmessage ? : (char*)msg;
 }
diff --git a/ui.c b/ui.c
deleted file mode 100644
index ceb971c..0000000
--- a/ui.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Off-the-Record Messaging (OTR) module for the irssi IRC client
- * Copyright (C) 2008  Uli Meis <a.sporto+bee at gmail.com>
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
- */
-
-#include "otr.h"
-
-char *lvlstring[] = { 
-	"NOTICE",
-	"DEBUG"
-};
-
-
-void otr_log(SERVER_REC *server, const char *nick, 
-	     int level, const char *format, ...) {
-	va_list params;
-	va_start( params, format );
-	char msg[LOGMAX], *s = msg;
-
-	if ((level==LVL_DEBUG)&&!debug)
-		return;
-
-	s += sprintf(s,"%s","%9OTR%9");
-
-	if (level!=LVL_NOTICE)	
-		s += sprintf(s,"(%s)",lvlstring[level]);
-
-	s += sprintf(s,": ");
-
-	if( vsnprintf( s, LOGMAX, format, params ) < 0 )
-		sprintf( s, "internal error parsing error string (BUG)" );
-	va_end( params );
-
-	printtext(server, nick, MSGLEVEL_MSGS, msg);
-}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git



More information about the Pkg-privacy-commits mailing list