[Pkg-privacy-commits] [irssi-plugin-otr] 73/267: weechat: working again plus status bar (thx to netzwurm) and signal support.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:29 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 fd11e699d9cb8d2f230251b23c037f1fd6372e14
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Sun Feb 22 01:29:14 2009 +0100

    weechat: working again plus status bar (thx to netzwurm) and signal support.
---
 io_util.c             |  2 +-
 otr.h                 |  4 ++--
 otr_util.c            |  2 +-
 weechat/weechat_otr.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/io_util.c b/io_util.c
index 40366cb..b347950 100644
--- a/io_util.c
+++ b/io_util.c
@@ -237,7 +237,7 @@ void io_explode_args(const char *args, char ***argvp, char ***argv_eolp, int *ar
 /*
  * Get a format describing the OTR status of this conversation.
  */
-int otr_getstatus_format(IRC_CTX *ircctx, char *nick)
+int otr_getstatus_format(IRC_CTX *ircctx, const char *nick)
 {
 	int status = otr_getstatus(ircctx,nick);
 
diff --git a/otr.h b/otr.h
index 1fe90c4..d6041f5 100644
--- a/otr.h
+++ b/otr.h
@@ -204,7 +204,7 @@ void otr_deinit_user(IOUSTATE *ioustate);
 
 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(IRC_CTX *ircctx, char *nick);
+int otr_getstatus(IRC_CTX *ircctx, const char *nick);
 ConnContext *otr_getcontext(const char *accname,const char *nick,int create,IRC_CTX *ircctx);
 
 /* user interaction */
@@ -238,6 +238,6 @@ extern struct _cmds cmds[];
 
 int cmd_generic(IOUSTATE *ioustate, IRC_CTX *ircctx, int argc, char *argv[], char *argv_eol[],
 	    char *target);
-int otr_getstatus_format(IRC_CTX *ircctx, char *nick);
+int otr_getstatus_format(IRC_CTX *ircctx, const char *nick);
 
 void io_explode_args(const char *args, char ***argvp, char ***argv_eolp, int *argcp);
diff --git a/otr_util.c b/otr_util.c
index 6fa42cb..777cc8d 100644
--- a/otr_util.c
+++ b/otr_util.c
@@ -268,7 +268,7 @@ struct ctxlist_ *otr_contexts(IOUSTATE *ioustate)
 /*
  * Get the OTR status of this conversation.
  */
-int otr_getstatus(IRC_CTX *ircctx, char *nick)
+int otr_getstatus(IRC_CTX *ircctx, const char *nick)
 {
 	ConnContext *co;
 	char accname[128];
diff --git a/weechat/weechat_otr.c b/weechat/weechat_otr.c
index 9393afa..eac529b 100644
--- a/weechat/weechat_otr.c
+++ b/weechat/weechat_otr.c
@@ -27,6 +27,7 @@ WEECHAT_PLUGIN_WEECHAT_VERSION("unknown");
 WEECHAT_PLUGIN_LICENSE("GPL3");
 
 struct t_weechat_plugin *weechat_otr_plugin = NULL;
+struct t_gui_bar_item *otr_statusbar;
 
 int debug = 0;
 
@@ -102,11 +103,25 @@ void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg) {
 	weechat_command(NULL,nmsg);
 }
 
-IRC_CTX *server_find_address(char *address)
+IRC_CTX *ircctx_by_peername(const char *peername, char *nick)
 {
+	char *address;
 	static IRC_CTX ircctx;
+	static char pname[256];
+
+	strcpy(pname,peername);
+
+	address = strchr(pname,'@');
+
+	if (!address)
+		return NULL;
+
+	*address = '\0';
+	strcpy(nick,pname);
+	*address++ = '@';
 
 	ircctx.address = address;
+	ircctx.nick = pname;
 
         return &ircctx;
 }
@@ -249,6 +264,48 @@ int cmd_otr(void *data, struct t_gui_buffer *buffer, int argc, char **word, char
 	return WEECHAT_RC_OK;
 }
 
+/*
+ * otr status bar
+ */
+char* otr_statusbar_callback (void *data,
+			      struct t_gui_bar_item *item,
+			      struct t_gui_window *window)
+{
+	const char *target;
+	IRC_CTX ircctx;
+	int formatnum;
+	struct t_gui_buffer *buffer = 
+		weechat_window_get_pointer(window, "buffer");
+	const char *type = weechat_buffer_get_string (buffer, "localvar_type");
+
+	if (!type || strcmp(type, "private") != 0) 
+		return strdup("");
+	
+	ircctx.nick = (char*)weechat_buffer_get_string(buffer,"localvar_nick");
+	ircctx.address =  (char*)weechat_buffer_get_string(buffer,"localvar_server");
+	target = weechat_buffer_get_string(buffer,"short_name");
+
+	formatnum = otr_getstatus_format(&ircctx, target);
+
+	return strdup (formats[formatnum].def);
+}
+
+
+void otr_status_change(IRC_CTX *ircctx, const char *nick, int event)
+{
+	char signalname[128];
+	char servernick[256];
+
+	sprintf(signalname,"OTR_%s",otr_status_txt[event]);
+	sprintf(servernick,"%s,%s",ircctx->address,nick);
+
+	weechat_hook_signal_send(signalname,
+				 WEECHAT_HOOK_SIGNAL_STRING,
+				 servernick);
+
+	weechat_bar_item_update("otr");
+}
+
 int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
 {
 
@@ -281,11 +338,16 @@ int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]
 	cmds[CMDCOUNT].name = "set";
 	cmds[CMDCOUNT].cmdfunc = cmd_set;
 
+	otr_statusbar = weechat_bar_item_new ("otr", &otr_statusbar_callback, NULL);
+	weechat_bar_item_update ("otr");
+
 	return WEECHAT_RC_OK;
 }
 
 int weechat_plugin_end (struct t_weechat_plugin *plugin)
 {
+	weechat_bar_item_remove(otr_statusbar);
+
 	otr_deinit_user(ioustate);
 
 	otrlib_deinit();

-- 
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