Permalink
Browse files

And here comes a really bad hack to make otr_key use weechat_hook_fd.

  • Loading branch information...
1 parent 9cc0177 commit 0d85b1ea46ddc4b831da7f7e9ed413952aa8df14 @ulim ulim committed Feb 11, 2009
Showing with 42 additions and 7 deletions.
  1. +2 −1 otr_key.c
  2. +2 −0 weechat/CMakeLists.txt
  3. +1 −1 weechat/weechat_otr.c
  4. +37 −5 weechat/weechat_otr.h
View
3 otr_key.c
@@ -37,7 +37,8 @@ struct {
char *protocol;
time_t started;
GIOChannel *ch[2];
- guint cpid,cwid;
+ guint cpid;
+ guint cwid;
pid_t pid;
} kg_st = {.status = KEYGEN_NO };
View
2 weechat/CMakeLists.txt
@@ -27,5 +27,7 @@ IF(NOT DOCDIR)
SET(DOCDIR share/doc/weechat-otr)
ENDIF(NOT DOCDIR)
+SET_TARGET_PROPERTIES(weechatotr PROPERTIES PREFIX "" OUTPUT_NAME "irc-otr")
+
INSTALL(TARGETS weechatotr DESTINATION lib${LIB_SUFFIX}/weechat/plugins)
INSTALL(FILES README LICENSE DESTINATION ${DOCDIR})
View
2 weechat/weechat_otr.c
@@ -58,7 +58,7 @@ void printformatva(IRC_CTX *ircctx, const char *nick, char *format, va_list para
weechat_command(NULL,cmd);
buffer = weechat_buffer_search("irc",s);
if (!buffer)
- weechat_printf(NULL,"OTR: Failed to create "
+ weechat_printf(NULL,"OTR: Failed to create "
"a buffer for the following "
"message! server=%s,nick=%s",
ircctx->address,nick);
View
42 weechat/weechat_otr.h
@@ -68,7 +68,6 @@ void printformat(IRC_CTX *ircctx, const char *nick, int lvl, int fnum, ...);
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));
@@ -81,10 +80,43 @@ static IRC_CTX *IRCCTX_DUP(IRC_CTX *ircctx)
#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);
+ free(ircctx->nick);
+ free(ircctx->address);
+ free(ircctx);
+}
+
+#define g_io_add_watch(pid,a,func,b) gioaddwatchfake(pid,func)
+
+#define g_child_watch_add(pid,func,dunno) NULL
+#define g_source_remove(a) gsourceremovefake(a)
+#define guint struct t_hook *
+
+static void gsourceremovefake(struct t_hook *hook) __attribute__ ((unused));
+static void gsourceremovefake(struct t_hook *hook)
+{
+ if (hook)
+ weechat_unhook(hook);
+
+}
+
+gboolean keygen_complete(GIOChannel *source, GIOCondition condition,
+ gpointer data);
+
+static int cb(void *data)
+{
+ keygen_complete(NULL,0,NULL);
+ return TRUE;
+}
+
+static struct t_hook *gioaddwatchfake(GIOChannel *source, int (*func)(GIOChannel *source,
+ GIOCondition condition,
+ gpointer data))
+ __attribute__ ((unused));
+
+static struct t_hook *gioaddwatchfake(GIOChannel *source, int (*func)(GIOChannel *source,GIOCondition
+ condition, gpointer data))
+{
+ return weechat_hook_fd(g_io_channel_unix_get_fd(source),TRUE,FALSE,FALSE,cb,source);
}

0 comments on commit 0d85b1e

Please sign in to comment.