Package: irssi-plugin-xmpp / 0.54-3

singpolyma-0110-Display-useful-messages-for-xmpppgp-command.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
From 6f7eeccee2e6fcd38897bd2212c1ea4b4d56d1a6 Mon Sep 17 00:00:00 2001
From: Stephen Paul Weber <singpolyma@singpolyma.net>
Date: Wed, 18 Mar 2015 11:52:51 -0500
Subject: [PATCH 10/10] Display useful messages for /xmpppgp command

---
 src/core/xmpp-commands.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/core/xmpp-commands.c b/src/core/xmpp-commands.c
index f303736..5c9146d 100644
--- a/src/core/xmpp-commands.c
+++ b/src/core/xmpp-commands.c
@@ -542,16 +542,33 @@ cmd_xmpppgp(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *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;
+
+		if(!user) {
+			printtext_window(item->window, 1, "xmpppgp: user not found in roster");
+			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;
+		if(!res) {
+			printtext_window(item->window, 1, "xmpppgp: user's resource not found in roster");
+			goto error;
+		}
+
+		if(strcmp(data, "on") == 0) {
+			if(res->pgp_keyid) {
+				printtext_window(item->window, 1, "xmpppgp: encryption enabled");
+				res->pgp_encrypt = 1;
+			} else {
+				printtext_window(item->window, 1, "xmpppgp: no keyid found for destination");
+				goto error;
+			}
 		} else if(strcmp(data, "off") == 0) {
+			printtext_window(item->window, 1, "xmpppgp: encryption disabled");
 			res->pgp_encrypt = 0;
 		} else {
+			printtext_window(item->window, 1, "xmpppgp: destination keyid set");
 			res->pgp_keyid = malloc(9);
 			strcpy(res->pgp_keyid, data);
 		}
-- 
2.1.4