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