2 * aimpasswd.c -- Change AIM password without logging in.
4 * Defintly not done yet.
6 * TODO: Make this work.
8 * -----------------------------------------------------------
10 * I'm releasing this code and all it's associated linkage
11 * under the GNU General Public License. For more information,
12 * please refer to http://www.fsf.org. For any questions,
13 * please contact me at the address below.
15 * (c) 1998/99 Adam Fritzler, PST, afritz@iname.com
17 * -----------------------------------------------------------
27 #include "aim.h" /* for struct defs, global ptrs, etc */
29 int faimtest_parse_oncoming(struct command_rx_struct *, ...);
30 int faimtest_parse_offgoing(struct command_rx_struct *, ...);
31 int faimtest_parse_login_phase3d_f(struct command_rx_struct *, ...);
32 int faimtest_auth_error(struct command_rx_struct *, ...);
33 int faimtest_auth_success(struct command_rx_struct *, ...);
34 int faimtest_parse_incoming_im(struct command_rx_struct *command, ...);
35 int faimtest_parse_userinfo(struct command_rx_struct *command, ...);
36 int faimtest_handleredirect(struct command_rx_struct *command, ...);
37 int faimtest_authsvrready(struct command_rx_struct *command, ...);
38 int faimtest_pwdchngdone(struct command_rx_struct *command, ...);
39 int faimtest_serverready(struct command_rx_struct *command, ...);
41 int bleu(struct command_rx_struct *blah, ...)
49 specify your custom command handlers here. I recommend
50 at least overriding the login_phase3d_f handler so that
51 you can have your own buddy list and profile. The
52 rest are probably only useful to override for UI
55 rxcallback_t faimtest_callbacks[] = {
56 bleu, /* incoming IM */
57 bleu, /* oncoming buddy */
58 bleu, /* offgoing buddy */
59 NULL, /* last IM was missed 1 */
60 NULL, /* last IM was missed 2 */
61 NULL, /* login phase 4 packet C command 1 -- depricated */
62 NULL, /* login phase 4 packet C command 2 -- depricated */
63 NULL, /* login phase 2, first resp -- depricated */
64 faimtest_serverready, /* server ready -- **HANDLING REQUIRED** */
65 NULL, /* login phase 3 packet B -- depricated */
66 NULL, /* login phase 3D packet A -- depricated */
67 NULL, /* login phase 3D packet B -- depricated */
68 NULL, /* login phase 3D packet C -- depricated */
69 NULL, /* login phase 3D packet D -- depricated */
70 NULL, /* login phase 3D packet E -- depricated */
71 faimtest_handleredirect, /* redirect -- **HANDLING REQUIRED** */
72 NULL, /* last command bad */
73 NULL, /* missed some messages */
74 NULL, /* completely unknown command */
75 bleu, /* user info response */
76 NULL, /* user search by address response */
77 NULL, /* user serach by name response */
78 NULL, /* user search fail */
80 faimtest_auth_success,
81 faimtest_authsvrready,
85 0x00 /* terminating NULL -- REQUIRED */
88 aim_connrst(); /* reset connection array -- there's a better place for this*/
89 /* register our callback array (optional) */
90 aim_register_callbacks(faimtest_callbacks);
93 aim_login("NAME", "PASS");
94 while (aim_select(NULL) > (struct aim_conn_t *)0)
96 if (aim_get_command() < 0)
98 printf("\afaimtest: connection error!\n");
105 printf("AIM just decided we didn't need to be here anymore, closing up.,,\n");
107 /* close up all connections, dead or no */
114 int faimtest_serverready(struct command_rx_struct *command, ...)
116 switch (command->conn->type)
118 case AIM_CONN_TYPE_BOS:
119 printf("requesting AUTH service\n");
120 aim_bos_reqservice(command->conn, 0x0007);
123 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
131 This, of course, handles Service Redirects from OSCAR.
133 Should get passed in the following:
134 struct command_rx_struct *command
137 the destination service ID
139 the IP address of the service's server
143 int faimtest_handleredirect(struct command_rx_struct *command, ...)
150 va_start(ap, command);
151 serviceid = va_arg(ap, int);
152 ip = va_arg(ap, char *);
153 cookie = va_arg(ap, char *);
158 case 0x0007: /* Authorizer */
160 struct aim_conn_t *tstconn;
161 /* Open a connection to the Auth */
162 tstconn = aim_newconn(AIM_CONN_TYPE_AUTH, ip);
163 /* Send the cookie to the Auth */
164 aim_auth_sendcookie(tstconn, cookie);
168 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
175 int faimtest_auth_error(struct command_rx_struct *command, ...)
178 struct login_phase1_struct *logininfo;
182 va_start(ap, command);
183 logininfo = va_arg(ap, struct login_phase1_struct *);
184 printf("Screen name: %s\n", logininfo->screen_name);
185 errorurl = va_arg(ap, char *);
186 printf("Error URL: %s\n", errorurl);
187 errorcode = va_arg(ap, short);
188 printf("Error code: 0x%02x\n", errorcode);
191 aim_conn_close(aim_getconn_type(AIM_CONN_TYPE_AUTH));
197 int faimtest_auth_success(struct command_rx_struct *command, ...)
200 struct login_phase1_struct *logininfo;
201 struct aim_conn_t *bosconn = NULL;
203 va_start(ap, command);
204 logininfo = va_arg(ap, struct login_phase1_struct *);
207 printf("Screen name: %s\n", logininfo->screen_name);
208 printf("Reg status: %2d\n", logininfo->regstatus);
209 printf("Email: %s\n", logininfo->email);
210 printf("Cookie len: %d\n", sizeof(logininfo->cookie));
211 printf("BOS IP: %s\n", logininfo->BOSIP);
213 printf("Closing auth connection...\n");
214 aim_conn_close(command->conn);
215 bosconn = aim_newconn(AIM_CONN_TYPE_BOS, logininfo->BOSIP);
216 aim_auth_sendcookie(bosconn, logininfo->cookie);
221 int faimtest_authsvrready(struct command_rx_struct *command, ...)
223 /* should just be able to tell it we're ready too... */
224 aim_auth_clientready(command->conn);
227 * This is where you'd really begin changing your password.
228 * However, this callback may get called for reasons other
229 * than you wanting to change your password. You should
230 * probably check that before actually doing it.
232 //aim_auth_changepasswd(command->conn, "", "");
237 int faimtest_pwdchngdone(struct command_rx_struct *command, ...)
239 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");