Ignore:
Timestamp:
2010-06-05T23:21:02Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1fdb0a4
Parents:
3ab1d31 (diff), e774815 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merging libpurple branch into killerbee. It's fairly usable already, and
Debian packaging is now properly separated. This also picks up a load of
stuff from mainline it seems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    r3ab1d31 rb308cf9  
    205205static int gaim_icbm_param_info  (aim_session_t *, aim_frame_t *, ...);
    206206static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...);
    207 static int gaim_memrequest       (aim_session_t *, aim_frame_t *, ...);
    208207static int gaim_selfinfo         (aim_session_t *, aim_frame_t *, ...);
    209208static int gaim_offlinemsg       (aim_session_t *, aim_frame_t *, ...);
     
    291290        odata = (struct oscar_data *)ic->proto_data;
    292291
    293         if (condition & GAIM_INPUT_READ) {
     292        if (condition & B_EV_IO_READ) {
    294293                if (aim_get_command(odata->sess, conn) >= 0) {
    295294                        aim_rxdispatch(odata->sess);
     
    363362
    364363        aim_conn_completeconnect(sess, conn);
    365         ic->inpa = b_input_add(conn->fd, GAIM_INPUT_READ,
     364        ic->inpa = b_input_add(conn->fd, B_EV_IO_READ,
    366365                        oscar_callback, conn);
    367366       
     
    493492
    494493        aim_conn_completeconnect(sess, bosconn);
    495         ic->inpa = b_input_add(bosconn->fd, GAIM_INPUT_READ,
     494        ic->inpa = b_input_add(bosconn->fd, B_EV_IO_READ,
    496495                        oscar_callback, bosconn);
    497496        imcb_log(ic, _("Connection established, cookie sent"));
     
    570569        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0);
    571570        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0);
    572         aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0);
    573571        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0);
    574572        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
     
    604602}
    605603
    606 struct pieceofcrap {
    607         struct im_connection *ic;
    608         unsigned long offset;
    609         unsigned long len;
    610         char *modname;
    611         int fd;
    612         aim_conn_t *conn;
    613         unsigned int inpa;
    614 };
    615 
    616 static gboolean damn_you(gpointer data, gint source, b_input_condition c)
    617 {
    618         struct pieceofcrap *pos = data;
    619         struct oscar_data *od = pos->ic->proto_data;
    620         char in = '\0';
    621         int x = 0;
    622         unsigned char m[17];
    623 
    624         while (read(pos->fd, &in, 1) == 1) {
    625                 if (in == '\n')
    626                         x++;
    627                 else if (in != '\r')
    628                         x = 0;
    629                 if (x == 2)
    630                         break;
    631                 in = '\0';
    632         }
    633         if (in != '\n') {
    634                 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
    635                                 " You may be disconnected shortly.");
    636                 b_event_remove(pos->inpa);
    637                 closesocket(pos->fd);
    638                 g_free(pos);
    639                 return FALSE;
    640         }
    641         /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
    642         read(pos->fd, m, 16);
    643         m[16] = '\0';
    644         b_event_remove(pos->inpa);
    645         closesocket(pos->fd);
    646         aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
    647         g_free(pos);
    648        
    649         return FALSE;
    650 }
    651 
    652 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {
    653         struct pieceofcrap *pos = data;
    654         char buf[BUF_LONG];
    655 
    656         if (source < 0) {
    657                 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
    658                                 " You may be disconnected shortly.");
    659                 if (pos->modname)
    660                         g_free(pos->modname);
    661                 g_free(pos);
    662                 return FALSE;
    663         }
    664 
    665         g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA
    666                         "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
    667                         pos->offset, pos->len, pos->modname ? pos->modname : "");
    668         write(pos->fd, buf, strlen(buf));
    669         if (pos->modname)
    670                 g_free(pos->modname);
    671         pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
    672         return FALSE;
    673 }
    674 
    675604/* size of icbmui.ocm, the largest module in AIM 3.5 */
    676605#define AIM_MAX_FILE_SIZE 98304
    677 
    678 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) {
    679         va_list ap;
    680         struct pieceofcrap *pos;
    681         guint32 offset, len;
    682         char *modname;
    683         int fd;
    684 
    685         va_start(ap, fr);
    686         offset = (guint32)va_arg(ap, unsigned long);
    687         len = (guint32)va_arg(ap, unsigned long);
    688         modname = va_arg(ap, char *);
    689         va_end(ap);
    690 
    691         if (len == 0) {
    692                 aim_sendmemblock(sess, fr->conn, offset, len, NULL,
    693                                 AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    694                 return 1;
    695         }
    696         /* uncomment this when you're convinced it's right. remember, it's been wrong before.
    697         if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {
    698                 char *buf;
    699                 int i = 8;
    700                 if (modname)
    701                         i += strlen(modname);
    702                 buf = g_malloc(i);
    703                 i = 0;
    704                 if (modname) {
    705                         memcpy(buf, modname, strlen(modname));
    706                         i += strlen(modname);
    707                 }
    708                 buf[i++] = offset & 0xff;
    709                 buf[i++] = (offset >> 8) & 0xff;
    710                 buf[i++] = (offset >> 16) & 0xff;
    711                 buf[i++] = (offset >> 24) & 0xff;
    712                 buf[i++] = len & 0xff;
    713                 buf[i++] = (len >> 8) & 0xff;
    714                 buf[i++] = (len >> 16) & 0xff;
    715                 buf[i++] = (len >> 24) & 0xff;
    716                 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    717                 g_free(buf);
    718                 return 1;
    719         }
    720         */
    721 
    722         pos = g_new0(struct pieceofcrap, 1);
    723         pos->ic = sess->aux_data;
    724         pos->conn = fr->conn;
    725 
    726         pos->offset = offset;
    727         pos->len = len;
    728         pos->modname = modname ? g_strdup(modname) : NULL;
    729 
    730         fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos);
    731         if (fd < 0) {
    732                 if (pos->modname)
    733                         g_free(pos->modname);
    734                 g_free(pos);
    735                 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM."
    736                                 " You may be disconnected shortly.");
    737         }
    738         pos->fd = fd;
    739 
    740         return 1;
    741 }
    742606
    743607static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
     
    838702
    839703        aim_conn_completeconnect(sess, tstconn);
    840         odata->cnpa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
     704        odata->cnpa = b_input_add(tstconn->fd, B_EV_IO_READ,
    841705                                        oscar_callback, tstconn);
    842706       
     
    866730
    867731        aim_conn_completeconnect(sess, tstconn);
    868         odata->paspa = b_input_add(tstconn->fd, GAIM_INPUT_READ,
     732        odata->paspa = b_input_add(tstconn->fd, B_EV_IO_READ,
    869733                                oscar_callback, tstconn);
    870734       
     
    902766        aim_conn_completeconnect(sess, ccon->conn);
    903767        ccon->inpa = b_input_add(tstconn->fd,
    904                         GAIM_INPUT_READ,
     768                        B_EV_IO_READ,
    905769                        oscar_callback, tstconn);
    906770        odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon);
     
    26512515        char * chatname;
    26522516       
    2653         chatname = g_strdup_printf("%s%d", ic->acc->user, chat_id++);
     2517        chatname = g_strdup_printf("%s%s_%d", isdigit(*ic->acc->user) ? "icq_" : "",
     2518                                   ic->acc->user, chat_id++);
    26542519 
    26552520        ret = oscar_chat_join(ic, chatname, NULL, NULL);
Note: See TracChangeset for help on using the changeset viewer.