libpurple/protocols/silc/buddy.c

Thu, 06 Feb 2014 20:02:57 +0530

author
Ankit Vani <a@nevitus.org>
date
Thu, 06 Feb 2014 20:02:57 +0530
branch
soc.2013.gobjectification.plugins
changeset 37075
cf3f735b09b7
parent 37015
28ee14bbe0ab
child 37131
fe9ff76f1c6c
permissions
-rw-r--r--

Merge gtkdoc-conversion

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

mercurial