libpurple/protocols/silc10/buddy.c

Sat, 09 Jun 2007 16:39:00 +0000

author
Stu Tomlinson <nosnilmot@pidgin.im>
date
Sat, 09 Jun 2007 16:39:00 +0000
changeset 17674
aafdd7bed36d
child 18190
bcf28ef7e8ff
permissions
-rw-r--r--

Duplicate the current SILC prpl as silc10 for backwards compatibility with
SILC Toolkit 1.0

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

mercurial