Changeset 862371b for libfaim/admin.c
- Timestamp:
- Jun 29, 2003, 1:47:04 PM (21 years ago)
- Branches:
- master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- e016fc2
- Parents:
- 03ad7b2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfaim/admin.c
r5e53c4a r862371b 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, 6 * 7 */ 1 8 2 9 #define FAIM_INTERNAL 3 10 #include <aim.h> 4 11 5 /* called for both reply and change-reply */ 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 * 20 */ 21 faim_export int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info) 22 { 23 aim_frame_t *fr; 24 aim_snacid_t snacid; 25 26 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14))) 27 return -ENOMEM; 28 29 snacid = aim_cachesnac(sess, 0x0007, 0x0002, 0x0000, NULL, 0); 30 aim_putsnac(&fr->data, 0x0007, 0x0002, 0x0000, snacid); 31 32 aimbs_put16(&fr->data, info); 33 aimbs_put16(&fr->data, 0x0000); 34 35 aim_tx_enqueue(sess, fr); 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 */ 6 47 static int infochange(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 7 48 { 8 9 /* 10 * struct { 11 * unsigned short perms; 12 * unsigned short tlvcount; 13 * aim_tlv_t tlvs[tlvcount]; 14 * } admin_info[n]; 15 */ 16 while (aim_bstream_empty(bs)) { 17 fu16_t perms, tlvcount; 18 19 perms = aimbs_get16(bs); 20 tlvcount = aimbs_get16(bs); 21 22 while (tlvcount && aim_bstream_empty(bs)) { 23 aim_rxcallback_t userfunc; 24 fu16_t type, len; 25 fu8_t *val; 26 int str = 0; 27 28 type = aimbs_get16(bs); 29 len = aimbs_get16(bs); 30 31 if ((type == 0x0011) || (type == 0x0004)) 32 str = 1; 33 34 if (str) 35 val = aimbs_getstr(bs, len); 36 else 37 val = aimbs_getraw(bs, len); 38 39 /* XXX fix so its only called once for the entire packet */ 40 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 41 userfunc(sess, rx, (snac->subtype == 0x0005) ? 1 : 0, perms, type, len, val, str); 42 43 free(val); 44 45 tlvcount--; 49 aim_rxcallback_t userfunc; 50 char *url=NULL, *sn=NULL, *email=NULL; 51 fu16_t perms, tlvcount, err=0; 52 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); 61 62 switch (type) { 63 case 0x0001: { 64 sn = aimbs_getstr(bs, length); 65 } break; 66 67 case 0x0004: { 68 url = aimbs_getstr(bs, length); 69 } break; 70 71 case 0x0008: { 72 err = aimbs_get16(bs); 73 } break; 74 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; 46 82 } 83 84 tlvcount--; 47 85 } 48 86 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); 89 90 if (sn) free(sn); 91 if (url) free(url); 92 if (email) free(email); 93 49 94 return 1; 50 95 } 51 96 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 { 103 aim_frame_t *fr; 104 aim_snacid_t snacid; 105 aim_tlvlist_t *tl = NULL; 106 107 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newnick)))) 108 return -ENOMEM; 109 110 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); 111 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); 112 113 aim_addtlvtochain_raw(&tl, 0x0001, strlen(newnick), newnick); 114 115 aim_writetlvchain(&fr->data, &tl); 116 aim_freetlvchain(&tl); 117 118 aim_tx_enqueue(sess, fr); 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 { 130 aim_frame_t *fr; 131 aim_tlvlist_t *tl = NULL; 132 aim_snacid_t snacid; 133 134 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw)))) 135 return -ENOMEM; 136 137 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); 138 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); 139 140 /* new password TLV t(0002) */ 141 aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw); 142 143 /* current password TLV t(0012) */ 144 aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw); 145 146 aim_writetlvchain(&fr->data, &tl); 147 aim_freetlvchain(&tl); 148 149 aim_tx_enqueue(sess, fr); 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 { 160 aim_frame_t *fr; 161 aim_snacid_t snacid; 162 aim_tlvlist_t *tl = NULL; 163 164 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail)))) 165 return -ENOMEM; 166 167 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0); 168 aim_putsnac(&fr->data, 0x0007, 0x0004, 0x0000, snacid); 169 170 aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail); 171 172 aim_writetlvchain(&fr->data, &tl); 173 aim_freetlvchain(&tl); 174 175 aim_tx_enqueue(sess, fr); 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 */ 52 197 static int accountconfirm(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 53 198 { 54 199 aim_rxcallback_t userfunc; 55 200 fu16_t status; 201 aim_tlvlist_t *tl; 56 202 57 203 status = aimbs_get16(bs); 204 /* This is 0x0013 if unable to confirm at this time */ 205 206 tl = aim_readtlvchain(bs); 58 207 59 208 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) … … 87 236 return 0; 88 237 } 89 90 faim_export int aim_admin_changepasswd(aim_session_t *sess, aim_conn_t *conn, const char *newpw, const char *curpw)91 {92 aim_frame_t *tx;93 aim_tlvlist_t *tl = NULL;94 aim_snacid_t snacid;95 96 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+4+strlen(curpw)+4+strlen(newpw))))97 return -ENOMEM;98 99 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);100 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);101 102 /* new password TLV t(0002) */103 aim_addtlvtochain_raw(&tl, 0x0002, strlen(newpw), newpw);104 105 /* current password TLV t(0012) */106 aim_addtlvtochain_raw(&tl, 0x0012, strlen(curpw), curpw);107 108 aim_writetlvchain(&tx->data, &tl);109 aim_freetlvchain(&tl);110 111 aim_tx_enqueue(sess, tx);112 113 return 0;114 }115 116 /*117 * Request account confirmation.118 *119 * This will cause an email to be sent to the address associated with120 * the account. By following the instructions in the mail, you can121 * get the TRIAL flag removed from your account.122 *123 */124 faim_export int aim_admin_reqconfirm(aim_session_t *sess, aim_conn_t *conn)125 {126 return aim_genericreq_n(sess, conn, 0x0007, 0x0006);127 }128 129 /*130 * Request a bit of account info.131 *132 * The only known valid tag is 0x0011 (email address).133 *134 */135 faim_export int aim_admin_getinfo(aim_session_t *sess, aim_conn_t *conn, fu16_t info)136 {137 aim_frame_t *tx;138 aim_snacid_t snacid;139 140 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 14)))141 return -ENOMEM;142 143 snacid = aim_cachesnac(sess, 0x0002, 0x0002, 0x0000, NULL, 0);144 aim_putsnac(&tx->data, 0x0007, 0x0002, 0x0000, snacid);145 146 aimbs_put16(&tx->data, info);147 aimbs_put16(&tx->data, 0x0000);148 149 aim_tx_enqueue(sess, tx);150 151 return 0;152 }153 154 faim_export int aim_admin_setemail(aim_session_t *sess, aim_conn_t *conn, const char *newemail)155 {156 aim_frame_t *tx;157 aim_snacid_t snacid;158 aim_tlvlist_t *tl = NULL;159 160 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newemail))))161 return -ENOMEM;162 163 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);164 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);165 166 aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail);167 168 aim_writetlvchain(&tx->data, &tl);169 aim_freetlvchain(&tl);170 171 aim_tx_enqueue(sess, tx);172 173 return 0;174 }175 176 faim_export int aim_admin_setnick(aim_session_t *sess, aim_conn_t *conn, const char *newnick)177 {178 aim_frame_t *tx;179 aim_snacid_t snacid;180 aim_tlvlist_t *tl = NULL;181 182 if (!(tx = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(newnick))))183 return -ENOMEM;184 185 snacid = aim_cachesnac(sess, 0x0007, 0x0004, 0x0000, NULL, 0);186 aim_putsnac(&tx->data, 0x0007, 0x0004, 0x0000, snacid);187 188 aim_addtlvtochain_raw(&tl, 0x0001, strlen(newnick), newnick);189 190 aim_writetlvchain(&tx->data, &tl);191 aim_freetlvchain(&tl);192 193 aim_tx_enqueue(sess, tx);194 195 return 0;196 }197
Note: See TracChangeset
for help on using the changeset viewer.