# HG changeset patch # User Eric Warmenhoven # Date 971377176 0 # Node ID 82c5865f7cfe0094f1cebe6ed2870889fedc8073 # Parent ae6d13c11570524cac1a8fb2bf3a23f99d757a87 [gaim-migrate @ 990] i hope this works committer: Tailor Script diff -r ae6d13c11570 -r 82c5865f7cfe HACKING --- a/HACKING Thu Oct 12 09:02:56 2000 +0000 +++ b/HACKING Thu Oct 12 18:59:36 2000 +0000 @@ -34,7 +34,7 @@ of the information that's printed is useless anyway though; so the --enable-debug option really doesn't do a whole lot. -This file was last modified by $Author: warmenhoven $ on $Date: 2000-10-12 05:02:56 -0400 (Thu, 12 Oct 2000) $. +This file was last modified by $Author: warmenhoven $ on $Date: 2000-10-12 14:59:36 -0400 (Thu, 12 Oct 2000) $. PROGRAM FLOW @@ -52,9 +52,8 @@ username and the password for the account. If the password length is zero (the password field is a character array rather than pointer so it will not be NULL) then the Signon callback will prompt for the -password before calling serv_login. serv_login then finds the user, -and signs in using the specified protocol. (This is a bad way of doing -things and should be fixed.) We'll assume TOC for the rest of this +password before calling serv_login. serv_login then signs in the user +using the appropriate protocol. We'll assume TOC for the rest of this discussion; Oscar has a lot of bad hacks to get it working that I don't even want to think about. diff -r ae6d13c11570 -r 82c5865f7cfe src/buddy.c --- a/src/buddy.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/buddy.c Thu Oct 12 18:59:36 2000 +0000 @@ -1176,6 +1176,7 @@ who = g_strdup(normalize(name)); + /* FIXME: we should decide somewhere who we're pouncing as */ while(bp) { b = (struct buddy_pounce *)bp->data;; bp = bp->next; /* increment the list here because rem_bp can make our handle bad */ @@ -1195,7 +1196,7 @@ write_to_conv(c, b->message, WFLAG_SEND, NULL); - serv_send_im(name, b->message, 0); + serv_send_im(c->gc, name, b->message, 0); } rem_bp(NULL, b); diff -r ae6d13c11570 -r 82c5865f7cfe src/conversation.c --- a/src/conversation.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/conversation.c Thu Oct 12 18:59:36 2000 +0000 @@ -696,7 +696,7 @@ write_to_conv(c, buf3, WFLAG_SEND, NULL); g_free(buf3); - serv_send_im(c->name, buf, 0); + serv_send_im(c->gc, c->name, buf, 0); if (c->makesound && (sound_options & OPT_SOUND_SEND)) play_sound(SEND); diff -r ae6d13c11570 -r 82c5865f7cfe src/gaim.h --- a/src/gaim.h Thu Oct 12 09:02:56 2000 +0000 +++ b/src/gaim.h Thu Oct 12 18:59:36 2000 +0000 @@ -624,11 +624,11 @@ /* Functions in server.c */ /* input to serv */ -extern struct gaim_connection *serv_login(char *, char *); +extern void serv_login(struct aim_user *); extern void serv_close(struct gaim_connection *); extern void serv_touch_idle(struct gaim_connection *); extern void serv_finish_login(); -extern void serv_send_im(char *, char *, int); +extern void serv_send_im(struct gaim_connection *, char *, char *, int); extern void serv_get_info(char *); extern void serv_get_away_msg(char *); extern void serv_get_dir(char *); @@ -700,7 +700,7 @@ extern int connect_address(unsigned int, unsigned short); /* Functions in oscar.c */ -extern struct gaim_connection *oscar_login(char *, char *); +extern void oscar_login(struct aim_user *); extern void oscar_close(struct gaim_connection *); extern struct chat_connection *find_oscar_chat(struct gaim_connection *, char *name); extern void oscar_do_directim(struct gaim_connection *, char *); @@ -708,7 +708,7 @@ /* Functions in toc.c */ extern void toc_close(); -extern struct gaim_connection *toc_login(char *, char *); +extern void toc_login(struct aim_user *); extern int toc_wait_signon(struct gaim_connection *); extern char *toc_wait_config(struct gaim_connection *); extern int sflap_send(struct gaim_connection *, char *, int , int ); diff -r ae6d13c11570 -r 82c5865f7cfe src/multi.c --- a/src/multi.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/multi.c Thu Oct 12 18:59:36 2000 +0000 @@ -82,15 +82,6 @@ void destroy_gaim_conn(struct gaim_connection *gc) { - switch (gc->protocol) { - case PROTO_TOC: - break; - case PROTO_OSCAR: - break; - default: - /* PRPL */ - break; - } connections = g_slist_remove(connections, gc); g_free(gc); redo_convo_menus(); @@ -454,17 +445,13 @@ static void pass_signon(GtkWidget *w, struct aim_user *u) { char *txt = gtk_entry_get_text(GTK_ENTRY(u->passentry)); - char *un, *ps; + g_snprintf(u->password, sizeof(u->password), "%s", txt); #ifdef USE_APPLET set_user_state(signing_on); #endif - un = g_strdup(u->username); - ps = g_strdup(txt); gtk_widget_destroy(u->passprmt); u->passprmt = NULL; - serv_login(un, ps); - g_free(un); - g_free(ps); + serv_login(u); } static void do_pass_dlg(struct aim_user *u) @@ -537,19 +524,13 @@ u = find_user(name); gc = find_gaim_conn_by_name(name); if (!gc) { - char *un, *ps; if (!u->password[0]) { do_pass_dlg(u); } else { #ifdef USE_APPLET set_user_state(signing_on); #endif /* USE_APPLET */ - - un = g_strdup(u->username); - ps = g_strdup(u->password); - gc = serv_login(un, ps); - g_free(un); - g_free(ps); + serv_login(u); } } else { signoff(gc); @@ -660,7 +641,6 @@ { GList *u = aim_users; struct aim_user *a = NULL; - char *un, *ps; while (u) { a = (struct aim_user *)u->data; @@ -668,12 +648,7 @@ #ifdef USE_APPLET set_user_state(signing_on); #endif /* USE_APPLET */ - - un = g_strdup(a->username); - ps = g_strdup(a->password); - serv_login(un, ps); - g_free(un); - g_free(ps); + serv_login(a); } u = u->next; } diff -r ae6d13c11570 -r 82c5865f7cfe src/oscar.c --- a/src/oscar.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/oscar.c Thu Oct 12 18:59:36 2000 +0000 @@ -249,17 +249,16 @@ } } -struct gaim_connection *oscar_login(char *username, char *password) { +void oscar_login(struct aim_user *user) { struct aim_session_t *sess; struct aim_conn_t *conn; - struct aim_user *u; char buf[256]; struct gaim_connection *gc; - sprintf(debug_buff, _("Logging in %s\n"), username); + sprintf(debug_buff, _("Logging in %s\n"), user->username); debug_print(debug_buff); - gc = new_gaim_conn(PROTO_OSCAR, username, password); + gc = new_gaim_conn(PROTO_OSCAR, user->username, user->password); sess = g_new0(struct aim_session_t, 1); aim_session_init(sess); /* we need an immediate queue because we don't use a while-loop to @@ -274,7 +273,7 @@ debug_print(_("internal connection error\n")); hide_login_progress(gc->username, _("Unable to login to AIM")); destroy_gaim_conn(gc); - return NULL; + return; } else if (conn->fd == -1) { if (conn->status & AIM_CONN_STATUS_RESOLVERR) { sprintf(debug_buff, _("couldn't resolve host")); @@ -286,26 +285,23 @@ hide_login_progress(gc->username, debug_buff); } destroy_gaim_conn(gc); - return NULL; + return; } - g_snprintf(buf, sizeof(buf), _("Signon: %s"), username); + g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); aim_sendconnack(sess, conn); - aim_request_login(sess, conn, username); + aim_request_login(sess, conn, gc->username); gc->inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, conn); - u = find_user(username); - sprintf(gc->user_info, "%s", u->user_info); - gc->options = u->options; - save_prefs(); + sprintf(gc->user_info, "%s", user->user_info); + gc->options = user->options; + save_prefs(); /* is this necessary anymore? */ debug_print(_("Password sent, waiting for response\n")); - - return gc; } void oscar_close(struct gaim_connection *gc) { diff -r ae6d13c11570 -r 82c5865f7cfe src/perl.c --- a/src/perl.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/perl.c Thu Oct 12 18:59:36 2000 +0000 @@ -461,6 +461,7 @@ XS (XS_AIM_print_to_conv) { + /* FIXME char *nick, *what; struct conversation *c; int junk; @@ -474,6 +475,7 @@ c = new_conversation(nick); write_to_conv(c, what, WFLAG_SEND, NULL); serv_send_im(nick, what, 0); + */ } XS (XS_AIM_print_to_chat) diff -r ae6d13c11570 -r 82c5865f7cfe src/server.c --- a/src/server.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/server.c Thu Oct 12 18:59:36 2000 +0000 @@ -40,18 +40,13 @@ int correction_time = 0; -struct gaim_connection *serv_login(char *username, char *password) +void serv_login(struct aim_user *user) { - struct aim_user *u = find_user(username); - - if (u->protocol == PROTO_TOC) { - return toc_login(username, password); - } else if (u->protocol == PROTO_OSCAR) { + if (user->protocol == PROTO_TOC) { + toc_login(user); + } else if (user->protocol == PROTO_OSCAR) { debug_print("Logging in using Oscar. Expect problems.\n"); - return oscar_login(username, password); - } else { - /* PRPL */ - return NULL; + oscar_login(user); } } @@ -61,7 +56,6 @@ toc_close(gc); else if (gc->protocol == PROTO_OSCAR) oscar_close(gc); - else /* PRPL */ ; account_offline(gc); destroy_gaim_conn(gc); @@ -137,35 +131,31 @@ -void serv_send_im(char *name, char *message, int away) +void serv_send_im(struct gaim_connection *gc, char *name, char *message, int away) { struct conversation *cnv = find_conversation(name); - if (cnv && cnv->is_direct) { - if (cnv->gc->protocol == PROTO_OSCAR) { + if (cnv && cnv->is_direct && (gc->protocol == PROTO_OSCAR)) { debug_printf("Sending DirectIM to %s\n", name); - aim_send_im_direct(cnv->gc->oscar_sess, cnv->conn, message); - } else { - /* Direct IM TOC FIXME */ - } + aim_send_im_direct(gc->oscar_sess, cnv->conn, message); } else { - if (cnv->gc->protocol == PROTO_TOC) { + if (gc->protocol == PROTO_TOC) { char buf[MSG_LEN - 7]; escape_text(message); g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), message, ((away) ? " auto" : "")); - sflap_send(cnv->gc, buf, -1, TYPE_DATA); - } else if (cnv->gc->protocol == PROTO_OSCAR) { + sflap_send(gc, buf, -1, TYPE_DATA); + } else if (gc->protocol == PROTO_OSCAR) { if (away) - aim_send_im(cnv->gc->oscar_sess, cnv->gc->oscar_conn, + aim_send_im(gc->oscar_sess, gc->oscar_conn, name, AIM_IMFLAGS_AWAY, message); else - aim_send_im(cnv->gc->oscar_sess, cnv->gc->oscar_conn, + aim_send_im(gc->oscar_sess, gc->oscar_conn, name, AIM_IMFLAGS_ACK, message); } } if (!away) - serv_touch_idle(cnv->gc); + serv_touch_idle(gc); } void serv_get_info(char *name) @@ -702,7 +692,7 @@ !strcmp(message, ">>>Automated Message: Getting Away Message<<<")) { char *tmpmsg = stylize(awaymessage->message, MSG_LEN); - serv_send_im(name, tmpmsg, 1); + serv_send_im(gc, name, tmpmsg, 1); g_free(tmpmsg); return; } @@ -772,7 +762,7 @@ escape_text(tmpmsg); escape_message(tmpmsg); } - serv_send_im(name, away_subs(tmpmsg, alias), 1); + serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); g_free(tmpmsg); tmpmsg = stylize(awaymessage->message, MSG_LEN); @@ -972,8 +962,6 @@ } else if (g->protocol == PROTO_OSCAR) { gtk_object_set_user_data(GTK_OBJECT(d), (void *)g_strdup(name)); gtk_object_set_user_data(GTK_OBJECT(yesbtn), (void *)id); - } else { - /* PRPL */ } diff -r ae6d13c11570 -r 82c5865f7cfe src/toc.c --- a/src/toc.c Thu Oct 12 09:02:56 2000 +0000 +++ b/src/toc.c Thu Oct 12 18:59:36 2000 +0000 @@ -39,7 +39,7 @@ #include "gaim.h" #include "gnome_applet_mgr.h" -#define REVISION "gaim:$Revision: 988 $" +#define REVISION "gaim:$Revision: 990 $" static unsigned int peer_ver=0; @@ -54,11 +54,10 @@ /* ok. this function used to take username/password, and return 0 on success. * now, it takes username/password, and returns NULL on error or a new gaim_connection * on success. */ -struct gaim_connection *toc_login(char *username, char *password) +void toc_login(struct aim_user *user) { char *config; struct in_addr *sin; - struct aim_user *u; struct gaim_connection *gc; char buf[80]; char buf2[2048]; @@ -68,8 +67,8 @@ sin = (struct in_addr *)get_address(aim_host); if (!sin) { g_snprintf(buf, sizeof(buf), "Unable to lookup %s", aim_host); - hide_login_progress(username, buf); - return NULL; + hide_login_progress(user->username, buf); + return; } g_snprintf(toc_addy, sizeof(toc_addy), "%s", inet_ntoa(*sin)); @@ -77,7 +76,7 @@ - gc = new_gaim_conn(PROTO_TOC, username, password); + gc = new_gaim_conn(PROTO_TOC, user->username, user->password); gc->toc_fd = connect_address(sin->s_addr, aim_port); @@ -86,29 +85,28 @@ inet_ntoa(*sin)); hide_login_progress(gc->username, buf); destroy_gaim_conn(gc); - return NULL; + return; } g_free(sin); - g_snprintf(buf, sizeof(buf), "Signon: %s",username); + g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username); if (toc_signon(gc) < 0) { hide_login_progress(gc->username, "Disconnected."); destroy_gaim_conn(gc); - return NULL; + return; } g_snprintf(buf, sizeof(buf), "Waiting for reply..."); if (toc_wait_signon(gc) < 0) { hide_login_progress(gc->username, "Authentication Failed"); destroy_gaim_conn(gc); - return NULL; + return; } - u = find_user(username); - sprintf(gc->user_info, "%s", u->user_info); - gc->options = u->options; + sprintf(gc->user_info, "%s", user->user_info); + gc->options = user->options; save_prefs(); g_snprintf(buf, sizeof(buf), "Retrieving config..."); @@ -152,7 +150,6 @@ serv_finish_login(gc); gaim_setup(gc); - return 0; } void toc_close(struct gaim_connection *gc)