2 * Purple's oscar protocol plugin
3 * This file is the legal property of its developers.
4 * Please see the AUTHORS file distributed alongside this file.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 * Family 0x0007 - Account Administration.
24 * Used for stuff like changing the formating of your username, changing your
25 * email address, requesting an account confirmation email, getting account info,
31 * Subtype 0x0002 - Request a bit of account info.
33 * Info should be one of the following:
34 * 0x0001 - Username formatting
35 * 0x0011 - Email address
39 aim_admin_getinfo(OscarData
*od
, FlapConnection
*conn
, guint16 info
)
44 byte_stream_new(&bs
, 4);
46 byte_stream_put16(&bs
, info
);
47 byte_stream_put16(&bs
, 0x0000);
49 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ADMIN
, 0x0002, 0x0000, NULL
, 0);
50 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ADMIN
, 0x0002, snacid
, &bs
);
52 byte_stream_destroy(&bs
);
56 * Subtypes 0x0003 and 0x0005 - Parse account info.
58 * Called in reply to both an information request (subtype 0x0002) and
59 * an information change (subtype 0x0004).
62 infochange(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
64 aim_rxcallback_t userfunc
;
65 char *url
=NULL
, *sn
=NULL
, *email
=NULL
;
66 guint16 perms
, tlvcount
, err
=0;
68 perms
= byte_stream_get16(bs
);
69 tlvcount
= byte_stream_get16(bs
);
71 while (tlvcount
&& byte_stream_bytes_left(bs
)) {
74 type
= byte_stream_get16(bs
);
75 length
= byte_stream_get16(bs
);
80 sn
= byte_stream_getstr(bs
, length
);
85 url
= byte_stream_getstr(bs
, length
);
89 err
= byte_stream_get16(bs
);
95 email
= g_strdup("*suppressed");
97 email
= byte_stream_getstr(bs
, length
);
104 if ((userfunc
= aim_callhandler(od
, snac
->family
, snac
->subtype
)))
105 userfunc(od
, conn
, frame
, (snac
->subtype
== 0x0005) ? 1 : 0, perms
, err
, url
, sn
, email
);
113 * Subtype 0x0004 - Set the formatting of username (change spaces and capitalization).
116 aim_admin_setnick(OscarData
*od
, FlapConnection
*conn
, const char *newnick
)
120 GSList
*tlvlist
= NULL
;
122 byte_stream_new(&bs
, 2+2+strlen(newnick
));
124 aim_tlvlist_add_str(&tlvlist
, 0x0001, newnick
);
126 aim_tlvlist_write(&bs
, &tlvlist
);
127 aim_tlvlist_free(tlvlist
);
129 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ADMIN
, 0x0004, 0x0000, NULL
, 0);
130 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ADMIN
, 0x0004, snacid
, &bs
);
132 byte_stream_destroy(&bs
);
136 * Subtype 0x0004 - Change password.
139 aim_admin_changepasswd(OscarData
*od
, FlapConnection
*conn
, const char *newpw
, const char *curpw
)
142 GSList
*tlvlist
= NULL
;
145 byte_stream_new(&bs
, 4+strlen(curpw
)+4+strlen(newpw
));
147 /* new password TLV t(0002) */
148 aim_tlvlist_add_str(&tlvlist
, 0x0002, newpw
);
150 /* current password TLV t(0012) */
151 aim_tlvlist_add_str(&tlvlist
, 0x0012, curpw
);
153 aim_tlvlist_write(&bs
, &tlvlist
);
154 aim_tlvlist_free(tlvlist
);
156 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ADMIN
, 0x0004, 0x0000, NULL
, 0);
157 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ADMIN
, 0x0004, snacid
, &bs
);
159 byte_stream_destroy(&bs
);
163 * Subtype 0x0004 - Change email address.
166 aim_admin_setemail(OscarData
*od
, FlapConnection
*conn
, const char *newemail
)
170 GSList
*tlvlist
= NULL
;
172 byte_stream_new(&bs
, 2+2+strlen(newemail
));
174 aim_tlvlist_add_str(&tlvlist
, 0x0011, newemail
);
176 aim_tlvlist_write(&bs
, &tlvlist
);
177 aim_tlvlist_free(tlvlist
);
179 snacid
= aim_cachesnac(od
, SNAC_FAMILY_ADMIN
, 0x0004, 0x0000, NULL
, 0);
180 flap_connection_send_snac(od
, conn
, SNAC_FAMILY_ADMIN
, 0x0004, snacid
, &bs
);
182 byte_stream_destroy(&bs
);
186 * Subtype 0x0006 - Request account confirmation.
188 * This will cause an email to be sent to the address associated with
189 * the account. By following the instructions in the mail, you can
190 * get the TRIAL flag removed from your account.
194 aim_admin_reqconfirm(OscarData
*od
, FlapConnection
*conn
)
196 aim_genericreq_n(od
, conn
, SNAC_FAMILY_ADMIN
, 0x0006);
200 * Subtype SNAC_FAMILY_ADMIN - Account confirmation request acknowledgement.
203 accountconfirm(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
206 aim_rxcallback_t userfunc
;
208 /* GSList *tlvlist; */
210 status
= byte_stream_get16(bs
);
211 /* Status is 0x0013 if unable to confirm at this time */
213 /* tlvlist = aim_tlvlist_read(bs); */
215 if ((userfunc
= aim_callhandler(od
, snac
->family
, snac
->subtype
)))
216 ret
= userfunc(od
, conn
, frame
, status
);
218 /* aim_tlvlist_free(tlvlist); */
224 snachandler(OscarData
*od
, FlapConnection
*conn
, aim_module_t
*mod
, FlapFrame
*frame
, aim_modsnac_t
*snac
, ByteStream
*bs
)
226 if ((snac
->subtype
== 0x0003) || (snac
->subtype
== 0x0005)) {
227 infochange(od
, conn
, mod
, frame
, snac
, bs
);
229 } else if (snac
->subtype
== SNAC_FAMILY_ADMIN
)
230 return accountconfirm(od
, conn
, mod
, frame
, snac
, bs
);
235 int admin_modfirst(OscarData
*od
, aim_module_t
*mod
)
237 mod
->family
= SNAC_FAMILY_ADMIN
;
238 mod
->version
= 0x0001;
239 mod
->toolid
= 0x0010;
240 mod
->toolversion
= 0x0629;
242 strncpy(mod
->name
, "admin", sizeof(mod
->name
));
243 mod
->snachandler
= snachandler
;