Package: irssi-plugin-xmpp / 0.54-3

singpolyma-0008-Command-to-turn-encryption-on-off.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 88af13c85590cc3a2229c36ddf5612e876d05f0e Mon Sep 17 00:00:00 2001
From: Stephen Paul Weber <singpolyma@singpolyma.net>
Date: Sat, 23 Apr 2011 14:01:51 -0500
Subject: [PATCH 08/18] Command to turn encryption on/off

---
 src/core/rosters.h       |  1 +
 src/core/xmpp-commands.c | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

--- a/src/core/rosters.h
+++ b/src/core/rosters.h
@@ -31,6 +31,7 @@
 	char	*status;
 	char	*composing_id;
 	char	*pgp_keyid;
+	int	pgp_encrypt;
 } XMPP_ROSTER_RESOURCE_REC;
 
 typedef struct _XMPP_ROSTER_USER_REC {
--- a/src/core/xmpp-commands.c
+++ b/src/core/xmpp-commands.c
@@ -534,6 +534,32 @@
 	g_free(recoded);
 }
 
+/* SYNTAX: XMPPPGP <on|off|KEYID> */
+static void
+cmd_xmpppgp(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
+{
+	if(IS_QUERY(item)) {
+		XMPP_ROSTER_USER_REC *user = rosters_find_user(server->roster, \
+			QUERY(item)->name, NULL, NULL);
+		XMPP_ROSTER_RESOURCE_REC *res;
+		if(!user) goto error;
+		res = rosters_find_resource(user->resources, \
+			xmpp_extract_resource(QUERY(item)->name));
+		if(!res) goto error;
+
+		if(res->pgp_keyid && strcmp(data, "on") == 0) {
+			res->pgp_encrypt = 1;
+		} else if(strcmp(data, "off") == 0) {
+			res->pgp_encrypt = 0;
+		} else {
+			res->pgp_keyid = malloc(9);
+			strcpy(res->pgp_keyid, data);
+		}
+	}
+error:
+	return;
+}
+
 char *
 xmpp_get_dest(const char *cmd_dest, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
 {
@@ -579,6 +605,7 @@
 	command_bind_xmpp("presence unsubscribe", NULL,
 	    (SIGNAL_FUNC)cmd_presence_unsubscribe);
 	command_bind_xmpp("me", NULL, (SIGNAL_FUNC)cmd_me);
+	command_bind_xmpp("xmpppgp", NULL, (SIGNAL_FUNC)cmd_xmpppgp);
 	settings_add_str("xmpp", "xmpp_default_away_mode", "away");
 }
 
@@ -603,4 +630,5 @@
 	command_unbind("presence unsubscribe",
 	    (SIGNAL_FUNC)cmd_presence_unsubscribe);
 	command_unbind("me", (SIGNAL_FUNC)cmd_me);
+	command_unbind("xmpppgp", (SIGNAL_FUNC)cmd_xmpppgp);
 }