Mercurial > pidgin
comparison libpurple/protocols/oscar/odc.c @ 25925:6e1967b0f90b
Change "screen name" to "username" or "buddy name" in a whole bunch of
places in the code. I've been using the definitions from the jabber
specs, where "user" is me and "buddy" is someone on my buddy list.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 26 Jan 2009 09:12:04 +0000 |
parents | cb1a897ae34c |
children | f541583e31bd |
comparison
equal
deleted
inserted
replaced
25924:584063555949 | 25925:6e1967b0f90b |
---|---|
60 { | 60 { |
61 PurpleAccount *account; | 61 PurpleAccount *account; |
62 PurpleConversation *conv; | 62 PurpleConversation *conv; |
63 | 63 |
64 account = purple_connection_get_account(conn->od->gc); | 64 account = purple_connection_get_account(conn->od->gc); |
65 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn); | 65 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->bn); |
66 purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); | 66 purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
67 g_free(tmp); | 67 g_free(tmp); |
68 } | 68 } |
69 | 69 |
70 if (conn->frame != NULL) | 70 if (conn->frame != NULL) |
88 size_t length; | 88 size_t length; |
89 ByteStream bs; | 89 ByteStream bs; |
90 | 90 |
91 purple_debug_info("oscar", "Outgoing ODC frame to %s with " | 91 purple_debug_info("oscar", "Outgoing ODC frame to %s with " |
92 "type=0x%04x, flags=0x%04x, payload length=%u\n", | 92 "type=0x%04x, flags=0x%04x, payload length=%u\n", |
93 conn->sn, frame->type, frame->flags, frame->payload.len); | 93 conn->bn, frame->type, frame->flags, frame->payload.len); |
94 | 94 |
95 account = purple_connection_get_account(conn->od->gc); | 95 account = purple_connection_get_account(conn->od->gc); |
96 username = purple_account_get_username(account); | 96 username = purple_account_get_username(account); |
97 memcpy(frame->sn, username, strlen(username)); | 97 memcpy(frame->bn, username, strlen(username)); |
98 memcpy(frame->cookie, conn->cookie, 8); | 98 memcpy(frame->cookie, conn->cookie, 8); |
99 | 99 |
100 length = 76; | 100 length = 76; |
101 byte_stream_new(&bs, length + frame->payload.len); | 101 byte_stream_new(&bs, length + frame->payload.len); |
102 byte_stream_putraw(&bs, conn->magic, 4); | 102 byte_stream_putraw(&bs, conn->magic, 4); |
114 byte_stream_put16(&bs, frame->encoding); | 114 byte_stream_put16(&bs, frame->encoding); |
115 byte_stream_put16(&bs, 0x0000); | 115 byte_stream_put16(&bs, 0x0000); |
116 byte_stream_put16(&bs, frame->flags); | 116 byte_stream_put16(&bs, frame->flags); |
117 byte_stream_put16(&bs, 0x0000); | 117 byte_stream_put16(&bs, 0x0000); |
118 byte_stream_put16(&bs, 0x0000); | 118 byte_stream_put16(&bs, 0x0000); |
119 byte_stream_putraw(&bs, frame->sn, 32); | 119 byte_stream_putraw(&bs, frame->bn, 32); |
120 byte_stream_putraw(&bs, frame->payload.data, frame->payload.len); | 120 byte_stream_putraw(&bs, frame->payload.data, frame->payload.len); |
121 | 121 |
122 peer_connection_send(conn, &bs); | 122 peer_connection_send(conn, &bs); |
123 | 123 |
124 byte_stream_destroy(&bs); | 124 byte_stream_destroy(&bs); |
364 | 364 |
365 /* Delete the attribute list */ | 365 /* Delete the attribute list */ |
366 g_datalist_clear(&attributes); | 366 g_datalist_clear(&attributes); |
367 | 367 |
368 /* Append the message up to the tag */ | 368 /* Append the message up to the tag */ |
369 utf8 = purple_plugin_oscar_decode_im_part(account, conn->sn, | 369 utf8 = purple_plugin_oscar_decode_im_part(account, conn->bn, |
370 encoding, 0x0000, tmp, start - tmp); | 370 encoding, 0x0000, tmp, start - tmp); |
371 if (utf8 != NULL) { | 371 if (utf8 != NULL) { |
372 g_string_append(newmsg, utf8); | 372 g_string_append(newmsg, utf8); |
373 g_free(utf8); | 373 g_free(utf8); |
374 } | 374 } |
384 } | 384 } |
385 | 385 |
386 /* Append any remaining message data */ | 386 /* Append any remaining message data */ |
387 if (tmp <= msgend) | 387 if (tmp <= msgend) |
388 { | 388 { |
389 utf8 = purple_plugin_oscar_decode_im_part(account, conn->sn, | 389 utf8 = purple_plugin_oscar_decode_im_part(account, conn->bn, |
390 encoding, 0x0000, tmp, msgend - tmp); | 390 encoding, 0x0000, tmp, msgend - tmp); |
391 if (utf8 != NULL) { | 391 if (utf8 != NULL) { |
392 g_string_append(newmsg, utf8); | 392 g_string_append(newmsg, utf8); |
393 g_free(utf8); | 393 g_free(utf8); |
394 } | 394 } |
398 imflags = 0; | 398 imflags = 0; |
399 if (images != NULL) | 399 if (images != NULL) |
400 imflags |= PURPLE_MESSAGE_IMAGES; | 400 imflags |= PURPLE_MESSAGE_IMAGES; |
401 if (autoreply) | 401 if (autoreply) |
402 imflags |= PURPLE_MESSAGE_AUTO_RESP; | 402 imflags |= PURPLE_MESSAGE_AUTO_RESP; |
403 serv_got_im(gc, conn->sn, newmsg->str, imflags, time(NULL)); | 403 serv_got_im(gc, conn->bn, newmsg->str, imflags, time(NULL)); |
404 g_string_free(newmsg, TRUE); | 404 g_string_free(newmsg, TRUE); |
405 | 405 |
406 /* unref any images we allocated */ | 406 /* unref any images we allocated */ |
407 if (images) | 407 if (images) |
408 { | 408 { |
501 frame->payload.len = byte_stream_get32(bs); | 501 frame->payload.len = byte_stream_get32(bs); |
502 frame->encoding = byte_stream_get16(bs); | 502 frame->encoding = byte_stream_get16(bs); |
503 byte_stream_advance(bs, 4); | 503 byte_stream_advance(bs, 4); |
504 frame->flags = byte_stream_get16(bs); | 504 frame->flags = byte_stream_get16(bs); |
505 byte_stream_advance(bs, 4); | 505 byte_stream_advance(bs, 4); |
506 byte_stream_getrawbuf(bs, frame->sn, 32); | 506 byte_stream_getrawbuf(bs, frame->bn, 32); |
507 | 507 |
508 purple_debug_info("oscar", "Incoming ODC frame from %s with " | 508 purple_debug_info("oscar", "Incoming ODC frame from %s with " |
509 "type=0x%04x, flags=0x%04x, payload length=%u\n", | 509 "type=0x%04x, flags=0x%04x, payload length=%u\n", |
510 frame->sn, frame->type, frame->flags, frame->payload.len); | 510 frame->bn, frame->type, frame->flags, frame->payload.len); |
511 | 511 |
512 if (!conn->ready) | 512 if (!conn->ready) |
513 { | 513 { |
514 /* | 514 /* |
515 * We need to verify the cookie so that we know we are | 515 * We need to verify the cookie so that we know we are |
556 conn->listenerfd = -1; | 556 conn->listenerfd = -1; |
557 } | 557 } |
558 | 558 |
559 /* Tell the local user that we are connected */ | 559 /* Tell the local user that we are connected */ |
560 account = purple_connection_get_account(gc); | 560 account = purple_connection_get_account(gc); |
561 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn); | 561 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->bn); |
562 purple_conversation_write(conv, NULL, _("Direct IM established"), | 562 purple_conversation_write(conv, NULL, _("Direct IM established"), |
563 PURPLE_MESSAGE_SYSTEM, time(NULL)); | 563 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
564 } | 564 } |
565 | 565 |
566 if ((frame->type != 0x0001) && (frame->subtype != 0x0006)) | 566 if ((frame->type != 0x0001) && (frame->subtype != 0x0006)) |
574 if (frame->flags & 0x0008) | 574 if (frame->flags & 0x0008) |
575 { | 575 { |
576 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | 576 /* I had to leave this. It's just too funny. It reminds me of my sister. */ |
577 purple_debug_info("oscar", "ohmigod! %s has started typing " | 577 purple_debug_info("oscar", "ohmigod! %s has started typing " |
578 "(DirectIM). He's going to send you a message! " | 578 "(DirectIM). He's going to send you a message! " |
579 "*squeal*\n", conn->sn); | 579 "*squeal*\n", conn->bn); |
580 serv_got_typing(gc, conn->sn, 0, PURPLE_TYPING); | 580 serv_got_typing(gc, conn->bn, 0, PURPLE_TYPING); |
581 } | 581 } |
582 else if (frame->flags & 0x0004) | 582 else if (frame->flags & 0x0004) |
583 { | 583 { |
584 serv_got_typing(gc, conn->sn, 0, PURPLE_TYPED); | 584 serv_got_typing(gc, conn->bn, 0, PURPLE_TYPED); |
585 } | 585 } |
586 else | 586 else |
587 { | 587 { |
588 serv_got_typing_stopped(gc, conn->sn); | 588 serv_got_typing_stopped(gc, conn->bn); |
589 } | 589 } |
590 | 590 |
591 if (frame->payload.len > 0) | 591 if (frame->payload.len > 0) |
592 { | 592 { |
593 if (frame->payload.len > DIRECTIM_MAX_FILESIZE) | 593 if (frame->payload.len > DIRECTIM_MAX_FILESIZE) |
596 PurpleAccount *account; | 596 PurpleAccount *account; |
597 PurpleConversation *conv; | 597 PurpleConversation *conv; |
598 | 598 |
599 size1 = purple_str_size_to_units(frame->payload.len); | 599 size1 = purple_str_size_to_units(frame->payload.len); |
600 size2 = purple_str_size_to_units(DIRECTIM_MAX_FILESIZE); | 600 size2 = purple_str_size_to_units(DIRECTIM_MAX_FILESIZE); |
601 tmp = g_strdup_printf(_("%s tried to send you a %s file, but we only allow files up to %s over Direct IM. Try using file transfer instead.\n"), conn->sn, size1, size2); | 601 tmp = g_strdup_printf(_("%s tried to send you a %s file, but we only allow files up to %s over Direct IM. Try using file transfer instead.\n"), conn->bn, size1, size2); |
602 g_free(size1); | 602 g_free(size1); |
603 g_free(size2); | 603 g_free(size2); |
604 | 604 |
605 account = purple_connection_get_account(conn->od->gc); | 605 account = purple_connection_get_account(conn->od->gc); |
606 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->sn); | 606 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, conn->bn); |
607 purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); | 607 purple_conversation_write(conv, NULL, tmp, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
608 g_free(tmp); | 608 g_free(tmp); |
609 | 609 |
610 peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); | 610 peer_connection_destroy(conn, OSCAR_DISCONNECT_LOCAL_CLOSED, NULL); |
611 g_free(frame); | 611 g_free(frame); |