13234
|
1 /*
|
|
2 * Gaim's oscar protocol plugin
|
|
3 * This file is the legal property of its developers.
|
|
4 * Please see the AUTHORS file distributed alongside this file.
|
|
5 *
|
|
6 * This library is free software; you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU Lesser General Public
|
|
8 * License as published by the Free Software Foundation; either
|
|
9 * version 2 of the License, or (at your option) any later version.
|
|
10 *
|
|
11 * This library is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 * Lesser General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU Lesser General Public
|
|
17 * License along with this library; if not, write to the Free Software
|
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21 /*
|
|
22 * Family 0x0007 - Account Administration.
|
|
23 *
|
|
24 * Used for stuff like changing the formating of your screen name, changing your
|
|
25 * email address, requesting an account confirmation email, getting account info,
|
|
26 *
|
|
27 */
|
|
28
|
|
29 #include "oscar.h"
|
|
30
|
|
31 /*
|
|
32 * Subtype 0x0002 - Request a bit of account info.
|
|
33 *
|
|
34 * Info should be one of the following:
|
|
35 * 0x0001 - Screen name formatting
|
|
36 * 0x0011 - Email address
|
|
37 * 0x0013 - Unknown
|
|
38 *
|
|
39 */
|
13592
|
40 int
|
|
41 aim_admin_getinfo(OscarData *od, FlapConnection *conn, guint16 info)
|
13234
|
42 {
|
13239
|
43 FlapFrame *fr;
|
13234
|
44 aim_snacid_t snacid;
|
|
45
|
13592
|
46 fr = flap_frame_new(od, 0x02, 14);
|
13234
|
47
|
13592
|
48 snacid = aim_cachesnac(od, 0x0007, 0x0002, 0x0000, NULL, 0);
|
13234
|
49 aim_putsnac(&fr->data, 0x0007, 0x0002, 0x0000, snacid);
|
|
50
|
13592
|
51 byte_stream_put16(&fr->data, info);
|
|
52 byte_stream_put16(&fr->data, 0x0000);
|
13234
|
53
|
13592
|
54 flap_connection_send(conn, fr);
|
13234
|
55
|
|
56 return 0;
|
|
57 }
|
|
58
|
|
59 /*
|
|
60 * Subtypes 0x0003 and 0x0005 - Parse account info.
|
|
61 *
|
|
62 * Called in reply to both an information request (subtype 0x0002) and
|
|
63 * an information change (subtype 0x0004).
|
|
64 *
|
|
65 */
|
13592
|
66 static int
|
|
67 infochange(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
68 {
|
|
69 aim_rxcallback_t userfunc;
|
|
70 char *url=NULL, *sn=NULL, *email=NULL;
|
|
71 guint16 perms, tlvcount, err=0;
|
|
72
|
13592
|
73 perms = byte_stream_get16(bs);
|
|
74 tlvcount = byte_stream_get16(bs);
|
13234
|
75
|
13592
|
76 while (tlvcount && byte_stream_empty(bs)) {
|
13234
|
77 guint16 type, length;
|
|
78
|
13592
|
79 type = byte_stream_get16(bs);
|
|
80 length = byte_stream_get16(bs);
|
13234
|
81
|
|
82 switch (type) {
|
|
83 case 0x0001: {
|
13592
|
84 sn = byte_stream_getstr(bs, length);
|
13234
|
85 } break;
|
|
86
|
|
87 case 0x0004: {
|
13592
|
88 url = byte_stream_getstr(bs, length);
|
13234
|
89 } break;
|
|
90
|
|
91 case 0x0008: {
|
13592
|
92 err = byte_stream_get16(bs);
|
13234
|
93 } break;
|
|
94
|
|
95 case 0x0011: {
|
13592
|
96 if (length == 0)
|
|
97 email = g_strdup("*suppressed");
|
|
98 else
|
|
99 email = byte_stream_getstr(bs, length);
|
13234
|
100 } break;
|
|
101 }
|
|
102
|
|
103 tlvcount--;
|
|
104 }
|
|
105
|
13592
|
106 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
107 userfunc(od, conn, frame, (snac->subtype == 0x0005) ? 1 : 0, perms, err, url, sn, email);
|
13234
|
108
|
|
109 free(sn);
|
|
110 free(url);
|
|
111 free(email);
|
|
112
|
|
113 return 1;
|
|
114 }
|
|
115
|
|
116 /*
|
|
117 * Subtype 0x0004 - Set screenname formatting.
|
|
118 *
|
|
119 */
|
13592
|
120 int
|
|
121 aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick)
|
13234
|
122 {
|
13239
|
123 FlapFrame *fr;
|
13234
|
124 aim_snacid_t snacid;
|
|
125 aim_tlvlist_t *tl = NULL;
|
|
126
|
13592
|
127 fr = flap_frame_new(od, 0x02, 10+2+2+strlen(newnick));
|
13234
|
128 return -ENOMEM;
|
|
129
|
13592
|
130 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0);
|
13234
|
131 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid);
|
|
132
|
|
133 aim_tlvlist_add_str(&tl, 0x0001, newnick);
|
|
134
|
|
135 aim_tlvlist_write(&fr->data, &tl);
|
|
136 aim_tlvlist_free(&tl);
|
|
137
|
13592
|
138 flap_connection_send(conn, fr);
|
13234
|
139
|
|
140
|
|
141 return 0;
|
|
142 }
|
|
143
|
|
144 /*
|
|
145 * Subtype 0x0004 - Change password.
|
|
146 *
|
|
147 */
|
13592
|
148 int
|
|
149 aim_admin_changepasswd(OscarData *od, FlapConnection *conn, const char *newpw, const char *curpw)
|
13234
|
150 {
|
13239
|
151 FlapFrame *fr;
|
13234
|
152 aim_tlvlist_t *tl = NULL;
|
|
153 aim_snacid_t snacid;
|
|
154
|
13592
|
155 fr = flap_frame_new(od, 0x02, 10+4+strlen(curpw)+4+strlen(newpw));
|
13234
|
156
|
13592
|
157 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0);
|
13234
|
158 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid);
|
|
159
|
|
160 /* new password TLV t(0002) */
|
|
161 aim_tlvlist_add_str(&tl, 0x0002, newpw);
|
|
162
|
|
163 /* current password TLV t(0012) */
|
|
164 aim_tlvlist_add_str(&tl, 0x0012, curpw);
|
|
165
|
|
166 aim_tlvlist_write(&fr->data, &tl);
|
|
167 aim_tlvlist_free(&tl);
|
|
168
|
13592
|
169 flap_connection_send(conn, fr);
|
13234
|
170
|
|
171 return 0;
|
|
172 }
|
|
173
|
|
174 /*
|
|
175 * Subtype 0x0004 - Change email address.
|
|
176 *
|
|
177 */
|
13592
|
178 int
|
|
179 aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail)
|
13234
|
180 {
|
13239
|
181 FlapFrame *fr;
|
13234
|
182 aim_snacid_t snacid;
|
|
183 aim_tlvlist_t *tl = NULL;
|
|
184
|
13592
|
185 flap_frame_new(od, 0x02, 10+2+2+strlen(newemail));
|
13234
|
186
|
13592
|
187 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0);
|
13234
|
188 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid);
|
|
189
|
|
190 aim_tlvlist_add_str(&tl, 0x0011, newemail);
|
|
191
|
|
192 aim_tlvlist_write(&fr->data, &tl);
|
|
193 aim_tlvlist_free(&tl);
|
|
194
|
13592
|
195 flap_connection_send(conn, fr);
|
13234
|
196
|
|
197 return 0;
|
|
198 }
|
|
199
|
|
200 /*
|
|
201 * Subtype 0x0006 - Request account confirmation.
|
|
202 *
|
|
203 * This will cause an email to be sent to the address associated with
|
|
204 * the account. By following the instructions in the mail, you can
|
|
205 * get the TRIAL flag removed from your account.
|
|
206 *
|
|
207 */
|
13592
|
208 int
|
|
209 aim_admin_reqconfirm(OscarData *od, FlapConnection *conn)
|
13234
|
210 {
|
13592
|
211 return aim_genericreq_n(od, conn, 0x0007, 0x0006);
|
13234
|
212 }
|
|
213
|
|
214 /*
|
|
215 * Subtype 0x0007 - Account confirmation request acknowledgement.
|
|
216 *
|
|
217 */
|
13592
|
218 static int
|
|
219 accountconfirm(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
220 {
|
|
221 int ret = 0;
|
|
222 aim_rxcallback_t userfunc;
|
|
223 guint16 status;
|
|
224 aim_tlvlist_t *tl;
|
|
225
|
13592
|
226 status = byte_stream_get16(bs);
|
13234
|
227 /* This is 0x0013 if unable to confirm at this time */
|
|
228
|
|
229 tl = aim_tlvlist_read(bs);
|
|
230
|
13592
|
231 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
232 ret = userfunc(od, conn, frame, status);
|
13234
|
233
|
|
234 return ret;
|
|
235 }
|
|
236
|
13592
|
237 static int
|
|
238 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
239 {
|
|
240 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005))
|
13592
|
241 return infochange(od, conn, mod, frame, snac, bs);
|
13234
|
242 else if (snac->subtype == 0x0007)
|
13592
|
243 return accountconfirm(od, conn, mod, frame, snac, bs);
|
13234
|
244
|
|
245 return 0;
|
|
246 }
|
|
247
|
13592
|
248 int admin_modfirst(OscarData *od, aim_module_t *mod)
|
13234
|
249 {
|
|
250 mod->family = 0x0007;
|
|
251 mod->version = 0x0001;
|
|
252 mod->toolid = 0x0010;
|
|
253 mod->toolversion = 0x0629;
|
|
254 mod->flags = 0;
|
|
255 strncpy(mod->name, "admin", sizeof(mod->name));
|
|
256 mod->snachandler = snachandler;
|
|
257
|
|
258 return 0;
|
|
259 }
|