| 1 |
From 6f7eeccee2e6fcd38897bd2212c1ea4b4d56d1a6 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Stephen Paul Weber <[email protected]> |
| 3 |
Date: Wed, 18 Mar 2015 11:52:51 -0500 |
| 4 |
Subject: [PATCH 10/10] Display useful messages for /xmpppgp command |
| 5 |
|
| 6 |
--- |
| 7 |
src/core/xmpp-commands.c | 25 +++++++++++++++++++++---- |
| 8 |
1 file changed, 21 insertions(+), 4 deletions(-) |
| 9 |
|
| 10 |
diff --git a/src/core/xmpp-commands.c b/src/core/xmpp-commands.c |
| 11 |
index f303736..5c9146d 100644 |
| 12 |
--- a/src/core/xmpp-commands.c |
| 13 |
+++ b/src/core/xmpp-commands.c |
| 14 |
@@ -542,16 +542,33 @@ cmd_xmpppgp(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *item) |
| 15 |
XMPP_ROSTER_USER_REC *user = rosters_find_user(server->roster, \ |
| 16 |
QUERY(item)->name, NULL, NULL); |
| 17 |
XMPP_ROSTER_RESOURCE_REC *res; |
| 18 |
- if(!user) goto error; |
| 19 |
+ |
| 20 |
+ if(!user) { |
| 21 |
+ printtext_window(item->window, 1, "xmpppgp: user not found in roster"); |
| 22 |
+ goto error; |
| 23 |
+ } |
| 24 |
+ |
| 25 |
res = rosters_find_resource(user->resources, \ |
| 26 |
xmpp_extract_resource(QUERY(item)->name)); |
| 27 |
- if(!res) goto error; |
| 28 |
|
| 29 |
- if(res->pgp_keyid && strcmp(data, "on") == 0) { |
| 30 |
- res->pgp_encrypt = 1; |
| 31 |
+ if(!res) { |
| 32 |
+ printtext_window(item->window, 1, "xmpppgp: user's resource not found in roster"); |
| 33 |
+ goto error; |
| 34 |
+ } |
| 35 |
+ |
| 36 |
+ if(strcmp(data, "on") == 0) { |
| 37 |
+ if(res->pgp_keyid) { |
| 38 |
+ printtext_window(item->window, 1, "xmpppgp: encryption enabled"); |
| 39 |
+ res->pgp_encrypt = 1; |
| 40 |
+ } else { |
| 41 |
+ printtext_window(item->window, 1, "xmpppgp: no keyid found for destination"); |
| 42 |
+ goto error; |
| 43 |
+ } |
| 44 |
} else if(strcmp(data, "off") == 0) { |
| 45 |
+ printtext_window(item->window, 1, "xmpppgp: encryption disabled"); |
| 46 |
res->pgp_encrypt = 0; |
| 47 |
} else { |
| 48 |
+ printtext_window(item->window, 1, "xmpppgp: destination keyid set"); |
| 49 |
res->pgp_keyid = malloc(9); |
| 50 |
strcpy(res->pgp_keyid, data); |
| 51 |
} |
| 52 |
-- |
| 53 |
2.1.4 |
| 54 |
|