Changeset 66c57924 for protocols/oscar
- Timestamp:
- 2005-11-20T16:09:23Z (19 years ago)
- Branches:
- master
- Children:
- 831c955
- Parents:
- 94281ef
- Location:
- protocols/oscar
- Files:
-
- 2 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/oscar/Makefile
r94281ef r66c57924 10 10 11 11 # [SH] Program variables 12 objects = admin.o auth.o bos.o buddylist.o chat.o chatnav.o conn.o ft.oicq.o im.o info.o misc.o msgcookie.o rxhandlers.o rxqueue.o search.o service.o snac.o ssi.o stats.o tlv.o txqueue.o oscar_util.o oscar.o12 objects = admin.o auth.o bos.o buddylist.o chat.o chatnav.o conn.o icq.o im.o info.o misc.o msgcookie.o rxhandlers.o rxqueue.o search.o service.o snac.o ssi.o stats.o tlv.o txqueue.o oscar_util.o oscar.o 13 13 14 14 CFLAGS += -Wall -
protocols/oscar/aim.h
r94281ef r66c57924 168 168 #define AIM_CONN_TYPE_CHATNAV 0x000d 169 169 170 /* they start getting arbitrary in rendezvous stuff =) */171 #define AIM_CONN_TYPE_RENDEZVOUS 0x0101 /* these do not speak FLAP! */172 #define AIM_CONN_TYPE_RENDEZVOUS_OUT 0x0102 /* socket waiting for accept() */173 174 /*175 * Subtypes, we need these for OFT stuff.176 */177 #define AIM_CONN_SUBTYPE_OFT_DIRECTIM 0x0001178 #define AIM_CONN_SUBTYPE_OFT_GETFILE 0x0002179 #define AIM_CONN_SUBTYPE_OFT_SENDFILE 0x0003180 #define AIM_CONN_SUBTYPE_OFT_BUDDYICON 0x0004181 #define AIM_CONN_SUBTYPE_OFT_VOICE 0x0005182 183 170 /* 184 171 * Status values returned from aim_conn_new(). ORed together. … … 191 178 192 179 #define AIM_FRAMETYPE_FLAP 0x0000 193 #define AIM_FRAMETYPE_OFT 0x0001194 180 195 181 /* … … 258 244 flap_seqnum_t seqnum; 259 245 } flap; 260 struct {261 guint16 type;262 guint8 magic[4]; /* ODC2 OFT2 */263 guint16 hdr2len;264 guint8 *hdr2; /* rest of bloated header */265 } oft;266 246 } hdr; 267 247 aim_bstream_t data; /* payload stream */ … … 670 650 #define AIM_COOKIETYPE_CHATNAV 0x06 671 651 #define AIM_COOKIETYPE_INVITE 0x07 672 /* we'll move OFT up a bit to give breathing room. not like it really673 * matters. */674 #define AIM_COOKIETYPE_OFTIM 0x10675 #define AIM_COOKIETYPE_OFTGET 0x11676 #define AIM_COOKIETYPE_OFTSEND 0x12677 #define AIM_COOKIETYPE_OFTVOICE 0x13678 #define AIM_COOKIETYPE_OFTIMAGE 0x14679 #define AIM_COOKIETYPE_OFTICON 0x15680 652 681 653 int aim_handlerendconnect(aim_session_t *sess, aim_conn_t *cur); -
protocols/oscar/aim_internal.h
r94281ef r66c57924 192 192 aim_msgcookie_t *aim_checkcookie(aim_session_t *sess, const unsigned char *, const int); 193 193 int aim_freecookie(aim_session_t *sess, aim_msgcookie_t *cookie); 194 int aim_msgcookie_gettype(int reqclass);195 194 int aim_cookie_free(aim_session_t *sess, aim_msgcookie_t *cookie); 196 195 -
protocols/oscar/conn.c
r94281ef r66c57924 164 164 * This will free ->internal if it necessary... 165 165 */ 166 if ((*deadconn)->type == AIM_CONN_TYPE_RENDEZVOUS) 167 aim_conn_kill_rend(sess, *deadconn); 168 else if ((*deadconn)->type == AIM_CONN_TYPE_CHAT) 166 if ((*deadconn)->type == AIM_CONN_TYPE_CHAT) 169 167 aim_conn_kill_chat(sess, *deadconn); 170 168 … … 314 312 if (deadconn->handlerlist) 315 313 aim_clearhandlers(deadconn); 316 if (deadconn->type == AIM_CONN_TYPE_RENDEZVOUS)317 aim_conn_close_rend((aim_session_t *)deadconn->sessv, deadconn);318 314 319 315 return; -
protocols/oscar/im.c
r94281ef r66c57924 2039 2039 */ 2040 2040 aimbs_put8(&fr->data, strlen(sn)); 2041 aimbs_putraw(&fr->data, sn, strlen(sn));2041 aimbs_putraw(&fr->data, (const guint8*)sn, strlen(sn)); 2042 2042 2043 2043 /* -
protocols/oscar/msgcookie.c
r94281ef r66c57924 178 178 return 0; 179 179 } 180 181 /* XXX I hate switch */182 int aim_msgcookie_gettype(int reqclass)183 {184 /* XXX: hokey-assed. needs fixed. */185 switch(reqclass) {186 case AIM_CAPS_BUDDYICON: return AIM_COOKIETYPE_OFTICON;187 case AIM_CAPS_VOICE: return AIM_COOKIETYPE_OFTVOICE;188 case AIM_CAPS_IMIMAGE: return AIM_COOKIETYPE_OFTIMAGE;189 case AIM_CAPS_CHAT: return AIM_COOKIETYPE_CHAT;190 case AIM_CAPS_GETFILE: return AIM_COOKIETYPE_OFTGET;191 case AIM_CAPS_SENDFILE: return AIM_COOKIETYPE_OFTSEND;192 default: return AIM_COOKIETYPE_UNKNOWN;193 }194 }195 196 -
protocols/oscar/oscar.c
r94281ef r66c57924 275 275 276 276 if (condition & GAIM_INPUT_READ) { 277 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { 278 if (aim_handlerendconnect(odata->sess, conn) < 0) { 277 if (aim_get_command(odata->sess, conn) >= 0) { 278 aim_rxdispatch(odata->sess); 279 if (odata->killme) 280 signoff(gc); 281 } else { 282 if ((conn->type == AIM_CONN_TYPE_BOS) || 283 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { 284 hide_login_progress_error(gc, _("Disconnected.")); 285 signoff(gc); 286 } else if (conn->type == AIM_CONN_TYPE_CHAT) { 287 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); 288 char buf[BUF_LONG]; 289 c->conn = NULL; 290 if (c->inpa > 0) 291 gaim_input_remove(c->inpa); 292 c->inpa = 0; 293 c->fd = -1; 279 294 aim_conn_kill(odata->sess, &conn); 280 } 281 } else { 282 if (aim_get_command(odata->sess, conn) >= 0) { 283 aim_rxdispatch(odata->sess); 284 if (odata->killme) 285 signoff(gc); 295 sprintf(buf, _("You have been disconnected from chat room %s."), c->name); 296 do_error_dialog(sess->aux_data, buf, _("Chat Error!")); 297 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { 298 if (odata->cnpa > 0) 299 gaim_input_remove(odata->cnpa); 300 odata->cnpa = 0; 301 while (odata->create_rooms) { 302 struct create_room *cr = odata->create_rooms->data; 303 g_free(cr->name); 304 odata->create_rooms = 305 g_slist_remove(odata->create_rooms, cr); 306 g_free(cr); 307 do_error_dialog(sess->aux_data, _("Chat is currently unavailable"), 308 _("Gaim - Chat")); 309 } 310 aim_conn_kill(odata->sess, &conn); 311 } else if (conn->type == AIM_CONN_TYPE_AUTH) { 312 if (odata->paspa > 0) 313 gaim_input_remove(odata->paspa); 314 odata->paspa = 0; 315 aim_conn_kill(odata->sess, &conn); 286 316 } else { 287 if ((conn->type == AIM_CONN_TYPE_BOS) || 288 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { 289 hide_login_progress_error(gc, _("Disconnected.")); 290 signoff(gc); 291 } else if (conn->type == AIM_CONN_TYPE_CHAT) { 292 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); 293 char buf[BUF_LONG]; 294 c->conn = NULL; 295 if (c->inpa > 0) 296 gaim_input_remove(c->inpa); 297 c->inpa = 0; 298 c->fd = -1; 299 aim_conn_kill(odata->sess, &conn); 300 sprintf(buf, _("You have been disconnected from chat room %s."), c->name); 301 do_error_dialog(sess->aux_data, buf, _("Chat Error!")); 302 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { 303 if (odata->cnpa > 0) 304 gaim_input_remove(odata->cnpa); 305 odata->cnpa = 0; 306 while (odata->create_rooms) { 307 struct create_room *cr = odata->create_rooms->data; 308 g_free(cr->name); 309 odata->create_rooms = 310 g_slist_remove(odata->create_rooms, cr); 311 g_free(cr); 312 do_error_dialog(sess->aux_data, _("Chat is currently unavailable"), 313 _("Gaim - Chat")); 314 } 315 aim_conn_kill(odata->sess, &conn); 316 } else if (conn->type == AIM_CONN_TYPE_AUTH) { 317 if (odata->paspa > 0) 318 gaim_input_remove(odata->paspa); 319 odata->paspa = 0; 320 aim_conn_kill(odata->sess, &conn); 321 } else { 322 aim_conn_kill(odata->sess, &conn); 323 } 317 aim_conn_kill(odata->sess, &conn); 324 318 } 325 319 } -
protocols/oscar/rxhandlers.c
r94281ef r66c57924 341 341 continue; 342 342 343 /*344 * This is a debugging/sanity check only and probably345 * could/should be removed for stable code.346 */347 if (((cur->hdrtype == AIM_FRAMETYPE_OFT) &&348 (cur->conn->type != AIM_CONN_TYPE_RENDEZVOUS)) ||349 ((cur->hdrtype == AIM_FRAMETYPE_FLAP) &&350 (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS))) {351 do_error_dialog(sess->aux_data, "incompatible frame type/connection type combination", "Gaim");352 cur->handled = 1;353 continue;354 }355 356 if (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS) {357 if (cur->hdrtype != AIM_FRAMETYPE_OFT) {358 do_error_dialog(sess->aux_data, "non-OFT frames on OFT connection", "Gaim");359 cur->handled = 1; /* get rid of it */360 } else {361 /* FIXME: implement this (OFT frame) */362 cur->handled = 1; /* get rid of it */363 }364 continue;365 }366 367 if (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {368 /* not possible */369 do_error_dialog(sess->aux_data, "RENDEZVOUS packet in rxqueue", "Gaim");370 cur->handled = 1;371 continue;372 }373 374 343 if (cur->hdr.flap.type == 0x01) { 375 344 -
protocols/oscar/rxqueue.c
r94281ef r66c57924 332 332 g_free(frame->data.data); /* XXX aim_bstream_free */ 333 333 334 if (frame->hdrtype == AIM_FRAMETYPE_OFT)335 g_free(frame->hdr.oft.hdr2);336 334 g_free(frame); 337 338 return;339 335 } 340 336 … … 362 358 if (conn->status & AIM_CONN_STATUS_INPROGRESS) 363 359 return aim_conn_completeconnect(sess, conn); 364 365 /*366 * Rendezvous (client-client) connections do not speak367 * FLAP, so this function will break on them.368 */369 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS)370 return aim_get_command_rendezvous(sess, conn);371 else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {372 do_error_dialog(sess->aux_data,"AIM_CONN_TYPE_RENDEZVOUS_OUT shouldn't use FLAP", "Gaim");373 return 0;374 }375 360 376 361 aim_bstream_init(&flaphdr, flaphdr_raw, sizeof(flaphdr_raw)); -
protocols/oscar/txqueue.c
r94281ef r66c57924 34 34 } 35 35 36 /* For sanity... */37 if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) ||38 (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT)) {39 if (framing != AIM_FRAMETYPE_OFT) {40 do_error_dialog(sess->aux_data, "attempted to allocate inappropriate frame type for rendezvous connection", "Gaim");41 return NULL;42 }43 } else {44 if (framing != AIM_FRAMETYPE_FLAP) {45 do_error_dialog(sess->aux_data, "attempted to allocate inappropriate frame type for FLAP connection", "Gaim");46 return NULL;47 }48 }49 50 36 if (!(fr = (aim_frame_t *)g_new0(aim_frame_t,1))) 51 37 return NULL; … … 58 44 59 45 fr->hdr.flap.type = chan; 60 61 } else if (fr->hdrtype == AIM_FRAMETYPE_OFT) {62 63 fr->hdr.oft.type = chan;64 fr->hdr.oft.hdr2len = 0; /* this will get setup by caller */65 46 66 47 } else … … 237 218 238 219 if (count) { 239 if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) &&240 (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) {241 /* I strongly suspect that this is a horrible thing to do242 * and I feel really guilty doing it. */243 const char *sn = aim_directim_getsn(conn);244 aim_rxcallback_t userfunc;245 while (count - wrote > 1024) {246 wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, 1024);247 if ((userfunc=aim_callhandler(conn->sessv, conn,248 AIM_CB_FAM_SPECIAL,249 AIM_CB_SPECIAL_IMAGETRANSFER)))250 userfunc(conn->sessv, NULL, sn,251 count-wrote>1024 ? ((double)wrote / count) : 1);252 }253 }254 220 if (count - wrote) { 255 221 wrote = wrote + aim_send(conn->fd, bs->data + bs->offset + wrote, count - wrote); … … 299 265 } 300 266 301 static int sendframe_oft(aim_session_t *sess, aim_frame_t *fr)302 {303 aim_bstream_t hbs;304 guint8 *hbs_raw;305 int hbslen;306 int err = 0;307 308 hbslen = 8 + fr->hdr.oft.hdr2len;309 if (!(hbs_raw = g_malloc(hbslen)))310 return -1;311 312 aim_bstream_init(&hbs, hbs_raw, hbslen);313 314 aimbs_putraw(&hbs, fr->hdr.oft.magic, 4);315 aimbs_put16(&hbs, fr->hdr.oft.hdr2len + 8);316 aimbs_put16(&hbs, fr->hdr.oft.type);317 aimbs_putraw(&hbs, fr->hdr.oft.hdr2, fr->hdr.oft.hdr2len);318 319 aim_bstream_rewind(&hbs);320 321 322 if (aim_bstream_send(&hbs, fr->conn, hbslen) != hbslen) {323 324 err = -errno;325 326 } else if (aim_bstream_curpos(&fr->data)) {327 int len;328 329 len = aim_bstream_curpos(&fr->data);330 aim_bstream_rewind(&fr->data);331 332 if (aim_bstream_send(&fr->data, fr->conn, len) != len)333 err = -errno;334 }335 336 g_free(hbs_raw); /* XXX aim_bstream_free */337 338 fr->handled = 1;339 fr->conn->lastactivity = time(NULL);340 341 342 return err;343 344 345 }346 347 267 int aim_tx_sendframe(aim_session_t *sess, aim_frame_t *fr) 348 268 { 349 269 if (fr->hdrtype == AIM_FRAMETYPE_FLAP) 350 270 return sendframe_flap(sess, fr); 351 else if (fr->hdrtype == AIM_FRAMETYPE_OFT)352 return sendframe_oft(sess, fr);353 271 return -1; 354 272 }
Note: See TracChangeset
for help on using the changeset viewer.