annotate src/protocols/silc/silc.c @ 11751:5d1dd575d0f4

[gaim-migrate @ 14042] don't set plugin_dialog = NULL just because a pref dialog was closed committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 23 Oct 2005 13:17:10 +0000
parents 11e95968c9ff
children fa742ad8068c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
3 silcgaim.c
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
4
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
5 Author: Pekka Riikonen <priikone@silcnet.org>
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
6
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
7 Copyright (C) 2004 - 2005 Pekka Riikonen
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
8
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
11 the Free Software Foundation; version 2 of the License.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
12
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
16 GNU General Public License for more details.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
17
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
18 */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
19
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
20 #include "silcincludes.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
21 #include "silcclient.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
22 #include "silcgaim.h"
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
23 #include "version.h"
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
24
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
25 extern SilcClientOperations ops;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
26 static GaimPlugin *silc_plugin = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
27
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
28 static const char *
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
29 silcgaim_list_icon(GaimAccount *a, GaimBuddy *b)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
30 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
31 return (const char *)"silc";
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
32 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
33
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
34 static void
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
35 silcgaim_list_emblems(GaimBuddy *b, const char **se, const char **sw,
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
36 const char **nw, const char **ne)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
37 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
38 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
39
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
40 static GList *
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
41 silcgaim_away_states(GaimAccount *account)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
42 {
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
43 GaimStatusType *type;
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
44 GList *types = NULL;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
45
10801
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
46 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, SILCGAIM_STATUS_ID_OFFLINE, _("Offline"), FALSE, FALSE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
47 types = g_list_append(types, type);
10801
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
48 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, SILCGAIM_STATUS_ID_AVAILABLE, _("Available"), FALSE, TRUE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
49 types = g_list_append(types, type);
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 9968
diff changeset
50 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, SILCGAIM_STATUS_ID_HYPER, _("Hyper Active"), FALSE, TRUE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
51 types = g_list_append(types, type);
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 9968
diff changeset
52 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_AWAY, _("Away"), FALSE, TRUE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
53 types = g_list_append(types, type);
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 9968
diff changeset
54 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_BUSY, _("Busy"), FALSE, TRUE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
55 types = g_list_append(types, type);
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 9968
diff changeset
56 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_INDISPOSED, _("Indisposed"), FALSE, TRUE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
57 types = g_list_append(types, type);
10050
30e052ebb5ae [gaim-migrate @ 11011]
Mark Doliner <mark@kingant.net>
parents: 9968
diff changeset
58 type = gaim_status_type_new_full(GAIM_STATUS_AWAY, SILCGAIM_STATUS_ID_PAGE, _("Wake Me Up"), FALSE, TRUE, FALSE);
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
59 types = g_list_append(types, type);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
60
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
61 return types;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
62 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
63
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
64 static void
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
65 silcgaim_set_status(GaimAccount *account, GaimStatus *status)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
66 {
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
67 GaimConnection *gc = gaim_account_get_connection(account);
10801
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
68 SilcGaim sg = NULL;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
69 SilcUInt32 mode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
70 SilcBuffer idp;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
71 unsigned char mb[4];
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
72 const char *state;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
73
10801
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
74 if (gc != NULL)
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
75 sg = gc->proto_data;
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
76
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
77 if (status == NULL)
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
78 return;
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
79
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
80 state = gaim_status_get_id(status);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10050
diff changeset
81
10801
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
82 if (state == NULL)
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
83 return;
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10050
diff changeset
84
10801
39b5a5e30f47 [gaim-migrate @ 12447]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
85 if ((sg == NULL) || (sg->conn == NULL))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
86 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
87
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
88 mode = sg->conn->local_entry->mode;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
89 mode &= ~(SILC_UMODE_GONE |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
90 SILC_UMODE_HYPER |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
91 SILC_UMODE_BUSY |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
92 SILC_UMODE_INDISPOSED |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
93 SILC_UMODE_PAGE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
94
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
95 if (!strcmp(state, "hyper"))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
96 mode |= SILC_UMODE_HYPER;
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
97 else if (!strcmp(state, "away"))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
98 mode |= SILC_UMODE_GONE;
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
99 else if (!strcmp(state, "busy"))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
100 mode |= SILC_UMODE_BUSY;
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
101 else if (!strcmp(state, "indisposed"))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
102 mode |= SILC_UMODE_INDISPOSED;
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
103 else if (!strcmp(state, "page"))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
104 mode |= SILC_UMODE_PAGE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
105
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
106 /* Send UMODE */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
107 idp = silc_id_payload_encode(sg->conn->local_id, SILC_ID_CLIENT);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
108 SILC_PUT32_MSB(mode, mb);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
109 silc_client_command_send(sg->client, sg->conn, SILC_COMMAND_UMODE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
110 ++sg->conn->cmd_ident, 2,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
111 1, idp->data, idp->len,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
112 2, mb, sizeof(mb));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
113 silc_buffer_free(idp);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
114 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
115
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
116
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
117 /*************************** Connection Routines *****************************/
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
118
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
119 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
120 silcgaim_keepalive(GaimConnection *gc)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
121 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
122 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
123 silc_client_send_packet(sg->client, sg->conn, SILC_PACKET_HEARTBEAT,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
124 NULL, 0);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
125 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
126
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
127 static int
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
128 silcgaim_scheduler(gpointer *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
129 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
130 SilcGaim sg = (SilcGaim)context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
131 silc_client_run_one(sg->client);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
132 return 1;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
133 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
134
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
135 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
136 silcgaim_nickname_parse(const char *nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
137 char **ret_nickname)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
138 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
139 silc_parse_userfqdn(nickname, ret_nickname, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
140 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
141
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
142 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
143 silcgaim_login_connected(gpointer data, gint source, GaimInputCondition cond)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
144 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
145 GaimConnection *gc = data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
146 SilcGaim sg = gc->proto_data;
9732
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
147 SilcClient client;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
148 SilcClientConnection conn;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
149 GaimAccount *account = sg->account;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
150 SilcClientConnectionParams params;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
151 const char *dfile;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
152
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
153 if (source < 0) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
154 gaim_connection_error(gc, _("Connection failed"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
155 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
156 }
9732
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
157
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
158 if (sg == NULL)
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
159 return;
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
160
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
161 client = sg->client;
eb9c345d45a3 [gaim-migrate @ 10593]
Ethan Blanton <elb@pidgin.im>
parents: 9597
diff changeset
162
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
163 if (!g_list_find(gaim_connections_get_all(), gc)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
164 close(source);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
165 g_source_remove(sg->scheduler);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
166 silc_client_stop(sg->client);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
167 silc_client_free(sg->client);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
168 silc_free(sg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
169 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
170 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
171
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
172 /* Get session detachment data, if available */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
173 memset(&params, 0, sizeof(params));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
174 dfile = silcgaim_session_file(gaim_account_get_username(sg->account));
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11257
diff changeset
175 params.detach_data = (unsigned char *)silc_file_readfile(dfile, &params.detach_data_len);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
176 if (params.detach_data)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
177 params.detach_data[params.detach_data_len] = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
178
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
179 /* Add connection to SILC client library */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
180 conn = silc_client_add_connection(
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
181 sg->client, &params,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
182 (char *)gaim_account_get_string(account, "server",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
183 "silc.silcnet.org"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
184 gaim_account_get_int(account, "port", 706), sg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
185 if (!conn) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
186 gaim_connection_error(gc, _("Cannot initialize SILC Client connection"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
187 gc->proto_data = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
188 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
189 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
190 sg->conn = conn;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
191
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
192 /* Progress */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
193 if (params.detach_data) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
194 gaim_connection_update_progress(gc, _("Resuming session"), 2, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
195 sg->resuming = TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
196 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
197 gaim_connection_update_progress(gc, _("Performing key exchange"), 2, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
198 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
199
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
200 /* Perform SILC Key Exchange. The "silc_connected" will be called
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
201 eventually. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
202 silc_client_start_key_exchange(sg->client, sg->conn, source);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
203
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
204 /* Set default attributes */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
205 if (!gaim_account_get_bool(account, "reject-attrs", FALSE)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
206 SilcUInt32 mask;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
207 const char *tmp;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
208 #ifdef HAVE_SYS_UTSNAME_H
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
209 struct utsname u;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
210 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
211
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
212 mask = SILC_ATTRIBUTE_MOOD_NORMAL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
213 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
214 SILC_ATTRIBUTE_STATUS_MOOD,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
215 SILC_32_TO_PTR(mask),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
216 sizeof(SilcUInt32));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
217 mask = SILC_ATTRIBUTE_CONTACT_CHAT;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
218 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
219 SILC_ATTRIBUTE_PREFERRED_CONTACT,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
220 SILC_32_TO_PTR(mask),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
221 sizeof(SilcUInt32));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
222 #ifdef HAVE_SYS_UTSNAME_H
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
223 if (!uname(&u)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
224 SilcAttributeObjDevice dev;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
225 memset(&dev, 0, sizeof(dev));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
226 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
227 dev.version = u.release;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
228 dev.model = u.sysname;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
229 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
230 SILC_ATTRIBUTE_DEVICE_INFO,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
231 (void *)&dev, sizeof(dev));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
232 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
233 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
234 #ifdef _WIN32
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
235 tmp = _tzname[0];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
236 #else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
237 tmp = tzname[0];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
238 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
239 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
240 SILC_ATTRIBUTE_TIMEZONE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
241 (void *)tmp, strlen(tmp));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
242 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
243
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
244 silc_free(params.detach_data);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
245 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
246
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
247 static void
10401
3e4ecbdf8d0a [gaim-migrate @ 11638]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10341
diff changeset
248 silcgaim_login(GaimAccount *account, GaimStatus *status)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
249 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
250 SilcGaim sg;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
251 SilcClient client;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
252 SilcClientParams params;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
253 GaimConnection *gc;
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
254 char pkd[256], prd[256];
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
255
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
256 gc = account->gc;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
257 if (!gc)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
258 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
259 gc->proto_data = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
260
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
261 memset(&params, 0, sizeof(params));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
262 strcat(params.nickname_format, "%n@%h%a");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
263 params.nickname_parse = silcgaim_nickname_parse;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
264 params.ignore_requested_attributes =
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
265 gaim_account_get_bool(account, "reject-attrs", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
266
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
267 /* Allocate SILC client */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
268 client = silc_client_alloc(&ops, &params, gc, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
269 if (!client) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
270 gaim_connection_error(gc, _("Out of memory"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
271 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
272 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
273
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
274 /* Get username, real name and local hostname for SILC library */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
275 if (gaim_account_get_username(account)) {
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
276 const char *u = gaim_account_get_username(account);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
277 char **up = g_strsplit(u, "@", 2);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
278 client->username = strdup(up[0]);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
279 g_strfreev(up);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
280 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
281 client->username = silc_get_username();
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
282 gaim_account_set_username(account, client->username);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
283 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
284 if (gaim_account_get_user_info(account)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
285 client->realname = strdup(gaim_account_get_user_info(account));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
286 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
287 client->realname = silc_get_real_name();
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
288 gaim_account_set_user_info(account, client->realname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
289 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
290 client->hostname = silc_net_localhost();
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
291
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
292 gaim_connection_set_display_name(gc, client->username);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
293
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
294 /* Init SILC client */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
295 if (!silc_client_init(client)) {
10909
bd6c0aa9ff6c [gaim-migrate @ 12642]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10869
diff changeset
296 gc->wants_to_die = TRUE;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
297 gaim_connection_error(gc, ("Cannot initialize SILC protocol"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
298 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
299 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
300
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
301 /* Check the ~/.silc dir and create it, and new key pair if necessary. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
302 if (!silcgaim_check_silc_dir(gc)) {
10909
bd6c0aa9ff6c [gaim-migrate @ 12642]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10869
diff changeset
303 gc->wants_to_die = TRUE;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
304 gaim_connection_error(gc, ("Cannot find/access ~/.silc directory"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
305 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
306 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
307
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
308 /* Progress */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
309 gaim_connection_update_progress(gc, _("Connecting to SILC Server"), 1, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
310
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
311 /* Load SILC key pair */
10909
bd6c0aa9ff6c [gaim-migrate @ 12642]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10869
diff changeset
312 g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir());
bd6c0aa9ff6c [gaim-migrate @ 12642]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10869
diff changeset
313 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir());
bd6c0aa9ff6c [gaim-migrate @ 12642]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10869
diff changeset
314 if (!silc_load_key_pair((char *)gaim_account_get_string(account, "public-key", pkd),
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
315 (char *)gaim_account_get_string(account, "private-key", prd),
10751
bf5e48215158 [gaim-migrate @ 12354]
Mark Doliner <mark@kingant.net>
parents: 10732
diff changeset
316 (gc->password == NULL) ? "" : gc->password, &client->pkcs,
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
317 &client->public_key, &client->private_key)) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
318 gaim_connection_error(gc, ("Could not load SILC key pair"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
319 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
320 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
321
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
322 sg = silc_calloc(1, sizeof(*sg));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
323 if (!sg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
324 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
325 memset(sg, 0, sizeof(*sg));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
326 sg->client = client;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
327 sg->gc = gc;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
328 sg->account = account;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
329 gc->proto_data = sg;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
330
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
331 /* Connect to the SILC server */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
332 if (gaim_proxy_connect(account,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
333 gaim_account_get_string(account, "server",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
334 "silc.silcnet.org"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
335 gaim_account_get_int(account, "port", 706),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
336 silcgaim_login_connected, gc)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
337 gaim_connection_error(gc, ("Unable to create connection"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
338 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
339 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
340
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
341 /* Schedule SILC using Glib's event loop */
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
342 #ifndef _WIN32
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
343 sg->scheduler = g_timeout_add(5, (GSourceFunc)silcgaim_scheduler, sg);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
344 #else
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
345 sg->scheduler = g_timeout_add(300, (GSourceFunc)silcgaim_scheduler, sg);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
346 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
347 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
348
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
349 static int
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
350 silcgaim_close_final(gpointer *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
351 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
352 SilcGaim sg = (SilcGaim)context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
353 silc_client_stop(sg->client);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
354 silc_client_free(sg->client);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
355 silc_free(sg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
356 return 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
357 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
358
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
359 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
360 silcgaim_close(GaimConnection *gc)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
361 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
362 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
363
10547
82d6760ba000 [gaim-migrate @ 11917]
Mark Doliner <mark@kingant.net>
parents: 10516
diff changeset
364 g_return_if_fail(sg != NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
365
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
366 /* Send QUIT */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
367 silc_client_command_call(sg->client, sg->conn, NULL,
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
368 "QUIT", "Download Gaim: " GAIM_WEBSITE, NULL);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
369
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
370 if (sg->conn)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
371 silc_client_close_connection(sg->client, sg->conn);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
372
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
373 g_source_remove(sg->scheduler);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
374 g_timeout_add(1, (GSourceFunc)silcgaim_close_final, sg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
375 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
376
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
377
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
378 /****************************** Protocol Actions *****************************/
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
379
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
380 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
381 silcgaim_attrs_cancel(GaimConnection *gc, GaimRequestFields *fields)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
382 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
383 /* Nothing */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
384 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
385
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
386 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
387 silcgaim_attrs_cb(GaimConnection *gc, GaimRequestFields *fields)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
388 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
389 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
390 SilcClient client = sg->client;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
391 SilcClientConnection conn = sg->conn;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
392 GaimRequestField *f;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
393 char *tmp;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
394 SilcUInt32 tmp_len, mask;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
395 SilcAttributeObjService service;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
396 SilcAttributeObjDevice dev;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
397 SilcVCardStruct vcard;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
398 const char *val;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
399
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
400 sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
401 if (!sg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
402 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
403
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
404 memset(&service, 0, sizeof(service));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
405 memset(&dev, 0, sizeof(dev));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
406 memset(&vcard, 0, sizeof(vcard));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
407
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
408 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
409 SILC_ATTRIBUTE_USER_INFO, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
410 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
411 SILC_ATTRIBUTE_SERVICE, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
412 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
413 SILC_ATTRIBUTE_STATUS_MOOD, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
414 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
415 SILC_ATTRIBUTE_STATUS_FREETEXT, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
416 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
417 SILC_ATTRIBUTE_STATUS_MESSAGE, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
418 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
419 SILC_ATTRIBUTE_PREFERRED_LANGUAGE, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
420 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
421 SILC_ATTRIBUTE_PREFERRED_CONTACT, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
422 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
423 SILC_ATTRIBUTE_TIMEZONE, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
424 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
425 SILC_ATTRIBUTE_GEOLOCATION, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
426 silc_client_attribute_del(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
427 SILC_ATTRIBUTE_DEVICE_INFO, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
428
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
429 /* Set mood */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
430 mask = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
431 f = gaim_request_fields_get_field(fields, "mood_normal");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
432 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
433 mask |= SILC_ATTRIBUTE_MOOD_NORMAL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
434 f = gaim_request_fields_get_field(fields, "mood_happy");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
435 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
436 mask |= SILC_ATTRIBUTE_MOOD_HAPPY;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
437 f = gaim_request_fields_get_field(fields, "mood_sad");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
438 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
439 mask |= SILC_ATTRIBUTE_MOOD_SAD;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
440 f = gaim_request_fields_get_field(fields, "mood_angry");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
441 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
442 mask |= SILC_ATTRIBUTE_MOOD_ANGRY;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
443 f = gaim_request_fields_get_field(fields, "mood_jealous");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
444 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
445 mask |= SILC_ATTRIBUTE_MOOD_JEALOUS;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
446 f = gaim_request_fields_get_field(fields, "mood_ashamed");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
447 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
448 mask |= SILC_ATTRIBUTE_MOOD_ASHAMED;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
449 f = gaim_request_fields_get_field(fields, "mood_invincible");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
450 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
451 mask |= SILC_ATTRIBUTE_MOOD_INVINCIBLE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
452 f = gaim_request_fields_get_field(fields, "mood_inlove");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
453 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
454 mask |= SILC_ATTRIBUTE_MOOD_INLOVE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
455 f = gaim_request_fields_get_field(fields, "mood_sleepy");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
456 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
457 mask |= SILC_ATTRIBUTE_MOOD_SLEEPY;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
458 f = gaim_request_fields_get_field(fields, "mood_bored");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
459 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
460 mask |= SILC_ATTRIBUTE_MOOD_BORED;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
461 f = gaim_request_fields_get_field(fields, "mood_excited");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
462 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
463 mask |= SILC_ATTRIBUTE_MOOD_EXCITED;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
464 f = gaim_request_fields_get_field(fields, "mood_anxious");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
465 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
466 mask |= SILC_ATTRIBUTE_MOOD_ANXIOUS;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
467 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
468 SILC_ATTRIBUTE_STATUS_MOOD,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
469 SILC_32_TO_PTR(mask),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
470 sizeof(SilcUInt32));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
471
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
472 /* Set preferred contact */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
473 mask = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
474 f = gaim_request_fields_get_field(fields, "contact_chat");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
475 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
476 mask |= SILC_ATTRIBUTE_CONTACT_CHAT;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
477 f = gaim_request_fields_get_field(fields, "contact_email");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
478 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
479 mask |= SILC_ATTRIBUTE_CONTACT_EMAIL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
480 f = gaim_request_fields_get_field(fields, "contact_call");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
481 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
482 mask |= SILC_ATTRIBUTE_CONTACT_CALL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
483 f = gaim_request_fields_get_field(fields, "contact_sms");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
484 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
485 mask |= SILC_ATTRIBUTE_CONTACT_SMS;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
486 f = gaim_request_fields_get_field(fields, "contact_mms");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
487 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
488 mask |= SILC_ATTRIBUTE_CONTACT_MMS;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
489 f = gaim_request_fields_get_field(fields, "contact_video");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
490 if (f && gaim_request_field_bool_get_value(f))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
491 mask |= SILC_ATTRIBUTE_CONTACT_VIDEO;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
492 if (mask)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
493 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
494 SILC_ATTRIBUTE_PREFERRED_CONTACT,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
495 SILC_32_TO_PTR(mask),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
496 sizeof(SilcUInt32));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
497
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
498 /* Set status text */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
499 val = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
500 f = gaim_request_fields_get_field(fields, "status_text");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
501 if (f)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
502 val = gaim_request_field_string_get_value(f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
503 if (val && *val)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
504 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
505 SILC_ATTRIBUTE_STATUS_FREETEXT,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
506 (void *)val, strlen(val));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
507
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
508 /* Set vcard */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
509 val = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
510 f = gaim_request_fields_get_field(fields, "vcard");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
511 if (f)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
512 val = gaim_request_field_string_get_value(f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
513 if (val && *val) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
514 gaim_prefs_set_string("/plugins/prpl/silc/vcard", val);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
515 tmp = silc_file_readfile(val, &tmp_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
516 if (tmp) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
517 tmp[tmp_len] = 0;
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11257
diff changeset
518 if (silc_vcard_decode((unsigned char *)tmp, tmp_len, &vcard))
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
519 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
520 SILC_ATTRIBUTE_USER_INFO,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
521 (void *)&vcard,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
522 sizeof(vcard));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
523 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
524 silc_vcard_free(&vcard);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
525 silc_free(tmp);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
526 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
527
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
528 #ifdef HAVE_SYS_UTSNAME_H
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
529 /* Set device info */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
530 f = gaim_request_fields_get_field(fields, "device");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
531 if (f && gaim_request_field_bool_get_value(f)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
532 struct utsname u;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
533 if (!uname(&u)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
534 dev.type = SILC_ATTRIBUTE_DEVICE_COMPUTER;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
535 dev.version = u.release;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
536 dev.model = u.sysname;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
537 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
538 SILC_ATTRIBUTE_DEVICE_INFO,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
539 (void *)&dev, sizeof(dev));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
540 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
541 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
542 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
543
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
544 /* Set timezone */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
545 val = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
546 f = gaim_request_fields_get_field(fields, "timezone");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
547 if (f)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
548 val = gaim_request_field_string_get_value(f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
549 if (val && *val)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
550 silc_client_attribute_add(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
551 SILC_ATTRIBUTE_TIMEZONE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
552 (void *)val, strlen(val));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
553 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
554
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
555 static void
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
556 silcgaim_attrs(GaimPluginAction *action)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
557 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
558 GaimConnection *gc = (GaimConnection *) action->context;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
559 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
560 SilcClient client = sg->client;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
561 SilcClientConnection conn = sg->conn;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
562 GaimRequestFields *fields;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
563 GaimRequestFieldGroup *g;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
564 GaimRequestField *f;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
565 SilcHashTable attrs;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
566 SilcAttributePayload attr;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
567 gboolean mnormal = TRUE, mhappy = FALSE, msad = FALSE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
568 mangry = FALSE, mjealous = FALSE, mashamed = FALSE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
569 minvincible = FALSE, minlove = FALSE, msleepy = FALSE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
570 mbored = FALSE, mexcited = FALSE, manxious = FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
571 gboolean cemail = FALSE, ccall = FALSE, csms = FALSE,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
572 cmms = FALSE, cchat = TRUE, cvideo = FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
573 gboolean device = TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
574 char status[1024];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
575
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
576 sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
577 if (!sg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
578 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
579
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
580 memset(status, 0, sizeof(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
581
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
582 attrs = silc_client_attributes_get(client, conn);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
583 if (attrs) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
584 if (silc_hash_table_find(attrs,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
585 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_MOOD),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
586 NULL, (void *)&attr)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
587 SilcUInt32 mood = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
588 silc_attribute_get_object(attr, &mood, sizeof(mood));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
589 mnormal = !mood;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
590 mhappy = (mood & SILC_ATTRIBUTE_MOOD_HAPPY);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
591 msad = (mood & SILC_ATTRIBUTE_MOOD_SAD);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
592 mangry = (mood & SILC_ATTRIBUTE_MOOD_ANGRY);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
593 mjealous = (mood & SILC_ATTRIBUTE_MOOD_JEALOUS);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
594 mashamed = (mood & SILC_ATTRIBUTE_MOOD_ASHAMED);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
595 minvincible = (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
596 minlove = (mood & SILC_ATTRIBUTE_MOOD_INLOVE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
597 msleepy = (mood & SILC_ATTRIBUTE_MOOD_SLEEPY);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
598 mbored = (mood & SILC_ATTRIBUTE_MOOD_BORED);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
599 mexcited = (mood & SILC_ATTRIBUTE_MOOD_EXCITED);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
600 manxious = (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
601 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
602
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
603 if (silc_hash_table_find(attrs,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
604 SILC_32_TO_PTR(SILC_ATTRIBUTE_PREFERRED_CONTACT),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
605 NULL, (void *)&attr)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
606 SilcUInt32 contact = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
607 silc_attribute_get_object(attr, &contact, sizeof(contact));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
608 cemail = (contact & SILC_ATTRIBUTE_CONTACT_EMAIL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
609 ccall = (contact & SILC_ATTRIBUTE_CONTACT_CALL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
610 csms = (contact & SILC_ATTRIBUTE_CONTACT_SMS);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
611 cmms = (contact & SILC_ATTRIBUTE_CONTACT_MMS);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
612 cchat = (contact & SILC_ATTRIBUTE_CONTACT_CHAT);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
613 cvideo = (contact & SILC_ATTRIBUTE_CONTACT_VIDEO);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
614 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
615
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
616 if (silc_hash_table_find(attrs,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
617 SILC_32_TO_PTR(SILC_ATTRIBUTE_STATUS_FREETEXT),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
618 NULL, (void *)&attr))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
619 silc_attribute_get_object(attr, &status, sizeof(status));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
620
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
621 if (!silc_hash_table_find(attrs,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
622 SILC_32_TO_PTR(SILC_ATTRIBUTE_DEVICE_INFO),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
623 NULL, (void *)&attr))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
624 device = FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
625 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
626
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
627 fields = gaim_request_fields_new();
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
628
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
629 g = gaim_request_field_group_new(NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
630 f = gaim_request_field_label_new("l3", _("Your Current Mood"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
631 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
632 f = gaim_request_field_bool_new("mood_normal", _("Normal"), mnormal);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
633 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
634 f = gaim_request_field_bool_new("mood_happy", _("Happy"), mhappy);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
635 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
636 f = gaim_request_field_bool_new("mood_sad", _("Sad"), msad);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
637 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
638 f = gaim_request_field_bool_new("mood_angry", _("Angry"), mangry);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
639 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
640 f = gaim_request_field_bool_new("mood_jealous", _("Jealous"), mjealous);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
641 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
642 f = gaim_request_field_bool_new("mood_ashamed", _("Ashamed"), mashamed);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
643 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
644 f = gaim_request_field_bool_new("mood_invincible", _("Invincible"), minvincible);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
645 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
646 f = gaim_request_field_bool_new("mood_inlove", _("In Love"), minlove);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
647 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
648 f = gaim_request_field_bool_new("mood_sleepy", _("Sleepy"), msleepy);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
649 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
650 f = gaim_request_field_bool_new("mood_bored", _("Bored"), mbored);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
651 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
652 f = gaim_request_field_bool_new("mood_excited", _("Excited"), mexcited);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
653 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
654 f = gaim_request_field_bool_new("mood_anxious", _("Anxious"), manxious);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
655 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
656
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
657 f = gaim_request_field_label_new("l4", _("\nYour Preferred Contact Methods"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
658 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
659 f = gaim_request_field_bool_new("contact_chat", _("Chat"), cchat);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
660 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
661 f = gaim_request_field_bool_new("contact_email", _("Email"), cemail);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
662 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
663 f = gaim_request_field_bool_new("contact_call", _("Phone"), ccall);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
664 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
665 f = gaim_request_field_bool_new("contact_sms", _("SMS"), csms);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
666 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
667 f = gaim_request_field_bool_new("contact_mms", _("MMS"), cmms);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
668 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
669 f = gaim_request_field_bool_new("contact_video", _("Video Conferencing"), cvideo);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
670 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
671 gaim_request_fields_add_group(fields, g);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
672
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
673 g = gaim_request_field_group_new(NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
674 f = gaim_request_field_string_new("status_text", _("Your Current Status"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
675 status[0] ? status : NULL, TRUE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
676 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
677 gaim_request_fields_add_group(fields, g);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
678
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
679 g = gaim_request_field_group_new(NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
680 #if 0
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
681 f = gaim_request_field_label_new("l2", _("Online Services"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
682 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
683 f = gaim_request_field_bool_new("services",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
684 _("Let others see what services you are using"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
685 TRUE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
686 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
687 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
688 #ifdef HAVE_SYS_UTSNAME_H
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
689 f = gaim_request_field_bool_new("device",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
690 _("Let others see what computer you are using"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
691 device);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
692 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
693 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
694 gaim_request_fields_add_group(fields, g);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
695
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
696 g = gaim_request_field_group_new(NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
697 f = gaim_request_field_string_new("vcard", _("Your VCard File"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
698 gaim_prefs_get_string("/plugins/prpl/silc/vcard"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
699 FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
700 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
701 #ifdef _WIN32
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
702 f = gaim_request_field_string_new("timezone", _("Timezone"), _tzname[0], FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
703 #else
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
704 f = gaim_request_field_string_new("timezone", _("Timezone"), tzname[0], FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
705 #endif
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
706 gaim_request_field_group_add_field(g, f);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
707 gaim_request_fields_add_group(fields, g);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
708
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
709
11201
07dc8c6a359f [gaim-migrate @ 13329]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
710 gaim_request_fields(gc, _("User Online Status Attributes"),
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
711 _("User Online Status Attributes"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
712 _("You can let other users see your online status information "
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
713 "and your personal information. Please fill the information "
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
714 "you would like other users to see about yourself."),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
715 fields,
8906
0d3a68e36132 [gaim-migrate @ 9676]
Nathan Walp <nwalp@pidgin.im>
parents: 8891
diff changeset
716 _("OK"), G_CALLBACK(silcgaim_attrs_cb),
0d3a68e36132 [gaim-migrate @ 9676]
Nathan Walp <nwalp@pidgin.im>
parents: 8891
diff changeset
717 _("Cancel"), G_CALLBACK(silcgaim_attrs_cancel), gc);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
718 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
719
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
720 static void
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
721 silcgaim_detach(GaimPluginAction *action)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
722 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
723 GaimConnection *gc = (GaimConnection *) action->context;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
724 SilcGaim sg;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
725
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
726 if (!gc)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
727 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
728 sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
729 if (!sg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
730 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
731
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
732 /* Call DETACH */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
733 silc_client_command_call(sg->client, sg->conn, "DETACH");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
734 sg->detaching = TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
735 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
736
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
737 static void
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
738 silcgaim_view_motd(GaimPluginAction *action)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
739 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
740 GaimConnection *gc = (GaimConnection *) action->context;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
741 SilcGaim sg;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
742 char *tmp;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
743
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
744 if (!gc)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
745 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
746 sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
747 if (!sg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
748 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
749
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
750 if (!sg->motd) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
751 gaim_notify_error(
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
752 gc, _("Message of the Day"), _("No Message of the Day available"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
753 _("There is no Message of the Day associated with this connection"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
754 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
755 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
756
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10547
diff changeset
757 tmp = g_markup_escape_text(sg->motd, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
758 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
759 tmp, NULL, NULL);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
760 g_free(tmp);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
761 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
762
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
763 static void
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
764 silcgaim_change_pass(GaimPluginAction *action)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
765 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
766 GaimConnection *gc = (GaimConnection *) action->context;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
767 gaim_account_request_change_password(gaim_connection_get_account(gc));
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
768 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
769
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
770 static void
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
771 silcgaim_change_passwd(GaimConnection *gc, const char *old, const char *new)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
772 {
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
773 char prd[256];
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
774 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.pub", silcgaim_silcdir());
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
775 silc_change_private_key_passphrase(gaim_account_get_string(gc->account,
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
776 "private-key",
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
777 prd), old, new);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
778 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
779
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
780 static void
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
781 silcgaim_show_set_info(GaimPluginAction *action)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
782 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
783 GaimConnection *gc = (GaimConnection *) action->context;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
784 gaim_account_request_change_user_info(gaim_connection_get_account(gc));
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
785 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
786
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
787 static void
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
788 silcgaim_set_info(GaimConnection *gc, const char *text)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
789 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
790 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
791
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
792 static GList *
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
793 silcgaim_actions(GaimPlugin *plugin, gpointer context)
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
794 {
9024
85caba2f820a [gaim-migrate @ 9800]
Tim Ringenbach <marv@pidgin.im>
parents: 9015
diff changeset
795 GaimConnection *gc = context;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
796 GList *list = NULL;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
797 GaimPluginAction *act;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
798
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
799 if (!gaim_account_get_bool(gc->account, "reject-attrs", FALSE)) {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
800 act = gaim_plugin_action_new(_("Online Status"),
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
801 silcgaim_attrs);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
802 list = g_list_append(list, act);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
803 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
804
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
805 act = gaim_plugin_action_new(_("Detach From Server"),
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
806 silcgaim_detach);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
807 list = g_list_append(list, act);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
808
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
809 act = gaim_plugin_action_new(_("View Message of the Day"),
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
810 silcgaim_view_motd);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
811 list = g_list_append(list, act);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
812
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
813 act = gaim_plugin_action_new(_("Change Password..."),
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
814 silcgaim_change_pass);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
815 list = g_list_append(list, act);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
816
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
817 act = gaim_plugin_action_new(_("Set User Info..."),
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
818 silcgaim_show_set_info);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
819 list = g_list_append(list, act);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
820
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
821 return list;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
822 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
823
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
824
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
825 /******************************* IM Routines *********************************/
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
826
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
827 typedef struct {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
828 char *nick;
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11257
diff changeset
829 char *message;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
830 SilcUInt32 message_len;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
831 SilcMessageFlags flags;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
832 } *SilcGaimIM;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
833
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
834 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
835 silcgaim_send_im_resolved(SilcClient client,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
836 SilcClientConnection conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
837 SilcClientEntry *clients,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
838 SilcUInt32 clients_count,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
839 void *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
840 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
841 GaimConnection *gc = client->application;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
842 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
843 SilcGaimIM im = context;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
844 GaimConversation *convo;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
845 char tmp[256], *nickname = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
846 SilcClientEntry client_entry;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
847
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11318
diff changeset
848 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, im->nick,
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10225
diff changeset
849 sg->account);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
850 if (!convo)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
851 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
852
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
853 if (!clients)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
854 goto err;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
855
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
856 if (clients_count > 1) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
857 silc_parse_userfqdn(im->nick, &nickname, NULL);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
858
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
859 /* Find the correct one. The im->nick might be a formatted nick
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
860 so this will find the correct one. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
861 clients = silc_client_get_clients_local(client, conn,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
862 nickname, im->nick,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
863 &clients_count);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
864 if (!clients)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
865 goto err;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
866 client_entry = clients[0];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
867 silc_free(clients);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
868 } else {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
869 client_entry = clients[0];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
870 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
871
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
872 /* Send the message */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
873 silc_client_send_private_message(client, conn, client_entry, im->flags,
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11257
diff changeset
874 (unsigned char *)im->message, im->message_len, TRUE);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
875 gaim_conv_im_write(GAIM_CONV_IM(convo), conn->local_entry->nickname,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
876 im->message, 0, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
877
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
878 goto out;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
879
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
880 err:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
881 g_snprintf(tmp, sizeof(tmp),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
882 _("User <I>%s</I> is not present in the network"), im->nick);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
883 gaim_conversation_write(convo, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
884
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
885 out:
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
886 g_free(im->nick);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
887 g_free(im->message);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
888 silc_free(im);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
889 silc_free(nickname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
890 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
891
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
892 static int
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
893 silcgaim_send_im(GaimConnection *gc, const char *who, const char *msg,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
894 GaimConvImFlags flags)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
895 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
896 SilcGaim sg = gc->proto_data;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
897 SilcClient client = sg->client;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
898 SilcClientConnection conn = sg->conn;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
899 SilcClientEntry *clients;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
900 SilcUInt32 clients_count, mflags;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
901 char *nickname;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
902 int ret;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
903 gboolean sign = gaim_prefs_get_bool("/plugins/prpl/silc/sign_im");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
904
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
905 if (!who || !msg)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
906 return 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
907
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
908 mflags = SILC_MESSAGE_FLAG_UTF8;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
909
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
910 if (!g_ascii_strncasecmp(msg, "/me ", 4)) {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
911 msg += 4;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
912 if (!msg)
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
913 return 0;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
914 mflags |= SILC_MESSAGE_FLAG_ACTION;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
915 } else if (strlen(msg) > 1 && msg[0] == '/') {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
916 if (!silc_client_command_call(client, conn, msg + 1))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
917 gaim_notify_error(gc, ("Call Command"), _("Cannot call command"),
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
918 _("Unknown command"));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
919 return 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
920 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
921
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
922
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
923 if (!silc_parse_userfqdn(who, &nickname, NULL))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
924 return 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
925
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
926 if (sign)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
927 mflags |= SILC_MESSAGE_FLAG_SIGNED;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
928
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
929 /* Find client entry */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
930 clients = silc_client_get_clients_local(client, conn, nickname, who,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
931 &clients_count);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
932 if (!clients) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
933 /* Resolve unknown user */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
934 SilcGaimIM im = silc_calloc(1, sizeof(*im));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
935 if (!im)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
936 return 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
937 im->nick = g_strdup(who);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
938 im->message = g_strdup(msg);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
939 im->message_len = strlen(im->message);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
940 im->flags = mflags;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
941 silc_client_get_clients(client, conn, nickname, NULL,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
942 silcgaim_send_im_resolved, im);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
943 silc_free(nickname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
944 return 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
945 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
946
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
947 /* Send private message directly */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
948 ret = silc_client_send_private_message(client, conn, clients[0],
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11257
diff changeset
949 mflags, (unsigned char *)msg,
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
950 strlen(msg), TRUE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
951
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
952 silc_free(nickname);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
953 silc_free(clients);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
954 return ret;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
955 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
956
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
957
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
958 GList *silcgaim_blist_node_menu(GaimBlistNode *node) {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
959 /* split this single menu building function back into the two
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
960 original: one for buddies and one for chats */
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
961
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
962 if(GAIM_BLIST_NODE_IS_CHAT(node)) {
9038
095731b5e4f6 [gaim-migrate @ 9814]
Tim Ringenbach <marv@pidgin.im>
parents: 9030
diff changeset
963 return silcgaim_chat_menu((GaimChat *) node);
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
964 } else if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
965 return silcgaim_buddy_menu((GaimBuddy *) node);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
966 } else {
9038
095731b5e4f6 [gaim-migrate @ 9814]
Tim Ringenbach <marv@pidgin.im>
parents: 9030
diff changeset
967 g_return_val_if_reached(NULL);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
968 }
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
969 }
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
970
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
971 /********************************* Commands **********************************/
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
972
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
973 static GaimCmdRet silcgaim_cmd_chat_part(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
974 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
975 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
976 GaimConnection *gc;
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
977 GaimConversation *convo;
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
978 int id = 0;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
979
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
980 gc = gaim_conversation_get_gc(conv);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
981
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
982 if (gc == NULL)
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
983 return GAIM_CMD_RET_FAILED;
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
984
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
985 if(args && args[0]) {
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11318
diff changeset
986 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0],
10246
a66cf83552dc [gaim-migrate @ 11386]
Mark Doliner <mark@kingant.net>
parents: 10225
diff changeset
987 gc->account);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
988 } else
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
989 convo = conv;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
990
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
991 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo));
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
992
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
993 if (id == 0)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
994 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
995
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
996 silcgaim_chat_leave(gc, id);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
997
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
998 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
999
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1000 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1001
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1002 static GaimCmdRet silcgaim_cmd_chat_topic(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1003 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1004 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1005 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1006 int id = 0;
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9754
diff changeset
1007 char *buf, *tmp, *tmp2;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1008 const char *topic;
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1009
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1010 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1011 id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv));
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1012
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1013 if (gc == NULL || id == 0)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1014 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1015
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1016 if (!args || !args[0]) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1017 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1018 if (topic) {
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10547
diff changeset
1019 tmp = g_markup_escape_text(topic, -1);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9754
diff changeset
1020 tmp2 = gaim_markup_linkify(tmp);
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9754
diff changeset
1021 buf = g_strdup_printf(_("current topic is: %s"), tmp2);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1022 g_free(tmp);
9762
3f97624e7753 [gaim-migrate @ 10630]
Tim Ringenbach <marv@pidgin.im>
parents: 9754
diff changeset
1023 g_free(tmp2);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1024 } else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1025 buf = g_strdup(_("No topic is set"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1026 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), gc->account->username, buf,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1027 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1028 g_free(buf);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1029
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1030 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1031
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1032 if (args && args[0] && (strlen(args[0]) > 255)) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1033 *error = g_strdup(_("Topic too long"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1034 return GAIM_CMD_RET_FAILED;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1035 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1036
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1037 silcgaim_chat_set_topic(gc, id, args ? args[0] : NULL);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1038
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1039 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1040 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1041
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1042 static GaimCmdRet silcgaim_cmd_chat_join(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1043 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1044 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1045 GHashTable *comp;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1046
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1047 if(!args || !args[0])
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1048 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1049
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1050 comp = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1051
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1052 g_hash_table_replace(comp, "channel", args[0]);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1053 if(args[1])
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1054 g_hash_table_replace(comp, "passphrase", args[1]);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1055
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1056 silcgaim_chat_join(gaim_conversation_get_gc(conv), comp);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1057
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1058 g_hash_table_destroy(comp);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1059 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1060 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1061
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1062 static GaimCmdRet silcgaim_cmd_chat_list(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1063 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1064 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1065 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1066 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1067 gaim_roomlist_show_with_account(gaim_connection_get_account(gc));
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1068 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1069 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1070
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1071 static GaimCmdRet silcgaim_cmd_whois(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1072 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1073 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1074 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1075
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1076 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1077
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1078 if (gc == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1079 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1080
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1081 silcgaim_get_info(gc, args[0]);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1082
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1083 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1084 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1085
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1086 static GaimCmdRet silcgaim_cmd_msg(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1087 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1088 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1089 int ret;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1090 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1091
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1092 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1093
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1094 if (gc == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1095 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1096
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1097 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1098
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1099 if (ret)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1100 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1101 else
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1102 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1103 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1104
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1105 static GaimCmdRet silcgaim_cmd_query(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1106 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1107 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1108 int ret = 1;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1109 GaimConversation *convo;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1110 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1111 GaimAccount *account;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1112
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1113 if (!args || !args[0]) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1114 *error = g_strdup(_("You must specify a nick"));
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1115 return GAIM_CMD_RET_FAILED;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1116 }
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1117
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1118 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1119
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1120 if (gc == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1121 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1122
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1123 account = gaim_connection_get_account(gc);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1124
11338
17142948653e [gaim-migrate @ 13551]
Mark Doliner <mark@kingant.net>
parents: 11318
diff changeset
1125 convo = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, args[0]);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1126
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1127 if (args[1]) {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1128 ret = silcgaim_send_im(gc, args[0], args[1], GAIM_MESSAGE_SEND);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1129 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc),
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1130 args[1], GAIM_MESSAGE_SEND, time(NULL));
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1131 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1132
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1133 if (ret)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1134 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1135 else
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1136 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1137 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1138
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1139 static GaimCmdRet silcgaim_cmd_motd(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1140 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1141 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1142 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1143 SilcGaim sg;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1144 char *tmp;
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1145
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1146 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1147
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1148 if (gc == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1149 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1150
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1151 sg = gc->proto_data;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1152
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1153 if (sg == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1154 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1155
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1156 if (!sg->motd) {
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1157 *error = g_strdup(_("There is no Message of the Day associated with this connection"));
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1158 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1159 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1160
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10547
diff changeset
1161 tmp = g_markup_escape_text(sg->motd, -1);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1162 gaim_notify_formatted(gc, NULL, _("Message of the Day"), NULL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1163 tmp, NULL, NULL);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1164 g_free(tmp);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1165
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1166 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1167 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1168
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1169 static GaimCmdRet silcgaim_cmd_detach(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1170 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1171 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1172 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1173 SilcGaim sg;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1174
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1175 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1176
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1177 if (gc == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1178 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1179
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1180 sg = gc->proto_data;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1181
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1182 if (sg == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1183 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1184
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1185 silc_client_command_call(sg->client, sg->conn, "DETACH");
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1186 sg->detaching = TRUE;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1187
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1188 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1189 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1190
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1191 static GaimCmdRet silcgaim_cmd_cmode(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1192 const char *cmd, char **args, char **error, void *data)
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1193 {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1194 GaimConnection *gc;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1195 SilcGaim sg;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1196 SilcChannelEntry channel;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1197 char *silccmd, *silcargs, *msg, tmp[256];
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1198 const char *chname;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1199
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1200 gc = gaim_conversation_get_gc(conv);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1201
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1202 if (gc == NULL || !args || gc->proto_data == NULL)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1203 return GAIM_CMD_RET_FAILED;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1204
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1205 sg = gc->proto_data;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1206
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1207 if (args[0])
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1208 chname = args[0];
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1209 else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1210 chname = gaim_conversation_get_name(conv);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1211
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1212 if (!args[1]) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1213 channel = silc_client_get_channel(sg->client, sg->conn,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1214 (char *)chname);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1215 if (!channel) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1216 *error = g_strdup_printf(_("channel %s not found"), chname);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1217 return GAIM_CMD_RET_FAILED;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1218 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1219 if (channel->mode) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1220 silcgaim_get_chmode_string(channel->mode, tmp, sizeof(tmp));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1221 msg = g_strdup_printf(_("channel modes for %s: %s"), chname, tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1222 } else {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1223 msg = g_strdup_printf(_("no channel modes are set on %s"), chname);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1224 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1225 gaim_conv_chat_write(GAIM_CONV_CHAT(conv), "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1226 msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1227 g_free(msg);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1228 return GAIM_CMD_RET_OK;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1229 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1230
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1231 silcargs = g_strjoinv(" ", args);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1232 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1233 g_free(silcargs);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1234 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1235 g_free(silccmd);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1236 *error = g_strdup_printf(_("Failed to set cmodes for %s"), args[0]);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1237 return GAIM_CMD_RET_FAILED;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1238 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1239 g_free(silccmd);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1240
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1241 return GAIM_CMD_RET_OK;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1242 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1243
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1244 static GaimCmdRet silcgaim_cmd_generic(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1245 const char *cmd, char **args, char **error, void *data)
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1246 {
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1247 GaimConnection *gc;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1248 SilcGaim sg;
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1249 char *silccmd, *silcargs;
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1250
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1251 gc = gaim_conversation_get_gc(conv);
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1252
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1253 if (gc == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1254 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1255
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1256 sg = gc->proto_data;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1257
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1258 if (sg == NULL)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1259 return GAIM_CMD_RET_FAILED;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1260
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1261 silcargs = g_strjoinv(" ", args);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1262 silccmd = g_strconcat(cmd, " ", args ? silcargs : NULL, NULL);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1263 g_free(silcargs);
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1264 if (!silc_client_command_call(sg->client, sg->conn, silccmd)) {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1265 g_free(silccmd);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1266 *error = g_strdup_printf(_("Unknown command: %s, (may be a Gaim bug)"), cmd);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1267 return GAIM_CMD_RET_FAILED;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1268 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1269 g_free(silccmd);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1270
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1271 return GAIM_CMD_RET_OK;
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1272 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1273
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1274 static GaimCmdRet silcgaim_cmd_quit(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1275 const char *cmd, char **args, char **error, void *data)
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1276 {
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1277 GaimConnection *gc;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1278 SilcGaim sg;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1279
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1280 gc = gaim_conversation_get_gc(conv);
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1281
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1282 if (gc == NULL)
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1283 return GAIM_CMD_RET_FAILED;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1284
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1285 sg = gc->proto_data;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1286
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1287 if (sg == NULL)
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1288 return GAIM_CMD_RET_FAILED;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1289
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1290 silc_client_command_call(sg->client, sg->conn, NULL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1291 "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE, NULL);
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1292
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1293 return GAIM_CMD_RET_OK;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1294 }
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1295
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1296 static GaimCmdRet silcgaim_cmd_call(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1297 const char *cmd, char **args, char **error, void *data)
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1298 {
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1299 GaimConnection *gc;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1300 SilcGaim sg;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1301
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1302 gc = gaim_conversation_get_gc(conv);
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1303
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1304 if (gc == NULL)
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1305 return GAIM_CMD_RET_FAILED;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1306
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1307 sg = gc->proto_data;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1308
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1309 if (sg == NULL)
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1310 return GAIM_CMD_RET_FAILED;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1311
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1312 if (!silc_client_command_call(sg->client, sg->conn, args[0])) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1313 *error = g_strdup_printf(_("Unknown command: %s"), args[0]);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1314 return GAIM_CMD_RET_FAILED;
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1315 }
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1316
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1317 return GAIM_CMD_RET_OK;
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1318 }
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1319
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9024
diff changeset
1320
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1321 /************************** Plugin Initialization ****************************/
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1322
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1323 static void
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1324 silcgaim_register_commands(void)
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1325 {
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1326 gaim_cmd_register("part", "w", GAIM_CMD_P_PRPL,
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1327 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1328 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1329 "prpl-silc", silcgaim_cmd_chat_part, _("part [channel]: Leave the chat"), NULL);
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1330 gaim_cmd_register("leave", "w", GAIM_CMD_P_PRPL,
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1331 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1332 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1333 "prpl-silc", silcgaim_cmd_chat_part, _("leave [channel]: Leave the chat"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1334 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1335 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1336 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc",
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1337 silcgaim_cmd_chat_topic, _("topic [&lt;new topic&gt;]: View or change the topic"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1338 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1339 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT |
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1340 GAIM_CMD_FLAG_PRPL_ONLY | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1341 "prpl-silc", silcgaim_cmd_chat_join,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1342 _("join &lt;channel&gt; [&lt;password&gt;]: Join a chat on this network"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1343 gaim_cmd_register("list", "", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1344 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1345 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc",
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1346 silcgaim_cmd_chat_list, _("list: List channels on this network"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1347 gaim_cmd_register("whois", "w", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1348 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1349 "prpl-silc",
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1350 silcgaim_cmd_whois, _("whois &lt;nick&gt;: View nick's information"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1351 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1352 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1353 "prpl-silc", silcgaim_cmd_msg,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1354 _("msg &lt;nick&gt; &lt;message&gt;: Send a private message to a user"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1355 gaim_cmd_register("query", "ws", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1356 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1357 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_query,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1358 _("query &lt;nick&gt; [&lt;message&gt;]: Send a private message to a user"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1359 gaim_cmd_register("motd", "", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1360 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1361 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_motd,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1362 _("motd: View the server's Message Of The Day"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1363 gaim_cmd_register("detach", "", GAIM_CMD_P_PRPL,
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1364 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1365 "prpl-silc", silcgaim_cmd_detach,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1366 _("detach: Detach this session"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1367 gaim_cmd_register("quit", "s", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1368 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1369 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_quit,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1370 _("quit [message]: Disconnect from the server, with an optional message"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1371 gaim_cmd_register("call", "s", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1372 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1373 "prpl-silc", silcgaim_cmd_call,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1374 _("call &lt;command&gt;: Call any silc client command"), NULL);
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1375 /* These below just get passed through for the silc client library to deal
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1376 * with */
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1377 gaim_cmd_register("kill", "ws", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1378 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1379 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1380 _("kill &lt;nick&gt; [-pubkey|&lt;reason&gt;]: Kill nick"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1381 gaim_cmd_register("nick", "w", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1382 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1383 "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1384 _("nick &lt;newnick&gt;: Change your nickname"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1385 gaim_cmd_register("whowas", "ww", GAIM_CMD_P_PRPL,
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1386 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1387 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1388 _("whowas &lt;nick&gt;: View nick's information"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1389 gaim_cmd_register("cmode", "wws", GAIM_CMD_P_PRPL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1390 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1391 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_cmode,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1392 _("cmode &lt;channel&gt; [+|-&lt;modes&gt;] [arguments]: Change or display channel modes"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1393 gaim_cmd_register("cumode", "wws", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1394 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1395 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1396 _("cumode &lt;channel&gt; +|-&lt;modes&gt; &lt;nick&gt;: Change nick's modes on channel"), NULL);
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1397 gaim_cmd_register("umode", "w", GAIM_CMD_P_PRPL,
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1398 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1399 "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1400 _("umode &lt;usermodes&gt;: Set your modes in the network"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1401 gaim_cmd_register("oper", "s", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1402 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1403 "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1404 _("oper &lt;nick&gt; [-pubkey]: Get server operator privileges"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1405 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1406 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1407 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1408 _("invite &lt;channel&gt; [-|+]&lt;nick&gt;: invite nick or add/remove from channel invite list"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1409 gaim_cmd_register("kick", "wws", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1410 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1411 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1412 _("kick &lt;channel&gt; &lt;nick&gt; [comment]: Kick client from channel"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1413 gaim_cmd_register("info", "w", GAIM_CMD_P_PRPL,
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1414 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1415 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1416 _("info [server]: View server administrative details"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1417 gaim_cmd_register("ban", "ww", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1418 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1419 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1420 _("ban [&lt;channel&gt; +|-&lt;nick&gt;]: Ban client from channel"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1421 gaim_cmd_register("getkey", "w", GAIM_CMD_P_PRPL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1422 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1423 "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1424 _("getkey &lt;nick|server&gt;: Retrieve client's or server's public key"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1425 gaim_cmd_register("stats", "", GAIM_CMD_P_PRPL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1426 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1427 "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1428 _("stats: View server and network statistics"), NULL);
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1429 gaim_cmd_register("ping", "", GAIM_CMD_P_PRPL,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1430 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1431 "prpl-silc", silcgaim_cmd_generic,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9552
diff changeset
1432 _("ping: Send PING to the connected server"), NULL);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1433 #if 0 /* Gaim doesn't handle these yet */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1434 gaim_cmd_register("users", "w", GAIM_CMD_P_PRPL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1435 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1436 "prpl-silc", silcgaim_cmd_users,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1437 _("users &lt;channel&gt;: List users in channel"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1438 gaim_cmd_register("names", "ww", GAIM_CMD_P_PRPL,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1439 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1440 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-silc", silcgaim_cmd_names,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1441 _("names [-count|-ops|-halfops|-voices|-normal] &lt;channel(s)&gt;: List specific users in channel(s)"));
9359
43741d8f76f7 [gaim-migrate @ 10167]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
1442 #endif
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1443 }
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1444
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1445 static GaimPluginPrefFrame *
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1446 silcgaim_pref_frame(GaimPlugin *plugin)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1447 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1448 GaimPluginPrefFrame *frame;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1449 GaimPluginPref *ppref;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1450
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1451 frame = gaim_plugin_pref_frame_new();
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1452
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1453 ppref = gaim_plugin_pref_new_with_label(_("Instant Messages"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1454 gaim_plugin_pref_frame_add(frame, ppref);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1455
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1456 ppref = gaim_plugin_pref_new_with_name_and_label(
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1457 "/plugins/prpl/silc/sign_im",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1458 _("Digitally sign all IM messages"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1459 gaim_plugin_pref_frame_add(frame, ppref);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1460
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1461 ppref = gaim_plugin_pref_new_with_name_and_label(
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1462 "/plugins/prpl/silc/verify_im",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1463 _("Verify all IM message signatures"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1464 gaim_plugin_pref_frame_add(frame, ppref);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1465
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1466 ppref = gaim_plugin_pref_new_with_label(_("Channel Messages"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1467 gaim_plugin_pref_frame_add(frame, ppref);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1468
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1469 ppref = gaim_plugin_pref_new_with_name_and_label(
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1470 "/plugins/prpl/silc/sign_chat",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1471 _("Digitally sign all channel messages"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1472 gaim_plugin_pref_frame_add(frame, ppref);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1473
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1474 ppref = gaim_plugin_pref_new_with_name_and_label(
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1475 "/plugins/prpl/silc/verify_chat",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1476 _("Verify all channel message signatures"));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1477 gaim_plugin_pref_frame_add(frame, ppref);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1478
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1479 return frame;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1480 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1481
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1482 static GaimPluginUiInfo prefs_info =
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1483 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1484 silcgaim_pref_frame,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1485 };
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1486
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1487 static GaimPluginProtocolInfo prpl_info =
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1488 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1489 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1490 OPT_PROTO_PASSWORD_OPTIONAL,
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1491 NULL, /* user_splits */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1492 NULL, /* protocol_options */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1493 NO_BUDDY_ICONS, /* icon_spec */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1494 silcgaim_list_icon, /* list_icon */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1495 silcgaim_list_emblems, /* list_emblems */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1496 silcgaim_status_text, /* status_text */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1497 silcgaim_tooltip_text, /* tooltip_text */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1498 silcgaim_away_states, /* away_states */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1499 silcgaim_blist_node_menu, /* blist_node_menu */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1500 silcgaim_chat_info, /* chat_info */
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9732
diff changeset
1501 silcgaim_chat_info_defaults,/* chat_info_defaults */
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1502 silcgaim_login, /* login */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1503 silcgaim_close, /* close */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1504 silcgaim_send_im, /* send_im */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1505 silcgaim_set_info, /* set_info */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1506 NULL, /* send_typing */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1507 silcgaim_get_info, /* get_info */
9968
67468d443cd1 [gaim-migrate @ 10878]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
1508 silcgaim_set_status, /* set_status */
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1509 silcgaim_idle_set, /* set_idle */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1510 silcgaim_change_passwd, /* change_passwd */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1511 silcgaim_add_buddy, /* add_buddy */
10869
3e43c132f151 [gaim-migrate @ 12556]
Mark Doliner <mark@kingant.net>
parents: 10825
diff changeset
1512 NULL, /* add_buddies */
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1513 silcgaim_remove_buddy, /* remove_buddy */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1514 NULL, /* remove_buddies */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1515 NULL, /* add_permit */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1516 NULL, /* add_deny */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1517 NULL, /* rem_permit */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1518 NULL, /* rem_deny */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1519 NULL, /* set_permit_deny */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1520 silcgaim_chat_join, /* join_chat */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1521 NULL, /* reject_chat */
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9762
diff changeset
1522 silcgaim_get_chat_name, /* get_chat_name */
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1523 silcgaim_chat_invite, /* chat_invite */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1524 silcgaim_chat_leave, /* chat_leave */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1525 NULL, /* chat_whisper */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1526 silcgaim_chat_send, /* chat_send */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1527 silcgaim_keepalive, /* keepalive */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1528 NULL, /* register_user */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1529 NULL, /* get_cb_info */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1530 NULL, /* get_cb_away */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1531 NULL, /* alias_buddy */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1532 NULL, /* group_buddy */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1533 NULL, /* rename_group */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1534 NULL, /* buddy_free */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1535 NULL, /* convo_closed */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1536 NULL, /* normalize */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1537 NULL, /* set_buddy_icon */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1538 NULL, /* remove_group */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1539 NULL, /* get_cb_real_name */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1540 silcgaim_chat_set_topic, /* set_chat_topic */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1541 NULL, /* find_blist_chat */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1542 silcgaim_roomlist_get_list, /* roomlist_get_list */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1543 silcgaim_roomlist_cancel, /* roomlist_cancel */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1544 NULL, /* roomlist_expand_category */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1545 NULL, /* can_receive_file */
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9466
diff changeset
1546 silcgaim_ftp_send_file /* send_file */
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1547 };
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1548
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1549 static GaimPluginInfo info =
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1550 {
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
1551 GAIM_PLUGIN_MAGIC,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
1552 GAIM_MAJOR_VERSION,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
1553 GAIM_MINOR_VERSION,
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1554 GAIM_PLUGIN_PROTOCOL, /**< type */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1555 NULL, /**< ui_requirement */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1556 0, /**< flags */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1557 NULL, /**< dependencies */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1558 GAIM_PRIORITY_DEFAULT, /**< priority */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1559
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1560 "prpl-silc", /**< id */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1561 "SILC", /**< name */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1562 "1.0", /**< version */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1563 /** summary */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1564 N_("SILC Protocol Plugin"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1565 /** description */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1566 N_("Secure Internet Live Conferencing (SILC) Protocol"),
8891
4f7c365c5c5a [gaim-migrate @ 9660]
Mark Doliner <mark@kingant.net>
parents: 8849
diff changeset
1567 "Pekka Riikonen", /**< author */
4f7c365c5c5a [gaim-migrate @ 9660]
Mark Doliner <mark@kingant.net>
parents: 8849
diff changeset
1568 "http://silcnet.org/", /**< homepage */
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1569
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1570 NULL, /**< load */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1571 NULL, /**< unload */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1572 NULL, /**< destroy */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1573
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1574 NULL, /**< ui_info */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1575 &prpl_info, /**< extra_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
1576 &prefs_info, /**< prefs_info */
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1577 silcgaim_actions
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1578 };
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1579
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1580 static void
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1581 init_plugin(GaimPlugin *plugin)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1582 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1583 GaimAccountOption *option;
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1584 GaimAccountUserSplit *split;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1585 char tmp[256];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1586
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1587 silc_plugin = plugin;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1588
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1589 split = gaim_account_user_split_new(_("Network"), "silcnet.org", '@');
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1590 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1591
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1592 /* Account options */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1593 option = gaim_account_option_string_new(_("Connect server"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1594 "server",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1595 "silc.silcnet.org");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1596 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1597 option = gaim_account_option_int_new(_("Port"), "port", 706);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1598 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1599 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir());
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1600 option = gaim_account_option_string_new(_("Public Key file"),
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1601 "public-key", tmp);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1602 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1603 g_snprintf(tmp, sizeof(tmp), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir());
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1604 option = gaim_account_option_string_new(_("Private Key file"),
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1605 "private-key", tmp);
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10802
diff changeset
1606 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1607 option = gaim_account_option_bool_new(_("Public key authentication"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1608 "pubkey-auth", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1609 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1610
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1611 option = gaim_account_option_bool_new(_("Reject watching by other users"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1612 "reject-watch", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1613 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1614 option = gaim_account_option_bool_new(_("Block invites"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1615 "block-invites", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1616 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1617 option = gaim_account_option_bool_new(_("Block IMs without Key Exchange"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1618 "block-ims", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1619 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1620 option = gaim_account_option_bool_new(_("Reject online status attribute requests"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1621 "reject-attrs", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1622 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1623
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1624 /* Preferences */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1625 gaim_prefs_add_none("/plugins/prpl/silc");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1626 gaim_prefs_add_bool("/plugins/prpl/silc/sign_im", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1627 gaim_prefs_add_bool("/plugins/prpl/silc/verify_im", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1628 gaim_prefs_add_bool("/plugins/prpl/silc/sign_chat", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1629 gaim_prefs_add_bool("/plugins/prpl/silc/verify_chat", FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1630 gaim_prefs_add_string("/plugins/prpl/silc/vcard", "");
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1631
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9039
diff changeset
1632 silcgaim_register_commands();
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1633
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1634 #ifdef _WIN32
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1635 silc_net_win32_init();
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
1636 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1637 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1638
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1639 GAIM_INIT_PLUGIN(silc, init_plugin, info);