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