Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 9933:cee849d17167
[gaim-migrate @ 10825]
Another patch from Dave West. This makes the file transfer message
show up when someone sends you an AIM file transfer. It also attempts
to decode the message to UTF-8. The chat invitation messages also
benefit from this attempted conversion.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 02 Sep 2004 03:46:53 +0000 |
parents | fb08a0973b3e |
children | bb0c04ebcdef |
comparison
equal
deleted
inserted
replaced
9932:3fa121db91d0 | 9933:cee849d17167 |
---|---|
349 */ | 349 */ |
350 static gchar *oscar_encoding_extract(const char *encoding) | 350 static gchar *oscar_encoding_extract(const char *encoding) |
351 { | 351 { |
352 gchar *ret = NULL; | 352 gchar *ret = NULL; |
353 char *begin, *end; | 353 char *begin, *end; |
354 | |
355 g_return_val_if_fail(encoding != NULL, NULL); | |
354 | 356 |
355 /* Make sure encoding begins with charset= */ | 357 /* Make sure encoding begins with charset= */ |
356 if (strncmp(encoding, "text/aolrtf; charset=", 21)) | 358 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
357 return NULL; | 359 return NULL; |
358 | 360 |
3279 return 1; | 3281 return 1; |
3280 } | 3282 } |
3281 | 3283 |
3282 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { | 3284 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
3283 GaimConnection *gc; | 3285 GaimConnection *gc; |
3286 GaimAccount *account; | |
3284 OscarData *od; | 3287 OscarData *od; |
3285 const char *username; | 3288 const char *username = NULL; |
3289 char *message = NULL; | |
3286 | 3290 |
3287 g_return_val_if_fail(sess != NULL, 0); | 3291 g_return_val_if_fail(sess != NULL, 0); |
3288 g_return_val_if_fail(sess->aux_data != NULL, 0); | 3292 g_return_val_if_fail(sess->aux_data != NULL, 0); |
3289 | 3293 |
3290 gc = sess->aux_data; | 3294 gc = sess->aux_data; |
3295 account = gaim_connection_get_account(gc); | |
3291 od = gc->proto_data; | 3296 od = gc->proto_data; |
3292 username = gaim_account_get_username(gaim_connection_get_account(gc)); | 3297 username = gaim_account_get_username(account); |
3293 | 3298 |
3294 if (!args) | 3299 if (args == NULL) |
3295 return 0; | 3300 return 0; |
3296 | 3301 |
3297 gaim_debug_misc("oscar", | 3302 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
3298 "rendezvous with %s, status is %hu\n", | 3303 userinfo->sn, args->status); |
3299 userinfo->sn, args->status); | 3304 |
3305 if (args->msg != NULL) | |
3306 { | |
3307 if (args->encoding != NULL) | |
3308 { | |
3309 char *encoding = NULL; | |
3310 encoding = oscar_encoding_extract(args->encoding); | |
3311 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
3312 g_free(encoding); | |
3313 } else { | |
3314 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
3315 message = g_strdup(args->msg); | |
3316 } | |
3317 } | |
3300 | 3318 |
3301 if (args->reqclass & AIM_CAPS_CHAT) { | 3319 if (args->reqclass & AIM_CAPS_CHAT) { |
3302 char *name; | 3320 char *name; |
3303 GHashTable *components; | 3321 GHashTable *components; |
3304 | 3322 |
3305 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) | 3323 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
3324 g_free(message); | |
3306 return 1; | 3325 return 1; |
3326 } | |
3307 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, | 3327 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
3308 g_free); | 3328 g_free); |
3309 name = extract_name(args->info.chat.roominfo.name); | 3329 name = extract_name(args->info.chat.roominfo.name); |
3310 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); | 3330 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
3311 g_hash_table_replace(components, g_strdup("exchange"), g_strdup_printf("%d", args->info.chat.roominfo.exchange)); | 3331 g_hash_table_replace(components, g_strdup("exchange"), g_strdup_printf("%d", args->info.chat.roominfo.exchange)); |
3312 serv_got_chat_invite(gc, | 3332 serv_got_chat_invite(gc, |
3313 name ? name : args->info.chat.roominfo.name, | 3333 name ? name : args->info.chat.roominfo.name, |
3314 userinfo->sn, | 3334 userinfo->sn, |
3315 args->msg, | 3335 message, |
3316 components); | 3336 components); |
3317 if (name) | 3337 if (name) |
3318 g_free(name); | 3338 g_free(name); |
3319 } else if (args->reqclass & AIM_CAPS_SENDFILE) { | 3339 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
3320 /* BBB */ | 3340 /* BBB */ |
3331 "information.\n", userinfo->sn); | 3351 "information.\n", userinfo->sn); |
3332 if (args->proxyip) | 3352 if (args->proxyip) |
3333 gaim_debug_warning("oscar", | 3353 gaim_debug_warning("oscar", |
3334 "IP for a proxy server was given. Gaim " | 3354 "IP for a proxy server was given. Gaim " |
3335 "does not support this yet.\n"); | 3355 "does not support this yet.\n"); |
3356 g_free(message); | |
3336 return 1; | 3357 return 1; |
3337 } | 3358 } |
3338 | 3359 |
3339 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | 3360 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { |
3340 /* last char of the ft req is a star, they are sending us a | 3361 /* last char of the ft req is a star, they are sending us a |
3353 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | 3374 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); |
3354 xfer->remote_ip = g_strdup(args->verifiedip); | 3375 xfer->remote_ip = g_strdup(args->verifiedip); |
3355 xfer->remote_port = args->port; | 3376 xfer->remote_port = args->port; |
3356 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); | 3377 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
3357 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | 3378 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
3379 gaim_xfer_set_message(xfer, message); | |
3358 | 3380 |
3359 /* Create the oscar-specific data */ | 3381 /* Create the oscar-specific data */ |
3360 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); | 3382 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
3361 if (args->proxyip) | 3383 if (args->proxyip) |
3362 oft_info->proxyip = g_strdup(args->proxyip); | 3384 oft_info->proxyip = g_strdup(args->proxyip); |
3368 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); | 3390 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
3369 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); | 3391 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
3370 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_recv); | 3392 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_recv); |
3371 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); | 3393 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
3372 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); | 3394 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
3373 | |
3374 /* | |
3375 * XXX - Should do something with args->msg, args->encoding, and args->language | |
3376 * probably make it apply to all ch2 messages. | |
3377 */ | |
3378 | 3395 |
3379 /* Keep track of this transfer for later */ | 3396 /* Keep track of this transfer for later */ |
3380 od->file_transfers = g_slist_append(od->file_transfers, xfer); | 3397 od->file_transfers = g_slist_append(od->file_transfers, xfer); |
3381 | 3398 |
3382 /* Now perform the request */ | 3399 /* Now perform the request */ |
3400 "unknown rendezvous status!\n"); | 3417 "unknown rendezvous status!\n"); |
3401 } | 3418 } |
3402 } else if (args->reqclass & AIM_CAPS_GETFILE) { | 3419 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
3403 } else if (args->reqclass & AIM_CAPS_TALK) { | 3420 } else if (args->reqclass & AIM_CAPS_TALK) { |
3404 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { | 3421 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
3405 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), | 3422 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
3406 userinfo->sn, args->info.icon.icon, | 3423 args->info.icon.icon, |
3407 args->info.icon.length); | 3424 args->info.icon.length); |
3408 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { | 3425 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
3409 /* Consider moving all this into a helper func in the direct im block way up there */ | 3426 /* Consider moving all this into a helper func in the direct im block way up there */ |
3410 struct ask_direct *d = g_new0(struct ask_direct, 1); | 3427 struct ask_direct *d = g_new0(struct ask_direct, 1); |
3411 struct oscar_direct_im *dim = oscar_direct_im_find(od, userinfo->sn); | 3428 struct oscar_direct_im *dim = oscar_direct_im_find(od, userinfo->sn); |
3413 | 3430 |
3414 if (!args->verifiedip) { | 3431 if (!args->verifiedip) { |
3415 /* TODO: do something about this, after figuring out what it means */ | 3432 /* TODO: do something about this, after figuring out what it means */ |
3416 gaim_debug_info("oscar", | 3433 gaim_debug_info("oscar", |
3417 "directim kill blocked (%s)\n", userinfo->sn); | 3434 "directim kill blocked (%s)\n", userinfo->sn); |
3435 g_free(message); | |
3418 return 1; | 3436 return 1; |
3419 } | 3437 } |
3420 | 3438 |
3421 gaim_debug_info("oscar", | 3439 gaim_debug_info("oscar", |
3422 "%s received direct im request from %s (%s)\n", | 3440 "%s received direct im request from %s (%s)\n", |
3455 gaim_debug_error("oscar", "Got an ICQ Server Relay message of type %d\n", args->info.rtfmsg.msgtype); | 3473 gaim_debug_error("oscar", "Got an ICQ Server Relay message of type %d\n", args->info.rtfmsg.msgtype); |
3456 } else { | 3474 } else { |
3457 gaim_debug_error("oscar", | 3475 gaim_debug_error("oscar", |
3458 "Unknown reqclass %hu\n", args->reqclass); | 3476 "Unknown reqclass %hu\n", args->reqclass); |
3459 } | 3477 } |
3478 | |
3479 g_free(message); | |
3460 | 3480 |
3461 return 1; | 3481 return 1; |
3462 } | 3482 } |
3463 | 3483 |
3464 /* | 3484 /* |