Mercurial > pidgin.yaz
changeset 7282:ad243bc63184
[gaim-migrate @ 7861]
Mostly this is my usual blah clean-up/changes.
I started merging that icq sms patch, but I'm not comfortable
with much of it...
I also made AIM have 6 login steps instead of 2. The first
few go pretty quickly though. I'll probably work on this
more later, but I'm going to sleep now.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 16 Oct 2003 06:12:43 +0000 |
parents | 0f7dd6715a90 |
children | b8fcbff88438 |
files | src/protocols/oscar/aim.h src/protocols/oscar/auth.c src/protocols/oscar/bos.c src/protocols/oscar/buddylist.c src/protocols/oscar/conn.c src/protocols/oscar/email.c src/protocols/oscar/icq.c src/protocols/oscar/im.c src/protocols/oscar/locate.c src/protocols/oscar/misc.c src/protocols/oscar/oscar.c src/protocols/oscar/service.c src/protocols/oscar/ssi.c |
diffstat | 13 files changed, 141 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/aim.h Thu Oct 16 06:12:43 2003 +0000 @@ -375,8 +375,6 @@ } aim_msgcookie_t; /* Values for sess->flags */ -#define AIM_SESS_FLAGS_SNACLOGIN 0x00000001 -#define AIM_SESS_FLAGS_XORLOGIN 0x00000002 #define AIM_SESS_FLAGS_NONBLOCKCONNECT 0x00000004 #define AIM_SESS_FLAGS_DONTTIMEOUTONICBM 0x00000008 @@ -1349,8 +1347,8 @@ struct aim_emailinfo *next; }; -faim_export int aim_email_sendcookies(aim_session_t *sess, aim_conn_t *conn); -faim_export int aim_email_activate(aim_session_t *sess, aim_conn_t *conn); +faim_export int aim_email_sendcookies(aim_session_t *sess); +faim_export int aim_email_activate(aim_session_t *sess);
--- a/src/protocols/oscar/auth.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/auth.c Thu Oct 16 06:12:43 2003 +0000 @@ -11,6 +11,8 @@ #include "md5.h" +#include <ctype.h> + /** * Encode a password using old XOR method * @@ -221,11 +223,8 @@ if (!ci || !sn || !password) return -EINVAL; - /* - * What the XORLOGIN flag _really_ means is that its an ICQ login, - * which is really stupid and painful, so its not done here. - */ - if (sess->flags & AIM_SESS_FLAGS_XORLOGIN) + /* If we're signing on an ICQ account then use the older, XOR login method */ + if (isdigit(sn[0])) return goddamnicq2(sess, conn, sn, password, ci); if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) @@ -443,9 +442,6 @@ aim_frame_t fr; aim_rxcallback_t userfunc; - sess->flags &= ~AIM_SESS_FLAGS_SNACLOGIN; - sess->flags |= AIM_SESS_FLAGS_XORLOGIN; - fr.conn = conn; if ((userfunc = aim_callhandler(sess, conn, 0x0017, 0x0007))) @@ -476,8 +472,6 @@ if ((sn[0] >= '0') && (sn[0] <= '9')) return goddamnicq(sess, conn, sn); - sess->flags |= AIM_SESS_FLAGS_SNACLOGIN; - aim_sendflapver(sess, conn); if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+2+strlen(sn) /*+8*/ )))
--- a/src/protocols/oscar/bos.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/bos.c Thu Oct 16 06:12:43 2003 +0000 @@ -12,7 +12,7 @@ /* Subtype 0x0002 - Request BOS rights. */ faim_export int aim_bos_reqrights(aim_session_t *sess, aim_conn_t *conn) { - return aim_genericreq_n(sess, conn, 0x0009, 0x0002); + return aim_genericreq_n_snacid(sess, conn, 0x0009, 0x0002); } /* Subtype 0x0003 - BOS Rights. */
--- a/src/protocols/oscar/buddylist.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/buddylist.c Thu Oct 16 06:12:43 2003 +0000 @@ -16,7 +16,7 @@ */ faim_export int aim_bos_reqbuddyrights(aim_session_t *sess, aim_conn_t *conn) { - return aim_genericreq_n(sess, conn, 0x0003, 0x0002); + return aim_genericreq_n_snacid(sess, conn, 0x0003, 0x0002); } /*
--- a/src/protocols/oscar/conn.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/conn.c Thu Oct 16 06:12:43 2003 +0000 @@ -852,13 +852,12 @@ } /** - * aim_session_init - Initializes a session structure - * @sess: Session to initialize - * @flags: Flags to use. Any of %AIM_SESS_FLAGS %OR'd together. - * @debuglevel: Level of debugging output (zero is least) + * Initializes a session structure by setting the initial values + * stuff in the aim_session_t struct. * - * Sets up the initial values for a session. - * + * @param sess Session to initialize. + * @param flags Flags to use. nAny of %AIM_SESS_FLAGS %OR'd together. + * @param debuglevel Level of debugging output (zero is least). */ faim_export void aim_session_init(aim_session_t *sess, fu32_t flags, int debuglevel) { @@ -896,11 +895,6 @@ sess->authinfo = NULL; - /* - * Default to SNAC login unless XORLOGIN is explicitly set. - */ - if (!(flags & AIM_SESS_FLAGS_XORLOGIN)) - sess->flags |= AIM_SESS_FLAGS_SNACLOGIN; sess->flags |= flags; /*
--- a/src/protocols/oscar/email.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/email.c Thu Oct 16 06:12:43 2003 +0000 @@ -18,12 +18,13 @@ * @param conn The email connection for this session. * @return Return 0 if no errors, otherwise return the error number. */ -faim_export int aim_email_sendcookies(aim_session_t *sess, aim_conn_t *conn) +faim_export int aim_email_sendcookies(aim_session_t *sess) { + aim_conn_t *conn; aim_frame_t *fr; aim_snacid_t snacid; - if (!sess || !conn) + if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_EML))) return -EINVAL; if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+2+16+16))) @@ -140,12 +141,13 @@ * @param conn The email connection for this session. * @return Return 0 if no errors, otherwise return the error number. */ -faim_export int aim_email_activate(aim_session_t *sess, aim_conn_t *conn) +faim_export int aim_email_activate(aim_session_t *sess) { + aim_conn_t *conn; aim_frame_t *fr; aim_snacid_t snacid; - if (!sess || !conn) + if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_EML))) return -EINVAL; if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+1+16)))
--- a/src/protocols/oscar/icq.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/icq.c Thu Oct 16 06:12:43 2003 +0000 @@ -320,6 +320,99 @@ return 0; } +/* + * Send an SMS message. This is the non-US way. The US-way is to IM + * their cell phone number (+19195551234). + * + * We basically construct and send an XML message. The format is: + * <icq_sms_message> + * <destination>full_phone_without_leading_+</destination> + * <text>message</text> + * <codepage>1252</codepage> + * <senders_UIN>self_uin</senders_UIN> + * <senders_name>self_name</senders_name> + * <delivery_receipt>Yes|No</delivery_receipt> + * <time>Wkd, DD Mmm YYYY HH:MM:SS TMZ</time> + * </icq_sms_message> + * + * Yeah hi Peter, whaaaat's happening. If there's any way to use + * a codepage other than 1252 that would be great. Thaaaanks. + */ +faim_export int aim_icq_sendsms(aim_session_t *sess, const char *name, const char *msg, const char *alias) +{ + aim_conn_t *conn; + aim_frame_t *fr; + aim_snacid_t snacid; + int bslen, xmllen; + char *xml, timestr[30]; + time_t t; + struct tm *tm; + + if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) + return -EINVAL; + + if (!name || !msg || !alias) + return -EINVAL; + + time(&t); + tm = gmtime(&t); + strftime(timestr, 30, "%a, %d %b %Y %T %Z", tm); + + /* The length of xml included the null terminating character */ + xmllen = 500 + strlen(name) + strlen(msg) + strlen(sess->sn) + strlen(alias) + strlen(timestr) + 1; + + if (!(xml = (char *)malloc(xmllen*sizeof(char)))) + return -ENOMEM; + snprintf(xml, xmllen, "<icq_sms_message>\n" + "\t<destination>%s</destination>\n" + "\t<text>%s</text>\n" + "\t<codepage>1252</codepage>\n" + "\t<senders_UIN>%s</senders_UIN>\n" + "\t<senders_name>%s</senders_name>\n" + "\t<delivery_receipt>Yes</delivery_receipt>\n" + "\t<time>%s</time>\n" + "</icq_sms_message>\n", + name, msg, sess->sn, alias, timestr); + + bslen = 37 + xmllen; + + if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) { + free(xml); + return -ENOMEM; + } + + snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); + aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); + + /* For simplicity, don't bother using a tlvlist */ + aimbs_put16(&fr->data, 0x0001); + aimbs_put16(&fr->data, bslen); + + aimbs_putle16(&fr->data, bslen - 2); + aimbs_putle32(&fr->data, atoi(sess->sn)); + aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ + aimbs_putle16(&fr->data, snacid); /* eh. */ + + /* From libicq200-0.3.2/src/SNAC-SRV.cpp */ + aimbs_putle16(&fr->data, 0x8214); + aimbs_put16(&fr->data, 0x0001); + aimbs_put16(&fr->data, 0x0016); + aimbs_put32(&fr->data, 0x00000000); + aimbs_put32(&fr->data, 0x00000000); + aimbs_put32(&fr->data, 0x00000000); + aimbs_put32(&fr->data, 0x00000000); + + aimbs_put16(&fr->data, 0x0000); + aimbs_put16(&fr->data, xmllen); + aimbs_putraw(&fr->data, xml, xmllen); + + aim_tx_enqueue(sess, fr); + + free(xml); + + return 0; +} + static void aim_icq_freeinfo(struct aim_icq_info *info) { int i;
--- a/src/protocols/oscar/im.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/im.c Thu Oct 16 06:12:43 2003 +0000 @@ -166,7 +166,7 @@ if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0004))) return -EINVAL; - return aim_genericreq_n(sess, conn, 0x0004, 0x0004); + return aim_genericreq_n_snacid(sess, conn, 0x0004, 0x0004); } /**
--- a/src/protocols/oscar/locate.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/locate.c Thu Oct 16 06:12:43 2003 +0000 @@ -842,7 +842,7 @@ if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_LOC))) return -EINVAL; - return aim_genericreq_n(sess, conn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQRIGHTS); + return aim_genericreq_n_snacid(sess, conn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQRIGHTS); } /*
--- a/src/protocols/oscar/misc.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/misc.c Thu Oct 16 06:12:43 2003 +0000 @@ -12,7 +12,6 @@ /* * Generic routine for sending commands. * - * * I know I can do this in a smarter way...but I'm not thinking straight * right now... *
--- a/src/protocols/oscar/oscar.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/oscar.c Thu Oct 16 06:12:43 2003 +0000 @@ -276,6 +276,7 @@ static gboolean gaim_icon_timerfunc(gpointer data); /* prpl actions - remove this at some point */ +/* Because I don't like forward declarations? I think that was why... */ static void oscar_set_info(GaimConnection *gc, const char *text); static void oscar_free_name_data(struct name_data *data) { @@ -626,7 +627,6 @@ od = gc->proto_data; sess = od->sess; conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); - conn->fd = source; if (source < 0) { @@ -636,14 +636,16 @@ aim_conn_completeconnect(sess, conn); gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); + aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); + gaim_debug(GAIM_DEBUG_INFO, "oscar", - "Password sent, waiting for response\n"); + "Screen name sent, waiting for response\n"); + gaim_connection_update_progress(gc, _("Screen name sent"), 1, 6); } static void oscar_login(GaimAccount *account) { aim_session_t *sess; aim_conn_t *conn; - char buf[256]; GaimConnection *gc = gaim_account_get_connection(account); struct oscar_data *od = gc->proto_data = g_new0(struct oscar_data, 1); @@ -658,12 +660,12 @@ od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); sess = g_new0(aim_session_t, 1); - aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); aim_setdebuggingcb(sess, oscar_debug); - - /* we need an immediate queue because we don't use a while-loop to - * see if things need to be sent. */ + /* + * We need an immediate queue because we don't use a while-loop + * to see if things need to be sent. + */ aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); od->sess = sess; sess->aux_data = gc; @@ -676,9 +678,6 @@ return; } - g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(account)); - gaim_connection_update_progress(gc, buf, 2, 5); - aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); @@ -690,7 +689,8 @@ gaim_connection_error(gc, _("Couldn't connect to host")); return; } - aim_request_login(sess, conn, gaim_account_get_username(account)); + + gaim_connection_update_progress(gc, _("Connecting"), 0, 6); } static void oscar_close(GaimConnection *gc) { @@ -782,7 +782,7 @@ aim_conn_completeconnect(sess, bosconn); gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); gaim_connection_update_progress(gc, - _("Connection established, cookie sent"), 4, 5); + _("Connection established, cookie sent"), 4, 6); } /* BBB */ @@ -1169,6 +1169,8 @@ aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); gaim_input_remove(gc->inpa); + gaim_connection_update_progress(gc, _("Received authorization"), 4, 6); + return 1; } @@ -1331,9 +1333,12 @@ static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { GaimConnection *gc = sess->aux_data; + struct oscar_data *od = gc->proto_data; GaimAccount *account = gaim_connection_get_account(gc); GaimAccount *ac = gaim_connection_get_account(gc); - struct oscar_data *od = gc->proto_data; +#if 0 + struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; +#endif va_list ap; char *key; @@ -1346,14 +1351,13 @@ aim_send_login(sess, fr->conn, gaim_account_get_username(ac), gaim_account_get_password(account), &info, key); } else { -#if 0 - struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; -#endif struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; aim_send_login(sess, fr->conn, gaim_account_get_username(ac), gaim_account_get_password(account), &info, key); } + gaim_connection_update_progress(gc, _("Password sent"), 3, 6); + return 1; } @@ -1394,8 +1398,8 @@ aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); - aim_email_sendcookies(sess, fr->conn); - aim_email_activate(sess, fr->conn); + aim_email_sendcookies(sess); + aim_email_activate(sess); aim_clientready(sess, fr->conn); return 1;
--- a/src/protocols/oscar/service.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/service.c Thu Oct 16 06:12:43 2003 +0000 @@ -151,7 +151,7 @@ /* Subtype 0x0006 - Request Rate Information. */ faim_internal int aim_reqrates(aim_session_t *sess, aim_conn_t *conn) { - return aim_genericreq_n(sess, conn, 0x0001, 0x0006); + return aim_genericreq_n_snacid(sess, conn, 0x0001, 0x0006); } /* @@ -491,7 +491,7 @@ /* Subtype 0x000e - Request self-info */ faim_export int aim_reqpersonalinfo(aim_session_t *sess, aim_conn_t *conn) { - return aim_genericreq_n(sess, conn, 0x0001, 0x000e); + return aim_genericreq_n_snacid(sess, conn, 0x0001, 0x000e); } /* Subtype 0x000f - Self User Info */ @@ -660,6 +660,8 @@ * WinAIM sends these every 4min or so to keep the connection alive. Its not * really necessary. * + * Wha? No? Since when? I think WinAIM sends an empty channel 3 + * SNAC as a no-op... */ faim_export int aim_nop(aim_session_t *sess, aim_conn_t *conn) {
--- a/src/protocols/oscar/ssi.c Thu Oct 16 04:35:41 2003 +0000 +++ b/src/protocols/oscar/ssi.c Thu Oct 16 06:12:43 2003 +0000 @@ -1105,7 +1105,7 @@ if (!sess || !(conn = aim_conn_findbygroup(sess, AIM_CB_FAM_SSI))) return -EINVAL; - return aim_genericreq_n(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_REQRIGHTS); + return aim_genericreq_n_snacid(sess, conn, AIM_CB_FAM_SSI, AIM_CB_SSI_REQRIGHTS); } /*