[Pkg-privacy-commits] [irssi-plugin-otr] 57/267: Initial weechat support.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:26:16 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 2038c5179823cc0634eaba2d9395da094734fc00
Author: Uli Meis <a.sporto+bee at gmail.com>
Date: Sat Feb 7 17:39:48 2009 +0100
Initial weechat support.
---
CMakeLists.txt | 34 ++++-
irssi/CMakeLists.txt | 93 ++++++-------
makeformats.py | 8 ++
otr.h | 6 +
weechat/CMakeLists.txt | 31 +++++
weechat/weechat_otr.c | 365 +++++++++++++++++++++++++++++++++++++++++++++++++
weechat/weechat_otr.h | 90 ++++++++++++
xchat/CMakeLists.txt | 43 +++---
8 files changed, 590 insertions(+), 80 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f7f28f..2a0a732 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -160,17 +160,36 @@ FOREACH(X ${LIBGCRYPT_LDFLAGS} ${GLIB_LDFLAGS} ${APPLE_LDFLAGS})
SET(MAIN_LDFLAGS "${MAIN_LDFLAGS} ${X}")
ENDFOREACH(X ${LIBGCRYPT_LDFLAGS} ${GLIB_LDFLAGS} ${APPLE_LDFLAGS})
+FIND_PATH(IRSSI_INCLUDE_DIR NAMES irssi/src/core/module.h)
+MARK_AS_ADVANCED(IRSSI_INCLUDE_DIR)
+
+FIND_PATH(WEECHAT_INCLUDE_DIR NAMES weechat/weechat-plugin.h)
+MARK_AS_ADVANCED(WEECHAT_INCLUDE_DIR)
+
+FIND_PATH(XCHAT_INCLUDE_DIR NAMES xchat/xchat-plugin.h)
+MARK_AS_ADVANCED(XCHAT_INCLUDE_DIR)
+
IF(CMAKE_SOURCE_DIR MATCHES "irssi[^/]*$")
- SET(WANT_IRSSI ON)
+ SET(W_IRSSI ON)
ELSEIF(CMAKE_SOURCE_DIR MATCHES "xchat[^/]*$")
- SET(WANT_XCHAT ON)
+ SET(W_XCHAT ON)
+ELSEIF(CMAKE_SOURCE_DIR MATCHES "weechat[^/]*$")
+ SET(W_WEECHAT ON)
ELSE(CMAKE_SOURCE_DIR MATCHES "irssi[^/]*$")
- SET(WANT_IRSSI ON)
- SET(WANT_XCHAT ON)
+ IF(IRSSI_INCLUDE_DIR)
+ SET(W_IRSSI ON)
+ ENDIF(IRSSI_INCLUDE_DIR)
+ IF(XCHAT_INCLUDE_DIR)
+ SET(W_XCHAT ON)
+ ENDIF(XCHAT_INCLUDE_DIR)
+ IF(WEECHAT_INCLUDE_DIR)
+ SET(W_WEECHAT ON)
+ ENDIF(WEECHAT_INCLUDE_DIR)
ENDIF(CMAKE_SOURCE_DIR MATCHES "irssi[^/]*$")
-OPTION(WANT_IRSSI "build irssi plugin" ${WANT_IRSSI})
-OPTION(WANT_XCHAT "build xchat plugin" ${WANT_XCHAT})
+OPTION(WANT_IRSSI "build irssi plugin" ${W_IRSSI})
+OPTION(WANT_XCHAT "build xchat plugin" ${W_XCHAT})
+OPTION(WANT_WEECHAT "build weechat plugin" ${W_WEECHAT})
IF(WANT_IRSSI)
INCLUDE(irssi/CMakeLists.txt)
@@ -178,6 +197,9 @@ ENDIF(WANT_IRSSI)
IF(WANT_XCHAT)
INCLUDE(xchat/CMakeLists.txt)
ENDIF(WANT_XCHAT)
+IF(WANT_WEECHAT)
+ INCLUDE(weechat/CMakeLists.txt)
+ENDIF(WANT_WEECHAT)
# cscope
diff --git a/irssi/CMakeLists.txt b/irssi/CMakeLists.txt
index 10bd726..b82466a 100644
--- a/irssi/CMakeLists.txt
+++ b/irssi/CMakeLists.txt
@@ -1,64 +1,57 @@
# irssi public headers
-FIND_PATH(IRSSI_INCLUDE_DIR NAMES irssi/src/core/module.h)
-MARK_AS_ADVANCED(IRSSI_INCLUDE_DIR)
-
IF(NOT IRSSI_INCLUDE_DIR)
- MESSAGE(STATUS "*** no irssi found ***")
-ELSEIF(BUILDFOR AND NOT BUILDFOR STREQUAL "irssi")
- MESSAGE(STATUS "*** not building for irssi ***")
-ELSE(NOT IRSSI_INCLUDE_DIR)
- MESSAGE(STATUS "*** building for irssi ***")
- SET(HAVE_IRSSI 1)
- SET(IRCOTR_INCLUDE_DIRS
- ${IRCOTR_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)
+ MESSAGE(FATAL_ERROR "*** no irssi found. If you don't want this plugin set the
+ appropriate option to OFF, use for instance 'ccmake .' ***")
+ENDIF(NOT IRSSI_INCLUDE_DIR)
- INCLUDE_DIRECTORIES(${IRCOTR_INCLUDE_DIRS})
+MESSAGE(STATUS "*** building for irssi ***")
- SET(CMAKE_REQUIRED_INCLUDES ${IRCOTR_INCLUDE_DIRS})
+SET(IRCOTR_INCLUDE_DIRS
+ ${IRCOTR_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)
- # irssi statusbar header
+INCLUDE_DIRECTORIES(${IRCOTR_INCLUDE_DIRS})
- CHECK_INCLUDE_FILES("glib.h;common.h;fe-text/statusbar-item.h" HAVE_IRSSISBAR_H)
+SET(CMAKE_REQUIRED_INCLUDES ${IRCOTR_INCLUDE_DIRS})
- # Bad hack
+# irssi statusbar header
- 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_INCLUDE_FILES("glib.h;common.h;fe-text/statusbar-item.h" HAVE_IRSSISBAR_H)
-ENDIF(NOT IRSSI_INCLUDE_DIR)
+# 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_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)
-IF(HAVE_IRSSI)
- ADD_LIBRARY(irssiotr SHARED irssi/irssi_otr.c otr_util.c otr_ops.c otr_key.c ${CMAKE_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)
+ADD_LIBRARY(irssiotr SHARED irssi/irssi_otr.c otr_util.c otr_ops.c otr_key.c ${CMAKE_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)
# docdir
diff --git a/makeformats.py b/makeformats.py
index 744c51c..40a8706 100755
--- a/makeformats.py
+++ b/makeformats.py
@@ -27,6 +27,14 @@ src.write("""char *otr_help = "%s";\n""" % "\\n".join(
+["%9- End of OTR help -%9"]
))
+srcx.write("""char *otr_help = "%s";\n""" % "\\n".join(
+ ["- OTR help -"]+
+ [re.sub('"([^"]*)"','\\"\\1\\"',
+ x.replace('\n','').replace("\t"," ") )
+ for x in open(sys.argv[2],"r").readlines()]
+ +["- End of OTR help -"]
+ ))
+
src.write('FORMAT_REC formats[] = {\n')
srcx.write('FORMAT_REC formats[] = {\n')
diff --git a/otr.h b/otr.h
index d1e8c3b..c239241 100644
--- a/otr.h
+++ b/otr.h
@@ -46,6 +46,12 @@
#include <xchat_otr.h>
#endif
+/* weechat */
+
+#ifdef TARGET_WEECHAT
+#include <weechat_otr.h>
+#endif
+
/* log stuff */
#define LOGMAX 1024
diff --git a/weechat/CMakeLists.txt b/weechat/CMakeLists.txt
new file mode 100644
index 0000000..c16696e
--- /dev/null
+++ b/weechat/CMakeLists.txt
@@ -0,0 +1,31 @@
+IF(NOT WEECHAT_INCLUDE_DIR)
+ MESSAGE(FATAL_ERROR "*** no weechat found. If you don't want this plugin set the
+ appropriate option to OFF, use for instance 'ccmake .' ***")
+ENDIF(NOT WEECHAT_INCLUDE_DIR)
+
+MESSAGE(STATUS "*** building for weechat ***")
+SET(IRCOTR_INCLUDE_DIRS
+ ${IRCOTR_INCLUDE_DIRS}
+ ${WEECHAT_INCLUDE_DIR}/weechat
+ weechat)
+
+INCLUDE_DIRECTORIES(${IRCOTR_INCLUDE_DIRS})
+
+ADD_LIBRARY(weechatotr SHARED weechat/weechat_otr.c otr_util.c otr_ops.c otr_key.c ${PROJECT_BINARY_DIR}/xchat-formats.c)
+TARGET_LINK_LIBRARIES(weechatotr ${GLIB_LIBRARIES} ${LIBOTR_LIBRARIES})
+SET_TARGET_PROPERTIES(weechatotr PROPERTIES
+ COMPILE_FLAGS -DTARGET_WEECHAT
+ OUTPUT_NAME "weechatotr"
+ LINK_FLAGS "${MAIN_LDFLAGS}")
+IF(APPLE)
+ SET_TARGET_PROPERTIES(weechatotr PROPERTIES SUFFIX ".so")
+ENDIF(APPLE)
+
+# docdir
+
+IF(NOT DOCDIR)
+ SET(DOCDIR share/doc/weechat-otr)
+ENDIF(NOT DOCDIR)
+
+INSTALL(TARGETS weechatotr DESTINATION lib${LIB_SUFFIX}/weechat/plugins)
+INSTALL(FILES README LICENSE DESTINATION ${DOCDIR})
diff --git a/weechat/weechat_otr.c b/weechat/weechat_otr.c
new file mode 100644
index 0000000..9314f02
--- /dev/null
+++ b/weechat/weechat_otr.c
@@ -0,0 +1,365 @@
+/*
+ * Off-the-Record Messaging (OTR) modules for IRC
+ * Copyright (C) 2009 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"
+
+WEECHAT_PLUGIN_NAME("weechat-otr");
+WEECHAT_PLUGIN_DESCRIPTION("Off-The-Record Messaging for WeeChat");
+WEECHAT_PLUGIN_AUTHOR("Uli Meis <a.sporto+bee at gmail.com>");
+WEECHAT_PLUGIN_VERSION(IRCOTR_VERSION);
+WEECHAT_PLUGIN_WEECHAT_VERSION("unknown");
+WEECHAT_PLUGIN_LICENSE("GPL3");
+
+struct t_weechat_plugin *weechat_otr_plugin = NULL;
+
+int debug = 0;
+
+#ifdef HAVE_GREGEX_H
+GRegex *regex_nickignore = NULL;
+#endif
+
+static char set_policy[512] = IO_DEFAULT_POLICY;
+static char set_policy_known[512] = IO_DEFAULT_POLICY_KNOWN;
+static char set_ignore[512] = IO_DEFAULT_IGNORE;
+static int set_finishonunload = TRUE;
+
+void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg) {
+ char s[256];
+ char nmsg[512];
+ struct t_gui_buffer *buffer;
+
+ sprintf(s,"%s.%s",ircctx->address,recipient);
+ buffer = weechat_buffer_search("irc",s);
+ if (buffer) {
+ weechat_printf(NULL,"OTR injection %s.%s: %s",ircctx->address,recipient,msg);
+ sprintf(nmsg,"/quote PRIVMSG %s :%s",recipient,msg);
+ weechat_command(buffer,nmsg);
+ } else {
+ weechat_printf(NULL,"OTR: injection error, no buffer found");
+ //TODO: create query window on demand
+ }
+}
+
+IRC_CTX *server_find_address(char *address)
+{
+ static IRC_CTX ircctx;
+
+ ircctx.address = address;
+
+ return &ircctx;
+}
+
+void printformat(IRC_CTX *ircctx, const char *nick, int lvl, int fnum, ...)
+{
+ va_list params;
+ va_start( params, fnum );
+ char msg[LOGMAX], *s = msg;
+ char *server = NULL;
+ struct t_gui_buffer *buffer = NULL;
+
+ if (ircctx)
+ server = ircctx->address;
+
+ if (server&&nick) {
+ char s[256];
+ sprintf(s,"%s.%s",ircctx->address,nick);
+ buffer = weechat_buffer_search("irc",s);
+ //TODO: create query window on demand
+ }
+
+ if( vsnprintf( s, LOGMAX, formats[fnum].def, params ) < 0 )
+ sprintf( s, "internal error parsing error string (BUG)" );
+ va_end( params );
+
+ weechat_printf(buffer,"OTR: %s",s);
+}
+
+int extract_nick(char *nick, char *line)
+{
+ char *excl;
+
+ if (*line++ != ':')
+ return FALSE;
+
+ strcpy(nick,line);
+
+ if ((excl = strchr(nick,'!')))
+ *excl = '\0';
+
+ return TRUE;
+
+}
+
+char *wc_modifier_privmsg_in(void *data, const char *modifier,
+ const char *modifier_data, const char *string)
+{
+ int argc;
+ char **argv, **argv_eol;
+ char *server = strdup(modifier_data);
+ char nick[256];
+ char *newmsg,*msg;
+ IRC_CTX ircctx;
+ struct t_gui_buffer *buffer;
+ char bname[256];
+ char cmsg[512];
+
+ string = strdup(string);
+
+ argv = weechat_string_explode (string, " ", 0, 0, &argc);
+ argv_eol = weechat_string_explode (string, " ", 1, 0, NULL);
+
+ if (!extract_nick(nick,argv[0]))
+ goto done;
+
+#ifdef HAVE_GREGEX_H
+ if (g_regex_match(regex_nickignore,nick,0,NULL))
+ goto done;
+#endif
+
+ ircctx.address = server;
+ sprintf(bname,"%s.%s",ircctx.address,nick);
+ buffer = weechat_buffer_search("irc",bname);
+ if (!buffer) {
+ weechat_printf(NULL,"OTR receive: no buffer found for %s",bname);
+ //TODO: create query window on demand
+ goto done;
+ }
+
+ ircctx.nick = (char*)weechat_buffer_get_string(buffer,"localvar_nick");
+
+ msg = argv_eol[3]+1;
+ weechat_printf(NULL,"otr receive own %s, server %s, nick %s, msg %s",
+ ircctx.nick,ircctx.address,nick,msg);
+ newmsg = otr_receive(&ircctx,msg,nick);
+
+ if (!newmsg) {
+ string = strdup("");
+ goto done;
+ }
+
+ if (newmsg==msg) {
+ goto done;
+ }
+
+/* weechat_printf_tags(buffer,
+ irc_protocol_tags("privmsg", "notify_private"),
+ "%s%s",
+ irc_nick_as_prefix(NULL,nick,IRC_COLOR_CHAT_NICK_OTHER),
+ "?");*/
+
+ sprintf(cmsg,"%s\t%s",nick,newmsg);
+ weechat_printf(buffer,cmsg);
+
+ otrl_message_free(newmsg);
+
+ string = strdup("");
+done:
+ free(server);
+ weechat_string_free_exploded(argv);
+ weechat_string_free_exploded(argv_eol);
+
+ return (char*)string;
+}
+
+char *wc_modifier_privmsg_out(void *data, const char *modifier,
+ const char *modifier_data, const char *string)
+{
+ int argc;
+ char **argv, **argv_eol;
+ IRC_CTX ircctx;
+ char newmsg[512];
+ char *otrmsg;
+ struct t_gui_buffer *buffer;
+ char s[256];
+ char *msg;
+
+ argv = weechat_string_explode (string, " ", 0, 0, &argc);
+ argv_eol = weechat_string_explode (string, " ", 1, 0, NULL);
+
+ string = strdup(string);
+
+ if ((*argv[1]=='&')||(*argv[1]=='#'))
+ goto done;
+
+ msg = argv_eol[2]+1;
+
+#ifdef HAVE_GREGEX_H
+ if (g_regex_match(regex_nickignore,argv[1],0,NULL))
+ goto done;
+#endif
+
+ /* we're unfortunately fed back stuff from irc_send_message above */
+ if (strncmp(msg,"?OTR",4)==0)
+ return strdup(string);
+
+ ircctx.address = (char*)modifier_data;
+ sprintf(s,"%s.%s",ircctx.address,argv[1]);
+ buffer = weechat_buffer_search("irc",s);
+ if (!buffer) {
+ weechat_printf(NULL,"OTR send: no buffer found for %s",s);
+ //TODO: create query window on demand
+ goto done;
+ }
+ ircctx.nick = (char*)weechat_buffer_get_string(buffer,"localvar_nick");
+ weechat_printf(NULL,"otr send own %s, server %s, nick %s, msg %s",
+ ircctx.nick,ircctx.address,argv[1],msg);
+ otrmsg = otr_send(&ircctx,msg,argv[1]);
+
+ if (otrmsg==msg)
+ goto done;
+
+ if (!otrmsg) {
+ weechat_printf(NULL,"OTR send NULL");
+ free((char*)string);
+ string = strdup("");
+ goto done;
+ }
+
+ weechat_printf(NULL,"NEWMSG");
+ snprintf(newmsg, 511, "PRIVMSG %s :%s", argv[1], otrmsg);
+
+ otrl_message_free(otrmsg);
+
+ free((char*)string);
+ string = newmsg;
+
+done:
+ weechat_string_free_exploded(argv);
+ weechat_string_free_exploded(argv_eol);
+
+ return (char*)string;
+}
+
+int cmd_otr(void *data, struct t_gui_buffer *buffer, int argc, char **word, char **word_eol)
+{
+ const char *own_nick = weechat_buffer_get_string(buffer,"localvar_nick");
+ const char *server = weechat_buffer_get_string(buffer,"localvar_server");
+ char *target = (char*)weechat_buffer_get_string(buffer,"short_name");
+ IRC_CTX ircctxs = {
+ .nick = (char*)own_nick,
+ .address = (char*)server },
+ *ircctx = &ircctxs;
+
+ char *cmd = argc > 1 ? word[1] : NULL;
+ char *parm1 = argc > 2 ? word[2] : "";
+ char *parm2 = argc > 3 ? word[3] : "";
+
+ if (!cmd) {
+ weechat_printf(buffer,otr_help);
+ } else if (strcmp(cmd,"debug")==0) {
+ debug = !debug;
+ otr_noticest(debug ? TXT_CMD_DEBUG_ON : TXT_CMD_DEBUG_OFF);
+ } else if (strcmp(cmd,"version")==0) {
+ otr_noticest(TXT_CMD_VERSION,IRCOTR_VERSION);
+ } else if (strcmp(cmd,"finish")==0) {
+ if (parm1&&*parm1)
+ otr_finish(NULL,NULL,parm1,TRUE);
+ else
+ otr_finish(ircctx,target,NULL,TRUE);
+ } else if (strcmp(cmd,"trust")==0) {
+ if (parm1&&*parm1)
+ otr_trust(NULL,NULL,parm1);
+ else
+ otr_trust(ircctx,target,NULL);
+ } else if (strcmp(cmd,"authabort")==0) {
+ if (parm1&&*parm1)
+ otr_authabort(NULL,NULL,parm1);
+ else
+ otr_authabort(ircctx,target,NULL);
+ } else if (strcmp(cmd,"genkey")==0) {
+ if (parm1&&*parm1) {
+ if (strcmp(parm1,"abort")==0)
+ keygen_abort(FALSE);
+ else if (strchr(parm1,'@'))
+ keygen_run(parm1);
+ else
+ otr_noticest(TXT_KG_NEEDACC);
+ } else {
+ otr_noticest(TXT_KG_NEEDACC);
+ }
+ } else if (strcmp(cmd,"auth")==0) {
+ if (!parm1||!*parm1) {
+ otr_notice(ircctx,target,
+ TXT_CMD_AUTH);
+ } else if (parm2&&*parm2&&strchr(parm1,'@'))
+ otr_auth(NULL,NULL,word_eol[3],parm1);
+ else
+ otr_auth(ircctx,target,NULL,word_eol[2]);
+ } else if (strcmp(cmd,"set")==0) {
+ if (strcmp(parm1,"policy")==0) {
+ otr_setpolicies(word_eol[3],FALSE);
+ strcpy(set_policy,word_eol[3]);
+ } else if (strcmp(parm1,"policy_known")==0) {
+ otr_setpolicies(word_eol[3],TRUE);
+ strcpy(set_policy_known,word_eol[3]);
+ } else if (strcmp(parm1,"ignore")==0) {
+#ifdef HAVE_GREGEX_H
+ if (regex_nickignore)
+ g_regex_unref(regex_nickignore);
+ regex_nickignore = g_regex_new(word_eol[3],0,0,NULL);
+ strcpy(set_ignore,word_eol[3]);
+#endif
+ } else if (strcmp(parm1,"finishonunload")==0) {
+ set_finishonunload = (strcasecmp(parm2,"true")==0);
+ } else {
+ weechat_printf(buffer, "policy: %s\n"
+ "policy_known: %s\nignore: %s\n"
+ "finishonunload: %s\n",
+ set_policy,set_policy_known,set_ignore,
+ set_finishonunload ? "true" : "false");
+ }
+
+ }
+
+ return WEECHAT_RC_OK;
+}
+int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
+{
+
+ weechat_plugin = plugin;
+
+ weechat_hook_modifier("irc_in_privmsg", &wc_modifier_privmsg_in, NULL);
+ weechat_hook_modifier("irc_out_privmsg", &wc_modifier_privmsg_out, NULL);
+
+ if (otrlib_init())
+ return WEECHAT_RC_ERROR;
+
+ otr_setpolicies(IO_DEFAULT_POLICY,FALSE);
+ otr_setpolicies(IO_DEFAULT_POLICY_KNOWN,TRUE);
+
+#ifdef HAVE_GREGEX_H
+ if (regex_nickignore)
+ g_regex_unref(regex_nickignore);
+ regex_nickignore = g_regex_new(IO_DEFAULT_IGNORE,0,0,NULL);
+#endif
+
+ weechat_hook_command ("otr",
+ N_("Control the OTR module"),
+ N_("[text]"),
+ N_("text: write this text"),
+ "",
+ &cmd_otr, NULL);
+
+ return WEECHAT_RC_OK;
+}
+
+int weechat_plugin_end (struct t_weechat_plugin *plugin)
+{
+ return WEECHAT_RC_OK;
+}
diff --git a/weechat/weechat_otr.h b/weechat/weechat_otr.h
new file mode 100644
index 0000000..c9ffc16
--- /dev/null
+++ b/weechat/weechat_otr.h
@@ -0,0 +1,90 @@
+/*
+ * Off-the-Record Messaging (OTR) modules for IRC
+ * Copyright (C) 2009 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 "weechat-plugin.h"
+
+extern struct t_weechat_plugin *weechat_otr_plugin;
+#define weechat_plugin weechat_otr_plugin
+
+#define MAX_FORMAT_PARAMS 10
+
+struct _IRC_CTX {
+ char *nick;
+ char *address;
+};
+
+typedef struct _IRC_CTX IRC_CTX;
+struct _FORMAT_REC {
+ char *tag;
+ char *def;
+
+ int params;
+ int paramtypes[MAX_FORMAT_PARAMS];
+};
+
+typedef struct _FORMAT_REC FORMAT_REC;
+
+enum { MSGLEVEL_CRAP, MSGLEVEL_MSGS } lvls;
+
+#define statusbar_items_redraw(name) ;
+#define get_client_config_dir() weechat_info_get("weechat_dir",NULL)
+
+void printformat(IRC_CTX *ircctx, const char *nick, int lvl, int fnum, ...);
+
+#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__); \
+}
+
+static IRC_CTX *IRCCTX_DUP(IRC_CTX *ircctx) __attribute__ ((unused));
+static void IRCCTX_FREE(IRC_CTX *ircctx) __attribute__ ((unused));
+
+//#define IRCCTX_DUP(ircctx) g_memdup(ircctx,sizeof(IRC_CTX));
+static IRC_CTX *IRCCTX_DUP(IRC_CTX *ircctx)
+{
+ IRC_CTX *nctx = g_memdup(ircctx,sizeof(IRC_CTX));
+
+ nctx->nick = strdup(ircctx->nick);
+ nctx->address = strdup(ircctx->address);
+
+ return nctx;
+}
+
+#define IRCCTX_ADDR(ircctx) ircctx->address
+#define IRCCTX_NICK(ircctx) ircctx->nick
+//#define IRCCTX_FREE(ircctx) g_free(ircctx)
+static void IRCCTX_FREE(IRC_CTX *ircctx)
+{
+ g_free(ircctx->nick);
+ g_free(ircctx->address);
+ g_free(ircctx);
+}
diff --git a/xchat/CMakeLists.txt b/xchat/CMakeLists.txt
index 2407d19..19f79aa 100644
--- a/xchat/CMakeLists.txt
+++ b/xchat/CMakeLists.txt
@@ -1,32 +1,27 @@
-FIND_PATH(XCHAT_INCLUDE_DIR NAMES xchat/xchat-plugin.h)
-MARK_AS_ADVANCED(XCHAT_INCLUDE_DIR)
-
IF(NOT XCHAT_INCLUDE_DIR)
- MESSAGE(STATUS "*** no xchat found ***")
-ELSEIF(BUILDFOR AND NOT BUILDFOR STREQUAL "xchat")
- MESSAGE(STATUS "*** not building for xchat ***")
-ELSE(NOT XCHAT_INCLUDE_DIR)
- MESSAGE(STATUS "*** building for xchat ***")
- SET(HAVE_XCHAT 1)
- SET(IRCOTR_INCLUDE_DIRS
- ${IRCOTR_INCLUDE_DIRS}
- ${XCHAT_INCLUDE_DIR}/xchat
- xchat)
+ MESSAGE(FATAL_ERROR "*** no xchat found. If you don't want this plugin set the
+ appropriate option to OFF, use for instance 'ccmake .' ***")
ENDIF(NOT XCHAT_INCLUDE_DIR)
+MESSAGE(STATUS "*** building for xchat ***")
+
+SET(IRCOTR_INCLUDE_DIRS
+ ${IRCOTR_INCLUDE_DIRS}
+ ${XCHAT_INCLUDE_DIR}/xchat
+ xchat)
+
INCLUDE_DIRECTORIES(${IRCOTR_INCLUDE_DIRS})
-IF(HAVE_XCHAT)
- ADD_LIBRARY(xchatotr SHARED xchat/xchat_otr.c otr_util.c otr_ops.c otr_key.c ${PROJECT_BINARY_DIR}/xchat-formats.c)
- TARGET_LINK_LIBRARIES(xchatotr ${GLIB_LIBRARIES} ${LIBOTR_LIBRARIES})
- SET_TARGET_PROPERTIES(xchatotr PROPERTIES
- COMPILE_FLAGS -DTARGET_XCHAT
- OUTPUT_NAME "xchatotr"
- LINK_FLAGS "${MAIN_LDFLAGS}")
- IF(APPLE)
- SET_TARGET_PROPERTIES(xchatotr PROPERTIES SUFFIX ".so")
- ENDIF(APPLE)
-ENDIF(HAVE_XCHAT)
+ADD_LIBRARY(xchatotr SHARED xchat/xchat_otr.c otr_util.c otr_ops.c otr_key.c ${PROJECT_BINARY_DIR}/xchat-formats.c)
+TARGET_LINK_LIBRARIES(xchatotr ${GLIB_LIBRARIES} ${LIBOTR_LIBRARIES})
+SET_TARGET_PROPERTIES(xchatotr PROPERTIES
+ COMPILE_FLAGS -DTARGET_XCHAT
+ OUTPUT_NAME "xchatotr"
+ LINK_FLAGS "${MAIN_LDFLAGS}")
+
+IF(APPLE)
+ SET_TARGET_PROPERTIES(xchatotr PROPERTIES SUFFIX ".so")
+ENDIF(APPLE)
# docdir
--
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