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("a275081780", "1Fritz"); /* not real password :) */
94 aim_login("diputs 81", "1Fritz");
95 while (aim_select(NULL) > (struct aim_conn_t *)0)
97 if (aim_get_command() < 0)
99 printf("\afaimtest: connection error!\n");
106 printf("AIM just decided we didn't need to be here anymore, closing up.,,\n");
108 /* close up all connections, dead or no */
115 int faimtest_serverready(struct command_rx_struct *command, ...)
117 switch (command->conn->type)
119 case AIM_CONN_TYPE_BOS:
120 printf("requesting AUTH service\n");
121 aim_bos_reqservice(command->conn, 0x0007);
124 fprintf(stderr, "faimtest: unknown connection type on Server Ready\n");
132 This, of course, handles Service Redirects from OSCAR.
134 Should get passed in the following:
135 struct command_rx_struct *command
138 the destination service ID
140 the IP address of the service's server
144 int faimtest_handleredirect(struct command_rx_struct *command, ...)
151 va_start(ap, command);
152 serviceid = va_arg(ap, int);
153 ip = va_arg(ap, char *);
154 cookie = va_arg(ap, char *);
159 case 0x0007: /* Authorizer */
161 struct aim_conn_t *tstconn;
162 /* Open a connection to the Auth */
163 tstconn = aim_newconn(AIM_CONN_TYPE_AUTH, ip);
164 /* Send the cookie to the Auth */
165 aim_auth_sendcookie(tstconn, cookie);
169 printf("uh oh... got redirect for unknown service 0x%04x!!\n", serviceid);
176 int faimtest_auth_error(struct command_rx_struct *command, ...)
179 struct login_phase1_struct *logininfo;
183 va_start(ap, command);
184 logininfo = va_arg(ap, struct login_phase1_struct *);
185 printf("Screen name: %s\n", logininfo->screen_name);
186 errorurl = va_arg(ap, char *);
187 printf("Error URL: %s\n", errorurl);
188 errorcode = va_arg(ap, short);
189 printf("Error code: 0x%02x\n", errorcode);
192 aim_conn_close(aim_getconn_type(AIM_CONN_TYPE_AUTH));
198 int faimtest_auth_success(struct command_rx_struct *command, ...)
201 struct login_phase1_struct *logininfo;
202 struct aim_conn_t *bosconn = NULL;
204 va_start(ap, command);
205 logininfo = va_arg(ap, struct login_phase1_struct *);
208 printf("Screen name: %s\n", logininfo->screen_name);
209 printf("Reg status: %2d\n", logininfo->regstatus);
210 printf("Email: %s\n", logininfo->email);
211 printf("Cookie len: %d\n", sizeof(logininfo->cookie));
212 printf("BOS IP: %s\n", logininfo->BOSIP);
214 printf("Closing auth connection...\n");
215 aim_conn_close(command->conn);
216 bosconn = aim_newconn(AIM_CONN_TYPE_BOS, logininfo->BOSIP);
217 aim_auth_sendcookie(bosconn, logininfo->cookie);
222 int faimtest_authsvrready(struct command_rx_struct *command, ...)
224 /* should just be able to tell it we're ready too... */
225 aim_auth_clientready(command->conn);
228 * This is where you'd really begin changing your password.
229 * However, this callback may get called for reasons other
230 * than you wanting to change your password. You should
231 * probably check that before actually doing it.
233 //aim_auth_changepasswd(command->conn, "Fritz", "1Fritz");
238 int faimtest_pwdchngdone(struct command_rx_struct *command, ...)
240 printf("PASSWORD CHANGE SUCCESSFUL!!!\n");