Sun, 15 May 2016 15:32:05 -0300
Add "account-status-changing" signal from instantbird
It's like "account-status-changed", but emitted before the status change
instead of after.
Instantbird ticket: https://bugzilla.mozilla.org/show_bug.cgi?id=954403
| 8849 | 1 | /* |
| 2 | ||
| 15884 | 3 | silcpurple_buddy.c |
| 8849 | 4 | |
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
7 | Copyright (C) 2004 - 2007 Pekka Riikonen |
| 8849 | 8 | |
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27199
diff
changeset
|
20 | #include "internal.h" |
|
35190
5986ee34c476
libpurple: Fix build and warnings with glib 2.24
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
21 | #include "glibcompat.h" |
|
35681
54694ef14d46
Silc: ignore Wcast-align in silc.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35190
diff
changeset
|
22 | PURPLE_BEGIN_IGNORE_CAST_ALIGN |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
23 | #include "silc.h" |
|
35681
54694ef14d46
Silc: ignore Wcast-align in silc.h
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35190
diff
changeset
|
24 | PURPLE_END_IGNORE_CAST_ALIGN |
| 8849 | 25 | #include "silcclient.h" |
| 15884 | 26 | #include "silcpurple.h" |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
27 | #include "wb.h" |
| 8849 | 28 | |
| 29 | /***************************** Key Agreement *********************************/ | |
| 30 | ||
| 31 | static void | |
| 15884 | 32 | silcpurple_buddy_keyagr(PurpleBlistNode *node, gpointer data); |
| 9060 | 33 | |
| 34 | static void | |
| 15884 | 35 | silcpurple_buddy_keyagr_do(PurpleConnection *gc, const char *name, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
36 | gboolean force_local); |
| 8849 | 37 | |
| 38 | typedef struct { | |
| 39 | char *nick; | |
| 15884 | 40 | PurpleConnection *gc; |
| 41 | } *SilcPurpleResolve; | |
| 8849 | 42 | |
| 43 | static void | |
| 15884 | 44 | silcpurple_buddy_keyagr_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
45 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
46 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
47 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
48 | void *context) |
| 8849 | 49 | { |
| 15884 | 50 | PurpleConnection *gc = client->application; |
| 51 | SilcPurpleResolve r = context; | |
| 8849 | 52 | char tmp[256]; |
| 53 | ||
| 54 | if (!clients) { | |
| 55 | g_snprintf(tmp, sizeof(tmp), | |
| 56 | _("User %s is not present in the network"), r->nick); | |
| 15884 | 57 | purple_notify_error(gc, _("Key Agreement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
58 | _("Cannot perform the key agreement"), tmp, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
59 | purple_request_cpar_from_connection(gc)); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
60 | g_free(r->nick); |
| 8849 | 61 | silc_free(r); |
| 62 | return; | |
| 63 | } | |
| 64 | ||
| 15884 | 65 | silcpurple_buddy_keyagr_do(gc, r->nick, FALSE); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
66 | g_free(r->nick); |
| 8849 | 67 | silc_free(r); |
| 68 | } | |
| 69 | ||
| 70 | static void | |
| 15884 | 71 | silcpurple_buddy_keyagr_cb(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
72 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
73 | SilcClientEntry client_entry, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
74 | SilcKeyAgreementStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
75 | SilcSKEKeyMaterial key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
76 | void *context) |
| 8849 | 77 | { |
| 15884 | 78 | PurpleConnection *gc = client->application; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
79 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 80 | |
| 81 | if (!sg->conn) | |
| 82 | return; | |
| 83 | ||
| 84 | switch (status) { | |
| 85 | case SILC_KEY_AGREEMENT_OK: | |
| 86 | { | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
87 | PurpleIMConversation *im; |
| 8849 | 88 | char tmp[128]; |
| 89 | ||
| 90 | /* Set the private key for this client */ | |
| 91 | silc_client_del_private_message_key(client, conn, client_entry); | |
| 92 | silc_client_add_private_message_key_ske(client, conn, client_entry, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
93 | NULL, NULL, key); |
| 8849 | 94 | silc_ske_free_key_material(key); |
| 95 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
96 | |
| 8849 | 97 | /* Open IM window */ |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
98 | im = purple_conversations_find_im_with_account( |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
99 | client_entry->nickname, sg->account); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
100 | if (im) { |
| 11586 | 101 | /* we don't have windows in the core anymore...but we may want to |
| 102 | * provide some method for asking the UI to show the window | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
103 | purple_conversation_window_show(purple_conversation_get_window(im)); |
| 11586 | 104 | */ |
| 105 | } else { | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
106 | im = purple_im_conversation_new(sg->account, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
107 | client_entry->nickname); |
| 11586 | 108 | } |
| 8849 | 109 | g_snprintf(tmp, sizeof(tmp), "%s [private key]", client_entry->nickname); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34889
diff
changeset
|
110 | purple_conversation_set_title(PURPLE_CONVERSATION(im), tmp); |
| 8849 | 111 | } |
| 112 | break; | |
| 113 | ||
| 114 | case SILC_KEY_AGREEMENT_ERROR: | |
| 15884 | 115 | purple_notify_error(gc, _("Key Agreement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
116 | _("Error occurred during key agreement"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
117 | purple_request_cpar_from_connection(gc)); |
| 8849 | 118 | break; |
| 119 | ||
| 120 | case SILC_KEY_AGREEMENT_FAILURE: | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
121 | purple_notify_error(gc, _("Key Agreement"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
122 | _("Key Agreement failed"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
123 | purple_request_cpar_from_connection(gc)); |
| 8849 | 124 | break; |
| 125 | ||
| 126 | case SILC_KEY_AGREEMENT_TIMEOUT: | |
| 15884 | 127 | purple_notify_error(gc, _("Key Agreement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
128 | _("Timeout during key agreement"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
129 | purple_request_cpar_from_connection(gc)); |
| 8849 | 130 | break; |
| 131 | ||
| 132 | case SILC_KEY_AGREEMENT_ABORTED: | |
| 15884 | 133 | purple_notify_error(gc, _("Key Agreement"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
134 | _("Key agreement was aborted"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
135 | purple_request_cpar_from_connection(gc)); |
| 8849 | 136 | break; |
| 137 | ||
| 138 | case SILC_KEY_AGREEMENT_ALREADY_STARTED: | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
139 | purple_notify_error(gc, _("Key Agreement"), _("Key agreement is" |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
140 | " already started"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
141 | purple_request_cpar_from_connection(gc)); |
| 8849 | 142 | break; |
| 143 | ||
| 144 | case SILC_KEY_AGREEMENT_SELF_DENIED: | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
145 | purple_notify_error(gc, _("Key Agreement"), _("Key agreement " |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
146 | "cannot be started with yourself"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
147 | purple_request_cpar_from_connection(gc)); |
| 8849 | 148 | break; |
| 149 | ||
| 150 | default: | |
| 151 | break; | |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 155 | static void | |
| 15884 | 156 | silcpurple_buddy_keyagr_do(PurpleConnection *gc, const char *name, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
157 | gboolean force_local) |
| 8849 | 158 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
159 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
160 | SilcDList clients; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
161 | SilcClientEntry client_entry; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
162 | SilcClientConnectionParams params; |
| 8910 | 163 | char *local_ip = NULL, *remote_ip = NULL; |
| 8849 | 164 | gboolean local = TRUE; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
165 | SilcSocket sock; |
| 8849 | 166 | |
| 167 | if (!sg->conn || !name) | |
| 168 | return; | |
| 169 | ||
| 170 | /* Find client entry */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
171 | clients = silc_client_get_clients_local(sg->client, sg->conn, name, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
172 | FALSE); |
| 8849 | 173 | if (!clients) { |
| 174 | /* Resolve unknown user */ | |
| 15884 | 175 | SilcPurpleResolve r = silc_calloc(1, sizeof(*r)); |
| 8849 | 176 | if (!r) |
| 177 | return; | |
| 178 | r->nick = g_strdup(name); | |
| 179 | r->gc = gc; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
180 | silc_client_get_clients(sg->client, sg->conn, name, NULL, |
| 15884 | 181 | silcpurple_buddy_keyagr_resolved, r); |
| 8849 | 182 | return; |
| 183 | } | |
| 184 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
185 | silc_socket_stream_get_info(silc_packet_stream_get_stream(sg->conn->stream), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
186 | &sock, NULL, NULL, NULL); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
187 | |
| 8849 | 188 | /* Resolve the local IP from the outgoing socket connection. We resolve |
| 189 | it to check whether we have a private range IP address or public IP | |
| 190 | address. If we have public then we will assume that we are not behind | |
| 191 | NAT and will provide automatically the point of connection to the | |
| 192 | agreement. If we have private range address we assume that we are | |
| 193 | behind NAT and we let the responder provide the point of connection. | |
| 194 | ||
| 195 | The algorithm also checks the remote IP address of server connection. | |
| 196 | If it is private range address and we have private range address we | |
| 197 | assume that we are chatting in LAN and will provide the point of | |
| 198 | connection. | |
| 199 | ||
| 200 | Naturally this algorithm does not always get things right. */ | |
| 201 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
202 | if (silc_net_check_local_by_sock(sock, NULL, &local_ip)) { |
| 8849 | 203 | /* Check if the IP is private */ |
| 15884 | 204 | if (!force_local && silcpurple_ip_is_private(local_ip)) { |
| 8849 | 205 | local = FALSE; |
| 206 | ||
| 207 | /* Local IP is private, resolve the remote server IP to see whether | |
| 208 | we are talking to Internet or just on LAN. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
209 | if (silc_net_check_host_by_sock(sock, NULL, |
| 8849 | 210 | &remote_ip)) |
| 15884 | 211 | if (silcpurple_ip_is_private(remote_ip)) |
| 8849 | 212 | /* We assume we are in LAN. Let's provide |
| 213 | the connection point. */ | |
| 214 | local = TRUE; | |
| 215 | } | |
| 216 | } | |
| 217 | ||
| 218 | if (force_local) | |
| 219 | local = TRUE; | |
| 220 | ||
| 221 | if (local && !local_ip) | |
| 222 | local_ip = silc_net_localip(); | |
| 223 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
224 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
225 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
226 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
227 | memset(¶ms, 0, sizeof(params)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
228 | params.timeout_secs = 60; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
229 | if (local) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
230 | /* Provide connection point */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
231 | params.local_ip = local_ip; |
| 8849 | 232 | |
| 233 | /* Send the key agreement request */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
234 | silc_client_send_key_agreement(sg->client, sg->conn, client_entry, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
235 | ¶ms, sg->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
236 | sg->private_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
237 | silcpurple_buddy_keyagr_cb, NULL); |
| 8849 | 238 | |
| 239 | silc_free(local_ip); | |
| 240 | silc_free(remote_ip); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
241 | silc_client_list_free(sg->client, sg->conn, clients); |
| 8849 | 242 | } |
| 243 | ||
| 244 | typedef struct { | |
| 245 | SilcClient client; | |
| 246 | SilcClientConnection conn; | |
| 247 | SilcClientID client_id; | |
| 248 | char *hostname; | |
| 249 | SilcUInt16 port; | |
| 15884 | 250 | } *SilcPurpleKeyAgrAsk; |
| 8849 | 251 | |
| 252 | static void | |
| 15884 | 253 | silcpurple_buddy_keyagr_request_cb(SilcPurpleKeyAgrAsk a, gint id) |
| 8849 | 254 | { |
| 255 | SilcClientEntry client_entry; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
256 | SilcClientConnectionParams params; |
| 8849 | 257 | |
| 258 | if (id != 1) | |
| 259 | goto out; | |
| 260 | ||
| 261 | /* Get the client entry. */ | |
| 262 | client_entry = silc_client_get_client_by_id(a->client, a->conn, | |
| 263 | &a->client_id); | |
| 264 | if (!client_entry) { | |
| 15884 | 265 | purple_notify_error(a->client->application, _("Key Agreement"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
266 | _("The remote user is not present in the network any more"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
267 | NULL, NULL); |
| 8849 | 268 | goto out; |
| 269 | } | |
| 270 | ||
| 271 | /* If the hostname was provided by the requestor perform the key agreement | |
| 272 | now. Otherwise, we will send him a request to connect to us. */ | |
| 273 | if (a->hostname) { | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
274 | memset(¶ms, 0, sizeof(params)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
275 | params.timeout_secs = 60; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
276 | silc_client_perform_key_agreement(a->client, a->conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
277 | client_entry, ¶ms, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
278 | a->conn->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
279 | a->conn->private_key, |
| 8849 | 280 | a->hostname, a->port, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
281 | silcpurple_buddy_keyagr_cb, NULL); |
| 8849 | 282 | } else { |
| 283 | /* Send request. Force us as the point of connection since requestor | |
| 284 | did not provide the point of connection. */ | |
| 15884 | 285 | silcpurple_buddy_keyagr_do(a->client->application, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
286 | client_entry->nickname, TRUE); |
| 8849 | 287 | } |
| 288 | ||
| 289 | out: | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
290 | g_free(a->hostname); |
| 8849 | 291 | silc_free(a); |
| 292 | } | |
| 293 | ||
| 15884 | 294 | void silcpurple_buddy_keyagr_request(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
295 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
296 | SilcClientEntry client_entry, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
297 | const char *hostname, SilcUInt16 port, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
298 | SilcUInt16 protocol) |
| 8849 | 299 | { |
| 300 | char tmp[128], tmp2[128]; | |
| 15884 | 301 | SilcPurpleKeyAgrAsk a; |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
302 | PurpleConnection *gc = client->application; |
| 8849 | 303 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
304 | /* For now Pidgin don't support UDP key agreement */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
305 | if (protocol == 1) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
306 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
307 | |
| 8849 | 308 | g_snprintf(tmp, sizeof(tmp), |
| 309 | _("Key agreement request received from %s. Would you like to " | |
| 310 | "perform the key agreement?"), client_entry->nickname); | |
| 311 | if (hostname) | |
| 312 | g_snprintf(tmp2, sizeof(tmp2), | |
| 313 | _("The remote user is waiting key agreement on:\n" | |
| 314 | "Remote host: %s\nRemote port: %d"), hostname, port); | |
| 315 | ||
| 316 | a = silc_calloc(1, sizeof(*a)); | |
| 317 | if (!a) | |
| 318 | return; | |
| 319 | a->client = client; | |
| 320 | a->conn = conn; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
321 | a->client_id = client_entry->id; |
| 8849 | 322 | if (hostname) |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
323 | a->hostname = g_strdup(hostname); |
| 8849 | 324 | a->port = port; |
| 325 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
326 | purple_request_action(client->application, _("Key Agreement Request"), tmp, |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
327 | hostname ? tmp2 : NULL, 1, purple_request_cpar_from_connection(gc), |
|
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
328 | a, 2, _("Yes"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
329 | _("No"), G_CALLBACK(silcpurple_buddy_keyagr_request_cb)); |
| 8849 | 330 | } |
| 331 | ||
| 332 | static void | |
| 15884 | 333 | silcpurple_buddy_keyagr(PurpleBlistNode *node, gpointer data) |
| 8849 | 334 | { |
| 15884 | 335 | PurpleBuddy *buddy; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
336 | PurpleAccount *account; |
| 9060 | 337 | |
| 15884 | 338 | buddy = (PurpleBuddy *)node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
339 | account = purple_buddy_get_account(buddy); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
340 | silcpurple_buddy_keyagr_do(purple_account_get_connection(account), |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
341 | purple_buddy_get_name(buddy), FALSE); |
| 8849 | 342 | } |
| 343 | ||
| 344 | ||
| 345 | /**************************** Static IM Key **********************************/ | |
| 346 | ||
| 347 | static void | |
| 15884 | 348 | silcpurple_buddy_resetkey(PurpleBlistNode *node, gpointer data) |
| 8849 | 349 | { |
| 15884 | 350 | PurpleBuddy *b; |
| 351 | PurpleConnection *gc; | |
| 352 | SilcPurple sg; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
353 | SilcDList clients; |
| 8849 | 354 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
355 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
356 | |
| 15884 | 357 | b = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
358 | gc = purple_account_get_connection(purple_buddy_get_account(b)); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
359 | sg = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
360 | |
| 8849 | 361 | /* Find client entry */ |
| 362 | clients = silc_client_get_clients_local(sg->client, sg->conn, | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
363 | purple_buddy_get_name(b), FALSE); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
364 | if (!clients) |
| 8849 | 365 | return; |
| 366 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
367 | silc_dlist_start(clients); |
| 8849 | 368 | silc_client_del_private_message_key(sg->client, sg->conn, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
369 | silc_dlist_get(clients)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
370 | silc_client_list_free(sg->client, sg->conn, clients); |
| 8849 | 371 | } |
| 372 | ||
| 373 | typedef struct { | |
| 374 | SilcClient client; | |
| 375 | SilcClientConnection conn; | |
| 376 | SilcClientID client_id; | |
| 15884 | 377 | } *SilcPurplePrivkey; |
| 8849 | 378 | |
| 379 | static void | |
| 15884 | 380 | silcpurple_buddy_privkey(PurpleConnection *gc, const char *name); |
| 8849 | 381 | |
| 382 | static void | |
| 15884 | 383 | silcpurple_buddy_privkey_cb(SilcPurplePrivkey p, const char *passphrase) |
| 8849 | 384 | { |
| 385 | SilcClientEntry client_entry; | |
| 386 | ||
| 387 | if (!passphrase || !(*passphrase)) { | |
| 388 | silc_free(p); | |
| 389 | return; | |
| 390 | } | |
| 391 | ||
| 392 | /* Get the client entry. */ | |
| 393 | client_entry = silc_client_get_client_by_id(p->client, p->conn, | |
| 394 | &p->client_id); | |
| 395 | if (!client_entry) { | |
| 15884 | 396 | purple_notify_error(p->client->application, _("IM With Password"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
397 | _("The remote user is not present in the network any more"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
398 | NULL, NULL); |
| 8849 | 399 | silc_free(p); |
| 400 | return; | |
| 401 | } | |
| 402 | ||
| 403 | /* Set the private message key */ | |
| 404 | silc_client_del_private_message_key(p->client, p->conn, | |
| 405 | client_entry); | |
| 406 | silc_client_add_private_message_key(p->client, p->conn, | |
| 407 | client_entry, NULL, NULL, | |
| 408 | (unsigned char *)passphrase, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
409 | strlen(passphrase)); |
| 8849 | 410 | silc_free(p); |
| 411 | } | |
| 412 | ||
| 413 | static void | |
| 15884 | 414 | silcpurple_buddy_privkey_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
415 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
416 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
417 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
418 | void *context) |
| 8849 | 419 | { |
| 420 | char tmp[256]; | |
| 421 | ||
| 422 | if (!clients) { | |
| 423 | g_snprintf(tmp, sizeof(tmp), | |
| 424 | _("User %s is not present in the network"), | |
| 425 | (const char *)context); | |
| 15884 | 426 | purple_notify_error(client->application, _("IM With Password"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
427 | _("Cannot set IM key"), tmp, NULL); |
| 8849 | 428 | g_free(context); |
| 429 | return; | |
| 430 | } | |
| 431 | ||
| 15884 | 432 | silcpurple_buddy_privkey(client->application, context); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
433 | g_free(context); |
| 8849 | 434 | } |
| 435 | ||
| 436 | static void | |
| 15884 | 437 | silcpurple_buddy_privkey(PurpleConnection *gc, const char *name) |
| 8849 | 438 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
439 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 15884 | 440 | SilcPurplePrivkey p; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
441 | SilcDList clients; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
442 | SilcClientEntry client_entry; |
| 8849 | 443 | |
| 9038 | 444 | if (!name) |
| 445 | return; | |
| 8849 | 446 | |
| 447 | /* Find client entry */ | |
| 448 | clients = silc_client_get_clients_local(sg->client, sg->conn, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
449 | name, FALSE); |
| 8849 | 450 | if (!clients) { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
451 | silc_client_get_clients(sg->client, sg->conn, name, NULL, |
| 15884 | 452 | silcpurple_buddy_privkey_resolved, |
| 9038 | 453 | g_strdup(name)); |
| 8849 | 454 | return; |
| 455 | } | |
| 456 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
457 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
458 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
459 | |
| 8849 | 460 | p = silc_calloc(1, sizeof(*p)); |
| 461 | if (!p) | |
| 462 | return; | |
| 463 | p->client = sg->client; | |
| 464 | p->conn = sg->conn; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
465 | p->client_id = client_entry->id; |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
466 | purple_request_input(gc, _("IM With Password"), NULL, |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
467 | _("Set IM Password"), NULL, FALSE, TRUE, NULL, |
|
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
468 | _("OK"), G_CALLBACK(silcpurple_buddy_privkey_cb), |
|
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
469 | _("Cancel"), G_CALLBACK(silcpurple_buddy_privkey_cb), |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34304
diff
changeset
|
470 | purple_request_cpar_from_connection(gc), p); |
| 8849 | 471 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
472 | silc_client_list_free(sg->client, sg->conn, clients); |
| 8849 | 473 | } |
| 474 | ||
| 9038 | 475 | static void |
| 15884 | 476 | silcpurple_buddy_privkey_menu(PurpleBlistNode *node, gpointer data) |
| 9038 | 477 | { |
| 15884 | 478 | PurpleBuddy *buddy; |
| 479 | PurpleConnection *gc; | |
| 9038 | 480 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
481 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 9038 | 482 | |
| 15884 | 483 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
484 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 9038 | 485 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
486 | silcpurple_buddy_privkey(gc, purple_buddy_get_name(buddy)); |
| 9038 | 487 | } |
| 488 | ||
| 8849 | 489 | |
| 490 | /**************************** Get Public Key *********************************/ | |
| 491 | ||
| 492 | typedef struct { | |
| 493 | SilcClient client; | |
| 494 | SilcClientConnection conn; | |
| 495 | SilcClientID client_id; | |
| 15884 | 496 | } *SilcPurpleBuddyGetkey; |
| 8849 | 497 | |
| 498 | static void | |
| 15884 | 499 | silcpurple_buddy_getkey(PurpleConnection *gc, const char *name); |
| 8849 | 500 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
501 | static SilcBool |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
502 | silcpurple_buddy_getkey_cb(SilcClient client, SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
503 | SilcCommand command, SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
504 | SilcStatus error, void *context, va_list ap) |
| 8849 | 505 | { |
| 506 | SilcClientEntry client_entry; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
507 | SilcPurpleBuddyGetkey g = context; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
508 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
509 | if (status != SILC_STATUS_OK) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
510 | purple_notify_error(g->client->application, _("Get Public Key"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
511 | _("The remote user is not present in the network any more"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
512 | NULL, NULL); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
513 | silc_free(g); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
514 | return FALSE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
515 | } |
| 8849 | 516 | |
| 517 | /* Get the client entry. */ | |
| 518 | client_entry = silc_client_get_client_by_id(g->client, g->conn, | |
| 519 | &g->client_id); | |
| 520 | if (!client_entry) { | |
| 15884 | 521 | purple_notify_error(g->client->application, _("Get Public Key"), |
| 8849 | 522 | _("The remote user is not present in the network any more"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
523 | NULL, NULL); |
| 8849 | 524 | silc_free(g); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
525 | return FALSE; |
| 8849 | 526 | } |
| 527 | ||
| 528 | if (!client_entry->public_key) { | |
| 529 | silc_free(g); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
530 | return FALSE; |
| 8849 | 531 | } |
| 532 | ||
| 533 | /* Now verify the public key */ | |
| 15884 | 534 | silcpurple_verify_public_key(g->client, g->conn, client_entry->nickname, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
535 | SILC_CONN_CLIENT, client_entry->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
536 | NULL, NULL); |
| 8849 | 537 | silc_free(g); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
538 | return TRUE; |
| 8849 | 539 | } |
| 540 | ||
| 541 | static void | |
| 15884 | 542 | silcpurple_buddy_getkey_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
543 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
544 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
545 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
546 | void *context) |
| 8849 | 547 | { |
| 548 | char tmp[256]; | |
| 549 | ||
| 550 | if (!clients) { | |
| 551 | g_snprintf(tmp, sizeof(tmp), | |
| 552 | _("User %s is not present in the network"), | |
| 553 | (const char *)context); | |
| 15884 | 554 | purple_notify_error(client->application, _("Get Public Key"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
555 | _("Cannot fetch the public key"), tmp, NULL); |
| 8849 | 556 | g_free(context); |
| 557 | return; | |
| 558 | } | |
| 559 | ||
| 15884 | 560 | silcpurple_buddy_getkey(client->application, context); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
21630
diff
changeset
|
561 | g_free(context); |
| 8849 | 562 | } |
| 563 | ||
| 564 | static void | |
| 15884 | 565 | silcpurple_buddy_getkey(PurpleConnection *gc, const char *name) |
| 8849 | 566 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
567 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 9038 | 568 | SilcClient client = sg->client; |
| 569 | SilcClientConnection conn = sg->conn; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
570 | SilcClientEntry client_entry; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
571 | SilcDList clients; |
| 15884 | 572 | SilcPurpleBuddyGetkey g; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
573 | SilcUInt16 cmd_ident; |
| 8849 | 574 | |
| 9038 | 575 | if (!name) |
| 576 | return; | |
| 8849 | 577 | |
| 578 | /* Find client entry */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
579 | clients = silc_client_get_clients_local(client, conn, name, FALSE); |
| 8849 | 580 | if (!clients) { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
581 | silc_client_get_clients(client, conn, name, NULL, |
| 15884 | 582 | silcpurple_buddy_getkey_resolved, |
| 9038 | 583 | g_strdup(name)); |
| 8849 | 584 | return; |
| 585 | } | |
| 586 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
587 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
588 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
589 | |
| 8849 | 590 | /* Call GETKEY */ |
| 591 | g = silc_calloc(1, sizeof(*g)); | |
| 592 | if (!g) | |
| 593 | return; | |
| 594 | g->client = client; | |
| 595 | g->conn = conn; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
596 | g->client_id = client_entry->id; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
597 | cmd_ident = silc_client_command_call(client, conn, NULL, "GETKEY", |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
598 | client_entry->nickname, NULL); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
599 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, cmd_ident, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
600 | silcpurple_buddy_getkey_cb, g); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
601 | silc_client_list_free(client, conn, clients); |
| 8849 | 602 | } |
| 603 | ||
| 604 | static void | |
| 15884 | 605 | silcpurple_buddy_getkey_menu(PurpleBlistNode *node, gpointer data) |
| 9038 | 606 | { |
| 15884 | 607 | PurpleBuddy *buddy; |
| 608 | PurpleConnection *gc; | |
| 9038 | 609 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
610 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 9038 | 611 | |
| 15884 | 612 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
613 | gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 9038 | 614 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
615 | silcpurple_buddy_getkey(gc, purple_buddy_get_name(buddy)); |
| 9038 | 616 | } |
| 617 | ||
| 618 | static void | |
| 15884 | 619 | silcpurple_buddy_showkey(PurpleBlistNode *node, gpointer data) |
| 8849 | 620 | { |
| 15884 | 621 | PurpleBuddy *b; |
| 622 | PurpleConnection *gc; | |
| 623 | SilcPurple sg; | |
| 8849 | 624 | SilcPublicKey public_key; |
| 625 | const char *pkfile; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
626 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
627 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 8849 | 628 | |
| 15884 | 629 | b = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
630 | gc = purple_account_get_connection(purple_buddy_get_account(b)); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
631 | sg = purple_connection_get_protocol_data(gc); |
| 8849 | 632 | |
| 15884 | 633 | pkfile = purple_blist_node_get_string(node, "public-key"); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
634 | if (!silc_pkcs_load_public_key(pkfile, &public_key)) { |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
635 | purple_notify_error(gc, _("Show Public Key"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
636 | _("Could not load public key"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
637 | purple_request_cpar_from_connection(gc)); |
| 8849 | 638 | return; |
| 639 | } | |
| 640 | ||
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
641 | silcpurple_show_public_key(sg, purple_buddy_get_name(b), public_key, NULL, NULL); |
| 8849 | 642 | silc_pkcs_public_key_free(public_key); |
| 643 | } | |
| 644 | ||
| 645 | ||
| 646 | /**************************** Buddy routines *********************************/ | |
| 647 | ||
| 648 | /* The buddies are implemented by using the WHOIS and WATCH commands that | |
| 649 | can be used to search users by their public key. Since nicknames aren't | |
| 650 | unique in SILC we cannot trust the buddy list using their nickname. We | |
| 651 | associate public keys to buddies and use those to search and watch | |
| 652 | in the network. | |
| 653 | ||
| 15884 | 654 | The problem is that Purple does not return PurpleBuddy contexts to the |
| 8849 | 655 | callbacks but the buddy names. Naturally, this is not going to work |
| 656 | with SILC. But, for now, we have to do what we can... */ | |
| 657 | ||
| 658 | typedef struct { | |
| 659 | SilcClient client; | |
| 660 | SilcClientConnection conn; | |
| 661 | SilcClientID client_id; | |
| 15884 | 662 | PurpleBuddy *b; |
| 8849 | 663 | unsigned char *offline_pk; |
| 664 | SilcUInt32 offline_pk_len; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
665 | SilcPublicKey public_key; |
| 8849 | 666 | unsigned int offline : 1; |
| 667 | unsigned int pubkey_search : 1; | |
| 668 | unsigned int init : 1; | |
| 15884 | 669 | } *SilcPurpleBuddyRes; |
| 8849 | 670 | |
| 671 | static void | |
| 15884 | 672 | silcpurple_add_buddy_ask_pk_cb(SilcPurpleBuddyRes r, gint id); |
| 8849 | 673 | static void |
| 15884 | 674 | silcpurple_add_buddy_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
675 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
676 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
677 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
678 | void *context); |
| 8849 | 679 | |
| 15884 | 680 | void silcpurple_get_info(PurpleConnection *gc, const char *who) |
| 8849 | 681 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
682 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 683 | SilcClient client = sg->client; |
| 684 | SilcClientConnection conn = sg->conn; | |
| 685 | SilcClientEntry client_entry; | |
| 15884 | 686 | PurpleBuddy *b; |
| 8849 | 687 | const char *filename, *nick = who; |
| 688 | char tmp[256]; | |
| 689 | ||
| 690 | if (!who) | |
| 691 | return; | |
| 692 | if (strlen(who) > 1 && who[0] == '@') | |
| 693 | nick = who + 1; | |
| 694 | if (strlen(who) > 1 && who[0] == '*') | |
| 695 | nick = who + 1; | |
| 696 | if (strlen(who) > 2 && who[0] == '*' && who[1] == '@') | |
| 697 | nick = who + 2; | |
| 698 | ||
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
699 | b = purple_blist_find_buddy(purple_connection_get_account(gc), nick); |
| 8849 | 700 | if (b) { |
| 701 | /* See if we have this buddy's public key. If we do use that | |
| 702 | to search the details. */ | |
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
703 | gpointer proto_data; |
| 15884 | 704 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
| 8849 | 705 | if (filename) { |
| 706 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 707 | command reply. */ | |
| 708 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 709 | "-details", "-pubkey", filename, NULL); | |
| 710 | return; | |
| 711 | } | |
| 712 | ||
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
713 | if (!(proto_data = purple_buddy_get_protocol_data(b))) { |
| 8849 | 714 | g_snprintf(tmp, sizeof(tmp), |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
715 | _("User %s is not present in the network"), purple_buddy_get_name(b)); |
| 15884 | 716 | purple_notify_error(gc, _("User Information"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
717 | _("Cannot get user information"), tmp, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
718 | purple_request_cpar_from_connection(gc)); |
| 8849 | 719 | return; |
| 720 | } | |
| 721 | ||
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
722 | client_entry = silc_client_get_client_by_id(client, conn, proto_data); |
| 8849 | 723 | if (client_entry) { |
| 724 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 725 | command reply. */ | |
| 726 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 727 | client_entry->nickname, "-details", NULL); | |
| 728 | } | |
| 729 | } else { | |
| 730 | /* Call WHOIS just with nickname. */ | |
| 731 | silc_client_command_call(client, conn, NULL, "WHOIS", nick, NULL); | |
| 732 | } | |
| 733 | } | |
| 734 | ||
| 735 | static void | |
| 15884 | 736 | silcpurple_add_buddy_pk_no(SilcPurpleBuddyRes r) |
| 8849 | 737 | { |
| 738 | char tmp[512]; | |
| 739 | g_snprintf(tmp, sizeof(tmp), _("The %s buddy is not trusted"), | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
740 | purple_buddy_get_name(r->b)); |
| 15884 | 741 | purple_notify_error(r->client->application, _("Add Buddy"), tmp, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
742 | _("You cannot receive buddy notifications until you " |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
743 | "import his/her public key. You can use the Get Public Key " |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
744 | "command to get the public key."), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
745 | purple_request_cpar_from_account(purple_buddy_get_account(r->b))); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
746 | purple_protocol_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_OFFLINE, NULL); |
| 8849 | 747 | } |
| 748 | ||
| 749 | static void | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
750 | silcpurple_add_buddy_save(SilcBool success, void *context) |
| 8849 | 751 | { |
| 15884 | 752 | SilcPurpleBuddyRes r = context; |
| 753 | PurpleBuddy *b = r->b; | |
| 8849 | 754 | SilcClientEntry client_entry; |
| 755 | SilcAttributePayload attr; | |
| 756 | SilcAttribute attribute; | |
| 757 | SilcVCardStruct vcard; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
758 | SilcMime message = NULL, extension = NULL; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
759 | SilcMime usericon = NULL; |
| 8849 | 760 | SilcAttributeObjPk serverpk, usersign, serversign; |
| 761 | gboolean usign_success = TRUE, ssign_success = TRUE; | |
|
11165
770e5d7940a0
[gaim-migrate @ 13266]
Mark Doliner <markdoliner@pidgin.im>
parents:
10869
diff
changeset
|
762 | char filename[512], filename2[512], *fingerprint = NULL, *tmp; |
| 8849 | 763 | SilcUInt32 len; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
764 | SilcHash hash; |
|
36256
a437550a9308
Remove -Wno-sign-compare and backport fixes from default.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
35995
diff
changeset
|
765 | gsize i; |
| 8849 | 766 | |
| 767 | if (!success) { | |
| 768 | /* The user did not trust the public key. */ | |
| 15884 | 769 | silcpurple_add_buddy_pk_no(r); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
770 | silc_free(r->offline_pk); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
771 | if (r->public_key) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
772 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 773 | silc_free(r); |
| 774 | return; | |
| 775 | } | |
| 776 | ||
| 777 | if (r->offline) { | |
| 778 | /* User is offline. Associate the imported public key with | |
| 779 | this user. */ | |
| 780 | fingerprint = silc_hash_fingerprint(NULL, r->offline_pk, | |
| 781 | r->offline_pk_len); | |
| 782 | for (i = 0; i < strlen(fingerprint); i++) | |
| 783 | if (fingerprint[i] == ' ') | |
| 784 | fingerprint[i] = '_'; | |
| 785 | g_snprintf(filename, sizeof(filename) - 1, | |
| 786 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 15884 | 787 | silcpurple_silcdir(), fingerprint); |
| 788 | purple_blist_node_set_string((PurpleBlistNode *)b, "public-key", filename); | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
789 | purple_protocol_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_OFFLINE, NULL); |
| 8849 | 790 | silc_free(fingerprint); |
| 791 | silc_free(r->offline_pk); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
792 | if (r->public_key) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
793 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 794 | silc_free(r); |
| 795 | return; | |
| 796 | } | |
| 797 | ||
| 798 | /* Get the client entry. */ | |
| 799 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 800 | &r->client_id); | |
| 801 | if (!client_entry) { | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
802 | silc_free(r->offline_pk); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
803 | silc_pkcs_public_key_free(r->public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
804 | if (r->public_key) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
805 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 806 | silc_free(r); |
| 807 | return; | |
| 808 | } | |
| 809 | ||
| 810 | memset(&vcard, 0, sizeof(vcard)); | |
| 811 | memset(&serverpk, 0, sizeof(serverpk)); | |
| 812 | memset(&usersign, 0, sizeof(usersign)); | |
| 813 | memset(&serversign, 0, sizeof(serversign)); | |
| 814 | ||
| 815 | /* Now that we have the public key and we trust it now we | |
| 816 | save the attributes of the buddy and update its status. */ | |
| 817 | ||
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
818 | if (client_entry->attrs) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
819 | silc_dlist_start(client_entry->attrs); |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
820 | while ((attr = silc_dlist_get(client_entry->attrs)) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
821 | != SILC_LIST_END) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
822 | attribute = silc_attribute_get_attribute(attr); |
| 8849 | 823 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
824 | switch (attribute) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
825 | case SILC_ATTRIBUTE_USER_INFO: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
826 | if (!silc_attribute_get_object(attr, (void *)&vcard, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
827 | sizeof(vcard))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
828 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
829 | break; |
| 8849 | 830 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
831 | case SILC_ATTRIBUTE_STATUS_MESSAGE: |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
832 | message = silc_mime_alloc(); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
833 | if (!silc_attribute_get_object(attr, (void *)message, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
834 | sizeof(*message))) |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
835 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
836 | break; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
837 | |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
838 | case SILC_ATTRIBUTE_EXTENSION: |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
839 | extension = silc_mime_alloc(); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
840 | if (!silc_attribute_get_object(attr, (void *)extension, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
841 | sizeof(*extension))) |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
842 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
843 | break; |
| 8849 | 844 | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
845 | case SILC_ATTRIBUTE_USER_ICON: |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
846 | usericon = silc_mime_alloc(); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
847 | if (!silc_attribute_get_object(attr, (void *)usericon, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
848 | sizeof(*usericon))) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
849 | continue; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
850 | break; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
851 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
852 | case SILC_ATTRIBUTE_SERVER_PUBLIC_KEY: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
853 | if (serverpk.type) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
854 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
855 | if (!silc_attribute_get_object(attr, (void *)&serverpk, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
856 | sizeof(serverpk))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
857 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
858 | break; |
| 8849 | 859 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
860 | case SILC_ATTRIBUTE_USER_DIGITAL_SIGNATURE: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
861 | if (usersign.data) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
862 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
863 | if (!silc_attribute_get_object(attr, (void *)&usersign, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
864 | sizeof(usersign))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
865 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
866 | break; |
| 8849 | 867 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
868 | case SILC_ATTRIBUTE_SERVER_DIGITAL_SIGNATURE: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
869 | if (serversign.data) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
870 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
871 | if (!silc_attribute_get_object(attr, (void *)&serversign, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
872 | sizeof(serversign))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
873 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
874 | break; |
| 8849 | 875 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
876 | default: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
877 | break; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
878 | } |
| 8849 | 879 | } |
| 880 | } | |
| 881 | ||
| 882 | /* Verify the attribute signatures */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
883 | silc_hash_alloc((const unsigned char *)"sha1", &hash); |
| 8849 | 884 | |
| 885 | if (usersign.data) { | |
| 886 | unsigned char *verifyd; | |
| 887 | SilcUInt32 verify_len; | |
| 888 | ||
| 889 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, | |
| 890 | FALSE, &verify_len); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
891 | if (verifyd && !silc_pkcs_verify(client_entry->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
892 | usersign.data, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
893 | usersign.data_len, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
894 | verifyd, verify_len, hash)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
895 | usign_success = FALSE; |
| 8849 | 896 | silc_free(verifyd); |
| 897 | } | |
| 898 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
899 | if (serversign.data) { |
| 8849 | 900 | SilcPublicKey public_key; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
901 | SilcPKCSType type = 0; |
| 8849 | 902 | unsigned char *verifyd; |
| 903 | SilcUInt32 verify_len; | |
| 904 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
905 | if (!strcmp(serverpk.type, "silc-rsa")) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
906 | type = SILC_PKCS_SILC; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
907 | else if (!strcmp(serverpk.type, "ssh-rsa")) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
908 | type = SILC_PKCS_SSH2; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
909 | else if (!strcmp(serverpk.type, "x509v3-sign-rsa")) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
910 | type = SILC_PKCS_X509V3; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
911 | else if (!strcmp(serverpk.type, "pgp-sign-rsa")) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
912 | type = SILC_PKCS_OPENPGP; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
913 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
914 | if (silc_pkcs_public_key_alloc(type, serverpk.data, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
915 | serverpk.data_len, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
916 | &public_key)) { |
| 8849 | 917 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, |
| 918 | TRUE, &verify_len); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
919 | if (verifyd && !silc_pkcs_verify(public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
920 | serversign.data, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
921 | serversign.data_len, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
922 | verifyd, verify_len, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
923 | hash)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
924 | ssign_success = FALSE; |
| 8849 | 925 | silc_pkcs_public_key_free(public_key); |
| 926 | silc_free(verifyd); | |
| 927 | } | |
| 928 | } | |
| 929 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
930 | fingerprint = silc_fingerprint(client_entry->fingerprint, 20); |
| 8849 | 931 | for (i = 0; i < strlen(fingerprint); i++) |
| 932 | if (fingerprint[i] == ' ') | |
| 933 | fingerprint[i] = '_'; | |
| 934 | ||
| 935 | if (usign_success || ssign_success) { | |
| 936 | struct passwd *pw; | |
| 937 | ||
| 938 | memset(filename2, 0, sizeof(filename2)); | |
| 939 | ||
| 940 | /* Filename for dir */ | |
| 941 | tmp = fingerprint + strlen(fingerprint) - 9; | |
| 942 | g_snprintf(filename, sizeof(filename) - 1, | |
| 943 | "%s" G_DIR_SEPARATOR_S "friends" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 944 | silcpurple_silcdir(), tmp); |
| 8849 | 945 | |
| 946 | pw = getpwuid(getuid()); | |
| 947 | if (!pw) | |
| 948 | return; | |
| 949 | ||
| 950 | /* Create dir if it doesn't exist */ | |
|
35995
d0bbb2dad7f3
Fix some CWE-367 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33787
diff
changeset
|
951 | if (pw->pw_uid == geteuid()) { |
|
d0bbb2dad7f3
Fix some CWE-367 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33787
diff
changeset
|
952 | if (g_mkdir(filename, 0755) != 0 && errno != EEXIST) |
|
d0bbb2dad7f3
Fix some CWE-367 coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33787
diff
changeset
|
953 | return; |
| 8849 | 954 | } |
| 955 | ||
| 956 | /* Save VCard */ | |
| 957 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 958 | "%s" G_DIR_SEPARATOR_S "vcard", filename); | |
| 959 | if (vcard.full_name) { | |
|
11488
d422a70bed74
[gaim-migrate @ 13730]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11338
diff
changeset
|
960 | tmp = (char *)silc_vcard_encode(&vcard, &len); |
| 8849 | 961 | silc_file_writefile(filename2, tmp, len); |
| 962 | silc_free(tmp); | |
| 963 | } | |
| 964 | ||
| 965 | /* Save status message */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
966 | if (message) { |
| 8849 | 967 | memset(filename2, 0, sizeof(filename2)); |
| 968 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 969 | "%s" G_DIR_SEPARATOR_S "status_message.mime", | |
| 970 | filename); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
971 | tmp = (char *)silc_mime_get_data(message, &len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
972 | silc_file_writefile(filename2, tmp, len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
973 | silc_mime_free(message); |
| 8849 | 974 | } |
| 975 | ||
| 976 | /* Save extension data */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
977 | if (extension) { |
| 8849 | 978 | memset(filename2, 0, sizeof(filename2)); |
| 979 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 980 | "%s" G_DIR_SEPARATOR_S "extension.mime", | |
| 981 | filename); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
982 | tmp = (char *)silc_mime_get_data(extension, &len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
983 | silc_file_writefile(filename2, tmp, len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
984 | silc_mime_free(extension); |
| 8849 | 985 | } |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
986 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
987 | /* Save user icon */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
988 | if (usericon) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
989 | const char *type = silc_mime_get_field(usericon, "Content-Type"); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
990 | if (type && |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
991 | (!strcmp(type, "image/jpeg") || |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
992 | !strcmp(type, "image/gif") || |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
993 | !strcmp(type, "image/bmp") || |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
994 | !strcmp(type, "image/png"))) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
995 | const unsigned char *data; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
996 | SilcUInt32 data_len; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
997 | data = silc_mime_get_data(usericon, &data_len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
998 | if (data) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
999 | /* TODO: Check if SILC gives us something to use as the checksum instead */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1000 | purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup(data, data_len), data_len, NULL); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1001 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1002 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1003 | silc_mime_free(usericon); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1004 | } |
| 8849 | 1005 | } |
| 1006 | ||
| 1007 | /* Save the public key path to buddy properties, as it is used | |
| 1008 | to identify the buddy in the network (and not the nickname). */ | |
| 1009 | memset(filename, 0, sizeof(filename)); | |
| 1010 | g_snprintf(filename, sizeof(filename) - 1, | |
| 1011 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 15884 | 1012 | silcpurple_silcdir(), fingerprint); |
| 1013 | purple_blist_node_set_string((PurpleBlistNode *)b, "public-key", filename); | |
| 8849 | 1014 | |
|
10050
78e480f768f2
[gaim-migrate @ 11011]
Dave West <kat@users.sourceforge.net>
parents:
10029
diff
changeset
|
1015 | /* Update online status */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1016 | purple_protocol_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_AVAILABLE, NULL); |
| 8849 | 1017 | |
| 1018 | /* Finally, start watching this user so we receive its status | |
| 1019 | changes from the server */ | |
| 1020 | g_snprintf(filename2, sizeof(filename2) - 1, "+%s", filename); | |
| 1021 | silc_client_command_call(r->client, r->conn, NULL, "WATCH", "-pubkey", | |
| 1022 | filename2, NULL); | |
| 1023 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1024 | silc_hash_free(hash); |
| 8849 | 1025 | silc_free(fingerprint); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1026 | silc_free(r->offline_pk); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1027 | if (r->public_key) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1028 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 1029 | silc_free(r); |
| 1030 | } | |
| 1031 | ||
| 1032 | static void | |
| 15884 | 1033 | silcpurple_add_buddy_ask_import(void *user_data, const char *name) |
| 8849 | 1034 | { |
| 15884 | 1035 | SilcPurpleBuddyRes r = (SilcPurpleBuddyRes)user_data; |
| 8849 | 1036 | |
| 1037 | /* Load the public key */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1038 | if (!silc_pkcs_load_public_key(name, &r->public_key)) { |
| 15884 | 1039 | silcpurple_add_buddy_ask_pk_cb(r, 0); |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1040 | purple_notify_error(r->client->application, _("Add Buddy"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1041 | _("Could not load public key"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1042 | purple_request_cpar_from_account( |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34333
diff
changeset
|
1043 | purple_buddy_get_account(r->b))); |
| 8849 | 1044 | return; |
| 1045 | } | |
| 1046 | ||
| 1047 | /* Now verify the public key */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1048 | r->offline_pk = silc_pkcs_public_key_encode(r->public_key, &r->offline_pk_len); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1049 | silcpurple_verify_public_key(r->client, r->conn, purple_buddy_get_name(r->b), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1050 | SILC_CONN_CLIENT, r->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1051 | silcpurple_add_buddy_save, r); |
| 8849 | 1052 | } |
| 1053 | ||
| 1054 | static void | |
| 15884 | 1055 | silcpurple_add_buddy_ask_pk_cancel(void *user_data, const char *name) |
| 8849 | 1056 | { |
| 15884 | 1057 | SilcPurpleBuddyRes r = (SilcPurpleBuddyRes)user_data; |
| 8849 | 1058 | |
| 1059 | /* The user did not import public key. The buddy is unusable. */ | |
| 15884 | 1060 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1061 | silc_free(r); |
| 1062 | } | |
| 1063 | ||
| 1064 | static void | |
| 15884 | 1065 | silcpurple_add_buddy_ask_pk_cb(SilcPurpleBuddyRes r, gint id) |
| 8849 | 1066 | { |
| 1067 | if (id != 0) { | |
| 1068 | /* The user did not import public key. The buddy is unusable. */ | |
| 15884 | 1069 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1070 | silc_free(r); |
| 1071 | return; | |
| 1072 | } | |
| 1073 | ||
| 1074 | /* Open file selector to select the public key. */ | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1075 | purple_request_file(r->client->application, _("Open..."), NULL, FALSE, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1076 | G_CALLBACK(silcpurple_add_buddy_ask_import), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1077 | G_CALLBACK(silcpurple_add_buddy_ask_pk_cancel), |
|
34333
b92698241603
Request API refactoring: switch purple_request_file to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
1078 | purple_request_cpar_from_account(purple_buddy_get_account(r->b)), r); |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
1079 | |
| 8849 | 1080 | } |
| 1081 | ||
| 1082 | static void | |
| 15884 | 1083 | silcpurple_add_buddy_ask_pk(SilcPurpleBuddyRes r) |
| 8849 | 1084 | { |
| 1085 | char tmp[512]; | |
| 1086 | g_snprintf(tmp, sizeof(tmp), _("The %s buddy is not present in the network"), | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1087 | purple_buddy_get_name(r->b)); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1088 | purple_request_action(r->client->application, _("Add Buddy"), tmp, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1089 | _("To add the buddy you must import his/her public key. " |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1090 | "Press Import to import a public key."), 0, |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
1091 | purple_request_cpar_from_account(purple_buddy_get_account(r->b)), r, 2, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1092 | _("Cancel"), G_CALLBACK(silcpurple_add_buddy_ask_pk_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1093 | _("_Import..."), G_CALLBACK(silcpurple_add_buddy_ask_pk_cb)); |
| 8849 | 1094 | } |
| 1095 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1096 | static SilcBool |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1097 | silcpurple_add_buddy_getkey_cb(SilcClient client, SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1098 | SilcCommand command, SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1099 | SilcStatus error, void *context, va_list ap) |
| 8849 | 1100 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1101 | SilcPurpleBuddyRes r = context; |
| 8849 | 1102 | SilcClientEntry client_entry; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1103 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1104 | if (status != SILC_STATUS_OK) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1105 | /* The buddy is offline/nonexistent. We will require user |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1106 | to associate a public key with the buddy or the buddy |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1107 | cannot be added. */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1108 | r->offline = TRUE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1109 | silcpurple_add_buddy_ask_pk(r); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1110 | return FALSE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1111 | } |
| 8849 | 1112 | |
| 1113 | /* Get the client entry. */ | |
| 1114 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 1115 | &r->client_id); | |
| 1116 | if (!client_entry || !client_entry->public_key) { | |
| 1117 | /* The buddy is offline/nonexistent. We will require user | |
| 1118 | to associate a public key with the buddy or the buddy | |
| 1119 | cannot be added. */ | |
| 1120 | r->offline = TRUE; | |
| 15884 | 1121 | silcpurple_add_buddy_ask_pk(r); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1122 | return FALSE; |
| 8849 | 1123 | } |
| 1124 | ||
| 1125 | /* Now verify the public key */ | |
| 15884 | 1126 | silcpurple_verify_public_key(r->client, r->conn, client_entry->nickname, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1127 | SILC_CONN_CLIENT, client_entry->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1128 | silcpurple_add_buddy_save, r); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1129 | return TRUE; |
| 8849 | 1130 | } |
| 1131 | ||
| 1132 | static void | |
| 15884 | 1133 | silcpurple_add_buddy_select_cb(SilcPurpleBuddyRes r, PurpleRequestFields *fields) |
| 8849 | 1134 | { |
| 15884 | 1135 | PurpleRequestField *f; |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
17680
diff
changeset
|
1136 | GList *list; |
| 8849 | 1137 | SilcClientEntry client_entry; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1138 | SilcDList clients; |
| 8849 | 1139 | |
| 15884 | 1140 | f = purple_request_fields_get_field(fields, "list"); |
| 1141 | list = purple_request_field_list_get_selected(f); | |
| 8849 | 1142 | if (!list) { |
| 1143 | /* The user did not select any user. */ | |
| 15884 | 1144 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1145 | silc_free(r); |
| 1146 | return; | |
| 1147 | } | |
| 1148 | ||
| 15884 | 1149 | client_entry = purple_request_field_list_get_data(f, list->data); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1150 | clients = silc_dlist_init(); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1151 | silc_dlist_add(clients, client_entry); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1152 | silcpurple_add_buddy_resolved(r->client, r->conn, SILC_STATUS_OK, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1153 | clients, r); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1154 | silc_dlist_uninit(clients); |
| 8849 | 1155 | } |
| 1156 | ||
| 1157 | static void | |
| 15884 | 1158 | silcpurple_add_buddy_select_cancel(SilcPurpleBuddyRes r, PurpleRequestFields *fields) |
| 8849 | 1159 | { |
| 1160 | /* The user did not select any user. */ | |
| 15884 | 1161 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1162 | silc_free(r); |
| 1163 | } | |
| 1164 | ||
| 1165 | static void | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1166 | silcpurple_add_buddy_select(SilcPurpleBuddyRes r, SilcDList clients) |
| 8849 | 1167 | { |
| 15884 | 1168 | PurpleRequestFields *fields; |
| 1169 | PurpleRequestFieldGroup *g; | |
| 1170 | PurpleRequestField *f; | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1171 | char tmp[512], tmp2[128]; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1172 | char *fingerprint; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1173 | SilcClientEntry client_entry; |
| 8849 | 1174 | |
| 15884 | 1175 | fields = purple_request_fields_new(); |
| 1176 | g = purple_request_field_group_new(NULL); | |
| 1177 | f = purple_request_field_list_new("list", NULL); | |
| 1178 | purple_request_field_group_add_field(g, f); | |
| 1179 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 1180 | purple_request_fields_add_group(fields, g); | |
| 8849 | 1181 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1182 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1183 | while ((client_entry = silc_dlist_get(clients))) { |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1184 | fingerprint = NULL; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1185 | if (*client_entry->fingerprint) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1186 | fingerprint = silc_fingerprint(client_entry->fingerprint, 20); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1187 | g_snprintf(tmp2, sizeof(tmp2), "\n%s", fingerprint); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1188 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1189 | g_snprintf(tmp, sizeof(tmp), "%s - %s (%s@%s)%s", |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1190 | client_entry->realname, client_entry->nickname, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1191 | client_entry->username, *client_entry->hostname ? |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1192 | client_entry->hostname : "", |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1193 | fingerprint ? tmp2 : ""); |
|
24900
a19d983918c2
Deprecate purple_request_field_list_add()
Richard Laager <rlaager@pidgin.im>
parents:
23196
diff
changeset
|
1194 | purple_request_field_list_add_icon(f, tmp, NULL, client_entry); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1195 | silc_free(fingerprint); |
| 8849 | 1196 | } |
| 1197 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1198 | purple_request_fields(r->client->application, _("Add Buddy"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1199 | _("Select correct user"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1200 | r->pubkey_search |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1201 | ? _("More than one user was found with the same public key. Select " |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1202 | "the correct user from the list to add to the buddy list.") |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1203 | : _("More than one user was found with the same name. Select " |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1204 | "the correct user from the list to add to the buddy list."), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1205 | fields, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1206 | _("OK"), G_CALLBACK(silcpurple_add_buddy_select_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1207 | _("Cancel"), G_CALLBACK(silcpurple_add_buddy_select_cancel), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
1208 | purple_request_cpar_from_account(purple_buddy_get_account(r->b)), r); |
| 8849 | 1209 | } |
| 1210 | ||
| 1211 | static void | |
| 15884 | 1212 | silcpurple_add_buddy_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1213 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1214 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1215 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1216 | void *context) |
| 8849 | 1217 | { |
| 15884 | 1218 | SilcPurpleBuddyRes r = context; |
| 1219 | PurpleBuddy *b = r->b; | |
| 8849 | 1220 | SilcAttributePayload pub; |
| 1221 | SilcAttributeObjPk userpk; | |
| 1222 | const char *filename; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1223 | SilcClientEntry client_entry = NULL; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1224 | SilcUInt16 cmd_ident; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1225 | const char *name; |
| 8849 | 1226 | |
| 15884 | 1227 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1228 | |
| 8849 | 1229 | /* If the buddy is offline/nonexistent, we will require user |
| 1230 | to associate a public key with the buddy or the buddy | |
| 1231 | cannot be added. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1232 | if (!clients) { |
| 8849 | 1233 | if (r->init) { |
| 1234 | silc_free(r); | |
| 1235 | return; | |
| 1236 | } | |
| 1237 | ||
| 1238 | r->offline = TRUE; | |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1239 | /* If the user has already associated a public key, try loading it |
|
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1240 | * before prompting the user to load it again */ |
|
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1241 | if (filename != NULL) |
| 15884 | 1242 | silcpurple_add_buddy_ask_import(r, filename); |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1243 | else |
| 15884 | 1244 | silcpurple_add_buddy_ask_pk(r); |
| 8849 | 1245 | return; |
| 1246 | } | |
| 1247 | ||
| 1248 | /* If more than one client was found with nickname, we need to verify | |
| 1249 | from user which one is the correct. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1250 | if (silc_dlist_count(clients) > 1 && !r->pubkey_search) { |
| 8849 | 1251 | if (r->init) { |
| 1252 | silc_free(r); | |
| 1253 | return; | |
| 1254 | } | |
| 1255 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1256 | silcpurple_add_buddy_select(r, clients); |
| 8849 | 1257 | return; |
| 1258 | } | |
| 1259 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1260 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1261 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1262 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1263 | name = purple_buddy_get_name(b); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1264 | |
| 8849 | 1265 | /* If we searched using public keys and more than one entry was found |
| 1266 | the same person is logged on multiple times. */ | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1267 | if (silc_dlist_count(clients) > 1 && r->pubkey_search && name) { |
| 8849 | 1268 | if (r->init) { |
| 1269 | /* Find the entry that closest matches to the | |
| 1270 | buddy nickname. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1271 | SilcClientEntry entry; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1272 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1273 | while ((entry = silc_dlist_get(clients))) { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1274 | if (!g_ascii_strncasecmp(name, entry->nickname, |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1275 | strlen(name))) { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1276 | client_entry = entry; |
| 8849 | 1277 | break; |
| 1278 | } | |
| 1279 | } | |
| 1280 | } else { | |
| 1281 | /* Verify from user which one is correct */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1282 | silcpurple_add_buddy_select(r, clients); |
| 8849 | 1283 | return; |
| 1284 | } | |
| 1285 | } | |
| 1286 | ||
|
35696
93b8292b2779
Fix remaining clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35681
diff
changeset
|
1287 | g_return_if_fail(client_entry != NULL); |
|
93b8292b2779
Fix remaining clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35681
diff
changeset
|
1288 | |
| 8849 | 1289 | /* The client was found. Now get its public key and verify |
| 1290 | that before adding the buddy. */ | |
| 1291 | memset(&userpk, 0, sizeof(userpk)); | |
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
1292 | purple_buddy_set_protocol_data(b, silc_memdup(&client_entry->id, sizeof(client_entry->id))); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1293 | r->client_id = client_entry->id; |
| 8849 | 1294 | |
| 1295 | /* Get the public key from attributes, if not present then | |
| 1296 | resolve it with GETKEY unless we have it cached already. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1297 | if (client_entry->attrs && !client_entry->public_key) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1298 | pub = silcpurple_get_attr(client_entry->attrs, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1299 | SILC_ATTRIBUTE_USER_PUBLIC_KEY); |
| 8849 | 1300 | if (!pub || !silc_attribute_get_object(pub, (void *)&userpk, |
| 1301 | sizeof(userpk))) { | |
| 1302 | /* Get public key with GETKEY */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1303 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1304 | silc_client_command_call(client, conn, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1305 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1306 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1307 | cmd_ident, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1308 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1309 | r); |
| 1310 | return; | |
| 1311 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1312 | if (!silc_pkcs_public_key_alloc(SILC_PKCS_SILC, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1313 | userpk.data, userpk.data_len, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1314 | &client_entry->public_key)) |
| 8849 | 1315 | return; |
| 1316 | silc_free(userpk.data); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1317 | } else if (filename && !client_entry->public_key) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1318 | if (!silc_pkcs_load_public_key(filename, &client_entry->public_key)) { |
| 8849 | 1319 | /* Get public key with GETKEY */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1320 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1321 | silc_client_command_call(client, conn, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1322 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1323 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1324 | cmd_ident, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1325 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1326 | r); |
| 1327 | return; | |
| 1328 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1329 | } else if (!client_entry->public_key) { |
| 8849 | 1330 | /* Get public key with GETKEY */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1331 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1332 | silc_client_command_call(client, conn, NULL, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1333 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1334 | silc_client_command_pending(conn, SILC_COMMAND_GETKEY, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1335 | cmd_ident, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1336 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1337 | r); |
| 1338 | return; | |
| 1339 | } | |
| 1340 | ||
| 1341 | /* We have the public key, verify it. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1342 | silcpurple_verify_public_key(client, conn, client_entry->nickname, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1343 | SILC_CONN_CLIENT, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1344 | client_entry->public_key, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1345 | silcpurple_add_buddy_save, r); |
| 8849 | 1346 | } |
| 1347 | ||
| 1348 | static void | |
| 15884 | 1349 | silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init) |
| 8849 | 1350 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1351 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1352 | SilcClient client = sg->client; |
| 1353 | SilcClientConnection conn = sg->conn; | |
| 15884 | 1354 | SilcPurpleBuddyRes r; |
| 8849 | 1355 | SilcBuffer attrs; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1356 | const char *filename, *name = purple_buddy_get_name(b); |
| 8849 | 1357 | |
| 1358 | r = silc_calloc(1, sizeof(*r)); | |
| 1359 | if (!r) | |
| 1360 | return; | |
| 1361 | r->client = client; | |
| 1362 | r->conn = conn; | |
| 1363 | r->b = b; | |
| 1364 | r->init = init; | |
| 1365 | ||
| 1366 | /* See if we have this buddy's public key. If we do use that | |
| 1367 | to search the details. */ | |
| 15884 | 1368 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
| 8849 | 1369 | if (filename) { |
| 1370 | SilcPublicKey public_key; | |
| 1371 | SilcAttributeObjPk userpk; | |
| 1372 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1373 | if (!silc_pkcs_load_public_key(filename, &public_key)) |
| 8849 | 1374 | return; |
| 1375 | ||
| 1376 | /* Get all attributes, and use the public key to search user */ | |
| 1377 | name = NULL; | |
| 1378 | attrs = silc_client_attributes_request(SILC_ATTRIBUTE_USER_INFO, | |
| 1379 | SILC_ATTRIBUTE_SERVICE, | |
| 1380 | SILC_ATTRIBUTE_STATUS_MOOD, | |
| 1381 | SILC_ATTRIBUTE_STATUS_FREETEXT, | |
| 1382 | SILC_ATTRIBUTE_STATUS_MESSAGE, | |
| 1383 | SILC_ATTRIBUTE_PREFERRED_LANGUAGE, | |
| 1384 | SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
| 1385 | SILC_ATTRIBUTE_TIMEZONE, | |
| 1386 | SILC_ATTRIBUTE_GEOLOCATION, | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1387 | SILC_ATTRIBUTE_USER_ICON, |
| 8849 | 1388 | SILC_ATTRIBUTE_DEVICE_INFO, 0); |
| 1389 | userpk.type = "silc-rsa"; | |
| 1390 | userpk.data = silc_pkcs_public_key_encode(public_key, &userpk.data_len); | |
| 1391 | attrs = silc_attribute_payload_encode(attrs, | |
| 1392 | SILC_ATTRIBUTE_USER_PUBLIC_KEY, | |
| 1393 | SILC_ATTRIBUTE_FLAG_VALID, | |
| 1394 | &userpk, sizeof(userpk)); | |
| 1395 | silc_free(userpk.data); | |
| 1396 | silc_pkcs_public_key_free(public_key); | |
| 1397 | r->pubkey_search = TRUE; | |
| 1398 | } else { | |
| 1399 | /* Get all attributes */ | |
| 1400 | attrs = silc_client_attributes_request(0); | |
| 1401 | } | |
| 1402 | ||
| 1403 | /* Resolve */ | |
| 1404 | silc_client_get_clients_whois(client, conn, name, NULL, attrs, | |
| 15884 | 1405 | silcpurple_add_buddy_resolved, r); |
| 8849 | 1406 | silc_buffer_free(attrs); |
| 1407 | } | |
| 1408 | ||
|
32320
75839f9d761c
silc: Fix build and update for API changes
Paul Aurich <darkrain42@pidgin.im>
parents:
32281
diff
changeset
|
1409 | void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message) |
| 8849 | 1410 | { |
|
25504
de6d3ee7d064
Properly don't re-add buddies in SILC
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
1411 | /* Don't add if the buddy is already on the list. |
|
de6d3ee7d064
Properly don't re-add buddies in SILC
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
1412 | * |
|
de6d3ee7d064
Properly don't re-add buddies in SILC
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
1413 | * SILC doesn't have groups, so we also don't need to do anything |
|
de6d3ee7d064
Properly don't re-add buddies in SILC
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
1414 | * for a move. */ |
|
26538
8f944369c8cb
Use purple_buddy_get_protocol_data instead of ->proto_data
Paul Aurich <darkrain42@pidgin.im>
parents:
26091
diff
changeset
|
1415 | if (purple_buddy_get_protocol_data(buddy) == NULL) |
|
25504
de6d3ee7d064
Properly don't re-add buddies in SILC
Paul Aurich <darkrain42@pidgin.im>
parents:
23196
diff
changeset
|
1416 | silcpurple_add_buddy_i(gc, buddy, FALSE); |
| 8849 | 1417 | } |
| 1418 | ||
| 15884 | 1419 | void silcpurple_send_buddylist(PurpleConnection *gc) |
|
10341
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1420 | { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26538
diff
changeset
|
1421 | GSList *buddies; |
| 15884 | 1422 | PurpleAccount *account; |
|
12111
a939a3c185f9
[gaim-migrate @ 14411]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12058
diff
changeset
|
1423 | |
| 15884 | 1424 | account = purple_connection_get_account(gc); |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1425 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
1426 | for (buddies = purple_blist_find_buddies(account, NULL); buddies; |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26538
diff
changeset
|
1427 | buddies = g_slist_delete_link(buddies, buddies)) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1428 | { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26538
diff
changeset
|
1429 | PurpleBuddy *buddy = buddies->data; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
26538
diff
changeset
|
1430 | silcpurple_add_buddy_i(gc, buddy, TRUE); |
|
10341
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1431 | } |
|
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1432 | } |
|
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1433 | |
| 15884 | 1434 | void silcpurple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 1435 | PurpleGroup *group) | |
| 8849 | 1436 | { |
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
1437 | silc_free(purple_buddy_get_protocol_data(buddy)); |
| 8849 | 1438 | } |
| 1439 | ||
| 15884 | 1440 | void silcpurple_idle_set(PurpleConnection *gc, int idle) |
| 8849 | 1441 | |
| 1442 | { | |
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1443 | SilcPurple sg; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1444 | SilcClient client; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1445 | SilcClientConnection conn; |
| 8849 | 1446 | SilcAttributeObjService service; |
| 1447 | const char *server; | |
| 1448 | int port; | |
| 1449 | ||
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1450 | sg = purple_connection_get_protocol_data(gc); |
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1451 | if (sg == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1452 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1453 | |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1454 | client = sg->client; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1455 | if (client == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1456 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1457 | |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1458 | conn = sg->conn; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1459 | if (conn == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1460 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1461 | |
| 15884 | 1462 | server = purple_account_get_string(sg->account, "server", |
| 8849 | 1463 | "silc.silcnet.org"); |
| 15884 | 1464 | port = purple_account_get_int(sg->account, "port", 706), |
| 8849 | 1465 | |
| 1466 | memset(&service, 0, sizeof(service)); | |
| 1467 | silc_client_attribute_del(client, conn, | |
| 1468 | SILC_ATTRIBUTE_SERVICE, NULL); | |
| 1469 | service.port = port; | |
| 1470 | g_snprintf(service.address, sizeof(service.address), "%s", server); | |
| 1471 | service.idle = idle; | |
| 1472 | silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_SERVICE, | |
| 1473 | &service, sizeof(service)); | |
| 1474 | } | |
| 1475 | ||
| 15884 | 1476 | char *silcpurple_status_text(PurpleBuddy *b) |
| 8849 | 1477 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1478 | PurpleAccount *account = purple_buddy_get_account(b); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1479 | PurpleConnection *gc = purple_account_get_connection(account); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1480 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1481 | SilcClient client = sg->client; |
| 1482 | SilcClientConnection conn = sg->conn; | |
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
1483 | SilcClientID *client_id = purple_buddy_get_protocol_data(b); |
| 8849 | 1484 | SilcClientEntry client_entry; |
| 1485 | SilcAttributePayload attr; | |
| 1486 | SilcAttributeMood mood = 0; | |
| 1487 | ||
| 1488 | /* Get the client entry. */ | |
| 1489 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1490 | if (!client_entry) | |
| 1491 | return NULL; | |
| 1492 | ||
| 1493 | /* If user is online, we show the mood status, if available. | |
| 1494 | If user is offline or away that status is indicated. */ | |
| 1495 | ||
| 1496 | if (client_entry->mode & SILC_UMODE_DETACHED) | |
| 1497 | return g_strdup(_("Detached")); | |
| 1498 | if (client_entry->mode & SILC_UMODE_GONE) | |
| 1499 | return g_strdup(_("Away")); | |
| 1500 | if (client_entry->mode & SILC_UMODE_INDISPOSED) | |
| 1501 | return g_strdup(_("Indisposed")); | |
| 1502 | if (client_entry->mode & SILC_UMODE_BUSY) | |
| 1503 | return g_strdup(_("Busy")); | |
| 1504 | if (client_entry->mode & SILC_UMODE_PAGE) | |
| 1505 | return g_strdup(_("Wake Me Up")); | |
| 1506 | if (client_entry->mode & SILC_UMODE_HYPER) | |
| 1507 | return g_strdup(_("Hyper Active")); | |
| 1508 | if (client_entry->mode & SILC_UMODE_ROBOT) | |
| 1509 | return g_strdup(_("Robot")); | |
| 1510 | ||
| 15884 | 1511 | attr = silcpurple_get_attr(client_entry->attrs, SILC_ATTRIBUTE_STATUS_MOOD); |
| 8849 | 1512 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { |
| 1513 | /* The mood is a bit mask, so we could show multiple moods, | |
| 1514 | but let's show only one for now. */ | |
| 1515 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) | |
| 1516 | return g_strdup(_("Happy")); | |
| 1517 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) | |
| 1518 | return g_strdup(_("Sad")); | |
| 1519 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) | |
| 1520 | return g_strdup(_("Angry")); | |
| 1521 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) | |
| 1522 | return g_strdup(_("Jealous")); | |
| 1523 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) | |
| 1524 | return g_strdup(_("Ashamed")); | |
| 1525 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) | |
| 1526 | return g_strdup(_("Invincible")); | |
| 1527 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) | |
| 1528 | return g_strdup(_("In Love")); | |
| 1529 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) | |
| 1530 | return g_strdup(_("Sleepy")); | |
| 1531 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) | |
| 1532 | return g_strdup(_("Bored")); | |
| 1533 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) | |
| 1534 | return g_strdup(_("Excited")); | |
| 1535 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) | |
| 1536 | return g_strdup(_("Anxious")); | |
| 1537 | } | |
| 1538 | ||
| 1539 | return NULL; | |
| 1540 | } | |
| 1541 | ||
| 15884 | 1542 | void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 8849 | 1543 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1544 | PurpleAccount *account = purple_buddy_get_account(b); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1545 | PurpleConnection *gc = purple_account_get_connection(account); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1546 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1547 | SilcClient client = sg->client; |
| 1548 | SilcClientConnection conn = sg->conn; | |
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
1549 | SilcClientID *client_id = purple_buddy_get_protocol_data(b); |
| 8849 | 1550 | SilcClientEntry client_entry; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1551 | char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; |
| 8849 | 1552 | char tmp[256]; |
| 1553 | ||
| 1554 | /* Get the client entry. */ | |
| 1555 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1556 | if (!client_entry) | |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1557 | return; |
| 8849 | 1558 | |
|
33796
4854740e5277
Merge with release-2.x.y (lots of conflicts, but all trivially resolved)
Daniel Atallah <datallah@pidgin.im>
diff
changeset
|
1559 | /* TODO: Check whether it's correct to call add_pair_html, |
|
4854740e5277
Merge with release-2.x.y (lots of conflicts, but all trivially resolved)
Daniel Atallah <datallah@pidgin.im>
diff
changeset
|
1560 | or if we should be using add_pair_plaintext */ |
|
4854740e5277
Merge with release-2.x.y (lots of conflicts, but all trivially resolved)
Daniel Atallah <datallah@pidgin.im>
diff
changeset
|
1561 | purple_notify_user_info_add_pair_html(user_info, _("Nickname"), client_entry->nickname); |
|
33787
eb88fd4cbced
Remove various array comparisons to NULL because they're silly
Daniel Atallah <datallah@pidgin.im>
parents:
29304
diff
changeset
|
1562 | g_snprintf(tmp, sizeof(tmp), "%s@%s", client_entry->username, client_entry->hostname); |
|
33796
4854740e5277
Merge with release-2.x.y (lots of conflicts, but all trivially resolved)
Daniel Atallah <datallah@pidgin.im>
diff
changeset
|
1563 | /* TODO: Check whether it's correct to call add_pair_html, |
|
4854740e5277
Merge with release-2.x.y (lots of conflicts, but all trivially resolved)
Daniel Atallah <datallah@pidgin.im>
diff
changeset
|
1564 | or if we should be using add_pair_plaintext */ |
|
4854740e5277
Merge with release-2.x.y (lots of conflicts, but all trivially resolved)
Daniel Atallah <datallah@pidgin.im>
diff
changeset
|
1565 | purple_notify_user_info_add_pair_html(user_info, _("Username"), tmp); |
| 8849 | 1566 | if (client_entry->mode) { |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1567 | memset(tmp, 0, sizeof(tmp)); |
| 15884 | 1568 | silcpurple_get_umode_string(client_entry->mode, |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1569 | tmp, sizeof(tmp) - strlen(tmp)); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1570 | purple_notify_user_info_add_pair_plaintext(user_info, _("User Modes"), tmp); |
| 8849 | 1571 | } |
| 1572 | ||
| 15884 | 1573 | silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1574 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1575 | if (statusstr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1576 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1577 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1578 | purple_notify_user_info_add_pair_html(user_info, _("Message"), statusstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1579 | g_free(statusstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1580 | } |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1581 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1582 | if (full) { |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1583 | if (moodstr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1584 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1585 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1586 | purple_notify_user_info_add_pair_html(user_info, _("Mood"), moodstr); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1587 | g_free(moodstr); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1588 | } |
| 8849 | 1589 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1590 | if (contactstr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1591 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1592 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1593 | purple_notify_user_info_add_pair_html(user_info, _("Preferred Contact"), contactstr); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1594 | g_free(contactstr); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1595 | } |
| 8849 | 1596 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1597 | if (langstr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1598 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1599 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1600 | purple_notify_user_info_add_pair_html(user_info, _("Preferred Language"), langstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1601 | g_free(langstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1602 | } |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1603 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1604 | if (devicestr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1605 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1606 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1607 | purple_notify_user_info_add_pair_html(user_info, _("Device"), devicestr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1608 | g_free(devicestr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1609 | } |
| 8849 | 1610 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1611 | if (tzstr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1612 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1613 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1614 | purple_notify_user_info_add_pair_html(user_info, _("Timezone"), tzstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1615 | g_free(tzstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1616 | } |
| 8849 | 1617 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1618 | if (geostr) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1619 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
29304
diff
changeset
|
1620 | or if we should be using add_pair_plaintext */ |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32188
diff
changeset
|
1621 | purple_notify_user_info_add_pair_html(user_info, _("Geolocation"), geostr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1622 | g_free(geostr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1623 | } |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1624 | } |
| 8849 | 1625 | } |
| 1626 | ||
| 1627 | static void | |
| 15884 | 1628 | silcpurple_buddy_kill(PurpleBlistNode *node, gpointer data) |
| 8849 | 1629 | { |
| 15884 | 1630 | PurpleBuddy *b; |
| 1631 | PurpleConnection *gc; | |
| 1632 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1633 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34635
diff
changeset
|
1634 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1635 | |
| 15884 | 1636 | b = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1637 | gc = purple_account_get_connection(purple_buddy_get_account(b)); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1638 | sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1639 | |
| 1640 | /* Call KILL */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1641 | silc_client_command_call(sg->client, sg->conn, NULL, "KILL", |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1642 | purple_buddy_get_name(b), "Killed by operator", NULL); |
| 8849 | 1643 | } |
| 1644 | ||
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1645 | typedef struct { |
| 15884 | 1646 | SilcPurple sg; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1647 | SilcClientEntry client_entry; |
| 15884 | 1648 | } *SilcPurpleBuddyWb; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1649 | |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1650 | static void |
| 15884 | 1651 | silcpurple_buddy_wb(PurpleBlistNode *node, gpointer data) |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1652 | { |
| 15884 | 1653 | SilcPurpleBuddyWb wb = data; |
| 1654 | silcpurple_wb_init(wb->sg, wb->client_entry); | |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1655 | silc_free(wb); |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1656 | } |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1657 | |
| 15884 | 1658 | GList *silcpurple_buddy_menu(PurpleBuddy *buddy) |
| 8849 | 1659 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1660 | PurpleAccount *account = purple_buddy_get_account(buddy); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1661 | PurpleConnection *gc = purple_account_get_connection(account); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1662 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1663 | SilcClientConnection conn = sg->conn; |
| 1664 | const char *pkfile = NULL; | |
| 1665 | SilcClientEntry client_entry = NULL; | |
| 15884 | 1666 | PurpleMenuAction *act; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1667 | GList *m = NULL; |
| 15884 | 1668 | SilcPurpleBuddyWb wb; |
| 8849 | 1669 | |
| 15884 | 1670 | pkfile = purple_blist_node_get_string((PurpleBlistNode *) buddy, "public-key"); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1671 | client_entry = silc_client_get_client_by_id(sg->client, |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1672 | sg->conn, |
|
24946
390536329dc5
Some more PurpleBuddy::proto_data related changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
1673 | purple_buddy_get_protocol_data(buddy)); |
| 8849 | 1674 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1675 | if (client_entry && |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1676 | silc_client_private_message_key_is_set(sg->client, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1677 | sg->conn, client_entry)) { |
| 15884 | 1678 | act = purple_menu_action_new(_("Reset IM Key"), |
| 1679 | PURPLE_CALLBACK(silcpurple_buddy_resetkey), | |
| 12919 | 1680 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1681 | m = g_list_append(m, act); |
| 8849 | 1682 | } else { |
| 15884 | 1683 | act = purple_menu_action_new(_("IM with Key Exchange"), |
| 1684 | PURPLE_CALLBACK(silcpurple_buddy_keyagr), | |
| 12919 | 1685 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1686 | m = g_list_append(m, act); |
| 8849 | 1687 | |
| 15884 | 1688 | act = purple_menu_action_new(_("IM with Password"), |
| 1689 | PURPLE_CALLBACK(silcpurple_buddy_privkey_menu), | |
| 12919 | 1690 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1691 | m = g_list_append(m, act); |
| 8849 | 1692 | } |
| 1693 | ||
| 1694 | if (pkfile) { | |
| 15884 | 1695 | act = purple_menu_action_new(_("Show Public Key"), |
| 1696 | PURPLE_CALLBACK(silcpurple_buddy_showkey), | |
| 12919 | 1697 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1698 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1699 | |
| 8849 | 1700 | } else { |
| 15884 | 1701 | act = purple_menu_action_new(_("Get Public Key..."), |
| 1702 | PURPLE_CALLBACK(silcpurple_buddy_getkey_menu), | |
| 12919 | 1703 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1704 | m = g_list_append(m, act); |
| 8849 | 1705 | } |
| 1706 | ||
| 1707 | if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { | |
| 15884 | 1708 | act = purple_menu_action_new(_("Kill User"), |
| 1709 | PURPLE_CALLBACK(silcpurple_buddy_kill), | |
| 12919 | 1710 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1711 | m = g_list_append(m, act); |
| 8849 | 1712 | } |
| 1713 | ||
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1714 | if (client_entry) { |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1715 | wb = silc_calloc(1, sizeof(*wb)); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1716 | wb->sg = sg; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1717 | wb->client_entry = client_entry; |
| 15884 | 1718 | act = purple_menu_action_new(_("Draw On Whiteboard"), |
| 1719 | PURPLE_CALLBACK(silcpurple_buddy_wb), | |
| 12919 | 1720 | (void *)wb, NULL); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1721 | m = g_list_append(m, act); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1722 | } |
| 8849 | 1723 | return m; |
| 1724 | } | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1725 | |
|
35833
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1726 | void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleImage *img) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1727 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1728 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1729 | SilcClient client = sg->client; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1730 | SilcClientConnection conn = sg->conn; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1731 | SilcMime mime; |
|
35833
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1732 | const gchar *type; |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1733 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1734 | /* Remove */ |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1735 | if (!img) { |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1736 | silc_client_attribute_del(client, conn, |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1737 | SILC_ATTRIBUTE_USER_ICON, NULL); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1738 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1739 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1740 | |
|
35833
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1741 | type = purple_image_get_mimetype(img); |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1742 | if (type == NULL) |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1743 | return; |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1744 | if (g_strcmp0(purple_image_get_extension(img), "ico") == 0) |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1745 | return; |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1746 | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1747 | /* Add */ |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1748 | mime = silc_mime_alloc(); |
|
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1749 | if (!mime) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1750 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1751 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1752 | silc_mime_add_field(mime, "Content-Type", type); |
|
35833
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1753 | silc_mime_add_data(mime, purple_image_get_data(img), |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1754 | purple_image_get_size(img)); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1755 | |
|
35833
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1756 | silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_USER_ICON, |
|
a7bfc2479cbd
imgstore: unref silc; fix inline images in silc
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35696
diff
changeset
|
1757 | mime, sizeof(*mime)); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1758 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1759 | silc_mime_free(mime); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1760 | } |