Fri, 30 Aug 2013 05:50:20 +0530
Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
| 8849 | 1 | /* |
| 2 | ||
| 15884 | 3 | silcpurple.c |
| 8849 | 4 | |
| 5 | Author: Pekka Riikonen <priikone@silcnet.org> | |
| 6 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
7 | Copyright (C) 2004 - 2007 Pekka Riikonen |
| 8849 | 8 | |
| 9 | This program is free software; you can redistribute it and/or modify | |
| 10 | it under the terms of the GNU General Public License as published by | |
| 11 | the Free Software Foundation; version 2 of the License. | |
| 12 | ||
| 13 | This program is distributed in the hope that it will be useful, | |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | GNU General Public License for more details. | |
| 17 | ||
| 18 | */ | |
| 19 | ||
|
28981
4e3922ab4844
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents:
27879
diff
changeset
|
20 | #include "internal.h" |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
21 | #include "plugins.h" |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
22 | #include "silc.h" |
| 8849 | 23 | #include "silcclient.h" |
| 15884 | 24 | #include "silcpurple.h" |
| 9943 | 25 | #include "version.h" |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11837
diff
changeset
|
26 | #include "wb.h" |
|
23551
b6109bbbbe6c
Added include for "core.h" to silc. Fix from phroggie, thanks. Fixes #6227
Evan Schoenberg <evands@pidgin.im>
parents:
23545
diff
changeset
|
27 | #include "core.h" |
| 8849 | 28 | |
| 29 | extern SilcClientOperations ops; | |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
30 | static PurpleProtocol *my_protocol = NULL; |
| 8849 | 31 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
32 | /* Error log message callback */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
33 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
34 | static SilcBool silcpurple_log_error(SilcLogType type, char *message, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
35 | void *context) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
36 | { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
37 | silc_say(NULL, NULL, SILC_CLIENT_MESSAGE_ERROR, message); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
38 | return TRUE; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
39 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
40 | |
| 8849 | 41 | static const char * |
| 15884 | 42 | silcpurple_list_icon(PurpleAccount *a, PurpleBuddy *b) |
| 8849 | 43 | { |
| 44 | return (const char *)"silc"; | |
| 45 | } | |
| 46 | ||
| 47 | static GList * | |
| 15884 | 48 | silcpurple_away_states(PurpleAccount *account) |
| 8849 | 49 | { |
| 15884 | 50 | PurpleStatusType *type; |
| 9968 | 51 | GList *types = NULL; |
| 8849 | 52 | |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
53 | type = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, SILCPURPLE_STATUS_ID_AVAILABLE, NULL, TRUE, TRUE, FALSE); |
| 9968 | 54 | types = g_list_append(types, type); |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
55 | type = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, SILCPURPLE_STATUS_ID_HYPER, _("Hyper Active"), TRUE, TRUE, FALSE); |
| 9968 | 56 | types = g_list_append(types, type); |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
57 | type = purple_status_type_new_full(PURPLE_STATUS_AWAY, SILCPURPLE_STATUS_ID_AWAY, NULL, TRUE, TRUE, FALSE); |
| 9968 | 58 | types = g_list_append(types, type); |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
59 | type = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE, SILCPURPLE_STATUS_ID_BUSY, _("Busy"), TRUE, TRUE, FALSE); |
| 9968 | 60 | types = g_list_append(types, type); |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
61 | type = purple_status_type_new_full(PURPLE_STATUS_AWAY, SILCPURPLE_STATUS_ID_INDISPOSED, _("Indisposed"), TRUE, TRUE, FALSE); |
| 9968 | 62 | types = g_list_append(types, type); |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
63 | type = purple_status_type_new_full(PURPLE_STATUS_AWAY, SILCPURPLE_STATUS_ID_PAGE, _("Wake Me Up"), TRUE, TRUE, FALSE); |
| 9968 | 64 | types = g_list_append(types, type); |
|
25552
ffd94785b2ad
For some reason, all these statuses were set to saveable=FALSE. With the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25545
diff
changeset
|
65 | type = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, SILCPURPLE_STATUS_ID_OFFLINE, NULL, TRUE, TRUE, FALSE); |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
66 | types = g_list_append(types, type); |
| 8849 | 67 | |
| 9968 | 68 | return types; |
| 8849 | 69 | } |
| 70 | ||
| 71 | static void | |
| 15884 | 72 | silcpurple_set_status(PurpleAccount *account, PurpleStatus *status) |
| 8849 | 73 | { |
| 15884 | 74 | PurpleConnection *gc = purple_account_get_connection(account); |
| 75 | SilcPurple sg = NULL; | |
| 8849 | 76 | SilcUInt32 mode; |
| 77 | SilcBuffer idp; | |
| 78 | unsigned char mb[4]; | |
| 9968 | 79 | const char *state; |
| 8849 | 80 | |
|
10801
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
81 | if (gc != NULL) |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
82 | sg = purple_connection_get_protocol_data(gc); |
|
10801
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
83 | |
|
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
84 | if (status == NULL) |
|
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
85 | return; |
|
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
86 | |
| 15884 | 87 | state = purple_status_get_id(status); |
|
10225
0dfea1bc8695
[gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10050
diff
changeset
|
88 | |
|
10801
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
89 | if (state == NULL) |
|
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
90 | return; |
|
10225
0dfea1bc8695
[gaim-migrate @ 11357]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10050
diff
changeset
|
91 | |
|
10801
b5f44181183f
[gaim-migrate @ 12447]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
92 | if ((sg == NULL) || (sg->conn == NULL)) |
| 8849 | 93 | return; |
| 94 | ||
| 95 | mode = sg->conn->local_entry->mode; | |
| 96 | mode &= ~(SILC_UMODE_GONE | | |
| 97 | SILC_UMODE_HYPER | | |
| 98 | SILC_UMODE_BUSY | | |
| 99 | SILC_UMODE_INDISPOSED | | |
| 100 | SILC_UMODE_PAGE); | |
| 101 | ||
| 9968 | 102 | if (!strcmp(state, "hyper")) |
| 8849 | 103 | mode |= SILC_UMODE_HYPER; |
| 9968 | 104 | else if (!strcmp(state, "away")) |
| 8849 | 105 | mode |= SILC_UMODE_GONE; |
| 9968 | 106 | else if (!strcmp(state, "busy")) |
| 8849 | 107 | mode |= SILC_UMODE_BUSY; |
| 9968 | 108 | else if (!strcmp(state, "indisposed")) |
| 8849 | 109 | mode |= SILC_UMODE_INDISPOSED; |
| 9968 | 110 | else if (!strcmp(state, "page")) |
| 8849 | 111 | mode |= SILC_UMODE_PAGE; |
| 112 | ||
| 113 | /* Send UMODE */ | |
| 114 | idp = silc_id_payload_encode(sg->conn->local_id, SILC_ID_CLIENT); | |
| 115 | SILC_PUT32_MSB(mode, mb); | |
| 116 | silc_client_command_send(sg->client, sg->conn, SILC_COMMAND_UMODE, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
117 | silcpurple_command_reply, NULL, 2, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
118 | 1, idp->data, silc_buffer_len(idp), |
| 8849 | 119 | 2, mb, sizeof(mb)); |
| 120 | silc_buffer_free(idp); | |
| 121 | } | |
| 122 | ||
| 123 | ||
| 124 | /*************************** Connection Routines *****************************/ | |
| 125 | ||
| 126 | static void | |
| 15884 | 127 | silcpurple_keepalive(PurpleConnection *gc) |
| 8849 | 128 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
129 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
130 | silc_packet_send(sg->conn->stream, SILC_PACKET_HEARTBEAT, 0, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
131 | NULL, 0); |
| 8849 | 132 | } |
| 133 | ||
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
134 | #if __SILC_TOOLKIT_VERSION < SILC_VERSION(1,1,1) |
|
17566
687225d827a2
300 milliseconds apparently works on win32 for the SILC scheduler, let's
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17564
diff
changeset
|
135 | static gboolean |
| 15884 | 136 | silcpurple_scheduler(gpointer *context) |
| 8849 | 137 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
138 | SilcClient client = (SilcClient)context; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
139 | silc_client_run_one(client); |
|
17566
687225d827a2
300 milliseconds apparently works on win32 for the SILC scheduler, let's
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17564
diff
changeset
|
140 | return TRUE; |
| 8849 | 141 | } |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
142 | #else |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
143 | typedef struct { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
144 | SilcPurple sg; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
145 | SilcUInt32 fd; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
146 | guint tag; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
147 | } *SilcPurpleTask; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
148 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
149 | /* A timeout occurred. Call SILC scheduler. */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
150 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
151 | static gboolean |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
152 | silcpurple_scheduler_timeout(gpointer context) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
153 | { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
154 | SilcPurpleTask task = (SilcPurpleTask)context; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
155 | silc_client_run_one(task->sg->client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
156 | silc_dlist_del(task->sg->tasks, task); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
157 | silc_free(task); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
158 | return FALSE; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
159 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
160 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
161 | /* An fd task event occurred. Call SILC scheduler. */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
162 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
163 | static void |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
164 | silcpurple_scheduler_fd(gpointer data, gint fd, PurpleInputCondition cond) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
165 | { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
166 | SilcClient client = (SilcClient)data; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
167 | silc_client_run_one(client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
168 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
169 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
170 | /* SILC Scheduler notify callback. This is called whenever task is added to |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
171 | or deleted from SILC scheduler. It's also called when fd task events |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
172 | change. Here we add same tasks to glib's main loop. */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
173 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
174 | static void |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
175 | silcpurple_scheduler(SilcSchedule schedule, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
176 | SilcBool added, SilcTask task, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
177 | SilcBool fd_task, SilcUInt32 fd, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
178 | SilcTaskEvent event, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
179 | long seconds, long useconds, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
180 | void *context) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
181 | { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
182 | SilcClient client = (SilcClient)context; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
183 | PurpleConnection *gc = client->application; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
184 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
185 | SilcPurpleTask ptask = NULL; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
186 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
187 | if (added) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
188 | if (fd_task) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
189 | /* Add fd or change fd events */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
190 | PurpleInputCondition e = 0; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
191 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
192 | silc_dlist_start(sg->tasks); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
193 | while ((ptask = silc_dlist_get(sg->tasks))) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
194 | if (ptask->fd == fd) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
195 | purple_input_remove(ptask->tag); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
196 | break; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
197 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
198 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
199 | if (event & SILC_TASK_READ) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
200 | e |= PURPLE_INPUT_READ; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
201 | if (event & SILC_TASK_WRITE) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
202 | e |= PURPLE_INPUT_WRITE; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
203 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
204 | if (e) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
205 | if (!ptask) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
206 | ptask = silc_calloc(1, sizeof(*ptask)); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
207 | ptask->fd = fd; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
208 | silc_dlist_add(sg->tasks, ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
209 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
210 | ptask->tag = purple_input_add(fd, e, silcpurple_scheduler_fd, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
211 | client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
212 | } else if (ptask) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
213 | silc_dlist_del(sg->tasks, ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
214 | silc_free(ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
215 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
216 | } else { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
217 | /* Add timeout */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
218 | ptask = silc_calloc(1, sizeof(*ptask)); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
219 | ptask->sg = sg; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
220 | ptask->tag = purple_timeout_add((seconds * 1000) + |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
221 | (useconds / 1000), |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
222 | silcpurple_scheduler_timeout, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
223 | ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
224 | silc_dlist_add(sg->tasks, ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
225 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
226 | } else { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
227 | if (fd_task) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
228 | /* Remove fd */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
229 | silc_dlist_start(sg->tasks); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
230 | while ((ptask = silc_dlist_get(sg->tasks))) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
231 | if (ptask->fd == fd) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
232 | purple_input_remove(ptask->tag); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
233 | silc_dlist_del(sg->tasks, ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
234 | silc_free(ptask); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
235 | break; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
236 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
237 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
238 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
239 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
240 | #endif /* __SILC_TOOLKIT_VERSION */ |
| 8849 | 241 | |
| 242 | static void | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
243 | silcpurple_connect_cb(SilcClient client, SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
244 | SilcClientConnectionStatus status, SilcStatus error, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
245 | const char *message, void *context) |
| 8849 | 246 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
247 | PurpleConnection *gc = context; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
248 | SilcPurple sg; |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
249 | SilcUInt32 mask; |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
250 | char tz[16]; |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
251 | PurpleStoredImage *img; |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
252 | #ifdef HAVE_SYS_UTSNAME_H |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
253 | struct utsname u; |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
254 | #endif |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
255 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
256 | sg = purple_connection_get_protocol_data(gc); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
257 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
258 | switch (status) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
259 | case SILC_CLIENT_CONN_SUCCESS: |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
260 | case SILC_CLIENT_CONN_SUCCESS_RESUME: |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
261 | sg->conn = conn; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
262 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
263 | /* Connection created successfully */ |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
264 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
265 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
266 | /* Send the server our buddy list */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
267 | silcpurple_send_buddylist(gc); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
268 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
269 | g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
270 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
271 | /* Send any UMODEs configured for account */ |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
272 | if (purple_account_get_bool(sg->account, "block-ims", FALSE)) { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
273 | silc_client_command_call(sg->client, sg->conn, NULL, |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
274 | "UMODE", "+P", NULL); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
275 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
276 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
277 | /* Set default attributes */ |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
278 | mask = SILC_ATTRIBUTE_MOOD_NORMAL; |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
279 | silc_client_attribute_add(client, conn, |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
280 | SILC_ATTRIBUTE_STATUS_MOOD, |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
281 | SILC_32_TO_PTR(mask), |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
282 | sizeof(SilcUInt32)); |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
283 | mask = SILC_ATTRIBUTE_CONTACT_CHAT; |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
284 | silc_client_attribute_add(client, conn, |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
285 | SILC_ATTRIBUTE_PREFERRED_CONTACT, |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
286 | SILC_32_TO_PTR(mask), |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
287 | sizeof(SilcUInt32)); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
288 | #ifdef HAVE_SYS_UTSNAME_H |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
289 | if (!uname(&u)) { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
290 | SilcAttributeObjDevice dev; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
291 | memset(&dev, 0, sizeof(dev)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
292 | dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
293 | dev.version = u.release; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
294 | dev.model = u.sysname; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
295 | silc_client_attribute_add(client, conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
296 | SILC_ATTRIBUTE_DEVICE_INFO, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
297 | (void *)&dev, sizeof(dev)); |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
298 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
299 | #endif |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
300 | silc_timezone(tz, sizeof(tz)); |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
301 | silc_client_attribute_add(client, conn, |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
302 | SILC_ATTRIBUTE_TIMEZONE, |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
303 | (void *)tz, strlen(tz)); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
304 | |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
305 | /* Set our buddy icon */ |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
306 | img = purple_buddy_icons_find_account_icon(sg->account); |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
307 | silcpurple_buddy_set_icon(gc, img); |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
308 | purple_imgstore_unref(img); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
309 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
310 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
311 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
312 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
313 | case SILC_CLIENT_CONN_DISCONNECTED: |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
314 | /* Disconnected */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
315 | if (sg->resuming && !sg->detaching) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
316 | g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
317 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
318 | /* Close the connection */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
319 | if (!sg->detaching) |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
320 | purple_connection_error(gc, |
| 21279 | 321 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
322 | _("Disconnected by server")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
323 | else |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
324 | /* TODO: Does this work correctly? Maybe we need to set wants_to_die? */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
325 | purple_account_disconnect(purple_connection_get_account(gc)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
326 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
327 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
328 | case SILC_CLIENT_CONN_ERROR: |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
329 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
26482
diff
changeset
|
330 | _("Error connecting to SILC Server")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
331 | g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
332 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
333 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
334 | case SILC_CLIENT_CONN_ERROR_KE: |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
335 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
336 | _("Key Exchange failed")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
337 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
338 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
339 | case SILC_CLIENT_CONN_ERROR_AUTH: |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
340 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
341 | _("Authentication failed")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
342 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
343 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
344 | case SILC_CLIENT_CONN_ERROR_RESUME: |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
345 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
346 | _("Resuming detached session failed. " |
|
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
347 | "Press Reconnect to create new connection.")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
348 | g_unlink(silcpurple_session_file(purple_account_get_username(sg->account))); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
349 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
350 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
351 | case SILC_CLIENT_CONN_ERROR_TIMEOUT: |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
352 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
26482
diff
changeset
|
353 | _("Connection timed out")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
354 | break; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
355 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
356 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
357 | /* Error */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
358 | sg->conn = NULL; |
| 8849 | 359 | } |
| 360 | ||
| 361 | static void | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
362 | silcpurple_stream_created(SilcSocketStreamStatus status, SilcStream stream, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
363 | void *context) |
| 8849 | 364 | { |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
365 | PurpleConnection *gc = context; |
| 15884 | 366 | SilcPurple sg; |
|
9732
644615310076
[gaim-migrate @ 10593]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9597
diff
changeset
|
367 | SilcClient client; |
| 8849 | 368 | SilcClientConnectionParams params; |
| 369 | const char *dfile; | |
| 370 | ||
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
371 | sg = purple_connection_get_protocol_data(gc); |
|
13410
590ccd4c9bb1
[gaim-migrate @ 15784]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
372 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
373 | if (status != SILC_SOCKET_OK) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
374 | purple_connection_error(gc, |
|
21513
02642f4cb3df
Switch to purple_connection_error_reason in msnp9, and a few places I missed in
Will Thompson <resiak@pidgin.im>
parents:
21503
diff
changeset
|
375 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
02642f4cb3df
Switch to purple_connection_error_reason in msnp9, and a few places I missed in
Will Thompson <resiak@pidgin.im>
parents:
21503
diff
changeset
|
376 | _("Connection failed")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
377 | silc_pkcs_public_key_free(sg->public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
378 | silc_pkcs_private_key_free(sg->private_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
379 | silc_free(sg); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
380 | purple_connection_set_protocol_data(gc, NULL); |
| 8849 | 381 | return; |
| 382 | } | |
|
9732
644615310076
[gaim-migrate @ 10593]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9597
diff
changeset
|
383 | |
|
644615310076
[gaim-migrate @ 10593]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9597
diff
changeset
|
384 | client = sg->client; |
| 8849 | 385 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
386 | /* Get session detachment data, if available */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
387 | memset(¶ms, 0, sizeof(params)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
388 | dfile = silcpurple_session_file(purple_account_get_username(sg->account)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
389 | params.detach_data = (unsigned char *)silc_file_readfile(dfile, ¶ms.detach_data_len); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
390 | if (params.detach_data) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
391 | params.detach_data[params.detach_data_len] = 0; |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
392 | params.ignore_requested_attributes = FALSE; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
393 | params.pfs = purple_account_get_bool(sg->account, "pfs", FALSE); |
| 8849 | 394 | |
|
22847
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
395 | /* Progress */ |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
396 | if (params.detach_data) { |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
397 | purple_connection_update_progress(gc, _("Resuming session"), 2, 5); |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
398 | sg->resuming = TRUE; |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
399 | } else { |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
400 | purple_connection_update_progress(gc, _("Performing key exchange"), 2, 5); |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
401 | } |
|
fea937d28d73
Don't access uninitialized memory (I think this might actually fix some
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21630
diff
changeset
|
402 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
403 | /* Perform SILC Key Exchange. */ |
|
32763
fecea45a546b
Remove dead assignments found with clang-analyzer.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32698
diff
changeset
|
404 | silc_client_key_exchange(client, ¶ms, sg->public_key, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
405 | sg->private_key, stream, SILC_CONN_SERVER, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
406 | silcpurple_connect_cb, gc); |
| 8849 | 407 | |
| 408 | silc_free(params.detach_data); | |
| 409 | } | |
| 410 | ||
| 411 | static void | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
412 | silcpurple_login_connected(gpointer data, gint source, const gchar *error_message) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
413 | { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
414 | PurpleConnection *gc = data; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
415 | SilcPurple sg; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
416 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
417 | g_return_if_fail(gc != NULL); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
418 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
419 | sg = purple_connection_get_protocol_data(gc); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
420 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
421 | if (source < 0) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
422 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
423 | _("Connection failed")); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
424 | silc_pkcs_public_key_free(sg->public_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
425 | silc_pkcs_private_key_free(sg->private_key); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
426 | silc_free(sg); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
427 | purple_connection_set_protocol_data(gc, NULL); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
428 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
429 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
430 | |
|
21522
db7633b6104d
kill another compile warning
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21513
diff
changeset
|
431 | silc_hash_alloc((unsigned char *)"sha1", &sg->sha1hash); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
432 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
433 | /* Wrap socket to TCP stream */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
434 | silc_socket_tcp_stream_create(source, TRUE, FALSE, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
435 | sg->client->schedule, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
436 | silcpurple_stream_created, gc); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
437 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
438 | |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
439 | static void silcpurple_continue_running(SilcPurple sg) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
440 | { |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
441 | PurpleConnection *gc = sg->gc; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
442 | PurpleAccount *account = purple_connection_get_account(gc); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
443 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
444 | /* Connect to the SILC server */ |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
445 | if (purple_proxy_connect(gc, account, |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
446 | purple_account_get_string(account, "server", |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
447 | "silc.silcnet.org"), |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
448 | purple_account_get_int(account, "port", 706), |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
449 | silcpurple_login_connected, gc) == NULL) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
450 | { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
451 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
26482
diff
changeset
|
452 | _("Unable to connect")); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
453 | purple_connection_set_protocol_data(gc, NULL); |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
454 | silc_free(sg); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
455 | return; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
456 | } |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
457 | } |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
458 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
459 | static void silcpurple_got_password_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
460 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
461 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
462 | PurpleAccount *account = purple_connection_get_account(gc); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
463 | char pkd[256], prd[256]; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
464 | const char *password; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
465 | gboolean remember; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
466 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
467 | /* The password prompt dialog doesn't get disposed if the account disconnects */ |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
468 | if (!PURPLE_CONNECTION_IS_VALID(gc)) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
469 | return; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
470 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
471 | password = purple_request_fields_get_string(fields, "password"); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
472 | remember = purple_request_fields_get_bool(fields, "remember"); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
473 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
474 | if (!password || !*password) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
475 | { |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
476 | purple_notify_error(gc, NULL, _("Password is required to sign on."), NULL); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
477 | purple_connection_set_protocol_data(gc, NULL); |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
478 | silc_free(sg); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
479 | return; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
480 | } |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
481 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
482 | if (remember) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
483 | purple_account_set_remember_password(account, TRUE); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
484 | |
|
34029
059c1270db1f
Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34028
diff
changeset
|
485 | purple_account_set_password(account, password, NULL, NULL); |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
486 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
487 | /* Load SILC key pair */ |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
488 | g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
489 | g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
490 | if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd), |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
491 | (char *)purple_account_get_string(account, "private-key", prd), |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
492 | password, |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
493 | &sg->public_key, &sg->private_key)) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
494 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
26482
diff
changeset
|
495 | _("Unable to load SILC key pair")); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
496 | purple_connection_set_protocol_data(gc, NULL); |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
497 | silc_free(sg); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
498 | return; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
499 | } |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
500 | silcpurple_continue_running(sg); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
501 | } |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
502 | |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
503 | static void silcpurple_no_password_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
504 | { |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
505 | SilcPurple sg; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
506 | /* The password prompt dialog doesn't get disposed if the account disconnects */ |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
507 | if (!PURPLE_CONNECTION_IS_VALID(gc)) |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
508 | return; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
509 | sg = purple_connection_get_protocol_data(gc); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
510 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
26482
diff
changeset
|
511 | _("Unable to load SILC key pair")); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
512 | purple_connection_set_protocol_data(gc, NULL); |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
513 | silc_free(sg); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
514 | } |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
515 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
516 | static void silcpurple_running(SilcClient client, void *context) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
517 | { |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
518 | SilcPurple sg = context; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
519 | PurpleConnection *gc = sg->gc; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
520 | PurpleAccount *account = purple_connection_get_account(gc); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
521 | char pkd[256], prd[256]; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
522 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
523 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
524 | /* Progress */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
525 | purple_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
526 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
527 | /* Load SILC key pair */ |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
528 | g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
529 | g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
530 | if (!silc_load_key_pair((char *)purple_account_get_string(account, "public-key", pkd), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
531 | (char *)purple_account_get_string(account, "private-key", prd), |
|
32683
5376a35d461a
Samtime: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
532 | (purple_connection_get_password(gc) == NULL) ? "" : purple_connection_get_password(gc), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
533 | &sg->public_key, &sg->private_key)) { |
|
34022
c49f6e9ea27d
Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents:
27879
diff
changeset
|
534 | if (!purple_connection_get_password(gc)) { |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
535 | purple_account_request_password(account, G_CALLBACK(silcpurple_got_password_cb), |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
536 | G_CALLBACK(silcpurple_no_password_cb), gc); |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
537 | return; |
|
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
538 | } |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
539 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27879
f53273ef4e7e
Fix an incorrect string. Yes, this breaks the string freeze. But the string
Mark Doliner <markdoliner@pidgin.im>
parents:
27635
diff
changeset
|
540 | _("Unable to load SILC key pair")); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
541 | purple_connection_set_protocol_data(gc, NULL); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
542 | silc_free(sg); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
543 | return; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
544 | } |
|
22853
02735afc5a47
Prompt for silc private key passphrase if it is not saved for the account
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22852
diff
changeset
|
545 | silcpurple_continue_running(sg); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
546 | } |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
547 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
548 | static void |
| 15884 | 549 | silcpurple_login(PurpleAccount *account) |
| 8849 | 550 | { |
| 551 | SilcClient client; | |
| 15884 | 552 | PurpleConnection *gc; |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
553 | SilcPurple sg; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
554 | SilcClientParams params; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
555 | const char *cipher, *hmac; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
556 | char *username, *hostname, *realname, **up; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
557 | int i; |
| 8849 | 558 | |
|
32624
f957ad287bcc
Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32623
diff
changeset
|
559 | gc = purple_account_get_connection(account); |
| 8849 | 560 | if (!gc) |
| 561 | return; | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
562 | purple_connection_set_protocol_data(gc, NULL); |
| 8849 | 563 | |
| 564 | memset(¶ms, 0, sizeof(params)); | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
565 | strcat(params.nickname_format, "%n#a"); |
| 8849 | 566 | |
| 567 | /* Allocate SILC client */ | |
| 568 | client = silc_client_alloc(&ops, ¶ms, gc, NULL); | |
| 569 | if (!client) { | |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
570 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
571 | _("Out of memory")); |
| 8849 | 572 | return; |
| 573 | } | |
| 574 | ||
| 575 | /* Get username, real name and local hostname for SILC library */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
576 | if (!purple_account_get_username(account)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
577 | purple_account_set_username(account, silc_get_username()); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
578 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
579 | username = (char *)purple_account_get_username(account); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
580 | up = g_strsplit(username, "@", 2); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
581 | username = g_strdup(up[0]); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
582 | g_strfreev(up); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
583 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
584 | if (!purple_account_get_user_info(account)) { |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
585 | purple_account_set_user_info(account, silc_get_real_name()); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
586 | if (!purple_account_get_user_info(account)) |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
587 | purple_account_set_user_info(account, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
588 | "John T. Noname"); |
| 8849 | 589 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
590 | realname = (char *)purple_account_get_user_info(account); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
591 | hostname = silc_net_localhost(); |
| 8849 | 592 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
593 | purple_connection_set_display_name(gc, username); |
| 8849 | 594 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
595 | /* Register requested cipher and HMAC */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
596 | cipher = purple_account_get_string(account, "cipher", |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
597 | SILC_DEFAULT_CIPHER); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
598 | for (i = 0; silc_default_ciphers[i].name; i++) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
599 | if (!strcmp(silc_default_ciphers[i].name, cipher)) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
600 | silc_cipher_register(&(silc_default_ciphers[i])); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
601 | break; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
602 | } |
| 15884 | 603 | hmac = purple_account_get_string(account, "hmac", SILC_DEFAULT_HMAC); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
604 | for (i = 0; silc_default_hmacs[i].name; i++) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
605 | if (!strcmp(silc_default_hmacs[i].name, hmac)) { |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
606 | silc_hmac_register(&(silc_default_hmacs[i])); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
607 | break; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
608 | } |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
609 | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
610 | sg = silc_calloc(1, sizeof(*sg)); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
611 | if (!sg) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
612 | return; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
613 | sg->client = client; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
614 | sg->gc = gc; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
615 | sg->account = account; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
616 | purple_connection_set_protocol_data(gc, sg); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
617 | |
| 8849 | 618 | /* Init SILC client */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
619 | if (!silc_client_init(client, username, hostname, realname, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
620 | silcpurple_running, sg)) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
621 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
26482
diff
changeset
|
622 | _("Unable to initialize SILC protocol")); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
623 | purple_connection_set_protocol_data(gc, NULL); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
624 | silc_free(sg); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
625 | silc_free(hostname); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
626 | g_free(username); |
| 8849 | 627 | return; |
| 628 | } | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
629 | silc_free(hostname); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
630 | g_free(username); |
| 8849 | 631 | |
| 632 | /* Check the ~/.silc dir and create it, and new key pair if necessary. */ | |
| 15884 | 633 | if (!silcpurple_check_silc_dir(gc)) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31802
diff
changeset
|
634 | purple_connection_error(gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
20458
446bd3a80bdc
Add disconnection reasons to silc.
Will Thompson <resiak@pidgin.im>
parents:
19684
diff
changeset
|
635 | _("Error loading SILC key pair")); |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
636 | purple_connection_set_protocol_data(gc, NULL); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
637 | silc_free(sg); |
| 8849 | 638 | return; |
| 639 | } | |
| 640 | ||
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
641 | #if __SILC_TOOLKIT_VERSION < SILC_VERSION(1,1,1) |
| 8849 | 642 | /* Schedule SILC using Glib's event loop */ |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
643 | sg->scheduler = purple_timeout_add(300, (GSourceFunc)silcpurple_scheduler, client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
644 | #else |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
645 | /* Run SILC scheduler */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
646 | sg->tasks = silc_dlist_init(); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
647 | silc_schedule_set_notify(client->schedule, silcpurple_scheduler, |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
648 | client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
649 | silc_client_run_one(client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
650 | #endif /* __SILC_TOOLKIT_VERSION */ |
| 8849 | 651 | } |
| 652 | ||
| 653 | static int | |
| 15884 | 654 | silcpurple_close_final(gpointer *context) |
| 8849 | 655 | { |
| 15884 | 656 | SilcPurple sg = (SilcPurple)context; |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
657 | |
| 31444 | 658 | purple_debug_info("silc", "Finalizing SilcPurple %p\n", sg); |
| 659 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
660 | silc_client_stop(sg->client, NULL, NULL); |
| 8849 | 661 | silc_client_free(sg->client); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
662 | if (sg->sha1hash) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
663 | silc_hash_free(sg->sha1hash); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
664 | if (sg->mimeass) |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
665 | silc_mime_assembler_free(sg->mimeass); |
| 8849 | 666 | silc_free(sg); |
| 667 | return 0; | |
| 668 | } | |
| 669 | ||
| 670 | static void | |
| 15884 | 671 | silcpurple_close(PurpleConnection *gc) |
| 8849 | 672 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
673 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
674 | #if __SILC_TOOLKIT_VERSION >= SILC_VERSION(1,1,1) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
675 | SilcPurpleTask task; |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
676 | #endif /* __SILC_TOOLKIT_VERSION */ |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
677 | GHashTable *ui_info; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
678 | const char *ui_name = NULL, *ui_website = NULL; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
679 | char *quit_msg; |
| 8849 | 680 | |
|
10547
61f5540fc15a
[gaim-migrate @ 11917]
Mark Doliner <markdoliner@pidgin.im>
parents:
10516
diff
changeset
|
681 | g_return_if_fail(sg != NULL); |
| 8849 | 682 | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
683 | ui_info = purple_core_get_ui_info(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
684 | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
685 | if(ui_info) { |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
686 | ui_name = g_hash_table_lookup(ui_info, "name"); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
687 | ui_website = g_hash_table_lookup(ui_info, "website"); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
688 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
689 | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
690 | if(!ui_name || !ui_website) { |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
691 | ui_name = "Pidgin"; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
692 | ui_website = PURPLE_WEBSITE; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
693 | } |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
694 | quit_msg = g_strdup_printf(_("Download %s: %s"), |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
695 | ui_name, ui_website); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
696 | |
| 8849 | 697 | /* Send QUIT */ |
| 698 | silc_client_command_call(sg->client, sg->conn, NULL, | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
699 | "QUIT", quit_msg, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
700 | NULL); |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
701 | g_free(quit_msg); |
| 8849 | 702 | |
| 703 | if (sg->conn) | |
| 704 | silc_client_close_connection(sg->client, sg->conn); | |
| 705 | ||
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
706 | #if __SILC_TOOLKIT_VERSION >= SILC_VERSION(1,1,1) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
707 | if (sg->conn) |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
708 | silc_client_run_one(sg->client); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
709 | silc_schedule_set_notify(sg->client->schedule, NULL, NULL); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
710 | |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
711 | silc_dlist_start(sg->tasks); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
712 | while ((task = silc_dlist_get(sg->tasks))) { |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
713 | purple_input_remove(task->tag); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
714 | silc_free(task); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
715 | } |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
716 | silc_dlist_uninit(sg->tasks); |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
717 | #endif /* __SILC_TOOLKIT_VERSION */ |
|
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
718 | |
|
17570
4cca2fc0ec83
libpurple should not use glib eventloop stuff directly, since we have our
Richard Laager <rlaager@pidgin.im>
parents:
17566
diff
changeset
|
719 | purple_timeout_remove(sg->scheduler); |
| 31444 | 720 | |
| 721 | purple_debug_info("silc", "Scheduling destruction of SilcPurple %p\n", sg); | |
|
17570
4cca2fc0ec83
libpurple should not use glib eventloop stuff directly, since we have our
Richard Laager <rlaager@pidgin.im>
parents:
17566
diff
changeset
|
722 | purple_timeout_add(1, (GSourceFunc)silcpurple_close_final, sg); |
| 8849 | 723 | } |
| 724 | ||
| 725 | ||
| 726 | /****************************** Protocol Actions *****************************/ | |
| 727 | ||
| 728 | static void | |
| 15884 | 729 | silcpurple_attrs_cancel(PurpleConnection *gc, PurpleRequestFields *fields) |
| 8849 | 730 | { |
| 731 | /* Nothing */ | |
| 732 | } | |
| 733 | ||
| 734 | static void | |
| 15884 | 735 | silcpurple_attrs_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
| 8849 | 736 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
737 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 738 | SilcClient client = sg->client; |
| 739 | SilcClientConnection conn = sg->conn; | |
| 15884 | 740 | PurpleRequestField *f; |
| 8849 | 741 | char *tmp; |
| 742 | SilcUInt32 tmp_len, mask; | |
| 743 | SilcAttributeObjService service; | |
| 744 | SilcAttributeObjDevice dev; | |
| 745 | SilcVCardStruct vcard; | |
| 746 | const char *val; | |
| 747 | ||
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
748 | sg = purple_connection_get_protocol_data(gc); |
| 8849 | 749 | if (!sg) |
| 750 | return; | |
| 751 | ||
| 752 | memset(&service, 0, sizeof(service)); | |
| 753 | memset(&dev, 0, sizeof(dev)); | |
| 754 | memset(&vcard, 0, sizeof(vcard)); | |
| 755 | ||
| 756 | silc_client_attribute_del(client, conn, | |
| 757 | SILC_ATTRIBUTE_USER_INFO, NULL); | |
| 758 | silc_client_attribute_del(client, conn, | |
| 759 | SILC_ATTRIBUTE_SERVICE, NULL); | |
| 760 | silc_client_attribute_del(client, conn, | |
| 761 | SILC_ATTRIBUTE_STATUS_MOOD, NULL); | |
| 762 | silc_client_attribute_del(client, conn, | |
| 763 | SILC_ATTRIBUTE_STATUS_FREETEXT, NULL); | |
| 764 | silc_client_attribute_del(client, conn, | |
| 765 | SILC_ATTRIBUTE_STATUS_MESSAGE, NULL); | |
| 766 | silc_client_attribute_del(client, conn, | |
| 767 | SILC_ATTRIBUTE_PREFERRED_LANGUAGE, NULL); | |
| 768 | silc_client_attribute_del(client, conn, | |
| 769 | SILC_ATTRIBUTE_PREFERRED_CONTACT, NULL); | |
| 770 | silc_client_attribute_del(client, conn, | |
| 771 | SILC_ATTRIBUTE_TIMEZONE, NULL); | |
| 772 | silc_client_attribute_del(client, conn, | |
| 773 | SILC_ATTRIBUTE_GEOLOCATION, NULL); | |
| 774 | silc_client_attribute_del(client, conn, | |
| 775 | SILC_ATTRIBUTE_DEVICE_INFO, NULL); | |
| 776 | ||
| 777 | /* Set mood */ | |
| 778 | mask = 0; | |
| 15884 | 779 | f = purple_request_fields_get_field(fields, "mood_normal"); |
| 780 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 781 | mask |= SILC_ATTRIBUTE_MOOD_NORMAL; |
| 15884 | 782 | f = purple_request_fields_get_field(fields, "mood_happy"); |
| 783 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 784 | mask |= SILC_ATTRIBUTE_MOOD_HAPPY; |
| 15884 | 785 | f = purple_request_fields_get_field(fields, "mood_sad"); |
| 786 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 787 | mask |= SILC_ATTRIBUTE_MOOD_SAD; |
| 15884 | 788 | f = purple_request_fields_get_field(fields, "mood_angry"); |
| 789 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 790 | mask |= SILC_ATTRIBUTE_MOOD_ANGRY; |
| 15884 | 791 | f = purple_request_fields_get_field(fields, "mood_jealous"); |
| 792 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 793 | mask |= SILC_ATTRIBUTE_MOOD_JEALOUS; |
| 15884 | 794 | f = purple_request_fields_get_field(fields, "mood_ashamed"); |
| 795 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 796 | mask |= SILC_ATTRIBUTE_MOOD_ASHAMED; |
| 15884 | 797 | f = purple_request_fields_get_field(fields, "mood_invincible"); |
| 798 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 799 | mask |= SILC_ATTRIBUTE_MOOD_INVINCIBLE; |
| 15884 | 800 | f = purple_request_fields_get_field(fields, "mood_inlove"); |
| 801 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 802 | mask |= SILC_ATTRIBUTE_MOOD_INLOVE; |
| 15884 | 803 | f = purple_request_fields_get_field(fields, "mood_sleepy"); |
| 804 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 805 | mask |= SILC_ATTRIBUTE_MOOD_SLEEPY; |
| 15884 | 806 | f = purple_request_fields_get_field(fields, "mood_bored"); |
| 807 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 808 | mask |= SILC_ATTRIBUTE_MOOD_BORED; |
| 15884 | 809 | f = purple_request_fields_get_field(fields, "mood_excited"); |
| 810 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 811 | mask |= SILC_ATTRIBUTE_MOOD_EXCITED; |
| 15884 | 812 | f = purple_request_fields_get_field(fields, "mood_anxious"); |
| 813 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 814 | mask |= SILC_ATTRIBUTE_MOOD_ANXIOUS; |
| 815 | silc_client_attribute_add(client, conn, | |
| 816 | SILC_ATTRIBUTE_STATUS_MOOD, | |
| 817 | SILC_32_TO_PTR(mask), | |
| 818 | sizeof(SilcUInt32)); | |
| 819 | ||
| 820 | /* Set preferred contact */ | |
| 821 | mask = 0; | |
| 15884 | 822 | f = purple_request_fields_get_field(fields, "contact_chat"); |
| 823 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 824 | mask |= SILC_ATTRIBUTE_CONTACT_CHAT; |
| 15884 | 825 | f = purple_request_fields_get_field(fields, "contact_email"); |
| 826 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 827 | mask |= SILC_ATTRIBUTE_CONTACT_EMAIL; |
| 15884 | 828 | f = purple_request_fields_get_field(fields, "contact_call"); |
| 829 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 830 | mask |= SILC_ATTRIBUTE_CONTACT_CALL; |
| 15884 | 831 | f = purple_request_fields_get_field(fields, "contact_sms"); |
| 832 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 833 | mask |= SILC_ATTRIBUTE_CONTACT_SMS; |
| 15884 | 834 | f = purple_request_fields_get_field(fields, "contact_mms"); |
| 835 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 836 | mask |= SILC_ATTRIBUTE_CONTACT_MMS; |
| 15884 | 837 | f = purple_request_fields_get_field(fields, "contact_video"); |
| 838 | if (f && purple_request_field_bool_get_value(f)) | |
| 8849 | 839 | mask |= SILC_ATTRIBUTE_CONTACT_VIDEO; |
| 840 | if (mask) | |
| 841 | silc_client_attribute_add(client, conn, | |
| 842 | SILC_ATTRIBUTE_PREFERRED_CONTACT, | |
| 843 | SILC_32_TO_PTR(mask), | |
| 844 | sizeof(SilcUInt32)); | |
| 845 | ||
| 846 | /* Set status text */ | |
| 847 | val = NULL; | |
| 15884 | 848 | f = purple_request_fields_get_field(fields, "status_text"); |
| 8849 | 849 | if (f) |
| 15884 | 850 | val = purple_request_field_string_get_value(f); |
| 8849 | 851 | if (val && *val) |
| 852 | silc_client_attribute_add(client, conn, | |
| 853 | SILC_ATTRIBUTE_STATUS_FREETEXT, | |
| 854 | (void *)val, strlen(val)); | |
| 855 | ||
| 856 | /* Set vcard */ | |
| 857 | val = NULL; | |
| 15884 | 858 | f = purple_request_fields_get_field(fields, "vcard"); |
| 8849 | 859 | if (f) |
| 15884 | 860 | val = purple_request_field_string_get_value(f); |
| 8849 | 861 | if (val && *val) { |
| 15884 | 862 | purple_account_set_string(sg->account, "vcard", val); |
| 8849 | 863 | tmp = silc_file_readfile(val, &tmp_len); |
| 864 | if (tmp) { | |
| 865 | tmp[tmp_len] = 0; | |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11257
diff
changeset
|
866 | if (silc_vcard_decode((unsigned char *)tmp, tmp_len, &vcard)) |
| 8849 | 867 | silc_client_attribute_add(client, conn, |
| 868 | SILC_ATTRIBUTE_USER_INFO, | |
| 869 | (void *)&vcard, | |
| 870 | sizeof(vcard)); | |
| 871 | } | |
| 872 | silc_vcard_free(&vcard); | |
| 873 | silc_free(tmp); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
874 | } else { |
| 15884 | 875 | purple_account_set_string(sg->account, "vcard", ""); |
| 8849 | 876 | } |
| 877 | ||
| 878 | #ifdef HAVE_SYS_UTSNAME_H | |
| 879 | /* Set device info */ | |
| 15884 | 880 | f = purple_request_fields_get_field(fields, "device"); |
| 881 | if (f && purple_request_field_bool_get_value(f)) { | |
| 8849 | 882 | struct utsname u; |
| 883 | if (!uname(&u)) { | |
| 884 | dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER; | |
| 885 | dev.version = u.release; | |
| 886 | dev.model = u.sysname; | |
| 887 | silc_client_attribute_add(client, conn, | |
| 888 | SILC_ATTRIBUTE_DEVICE_INFO, | |
| 889 | (void *)&dev, sizeof(dev)); | |
| 890 | } | |
| 891 | } | |
| 892 | #endif | |
| 893 | ||
| 894 | /* Set timezone */ | |
| 895 | val = NULL; | |
| 15884 | 896 | f = purple_request_fields_get_field(fields, "timezone"); |
| 8849 | 897 | if (f) |
| 15884 | 898 | val = purple_request_field_string_get_value(f); |
| 8849 | 899 | if (val && *val) |
| 900 | silc_client_attribute_add(client, conn, | |
| 901 | SILC_ATTRIBUTE_TIMEZONE, | |
| 902 | (void *)val, strlen(val)); | |
| 903 | } | |
| 904 | ||
| 905 | static void | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
906 | silcpurple_attrs(PurpleProtocolAction *action) |
| 8849 | 907 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
908 | PurpleConnection *gc = action->connection; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
909 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 910 | SilcClient client = sg->client; |
| 911 | SilcClientConnection conn = sg->conn; | |
| 15884 | 912 | PurpleRequestFields *fields; |
| 913 | PurpleRequestFieldGroup *g; | |
| 914 | PurpleRequestField *f; | |
| 8849 | 915 | SilcHashTable attrs; |
| 916 | SilcAttributePayload attr; | |
| 917 | gboolean mnormal = TRUE, mhappy = FALSE, msad = FALSE, | |
| 918 | mangry = FALSE, mjealous = FALSE, mashamed = FALSE, | |
| 919 | minvincible = FALSE, minlove = FALSE, msleepy = FALSE, | |
| 920 | mbored = FALSE, mexcited = FALSE, manxious = FALSE; | |
| 921 | gboolean cemail = FALSE, ccall = FALSE, csms = FALSE, | |
| 922 | cmms = FALSE, cchat = TRUE, cvideo = FALSE; | |
|
33896
fb896f14715b
win32: fix most of easy warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
923 | #ifdef HAVE_SYS_UTSNAME_H |
| 8849 | 924 | gboolean device = TRUE; |
|
33896
fb896f14715b
win32: fix most of easy warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
925 | #endif |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
926 | char status[1024], tz[16]; |
| 8849 | 927 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
928 | sg = purple_connection_get_protocol_data(gc); |
| 8849 | 929 | if (!sg) |
| 930 | return; | |
| 931 | ||
| 932 | memset(status, 0, sizeof(status)); | |
| 933 | ||
| 934 | attrs = silc_client_attributes_get(client, conn); | |
| 935 | if (attrs) { | |
| 936 | if (silc_hash_table_find(attrs, | |
| 937 | SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_MOOD), | |
| 938 | NULL, (void *)&attr)) { | |
| 939 | SilcUInt32 mood = 0; | |
| 940 | silc_attribute_get_object(attr, &mood, sizeof(mood)); | |
| 941 | mnormal = !mood; | |
| 942 | mhappy = (mood & SILC_ATTRIBUTE_MOOD_HAPPY); | |
| 943 | msad = (mood & SILC_ATTRIBUTE_MOOD_SAD); | |
| 944 | mangry = (mood & SILC_ATTRIBUTE_MOOD_ANGRY); | |
| 945 | mjealous = (mood & SILC_ATTRIBUTE_MOOD_JEALOUS); | |
| 946 | mashamed = (mood & SILC_ATTRIBUTE_MOOD_ASHAMED); | |
| 947 | minvincible = (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE); | |
| 948 | minlove = (mood & SILC_ATTRIBUTE_MOOD_INLOVE); | |
| 949 | msleepy = (mood & SILC_ATTRIBUTE_MOOD_SLEEPY); | |
| 950 | mbored = (mood & SILC_ATTRIBUTE_MOOD_BORED); | |
| 951 | mexcited = (mood & SILC_ATTRIBUTE_MOOD_EXCITED); | |
| 952 | manxious = (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS); | |
| 953 | } | |
| 954 | ||
| 955 | if (silc_hash_table_find(attrs, | |
| 956 | SILC_32_TO_PTR(SILC_ATTRIBUTE_PREFERRED_CONTACT), | |
| 957 | NULL, (void *)&attr)) { | |
| 958 | SilcUInt32 contact = 0; | |
| 959 | silc_attribute_get_object(attr, &contact, sizeof(contact)); | |
| 960 | cemail = (contact & SILC_ATTRIBUTE_CONTACT_EMAIL); | |
| 961 | ccall = (contact & SILC_ATTRIBUTE_CONTACT_CALL); | |
| 962 | csms = (contact & SILC_ATTRIBUTE_CONTACT_SMS); | |
| 963 | cmms = (contact & SILC_ATTRIBUTE_CONTACT_MMS); | |
| 964 | cchat = (contact & SILC_ATTRIBUTE_CONTACT_CHAT); | |
| 965 | cvideo = (contact & SILC_ATTRIBUTE_CONTACT_VIDEO); | |
| 966 | } | |
| 967 | ||
| 968 | if (silc_hash_table_find(attrs, | |
| 969 | SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_FREETEXT), | |
| 970 | NULL, (void *)&attr)) | |
| 971 | silc_attribute_get_object(attr, &status, sizeof(status)); | |
| 972 | ||
|
33896
fb896f14715b
win32: fix most of easy warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
973 | #ifdef HAVE_SYS_UTSNAME_H |
| 8849 | 974 | if (!silc_hash_table_find(attrs, |
| 975 | SILC_32_TO_PTR(SILC_ATTRIBUTE_DEVICE_INFO), | |
| 976 | NULL, (void *)&attr)) | |
| 977 | device = FALSE; | |
|
33896
fb896f14715b
win32: fix most of easy warnings
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
978 | #endif |
| 8849 | 979 | } |
| 980 | ||
| 15884 | 981 | fields = purple_request_fields_new(); |
| 8849 | 982 | |
| 15884 | 983 | g = purple_request_field_group_new(NULL); |
| 984 | f = purple_request_field_label_new("l3", _("Your Current Mood")); | |
| 985 | purple_request_field_group_add_field(g, f); | |
| 986 | f = purple_request_field_bool_new("mood_normal", _("Normal"), mnormal); | |
| 987 | purple_request_field_group_add_field(g, f); | |
| 988 | f = purple_request_field_bool_new("mood_happy", _("Happy"), mhappy); | |
| 989 | purple_request_field_group_add_field(g, f); | |
| 990 | f = purple_request_field_bool_new("mood_sad", _("Sad"), msad); | |
| 991 | purple_request_field_group_add_field(g, f); | |
| 992 | f = purple_request_field_bool_new("mood_angry", _("Angry"), mangry); | |
| 993 | purple_request_field_group_add_field(g, f); | |
| 994 | f = purple_request_field_bool_new("mood_jealous", _("Jealous"), mjealous); | |
| 995 | purple_request_field_group_add_field(g, f); | |
| 996 | f = purple_request_field_bool_new("mood_ashamed", _("Ashamed"), mashamed); | |
| 997 | purple_request_field_group_add_field(g, f); | |
| 998 | f = purple_request_field_bool_new("mood_invincible", _("Invincible"), minvincible); | |
| 999 | purple_request_field_group_add_field(g, f); | |
| 1000 | f = purple_request_field_bool_new("mood_inlove", _("In love"), minlove); | |
| 1001 | purple_request_field_group_add_field(g, f); | |
| 1002 | f = purple_request_field_bool_new("mood_sleepy", _("Sleepy"), msleepy); | |
| 1003 | purple_request_field_group_add_field(g, f); | |
| 1004 | f = purple_request_field_bool_new("mood_bored", _("Bored"), mbored); | |
| 1005 | purple_request_field_group_add_field(g, f); | |
| 1006 | f = purple_request_field_bool_new("mood_excited", _("Excited"), mexcited); | |
| 1007 | purple_request_field_group_add_field(g, f); | |
| 1008 | f = purple_request_field_bool_new("mood_anxious", _("Anxious"), manxious); | |
| 1009 | purple_request_field_group_add_field(g, f); | |
| 8849 | 1010 | |
| 15884 | 1011 | f = purple_request_field_label_new("l4", _("\nYour Preferred Contact Methods")); |
| 1012 | purple_request_field_group_add_field(g, f); | |
| 1013 | f = purple_request_field_bool_new("contact_chat", _("Chat"), cchat); | |
| 1014 | purple_request_field_group_add_field(g, f); | |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23278
diff
changeset
|
1015 | f = purple_request_field_bool_new("contact_email", _("Email"), cemail); |
| 15884 | 1016 | purple_request_field_group_add_field(g, f); |
| 1017 | f = purple_request_field_bool_new("contact_call", _("Phone"), ccall); | |
| 1018 | purple_request_field_group_add_field(g, f); | |
| 1019 | f = purple_request_field_bool_new("contact_sms", _("SMS"), csms); | |
| 1020 | purple_request_field_group_add_field(g, f); | |
| 1021 | f = purple_request_field_bool_new("contact_mms", _("MMS"), cmms); | |
| 1022 | purple_request_field_group_add_field(g, f); | |
| 1023 | f = purple_request_field_bool_new("contact_video", _("Video conferencing"), cvideo); | |
| 1024 | purple_request_field_group_add_field(g, f); | |
| 1025 | purple_request_fields_add_group(fields, g); | |
| 8849 | 1026 | |
| 15884 | 1027 | g = purple_request_field_group_new(NULL); |
| 1028 | f = purple_request_field_string_new("status_text", _("Your Current Status"), | |
| 8849 | 1029 | status[0] ? status : NULL, TRUE); |
| 15884 | 1030 | purple_request_field_group_add_field(g, f); |
| 1031 | purple_request_fields_add_group(fields, g); | |
| 8849 | 1032 | |
| 15884 | 1033 | g = purple_request_field_group_new(NULL); |
| 8849 | 1034 | #if 0 |
| 15884 | 1035 | f = purple_request_field_label_new("l2", _("Online Services")); |
| 1036 | purple_request_field_group_add_field(g, f); | |
| 1037 | f = purple_request_field_bool_new("services", | |
| 8849 | 1038 | _("Let others see what services you are using"), |
| 1039 | TRUE); | |
| 15884 | 1040 | purple_request_field_group_add_field(g, f); |
| 8849 | 1041 | #endif |
| 1042 | #ifdef HAVE_SYS_UTSNAME_H | |
| 15884 | 1043 | f = purple_request_field_bool_new("device", |
| 8849 | 1044 | _("Let others see what computer you are using"), |
| 1045 | device); | |
| 15884 | 1046 | purple_request_field_group_add_field(g, f); |
| 8849 | 1047 | #endif |
| 15884 | 1048 | purple_request_fields_add_group(fields, g); |
| 8849 | 1049 | |
| 15884 | 1050 | g = purple_request_field_group_new(NULL); |
| 1051 | f = purple_request_field_string_new("vcard", _("Your VCard File"), | |
| 1052 | purple_account_get_string(sg->account, "vcard", ""), | |
| 8849 | 1053 | FALSE); |
| 15884 | 1054 | purple_request_field_group_add_field(g, f); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1055 | |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1056 | silc_timezone(tz, sizeof(tz)); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1057 | f = purple_request_field_string_new("timezone", _("Timezone (UTC)"), tz, FALSE); |
| 15884 | 1058 | purple_request_field_group_add_field(g, f); |
| 1059 | purple_request_fields_add_group(fields, g); | |
| 8849 | 1060 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1061 | purple_request_fields(gc, _("User Online Status Attributes"), |
| 8849 | 1062 | _("User Online Status Attributes"), |
| 1063 | _("You can let other users see your online status information " | |
| 1064 | "and your personal information. Please fill the information " | |
| 1065 | "you would like other users to see about yourself."), | |
| 1066 | fields, | |
| 15884 | 1067 | _("OK"), G_CALLBACK(silcpurple_attrs_cb), |
|
16492
4f0dc2d16e55
Update SILC to match resent request API changes
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
1068 | _("Cancel"), G_CALLBACK(silcpurple_attrs_cancel), |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
1069 | purple_connection_get_account(gc), NULL, NULL, gc); |
| 8849 | 1070 | } |
| 1071 | ||
| 1072 | static void | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1073 | silcpurple_detach(PurpleProtocolAction *action) |
| 8849 | 1074 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1075 | PurpleConnection *gc = action->connection; |
| 15884 | 1076 | SilcPurple sg; |
| 8849 | 1077 | |
| 1078 | if (!gc) | |
| 1079 | return; | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1080 | sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1081 | if (!sg) |
| 1082 | return; | |
| 1083 | ||
| 1084 | /* Call DETACH */ | |
| 1085 | silc_client_command_call(sg->client, sg->conn, "DETACH"); | |
| 1086 | sg->detaching = TRUE; | |
| 1087 | } | |
| 1088 | ||
| 1089 | static void | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1090 | silcpurple_view_motd(PurpleProtocolAction *action) |
| 8849 | 1091 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1092 | PurpleConnection *gc = action->connection; |
| 15884 | 1093 | SilcPurple sg; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1094 | char *tmp; |
| 8849 | 1095 | |
| 1096 | if (!gc) | |
| 1097 | return; | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1098 | sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1099 | if (!sg) |
| 1100 | return; | |
| 1101 | ||
| 1102 | if (!sg->motd) { | |
| 15884 | 1103 | purple_notify_error( |
| 8849 | 1104 | gc, _("Message of the Day"), _("No Message of the Day available"), |
| 1105 | _("There is no Message of the Day associated with this connection")); | |
| 1106 | return; | |
| 1107 | } | |
| 1108 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10547
diff
changeset
|
1109 | tmp = g_markup_escape_text(sg->motd, -1); |
| 15884 | 1110 | purple_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1111 | tmp, NULL, NULL); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1112 | g_free(tmp); |
| 8849 | 1113 | } |
| 1114 | ||
| 9272 | 1115 | static void |
| 15884 | 1116 | silcpurple_create_keypair_cancel(PurpleConnection *gc, PurpleRequestFields *fields) |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1117 | { |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1118 | /* Nothing */ |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1119 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1120 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1121 | static void |
| 15884 | 1122 | silcpurple_create_keypair_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1123 | { |
|
31802
f54b3406b834
silc: Dead (redundant) initialization
Paul Aurich <darkrain42@pidgin.im>
parents:
31595
diff
changeset
|
1124 | SilcPurple sg; |
| 15884 | 1125 | PurpleRequestField *f; |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1126 | const char *val, *pkfile = NULL, *prfile = NULL; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1127 | const char *pass1 = NULL, *pass2 = NULL, *un = NULL, *hn = NULL; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1128 | const char *rn = NULL, *e = NULL, *o = NULL, *c = NULL; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1129 | char *identifier; |
| 15884 | 1130 | int keylen = SILCPURPLE_DEF_PKCS_LEN; |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1131 | SilcPublicKey public_key; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1132 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1133 | sg = purple_connection_get_protocol_data(gc); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1134 | if (!sg) |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1135 | return; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1136 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1137 | val = NULL; |
| 15884 | 1138 | f = purple_request_fields_get_field(fields, "pass1"); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1139 | if (f) |
| 15884 | 1140 | val = purple_request_field_string_get_value(f); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1141 | if (val && *val) |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1142 | pass1 = val; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1143 | else |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1144 | pass1 = ""; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1145 | val = NULL; |
| 15884 | 1146 | f = purple_request_fields_get_field(fields, "pass2"); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1147 | if (f) |
| 15884 | 1148 | val = purple_request_field_string_get_value(f); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1149 | if (val && *val) |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1150 | pass2 = val; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1151 | else |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1152 | pass2 = ""; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1153 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1154 | if (strcmp(pass1, pass2)) { |
| 15884 | 1155 | purple_notify_error( |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1156 | gc, _("Create New SILC Key Pair"), _("Passphrases do not match"), NULL); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1157 | return; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1158 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1159 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1160 | val = NULL; |
| 15884 | 1161 | f = purple_request_fields_get_field(fields, "key"); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1162 | if (f) |
| 15884 | 1163 | val = purple_request_field_string_get_value(f); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1164 | if (val && *val) |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1165 | keylen = atoi(val); |
| 15884 | 1166 | f = purple_request_fields_get_field(fields, "pkfile"); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1167 | if (f) |
| 15884 | 1168 | pkfile = purple_request_field_string_get_value(f); |
| 1169 | f = purple_request_fields_get_field(fields, "prfile"); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1170 | if (f) |
| 15884 | 1171 | prfile = purple_request_field_string_get_value(f); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1172 | |
| 15884 | 1173 | f = purple_request_fields_get_field(fields, "un"); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1174 | if (f) |
| 15884 | 1175 | un = purple_request_field_string_get_value(f); |
| 1176 | f = purple_request_fields_get_field(fields, "hn"); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1177 | if (f) |
| 15884 | 1178 | hn = purple_request_field_string_get_value(f); |
| 1179 | f = purple_request_fields_get_field(fields, "rn"); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1180 | if (f) |
| 15884 | 1181 | rn = purple_request_field_string_get_value(f); |
| 1182 | f = purple_request_fields_get_field(fields, "e"); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1183 | if (f) |
| 15884 | 1184 | e = purple_request_field_string_get_value(f); |
| 1185 | f = purple_request_fields_get_field(fields, "o"); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1186 | if (f) |
| 15884 | 1187 | o = purple_request_field_string_get_value(f); |
| 1188 | f = purple_request_fields_get_field(fields, "c"); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1189 | if (f) |
| 15884 | 1190 | c = purple_request_field_string_get_value(f); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1191 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1192 | identifier = silc_pkcs_silc_encode_identifier((char *)un, (char *)hn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1193 | (char *)rn, (char *)e, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1194 | (char *)o, (char *)c, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1195 | NULL); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1196 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1197 | /* Create the key pair */ |
| 15884 | 1198 | if (!silc_create_key_pair(SILCPURPLE_DEF_PKCS, keylen, pkfile, prfile, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1199 | identifier, pass1, &public_key, NULL, |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1200 | FALSE)) { |
| 15884 | 1201 | purple_notify_error( |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1202 | gc, _("Create New SILC Key Pair"), _("Key Pair Generation failed"), NULL); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1203 | return; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1204 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1205 | |
| 15884 | 1206 | silcpurple_show_public_key(sg, NULL, public_key, NULL, NULL); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1207 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1208 | silc_pkcs_public_key_free(public_key); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1209 | silc_free(identifier); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1210 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1211 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1212 | static void |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1213 | silcpurple_create_keypair(PurpleProtocolAction *action) |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1214 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1215 | PurpleConnection *gc = action->connection; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1216 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 15884 | 1217 | PurpleRequestFields *fields; |
| 1218 | PurpleRequestFieldGroup *g; | |
| 1219 | PurpleRequestField *f; | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1220 | const char *username, *realname; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1221 | char *hostname, **u; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1222 | char tmp[256], pkd[256], pkd2[256], prd[256], prd2[256]; |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1223 | |
| 15884 | 1224 | username = purple_account_get_username(sg->account); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1225 | u = g_strsplit(username, "@", 2); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1226 | username = u[0]; |
| 15884 | 1227 | realname = purple_account_get_user_info(sg->account); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1228 | hostname = silc_net_localhost(); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1229 | g_snprintf(tmp, sizeof(tmp), "%s@%s", username, hostname); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1230 | |
| 15884 | 1231 | g_snprintf(pkd2, sizeof(pkd2), "%s" G_DIR_SEPARATOR_S"public_key.pub", silcpurple_silcdir()); |
| 1232 | g_snprintf(prd2, sizeof(prd2), "%s" G_DIR_SEPARATOR_S"private_key.prv", silcpurple_silcdir()); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1233 | g_snprintf(pkd, sizeof(pkd) - 1, "%s", |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
1234 | purple_account_get_string(purple_connection_get_account(gc), "public-key", pkd2)); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1235 | g_snprintf(prd, sizeof(prd) - 1, "%s", |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
1236 | purple_account_get_string(purple_connection_get_account(gc), "private-key", prd2)); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1237 | |
| 15884 | 1238 | fields = purple_request_fields_new(); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1239 | |
| 15884 | 1240 | g = purple_request_field_group_new(NULL); |
| 1241 | f = purple_request_field_string_new("key", _("Key length"), "2048", FALSE); | |
| 1242 | purple_request_field_group_add_field(g, f); | |
| 1243 | f = purple_request_field_string_new("pkfile", _("Public key file"), pkd, FALSE); | |
| 1244 | purple_request_field_group_add_field(g, f); | |
| 1245 | f = purple_request_field_string_new("prfile", _("Private key file"), prd, FALSE); | |
| 1246 | purple_request_field_group_add_field(g, f); | |
| 1247 | purple_request_fields_add_group(fields, g); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1248 | |
| 15884 | 1249 | g = purple_request_field_group_new(NULL); |
| 1250 | f = purple_request_field_string_new("un", _("Username"), username ? username : "", FALSE); | |
| 1251 | purple_request_field_group_add_field(g, f); | |
| 1252 | f = purple_request_field_string_new("hn", _("Hostname"), hostname ? hostname : "", FALSE); | |
| 1253 | purple_request_field_group_add_field(g, f); | |
| 1254 | f = purple_request_field_string_new("rn", _("Real name"), realname ? realname : "", FALSE); | |
| 1255 | purple_request_field_group_add_field(g, f); | |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23278
diff
changeset
|
1256 | f = purple_request_field_string_new("e", _("Email"), tmp, FALSE); |
| 15884 | 1257 | purple_request_field_group_add_field(g, f); |
| 1258 | f = purple_request_field_string_new("o", _("Organization"), "", FALSE); | |
| 1259 | purple_request_field_group_add_field(g, f); | |
| 1260 | f = purple_request_field_string_new("c", _("Country"), "", FALSE); | |
| 1261 | purple_request_field_group_add_field(g, f); | |
| 1262 | purple_request_fields_add_group(fields, g); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1263 | |
| 15884 | 1264 | g = purple_request_field_group_new(NULL); |
| 1265 | f = purple_request_field_string_new("pass1", _("Passphrase"), "", FALSE); | |
| 1266 | purple_request_field_string_set_masked(f, TRUE); | |
| 1267 | purple_request_field_group_add_field(g, f); | |
| 1268 | f = purple_request_field_string_new("pass2", _("Passphrase (retype)"), "", FALSE); | |
| 1269 | purple_request_field_string_set_masked(f, TRUE); | |
| 1270 | purple_request_field_group_add_field(g, f); | |
| 1271 | purple_request_fields_add_group(fields, g); | |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1272 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
1273 | purple_request_fields(gc, _("Create New SILC Key Pair"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1274 | _("Create New SILC Key Pair"), NULL, fields, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1275 | _("Generate Key Pair"), G_CALLBACK(silcpurple_create_keypair_cb), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1276 | _("Cancel"), G_CALLBACK(silcpurple_create_keypair_cancel), |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
1277 | purple_connection_get_account(gc), NULL, NULL, gc); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1278 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1279 | g_strfreev(u); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1280 | silc_free(hostname); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1281 | } |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1282 | |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1283 | static void |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1284 | silcpurple_change_pass(PurpleProtocolAction *action) |
| 9272 | 1285 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1286 | PurpleConnection *gc = action->connection; |
| 15884 | 1287 | purple_account_request_change_password(purple_connection_get_account(gc)); |
| 9272 | 1288 | } |
| 1289 | ||
| 1290 | static void | |
| 15884 | 1291 | silcpurple_change_passwd(PurpleConnection *gc, const char *old, const char *new) |
| 9272 | 1292 | { |
|
22852
f6f9031e09fe
Fix for changing silc private key passphrase to or from the empty string,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22847
diff
changeset
|
1293 | char prd[256]; |
| 15884 | 1294 | g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcpurple_silcdir()); |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
1295 | silc_change_private_key_passphrase(purple_account_get_string(purple_connection_get_account(gc), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1296 | "private-key", |
|
22852
f6f9031e09fe
Fix for changing silc private key passphrase to or from the empty string,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22847
diff
changeset
|
1297 | prd), old ? old : "", new ? new : ""); |
| 9272 | 1298 | } |
| 1299 | ||
| 1300 | static void | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1301 | silcpurple_show_set_info(PurpleProtocolAction *action) |
| 9272 | 1302 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1303 | PurpleConnection *gc = action->connection; |
| 15884 | 1304 | purple_account_request_change_user_info(purple_connection_get_account(gc)); |
| 9272 | 1305 | } |
| 1306 | ||
| 1307 | static void | |
| 15884 | 1308 | silcpurple_set_info(PurpleConnection *gc, const char *text) |
| 9272 | 1309 | { |
| 1310 | } | |
| 1311 | ||
| 8849 | 1312 | static GList * |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1313 | silcpurple_get_actions(PurpleConnection *gc) |
| 8849 | 1314 | { |
| 1315 | GList *list = NULL; | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1316 | PurpleProtocolAction *act; |
| 8849 | 1317 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1318 | act = purple_protocol_action_new(_("Online Status"), |
|
17677
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
1319 | silcpurple_attrs); |
|
c1ef813bddcf
Remove the following SILC account options, as suggested by Pekka Riikonen
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17675
diff
changeset
|
1320 | list = g_list_append(list, act); |
| 8849 | 1321 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1322 | act = purple_protocol_action_new(_("Detach From Server"), |
| 15884 | 1323 | silcpurple_detach); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1324 | list = g_list_append(list, act); |
| 8849 | 1325 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1326 | act = purple_protocol_action_new(_("View Message of the Day"), |
| 15884 | 1327 | silcpurple_view_motd); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
1328 | list = g_list_append(list, act); |
| 8849 | 1329 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1330 | act = purple_protocol_action_new(_("Create SILC Key Pair..."), |
| 15884 | 1331 | silcpurple_create_keypair); |
|
12167
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1332 | list = g_list_append(list, act); |
|
f3ad3170f09d
[gaim-migrate @ 14468]
Pekka Riikonen <priikone@silcnet.org>
parents:
12149
diff
changeset
|
1333 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1334 | act = purple_protocol_action_new(_("Change Password..."), |
| 15884 | 1335 | silcpurple_change_pass); |
| 9272 | 1336 | list = g_list_append(list, act); |
| 1337 | ||
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1338 | act = purple_protocol_action_new(_("Set User Info..."), |
| 15884 | 1339 | silcpurple_show_set_info); |
| 9272 | 1340 | list = g_list_append(list, act); |
| 1341 | ||
| 8849 | 1342 | return list; |
| 1343 | } | |
| 1344 | ||
| 1345 | ||
| 1346 | /******************************* IM Routines *********************************/ | |
| 1347 | ||
| 1348 | typedef struct { | |
| 1349 | char *nick; | |
|
11318
13fa1d5134f3
[gaim-migrate @ 13521]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11257
diff
changeset
|
1350 | char *message; |
| 8849 | 1351 | SilcUInt32 message_len; |
| 1352 | SilcMessageFlags flags; | |
| 15884 | 1353 | PurpleMessageFlags gflags; |
| 1354 | } *SilcPurpleIM; | |
| 8849 | 1355 | |
| 1356 | static void | |
| 15884 | 1357 | silcpurple_send_im_resolved(SilcClient client, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1358 | SilcClientConnection conn, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1359 | SilcStatus status, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1360 | SilcDList clients, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1361 | void *context) |
| 8849 | 1362 | { |
| 15884 | 1363 | PurpleConnection *gc = client->application; |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1364 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 15884 | 1365 | SilcPurpleIM im = context; |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1366 | PurpleIMConversation *convo; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1367 | char tmp[256]; |
| 8849 | 1368 | SilcClientEntry client_entry; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1369 | SilcDList list; |
|
25545
040ec50ba303
Plug a memory leak in SILC, thanks to Luke Petre.
Luke Petre <luke@petre.net>
parents:
23551
diff
changeset
|
1370 | gboolean free_list = FALSE; |
| 8849 | 1371 | |
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
1372 | convo = purple_conversations_find_im_with_account(im->nick, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1373 | sg->account); |
| 8849 | 1374 | if (!convo) |
| 1375 | return; | |
| 1376 | ||
| 1377 | if (!clients) | |
| 1378 | goto err; | |
| 1379 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1380 | if (silc_dlist_count(clients) > 1) { |
| 8849 | 1381 | /* Find the correct one. The im->nick might be a formatted nick |
| 1382 | so this will find the correct one. */ | |
| 1383 | clients = silc_client_get_clients_local(client, conn, | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1384 | im->nick, FALSE); |
| 8849 | 1385 | if (!clients) |
| 1386 | goto err; | |
|
25545
040ec50ba303
Plug a memory leak in SILC, thanks to Luke Petre.
Luke Petre <luke@petre.net>
parents:
23551
diff
changeset
|
1387 | |
|
040ec50ba303
Plug a memory leak in SILC, thanks to Luke Petre.
Luke Petre <luke@petre.net>
parents:
23551
diff
changeset
|
1388 | free_list = TRUE; |
| 8849 | 1389 | } |
| 1390 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1391 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1392 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1393 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1394 | /* Check for images */ |
| 15884 | 1395 | if (im->gflags & PURPLE_MESSAGE_IMAGES) { |
|
33798
ab26d8e3da97
silc: Use appropriate datatype for SilcMessageFlags
Daniel Atallah <datallah@pidgin.im>
parents:
31802
diff
changeset
|
1396 | list = silcpurple_image_message(im->message, &im->flags); |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1397 | if (list) { |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1398 | /* Send one or more MIME message. If more than one, they |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1399 | are MIME fragments due to over large message */ |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1400 | SilcBuffer buf; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1401 | |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1402 | silc_dlist_start(list); |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1403 | while ((buf = silc_dlist_get(list)) != SILC_LIST_END) |
|
15081
7e978e8dc84a
[gaim-migrate @ 17801]
Daniel Atallah <datallah@pidgin.im>
parents:
14899
diff
changeset
|
1404 | silc_client_send_private_message(client, conn, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
1405 | client_entry, im->flags, sg->sha1hash, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1406 | buf->data, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1407 | silc_buffer_len(buf)); |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1408 | silc_mime_partial_free(list); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1409 | purple_conversation_write_message(PURPLE_CONVERSATION(convo), conn->local_entry->nickname, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1410 | im->message, 0, time(NULL)); |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1411 | goto out; |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1412 | } |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1413 | } |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1414 | |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1415 | /* Send the message */ |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1416 | silc_client_send_private_message(client, conn, client_entry, im->flags, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
1417 | sg->sha1hash, (unsigned char *)im->message, im->message_len); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1418 | purple_conversation_write_message(PURPLE_CONVERSATION(convo), conn->local_entry->nickname, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1419 | im->message, 0, time(NULL)); |
| 8849 | 1420 | goto out; |
| 1421 | ||
| 1422 | err: | |
| 1423 | g_snprintf(tmp, sizeof(tmp), | |
| 1424 | _("User <I>%s</I> is not present in the network"), im->nick); | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1425 | purple_conversation_write(PURPLE_CONVERSATION(convo), NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 8849 | 1426 | |
| 1427 | out: | |
|
25545
040ec50ba303
Plug a memory leak in SILC, thanks to Luke Petre.
Luke Petre <luke@petre.net>
parents:
23551
diff
changeset
|
1428 | if (free_list) { |
|
040ec50ba303
Plug a memory leak in SILC, thanks to Luke Petre.
Luke Petre <luke@petre.net>
parents:
23551
diff
changeset
|
1429 | silc_client_list_free(client, conn, clients); |
|
040ec50ba303
Plug a memory leak in SILC, thanks to Luke Petre.
Luke Petre <luke@petre.net>
parents:
23551
diff
changeset
|
1430 | } |
| 8849 | 1431 | g_free(im->nick); |
| 1432 | g_free(im->message); | |
| 1433 | silc_free(im); | |
| 1434 | } | |
| 1435 | ||
| 1436 | static int | |
| 15884 | 1437 | silcpurple_send_im(PurpleConnection *gc, const char *who, const char *message, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1438 | PurpleMessageFlags flags) |
| 8849 | 1439 | { |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1440 | SilcPurple sg = purple_connection_get_protocol_data(gc); |
| 8849 | 1441 | SilcClient client = sg->client; |
| 1442 | SilcClientConnection conn = sg->conn; | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1443 | SilcDList clients; |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1444 | SilcClientEntry client_entry; |
|
33798
ab26d8e3da97
silc: Use appropriate datatype for SilcMessageFlags
Daniel Atallah <datallah@pidgin.im>
parents:
31802
diff
changeset
|
1445 | SilcMessageFlags mflags; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1446 | char *msg, *tmp; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1447 | int ret = 0; |
| 15884 | 1448 | gboolean sign = purple_account_get_bool(sg->account, "sign-verify", FALSE); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1449 | SilcDList list; |
| 8849 | 1450 | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1451 | if (!who || !message) |
| 8849 | 1452 | return 0; |
| 1453 | ||
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1454 | mflags = SILC_MESSAGE_FLAG_UTF8; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1455 | |
| 15884 | 1456 | tmp = msg = purple_unescape_html(message); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1457 | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1458 | if (!g_ascii_strncasecmp(msg, "/me ", 4)) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1459 | msg += 4; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1460 | if (!*msg) { |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1461 | g_free(tmp); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1462 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1463 | } |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1464 | mflags |= SILC_MESSAGE_FLAG_ACTION; |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1465 | } else if (strlen(msg) > 1 && msg[0] == '/') { |
| 8849 | 1466 | if (!silc_client_command_call(client, conn, msg + 1)) |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1467 | purple_notify_error(gc, _("Call Command"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1468 | _("Cannot call command"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1469 | _("Unknown command")); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1470 | g_free(tmp); |
| 8849 | 1471 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1472 | } |
| 8849 | 1473 | |
| 1474 | if (sign) | |
| 1475 | mflags |= SILC_MESSAGE_FLAG_SIGNED; | |
| 1476 | ||
| 1477 | /* Find client entry */ | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1478 | clients = silc_client_get_clients_local(client, conn, who, FALSE); |
| 8849 | 1479 | if (!clients) { |
| 1480 | /* Resolve unknown user */ | |
| 15884 | 1481 | SilcPurpleIM im = silc_calloc(1, sizeof(*im)); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1482 | if (!im) { |
|
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1483 | g_free(tmp); |
| 8849 | 1484 | return 0; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1485 | } |
| 8849 | 1486 | im->nick = g_strdup(who); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1487 | im->message = g_strdup(message); |
| 8849 | 1488 | im->message_len = strlen(im->message); |
| 1489 | im->flags = mflags; | |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1490 | im->gflags = flags; |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1491 | silc_client_get_clients(client, conn, who, NULL, |
| 15884 | 1492 | silcpurple_send_im_resolved, im); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1493 | g_free(tmp); |
| 8849 | 1494 | return 0; |
| 1495 | } | |
| 1496 | ||
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1497 | silc_dlist_start(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1498 | client_entry = silc_dlist_get(clients); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1499 | |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1500 | /* Check for images */ |
| 15884 | 1501 | if (flags & PURPLE_MESSAGE_IMAGES) { |
| 1502 | list = silcpurple_image_message(message, &mflags); | |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1503 | if (list) { |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1504 | /* Send one or more MIME message. If more than one, they |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1505 | are MIME fragments due to over large message */ |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1506 | SilcBuffer buf; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
1507 | |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1508 | silc_dlist_start(list); |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1509 | while ((buf = silc_dlist_get(list)) != SILC_LIST_END) |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1510 | ret = |
|
15081
7e978e8dc84a
[gaim-migrate @ 17801]
Daniel Atallah <datallah@pidgin.im>
parents:
14899
diff
changeset
|
1511 | silc_client_send_private_message(client, conn, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
1512 | client_entry, mflags, sg->sha1hash, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1513 | buf->data, |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1514 | silc_buffer_len(buf)); |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1515 | silc_mime_partial_free(list); |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1516 | g_free(tmp); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1517 | silc_client_list_free(client, conn, clients); |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1518 | return ret; |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1519 | } |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1520 | } |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1521 | |
|
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1522 | /* Send private message directly */ |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1523 | ret = silc_client_send_private_message(client, conn, client_entry, |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19684
diff
changeset
|
1524 | mflags, sg->sha1hash, |
|
12303
f2b594862195
[gaim-migrate @ 14607]
Pekka Riikonen <priikone@silcnet.org>
parents:
12217
diff
changeset
|
1525 | (unsigned char *)msg, |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1526 | strlen(msg)); |
| 8849 | 1527 | |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12167
diff
changeset
|
1528 | g_free(tmp); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
1529 | silc_client_list_free(client, conn, clients); |
| 8849 | 1530 | return ret; |
| 1531 | } | |
| 1532 | ||
| 1533 | ||
| 15884 | 1534 | static GList *silcpurple_blist_node_menu(PurpleBlistNode *node) { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1535 | /* split this single menu building function back into the two |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1536 | original: one for buddies and one for chats */ |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
1537 | if(PURPLE_IS_CHAT(node)) { |
| 15884 | 1538 | return silcpurple_chat_menu((PurpleChat *) node); |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34627
diff
changeset
|
1539 | } else if(PURPLE_IS_BUDDY(node)) { |
| 15884 | 1540 | return silcpurple_buddy_menu((PurpleBuddy *) node); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1541 | } else { |
| 9038 | 1542 | g_return_val_if_reached(NULL); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1543 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1544 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1545 | |
| 9272 | 1546 | /********************************* Commands **********************************/ |
| 1547 | ||
| 15884 | 1548 | static PurpleCmdRet silcpurple_cmd_chat_part(PurpleConversation *conv, |
| 9597 | 1549 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1550 | { |
| 15884 | 1551 | PurpleConnection *gc; |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1552 | PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(conv); |
| 9272 | 1553 | int id = 0; |
| 1554 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1555 | gc = purple_conversation_get_connection(conv); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1556 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1557 | if (gc == NULL) |
| 15884 | 1558 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1559 | |
|
13636
7f3119845b45
[gaim-migrate @ 16033]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13546
diff
changeset
|
1560 | if(args && args[0]) |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1561 | chat = purple_conversations_find_chat_with_account(args[0], |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
1562 | purple_connection_get_account(gc)); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1563 | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1564 | if (chat != NULL) |
|
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1565 | id = purple_chat_conversation_get_id(chat); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1566 | |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1567 | if (id == 0) |
| 15884 | 1568 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1569 | |
| 15884 | 1570 | silcpurple_chat_leave(gc, id); |
| 9272 | 1571 | |
| 15884 | 1572 | return PURPLE_CMD_RET_OK; |
| 9272 | 1573 | |
| 1574 | } | |
| 1575 | ||
| 15884 | 1576 | static PurpleCmdRet silcpurple_cmd_chat_topic(PurpleConversation *conv, |
| 9597 | 1577 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1578 | { |
| 15884 | 1579 | PurpleConnection *gc; |
| 9272 | 1580 | int id = 0; |
| 9762 | 1581 | char *buf, *tmp, *tmp2; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1582 | const char *topic; |
| 9272 | 1583 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1584 | gc = purple_conversation_get_connection(conv); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1585 | id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)); |
| 9272 | 1586 | |
| 1587 | if (gc == NULL || id == 0) | |
| 15884 | 1588 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1589 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1590 | if (!args || !args[0]) { |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1591 | topic = purple_chat_conversation_get_topic(PURPLE_CHAT_CONVERSATION(conv)); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1592 | if (topic) { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10547
diff
changeset
|
1593 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 1594 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 1595 | buf = g_strdup_printf(_("current topic is: %s"), tmp2); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1596 | g_free(tmp); |
| 9762 | 1597 | g_free(tmp2); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1598 | } else |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1599 | buf = g_strdup(_("No topic is set")); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1600 | purple_conversation_write_message(conv, purple_account_get_username(purple_connection_get_account(gc)), buf, |
| 15884 | 1601 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1602 | g_free(buf); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1603 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1604 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1605 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1606 | if (args && args[0] && (strlen(args[0]) > 255)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1607 | *error = g_strdup(_("Topic too long")); |
| 15884 | 1608 | return PURPLE_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1609 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1610 | |
| 15884 | 1611 | silcpurple_chat_set_topic(gc, id, args ? args[0] : NULL); |
| 9272 | 1612 | |
| 15884 | 1613 | return PURPLE_CMD_RET_OK; |
| 9272 | 1614 | } |
| 1615 | ||
| 15884 | 1616 | static PurpleCmdRet silcpurple_cmd_chat_join(PurpleConversation *conv, |
| 9597 | 1617 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1618 | { |
| 1619 | GHashTable *comp; | |
| 1620 | ||
| 1621 | if(!args || !args[0]) | |
| 15884 | 1622 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1623 | |
| 1624 | comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); | |
| 1625 | ||
| 1626 | g_hash_table_replace(comp, "channel", args[0]); | |
| 1627 | if(args[1]) | |
| 1628 | g_hash_table_replace(comp, "passphrase", args[1]); | |
| 1629 | ||
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1630 | silcpurple_chat_join(purple_conversation_get_connection(conv), comp); |
| 9272 | 1631 | |
| 1632 | g_hash_table_destroy(comp); | |
| 15884 | 1633 | return PURPLE_CMD_RET_OK; |
| 9272 | 1634 | } |
| 1635 | ||
| 15884 | 1636 | static PurpleCmdRet silcpurple_cmd_chat_list(PurpleConversation *conv, |
| 9597 | 1637 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1638 | { |
| 15884 | 1639 | PurpleConnection *gc; |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1640 | gc = purple_conversation_get_connection(conv); |
| 15884 | 1641 | purple_roomlist_show_with_account(purple_connection_get_account(gc)); |
| 1642 | return PURPLE_CMD_RET_OK; | |
| 9272 | 1643 | } |
| 1644 | ||
| 15884 | 1645 | static PurpleCmdRet silcpurple_cmd_whois(PurpleConversation *conv, |
| 9597 | 1646 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1647 | { |
| 15884 | 1648 | PurpleConnection *gc; |
| 9272 | 1649 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1650 | gc = purple_conversation_get_connection(conv); |
| 9272 | 1651 | |
| 1652 | if (gc == NULL) | |
| 15884 | 1653 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1654 | |
| 15884 | 1655 | silcpurple_get_info(gc, args[0]); |
| 9272 | 1656 | |
| 15884 | 1657 | return PURPLE_CMD_RET_OK; |
| 9272 | 1658 | } |
| 1659 | ||
| 15884 | 1660 | static PurpleCmdRet silcpurple_cmd_msg(PurpleConversation *conv, |
| 9597 | 1661 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1662 | { |
| 1663 | int ret; | |
| 15884 | 1664 | PurpleConnection *gc; |
| 9272 | 1665 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1666 | gc = purple_conversation_get_connection(conv); |
| 9272 | 1667 | |
| 1668 | if (gc == NULL) | |
| 15884 | 1669 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1670 | |
| 15884 | 1671 | ret = silcpurple_send_im(gc, args[0], args[1], PURPLE_MESSAGE_SEND); |
| 9272 | 1672 | |
| 1673 | if (ret) | |
| 15884 | 1674 | return PURPLE_CMD_RET_OK; |
| 9272 | 1675 | else |
| 15884 | 1676 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1677 | } |
| 1678 | ||
| 15884 | 1679 | static PurpleCmdRet silcpurple_cmd_query(PurpleConversation *conv, |
| 9597 | 1680 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1681 | { |
| 1682 | int ret = 1; | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1683 | PurpleIMConversation *im; |
| 15884 | 1684 | PurpleConnection *gc; |
| 1685 | PurpleAccount *account; | |
| 9272 | 1686 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1687 | if (!args || !args[0]) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1688 | *error = g_strdup(_("You must specify a nick")); |
| 15884 | 1689 | return PURPLE_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1690 | } |
| 9272 | 1691 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1692 | gc = purple_conversation_get_connection(conv); |
| 9272 | 1693 | |
| 1694 | if (gc == NULL) | |
| 15884 | 1695 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1696 | |
| 15884 | 1697 | account = purple_connection_get_account(gc); |
| 9272 | 1698 | |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1699 | im = purple_im_conversation_new(account, args[0]); |
| 9272 | 1700 | |
| 1701 | if (args[1]) { | |
| 15884 | 1702 | ret = silcpurple_send_im(gc, args[0], args[1], PURPLE_MESSAGE_SEND); |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1703 | purple_conversation_write_message(PURPLE_CONVERSATION(im), purple_connection_get_display_name(gc), |
| 15884 | 1704 | args[1], PURPLE_MESSAGE_SEND, time(NULL)); |
| 9272 | 1705 | } |
| 1706 | ||
| 1707 | if (ret) | |
| 15884 | 1708 | return PURPLE_CMD_RET_OK; |
| 9272 | 1709 | else |
| 15884 | 1710 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1711 | } |
| 1712 | ||
| 15884 | 1713 | static PurpleCmdRet silcpurple_cmd_motd(PurpleConversation *conv, |
| 9597 | 1714 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1715 | { |
| 15884 | 1716 | PurpleConnection *gc; |
| 1717 | SilcPurple sg; | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1718 | char *tmp; |
| 9272 | 1719 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1720 | gc = purple_conversation_get_connection(conv); |
| 9272 | 1721 | |
| 1722 | if (gc == NULL) | |
| 15884 | 1723 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1724 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1725 | sg = purple_connection_get_protocol_data(gc); |
| 9272 | 1726 | |
| 1727 | if (sg == NULL) | |
| 15884 | 1728 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1729 | |
| 1730 | if (!sg->motd) { | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1731 | *error = g_strdup(_("There is no Message of the Day associated with this connection")); |
| 15884 | 1732 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1733 | } |
| 1734 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10547
diff
changeset
|
1735 | tmp = g_markup_escape_text(sg->motd, -1); |
| 15884 | 1736 | purple_notify_formatted(gc, NULL, _("Message of the Day"), NULL, |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1737 | tmp, NULL, NULL); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1738 | g_free(tmp); |
| 9272 | 1739 | |
| 15884 | 1740 | return PURPLE_CMD_RET_OK; |
| 9272 | 1741 | } |
| 1742 | ||
| 15884 | 1743 | static PurpleCmdRet silcpurple_cmd_detach(PurpleConversation *conv, |
| 9597 | 1744 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1745 | { |
| 15884 | 1746 | PurpleConnection *gc; |
| 1747 | SilcPurple sg; | |
| 9272 | 1748 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1749 | gc = purple_conversation_get_connection(conv); |
| 9272 | 1750 | |
| 1751 | if (gc == NULL) | |
| 15884 | 1752 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1753 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1754 | sg = purple_connection_get_protocol_data(gc); |
| 9272 | 1755 | |
| 1756 | if (sg == NULL) | |
| 15884 | 1757 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1758 | |
| 1759 | silc_client_command_call(sg->client, sg->conn, "DETACH"); | |
| 1760 | sg->detaching = TRUE; | |
| 1761 | ||
| 15884 | 1762 | return PURPLE_CMD_RET_OK; |
| 9272 | 1763 | } |
| 1764 | ||
| 15884 | 1765 | static PurpleCmdRet silcpurple_cmd_cmode(PurpleConversation *conv, |
| 9597 | 1766 | const char *cmd, char **args, char **error, void *data) |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1767 | { |
| 15884 | 1768 | PurpleConnection *gc; |
| 1769 | SilcPurple sg; | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1770 | SilcChannelEntry channel; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1771 | char *silccmd, *silcargs, *msg, tmp[256]; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1772 | const char *chname; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1773 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1774 | gc = purple_conversation_get_connection(conv); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1775 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1776 | if (gc == NULL || !args || purple_connection_get_protocol_data(gc) == NULL) |
| 15884 | 1777 | return PURPLE_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1778 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1779 | sg = purple_connection_get_protocol_data(gc); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1780 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1781 | if (args[0]) |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1782 | chname = args[0]; |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1783 | else |
| 15884 | 1784 | chname = purple_conversation_get_name(conv); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1785 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1786 | if (!args[1]) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1787 | channel = silc_client_get_channel(sg->client, sg->conn, |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1788 | (char *)chname); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1789 | if (!channel) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1790 | *error = g_strdup_printf(_("channel %s not found"), chname); |
| 15884 | 1791 | return PURPLE_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1792 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1793 | if (channel->mode) { |
| 15884 | 1794 | silcpurple_get_chmode_string(channel->mode, tmp, sizeof(tmp)); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1795 | msg = g_strdup_printf(_("channel modes for %s: %s"), chname, tmp); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1796 | } else { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1797 | msg = g_strdup_printf(_("no channel modes are set on %s"), chname); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1798 | } |
|
34897
a323e8b5a090
Refactored silc to use the GObjectified conversation API
Ankit Vani <a@nevitus.org>
parents:
34894
diff
changeset
|
1799 | purple_conversation_write_message(conv, "", |
| 15884 | 1800 | msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1801 | g_free(msg); |
| 15884 | 1802 | return PURPLE_CMD_RET_OK; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1803 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1804 | |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1805 | silcargs = g_strjoinv(" ", args); |
|
33801
6dbfcd72998e
Fix a few cases of dead code
Daniel Atallah <datallah@pidgin.im>
parents:
33798
diff
changeset
|
1806 | silccmd = g_strconcat(cmd, " ", silcargs, NULL); |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1807 | g_free(silcargs); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1808 | if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1809 | g_free(silccmd); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1810 | *error = g_strdup_printf(_("Failed to set cmodes for %s"), args[0]); |
| 15884 | 1811 | return PURPLE_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1812 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1813 | g_free(silccmd); |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1814 | |
| 15884 | 1815 | return PURPLE_CMD_RET_OK; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1816 | } |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1817 | |
| 15884 | 1818 | static PurpleCmdRet silcpurple_cmd_generic(PurpleConversation *conv, |
| 9597 | 1819 | const char *cmd, char **args, char **error, void *data) |
| 9272 | 1820 | { |
| 15884 | 1821 | PurpleConnection *gc; |
| 1822 | SilcPurple sg; | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1823 | char *silccmd, *silcargs; |
| 9272 | 1824 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1825 | gc = purple_conversation_get_connection(conv); |
| 9272 | 1826 | |
| 1827 | if (gc == NULL) | |
| 15884 | 1828 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1829 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1830 | sg = purple_connection_get_protocol_data(gc); |
| 9272 | 1831 | |
| 1832 | if (sg == NULL) | |
| 15884 | 1833 | return PURPLE_CMD_RET_FAILED; |
| 9272 | 1834 | |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1835 | silcargs = g_strjoinv(" ", args); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1836 | silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1837 | g_free(silcargs); |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1838 | if (!silc_client_command_call(sg->client, sg->conn, silccmd)) { |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1839 | g_free(silccmd); |
|
15444
b793ef258d23
I think this changes every user-visible string that contains 'Gaim.' We probably want the UI to be able
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
1840 | *error = g_strdup_printf(_("Unknown command: %s, (may be a client bug)"), cmd); |
| 15884 | 1841 | return PURPLE_CMD_RET_FAILED; |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1842 | } |
|
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
1843 | g_free(silccmd); |
| 9272 | 1844 | |
| 15884 | 1845 | return PURPLE_CMD_RET_OK; |
| 9272 | 1846 | } |
| 1847 | ||
| 15884 | 1848 | static PurpleCmdRet silcpurple_cmd_quit(PurpleConversation *conv, |
| 9597 | 1849 | const char *cmd, char **args, char **error, void *data) |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1850 | { |
| 15884 | 1851 | PurpleConnection *gc; |
| 1852 | SilcPurple sg; | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1853 | GHashTable *ui_info; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1854 | const char *ui_name = NULL, *ui_website = NULL; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1855 | char *quit_msg; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1856 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1857 | gc = purple_conversation_get_connection(conv); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1858 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1859 | if (gc == NULL) |
| 15884 | 1860 | return PURPLE_CMD_RET_FAILED; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1861 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1862 | sg = purple_connection_get_protocol_data(gc); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1863 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1864 | if (sg == NULL) |
| 15884 | 1865 | return PURPLE_CMD_RET_FAILED; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1866 | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1867 | ui_info = purple_core_get_ui_info(); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1868 | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1869 | if(ui_info) { |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1870 | ui_name = g_hash_table_lookup(ui_info, "name"); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1871 | ui_website = g_hash_table_lookup(ui_info, "website"); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1872 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1873 | |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1874 | if(!ui_name || !ui_website) { |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1875 | ui_name = "Pidgin"; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1876 | ui_website = PURPLE_WEBSITE; |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1877 | } |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1878 | quit_msg = g_strdup_printf(_("Download %s: %s"), |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1879 | ui_name, ui_website); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1880 | |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1881 | silc_client_command_call(sg->client, sg->conn, NULL, |
|
23545
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1882 | "QUIT", (args && args[0]) ? args[0] : quit_msg, NULL); |
|
676b13ddfd2c
Added "website" and "dev_website" items to the ui_info GHashTable,
Evan Schoenberg <evands@pidgin.im>
parents:
23542
diff
changeset
|
1883 | g_free(quit_msg); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1884 | |
| 15884 | 1885 | return PURPLE_CMD_RET_OK; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1886 | } |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1887 | |
| 15884 | 1888 | static PurpleCmdRet silcpurple_cmd_call(PurpleConversation *conv, |
| 9597 | 1889 | const char *cmd, char **args, char **error, void *data) |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1890 | { |
| 15884 | 1891 | PurpleConnection *gc; |
| 1892 | SilcPurple sg; | |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1893 | |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32683
diff
changeset
|
1894 | gc = purple_conversation_get_connection(conv); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1895 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1896 | if (gc == NULL) |
| 15884 | 1897 | return PURPLE_CMD_RET_FAILED; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1898 | |
|
32281
0ef1a6d8ca53
Convert silc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32157
diff
changeset
|
1899 | sg = purple_connection_get_protocol_data(gc); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1900 | |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1901 | if (sg == NULL) |
| 15884 | 1902 | return PURPLE_CMD_RET_FAILED; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1903 | |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1904 | if (!silc_client_command_call(sg->client, sg->conn, args[0])) { |
|
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1905 | *error = g_strdup_printf(_("Unknown command: %s"), args[0]); |
| 15884 | 1906 | return PURPLE_CMD_RET_FAILED; |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1907 | } |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1908 | |
| 15884 | 1909 | return PURPLE_CMD_RET_OK; |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1910 | } |
|
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
1911 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9024
diff
changeset
|
1912 | |
| 8849 | 1913 | /************************** Plugin Initialization ****************************/ |
| 1914 | ||
| 9272 | 1915 | static void |
| 15884 | 1916 | silcpurple_register_commands(void) |
| 9272 | 1917 | { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1918 | purple_cmd_register("part", "w", PURPLE_CMD_P_PROTOCOL, |
| 15884 | 1919 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1920 | PURPLE_CMD_FLAG_PROTOCOL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, |
| 15884 | 1921 | "prpl-silc", silcpurple_cmd_chat_part, _("part [channel]: Leave the chat"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1922 | purple_cmd_register("leave", "w", PURPLE_CMD_P_PROTOCOL, |
| 15884 | 1923 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1924 | PURPLE_CMD_FLAG_PROTOCOL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, |
| 15884 | 1925 | "prpl-silc", silcpurple_cmd_chat_part, _("leave [channel]: Leave the chat"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1926 | purple_cmd_register("topic", "s", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1927 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1928 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", |
| 1929 | silcpurple_cmd_chat_topic, _("topic [<new topic>]: View or change the topic"), NULL); | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1930 | purple_cmd_register("join", "ws", PURPLE_CMD_P_PROTOCOL, |
| 15884 | 1931 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1932 | PURPLE_CMD_FLAG_PROTOCOL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, |
| 15884 | 1933 | "prpl-silc", silcpurple_cmd_chat_join, |
| 9597 | 1934 | _("join <channel> [<password>]: Join a chat on this network"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1935 | purple_cmd_register("list", "", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1936 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1937 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", |
| 1938 | silcpurple_cmd_chat_list, _("list: List channels on this network"), NULL); | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1939 | purple_cmd_register("whois", "w", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1940 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9272 | 1941 | "prpl-silc", |
| 15884 | 1942 | silcpurple_cmd_whois, _("whois <nick>: View nick's information"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1943 | purple_cmd_register("msg", "ws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1944 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 1945 | "prpl-silc", silcpurple_cmd_msg, |
| 9597 | 1946 | _("msg <nick> <message>: Send a private message to a user"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1947 | purple_cmd_register("query", "ws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1948 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1949 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_query, |
| 9597 | 1950 | _("query <nick> [<message>]: Send a private message to a user"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1951 | purple_cmd_register("motd", "", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1952 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1953 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_motd, |
| 9597 | 1954 | _("motd: View the server's Message Of The Day"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1955 | purple_cmd_register("detach", "", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1956 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 1957 | "prpl-silc", silcpurple_cmd_detach, |
| 9597 | 1958 | _("detach: Detach this session"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1959 | purple_cmd_register("quit", "s", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1960 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1961 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_quit, |
| 9597 | 1962 | _("quit [message]: Disconnect from the server, with an optional message"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1963 | purple_cmd_register("call", "s", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1964 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 1965 | "prpl-silc", silcpurple_cmd_call, |
| 9597 | 1966 | _("call <command>: Call any silc client command"), NULL); |
| 1967 | /* These below just get passed through for the silc client library to deal | |
| 1968 | * with */ | |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1969 | purple_cmd_register("kill", "ws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1970 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1971 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 1972 | _("kill <nick> [-pubkey|<reason>]: Kill nick"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1973 | purple_cmd_register("nick", "w", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1974 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 1975 | "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 1976 | _("nick <newnick>: Change your nickname"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1977 | purple_cmd_register("whowas", "ww", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1978 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1979 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 1980 | _("whowas <nick>: View nick's information"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1981 | purple_cmd_register("cmode", "wws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1982 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1983 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_cmode, |
| 9597 | 1984 | _("cmode <channel> [+|-<modes>] [arguments]: Change or display channel modes"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1985 | purple_cmd_register("cumode", "wws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1986 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1987 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 1988 | _("cumode <channel> +|-<modes> <nick>: Change nick's modes on channel"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1989 | purple_cmd_register("umode", "w", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1990 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 1991 | "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 1992 | _("umode <usermodes>: Set your modes in the network"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1993 | purple_cmd_register("oper", "s", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1994 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 1995 | "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 1996 | _("oper <nick> [-pubkey]: Get server operator privileges"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1997 | purple_cmd_register("invite", "ws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1998 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 1999 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2000 | _("invite <channel> [-|+]<nick>: invite nick or add/remove from channel invite list"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2001 | purple_cmd_register("kick", "wws", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2002 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 2003 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2004 | _("kick <channel> <nick> [comment]: Kick client from channel"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2005 | purple_cmd_register("info", "w", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2006 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 2007 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2008 | _("info [server]: View server administrative details"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2009 | purple_cmd_register("ban", "ww", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2010 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 2011 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2012 | _("ban [<channel> +|-<nick>]: Ban client from channel"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2013 | purple_cmd_register("getkey", "w", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2014 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 2015 | "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2016 | _("getkey <nick|server>: Retrieve client's or server's public key"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2017 | purple_cmd_register("stats", "", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2018 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 2019 | "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2020 | _("stats: View server and network statistics"), NULL); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2021 | purple_cmd_register("ping", "", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2022 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 2023 | "prpl-silc", silcpurple_cmd_generic, |
| 9597 | 2024 | _("ping: Send PING to the connected server"), NULL); |
| 15884 | 2025 | #if 0 /* Purple doesn't handle these yet */ |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2026 | purple_cmd_register("users", "w", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2027 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 15884 | 2028 | "prpl-silc", silcpurple_cmd_users, |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
2029 | _("users <channel>: List users in channel")); |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2030 | purple_cmd_register("names", "ww", PURPLE_CMD_P_PROTOCOL, |
|
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
2031 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY | |
| 15884 | 2032 | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcpurple_cmd_names, |
|
9488
9d6520fa53fd
[gaim-migrate @ 10313]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
2033 | _("names [-count|-ops|-halfops|-voices|-normal] <channel(s)>: List specific users in channel(s)")); |
|
9359
89c40efa7f7b
[gaim-migrate @ 10167]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9353
diff
changeset
|
2034 | #endif |
| 9272 | 2035 | } |
| 2036 | ||
| 15884 | 2037 | static PurpleWhiteboardPrplOps silcpurple_wb_ops = |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11837
diff
changeset
|
2038 | { |
| 15884 | 2039 | silcpurple_wb_start, |
| 2040 | silcpurple_wb_end, | |
| 2041 | silcpurple_wb_get_dimensions, | |
| 2042 | silcpurple_wb_set_dimensions, | |
| 2043 | silcpurple_wb_get_brush, | |
| 2044 | silcpurple_wb_set_brush, | |
| 2045 | silcpurple_wb_send, | |
| 2046 | silcpurple_wb_clear, | |
|
16776
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
16549
diff
changeset
|
2047 | |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
16549
diff
changeset
|
2048 | /* padding */ |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
16549
diff
changeset
|
2049 | NULL, |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
16549
diff
changeset
|
2050 | NULL, |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
16549
diff
changeset
|
2051 | NULL, |
|
c9301dd6aa1f
Add padding to silc and bonjour to get rid of a bunch of warnings.
Mark Doliner <markdoliner@pidgin.im>
parents:
16549
diff
changeset
|
2052 | NULL |
|
12058
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11837
diff
changeset
|
2053 | }; |
|
6d4b6e3bd0ba
[gaim-migrate @ 14353]
Pekka Riikonen <priikone@silcnet.org>
parents:
11837
diff
changeset
|
2054 | |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2055 | #if 0 |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2056 | static SilcBool silcpurple_debug_cb(char *file, char *function, int line, |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2057 | char *message, void *context) |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2058 | { |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2059 | purple_debug_info("SILC", "%s:%d:%s - %s\n", file ? file : "(null)", line, function ? function : "(null)", message ? message : "(null)"); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2060 | return TRUE; |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2061 | } |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2062 | #endif |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2063 | |
| 8849 | 2064 | static void |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2065 | silcpurple_protocol_base_init(SILCProtocolClass *klass) |
| 8849 | 2066 | { |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2067 | PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass); |
| 15884 | 2068 | PurpleAccountOption *option; |
| 2069 | PurpleAccountUserSplit *split; | |
| 8849 | 2070 | char tmp[256]; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2071 | int i; |
| 15884 | 2072 | PurpleKeyValuePair *kvp; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2073 | GList *list = NULL; |
| 8849 | 2074 | |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2075 | proto_class->id = SILCPURPLE_ID; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2076 | proto_class->name = SILCPURPLE_NAME; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2077 | proto_class->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2078 | OPT_PROTO_PASSWORD_OPTIONAL | OPT_PROTO_IM_IMAGE | |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2079 | OPT_PROTO_SLASH_COMMANDS_NATIVE; |
|
36609
637155f87448
Refactored the protocols to use purple_buddy_icon_spec_new()
Ankit Vani <a@nevitus.org>
parents:
36596
diff
changeset
|
2080 | proto_class->icon_spec = purple_buddy_icon_spec_new("jpeg,gif,png,bmp", |
|
637155f87448
Refactored the protocols to use purple_buddy_icon_spec_new()
Ankit Vani <a@nevitus.org>
parents:
36596
diff
changeset
|
2081 | 0, 0, 96, 96, 0, |
|
637155f87448
Refactored the protocols to use purple_buddy_icon_spec_new()
Ankit Vani <a@nevitus.org>
parents:
36596
diff
changeset
|
2082 | PURPLE_ICON_SCALE_DISPLAY); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2083 | |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2084 | proto_class->whiteboard_protocol_ops = &silcpurple_wb_ops; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2085 | |
| 15884 | 2086 | split = purple_account_user_split_new(_("Network"), "silcnet.org", '@'); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2087 | proto_class->user_splits = g_list_append(proto_class->user_splits, split); |
|
10825
986d260851e8
[gaim-migrate @ 12490]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10802
diff
changeset
|
2088 | |
| 8849 | 2089 | /* Account options */ |
| 15884 | 2090 | option = purple_account_option_string_new(_("Connect server"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2091 | "server", |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2092 | "silc.silcnet.org"); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2093 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2094 | option = purple_account_option_int_new(_("Port"), "port", 706); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2095 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2096 | g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); |
| 2097 | option = purple_account_option_string_new(_("Public Key file"), | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2098 | "public-key", tmp); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2099 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2100 | g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); |
| 2101 | option = purple_account_option_string_new(_("Private Key file"), | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2102 | "private-key", tmp); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2103 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2104 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2105 | for (i = 0; silc_default_ciphers[i].name; i++) { |
| 15884 | 2106 | kvp = g_new0(PurpleKeyValuePair, 1); |
|
15081
7e978e8dc84a
[gaim-migrate @ 17801]
Daniel Atallah <datallah@pidgin.im>
parents:
14899
diff
changeset
|
2107 | kvp->key = g_strdup(silc_default_ciphers[i].name); |
|
7e978e8dc84a
[gaim-migrate @ 17801]
Daniel Atallah <datallah@pidgin.im>
parents:
14899
diff
changeset
|
2108 | kvp->value = g_strdup(silc_default_ciphers[i].name); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2109 | list = g_list_append(list, kvp); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2110 | } |
| 15884 | 2111 | option = purple_account_option_list_new(_("Cipher"), "cipher", list); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2112 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2113 | |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2114 | list = NULL; |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2115 | for (i = 0; silc_default_hmacs[i].name; i++) { |
| 15884 | 2116 | kvp = g_new0(PurpleKeyValuePair, 1); |
|
15081
7e978e8dc84a
[gaim-migrate @ 17801]
Daniel Atallah <datallah@pidgin.im>
parents:
14899
diff
changeset
|
2117 | kvp->key = g_strdup(silc_default_hmacs[i].name); |
|
7e978e8dc84a
[gaim-migrate @ 17801]
Daniel Atallah <datallah@pidgin.im>
parents:
14899
diff
changeset
|
2118 | kvp->value = g_strdup(silc_default_hmacs[i].name); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2119 | list = g_list_append(list, kvp); |
|
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2120 | } |
| 15884 | 2121 | option = purple_account_option_list_new(_("HMAC"), "hmac", list); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2122 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2123 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2124 | option = purple_account_option_bool_new(_("Use Perfect Forward Secrecy"), |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2125 | "pfs", FALSE); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2126 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2127 | |
| 15884 | 2128 | option = purple_account_option_bool_new(_("Public key authentication"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2129 | "pubkey-auth", FALSE); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2130 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2131 | option = purple_account_option_bool_new(_("Block IMs without Key Exchange"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2132 | "block-ims", FALSE); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2133 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2134 | option = purple_account_option_bool_new(_("Block messages to whiteboard"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2135 | "block-wb", FALSE); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2136 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2137 | option = purple_account_option_bool_new(_("Automatically open whiteboard"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2138 | "open-wb", FALSE); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2139 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 15884 | 2140 | option = purple_account_option_bool_new(_("Digitally sign and verify all messages"), |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2141 | "sign-verify", FALSE); |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2142 | proto_class->protocol_options = g_list_append(proto_class->protocol_options, option); |
| 8849 | 2143 | |
| 15884 | 2144 | purple_prefs_remove("/plugins/prpl/silc"); |
| 9272 | 2145 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2146 | silc_log_set_callback(SILC_LOG_ERROR, silcpurple_log_error, NULL); |
| 15884 | 2147 | silcpurple_register_commands(); |
|
9353
ff6546387358
[gaim-migrate @ 10161]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9308
diff
changeset
|
2148 | |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2149 | #if 0 |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2150 | silc_log_debug(TRUE); |
|
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2151 | silc_log_set_debug_string("*client*"); |
|
22972
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2152 | silc_log_quick(TRUE); |
|
2942c1995c22
Cleanup allocations/frees to match and plug some leaks.
Daniel Atallah <datallah@pidgin.im>
parents:
22853
diff
changeset
|
2153 | silc_log_set_debug_callbacks(silcpurple_debug_cb, NULL, NULL, NULL); |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2154 | #endif |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2155 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2156 | |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2157 | static void |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2158 | silcpurple_protocol_interface_init(PurpleProtocolInterface *iface) |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2159 | { |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2160 | iface->get_actions = silcpurple_get_actions; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2161 | iface->list_icon = silcpurple_list_icon; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2162 | iface->status_text = silcpurple_status_text; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2163 | iface->tooltip_text = silcpurple_tooltip_text; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2164 | iface->status_types = silcpurple_away_states; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2165 | iface->blist_node_menu = silcpurple_blist_node_menu; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2166 | iface->chat_info = silcpurple_chat_info; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2167 | iface->chat_info_defaults = silcpurple_chat_info_defaults; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2168 | iface->login = silcpurple_login; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2169 | iface->close = silcpurple_close; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2170 | iface->send_im = silcpurple_send_im; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2171 | iface->set_info = silcpurple_set_info; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2172 | iface->get_info = silcpurple_get_info; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2173 | iface->set_status = silcpurple_set_status; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2174 | iface->set_idle = silcpurple_idle_set; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2175 | iface->change_passwd = silcpurple_change_passwd; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2176 | iface->add_buddy = silcpurple_add_buddy; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2177 | iface->remove_buddy = silcpurple_remove_buddy; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2178 | iface->join_chat = silcpurple_chat_join; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2179 | iface->get_chat_name = silcpurple_get_chat_name; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2180 | iface->chat_invite = silcpurple_chat_invite; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2181 | iface->chat_leave = silcpurple_chat_leave; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2182 | iface->chat_send = silcpurple_chat_send; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2183 | iface->keepalive = silcpurple_keepalive; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2184 | iface->set_buddy_icon = silcpurple_buddy_set_icon; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2185 | iface->set_chat_topic = silcpurple_chat_set_topic; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2186 | iface->roomlist_get_list = silcpurple_roomlist_get_list; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2187 | iface->roomlist_cancel = silcpurple_roomlist_cancel; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2188 | iface->send_file = silcpurple_ftp_send_file; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2189 | iface->new_xfer = silcpurple_ftp_new_xfer; |
| 8849 | 2190 | } |
| 2191 | ||
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2192 | static void silcpurple_protocol_base_finalize(SILCProtocolClass *klass) { } |
| 8849 | 2193 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2194 | static PurplePluginInfo * |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2195 | plugin_query(GError **error) |
| 8849 | 2196 | { |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2197 | return purple_plugin_info_new( |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2198 | "id", SILCPURPLE_ID, |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2199 | "name", SILCPURPLE_NAME, |
| 36536 | 2200 | "version", "1.1", |
| 2201 | "category", N_("Protocol"), | |
| 2202 | "summary", N_("SILC Protocol Plugin"), | |
| 2203 | "description", N_("Secure Internet Live Conferencing (SILC) Protocol"), | |
| 2204 | "author", "Pekka Riikonen", | |
| 2205 | "website", "http://silcnet.org/", | |
| 2206 | "abi-version", PURPLE_ABI_VERSION, | |
| 2207 | "flags", GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL | | |
| 2208 | GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY, | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2209 | NULL |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2210 | ); |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2211 | } |
| 8849 | 2212 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2213 | static gboolean |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2214 | plugin_load(PurplePlugin *plugin, GError **error) |
| 8849 | 2215 | { |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2216 | my_protocol = purple_protocols_add(SILCPURPLE_TYPE_PROTOCOL); |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2217 | |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2218 | if (!my_protocol) { |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2219 | g_set_error(error, SILCPURPLE_DOMAIN, 0, _("Failed to add silc protocol")); |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2220 | return FALSE; |
|
12217
ea610d8ab584
[gaim-migrate @ 14519]
Pekka Riikonen <priikone@silcnet.org>
parents:
12216
diff
changeset
|
2221 | } |
|
17675
e7069bf1de1a
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17570
diff
changeset
|
2222 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2223 | return TRUE; |
| 8849 | 2224 | } |
| 2225 | ||
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2226 | static gboolean |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2227 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2228 | { |
|
36595
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2229 | if (!purple_protocols_remove(my_protocol)) { |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2230 | g_set_error(error, SILCPURPLE_DOMAIN, 0, _("Failed to remove silc protocol")); |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2231 | return FALSE; |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2232 | } |
|
d013a99e6d94
Refactored silc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36593
diff
changeset
|
2233 | |
|
36533
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2234 | return TRUE; |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2235 | } |
|
1e87c79042a3
Refactored silc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2236 | |
|
36613
0e96218aa13a
Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents:
36609
diff
changeset
|
2237 | static PurplePlugin *my_plugin; |
|
0e96218aa13a
Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents:
36609
diff
changeset
|
2238 | PURPLE_PROTOCOL_DEFINE(my_plugin, SILCProtocol, silcpurple_protocol); |
|
0e96218aa13a
Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents:
36609
diff
changeset
|
2239 | PURPLE_PLUGIN_INIT_VAL(my_plugin, silc, plugin_query, plugin_load, |
|
0e96218aa13a
Refactored the protocols to use the new macros, to allow for static or dynamic loading of types as configured
Ankit Vani <a@nevitus.org>
parents:
36609
diff
changeset
|
2240 | plugin_unload); |