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