Mercurial > pidgin
annotate src/protocols/oscar/admin.c @ 13159:d03013fd39bf
[gaim-migrate @ 15522]
Fix the filename unescaping.
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Tue, 07 Feb 2006 16:02:25 +0000 |
| parents | 1798ad0be460 |
| children |
| rev | line source |
|---|---|
| 3912 | 1 /* |
| 2 * Family 0x0007 - Account Administration. | |
| 3 * | |
| 4 * Used for stuff like changing the formating of your screen name, changing your | |
| 5 * email address, requesting an account confirmation email, getting account info, | |
| 4071 | 6 * |
| 3912 | 7 */ |
| 2086 | 8 |
| 9 #define FAIM_INTERNAL | |
| 10 #include <aim.h> | |
| 11 | |
| 3912 | 12 /* |
| 13 * Subtype 0x0002 - Request a bit of account info. | |
| 14 * | |
| 15 * Info should be one of the following: | |
| 16 * 0x0001 - Screen name formatting | |
| 17 * 0x0011 - Email address | |
| 18 * 0x0013 - Unknown | |
| 19 * | |
| 10986 | 20 */ |
| 3912 | 21 faim_export int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info) |
| 22 { | |
| 3952 | 23 aim_frame_t *fr; |
| 3912 | 24 aim_snacid_t snacid; |
| 25 | |
| 3952 | 26 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14))) |
| 3912 | 27 return -ENOMEM; |
| 28 | |
| 29 snacid = aim_cachesnac(sess, 0x0007, 0x0002, 0x0000, NULL, 0); | |
| 3952 | 30 aim_putsnac(&fr->data, 0x0007, 0x0002, 0x0000, snacid); |
| 3912 | 31 |
| 3952 | 32 aimbs_put16(&fr->data, info); |
| 33 aimbs_put16(&fr->data, 0x0000); | |
| 3912 | 34 |
| 3952 | 35 aim_tx_enqueue(sess, fr); |
| 3912 | 36 |
| 37 return 0; | |
| 38 } | |
| 39 | |
| 40 /* | |
| 41 * Subtypes 0x0003 and 0x0005 - Parse account info. | |
| 42 * | |
| 43 * Called in reply to both an information request (subtype 0x0002) and | |
| 44 * an information change (subtype 0x0004). | |
| 45 * | |
| 46 */ | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
47 static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
| 2086 | 48 { |
| 3912 | 49 aim_rxcallback_t userfunc; |
| 50 char *url=NULL, *sn=NULL, *email=NULL; | |
| 51 fu16_t perms, tlvcount, err=0; | |
| 2086 | 52 |
| 3912 | 53 perms = aimbs_get16(bs); |
| 54 tlvcount = aimbs_get16(bs); | |
| 55 | |
| 56 while (tlvcount && aim_bstream_empty(bs)) { | |
| 57 fu16_t type, length; | |
| 58 | |
| 59 type = aimbs_get16(bs); | |
| 60 length = aimbs_get16(bs); | |
| 2086 | 61 |
| 3912 | 62 switch (type) { |
| 63 case 0x0001: { | |
| 64 sn = aimbs_getstr(bs, length); | |
| 65 } break; | |
| 2086 | 66 |
| 3912 | 67 case 0x0004: { |
| 68 url = aimbs_getstr(bs, length); | |
| 69 } break; | |
| 2086 | 70 |
| 3912 | 71 case 0x0008: { |
| 72 err = aimbs_get16(bs); | |
| 73 } break; | |
| 2086 | 74 |
| 3912 | 75 case 0x0011: { |
| 76 if (length == 0) { | |
| 77 email = (char*)malloc(13*sizeof(char)); | |
| 78 strcpy(email, "*suppressed*"); | |
| 79 } else | |
| 80 email = aimbs_getstr(bs, length); | |
| 81 } break; | |
| 82 } | |
| 2086 | 83 |
| 3912 | 84 tlvcount--; |
| 85 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
86 |
| 3912 | 87 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
| 88 userfunc(sess, rx, (snac->subtype == 0x0005) ? 1 : 0, perms, err, url, sn, email); | |
| 2086 | 89 |
| 3912 | 90 if (sn) free(sn); |
| 91 if (url) free(url); | |
| 92 if (email) free(email); | |
| 2086 | 93 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
94 return 1; |
| 2086 | 95 } |
| 96 | |
| 3912 | 97 /* |
| 98 * Subtype 0x0004 - Set screenname formatting. | |
| 99 * | |
| 100 */ | |
| 101 faim_export int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick) | |
| 102 { | |
| 3952 | 103 aim_frame_t *fr; |
| 3912 | 104 aim_snacid_t snacid; |
| 105 aim_tlvlist_t *tl = NULL; | |
| 106 | |
| 3952 | 107 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newnick)))) |
| 3912 | 108 return -ENOMEM; |
| 109 | |
| 110 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
| 3952 | 111 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); |
| 3912 | 112 |
| 10991 | 113 aim_tlvlist_add_str(&tl, 0x0001, newnick); |
| 10986 | 114 |
| 7167 | 115 aim_tlvlist_write(&fr->data, &tl); |
| 116 aim_tlvlist_free(&tl); | |
| 10986 | 117 |
| 3952 | 118 aim_tx_enqueue(sess, fr); |
| 3912 | 119 |
| 120 | |
| 121 return 0; | |
| 122 } | |
| 123 | |
| 124 /* | |
| 125 * Subtype 0x0004 - Change password. | |
| 126 * | |
| 127 */ | |
| 128 faim_export int aim_admin_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *newpw, const char *curpw) | |
| 129 { | |
| 3952 | 130 aim_frame_t *fr; |
| 3912 | 131 aim_tlvlist_t *tl = NULL; |
| 132 aim_snacid_t snacid; | |
| 133 | |
| 3952 | 134 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw)))) |
| 3912 | 135 return -ENOMEM; |
| 136 | |
| 137 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
| 3952 | 138 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); |
| 3912 | 139 |
| 140 /* new password TLV t(0002) */ | |
| 10991 | 141 aim_tlvlist_add_str(&tl, 0x0002, newpw); |
| 3912 | 142 |
| 143 /* current password TLV t(0012) */ | |
| 10991 | 144 aim_tlvlist_add_str(&tl, 0x0012, curpw); |
| 3912 | 145 |
| 7167 | 146 aim_tlvlist_write(&fr->data, &tl); |
| 147 aim_tlvlist_free(&tl); | |
| 3912 | 148 |
| 3952 | 149 aim_tx_enqueue(sess, fr); |
| 3912 | 150 |
| 151 return 0; | |
| 152 } | |
| 153 | |
| 154 /* | |
| 155 * Subtype 0x0004 - Change email address. | |
| 156 * | |
| 157 */ | |
| 158 faim_export int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail) | |
| 159 { | |
| 3952 | 160 aim_frame_t *fr; |
| 3912 | 161 aim_snacid_t snacid; |
| 162 aim_tlvlist_t *tl = NULL; | |
| 163 | |
| 3952 | 164 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail)))) |
| 3912 | 165 return -ENOMEM; |
| 166 | |
| 167 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); | |
| 3952 | 168 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); |
| 3912 | 169 |
| 10991 | 170 aim_tlvlist_add_str(&tl, 0x0011, newemail); |
| 3912 | 171 |
| 7167 | 172 aim_tlvlist_write(&fr->data, &tl); |
| 173 aim_tlvlist_free(&tl); | |
| 3912 | 174 |
| 3952 | 175 aim_tx_enqueue(sess, fr); |
| 3912 | 176 |
| 177 return 0; | |
| 178 } | |
| 179 | |
| 180 /* | |
| 181 * Subtype 0x0006 - Request account confirmation. | |
| 182 * | |
| 183 * This will cause an email to be sent to the address associated with | |
| 184 * the account. By following the instructions in the mail, you can | |
| 185 * get the TRIAL flag removed from your account. | |
| 186 * | |
| 187 */ | |
| 188 faim_export int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn) | |
| 189 { | |
| 190 return aim_genericreq_n(sess, conn, 0x0007, 0x0006); | |
| 191 } | |
| 192 | |
| 193 /* | |
| 194 * Subtype 0x0007 - Account confirmation request acknowledgement. | |
| 195 * | |
| 196 */ | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
197 static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
| 2086 | 198 { |
| 4871 | 199 int ret = 0; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
200 aim_rxcallback_t userfunc; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
201 fu16_t status; |
| 3912 | 202 aim_tlvlist_t *tl; |
| 2086 | 203 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
204 status = aimbs_get16(bs); |
| 3912 | 205 /* This is 0x0013 if unable to confirm at this time */ |
| 206 | |
| 7167 | 207 tl = aim_tlvlist_read(bs); |
| 2086 | 208 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
209 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
| 4871 | 210 ret = userfunc(sess, rx, status); |
| 2086 | 211 |
| 4871 | 212 return ret; |
| 2086 | 213 } |
| 214 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
215 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
| 2086 | 216 { |
| 217 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
218 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005)) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
219 return infochange(sess, mod, rx, snac, bs); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
220 else if (snac->subtype == 0x0007) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
221 return accountconfirm(sess, mod, rx, snac, bs); |
| 2086 | 222 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
223 return 0; |
| 2086 | 224 } |
| 225 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
226 faim_internal int admin_modfirst(aim_session_t *sess, aim_module_t *mod) |
| 2086 | 227 { |
| 228 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
229 mod->family = 0x0007; |
| 2672 | 230 mod->version = 0x0001; |
| 4071 | 231 mod->toolid = 0x0010; |
| 232 mod->toolversion = 0x0629; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
233 mod->flags = 0; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
234 strncpy(mod->name, "admin", sizeof(mod->name)); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
235 mod->snachandler = snachandler; |
| 2086 | 236 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
237 return 0; |
| 2086 | 238 } |
