Mercurial > pidgin
comparison src/oscar.c @ 270:cfa39d39dec6
[gaim-migrate @ 280]
Fixed the 100% bug, but in doing so, broke permit/deny lists, so that got
commented out (yet again). Gaim/Faim is now usable.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 26 May 2000 23:10:21 +0000 |
parents | 5c19f91e7ce4 |
children | 4c6c213646a3 |
comparison
equal
deleted
inserted
replaced
269:46b6b894bc48 | 270:cfa39d39dec6 |
---|---|
56 static int gaim_chat_join (struct aim_session_t *, struct command_rx_struct *, ...); | 56 static int gaim_chat_join (struct aim_session_t *, struct command_rx_struct *, ...); |
57 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); | 57 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); |
58 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); | 58 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); |
59 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); | 59 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); |
60 | 60 |
61 /* FIXME ! This uses 100% of the CPU, guaranteed. It's not using aim_select | |
62 * anymore, which is a good thing, but gdk still thinks there's always data | |
63 * to be read, even though aim_get_command and aim_rxdispatch have already | |
64 * taken care of the data that there was. So, it constantly calls this, and | |
65 * it acts basically like an infinite loop that actually does some work, and | |
66 * eats all of your CPU. | |
67 */ | |
68 static void oscar_callback(gpointer data, gint source, | 61 static void oscar_callback(gpointer data, gint source, |
69 GdkInputCondition condition) { | 62 GdkInputCondition condition) { |
70 struct aim_session_t *sess = (struct aim_session_t *)data; | 63 struct aim_session_t *sess = (struct aim_session_t *)data; |
71 | 64 |
72 if (condition & GDK_INPUT_EXCEPTION) { | 65 if (condition & GDK_INPUT_EXCEPTION) { |
73 signoff(); | 66 signoff(); |
74 hide_login_progress("Disconnected."); | 67 hide_login_progress("Disconnected."); |
75 aim_logoff(sess); | 68 aim_logoff(sess); |
76 gdk_input_remove(inpa); | 69 gdk_input_remove(inpa); |
77 return; | 70 return; |
78 } | |
79 if (condition & GDK_INPUT_WRITE) { | |
80 aim_tx_flushqueue(sess); | |
81 } | 71 } |
82 if (condition & GDK_INPUT_READ) { | 72 if (condition & GDK_INPUT_READ) { |
83 if (aim_get_command(sess, gaim_conn) < 0) { | 73 if (aim_get_command(sess, gaim_conn) < 0) { |
84 debug_print("connection error!\n"); | 74 debug_print("connection error!\n"); |
85 signoff(); | 75 signoff(); |
140 AIM_CB_GEN_SERVERREADY, | 130 AIM_CB_GEN_SERVERREADY, |
141 gaim_auth_server_ready, 0); | 131 gaim_auth_server_ready, 0); |
142 aim_send_login(sess, conn, username, password, &info); | 132 aim_send_login(sess, conn, username, password, &info); |
143 | 133 |
144 gaim_conn = conn; | 134 gaim_conn = conn; |
145 inpa = gdk_input_add(conn->fd, | 135 inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
146 GDK_INPUT_READ | GDK_INPUT_WRITE | GDK_INPUT_EXCEPTION, | |
147 oscar_callback, sess); | 136 oscar_callback, sess); |
148 | 137 |
149 u = find_user(username); | 138 u = find_user(username); |
150 | 139 |
151 if (!u) { | 140 if (!u) { |
163 return 0; | 152 return 0; |
164 } | 153 } |
165 | 154 |
166 int oscar_send_im(char *name, char *msg, int away) { | 155 int oscar_send_im(char *name, char *msg, int away) { |
167 if (away) | 156 if (away) |
168 aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, msg); | 157 return aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, msg); |
169 else | 158 else |
170 aim_send_im(gaim_sess, gaim_conn, name, 0, msg); | 159 return aim_send_im(gaim_sess, gaim_conn, name, 0, msg); |
171 } | 160 } |
172 | 161 |
173 void oscar_close() { | 162 void oscar_close() { |
174 #ifdef USE_APPLET | 163 #ifdef USE_APPLET |
175 setUserState(offline); | 164 setUserState(offline); |
178 if (inpa > 0) | 167 if (inpa > 0) |
179 gdk_input_remove(inpa); | 168 gdk_input_remove(inpa); |
180 inpa = -1; | 169 inpa = -1; |
181 aim_logoff(gaim_sess); | 170 aim_logoff(gaim_sess); |
182 } | 171 } |
172 | |
173 extern void auth_failed(); | |
183 | 174 |
184 int gaim_parse_auth_resp(struct aim_session_t *sess, | 175 int gaim_parse_auth_resp(struct aim_session_t *sess, |
185 struct command_rx_struct *command, ...) { | 176 struct command_rx_struct *command, ...) { |
186 struct aim_conn_t *bosconn = NULL; | 177 struct aim_conn_t *bosconn = NULL; |
187 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n", | 178 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n", |
200 #endif | 191 #endif |
201 set_state(STATE_OFFLINE); | 192 set_state(STATE_OFFLINE); |
202 hide_login_progress("Authentication Failed"); | 193 hide_login_progress("Authentication Failed"); |
203 gdk_input_remove(inpa); | 194 gdk_input_remove(inpa); |
204 aim_conn_close(command->conn); | 195 aim_conn_close(command->conn); |
196 auth_failed(); | |
205 return 0; | 197 return 0; |
206 } | 198 } |
207 | 199 |
208 | 200 |
209 sprintf(debug_buff, "Email: %s\n", sess->logininfo.email); | 201 sprintf(debug_buff, "Email: %s\n", sess->logininfo.email); |
246 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0); | 238 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0); |
247 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); | 239 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); |
248 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | 240 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); |
249 | 241 |
250 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie); | 242 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie); |
251 inpa = gdk_input_add(bosconn->fd, | 243 inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
252 GDK_INPUT_READ | GDK_INPUT_WRITE | GDK_INPUT_EXCEPTION, | |
253 oscar_callback, sess); | 244 oscar_callback, sess); |
254 set_login_progress(4, "Connection established, cookie sent"); | 245 set_login_progress(4, "Connection established, cookie sent"); |
255 return 1; | 246 return 1; |
256 } | 247 } |
257 | 248 |
293 break; | 284 break; |
294 } | 285 } |
295 return 1; | 286 return 1; |
296 } | 287 } |
297 | 288 |
289 extern void gaim_setup(); | |
290 extern int bud_list_cache_exists(); | |
291 extern void do_import(GtkWidget *w, void *dummy); | |
292 | |
298 int gaim_handle_redirect(struct aim_session_t *sess, | 293 int gaim_handle_redirect(struct aim_session_t *sess, |
299 struct command_rx_struct *command, ...) { | 294 struct command_rx_struct *command, ...) { |
300 va_list ap; | 295 va_list ap; |
301 int serviceid; | 296 int serviceid; |
302 char *ip; | 297 char *ip; |
315 aim_bos_setbuddylist(sess, command->conn, buddies); | 310 aim_bos_setbuddylist(sess, command->conn, buddies); |
316 aim_bos_setprofile(sess, command->conn, profile, | 311 aim_bos_setprofile(sess, command->conn, profile, |
317 NULL, AIM_CAPS_CHAT); | 312 NULL, AIM_CAPS_CHAT); |
318 | 313 |
319 aim_bos_clientready(sess, command->conn); | 314 aim_bos_clientready(sess, command->conn); |
315 | |
316 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
320 | 317 |
321 gaim_sess = sess; | 318 gaim_sess = sess; |
322 gaim_conn = command->conn; | 319 gaim_conn = command->conn; |
323 | 320 |
324 debug_print("Roger that, all systems go\n"); | 321 debug_print("Roger that, all systems go\n"); |
450 /* channel 1: standard message */ | 447 /* channel 1: standard message */ |
451 if (channel == 1) { | 448 if (channel == 1) { |
452 struct aim_userinfo_s *userinfo; | 449 struct aim_userinfo_s *userinfo; |
453 char *msg = NULL; | 450 char *msg = NULL; |
454 u_int icbmflags = 0; | 451 u_int icbmflags = 0; |
455 char *tmpstr = NULL; | |
456 u_short flag1, flag2; | 452 u_short flag1, flag2; |
457 | 453 |
458 userinfo = va_arg(ap, struct aim_userinfo_s *); | 454 userinfo = va_arg(ap, struct aim_userinfo_s *); |
459 msg = va_arg(ap, char *); | 455 msg = va_arg(ap, char *); |
460 icbmflags = va_arg(ap, u_int); | 456 icbmflags = va_arg(ap, u_int); |
671 break; | 667 break; |
672 bcs = bcs->next; | 668 bcs = bcs->next; |
673 b = NULL; | 669 b = NULL; |
674 } | 670 } |
675 if (!b) | 671 if (!b) |
676 return; | 672 return 0; |
677 | 673 |
678 serv_got_chat_in(b->id, info->sn, 0, msg); | 674 serv_got_chat_in(b->id, info->sn, 0, msg); |
679 | 675 |
680 return 1; | 676 return 1; |
681 } | 677 } |