Debian Codegraph @

debian/patches/singpolyma-0008-Command-to-turn-encryption-on-off.patch

raw
1 From 88af13c85590cc3a2229c36ddf5612e876d05f0e Mon Sep 17 00:00:00 2001
2 From: Stephen Paul Weber <[email protected]>
3 Date: Sat, 23 Apr 2011 14:01:51 -0500
4 Subject: [PATCH 08/18] Command to turn encryption on/off
5
6 ---
7 src/core/rosters.h | 1 +
8 src/core/xmpp-commands.c | 28 ++++++++++++++++++++++++++++
9 2 files changed, 29 insertions(+)
10
11 --- a/src/core/rosters.h
12 +++ b/src/core/rosters.h
13 @@ -31,6 +31,7 @@
14 char *status;
15 char *composing_id;
16 char *pgp_keyid;
17 + int pgp_encrypt;
18 } XMPP_ROSTER_RESOURCE_REC;
19
20 typedef struct _XMPP_ROSTER_USER_REC {
21 --- a/src/core/xmpp-commands.c
22 +++ b/src/core/xmpp-commands.c
23 @@ -534,6 +534,32 @@
24 g_free(recoded);
25 }
26
27 +/* SYNTAX: XMPPPGP <on|off|KEYID> */
28 +static void
29 +cmd_xmpppgp(const char *data, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
30 +{
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;
39 +
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;
44 + } else {
45 + res->pgp_keyid = malloc(9);
46 + strcpy(res->pgp_keyid, data);
47 + }
48 + }
49 +error:
50 + return;
51 +}
52 +
53 char *
54 xmpp_get_dest(const char *cmd_dest, XMPP_SERVER_REC *server, WI_ITEM_REC *item)
55 {
56 @@ -579,6 +605,7 @@
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");
62 }
63
64 @@ -603,4 +630,5 @@
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);
69 }