Sat, 27 Sep 2008 06:33:42 +0000
Start hiding blist.h internals in prpls.
| 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. */ | |
| 15884 | 692 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
| 8849 | 693 | if (filename) { |
| 694 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 695 | command reply. */ | |
| 696 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 697 | "-details", "-pubkey", filename, NULL); | |
| 698 | return; | |
| 699 | } | |
| 700 | ||
| 701 | if (!b->proto_data) { | |
| 702 | g_snprintf(tmp, sizeof(tmp), | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
703 | _("User %s is not present in the network"), purple_buddy_get_name(b)); |
| 15884 | 704 | purple_notify_error(gc, _("User Information"), |
| 8849 | 705 | _("Cannot get user information"), tmp); |
| 706 | return; | |
| 707 | } | |
| 708 | ||
| 709 | client_entry = silc_client_get_client_by_id(client, conn, b->proto_data); | |
| 710 | if (client_entry) { | |
| 711 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 712 | command reply. */ | |
| 713 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 714 | client_entry->nickname, "-details", NULL); | |
| 715 | } | |
| 716 | } else { | |
| 717 | /* Call WHOIS just with nickname. */ | |
| 718 | silc_client_command_call(client, conn, NULL, "WHOIS", nick, NULL); | |
| 719 | } | |
| 720 | } | |
| 721 | ||
| 722 | static void | |
| 15884 | 723 | silcpurple_add_buddy_pk_no(SilcPurpleBuddyRes r) |
| 8849 | 724 | { |
| 725 | char tmp[512]; | |
| 726 | 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
|
727 | purple_buddy_get_name(r->b)); |
| 15884 | 728 | 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
|
729 | _("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
|
730 | "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
|
731 | "command to get the public key.")); |
| 15884 | 732 | purple_prpl_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_OFFLINE, NULL); |
| 8849 | 733 | } |
| 734 | ||
| 735 | 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
|
736 | silcpurple_add_buddy_save(SilcBool success, void *context) |
| 8849 | 737 | { |
| 15884 | 738 | SilcPurpleBuddyRes r = context; |
| 739 | PurpleBuddy *b = r->b; | |
| 8849 | 740 | SilcClientEntry client_entry; |
| 741 | SilcAttributePayload attr; | |
| 742 | SilcAttribute attribute; | |
| 743 | 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
|
744 | 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
|
745 | SilcMime usericon = NULL; |
| 8849 | 746 | SilcAttributeObjPk serverpk, usersign, serversign; |
| 747 | gboolean usign_success = TRUE, ssign_success = TRUE; | |
|
11165
770e5d7940a0
[gaim-migrate @ 13266]
Mark Doliner <markdoliner@pidgin.im>
parents:
10869
diff
changeset
|
748 | char filename[512], filename2[512], *fingerprint = NULL, *tmp; |
| 8849 | 749 | 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
|
750 | SilcHash hash; |
| 8849 | 751 | int i; |
| 752 | ||
| 753 | if (!success) { | |
| 754 | /* The user did not trust the public key. */ | |
| 15884 | 755 | 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
|
756 | 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
|
757 | 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
|
758 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 759 | silc_free(r); |
| 760 | return; | |
| 761 | } | |
| 762 | ||
| 763 | if (r->offline) { | |
| 764 | /* User is offline. Associate the imported public key with | |
| 765 | this user. */ | |
| 766 | fingerprint = silc_hash_fingerprint(NULL, r->offline_pk, | |
| 767 | r->offline_pk_len); | |
| 768 | for (i = 0; i < strlen(fingerprint); i++) | |
| 769 | if (fingerprint[i] == ' ') | |
| 770 | fingerprint[i] = '_'; | |
| 771 | g_snprintf(filename, sizeof(filename) - 1, | |
| 772 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 15884 | 773 | silcpurple_silcdir(), fingerprint); |
| 774 | purple_blist_node_set_string((PurpleBlistNode *)b, "public-key", filename); | |
| 775 | purple_prpl_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_OFFLINE, NULL); | |
| 8849 | 776 | silc_free(fingerprint); |
| 777 | 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
|
778 | 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
|
779 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 780 | silc_free(r); |
| 781 | return; | |
| 782 | } | |
| 783 | ||
| 784 | /* Get the client entry. */ | |
| 785 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 786 | &r->client_id); | |
| 787 | 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
|
788 | 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
|
789 | 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
|
790 | 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
|
791 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 792 | silc_free(r); |
| 793 | return; | |
| 794 | } | |
| 795 | ||
| 796 | memset(&vcard, 0, sizeof(vcard)); | |
| 797 | memset(&serverpk, 0, sizeof(serverpk)); | |
| 798 | memset(&usersign, 0, sizeof(usersign)); | |
| 799 | memset(&serversign, 0, sizeof(serversign)); | |
| 800 | ||
| 801 | /* Now that we have the public key and we trust it now we | |
| 802 | save the attributes of the buddy and update its status. */ | |
| 803 | ||
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
804 | if (client_entry->attrs) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
805 | silc_dlist_start(client_entry->attrs); |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
806 | while ((attr = silc_dlist_get(client_entry->attrs)) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
807 | != SILC_LIST_END) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
808 | attribute = silc_attribute_get_attribute(attr); |
| 8849 | 809 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
810 | switch (attribute) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
811 | case SILC_ATTRIBUTE_USER_INFO: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
812 | if (!silc_attribute_get_object(attr, (void *)&vcard, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
813 | sizeof(vcard))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
814 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
815 | break; |
| 8849 | 816 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
817 | 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
|
818 | 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
|
819 | 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
|
820 | sizeof(*message))) |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
821 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
822 | break; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
823 | |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
824 | 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
|
825 | 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
|
826 | 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
|
827 | sizeof(*extension))) |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
828 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
829 | break; |
| 8849 | 830 | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
831 | 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
|
832 | 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
|
833 | 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
|
834 | sizeof(*usericon))) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
835 | continue; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
836 | break; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
837 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
838 | case SILC_ATTRIBUTE_SERVER_PUBLIC_KEY: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
839 | if (serverpk.type) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
840 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
841 | if (!silc_attribute_get_object(attr, (void *)&serverpk, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
842 | sizeof(serverpk))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
843 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
844 | break; |
| 8849 | 845 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
846 | case SILC_ATTRIBUTE_USER_DIGITAL_SIGNATURE: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
847 | if (usersign.data) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
848 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
849 | if (!silc_attribute_get_object(attr, (void *)&usersign, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
850 | sizeof(usersign))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
851 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
852 | break; |
| 8849 | 853 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
854 | case SILC_ATTRIBUTE_SERVER_DIGITAL_SIGNATURE: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
855 | if (serversign.data) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
856 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
857 | if (!silc_attribute_get_object(attr, (void *)&serversign, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
858 | sizeof(serversign))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
859 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
860 | break; |
| 8849 | 861 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
862 | default: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
863 | break; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
864 | } |
| 8849 | 865 | } |
| 866 | } | |
| 867 | ||
| 868 | /* 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
|
869 | silc_hash_alloc((const unsigned char *)"sha1", &hash); |
| 8849 | 870 | |
| 871 | if (usersign.data) { | |
| 872 | unsigned char *verifyd; | |
| 873 | SilcUInt32 verify_len; | |
| 874 | ||
| 875 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, | |
| 876 | 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
|
877 | 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
|
878 | 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
|
879 | 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
|
880 | 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
|
881 | usign_success = FALSE; |
| 8849 | 882 | silc_free(verifyd); |
| 883 | } | |
| 884 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
885 | if (serversign.data) { |
| 8849 | 886 | 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
|
887 | SilcPKCSType type = 0; |
| 8849 | 888 | unsigned char *verifyd; |
| 889 | SilcUInt32 verify_len; | |
| 890 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
891 | if (!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
|
892 | 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
|
893 | 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
|
894 | 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
|
895 | 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
|
896 | 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
|
897 | 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
|
898 | 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
|
899 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
900 | 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
|
901 | 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
|
902 | &public_key)) { |
| 8849 | 903 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, |
| 904 | 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
|
905 | 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
|
906 | 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
|
907 | 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
|
908 | 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
|
909 | hash)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
910 | ssign_success = FALSE; |
| 8849 | 911 | silc_pkcs_public_key_free(public_key); |
| 912 | silc_free(verifyd); | |
| 913 | } | |
| 914 | } | |
| 915 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
916 | fingerprint = silc_fingerprint(client_entry->fingerprint, 20); |
| 8849 | 917 | for (i = 0; i < strlen(fingerprint); i++) |
| 918 | if (fingerprint[i] == ' ') | |
| 919 | fingerprint[i] = '_'; | |
| 920 | ||
| 921 | if (usign_success || ssign_success) { | |
| 922 | struct passwd *pw; | |
| 923 | struct stat st; | |
| 924 | ||
| 925 | memset(filename2, 0, sizeof(filename2)); | |
| 926 | ||
| 927 | /* Filename for dir */ | |
| 928 | tmp = fingerprint + strlen(fingerprint) - 9; | |
| 929 | g_snprintf(filename, sizeof(filename) - 1, | |
| 930 | "%s" G_DIR_SEPARATOR_S "friends" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 931 | silcpurple_silcdir(), tmp); |
| 8849 | 932 | |
| 933 | pw = getpwuid(getuid()); | |
| 934 | if (!pw) | |
| 935 | return; | |
| 936 | ||
| 937 | /* Create dir if it doesn't exist */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10341
diff
changeset
|
938 | if ((g_stat(filename, &st)) == -1) { |
| 8849 | 939 | if (errno == ENOENT) { |
|
20287
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
940 | if (pw->pw_uid == geteuid()) { |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
941 | int ret = g_mkdir(filename, 0755); |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
942 | if (ret < 0) |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
943 | return; |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
944 | } |
| 8849 | 945 | } |
| 946 | } | |
| 947 | ||
| 948 | /* Save VCard */ | |
| 949 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 950 | "%s" G_DIR_SEPARATOR_S "vcard", filename); | |
| 951 | if (vcard.full_name) { | |
|
11488
d422a70bed74
[gaim-migrate @ 13730]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11338
diff
changeset
|
952 | tmp = (char *)silc_vcard_encode(&vcard, &len); |
| 8849 | 953 | silc_file_writefile(filename2, tmp, len); |
| 954 | silc_free(tmp); | |
| 955 | } | |
| 956 | ||
| 957 | /* 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
|
958 | if (message) { |
| 8849 | 959 | memset(filename2, 0, sizeof(filename2)); |
| 960 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 961 | "%s" G_DIR_SEPARATOR_S "status_message.mime", | |
| 962 | 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
|
963 | 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
|
964 | 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
|
965 | silc_mime_free(message); |
| 8849 | 966 | } |
| 967 | ||
| 968 | /* 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
|
969 | if (extension) { |
| 8849 | 970 | memset(filename2, 0, sizeof(filename2)); |
| 971 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 972 | "%s" G_DIR_SEPARATOR_S "extension.mime", | |
| 973 | 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
|
974 | 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
|
975 | 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
|
976 | silc_mime_free(extension); |
| 8849 | 977 | } |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
978 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
979 | /* 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
|
980 | 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
|
981 | 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
|
982 | 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
|
983 | (!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
|
984 | !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
|
985 | !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
|
986 | !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
|
987 | 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
|
988 | 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
|
989 | 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
|
990 | 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
|
991 | /* 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
|
992 | 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
|
993 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
994 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
995 | silc_mime_free(usericon); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
996 | } |
| 8849 | 997 | } |
| 998 | ||
| 999 | /* Save the public key path to buddy properties, as it is used | |
| 1000 | to identify the buddy in the network (and not the nickname). */ | |
| 1001 | memset(filename, 0, sizeof(filename)); | |
| 1002 | g_snprintf(filename, sizeof(filename) - 1, | |
| 1003 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 15884 | 1004 | silcpurple_silcdir(), fingerprint); |
| 1005 | purple_blist_node_set_string((PurpleBlistNode *)b, "public-key", filename); | |
| 8849 | 1006 | |
|
10050
78e480f768f2
[gaim-migrate @ 11011]
Dave West <kat@users.sourceforge.net>
parents:
10029
diff
changeset
|
1007 | /* Update online status */ |
| 15884 | 1008 | purple_prpl_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_AVAILABLE, NULL); |
| 8849 | 1009 | |
| 1010 | /* Finally, start watching this user so we receive its status | |
| 1011 | changes from the server */ | |
| 1012 | g_snprintf(filename2, sizeof(filename2) - 1, "+%s", filename); | |
| 1013 | silc_client_command_call(r->client, r->conn, NULL, "WATCH", "-pubkey", | |
| 1014 | filename2, NULL); | |
| 1015 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1016 | silc_hash_free(hash); |
| 8849 | 1017 | 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
|
1018 | 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
|
1019 | 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
|
1020 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 1021 | silc_free(r); |
| 1022 | } | |
| 1023 | ||
| 1024 | static void | |
| 15884 | 1025 | silcpurple_add_buddy_ask_import(void *user_data, const char *name) |
| 8849 | 1026 | { |
| 15884 | 1027 | SilcPurpleBuddyRes r = (SilcPurpleBuddyRes)user_data; |
| 8849 | 1028 | |
| 1029 | /* 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
|
1030 | if (!silc_pkcs_load_public_key(name, &r->public_key)) { |
| 15884 | 1031 | silcpurple_add_buddy_ask_pk_cb(r, 0); |
| 1032 | purple_notify_error(r->client->application, | |
| 8849 | 1033 | _("Add Buddy"), _("Could not load public key"), NULL); |
| 1034 | return; | |
| 1035 | } | |
| 1036 | ||
| 1037 | /* 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
|
1038 | 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
|
1039 | 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
|
1040 | 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
|
1041 | silcpurple_add_buddy_save, r); |
| 8849 | 1042 | } |
| 1043 | ||
| 1044 | static void | |
| 15884 | 1045 | silcpurple_add_buddy_ask_pk_cancel(void *user_data, const char *name) |
| 8849 | 1046 | { |
| 15884 | 1047 | SilcPurpleBuddyRes r = (SilcPurpleBuddyRes)user_data; |
| 8849 | 1048 | |
| 1049 | /* The user did not import public key. The buddy is unusable. */ | |
| 15884 | 1050 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1051 | silc_free(r); |
| 1052 | } | |
| 1053 | ||
| 1054 | static void | |
| 15884 | 1055 | silcpurple_add_buddy_ask_pk_cb(SilcPurpleBuddyRes r, gint id) |
| 8849 | 1056 | { |
| 1057 | if (id != 0) { | |
| 1058 | /* The user did not import public key. The buddy is unusable. */ | |
| 15884 | 1059 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1060 | silc_free(r); |
| 1061 | return; | |
| 1062 | } | |
| 1063 | ||
| 1064 | /* Open file selector to select the public key. */ | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1065 | 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
|
1066 | 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
|
1067 | G_CALLBACK(silcpurple_add_buddy_ask_pk_cancel), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1068 | 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
|
1069 | |
| 8849 | 1070 | } |
| 1071 | ||
| 1072 | static void | |
| 15884 | 1073 | silcpurple_add_buddy_ask_pk(SilcPurpleBuddyRes r) |
| 8849 | 1074 | { |
| 1075 | char tmp[512]; | |
| 1076 | 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
|
1077 | purple_buddy_get_name(r->b)); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1078 | 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
|
1079 | _("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
|
1080 | "Press Import to import a public key."), 0, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1081 | 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
|
1082 | _("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
|
1083 | _("_Import..."), G_CALLBACK(silcpurple_add_buddy_ask_pk_cb)); |
| 8849 | 1084 | } |
| 1085 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1086 | 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
|
1087 | 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
|
1088 | 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
|
1089 | SilcStatus error, void *context, va_list ap) |
| 8849 | 1090 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1091 | SilcPurpleBuddyRes r = context; |
| 8849 | 1092 | 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
|
1093 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1094 | 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
|
1095 | /* 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
|
1096 | 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
|
1097 | 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
|
1098 | 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
|
1099 | 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
|
1100 | 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
|
1101 | } |
| 8849 | 1102 | |
| 1103 | /* Get the client entry. */ | |
| 1104 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 1105 | &r->client_id); | |
| 1106 | if (!client_entry || !client_entry->public_key) { | |
| 1107 | /* The buddy is offline/nonexistent. We will require user | |
| 1108 | to associate a public key with the buddy or the buddy | |
| 1109 | cannot be added. */ | |
| 1110 | r->offline = TRUE; | |
| 15884 | 1111 | 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
|
1112 | return FALSE; |
| 8849 | 1113 | } |
| 1114 | ||
| 1115 | /* Now verify the public key */ | |
| 15884 | 1116 | 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
|
1117 | 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
|
1118 | 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
|
1119 | return TRUE; |
| 8849 | 1120 | } |
| 1121 | ||
| 1122 | static void | |
| 15884 | 1123 | silcpurple_add_buddy_select_cb(SilcPurpleBuddyRes r, PurpleRequestFields *fields) |
| 8849 | 1124 | { |
| 15884 | 1125 | 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
|
1126 | GList *list; |
| 8849 | 1127 | 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
|
1128 | SilcDList clients; |
| 8849 | 1129 | |
| 15884 | 1130 | f = purple_request_fields_get_field(fields, "list"); |
| 1131 | list = purple_request_field_list_get_selected(f); | |
| 8849 | 1132 | if (!list) { |
| 1133 | /* The user did not select any user. */ | |
| 15884 | 1134 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1135 | silc_free(r); |
| 1136 | return; | |
| 1137 | } | |
| 1138 | ||
| 15884 | 1139 | 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
|
1140 | 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
|
1141 | 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
|
1142 | 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
|
1143 | 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
|
1144 | silc_dlist_uninit(clients); |
| 8849 | 1145 | } |
| 1146 | ||
| 1147 | static void | |
| 15884 | 1148 | silcpurple_add_buddy_select_cancel(SilcPurpleBuddyRes r, PurpleRequestFields *fields) |
| 8849 | 1149 | { |
| 1150 | /* The user did not select any user. */ | |
| 15884 | 1151 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1152 | silc_free(r); |
| 1153 | } | |
| 1154 | ||
| 1155 | 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
|
1156 | silcpurple_add_buddy_select(SilcPurpleBuddyRes r, SilcDList clients) |
| 8849 | 1157 | { |
| 15884 | 1158 | PurpleRequestFields *fields; |
| 1159 | PurpleRequestFieldGroup *g; | |
| 1160 | PurpleRequestField *f; | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1161 | char tmp[512], tmp2[128]; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1162 | 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
|
1163 | SilcClientEntry client_entry; |
| 8849 | 1164 | |
| 15884 | 1165 | fields = purple_request_fields_new(); |
| 1166 | g = purple_request_field_group_new(NULL); | |
| 1167 | f = purple_request_field_list_new("list", NULL); | |
| 1168 | purple_request_field_group_add_field(g, f); | |
| 1169 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 1170 | purple_request_fields_add_group(fields, g); | |
| 8849 | 1171 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1172 | 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
|
1173 | while ((client_entry = silc_dlist_get(clients))) { |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1174 | 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
|
1175 | 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
|
1176 | fingerprint = silc_fingerprint(client_entry->fingerprint, 20); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1177 | g_snprintf(tmp2, sizeof(tmp2), "\n%s", fingerprint); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1178 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1179 | 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
|
1180 | 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
|
1181 | 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
|
1182 | client_entry->hostname : "", |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1183 | 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
|
1184 | purple_request_field_list_add(f, tmp, client_entry); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1185 | silc_free(fingerprint); |
| 8849 | 1186 | } |
| 1187 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1188 | 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
|
1189 | _("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
|
1190 | 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
|
1191 | ? _("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
|
1192 | "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
|
1193 | : _("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
|
1194 | "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
|
1195 | fields, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1196 | _("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
|
1197 | _("Cancel"), G_CALLBACK(silcpurple_add_buddy_select_cancel), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1198 | purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), NULL, r); |
| 8849 | 1199 | } |
| 1200 | ||
| 1201 | static void | |
| 15884 | 1202 | 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
|
1203 | 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
|
1204 | 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
|
1205 | 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
|
1206 | void *context) |
| 8849 | 1207 | { |
| 15884 | 1208 | SilcPurpleBuddyRes r = context; |
| 1209 | PurpleBuddy *b = r->b; | |
| 8849 | 1210 | SilcAttributePayload pub; |
| 1211 | SilcAttributeObjPk userpk; | |
| 1212 | 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
|
1213 | 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
|
1214 | SilcUInt16 cmd_ident; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1215 | const char *name; |
| 8849 | 1216 | |
| 15884 | 1217 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1218 | |
| 8849 | 1219 | /* If the buddy is offline/nonexistent, we will require user |
| 1220 | to associate a public key with the buddy or the buddy | |
| 1221 | 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
|
1222 | if (!clients) { |
| 8849 | 1223 | if (r->init) { |
| 1224 | silc_free(r); | |
| 1225 | return; | |
| 1226 | } | |
| 1227 | ||
| 1228 | r->offline = TRUE; | |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1229 | /* 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
|
1230 | * before prompting the user to load it again */ |
|
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1231 | if (filename != NULL) |
| 15884 | 1232 | silcpurple_add_buddy_ask_import(r, filename); |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1233 | else |
| 15884 | 1234 | silcpurple_add_buddy_ask_pk(r); |
| 8849 | 1235 | return; |
| 1236 | } | |
| 1237 | ||
| 1238 | /* If more than one client was found with nickname, we need to verify | |
| 1239 | 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
|
1240 | if (silc_dlist_count(clients) > 1 && !r->pubkey_search) { |
| 8849 | 1241 | if (r->init) { |
| 1242 | silc_free(r); | |
| 1243 | return; | |
| 1244 | } | |
| 1245 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1246 | silcpurple_add_buddy_select(r, clients); |
| 8849 | 1247 | return; |
| 1248 | } | |
| 1249 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1250 | 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
|
1251 | 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
|
1252 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1253 | name = purple_buddy_get_name(b); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1254 | |
| 8849 | 1255 | /* If we searched using public keys and more than one entry was found |
| 1256 | 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
|
1257 | if (silc_dlist_count(clients) > 1 && r->pubkey_search && name) { |
| 8849 | 1258 | if (r->init) { |
| 1259 | /* Find the entry that closest matches to the | |
| 1260 | 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
|
1261 | 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
|
1262 | 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
|
1263 | 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
|
1264 | 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
|
1265 | 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
|
1266 | client_entry = entry; |
| 8849 | 1267 | break; |
| 1268 | } | |
| 1269 | } | |
| 1270 | } else { | |
| 1271 | /* 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
|
1272 | silcpurple_add_buddy_select(r, clients); |
| 8849 | 1273 | return; |
| 1274 | } | |
| 1275 | } | |
| 1276 | ||
| 1277 | /* The client was found. Now get its public key and verify | |
| 1278 | that before adding the buddy. */ | |
| 1279 | memset(&userpk, 0, sizeof(userpk)); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1280 | b->proto_data = silc_memdup(&client_entry->id, sizeof(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
|
1281 | r->client_id = client_entry->id; |
| 8849 | 1282 | |
| 1283 | /* Get the public key from attributes, if not present then | |
| 1284 | 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
|
1285 | 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
|
1286 | 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
|
1287 | SILC_ATTRIBUTE_USER_PUBLIC_KEY); |
| 8849 | 1288 | if (!pub || !silc_attribute_get_object(pub, (void *)&userpk, |
| 1289 | sizeof(userpk))) { | |
| 1290 | /* 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
|
1291 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1292 | 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
|
1293 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1294 | 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
|
1295 | 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
|
1296 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1297 | r); |
| 1298 | return; | |
| 1299 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1300 | 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
|
1301 | 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
|
1302 | &client_entry->public_key)) |
| 8849 | 1303 | return; |
| 1304 | 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
|
1305 | } 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
|
1306 | if (!silc_pkcs_load_public_key(filename, &client_entry->public_key)) { |
| 8849 | 1307 | /* 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
|
1308 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1309 | 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
|
1310 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1311 | 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
|
1312 | 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
|
1313 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1314 | r); |
| 1315 | return; | |
| 1316 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1317 | } else if (!client_entry->public_key) { |
| 8849 | 1318 | /* 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
|
1319 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1320 | 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
|
1321 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1322 | 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
|
1323 | 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
|
1324 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1325 | r); |
| 1326 | return; | |
| 1327 | } | |
| 1328 | ||
| 1329 | /* 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
|
1330 | 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
|
1331 | 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
|
1332 | 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
|
1333 | silcpurple_add_buddy_save, r); |
| 8849 | 1334 | } |
| 1335 | ||
| 1336 | static void | |
| 15884 | 1337 | silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init) |
| 8849 | 1338 | { |
| 15884 | 1339 | SilcPurple sg = gc->proto_data; |
| 8849 | 1340 | SilcClient client = sg->client; |
| 1341 | SilcClientConnection conn = sg->conn; | |
| 15884 | 1342 | SilcPurpleBuddyRes r; |
| 8849 | 1343 | SilcBuffer attrs; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1344 | const char *filename, *name = purple_buddy_get_name(b); |
| 8849 | 1345 | |
| 1346 | r = silc_calloc(1, sizeof(*r)); | |
| 1347 | if (!r) | |
| 1348 | return; | |
| 1349 | r->client = client; | |
| 1350 | r->conn = conn; | |
| 1351 | r->b = b; | |
| 1352 | r->init = init; | |
| 1353 | ||
| 1354 | /* See if we have this buddy's public key. If we do use that | |
| 1355 | to search the details. */ | |
| 15884 | 1356 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
| 8849 | 1357 | if (filename) { |
| 1358 | SilcPublicKey public_key; | |
| 1359 | SilcAttributeObjPk userpk; | |
| 1360 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1361 | if (!silc_pkcs_load_public_key(filename, &public_key)) |
| 8849 | 1362 | return; |
| 1363 | ||
| 1364 | /* Get all attributes, and use the public key to search user */ | |
| 1365 | name = NULL; | |
| 1366 | attrs = silc_client_attributes_request(SILC_ATTRIBUTE_USER_INFO, | |
| 1367 | SILC_ATTRIBUTE_SERVICE, | |
| 1368 | SILC_ATTRIBUTE_STATUS_MOOD, | |
| 1369 | SILC_ATTRIBUTE_STATUS_FREETEXT, | |
| 1370 | SILC_ATTRIBUTE_STATUS_MESSAGE, | |
| 1371 | SILC_ATTRIBUTE_PREFERRED_LANGUAGE, | |
| 1372 | SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
| 1373 | SILC_ATTRIBUTE_TIMEZONE, | |
| 1374 | SILC_ATTRIBUTE_GEOLOCATION, | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1375 | SILC_ATTRIBUTE_USER_ICON, |
| 8849 | 1376 | SILC_ATTRIBUTE_DEVICE_INFO, 0); |
| 1377 | userpk.type = "silc-rsa"; | |
| 1378 | userpk.data = silc_pkcs_public_key_encode(public_key, &userpk.data_len); | |
| 1379 | attrs = silc_attribute_payload_encode(attrs, | |
| 1380 | SILC_ATTRIBUTE_USER_PUBLIC_KEY, | |
| 1381 | SILC_ATTRIBUTE_FLAG_VALID, | |
| 1382 | &userpk, sizeof(userpk)); | |
| 1383 | silc_free(userpk.data); | |
| 1384 | silc_pkcs_public_key_free(public_key); | |
| 1385 | r->pubkey_search = TRUE; | |
| 1386 | } else { | |
| 1387 | /* Get all attributes */ | |
| 1388 | attrs = silc_client_attributes_request(0); | |
| 1389 | } | |
| 1390 | ||
| 1391 | /* Resolve */ | |
| 1392 | silc_client_get_clients_whois(client, conn, name, NULL, attrs, | |
| 15884 | 1393 | silcpurple_add_buddy_resolved, r); |
| 8849 | 1394 | silc_buffer_free(attrs); |
| 1395 | } | |
| 1396 | ||
| 15884 | 1397 | void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 8849 | 1398 | { |
| 15884 | 1399 | silcpurple_add_buddy_i(gc, buddy, FALSE); |
| 8849 | 1400 | } |
| 1401 | ||
| 15884 | 1402 | void silcpurple_send_buddylist(PurpleConnection *gc) |
|
10341
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1403 | { |
| 15884 | 1404 | PurpleBlistNode *gnode, *cnode, *bnode; |
| 1405 | PurpleBuddy *buddy; | |
| 1406 | PurpleAccount *account; | |
|
12111
a939a3c185f9
[gaim-migrate @ 14411]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12058
diff
changeset
|
1407 | |
| 15884 | 1408 | account = purple_connection_get_account(gc); |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1409 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1410 | for (gnode = purple_blist_get_root(); gnode != NULL; gnode = gnode->next) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1411 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1412 | if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1413 | continue; |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1414 | for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1415 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1416 | if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1417 | continue; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1418 | for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1419 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1420 | if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1421 | continue; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1422 | buddy = (PurpleBuddy *)bnode; |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1423 | if (purple_buddy_get_account(buddy) == account) |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1424 | silcpurple_add_buddy_i(gc, buddy, TRUE); |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1425 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1426 | } |
|
10341
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1427 | } |
|
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1428 | } |
|
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1429 | |
| 15884 | 1430 | void silcpurple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 1431 | PurpleGroup *group) | |
| 8849 | 1432 | { |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9272
diff
changeset
|
1433 | silc_free(buddy->proto_data); |
| 8849 | 1434 | } |
| 1435 | ||
| 15884 | 1436 | void silcpurple_idle_set(PurpleConnection *gc, int idle) |
| 8849 | 1437 | |
| 1438 | { | |
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1439 | SilcPurple sg; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1440 | SilcClient client; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1441 | SilcClientConnection conn; |
| 8849 | 1442 | SilcAttributeObjService service; |
| 1443 | const char *server; | |
| 1444 | int port; | |
| 1445 | ||
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1446 | sg = gc->proto_data; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1447 | if (sg == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1448 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1449 | |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1450 | client = sg->client; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1451 | if (client == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1452 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1453 | |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1454 | conn = sg->conn; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1455 | if (conn == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1456 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1457 | |
| 15884 | 1458 | server = purple_account_get_string(sg->account, "server", |
| 8849 | 1459 | "silc.silcnet.org"); |
| 15884 | 1460 | port = purple_account_get_int(sg->account, "port", 706), |
| 8849 | 1461 | |
| 1462 | memset(&service, 0, sizeof(service)); | |
| 1463 | silc_client_attribute_del(client, conn, | |
| 1464 | SILC_ATTRIBUTE_SERVICE, NULL); | |
| 1465 | service.port = port; | |
| 1466 | g_snprintf(service.address, sizeof(service.address), "%s", server); | |
| 1467 | service.idle = idle; | |
| 1468 | silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_SERVICE, | |
| 1469 | &service, sizeof(service)); | |
| 1470 | } | |
| 1471 | ||
| 15884 | 1472 | char *silcpurple_status_text(PurpleBuddy *b) |
| 8849 | 1473 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1474 | 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
|
1475 | 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
|
1476 | SilcPurple sg = gc->proto_data; |
| 8849 | 1477 | SilcClient client = sg->client; |
| 1478 | SilcClientConnection conn = sg->conn; | |
| 1479 | SilcClientID *client_id = b->proto_data; | |
| 1480 | SilcClientEntry client_entry; | |
| 1481 | SilcAttributePayload attr; | |
| 1482 | SilcAttributeMood mood = 0; | |
| 1483 | ||
| 1484 | /* Get the client entry. */ | |
| 1485 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1486 | if (!client_entry) | |
| 1487 | return NULL; | |
| 1488 | ||
| 1489 | /* If user is online, we show the mood status, if available. | |
| 1490 | If user is offline or away that status is indicated. */ | |
| 1491 | ||
| 1492 | if (client_entry->mode & SILC_UMODE_DETACHED) | |
| 1493 | return g_strdup(_("Detached")); | |
| 1494 | if (client_entry->mode & SILC_UMODE_GONE) | |
| 1495 | return g_strdup(_("Away")); | |
| 1496 | if (client_entry->mode & SILC_UMODE_INDISPOSED) | |
| 1497 | return g_strdup(_("Indisposed")); | |
| 1498 | if (client_entry->mode & SILC_UMODE_BUSY) | |
| 1499 | return g_strdup(_("Busy")); | |
| 1500 | if (client_entry->mode & SILC_UMODE_PAGE) | |
| 1501 | return g_strdup(_("Wake Me Up")); | |
| 1502 | if (client_entry->mode & SILC_UMODE_HYPER) | |
| 1503 | return g_strdup(_("Hyper Active")); | |
| 1504 | if (client_entry->mode & SILC_UMODE_ROBOT) | |
| 1505 | return g_strdup(_("Robot")); | |
| 1506 | ||
| 15884 | 1507 | attr = silcpurple_get_attr(client_entry->attrs, SILC_ATTRIBUTE_STATUS_MOOD); |
| 8849 | 1508 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { |
| 1509 | /* The mood is a bit mask, so we could show multiple moods, | |
| 1510 | but let's show only one for now. */ | |
| 1511 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) | |
| 1512 | return g_strdup(_("Happy")); | |
| 1513 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) | |
| 1514 | return g_strdup(_("Sad")); | |
| 1515 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) | |
| 1516 | return g_strdup(_("Angry")); | |
| 1517 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) | |
| 1518 | return g_strdup(_("Jealous")); | |
| 1519 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) | |
| 1520 | return g_strdup(_("Ashamed")); | |
| 1521 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) | |
| 1522 | return g_strdup(_("Invincible")); | |
| 1523 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) | |
| 1524 | return g_strdup(_("In Love")); | |
| 1525 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) | |
| 1526 | return g_strdup(_("Sleepy")); | |
| 1527 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) | |
| 1528 | return g_strdup(_("Bored")); | |
| 1529 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) | |
| 1530 | return g_strdup(_("Excited")); | |
| 1531 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) | |
| 1532 | return g_strdup(_("Anxious")); | |
| 1533 | } | |
| 1534 | ||
| 1535 | return NULL; | |
| 1536 | } | |
| 1537 | ||
| 15884 | 1538 | void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 8849 | 1539 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1540 | 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
|
1541 | 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
|
1542 | SilcPurple sg = gc->proto_data; |
| 8849 | 1543 | SilcClient client = sg->client; |
| 1544 | SilcClientConnection conn = sg->conn; | |
| 1545 | SilcClientID *client_id = b->proto_data; | |
| 1546 | SilcClientEntry client_entry; | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1547 | char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; |
| 8849 | 1548 | char tmp[256]; |
| 1549 | ||
| 1550 | /* Get the client entry. */ | |
| 1551 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1552 | if (!client_entry) | |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1553 | return; |
| 8849 | 1554 | |
| 1555 | if (client_entry->nickname) | |
| 15884 | 1556 | purple_notify_user_info_add_pair(user_info, _("Nickname"), |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1557 | client_entry->nickname); |
|
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1558 | if (client_entry->username && client_entry->hostname) { |
|
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1559 | g_snprintf(tmp, sizeof(tmp), "%s@%s", client_entry->username, client_entry->hostname); |
| 15884 | 1560 | purple_notify_user_info_add_pair(user_info, _("Username"), tmp); |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1561 | } |
| 8849 | 1562 | if (client_entry->mode) { |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1563 | memset(tmp, 0, sizeof(tmp)); |
| 15884 | 1564 | silcpurple_get_umode_string(client_entry->mode, |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1565 | tmp, sizeof(tmp) - strlen(tmp)); |
| 15884 | 1566 | purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp); |
| 8849 | 1567 | } |
| 1568 | ||
| 15884 | 1569 | 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
|
1570 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1571 | if (statusstr) { |
| 15884 | 1572 | purple_notify_user_info_add_pair(user_info, _("Message"), statusstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1573 | g_free(statusstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1574 | } |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1575 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1576 | if (full) { |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1577 | if (moodstr) { |
| 15884 | 1578 | purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1579 | g_free(moodstr); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1580 | } |
| 8849 | 1581 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1582 | if (contactstr) { |
| 15884 | 1583 | 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
|
1584 | g_free(contactstr); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1585 | } |
| 8849 | 1586 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1587 | if (langstr) { |
| 15884 | 1588 | 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
|
1589 | g_free(langstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1590 | } |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1591 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1592 | if (devicestr) { |
| 15884 | 1593 | purple_notify_user_info_add_pair(user_info, _("Device"), devicestr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1594 | g_free(devicestr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1595 | } |
| 8849 | 1596 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1597 | if (tzstr) { |
| 15884 | 1598 | purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1599 | g_free(tzstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1600 | } |
| 8849 | 1601 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1602 | if (geostr) { |
| 15884 | 1603 | purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1604 | g_free(geostr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1605 | } |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1606 | } |
| 8849 | 1607 | } |
| 1608 | ||
| 1609 | static void | |
| 15884 | 1610 | silcpurple_buddy_kill(PurpleBlistNode *node, gpointer data) |
| 8849 | 1611 | { |
| 15884 | 1612 | PurpleBuddy *b; |
| 1613 | PurpleConnection *gc; | |
| 1614 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1615 | |
| 15884 | 1616 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1617 | |
| 15884 | 1618 | b = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1619 | gc = purple_account_get_connection(purple_buddy_get_account(b)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1620 | sg = gc->proto_data; |
| 8849 | 1621 | |
| 1622 | /* Call KILL */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1623 | 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
|
1624 | purple_buddy_get_name(b), "Killed by operator", NULL); |
| 8849 | 1625 | } |
| 1626 | ||
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1627 | typedef struct { |
| 15884 | 1628 | SilcPurple sg; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1629 | SilcClientEntry client_entry; |
| 15884 | 1630 | } *SilcPurpleBuddyWb; |
|
12058
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 | static void |
| 15884 | 1633 | silcpurple_buddy_wb(PurpleBlistNode *node, gpointer data) |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1634 | { |
| 15884 | 1635 | SilcPurpleBuddyWb wb = data; |
| 1636 | silcpurple_wb_init(wb->sg, wb->client_entry); | |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1637 | silc_free(wb); |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1638 | } |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1639 | |
| 15884 | 1640 | GList *silcpurple_buddy_menu(PurpleBuddy *buddy) |
| 8849 | 1641 | { |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23196
diff
changeset
|
1642 | 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
|
1643 | PurpleConnection *gc = purple_account_get_connection(account); |
| 15884 | 1644 | SilcPurple sg = gc->proto_data; |
| 8849 | 1645 | SilcClientConnection conn = sg->conn; |
| 1646 | const char *pkfile = NULL; | |
| 1647 | SilcClientEntry client_entry = NULL; | |
| 15884 | 1648 | PurpleMenuAction *act; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1649 | GList *m = NULL; |
| 15884 | 1650 | SilcPurpleBuddyWb wb; |
| 8849 | 1651 | |
| 15884 | 1652 | pkfile = purple_blist_node_get_string((PurpleBlistNode *) buddy, "public-key"); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1653 | client_entry = silc_client_get_client_by_id(sg->client, |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1654 | sg->conn, |
| 9038 | 1655 | buddy->proto_data); |
| 8849 | 1656 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1657 | 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
|
1658 | 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
|
1659 | sg->conn, client_entry)) { |
| 15884 | 1660 | act = purple_menu_action_new(_("Reset IM Key"), |
| 1661 | PURPLE_CALLBACK(silcpurple_buddy_resetkey), | |
| 12919 | 1662 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1663 | m = g_list_append(m, act); |
| 8849 | 1664 | } else { |
| 15884 | 1665 | act = purple_menu_action_new(_("IM with Key Exchange"), |
| 1666 | PURPLE_CALLBACK(silcpurple_buddy_keyagr), | |
| 12919 | 1667 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1668 | m = g_list_append(m, act); |
| 8849 | 1669 | |
| 15884 | 1670 | act = purple_menu_action_new(_("IM with Password"), |
| 1671 | PURPLE_CALLBACK(silcpurple_buddy_privkey_menu), | |
| 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); |
| 8849 | 1674 | } |
| 1675 | ||
| 1676 | if (pkfile) { | |
| 15884 | 1677 | act = purple_menu_action_new(_("Show Public Key"), |
| 1678 | PURPLE_CALLBACK(silcpurple_buddy_showkey), | |
| 12919 | 1679 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1680 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1681 | |
| 8849 | 1682 | } else { |
| 15884 | 1683 | act = purple_menu_action_new(_("Get Public Key..."), |
| 1684 | PURPLE_CALLBACK(silcpurple_buddy_getkey_menu), | |
| 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 | ||
| 1689 | if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { | |
| 15884 | 1690 | act = purple_menu_action_new(_("Kill User"), |
| 1691 | PURPLE_CALLBACK(silcpurple_buddy_kill), | |
| 12919 | 1692 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1693 | m = g_list_append(m, act); |
| 8849 | 1694 | } |
| 1695 | ||
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1696 | if (client_entry) { |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1697 | wb = silc_calloc(1, sizeof(*wb)); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1698 | wb->sg = sg; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1699 | wb->client_entry = client_entry; |
| 15884 | 1700 | act = purple_menu_action_new(_("Draw On Whiteboard"), |
| 1701 | PURPLE_CALLBACK(silcpurple_buddy_wb), | |
| 12919 | 1702 | (void *)wb, NULL); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1703 | m = g_list_append(m, act); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1704 | } |
| 8849 | 1705 | return m; |
| 1706 | } | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1707 | |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1708 | void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1709 | { |
| 15884 | 1710 | SilcPurple sg = gc->proto_data; |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1711 | SilcClient client = sg->client; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1712 | SilcClientConnection conn = sg->conn; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1713 | SilcMime mime; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1714 | char type[32]; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1715 | const char *t; |
|
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 | /* Remove */ |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1718 | if (!img) { |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1719 | silc_client_attribute_del(client, conn, |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1720 | SILC_ATTRIBUTE_USER_ICON, NULL); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1721 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1722 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1723 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1724 | /* Add */ |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1725 | mime = silc_mime_alloc(); |
|
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1726 | if (!mime) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1727 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1728 | |
|
16672
0d38368057c7
Use the purple_imgstore_get_extension() convienence function.
Richard Laager <rlaager@pidgin.im>
parents:
16549
diff
changeset
|
1729 | 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
|
1730 | if (!t || !strcmp(t, "icon")) { |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1731 | silc_mime_free(mime); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1732 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1733 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1734 | if (!strcmp(t, "jpg")) |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1735 | t = "jpeg"; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1736 | g_snprintf(type, sizeof(type), "image/%s", t); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1737 | silc_mime_add_field(mime, "Content-Type", type); |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1738 | 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
|
1739 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1740 | 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
|
1741 | SILC_ATTRIBUTE_USER_ICON, mime, sizeof(*mime)); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1742 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1743 | silc_mime_free(mime); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1744 | } |