Sun, 01 Feb 2009 08:25:57 +0000
Move some MSN message handlers from switchboard to general msg.c.
References #7676.
| 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; |
| 9060 | 325 | |
| 15884 | 326 | buddy = (PurpleBuddy *)node; |
| 327 | silcpurple_buddy_keyagr_do(buddy->account->gc, buddy->name, FALSE); | |
| 8849 | 328 | } |
| 329 | ||
| 330 | ||
| 331 | /**************************** Static IM Key **********************************/ | |
| 332 | ||
| 333 | static void | |
| 15884 | 334 | silcpurple_buddy_resetkey(PurpleBlistNode *node, gpointer data) |
| 8849 | 335 | { |
| 15884 | 336 | PurpleBuddy *b; |
| 337 | PurpleConnection *gc; | |
| 338 | 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
|
339 | SilcDList clients; |
| 8849 | 340 | |
| 15884 | 341 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
342 | |
| 15884 | 343 | b = (PurpleBuddy *) node; |
| 344 | gc = purple_account_get_connection(b->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
345 | sg = gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
346 | |
| 8849 | 347 | /* Find client entry */ |
| 348 | 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
|
349 | b->name, FALSE); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
350 | if (!clients) |
| 8849 | 351 | return; |
| 352 | ||
|
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 | silc_dlist_start(clients); |
| 8849 | 354 | 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
|
355 | 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
|
356 | silc_client_list_free(sg->client, sg->conn, clients); |
| 8849 | 357 | } |
| 358 | ||
| 359 | typedef struct { | |
| 360 | SilcClient client; | |
| 361 | SilcClientConnection conn; | |
| 362 | SilcClientID client_id; | |
| 15884 | 363 | } *SilcPurplePrivkey; |
| 8849 | 364 | |
| 365 | static void | |
| 15884 | 366 | silcpurple_buddy_privkey(PurpleConnection *gc, const char *name); |
| 8849 | 367 | |
| 368 | static void | |
| 15884 | 369 | silcpurple_buddy_privkey_cb(SilcPurplePrivkey p, const char *passphrase) |
| 8849 | 370 | { |
| 371 | SilcClientEntry client_entry; | |
| 372 | ||
| 373 | if (!passphrase || !(*passphrase)) { | |
| 374 | silc_free(p); | |
| 375 | return; | |
| 376 | } | |
| 377 | ||
| 378 | /* Get the client entry. */ | |
| 379 | client_entry = silc_client_get_client_by_id(p->client, p->conn, | |
| 380 | &p->client_id); | |
| 381 | if (!client_entry) { | |
| 15884 | 382 | 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
|
383 | _("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
|
384 | NULL); |
| 8849 | 385 | silc_free(p); |
| 386 | return; | |
| 387 | } | |
| 388 | ||
| 389 | /* Set the private message key */ | |
| 390 | silc_client_del_private_message_key(p->client, p->conn, | |
| 391 | client_entry); | |
| 392 | silc_client_add_private_message_key(p->client, p->conn, | |
| 393 | client_entry, NULL, NULL, | |
| 394 | (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
|
395 | strlen(passphrase)); |
| 8849 | 396 | silc_free(p); |
| 397 | } | |
| 398 | ||
| 399 | static void | |
| 15884 | 400 | 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
|
401 | 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
|
402 | 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
|
403 | 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
|
404 | void *context) |
| 8849 | 405 | { |
| 406 | char tmp[256]; | |
| 407 | ||
| 408 | if (!clients) { | |
| 409 | g_snprintf(tmp, sizeof(tmp), | |
| 410 | _("User %s is not present in the network"), | |
| 411 | (const char *)context); | |
| 15884 | 412 | purple_notify_error(client->application, _("IM With Password"), |
| 8849 | 413 | _("Cannot set IM key"), tmp); |
| 414 | g_free(context); | |
| 415 | return; | |
| 416 | } | |
| 417 | ||
| 15884 | 418 | 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
|
419 | g_free(context); |
| 8849 | 420 | } |
| 421 | ||
| 422 | static void | |
| 15884 | 423 | silcpurple_buddy_privkey(PurpleConnection *gc, const char *name) |
| 8849 | 424 | { |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
425 | SilcPurple sg = gc->proto_data; |
| 15884 | 426 | 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
|
427 | 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
|
428 | SilcClientEntry client_entry; |
| 8849 | 429 | |
| 9038 | 430 | if (!name) |
| 431 | return; | |
| 8849 | 432 | |
| 433 | /* Find client entry */ | |
| 434 | 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
|
435 | name, FALSE); |
| 8849 | 436 | 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
|
437 | silc_client_get_clients(sg->client, sg->conn, name, NULL, |
| 15884 | 438 | silcpurple_buddy_privkey_resolved, |
| 9038 | 439 | g_strdup(name)); |
| 8849 | 440 | return; |
| 441 | } | |
| 442 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
443 | 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
|
444 | 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
|
445 | |
| 8849 | 446 | p = silc_calloc(1, sizeof(*p)); |
| 447 | if (!p) | |
| 448 | return; | |
| 449 | p->client = sg->client; | |
| 450 | 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
|
451 | p->client_id = client_entry->id; |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
452 | 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
|
453 | _("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
|
454 | _("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
|
455 | _("Cancel"), G_CALLBACK(silcpurple_buddy_privkey_cb), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
456 | gc->account, NULL, NULL, p); |
| 8849 | 457 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
458 | silc_client_list_free(sg->client, sg->conn, clients); |
| 8849 | 459 | } |
| 460 | ||
| 9038 | 461 | static void |
| 15884 | 462 | silcpurple_buddy_privkey_menu(PurpleBlistNode *node, gpointer data) |
| 9038 | 463 | { |
| 15884 | 464 | PurpleBuddy *buddy; |
| 465 | PurpleConnection *gc; | |
| 9038 | 466 | |
| 15884 | 467 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 9038 | 468 | |
| 15884 | 469 | buddy = (PurpleBuddy *) node; |
| 470 | gc = purple_account_get_connection(buddy->account); | |
| 9038 | 471 | |
| 15884 | 472 | silcpurple_buddy_privkey(gc, buddy->name); |
| 9038 | 473 | } |
| 474 | ||
| 8849 | 475 | |
| 476 | /**************************** Get Public Key *********************************/ | |
| 477 | ||
| 478 | typedef struct { | |
| 479 | SilcClient client; | |
| 480 | SilcClientConnection conn; | |
| 481 | SilcClientID client_id; | |
| 15884 | 482 | } *SilcPurpleBuddyGetkey; |
| 8849 | 483 | |
| 484 | static void | |
| 15884 | 485 | silcpurple_buddy_getkey(PurpleConnection *gc, const char *name); |
| 8849 | 486 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
487 | 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
|
488 | 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
|
489 | 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
|
490 | SilcStatus error, void *context, va_list ap) |
| 8849 | 491 | { |
| 492 | 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
|
493 | 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
|
494 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
495 | 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
|
496 | 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
|
497 | _("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
|
498 | NULL); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
499 | 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
|
500 | 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
|
501 | } |
| 8849 | 502 | |
| 503 | /* Get the client entry. */ | |
| 504 | client_entry = silc_client_get_client_by_id(g->client, g->conn, | |
| 505 | &g->client_id); | |
| 506 | if (!client_entry) { | |
| 15884 | 507 | purple_notify_error(g->client->application, _("Get Public Key"), |
| 8849 | 508 | _("The remote user is not present in the network any more"), |
| 509 | NULL); | |
| 510 | 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
|
511 | return FALSE; |
| 8849 | 512 | } |
| 513 | ||
| 514 | if (!client_entry->public_key) { | |
| 515 | 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
|
516 | return FALSE; |
| 8849 | 517 | } |
| 518 | ||
| 519 | /* Now verify the public key */ | |
| 15884 | 520 | 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
|
521 | 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
|
522 | NULL, NULL); |
| 8849 | 523 | 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
|
524 | return TRUE; |
| 8849 | 525 | } |
| 526 | ||
| 527 | static void | |
| 15884 | 528 | 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
|
529 | 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
|
530 | 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
|
531 | 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
|
532 | void *context) |
| 8849 | 533 | { |
| 534 | char tmp[256]; | |
| 535 | ||
| 536 | if (!clients) { | |
| 537 | g_snprintf(tmp, sizeof(tmp), | |
| 538 | _("User %s is not present in the network"), | |
| 539 | (const char *)context); | |
| 15884 | 540 | 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
|
541 | _("Cannot fetch the public key"), tmp); |
| 8849 | 542 | g_free(context); |
| 543 | return; | |
| 544 | } | |
| 545 | ||
| 15884 | 546 | 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
|
547 | g_free(context); |
| 8849 | 548 | } |
| 549 | ||
| 550 | static void | |
| 15884 | 551 | silcpurple_buddy_getkey(PurpleConnection *gc, const char *name) |
| 8849 | 552 | { |
| 15884 | 553 | SilcPurple sg = gc->proto_data; |
| 9038 | 554 | SilcClient client = sg->client; |
| 555 | 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
|
556 | 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
|
557 | SilcDList clients; |
| 15884 | 558 | 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
|
559 | SilcUInt16 cmd_ident; |
| 8849 | 560 | |
| 9038 | 561 | if (!name) |
| 562 | return; | |
| 8849 | 563 | |
| 564 | /* 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
|
565 | clients = silc_client_get_clients_local(client, conn, name, FALSE); |
| 8849 | 566 | 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
|
567 | silc_client_get_clients(client, conn, name, NULL, |
| 15884 | 568 | silcpurple_buddy_getkey_resolved, |
| 9038 | 569 | g_strdup(name)); |
| 8849 | 570 | return; |
| 571 | } | |
| 572 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
573 | 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
|
574 | 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
|
575 | |
| 8849 | 576 | /* Call GETKEY */ |
| 577 | g = silc_calloc(1, sizeof(*g)); | |
| 578 | if (!g) | |
| 579 | return; | |
| 580 | g->client = client; | |
| 581 | 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
|
582 | 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
|
583 | 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
|
584 | 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
|
585 | 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
|
586 | 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
|
587 | silc_client_list_free(client, conn, clients); |
| 8849 | 588 | } |
| 589 | ||
| 590 | static void | |
| 15884 | 591 | silcpurple_buddy_getkey_menu(PurpleBlistNode *node, gpointer data) |
| 9038 | 592 | { |
| 15884 | 593 | PurpleBuddy *buddy; |
| 594 | PurpleConnection *gc; | |
| 9038 | 595 | |
| 15884 | 596 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 9038 | 597 | |
| 15884 | 598 | buddy = (PurpleBuddy *) node; |
| 599 | gc = purple_account_get_connection(buddy->account); | |
| 9038 | 600 | |
| 15884 | 601 | silcpurple_buddy_getkey(gc, buddy->name); |
| 9038 | 602 | } |
| 603 | ||
| 604 | static void | |
| 15884 | 605 | silcpurple_buddy_showkey(PurpleBlistNode *node, gpointer data) |
| 8849 | 606 | { |
| 15884 | 607 | PurpleBuddy *b; |
| 608 | PurpleConnection *gc; | |
| 609 | SilcPurple sg; | |
| 8849 | 610 | SilcPublicKey public_key; |
| 611 | const char *pkfile; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
612 | |
| 15884 | 613 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 8849 | 614 | |
| 15884 | 615 | b = (PurpleBuddy *) node; |
| 616 | gc = purple_account_get_connection(b->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
617 | sg = gc->proto_data; |
| 8849 | 618 | |
| 15884 | 619 | 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
|
620 | if (!silc_pkcs_load_public_key(pkfile, &public_key)) { |
| 15884 | 621 | purple_notify_error(gc, |
| 8849 | 622 | _("Show Public Key"), |
| 623 | _("Could not load public key"), NULL); | |
| 624 | return; | |
| 625 | } | |
| 626 | ||
| 15884 | 627 | silcpurple_show_public_key(sg, b->name, public_key, NULL, NULL); |
| 8849 | 628 | silc_pkcs_public_key_free(public_key); |
| 629 | } | |
| 630 | ||
| 631 | ||
| 632 | /**************************** Buddy routines *********************************/ | |
| 633 | ||
| 634 | /* The buddies are implemented by using the WHOIS and WATCH commands that | |
| 635 | can be used to search users by their public key. Since nicknames aren't | |
| 636 | unique in SILC we cannot trust the buddy list using their nickname. We | |
| 637 | associate public keys to buddies and use those to search and watch | |
| 638 | in the network. | |
| 639 | ||
| 15884 | 640 | The problem is that Purple does not return PurpleBuddy contexts to the |
| 8849 | 641 | callbacks but the buddy names. Naturally, this is not going to work |
| 642 | with SILC. But, for now, we have to do what we can... */ | |
| 643 | ||
| 644 | typedef struct { | |
| 645 | SilcClient client; | |
| 646 | SilcClientConnection conn; | |
| 647 | SilcClientID client_id; | |
| 15884 | 648 | PurpleBuddy *b; |
| 8849 | 649 | unsigned char *offline_pk; |
| 650 | 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
|
651 | SilcPublicKey public_key; |
| 8849 | 652 | unsigned int offline : 1; |
| 653 | unsigned int pubkey_search : 1; | |
| 654 | unsigned int init : 1; | |
| 15884 | 655 | } *SilcPurpleBuddyRes; |
| 8849 | 656 | |
| 657 | static void | |
| 15884 | 658 | silcpurple_add_buddy_ask_pk_cb(SilcPurpleBuddyRes r, gint id); |
| 8849 | 659 | static void |
| 15884 | 660 | 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
|
661 | 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
|
662 | 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
|
663 | 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
|
664 | void *context); |
| 8849 | 665 | |
| 15884 | 666 | void silcpurple_get_info(PurpleConnection *gc, const char *who) |
| 8849 | 667 | { |
| 15884 | 668 | SilcPurple sg = gc->proto_data; |
| 8849 | 669 | SilcClient client = sg->client; |
| 670 | SilcClientConnection conn = sg->conn; | |
| 671 | SilcClientEntry client_entry; | |
| 15884 | 672 | PurpleBuddy *b; |
| 8849 | 673 | const char *filename, *nick = who; |
| 674 | char tmp[256]; | |
| 675 | ||
| 676 | if (!who) | |
| 677 | return; | |
| 678 | if (strlen(who) > 1 && who[0] == '@') | |
| 679 | nick = who + 1; | |
| 680 | if (strlen(who) > 1 && who[0] == '*') | |
| 681 | nick = who + 1; | |
| 682 | if (strlen(who) > 2 && who[0] == '*' && who[1] == '@') | |
| 683 | nick = who + 2; | |
| 684 | ||
| 15884 | 685 | b = purple_find_buddy(gc->account, nick); |
| 8849 | 686 | if (b) { |
| 687 | /* See if we have this buddy's public key. If we do use that | |
| 688 | to search the details. */ | |
| 15884 | 689 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
| 8849 | 690 | if (filename) { |
| 691 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 692 | command reply. */ | |
| 693 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 694 | "-details", "-pubkey", filename, NULL); | |
| 695 | return; | |
| 696 | } | |
| 697 | ||
| 698 | if (!b->proto_data) { | |
| 699 | g_snprintf(tmp, sizeof(tmp), | |
| 700 | _("User %s is not present in the network"), b->name); | |
| 15884 | 701 | purple_notify_error(gc, _("User Information"), |
| 8849 | 702 | _("Cannot get user information"), tmp); |
| 703 | return; | |
| 704 | } | |
| 705 | ||
| 706 | client_entry = silc_client_get_client_by_id(client, conn, b->proto_data); | |
| 707 | if (client_entry) { | |
| 708 | /* Call WHOIS. The user info is displayed in the WHOIS | |
| 709 | command reply. */ | |
| 710 | silc_client_command_call(client, conn, NULL, "WHOIS", | |
| 711 | client_entry->nickname, "-details", NULL); | |
| 712 | } | |
| 713 | } else { | |
| 714 | /* Call WHOIS just with nickname. */ | |
| 715 | silc_client_command_call(client, conn, NULL, "WHOIS", nick, NULL); | |
| 716 | } | |
| 717 | } | |
| 718 | ||
| 719 | static void | |
| 15884 | 720 | silcpurple_add_buddy_pk_no(SilcPurpleBuddyRes r) |
| 8849 | 721 | { |
| 722 | char tmp[512]; | |
| 723 | g_snprintf(tmp, sizeof(tmp), _("The %s buddy is not trusted"), | |
| 724 | r->b->name); | |
| 15884 | 725 | 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
|
726 | _("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
|
727 | "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
|
728 | "command to get the public key.")); |
| 15884 | 729 | purple_prpl_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_OFFLINE, NULL); |
| 8849 | 730 | } |
| 731 | ||
| 732 | 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
|
733 | silcpurple_add_buddy_save(SilcBool success, void *context) |
| 8849 | 734 | { |
| 15884 | 735 | SilcPurpleBuddyRes r = context; |
| 736 | PurpleBuddy *b = r->b; | |
| 8849 | 737 | SilcClientEntry client_entry; |
| 738 | SilcAttributePayload attr; | |
| 739 | SilcAttribute attribute; | |
| 740 | 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
|
741 | 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
|
742 | SilcMime usericon = NULL; |
| 8849 | 743 | SilcAttributeObjPk serverpk, usersign, serversign; |
| 744 | gboolean usign_success = TRUE, ssign_success = TRUE; | |
|
11165
770e5d7940a0
[gaim-migrate @ 13266]
Mark Doliner <markdoliner@pidgin.im>
parents:
10869
diff
changeset
|
745 | char filename[512], filename2[512], *fingerprint = NULL, *tmp; |
| 8849 | 746 | 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
|
747 | SilcHash hash; |
| 8849 | 748 | int i; |
| 749 | ||
| 750 | if (!success) { | |
| 751 | /* The user did not trust the public key. */ | |
| 15884 | 752 | 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
|
753 | 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
|
754 | 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
|
755 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 756 | silc_free(r); |
| 757 | return; | |
| 758 | } | |
| 759 | ||
| 760 | if (r->offline) { | |
| 761 | /* User is offline. Associate the imported public key with | |
| 762 | this user. */ | |
| 763 | fingerprint = silc_hash_fingerprint(NULL, r->offline_pk, | |
| 764 | r->offline_pk_len); | |
| 765 | for (i = 0; i < strlen(fingerprint); i++) | |
| 766 | if (fingerprint[i] == ' ') | |
| 767 | fingerprint[i] = '_'; | |
| 768 | g_snprintf(filename, sizeof(filename) - 1, | |
| 769 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 15884 | 770 | silcpurple_silcdir(), fingerprint); |
| 771 | purple_blist_node_set_string((PurpleBlistNode *)b, "public-key", filename); | |
| 772 | purple_prpl_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_OFFLINE, NULL); | |
| 8849 | 773 | silc_free(fingerprint); |
| 774 | 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
|
775 | 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
|
776 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 777 | silc_free(r); |
| 778 | return; | |
| 779 | } | |
| 780 | ||
| 781 | /* Get the client entry. */ | |
| 782 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 783 | &r->client_id); | |
| 784 | 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
|
785 | 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
|
786 | 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
|
787 | 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
|
788 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 789 | silc_free(r); |
| 790 | return; | |
| 791 | } | |
| 792 | ||
| 793 | memset(&vcard, 0, sizeof(vcard)); | |
| 794 | memset(&serverpk, 0, sizeof(serverpk)); | |
| 795 | memset(&usersign, 0, sizeof(usersign)); | |
| 796 | memset(&serversign, 0, sizeof(serversign)); | |
| 797 | ||
| 798 | /* Now that we have the public key and we trust it now we | |
| 799 | save the attributes of the buddy and update its status. */ | |
| 800 | ||
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
801 | if (client_entry->attrs) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
802 | silc_dlist_start(client_entry->attrs); |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
803 | while ((attr = silc_dlist_get(client_entry->attrs)) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
804 | != SILC_LIST_END) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
805 | attribute = silc_attribute_get_attribute(attr); |
| 8849 | 806 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
807 | switch (attribute) { |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
808 | case SILC_ATTRIBUTE_USER_INFO: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
809 | if (!silc_attribute_get_object(attr, (void *)&vcard, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
810 | sizeof(vcard))) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
811 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
812 | break; |
| 8849 | 813 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
814 | 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
|
815 | 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
|
816 | 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
|
817 | sizeof(*message))) |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
818 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
819 | break; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
820 | |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
821 | 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
|
822 | 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
|
823 | 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
|
824 | sizeof(*extension))) |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
825 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
826 | break; |
| 8849 | 827 | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
828 | 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
|
829 | 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
|
830 | 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
|
831 | sizeof(*usericon))) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
832 | continue; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
833 | break; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
834 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
835 | case SILC_ATTRIBUTE_SERVER_PUBLIC_KEY: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
836 | if (serverpk.type) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
837 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
838 | if (!silc_attribute_get_object(attr, (void *)&serverpk, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
839 | sizeof(serverpk))) |
|
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 | break; |
| 8849 | 842 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
843 | case SILC_ATTRIBUTE_USER_DIGITAL_SIGNATURE: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
844 | if (usersign.data) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
845 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
846 | if (!silc_attribute_get_object(attr, (void *)&usersign, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
847 | sizeof(usersign))) |
|
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 | break; |
| 8849 | 850 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
851 | case SILC_ATTRIBUTE_SERVER_DIGITAL_SIGNATURE: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
852 | if (serversign.data) |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
853 | continue; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
854 | if (!silc_attribute_get_object(attr, (void *)&serversign, |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
855 | sizeof(serversign))) |
|
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 | break; |
| 8849 | 858 | |
|
9133
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
859 | default: |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
860 | break; |
|
bc33b12619d4
[gaim-migrate @ 9915]
Pekka Riikonen <priikone@silcnet.org>
parents:
9060
diff
changeset
|
861 | } |
| 8849 | 862 | } |
| 863 | } | |
| 864 | ||
| 865 | /* 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
|
866 | silc_hash_alloc((const unsigned char *)"sha1", &hash); |
| 8849 | 867 | |
| 868 | if (usersign.data) { | |
| 869 | unsigned char *verifyd; | |
| 870 | SilcUInt32 verify_len; | |
| 871 | ||
| 872 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, | |
| 873 | 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
|
874 | 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
|
875 | 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
|
876 | 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
|
877 | 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
|
878 | usign_success = FALSE; |
| 8849 | 879 | silc_free(verifyd); |
| 880 | } | |
| 881 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
882 | if (serversign.data) { |
| 8849 | 883 | 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
|
884 | SilcPKCSType type = 0; |
| 8849 | 885 | unsigned char *verifyd; |
| 886 | SilcUInt32 verify_len; | |
| 887 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
888 | 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
|
889 | 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
|
890 | 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
|
891 | 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
|
892 | 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
|
893 | 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
|
894 | 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
|
895 | 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
|
896 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
897 | 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
|
898 | 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
|
899 | &public_key)) { |
| 8849 | 900 | verifyd = silc_attribute_get_verify_data(client_entry->attrs, |
| 901 | 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
|
902 | 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
|
903 | 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
|
904 | 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
|
905 | 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
|
906 | hash)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
907 | ssign_success = FALSE; |
| 8849 | 908 | silc_pkcs_public_key_free(public_key); |
| 909 | silc_free(verifyd); | |
| 910 | } | |
| 911 | } | |
| 912 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
913 | fingerprint = silc_fingerprint(client_entry->fingerprint, 20); |
| 8849 | 914 | for (i = 0; i < strlen(fingerprint); i++) |
| 915 | if (fingerprint[i] == ' ') | |
| 916 | fingerprint[i] = '_'; | |
| 917 | ||
| 918 | if (usign_success || ssign_success) { | |
| 919 | struct passwd *pw; | |
| 920 | struct stat st; | |
| 921 | ||
| 922 | memset(filename2, 0, sizeof(filename2)); | |
| 923 | ||
| 924 | /* Filename for dir */ | |
| 925 | tmp = fingerprint + strlen(fingerprint) - 9; | |
| 926 | g_snprintf(filename, sizeof(filename) - 1, | |
| 927 | "%s" G_DIR_SEPARATOR_S "friends" G_DIR_SEPARATOR_S "%s", | |
| 15884 | 928 | silcpurple_silcdir(), tmp); |
| 8849 | 929 | |
| 930 | pw = getpwuid(getuid()); | |
| 931 | if (!pw) | |
| 932 | return; | |
| 933 | ||
| 934 | /* Create dir if it doesn't exist */ | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10341
diff
changeset
|
935 | if ((g_stat(filename, &st)) == -1) { |
| 8849 | 936 | if (errno == ENOENT) { |
|
20287
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
937 | if (pw->pw_uid == geteuid()) { |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
938 | int ret = g_mkdir(filename, 0755); |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
939 | if (ret < 0) |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
940 | return; |
|
4a25d4144f16
applied changes from 20395453ab17cd8dd060d4d0794affda17e3272f
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18552
diff
changeset
|
941 | } |
| 8849 | 942 | } |
| 943 | } | |
| 944 | ||
| 945 | /* Save VCard */ | |
| 946 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 947 | "%s" G_DIR_SEPARATOR_S "vcard", filename); | |
| 948 | if (vcard.full_name) { | |
|
11488
d422a70bed74
[gaim-migrate @ 13730]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11338
diff
changeset
|
949 | tmp = (char *)silc_vcard_encode(&vcard, &len); |
| 8849 | 950 | silc_file_writefile(filename2, tmp, len); |
| 951 | silc_free(tmp); | |
| 952 | } | |
| 953 | ||
| 954 | /* 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
|
955 | if (message) { |
| 8849 | 956 | memset(filename2, 0, sizeof(filename2)); |
| 957 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 958 | "%s" G_DIR_SEPARATOR_S "status_message.mime", | |
| 959 | 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
|
960 | 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
|
961 | 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
|
962 | silc_mime_free(message); |
| 8849 | 963 | } |
| 964 | ||
| 965 | /* 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
|
966 | if (extension) { |
| 8849 | 967 | memset(filename2, 0, sizeof(filename2)); |
| 968 | g_snprintf(filename2, sizeof(filename2) - 1, | |
| 969 | "%s" G_DIR_SEPARATOR_S "extension.mime", | |
| 970 | filename); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
971 | tmp = (char *)silc_mime_get_data(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
|
972 | silc_file_writefile(filename2, tmp, len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
973 | silc_mime_free(extension); |
| 8849 | 974 | } |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
975 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
976 | /* 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
|
977 | 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
|
978 | 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
|
979 | 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
|
980 | (!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
|
981 | !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
|
982 | !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
|
983 | !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
|
984 | 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
|
985 | 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
|
986 | 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
|
987 | 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
|
988 | /* 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
|
989 | 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
|
990 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
991 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
992 | silc_mime_free(usericon); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
993 | } |
| 8849 | 994 | } |
| 995 | ||
| 996 | /* Save the public key path to buddy properties, as it is used | |
| 997 | to identify the buddy in the network (and not the nickname). */ | |
| 998 | memset(filename, 0, sizeof(filename)); | |
| 999 | g_snprintf(filename, sizeof(filename) - 1, | |
| 1000 | "%s" G_DIR_SEPARATOR_S "clientkeys" G_DIR_SEPARATOR_S "clientkey_%s.pub", | |
| 15884 | 1001 | silcpurple_silcdir(), fingerprint); |
| 1002 | purple_blist_node_set_string((PurpleBlistNode *)b, "public-key", filename); | |
| 8849 | 1003 | |
|
10050
78e480f768f2
[gaim-migrate @ 11011]
Dave West <kat@users.sourceforge.net>
parents:
10029
diff
changeset
|
1004 | /* Update online status */ |
| 15884 | 1005 | purple_prpl_got_user_status(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), SILCPURPLE_STATUS_ID_AVAILABLE, NULL); |
| 8849 | 1006 | |
| 1007 | /* Finally, start watching this user so we receive its status | |
| 1008 | changes from the server */ | |
| 1009 | g_snprintf(filename2, sizeof(filename2) - 1, "+%s", filename); | |
| 1010 | silc_client_command_call(r->client, r->conn, NULL, "WATCH", "-pubkey", | |
| 1011 | filename2, NULL); | |
| 1012 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1013 | silc_hash_free(hash); |
| 8849 | 1014 | 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
|
1015 | 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
|
1016 | 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
|
1017 | silc_pkcs_public_key_free(r->public_key); |
| 8849 | 1018 | silc_free(r); |
| 1019 | } | |
| 1020 | ||
| 1021 | static void | |
| 15884 | 1022 | silcpurple_add_buddy_ask_import(void *user_data, const char *name) |
| 8849 | 1023 | { |
| 15884 | 1024 | SilcPurpleBuddyRes r = (SilcPurpleBuddyRes)user_data; |
| 8849 | 1025 | |
| 1026 | /* 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
|
1027 | if (!silc_pkcs_load_public_key(name, &r->public_key)) { |
| 15884 | 1028 | silcpurple_add_buddy_ask_pk_cb(r, 0); |
| 1029 | purple_notify_error(r->client->application, | |
| 8849 | 1030 | _("Add Buddy"), _("Could not load public key"), NULL); |
| 1031 | return; | |
| 1032 | } | |
| 1033 | ||
| 1034 | /* 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
|
1035 | r->offline_pk = silc_pkcs_public_key_encode(r->public_key, &r->offline_pk_len); |
| 15884 | 1036 | silcpurple_verify_public_key(r->client, r->conn, r->b->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
|
1037 | 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
|
1038 | silcpurple_add_buddy_save, r); |
| 8849 | 1039 | } |
| 1040 | ||
| 1041 | static void | |
| 15884 | 1042 | silcpurple_add_buddy_ask_pk_cancel(void *user_data, const char *name) |
| 8849 | 1043 | { |
| 15884 | 1044 | SilcPurpleBuddyRes r = (SilcPurpleBuddyRes)user_data; |
| 8849 | 1045 | |
| 1046 | /* The user did not import public key. The buddy is unusable. */ | |
| 15884 | 1047 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1048 | silc_free(r); |
| 1049 | } | |
| 1050 | ||
| 1051 | static void | |
| 15884 | 1052 | silcpurple_add_buddy_ask_pk_cb(SilcPurpleBuddyRes r, gint id) |
| 8849 | 1053 | { |
| 1054 | if (id != 0) { | |
| 1055 | /* The user did not import public key. The buddy is unusable. */ | |
| 15884 | 1056 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1057 | silc_free(r); |
| 1058 | return; | |
| 1059 | } | |
| 1060 | ||
| 1061 | /* Open file selector to select the public key. */ | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1062 | 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
|
1063 | 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
|
1064 | G_CALLBACK(silcpurple_add_buddy_ask_pk_cancel), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1065 | 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
|
1066 | |
| 8849 | 1067 | } |
| 1068 | ||
| 1069 | static void | |
| 15884 | 1070 | silcpurple_add_buddy_ask_pk(SilcPurpleBuddyRes r) |
| 8849 | 1071 | { |
| 1072 | char tmp[512]; | |
| 1073 | g_snprintf(tmp, sizeof(tmp), _("The %s buddy is not present in the network"), | |
| 1074 | r->b->name); | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1075 | 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
|
1076 | _("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
|
1077 | "Press Import to import a public key."), 0, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1078 | 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
|
1079 | _("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
|
1080 | _("_Import..."), G_CALLBACK(silcpurple_add_buddy_ask_pk_cb)); |
| 8849 | 1081 | } |
| 1082 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1083 | 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
|
1084 | 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
|
1085 | 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
|
1086 | SilcStatus error, void *context, va_list ap) |
| 8849 | 1087 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1088 | SilcPurpleBuddyRes r = context; |
| 8849 | 1089 | 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
|
1090 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1091 | 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
|
1092 | /* 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
|
1093 | 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
|
1094 | 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
|
1095 | 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
|
1096 | 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
|
1097 | 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
|
1098 | } |
| 8849 | 1099 | |
| 1100 | /* Get the client entry. */ | |
| 1101 | client_entry = silc_client_get_client_by_id(r->client, r->conn, | |
| 1102 | &r->client_id); | |
| 1103 | if (!client_entry || !client_entry->public_key) { | |
| 1104 | /* The buddy is offline/nonexistent. We will require user | |
| 1105 | to associate a public key with the buddy or the buddy | |
| 1106 | cannot be added. */ | |
| 1107 | r->offline = TRUE; | |
| 15884 | 1108 | 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
|
1109 | return FALSE; |
| 8849 | 1110 | } |
| 1111 | ||
| 1112 | /* Now verify the public key */ | |
| 15884 | 1113 | 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
|
1114 | 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
|
1115 | 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
|
1116 | return TRUE; |
| 8849 | 1117 | } |
| 1118 | ||
| 1119 | static void | |
| 15884 | 1120 | silcpurple_add_buddy_select_cb(SilcPurpleBuddyRes r, PurpleRequestFields *fields) |
| 8849 | 1121 | { |
| 15884 | 1122 | 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
|
1123 | GList *list; |
| 8849 | 1124 | 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
|
1125 | SilcDList clients; |
| 8849 | 1126 | |
| 15884 | 1127 | f = purple_request_fields_get_field(fields, "list"); |
| 1128 | list = purple_request_field_list_get_selected(f); | |
| 8849 | 1129 | if (!list) { |
| 1130 | /* The user did not select any user. */ | |
| 15884 | 1131 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1132 | silc_free(r); |
| 1133 | return; | |
| 1134 | } | |
| 1135 | ||
| 15884 | 1136 | 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
|
1137 | 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
|
1138 | 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
|
1139 | 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
|
1140 | 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
|
1141 | silc_dlist_uninit(clients); |
| 8849 | 1142 | } |
| 1143 | ||
| 1144 | static void | |
| 15884 | 1145 | silcpurple_add_buddy_select_cancel(SilcPurpleBuddyRes r, PurpleRequestFields *fields) |
| 8849 | 1146 | { |
| 1147 | /* The user did not select any user. */ | |
| 15884 | 1148 | silcpurple_add_buddy_pk_no(r); |
| 8849 | 1149 | silc_free(r); |
| 1150 | } | |
| 1151 | ||
| 1152 | 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
|
1153 | silcpurple_add_buddy_select(SilcPurpleBuddyRes r, SilcDList clients) |
| 8849 | 1154 | { |
| 15884 | 1155 | PurpleRequestFields *fields; |
| 1156 | PurpleRequestFieldGroup *g; | |
| 1157 | PurpleRequestField *f; | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1158 | char tmp[512], tmp2[128]; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1159 | 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
|
1160 | SilcClientEntry client_entry; |
| 8849 | 1161 | |
| 15884 | 1162 | fields = purple_request_fields_new(); |
| 1163 | g = purple_request_field_group_new(NULL); | |
| 1164 | f = purple_request_field_list_new("list", NULL); | |
| 1165 | purple_request_field_group_add_field(g, f); | |
| 1166 | purple_request_field_list_set_multi_select(f, FALSE); | |
| 1167 | purple_request_fields_add_group(fields, g); | |
| 8849 | 1168 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1169 | 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
|
1170 | while ((client_entry = silc_dlist_get(clients))) { |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1171 | 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
|
1172 | 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
|
1173 | fingerprint = silc_fingerprint(client_entry->fingerprint, 20); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1174 | g_snprintf(tmp2, sizeof(tmp2), "\n%s", fingerprint); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1175 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1176 | 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
|
1177 | 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
|
1178 | 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
|
1179 | client_entry->hostname : "", |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1180 | 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
|
1181 | purple_request_field_list_add(f, tmp, client_entry); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1182 | silc_free(fingerprint); |
| 8849 | 1183 | } |
| 1184 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1185 | 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
|
1186 | _("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
|
1187 | 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
|
1188 | ? _("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
|
1189 | "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
|
1190 | : _("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
|
1191 | "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
|
1192 | fields, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1193 | _("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
|
1194 | _("Cancel"), G_CALLBACK(silcpurple_add_buddy_select_cancel), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1195 | purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), NULL, r); |
| 8849 | 1196 | } |
| 1197 | ||
| 1198 | static void | |
| 15884 | 1199 | 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
|
1200 | 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
|
1201 | 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
|
1202 | 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
|
1203 | void *context) |
| 8849 | 1204 | { |
| 15884 | 1205 | SilcPurpleBuddyRes r = context; |
| 1206 | PurpleBuddy *b = r->b; | |
| 8849 | 1207 | SilcAttributePayload pub; |
| 1208 | SilcAttributeObjPk userpk; | |
| 1209 | 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
|
1210 | 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
|
1211 | SilcUInt16 cmd_ident; |
| 8849 | 1212 | |
| 15884 | 1213 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1214 | |
| 8849 | 1215 | /* If the buddy is offline/nonexistent, we will require user |
| 1216 | to associate a public key with the buddy or the buddy | |
| 1217 | cannot be added. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1218 | if (!clients) { |
| 8849 | 1219 | if (r->init) { |
| 1220 | silc_free(r); | |
| 1221 | return; | |
| 1222 | } | |
| 1223 | ||
| 1224 | r->offline = TRUE; | |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1225 | /* If the user has already associated a public key, try loading it |
|
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1226 | * before prompting the user to load it again */ |
|
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1227 | if (filename != NULL) |
| 15884 | 1228 | silcpurple_add_buddy_ask_import(r, filename); |
|
10029
849bb075efb9
[gaim-migrate @ 10965]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9927
diff
changeset
|
1229 | else |
| 15884 | 1230 | silcpurple_add_buddy_ask_pk(r); |
| 8849 | 1231 | return; |
| 1232 | } | |
| 1233 | ||
| 1234 | /* If more than one client was found with nickname, we need to verify | |
| 1235 | from user which one is the correct. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1236 | if (silc_dlist_count(clients) > 1 && !r->pubkey_search) { |
| 8849 | 1237 | if (r->init) { |
| 1238 | silc_free(r); | |
| 1239 | return; | |
| 1240 | } | |
| 1241 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1242 | silcpurple_add_buddy_select(r, clients); |
| 8849 | 1243 | return; |
| 1244 | } | |
| 1245 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1246 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1247 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1248 | |
| 8849 | 1249 | /* If we searched using public keys and more than one entry was found |
| 1250 | the same person is logged on multiple times. */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1251 | if (silc_dlist_count(clients) > 1 && r->pubkey_search && b->name) { |
| 8849 | 1252 | if (r->init) { |
| 1253 | /* Find the entry that closest matches to the | |
| 1254 | 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
|
1255 | 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
|
1256 | 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
|
1257 | while ((entry = silc_dlist_get(clients))) { |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18190
diff
changeset
|
1258 | if (!g_ascii_strncasecmp(b->name, entry->nickname, |
| 8849 | 1259 | strlen(b->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
|
1260 | client_entry = entry; |
| 8849 | 1261 | break; |
| 1262 | } | |
| 1263 | } | |
| 1264 | } else { | |
| 1265 | /* 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
|
1266 | silcpurple_add_buddy_select(r, clients); |
| 8849 | 1267 | return; |
| 1268 | } | |
| 1269 | } | |
| 1270 | ||
| 1271 | /* The client was found. Now get its public key and verify | |
| 1272 | that before adding the buddy. */ | |
| 1273 | 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
|
1274 | 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
|
1275 | r->client_id = client_entry->id; |
| 8849 | 1276 | |
| 1277 | /* Get the public key from attributes, if not present then | |
| 1278 | 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
|
1279 | 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
|
1280 | 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
|
1281 | SILC_ATTRIBUTE_USER_PUBLIC_KEY); |
| 8849 | 1282 | if (!pub || !silc_attribute_get_object(pub, (void *)&userpk, |
| 1283 | sizeof(userpk))) { | |
| 1284 | /* 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
|
1285 | 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
|
1286 | 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
|
1287 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1288 | 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
|
1289 | 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
|
1290 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1291 | r); |
| 1292 | return; | |
| 1293 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1294 | 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
|
1295 | 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
|
1296 | &client_entry->public_key)) |
| 8849 | 1297 | return; |
| 1298 | 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
|
1299 | } 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
|
1300 | if (!silc_pkcs_load_public_key(filename, &client_entry->public_key)) { |
| 8849 | 1301 | /* 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
|
1302 | 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
|
1303 | 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
|
1304 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1305 | 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
|
1306 | 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
|
1307 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1308 | r); |
| 1309 | return; | |
| 1310 | } | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1311 | } else if (!client_entry->public_key) { |
| 8849 | 1312 | /* 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
|
1313 | cmd_ident = |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1314 | 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
|
1315 | "GETKEY", client_entry->nickname, NULL); |
| 8849 | 1316 | 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
|
1317 | 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
|
1318 | silcpurple_add_buddy_getkey_cb, |
| 8849 | 1319 | r); |
| 1320 | return; | |
| 1321 | } | |
| 1322 | ||
| 1323 | /* 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
|
1324 | 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
|
1325 | 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
|
1326 | 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
|
1327 | silcpurple_add_buddy_save, r); |
| 8849 | 1328 | } |
| 1329 | ||
| 1330 | static void | |
| 15884 | 1331 | silcpurple_add_buddy_i(PurpleConnection *gc, PurpleBuddy *b, gboolean init) |
| 8849 | 1332 | { |
| 15884 | 1333 | SilcPurple sg = gc->proto_data; |
| 8849 | 1334 | SilcClient client = sg->client; |
| 1335 | SilcClientConnection conn = sg->conn; | |
| 15884 | 1336 | SilcPurpleBuddyRes r; |
| 8849 | 1337 | SilcBuffer attrs; |
| 1338 | const char *filename, *name = b->name; | |
| 1339 | ||
| 1340 | r = silc_calloc(1, sizeof(*r)); | |
| 1341 | if (!r) | |
| 1342 | return; | |
| 1343 | r->client = client; | |
| 1344 | r->conn = conn; | |
| 1345 | r->b = b; | |
| 1346 | r->init = init; | |
| 1347 | ||
| 1348 | /* See if we have this buddy's public key. If we do use that | |
| 1349 | to search the details. */ | |
| 15884 | 1350 | filename = purple_blist_node_get_string((PurpleBlistNode *)b, "public-key"); |
| 8849 | 1351 | if (filename) { |
| 1352 | SilcPublicKey public_key; | |
| 1353 | SilcAttributeObjPk userpk; | |
| 1354 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1355 | if (!silc_pkcs_load_public_key(filename, &public_key)) |
| 8849 | 1356 | return; |
| 1357 | ||
| 1358 | /* Get all attributes, and use the public key to search user */ | |
| 1359 | name = NULL; | |
| 1360 | attrs = silc_client_attributes_request(SILC_ATTRIBUTE_USER_INFO, | |
| 1361 | SILC_ATTRIBUTE_SERVICE, | |
| 1362 | SILC_ATTRIBUTE_STATUS_MOOD, | |
| 1363 | SILC_ATTRIBUTE_STATUS_FREETEXT, | |
| 1364 | SILC_ATTRIBUTE_STATUS_MESSAGE, | |
| 1365 | SILC_ATTRIBUTE_PREFERRED_LANGUAGE, | |
| 1366 | SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
| 1367 | SILC_ATTRIBUTE_TIMEZONE, | |
| 1368 | SILC_ATTRIBUTE_GEOLOCATION, | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1369 | SILC_ATTRIBUTE_USER_ICON, |
| 8849 | 1370 | SILC_ATTRIBUTE_DEVICE_INFO, 0); |
| 1371 | userpk.type = "silc-rsa"; | |
| 1372 | userpk.data = silc_pkcs_public_key_encode(public_key, &userpk.data_len); | |
| 1373 | attrs = silc_attribute_payload_encode(attrs, | |
| 1374 | SILC_ATTRIBUTE_USER_PUBLIC_KEY, | |
| 1375 | SILC_ATTRIBUTE_FLAG_VALID, | |
| 1376 | &userpk, sizeof(userpk)); | |
| 1377 | silc_free(userpk.data); | |
| 1378 | silc_pkcs_public_key_free(public_key); | |
| 1379 | r->pubkey_search = TRUE; | |
| 1380 | } else { | |
| 1381 | /* Get all attributes */ | |
| 1382 | attrs = silc_client_attributes_request(0); | |
| 1383 | } | |
| 1384 | ||
| 1385 | /* Resolve */ | |
| 1386 | silc_client_get_clients_whois(client, conn, name, NULL, attrs, | |
| 15884 | 1387 | silcpurple_add_buddy_resolved, r); |
| 8849 | 1388 | silc_buffer_free(attrs); |
| 1389 | } | |
| 1390 | ||
| 15884 | 1391 | void silcpurple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 8849 | 1392 | { |
| 15884 | 1393 | silcpurple_add_buddy_i(gc, buddy, FALSE); |
| 8849 | 1394 | } |
| 1395 | ||
| 15884 | 1396 | void silcpurple_send_buddylist(PurpleConnection *gc) |
|
10341
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1397 | { |
| 15884 | 1398 | PurpleBuddyList *blist; |
| 1399 | PurpleBlistNode *gnode, *cnode, *bnode; | |
| 1400 | PurpleBuddy *buddy; | |
| 1401 | PurpleAccount *account; | |
|
12111
a939a3c185f9
[gaim-migrate @ 14411]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12058
diff
changeset
|
1402 | |
| 15884 | 1403 | account = purple_connection_get_account(gc); |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1404 | |
| 15884 | 1405 | if ((blist = purple_get_blist()) != NULL) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1406 | { |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1407 | for (gnode = blist->root; gnode != NULL; gnode = gnode->next) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1408 | { |
| 15884 | 1409 | if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1410 | continue; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1411 | for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1412 | { |
| 15884 | 1413 | if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1414 | continue; |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1415 | for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1416 | { |
| 15884 | 1417 | if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1418 | continue; |
| 15884 | 1419 | buddy = (PurpleBuddy *)bnode; |
| 1420 | if (purple_buddy_get_account(buddy) == account) | |
| 1421 | silcpurple_add_buddy_i(gc, buddy, TRUE); | |
|
10869
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1422 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1423 | } |
|
86a3144baf08
[gaim-migrate @ 12556]
Mark Doliner <markdoliner@pidgin.im>
parents:
10662
diff
changeset
|
1424 | } |
|
10341
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1425 | } |
|
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1426 | } |
|
92c66f97b73f
[gaim-migrate @ 11550]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
1427 | |
| 15884 | 1428 | void silcpurple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, |
| 1429 | PurpleGroup *group) | |
| 8849 | 1430 | { |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9272
diff
changeset
|
1431 | silc_free(buddy->proto_data); |
| 8849 | 1432 | } |
| 1433 | ||
| 15884 | 1434 | void silcpurple_idle_set(PurpleConnection *gc, int idle) |
| 8849 | 1435 | |
| 1436 | { | |
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1437 | SilcPurple sg; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1438 | SilcClient client; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1439 | SilcClientConnection conn; |
| 8849 | 1440 | SilcAttributeObjService service; |
| 1441 | const char *server; | |
| 1442 | int port; | |
| 1443 | ||
|
23196
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1444 | sg = gc->proto_data; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1445 | if (sg == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1446 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1447 | |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1448 | client = sg->client; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1449 | if (client == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1450 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1451 | |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1452 | conn = sg->conn; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1453 | if (conn == NULL) |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1454 | return; |
|
ee37c234be19
applied changes from 7f7111ed9e5924db9e740ad354fce8fb82445b1e
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22972
diff
changeset
|
1455 | |
| 15884 | 1456 | server = purple_account_get_string(sg->account, "server", |
| 8849 | 1457 | "silc.silcnet.org"); |
| 15884 | 1458 | port = purple_account_get_int(sg->account, "port", 706), |
| 8849 | 1459 | |
| 1460 | memset(&service, 0, sizeof(service)); | |
| 1461 | silc_client_attribute_del(client, conn, | |
| 1462 | SILC_ATTRIBUTE_SERVICE, NULL); | |
| 1463 | service.port = port; | |
| 1464 | g_snprintf(service.address, sizeof(service.address), "%s", server); | |
| 1465 | service.idle = idle; | |
| 1466 | silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_SERVICE, | |
| 1467 | &service, sizeof(service)); | |
| 1468 | } | |
| 1469 | ||
| 15884 | 1470 | char *silcpurple_status_text(PurpleBuddy *b) |
| 8849 | 1471 | { |
| 15884 | 1472 | SilcPurple sg = b->account->gc->proto_data; |
| 8849 | 1473 | SilcClient client = sg->client; |
| 1474 | SilcClientConnection conn = sg->conn; | |
| 1475 | SilcClientID *client_id = b->proto_data; | |
| 1476 | SilcClientEntry client_entry; | |
| 1477 | SilcAttributePayload attr; | |
| 1478 | SilcAttributeMood mood = 0; | |
| 1479 | ||
| 1480 | /* Get the client entry. */ | |
| 1481 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1482 | if (!client_entry) | |
| 1483 | return NULL; | |
| 1484 | ||
| 1485 | /* If user is online, we show the mood status, if available. | |
| 1486 | If user is offline or away that status is indicated. */ | |
| 1487 | ||
| 1488 | if (client_entry->mode & SILC_UMODE_DETACHED) | |
| 1489 | return g_strdup(_("Detached")); | |
| 1490 | if (client_entry->mode & SILC_UMODE_GONE) | |
| 1491 | return g_strdup(_("Away")); | |
| 1492 | if (client_entry->mode & SILC_UMODE_INDISPOSED) | |
| 1493 | return g_strdup(_("Indisposed")); | |
| 1494 | if (client_entry->mode & SILC_UMODE_BUSY) | |
| 1495 | return g_strdup(_("Busy")); | |
| 1496 | if (client_entry->mode & SILC_UMODE_PAGE) | |
| 1497 | return g_strdup(_("Wake Me Up")); | |
| 1498 | if (client_entry->mode & SILC_UMODE_HYPER) | |
| 1499 | return g_strdup(_("Hyper Active")); | |
| 1500 | if (client_entry->mode & SILC_UMODE_ROBOT) | |
| 1501 | return g_strdup(_("Robot")); | |
| 1502 | ||
| 15884 | 1503 | attr = silcpurple_get_attr(client_entry->attrs, SILC_ATTRIBUTE_STATUS_MOOD); |
| 8849 | 1504 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { |
| 1505 | /* The mood is a bit mask, so we could show multiple moods, | |
| 1506 | but let's show only one for now. */ | |
| 1507 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) | |
| 1508 | return g_strdup(_("Happy")); | |
| 1509 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) | |
| 1510 | return g_strdup(_("Sad")); | |
| 1511 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) | |
| 1512 | return g_strdup(_("Angry")); | |
| 1513 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) | |
| 1514 | return g_strdup(_("Jealous")); | |
| 1515 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) | |
| 1516 | return g_strdup(_("Ashamed")); | |
| 1517 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) | |
| 1518 | return g_strdup(_("Invincible")); | |
| 1519 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) | |
| 1520 | return g_strdup(_("In Love")); | |
| 1521 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) | |
| 1522 | return g_strdup(_("Sleepy")); | |
| 1523 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) | |
| 1524 | return g_strdup(_("Bored")); | |
| 1525 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) | |
| 1526 | return g_strdup(_("Excited")); | |
| 1527 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) | |
| 1528 | return g_strdup(_("Anxious")); | |
| 1529 | } | |
| 1530 | ||
| 1531 | return NULL; | |
| 1532 | } | |
| 1533 | ||
| 15884 | 1534 | void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) |
| 8849 | 1535 | { |
| 15884 | 1536 | SilcPurple sg = b->account->gc->proto_data; |
| 8849 | 1537 | SilcClient client = sg->client; |
| 1538 | SilcClientConnection conn = sg->conn; | |
| 1539 | SilcClientID *client_id = b->proto_data; | |
| 1540 | SilcClientEntry client_entry; | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1541 | char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; |
| 8849 | 1542 | char tmp[256]; |
| 1543 | ||
| 1544 | /* Get the client entry. */ | |
| 1545 | client_entry = silc_client_get_client_by_id(client, conn, client_id); | |
| 1546 | if (!client_entry) | |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1547 | return; |
| 8849 | 1548 | |
| 1549 | if (client_entry->nickname) | |
| 15884 | 1550 | purple_notify_user_info_add_pair(user_info, _("Nickname"), |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1551 | client_entry->nickname); |
|
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1552 | if (client_entry->username && client_entry->hostname) { |
|
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1553 | g_snprintf(tmp, sizeof(tmp), "%s@%s", client_entry->username, client_entry->hostname); |
| 15884 | 1554 | purple_notify_user_info_add_pair(user_info, _("Username"), tmp); |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1555 | } |
| 8849 | 1556 | if (client_entry->mode) { |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1557 | memset(tmp, 0, sizeof(tmp)); |
| 15884 | 1558 | silcpurple_get_umode_string(client_entry->mode, |
|
15234
25f4aabfdcaf
[gaim-migrate @ 17958]
Daniel Atallah <datallah@pidgin.im>
parents:
14254
diff
changeset
|
1559 | tmp, sizeof(tmp) - strlen(tmp)); |
| 15884 | 1560 | purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp); |
| 8849 | 1561 | } |
| 1562 | ||
| 15884 | 1563 | 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
|
1564 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1565 | if (statusstr) { |
| 15884 | 1566 | purple_notify_user_info_add_pair(user_info, _("Message"), statusstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1567 | g_free(statusstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1568 | } |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1569 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1570 | if (full) { |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1571 | if (moodstr) { |
| 15884 | 1572 | purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1573 | g_free(moodstr); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1574 | } |
| 8849 | 1575 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1576 | if (contactstr) { |
| 15884 | 1577 | 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
|
1578 | g_free(contactstr); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1579 | } |
| 8849 | 1580 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1581 | if (langstr) { |
| 15884 | 1582 | 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
|
1583 | g_free(langstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1584 | } |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1585 | |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1586 | if (devicestr) { |
| 15884 | 1587 | purple_notify_user_info_add_pair(user_info, _("Device"), devicestr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1588 | g_free(devicestr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1589 | } |
| 8849 | 1590 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1591 | if (tzstr) { |
| 15884 | 1592 | purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1593 | g_free(tzstr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1594 | } |
| 8849 | 1595 | |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1596 | if (geostr) { |
| 15884 | 1597 | purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr); |
|
12948
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1598 | g_free(geostr); |
|
0867a553ed26
[gaim-migrate @ 15301]
Richard Laager <rlaager@pidgin.im>
parents:
12947
diff
changeset
|
1599 | } |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1600 | } |
| 8849 | 1601 | } |
| 1602 | ||
| 1603 | static void | |
| 15884 | 1604 | silcpurple_buddy_kill(PurpleBlistNode *node, gpointer data) |
| 8849 | 1605 | { |
| 15884 | 1606 | PurpleBuddy *b; |
| 1607 | PurpleConnection *gc; | |
| 1608 | SilcPurple sg; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1609 | |
| 15884 | 1610 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1611 | |
| 15884 | 1612 | b = (PurpleBuddy *) node; |
| 1613 | gc = purple_account_get_connection(b->account); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1614 | sg = gc->proto_data; |
| 8849 | 1615 | |
| 1616 | /* Call KILL */ | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1617 | silc_client_command_call(sg->client, sg->conn, NULL, "KILL", |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1618 | b->name, "Killed by operator", NULL); |
| 8849 | 1619 | } |
| 1620 | ||
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1621 | typedef struct { |
| 15884 | 1622 | SilcPurple sg; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1623 | SilcClientEntry client_entry; |
| 15884 | 1624 | } *SilcPurpleBuddyWb; |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1625 | |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1626 | static void |
| 15884 | 1627 | silcpurple_buddy_wb(PurpleBlistNode *node, gpointer data) |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1628 | { |
| 15884 | 1629 | SilcPurpleBuddyWb wb = data; |
| 1630 | silcpurple_wb_init(wb->sg, wb->client_entry); | |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1631 | silc_free(wb); |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1632 | } |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11586
diff
changeset
|
1633 | |
| 15884 | 1634 | GList *silcpurple_buddy_menu(PurpleBuddy *buddy) |
| 8849 | 1635 | { |
| 15884 | 1636 | PurpleConnection *gc = purple_account_get_connection(buddy->account); |
| 1637 | SilcPurple sg = gc->proto_data; | |
| 8849 | 1638 | SilcClientConnection conn = sg->conn; |
| 1639 | const char *pkfile = NULL; | |
| 1640 | SilcClientEntry client_entry = NULL; | |
| 15884 | 1641 | PurpleMenuAction *act; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1642 | GList *m = NULL; |
| 15884 | 1643 | SilcPurpleBuddyWb wb; |
| 8849 | 1644 | |
| 15884 | 1645 | pkfile = purple_blist_node_get_string((PurpleBlistNode *) buddy, "public-key"); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1646 | client_entry = silc_client_get_client_by_id(sg->client, |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1647 | sg->conn, |
| 9038 | 1648 | buddy->proto_data); |
| 8849 | 1649 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1650 | if (client_entry && |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1651 | silc_client_private_message_key_is_set(sg->client, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1652 | sg->conn, client_entry)) { |
| 15884 | 1653 | act = purple_menu_action_new(_("Reset IM Key"), |
| 1654 | PURPLE_CALLBACK(silcpurple_buddy_resetkey), | |
| 12919 | 1655 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1656 | m = g_list_append(m, act); |
| 8849 | 1657 | } else { |
| 15884 | 1658 | act = purple_menu_action_new(_("IM with Key Exchange"), |
| 1659 | PURPLE_CALLBACK(silcpurple_buddy_keyagr), | |
| 12919 | 1660 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1661 | m = g_list_append(m, act); |
| 8849 | 1662 | |
| 15884 | 1663 | act = purple_menu_action_new(_("IM with Password"), |
| 1664 | PURPLE_CALLBACK(silcpurple_buddy_privkey_menu), | |
| 12919 | 1665 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1666 | m = g_list_append(m, act); |
| 8849 | 1667 | } |
| 1668 | ||
| 1669 | if (pkfile) { | |
| 15884 | 1670 | act = purple_menu_action_new(_("Show Public Key"), |
| 1671 | PURPLE_CALLBACK(silcpurple_buddy_showkey), | |
| 12919 | 1672 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1673 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1674 | |
| 8849 | 1675 | } else { |
| 15884 | 1676 | act = purple_menu_action_new(_("Get Public Key..."), |
| 1677 | PURPLE_CALLBACK(silcpurple_buddy_getkey_menu), | |
| 12919 | 1678 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1679 | m = g_list_append(m, act); |
| 8849 | 1680 | } |
| 1681 | ||
| 1682 | if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { | |
| 15884 | 1683 | act = purple_menu_action_new(_("Kill User"), |
| 1684 | PURPLE_CALLBACK(silcpurple_buddy_kill), | |
| 12919 | 1685 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
8910
diff
changeset
|
1686 | m = g_list_append(m, act); |
| 8849 | 1687 | } |
| 1688 | ||
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1689 | if (client_entry) { |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1690 | wb = silc_calloc(1, sizeof(*wb)); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1691 | wb->sg = sg; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1692 | wb->client_entry = client_entry; |
| 15884 | 1693 | act = purple_menu_action_new(_("Draw On Whiteboard"), |
| 1694 | PURPLE_CALLBACK(silcpurple_buddy_wb), | |
| 12919 | 1695 | (void *)wb, NULL); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1696 | m = g_list_append(m, act); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12111
diff
changeset
|
1697 | } |
| 8849 | 1698 | return m; |
| 1699 | } | |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1700 | |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1701 | void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1702 | { |
| 15884 | 1703 | SilcPurple sg = gc->proto_data; |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1704 | SilcClient client = sg->client; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1705 | SilcClientConnection conn = sg->conn; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1706 | SilcMime mime; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1707 | char type[32]; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1708 | const char *t; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1709 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1710 | /* Remove */ |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1711 | if (!img) { |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1712 | silc_client_attribute_del(client, conn, |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1713 | SILC_ATTRIBUTE_USER_ICON, NULL); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1714 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1715 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1716 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1717 | /* Add */ |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1718 | mime = silc_mime_alloc(); |
|
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1719 | if (!mime) |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1720 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1721 | |
|
16672
0d38368057c7
Use the purple_imgstore_get_extension() convienence function.
Richard Laager <rlaager@pidgin.im>
parents:
16549
diff
changeset
|
1722 | t = purple_imgstore_get_extension(img); |
|
16437
7ff7c3405ea2
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
1723 | if (!t || !strcmp(t, "icon")) { |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1724 | silc_mime_free(mime); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1725 | return; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1726 | } |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1727 | if (!strcmp(t, "jpg")) |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1728 | t = "jpeg"; |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1729 | g_snprintf(type, sizeof(type), "image/%s", t); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1730 | silc_mime_add_field(mime, "Content-Type", type); |
|
16549
59e5ad39510c
Update SILC for imgstore changes.
Daniel Atallah <datallah@pidgin.im>
parents:
16545
diff
changeset
|
1731 | silc_mime_add_data(mime, purple_imgstore_get_data(img), purple_imgstore_get_size(img)); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1732 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1733 | silc_client_attribute_add(client, conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16672
diff
changeset
|
1734 | SILC_ATTRIBUTE_USER_ICON, mime, sizeof(*mime)); |
|
12761
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1735 | |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1736 | silc_mime_free(mime); |
|
f9b56ebfe562
[gaim-migrate @ 15108]
Pekka Riikonen <priikone@silcnet.org>
parents:
12603
diff
changeset
|
1737 | } |