Changeset 3429b58 for protocols/oscar


Ignore:
Timestamp:
2010-05-13T22:05:13Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
704dd38
Parents:
58f5ef7 (diff), 3742fb6 (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:

Mainline merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/oscar/oscar.c

    r58f5ef7 r3429b58  
    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 *, ...);
     
    568567        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ERROR, gaim_parse_genericerr, 0);
    569568        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BOS, AIM_CB_BOS_ERROR, gaim_parse_genericerr, 0);
    570         aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, 0x1f, gaim_memrequest, 0);
    571569        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SELFINFO, gaim_selfinfo, 0);
    572570        aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
     
    602600}
    603601
    604 struct pieceofcrap {
    605         struct im_connection *ic;
    606         unsigned long offset;
    607         unsigned long len;
    608         char *modname;
    609         int fd;
    610         aim_conn_t *conn;
    611         unsigned int inpa;
    612 };
    613 
    614 static gboolean damn_you(gpointer data, gint source, b_input_condition c)
    615 {
    616         struct pieceofcrap *pos = data;
    617         struct oscar_data *od = pos->ic->proto_data;
    618         char in = '\0';
    619         int x = 0;
    620         unsigned char m[17];
    621 
    622         while (read(pos->fd, &in, 1) == 1) {
    623                 if (in == '\n')
    624                         x++;
    625                 else if (in != '\r')
    626                         x = 0;
    627                 if (x == 2)
    628                         break;
    629                 in = '\0';
    630         }
    631         if (in != '\n') {
    632                 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
    633                                 " You may be disconnected shortly.");
    634                 b_event_remove(pos->inpa);
    635                 closesocket(pos->fd);
    636                 g_free(pos);
    637                 return FALSE;
    638         }
    639         /* [WvG] Wheeeee! Who needs error checking anyway? ;-) */
    640         read(pos->fd, m, 16);
    641         m[16] = '\0';
    642         b_event_remove(pos->inpa);
    643         closesocket(pos->fd);
    644         aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH);
    645         g_free(pos);
    646        
    647         return FALSE;
    648 }
    649 
    650 static gboolean straight_to_hell(gpointer data, gint source, b_input_condition cond) {
    651         struct pieceofcrap *pos = data;
    652         char buf[BUF_LONG];
    653 
    654         if (source < 0) {
    655                 imcb_error(pos->ic, "Gaim was unable to get a valid hash for logging into AIM."
    656                                 " You may be disconnected shortly.");
    657                 if (pos->modname)
    658                         g_free(pos->modname);
    659                 g_free(pos);
    660                 return FALSE;
    661         }
    662 
    663         g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA
    664                         "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n",
    665                         pos->offset, pos->len, pos->modname ? pos->modname : "");
    666         write(pos->fd, buf, strlen(buf));
    667         if (pos->modname)
    668                 g_free(pos->modname);
    669         pos->inpa = b_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos);
    670         return FALSE;
    671 }
    672 
    673602/* size of icbmui.ocm, the largest module in AIM 3.5 */
    674603#define AIM_MAX_FILE_SIZE 98304
    675 
    676 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) {
    677         va_list ap;
    678         struct pieceofcrap *pos;
    679         guint32 offset, len;
    680         char *modname;
    681         int fd;
    682 
    683         va_start(ap, fr);
    684         offset = (guint32)va_arg(ap, unsigned long);
    685         len = (guint32)va_arg(ap, unsigned long);
    686         modname = va_arg(ap, char *);
    687         va_end(ap);
    688 
    689         if (len == 0) {
    690                 aim_sendmemblock(sess, fr->conn, offset, len, NULL,
    691                                 AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    692                 return 1;
    693         }
    694         /* uncomment this when you're convinced it's right. remember, it's been wrong before.
    695         if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) {
    696                 char *buf;
    697                 int i = 8;
    698                 if (modname)
    699                         i += strlen(modname);
    700                 buf = g_malloc(i);
    701                 i = 0;
    702                 if (modname) {
    703                         memcpy(buf, modname, strlen(modname));
    704                         i += strlen(modname);
    705                 }
    706                 buf[i++] = offset & 0xff;
    707                 buf[i++] = (offset >> 8) & 0xff;
    708                 buf[i++] = (offset >> 16) & 0xff;
    709                 buf[i++] = (offset >> 24) & 0xff;
    710                 buf[i++] = len & 0xff;
    711                 buf[i++] = (len >> 8) & 0xff;
    712                 buf[i++] = (len >> 16) & 0xff;
    713                 buf[i++] = (len >> 24) & 0xff;
    714                 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    715                 g_free(buf);
    716                 return 1;
    717         }
    718         */
    719 
    720         pos = g_new0(struct pieceofcrap, 1);
    721         pos->ic = sess->aux_data;
    722         pos->conn = fr->conn;
    723 
    724         pos->offset = offset;
    725         pos->len = len;
    726         pos->modname = modname ? g_strdup(modname) : NULL;
    727 
    728         fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos);
    729         if (fd < 0) {
    730                 if (pos->modname)
    731                         g_free(pos->modname);
    732                 g_free(pos);
    733                 imcb_error(sess->aux_data, "Gaim was unable to get a valid hash for logging into AIM."
    734                                 " You may be disconnected shortly.");
    735         }
    736         pos->fd = fd;
    737 
    738         return 1;
    739 }
    740604
    741605static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) {
Note: See TracChangeset for help on using the changeset viewer.