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: {
|
13650
|
84 free(sn);
|
13592
|
85 sn = byte_stream_getstr(bs, length);
|
13234
|
86 } break;
|
|
87
|
|
88 case 0x0004: {
|
13650
|
89 free(url);
|
13592
|
90 url = byte_stream_getstr(bs, length);
|
13234
|
91 } break;
|
|
92
|
|
93 case 0x0008: {
|
13592
|
94 err = byte_stream_get16(bs);
|
13234
|
95 } break;
|
|
96
|
|
97 case 0x0011: {
|
13650
|
98 free(email);
|
13592
|
99 if (length == 0)
|
|
100 email = g_strdup("*suppressed");
|
|
101 else
|
|
102 email = byte_stream_getstr(bs, length);
|
13234
|
103 } break;
|
|
104 }
|
|
105
|
|
106 tlvcount--;
|
|
107 }
|
|
108
|
13592
|
109 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
110 userfunc(od, conn, frame, (snac->subtype == 0x0005) ? 1 : 0, perms, err, url, sn, email);
|
13234
|
111
|
|
112 free(sn);
|
|
113 free(url);
|
|
114 free(email);
|
|
115
|
|
116 return 1;
|
|
117 }
|
|
118
|
|
119 /*
|
|
120 * Subtype 0x0004 - Set screenname formatting.
|
|
121 *
|
|
122 */
|
13592
|
123 int
|
|
124 aim_admin_setnick(OscarData *od, FlapConnection *conn, const char *newnick)
|
13234
|
125 {
|
13239
|
126 FlapFrame *fr;
|
13234
|
127 aim_snacid_t snacid;
|
|
128 aim_tlvlist_t *tl = NULL;
|
|
129
|
13592
|
130 fr = flap_frame_new(od, 0x02, 10+2+2+strlen(newnick));
|
13234
|
131
|
13592
|
132 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0);
|
13234
|
133 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid);
|
|
134
|
|
135 aim_tlvlist_add_str(&tl, 0x0001, newnick);
|
|
136
|
|
137 aim_tlvlist_write(&fr->data, &tl);
|
|
138 aim_tlvlist_free(&tl);
|
|
139
|
13592
|
140 flap_connection_send(conn, fr);
|
13234
|
141
|
|
142
|
|
143 return 0;
|
|
144 }
|
|
145
|
|
146 /*
|
|
147 * Subtype 0x0004 - Change password.
|
|
148 *
|
|
149 */
|
13592
|
150 int
|
|
151 aim_admin_changepasswd(OscarData *od, FlapConnection *conn, const char *newpw, const char *curpw)
|
13234
|
152 {
|
13239
|
153 FlapFrame *fr;
|
13234
|
154 aim_tlvlist_t *tl = NULL;
|
|
155 aim_snacid_t snacid;
|
|
156
|
13592
|
157 fr = flap_frame_new(od, 0x02, 10+4+strlen(curpw)+4+strlen(newpw));
|
13234
|
158
|
13592
|
159 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0);
|
13234
|
160 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid);
|
|
161
|
|
162 /* new password TLV t(0002) */
|
|
163 aim_tlvlist_add_str(&tl, 0x0002, newpw);
|
|
164
|
|
165 /* current password TLV t(0012) */
|
|
166 aim_tlvlist_add_str(&tl, 0x0012, curpw);
|
|
167
|
|
168 aim_tlvlist_write(&fr->data, &tl);
|
|
169 aim_tlvlist_free(&tl);
|
|
170
|
13592
|
171 flap_connection_send(conn, fr);
|
13234
|
172
|
|
173 return 0;
|
|
174 }
|
|
175
|
|
176 /*
|
|
177 * Subtype 0x0004 - Change email address.
|
|
178 *
|
|
179 */
|
13592
|
180 int
|
|
181 aim_admin_setemail(OscarData *od, FlapConnection *conn, const char *newemail)
|
13234
|
182 {
|
13239
|
183 FlapFrame *fr;
|
13234
|
184 aim_snacid_t snacid;
|
|
185 aim_tlvlist_t *tl = NULL;
|
|
186
|
13595
|
187 fr = flap_frame_new(od, 0x02, 10+2+2+strlen(newemail));
|
13234
|
188
|
13592
|
189 snacid = aim_cachesnac(od, 0x0007, 0x0004, 0x0000, NULL, 0);
|
13234
|
190 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid);
|
|
191
|
|
192 aim_tlvlist_add_str(&tl, 0x0011, newemail);
|
|
193
|
|
194 aim_tlvlist_write(&fr->data, &tl);
|
|
195 aim_tlvlist_free(&tl);
|
|
196
|
13592
|
197 flap_connection_send(conn, fr);
|
13234
|
198
|
|
199 return 0;
|
|
200 }
|
|
201
|
|
202 /*
|
|
203 * Subtype 0x0006 - Request account confirmation.
|
|
204 *
|
|
205 * This will cause an email to be sent to the address associated with
|
|
206 * the account. By following the instructions in the mail, you can
|
|
207 * get the TRIAL flag removed from your account.
|
|
208 *
|
|
209 */
|
13592
|
210 int
|
|
211 aim_admin_reqconfirm(OscarData *od, FlapConnection *conn)
|
13234
|
212 {
|
13592
|
213 return aim_genericreq_n(od, conn, 0x0007, 0x0006);
|
13234
|
214 }
|
|
215
|
|
216 /*
|
|
217 * Subtype 0x0007 - Account confirmation request acknowledgement.
|
|
218 *
|
|
219 */
|
13592
|
220 static int
|
|
221 accountconfirm(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
222 {
|
|
223 int ret = 0;
|
|
224 aim_rxcallback_t userfunc;
|
|
225 guint16 status;
|
13662
|
226 /* aim_tlvlist_t *tl; */
|
13234
|
227
|
13592
|
228 status = byte_stream_get16(bs);
|
13662
|
229 /* Status is 0x0013 if unable to confirm at this time */
|
13234
|
230
|
13662
|
231 /* tl = aim_tlvlist_read(bs); */
|
13234
|
232
|
13592
|
233 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
|
|
234 ret = userfunc(od, conn, frame, status);
|
13234
|
235
|
13662
|
236 /* aim_tlvlist_free(&tl); */
|
13651
|
237
|
13234
|
238 return ret;
|
|
239 }
|
|
240
|
13592
|
241 static int
|
|
242 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
|
13234
|
243 {
|
|
244 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005))
|
13592
|
245 return infochange(od, conn, mod, frame, snac, bs);
|
13234
|
246 else if (snac->subtype == 0x0007)
|
13592
|
247 return accountconfirm(od, conn, mod, frame, snac, bs);
|
13234
|
248
|
|
249 return 0;
|
|
250 }
|
|
251
|
13592
|
252 int admin_modfirst(OscarData *od, aim_module_t *mod)
|
13234
|
253 {
|
|
254 mod->family = 0x0007;
|
|
255 mod->version = 0x0001;
|
|
256 mod->toolid = 0x0010;
|
|
257 mod->toolversion = 0x0629;
|
|
258 mod->flags = 0;
|
|
259 strncpy(mod->name, "admin", sizeof(mod->name));
|
|
260 mod->snachandler = snachandler;
|
|
261
|
|
262 return 0;
|
|
263 }
|