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