int yahoo_c_send(GaimConnection *gc, int id, const char *what, GaimMessageFlags flags) { GaimConversation *c; int ret; struct yahoo_data *yd; yd = (struct yahoo_data *) gc->proto_data; if (!yd) return -1; c = gaim_find_chat(gc, id); if (!c) return -1; if (id != YAHOO_CHAT_ID) { ret = yahoo_conf_send(gc, gaim_connection_get_display_name(gc), gaim_conversation_get_name(c), gaim_conv_chat_get_users(GAIM_CONV_CHAT(c)), what); } else { ret = yahoo_chat_send(gc, gaim_connection_get_display_name(gc), gaim_conversation_get_name(c), what, flags); if (!ret) serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), gaim_connection_get_display_name(gc), 0, what, time(NULL)); } return ret; }
JabberChat *jabber_chat_find_by_conv(GaimConversation *conv) { GaimAccount *account = gaim_conversation_get_account(conv); GaimConnection *gc = gaim_account_get_connection(account); JabberStream *js = gc->proto_data; int id = gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)); return jabber_chat_find_by_id(js, id); }
void GaimChatMngr::ChatJoinedCbk(GaimConversation *conv) { mConvInfo_t *mConv = (mConvInfo_t *) conv->ui_data; if (mConv->pending_invit) { for (GList *l = mConv->pending_invit; l != NULL; l = l->next) { serv_chat_invite(gaim_conversation_get_gc(conv), gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), "Join my conference...", (char *)l->data); } } }
void yahoo_process_conference_message(GaimConnection *gc, struct yahoo_packet *pkt) { GSList *l; char *room = NULL; char *who = NULL; char *msg = NULL; char *msg2; int utf8 = 0; GaimConversation *c; for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 57: room = yahoo_string_decode(gc, pair->value, FALSE); break; case 3: who = pair->value; break; case 14: msg = pair->value; break; case 97: utf8 = strtol(pair->value, NULL, 10); break; } } if (room && who && msg) { msg2 = yahoo_string_decode(gc, msg, utf8); c = yahoo_find_conference(gc, room); if (!c) return; msg = yahoo_codes_to_html(msg2); serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), who, 0, msg, time(NULL)); g_free(msg); g_free(msg2); } if (room) g_free(room); }
/* recv an IM from a group chat */ void qq_process_recv_group_im(guint8 *data, guint8 **cursor, gint data_len, guint32 internal_group_id, GaimConnection *gc, guint16 im_type) { gchar *msg_with_gaim_smiley, *msg_utf8_encoded, *im_src_name, *hex_dump; guint16 unknown; guint32 unknown4; GaimConversation *conv; qq_data *qd; qq_buddy *member; qq_group *group; qq_recv_group_im *im_group; gint skip_len; g_return_if_fail(data != NULL && data_len > 0); qd = (qq_data *) gc->proto_data; hex_dump = hex_dump_to_str(*cursor, data_len - (*cursor - data)); gaim_debug(GAIM_DEBUG_INFO, "QQ", "group im hex dump\n%s\n", hex_dump); if (*cursor >= (data + data_len - 1)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group im_group is empty\n"); return; } im_group = g_newa(qq_recv_group_im, 1); read_packet_dw(data, cursor, data_len, &(im_group->external_group_id)); read_packet_b(data, cursor, data_len, &(im_group->group_type)); if(QQ_RECV_IM_TEMP_QUN_IM == im_type) { read_packet_dw(data, cursor, data_len, &(internal_group_id)); } read_packet_dw(data, cursor, data_len, &(im_group->member_uid)); read_packet_w(data, cursor, data_len, &unknown); /* 0x0001? */ read_packet_w(data, cursor, data_len, &(im_group->msg_seq)); read_packet_dw(data, cursor, data_len, (guint32 *) & (im_group->send_time)); read_packet_dw(data, cursor, data_len, &unknown4); /* versionID */ /* * length includes font_attr * this msg_len includes msg and font_attr **** the format is **** * length of all * 1. unknown 10 bytes * 2. 0-ended string * 3. font_attr */ read_packet_w(data, cursor, data_len, &(im_group->msg_len)); g_return_if_fail(im_group->msg_len > 0); /* * 10 bytes from lumaqq * contentType = buf.getChar(); * totalFragments = buf.get() & 255; * fragmentSequence = buf.get() & 255; * messageId = buf.getChar(); * buf.getInt(); */ if(im_type != QQ_RECV_IM_UNKNOWN_QUN_IM) skip_len = 10; else skip_len = 0; *cursor += skip_len; im_group->msg = g_strdup((gchar *) *cursor); *cursor += strlen(im_group->msg) + 1; /* there might not be any font_attr, check it */ im_group->font_attr_len = im_group->msg_len - strlen(im_group->msg) - 1 - skip_len; if (im_group->font_attr_len > 0) im_group->font_attr = g_memdup(*cursor, im_group->font_attr_len); else im_group->font_attr = NULL; /* group im_group has no flag to indicate whether it has font_attr or not */ msg_with_gaim_smiley = qq_smiley_to_gaim(im_group->msg); if (im_group->font_attr_len > 0) msg_utf8_encoded = qq_encode_to_gaim(im_group->font_attr, im_group->font_attr_len, msg_with_gaim_smiley); else msg_utf8_encoded = qq_to_utf8(msg_with_gaim_smiley, QQ_CHARSET_DEFAULT); group = qq_group_find_by_id(gc, internal_group_id, QQ_INTERNAL_ID); g_return_if_fail(group != NULL); conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, group->group_name_utf8, gaim_connection_get_account(gc)); if (conv == NULL && gaim_prefs_get_bool("/plugins/prpl/qq/prompt_group_msg_on_recv")) { serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8); conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, group->group_name_utf8, gaim_connection_get_account(gc)); } if (conv != NULL) { member = qq_group_find_member_by_uid(group, im_group->member_uid); if (member == NULL || member->nickname == NULL) im_src_name = uid_to_gaim_name(im_group->member_uid); else im_src_name = g_strdup(member->nickname); serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT (conv)), im_src_name, 0, msg_utf8_encoded, im_group->send_time); g_free(im_src_name); } g_free(hex_dump); g_free(msg_with_gaim_smiley); g_free(msg_utf8_encoded); g_free(im_group->msg); g_free(im_group->font_attr); }