static int yahoo_chat_send(GaimConnection *gc, const char *dn, const char *room, const char *what, GaimMessageFlags flags) { struct yahoo_data *yd = gc->proto_data; struct yahoo_packet *pkt; int me = 0; char *msg1, *msg2, *room2; gboolean utf8 = TRUE; if (yd->wm) { g_return_val_if_fail(yd->ycht != NULL, 1); return ycht_chat_send(yd->ycht, room, what); } msg1 = g_strdup(what); if (meify(msg1, -1)) me = 1; msg2 = yahoo_html_to_codes(msg1); g_free(msg1); msg1 = yahoo_string_encode(gc, msg2, &utf8); g_free(msg2); room2 = yahoo_string_encode(gc, room, NULL); pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, "sss", 1, dn, 104, room2, 117, msg1); if (me) yahoo_packet_hash_str(pkt, 124, "2"); else yahoo_packet_hash_str(pkt, 124, "1"); /* fixme: what about /think? (124=3) */ if (utf8) yahoo_packet_hash_str(pkt, 97, "1"); yahoo_packet_send_and_free(pkt, yd); g_free(msg1); g_free(room2); return 0; }
static int yahoo_chat_send(PurpleConnection *gc, const char *dn, const char *room, const char *what, PurpleMessageFlags flags) { YahooData *yd = purple_connection_get_protocol_data(gc); struct yahoo_packet *pkt; int me = 0; char *msg1, *msg2, *room2; if (yd->wm) { g_return_val_if_fail(yd->ycht != NULL, 1); return ycht_chat_send(yd->ycht, room, what); } msg1 = g_strdup(what); if (purple_message_meify(msg1, -1)) me = 1; msg2 = yahoo_html_to_codes(msg1); g_free(msg1); msg1 = yahoo_string_encode(gc, msg2, TRUE); g_free(msg2); room2 = yahoo_string_encode(gc, room, FALSE); pkt = yahoo_packet_new(YAHOO_SERVICE_COMMENT, YAHOO_STATUS_AVAILABLE, yd->session_id); yahoo_packet_hash(pkt, "sss", 1, dn, 104, room2, 117, msg1); if (me) yahoo_packet_hash_str(pkt, 124, "2"); else yahoo_packet_hash_str(pkt, 124, "1"); /* fixme: what about /think? (124=3) */ yahoo_packet_hash_str(pkt, 97, "1"); /* UTF-8 */ yahoo_packet_send_and_free(pkt, yd); g_free(msg1); g_free(room2); return 0; }