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