1
From 88af13c85590cc3a2229c36ddf5612e876d05f0e Mon Sep 17 00:00:00 2001
2
From: Stephen Paul Weber <singpolyma@singpolyma.net>
3
Date: Sat, 23 Apr 2011 14:01:51 -0500
4
Subject: [PATCH 08/18] Command to turn encryption on/off
7
src/core/rosters.h | 1 +
8
src/core/xmpp-commands.c | 28 ++++++++++++++++++++++++++++
9
2 files changed, 29 insertions(+)
11
--- a/src/core/rosters.h
12
+++ b/src/core/rosters.h
18
} XMPP_ROSTER_RESOURCE_REC;
20
typedef struct _XMPP_ROSTER_USER_REC {
21
--- a/src/core/xmpp-commands.c
22
+++ b/src/core/xmpp-commands.c
27
+/* SYNTAX: XMPPPGP <on|off|KEYID> */
29
+cmd_xmpppgp(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
31
+ if(IS_QUERY(item)) {
32
+ XMPP_ROSTER_USER_REC *user = rosters_find_user(server->roster, \
33
+ QUERY(item)->name, NULL, NULL);
34
+ XMPP_ROSTER_RESOURCE_REC *res;
35
+ if(!user) goto error;
36
+ res = rosters_find_resource(user->resources, \
37
+ xmpp_extract_resource(QUERY(item)->name));
38
+ if(!res) goto error;
40
+ if(res->pgp_keyid && strcmp(data, "on") == 0) {
41
+ res->pgp_encrypt = 1;
42
+ } else if(strcmp(data, "off") == 0) {
43
+ res->pgp_encrypt = 0;
45
+ res->pgp_keyid = malloc(9);
46
+ strcpy(res->pgp_keyid, data);
54
xmpp_get_dest(const char *cmd_dest, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
57
command_bind_xmpp("presence unsubscribe", NULL,
58
(SIGNAL_FUNC)cmd_presence_unsubscribe);
59
command_bind_xmpp("me", NULL, (SIGNAL_FUNC)cmd_me);
60
+ command_bind_xmpp("xmpppgp", NULL, (SIGNAL_FUNC)cmd_xmpppgp);
61
settings_add_str("xmpp", "xmpp_default_away_mode", "away");
65
command_unbind("presence unsubscribe",
66
(SIGNAL_FUNC)cmd_presence_unsubscribe);
67
command_unbind("me", (SIGNAL_FUNC)cmd_me);
68
+ command_unbind("xmpppgp", (SIGNAL_FUNC)cmd_xmpppgp);