Mercurial > pidgin.yaz
annotate src/protocols/oscar/admin.c @ 3952:07283934dedd
[gaim-migrate @ 4133]
Ok, big commit with little functionality change.
Most of it is me shuffling crap around because I'm one of them neat freaks. Lots of general code
cleanup too. I'm trying to move to that whole "one-family-per-file" thing.
The details...
I added libfaim support for aim's new search family, 0x000f. I only tested this briefly, so if
anyone uses it for anything, be aware that it could be buggy. I'll add oscar support sometime.
Advantages of this family are... when you search for someone, you get the directory info for that
person. So like, first name, middle name, last name, maiden name, city, state, country, zip,
address, interests, nickname, and maybe some other stuff. Basically all the info that they've set in
their directory info thing. Info. Oh, and I'm calling it "new search" because seach was already
taken, and cookie monster ate my right brain.
The reason I didn't add support to oscar.c... the new search family requires making a connection to
another server. While moving stuff around I realized that I didn't really like how new connections
are made. It's kind of sloppy. I'm thinking it would be nice to have an outgoing queue for each
type of connection, and then let the client queue messages as much as they want. Then, if libfaim
sees that there is a message for a certain type of connection, and there is no open connection of
that type, it will connect, and then flush the queue when the connection is made. This seems a lot
cleaner, but it also seems like a pain in the ass. I should do ssi for icq first, anyway :-)
Also, I think it would be neat if there was an ICBM file that handled channels 1 through 4. Then
im.c and chat.c could pass the ICBM part to the icbm stuff and it could get parsed there. im.c is
really huge right now.
I applied a patch from Graham Booker that paves the way for unicode in direct IMs. Thanks Graham.
Now we just need Paco-Paco to git a little free time and write a patch for this.
http://sourceforge.net/tracker/index.php?func=detail&aid=633589&group_id=235&atid=300235
I applied 2 patches from Will Mahan dealing with file transfer/oft/rendezous/whatever. Here's some
info on them, from The Man himself:
Patch 1
"Currently the Rendezvous code is rather messy; this
patch attempts to bring it up to speed with the rest of
the Oscar prpl. Its changes include:
* Rewrite several ft.c functions to use bstreams.
Apparently the code in question was written before
bstreams were implemented.
* Handle incoming Rendezvous packets through the
rxqueue like FLAP packets, rather than handling them as
a special case as soon as they are received. This
takes advantage of the bstream cleanup to unify some
code and simplify the aim_frame_t struct.
* Change some names used to try to clarify the
distinction between OFT, which refers specifically to
file transfer, and Rendezvous, which encompasses OFT as
well as other types of client-to-client connections."
Patch 2
"* Add some comments I inadvertently left out of my last patch.
* Fix a double-free that occurs when connections time out.
* Correct a bug causing filenames to be truncated by 4 characters on
some clients.
* Preserve directory structure when sending multiple files.
* Handle (throw away) resource forks sent by Mac clients."
I also changed all indents to tabs in ft.c.
And split all the bstream stuff from rxqueue.c and put it in bstream.c. It really is a separate
thing. Especially since it can be used for outgoing connections.
Also, I was going to look over the whole patch tonight to make sure it's all good, but it's like 6000
lines, so, uh, I'll do it later.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 13 Nov 2002 07:01:37 +0000 |
parents | e73c48cf1645 |
children | 2532f1192da3 |
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, | |
6 * | |
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 * | |
20 */ | |
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 |
113 aim_addtlvtochain_raw(&tl, 0x0001, strlen(newnick), newnick); | |
114 | |
3952 | 115 aim_writetlvchain(&fr->data, &tl); |
3912 | 116 aim_freetlvchain(&tl); |
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) */ | |
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 | |
3952 | 146 aim_writetlvchain(&fr->data, &tl); |
3912 | 147 aim_freetlvchain(&tl); |
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 |
170 aim_addtlvtochain_raw(&tl, 0x0011, strlen(newemail), newemail); | |
171 | |
3952 | 172 aim_writetlvchain(&fr->data, &tl); |
3912 | 173 aim_freetlvchain(&tl); |
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 { |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
199 aim_rxcallback_t userfunc; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
200 fu16_t status; |
3912 | 201 aim_tlvlist_t *tl; |
2086 | 202 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
203 status = aimbs_get16(bs); |
3912 | 204 /* This is 0x0013 if unable to confirm at this time */ |
205 | |
206 tl = aim_readtlvchain(bs); | |
2086 | 207 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
208 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
209 return userfunc(sess, rx, status); |
2086 | 210 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
211 return 0; |
2086 | 212 } |
213 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
214 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) |
2086 | 215 { |
216 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
217 if ((snac->subtype == 0x0003) || (snac->subtype == 0x0005)) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
218 return infochange(sess, mod, rx, snac, bs); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
219 else if (snac->subtype == 0x0007) |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
220 return accountconfirm(sess, mod, rx, snac, bs); |
2086 | 221 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
222 return 0; |
2086 | 223 } |
224 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
225 faim_internal int admin_modfirst(aim_session_t *sess, aim_module_t *mod) |
2086 | 226 { |
227 | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
228 mod->family = 0x0007; |
2672 | 229 mod->version = 0x0001; |
230 mod->toolid = AIM_TOOL_NEWWIN; | |
231 mod->toolversion = 0x0361; /* XXX this and above aren't right */ | |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
232 mod->flags = 0; |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
233 strncpy(mod->name, "admin", sizeof(mod->name)); |
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
234 mod->snachandler = snachandler; |
2086 | 235 |
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
236 return 0; |
2086 | 237 } |