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