Пример #1
0
static void ycht_progress_chatmsg(YchtConn *ycht, YchtPkt *pkt)
{
	char *who, *what, *msg;
	PurpleChatConversation *c;
	PurpleConnection *gc = ycht->gc;

	who = g_list_nth_data(pkt->data, 1);
	what = g_list_nth_data(pkt->data, 2);

	if (!who || !what)
		return;

	c = purple_conversations_find_chat(gc, YAHOO_CHAT_ID);
	if (!c)
		return;

	msg = yahoo_string_decode(gc, what, 1);
	what = yahoo_codes_to_html(msg);
	g_free(msg);

	if (pkt->service == YCHT_SERVICE_CHATMSG_EMOTE) {
		char *tmp = g_strdup_printf("/me %s", what);
		g_free(what);
		what = tmp;
	}

	purple_serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, what, time(NULL));
	g_free(what);
}
Пример #2
0
void yahoo_process_conference_message(GaimConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	char *msg = NULL;
	GaimConversation *c;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 57:
			room = pair->value;
			break;
		case 3:
			who = pair->value;
			break;
		case 14:
			msg = pair->value;
			break;
		}
	}

		if (room && who && msg) {
			c = yahoo_find_conference(gc, room);
			if (!c)
				return;
			msg = yahoo_codes_to_html(msg);
			serv_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(c)), who, 0, msg, time(NULL));
			g_free(msg);
		}

}
Пример #3
0
void yahoo_process_chat_message(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	char *room = NULL, *who = NULL, *msg = NULL, *msg2;
	int msgtype = 1, utf8 = 1; /* default to utf8 */
	PurpleConversation *c = NULL;
	GSList *l;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {

		case 97:
			utf8 = strtol(pair->value, NULL, 10);
			break;
		case 104:
			g_free(room);
			room = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 109:
			who = pair->value;
			break;
		case 117:
			msg = pair->value;
			break;
		case 124:
			msgtype = strtol(pair->value, NULL, 10);
			break;
		}
	}

	c = purple_find_chat(gc, YAHOO_CHAT_ID);
	if (!who || !c) {
		if (room)
			g_free(room);
		/* we still get messages after we part, funny that */
		return;
	}

	if (!msg) {
		purple_debug_misc("yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n");
		return;
	}
	msg2 = yahoo_string_decode(gc, msg, utf8);
	msg = yahoo_codes_to_html(msg2);
	g_free(msg2);

	if (msgtype == 2 || msgtype == 3) {
		char *tmp;
		tmp = g_strdup_printf("/me %s", msg);
		g_free(msg);
		msg = tmp;
	}

	serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, msg, time(NULL));
	g_free(msg);
	g_free(room);
}
Пример #4
0
void yahoo_process_conference_decline(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	char *msg = NULL;
	PurpleConversation *c = NULL;
	int utf8 = 0;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 57:
			g_free(room);
			room = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 54:
			who = pair->value;
			break;
		case 14:
			g_free(msg);
			msg = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 97:
			utf8 = strtol(pair->value, NULL, 10);
			break;
		}
	}
	if (!purple_privacy_check(purple_connection_get_account(gc), who))
	{
		g_free(room);
		g_free(msg);
		return;
	}

	if (who && room) {
		/* make sure we're in the room before we process a decline message for it */
		if((c = yahoo_find_conference(gc, room))) {
			char *tmp = NULL, *msg_tmp = NULL;
			if(msg)
			{
				msg_tmp = yahoo_string_decode(gc, msg, utf8);
				msg = yahoo_codes_to_html(msg_tmp);
				serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(c)), who, 0, msg, time(NULL));
				g_free(msg_tmp);
				g_free(msg);
			}

			tmp = g_strdup_printf(_("%s has declined to join."), who);
			purple_conversation_write(c, NULL, tmp, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LINKIFY, time(NULL));

			g_free(tmp);
		}

		g_free(room);
	}
}
Пример #5
0
void yahoo_process_conference_message(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	char *msg = NULL;
	int utf8 = 0;
	PurpleChatConversation *c;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 57:
			g_free(room);
			room = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 3:
			if (g_utf8_validate(pair->value, -1, NULL)) {
				who = pair->value;
			} else {
				purple_debug_warning("yahoo", "yahoo_process_conference_message "
						"got non-UTF-8 string for key %d\n", pair->key);
			}
			break;
		case 14:
			msg = pair->value;
			break;
		case 97:
			utf8 = strtol(pair->value, NULL, 10);
			break;
		}
	}

	if (room && who && msg) {
		char *msg2;

		c = yahoo_find_conference(gc, room);
		if (!c) {
			g_free(room);
			return;
		}

		msg2 = yahoo_string_decode(gc, msg, utf8);
		msg = yahoo_codes_to_html(msg2);
		purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c), who,
			PURPLE_MESSAGE_RECV, msg, time(NULL));
		g_free(msg);
		g_free(msg2);
	}

	g_free(room);
}
Пример #6
0
void yahoo_process_chat_message(GaimConnection *gc, struct yahoo_packet *pkt)
{
	char *room = NULL, *who = NULL, *msg = NULL;
	int msgtype = 1;
	GaimConversation *c = NULL;
	GSList *l;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {

		case 104:
			room = pair->value;
			break;
		case 109:
			who = pair->value;
			break;
		case 117:
			msg = pair->value;
			break;
		case 124:
			msgtype = strtol(pair->value, NULL, 10);
			break;
		}
	}

	if (!who)
		return;

	c = gaim_find_chat(gc, YAHOO_CHAT_ID);
	if (!c) {
		/* we still get messages after we part, funny that */
		return;
	}

	if (!msg) {
		gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n");
		return;
	}
	msg = yahoo_codes_to_html(msg);

	if (msgtype == 2 || msgtype == 3) {
		char *tmp;
		tmp = g_strdup_printf("/me %s", msg);
		g_free(msg);
		msg = tmp;
	}

	serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, msg, time(NULL));
	g_free(msg);
}
Пример #7
0
void yahoo_process_conference_message(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	char *msg = NULL;
	int utf8 = 0;
	PurpleConversation *c;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 57:
			g_free(room);
			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) {
		char *msg2;

		c = yahoo_find_conference(gc, room);
		if (!c) {
			g_free(room);
			return;
		}

		msg2 = yahoo_string_decode(gc, msg, utf8);
		msg = yahoo_codes_to_html(msg2);
		serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(c)), who, 0, msg, time(NULL));
		g_free(msg);
		g_free(msg2);
	}

	g_free(room);
}
Пример #8
0
void yahoo_process_conference_decline(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	char *msg = NULL;
	PurpleChatConversation *c = NULL;
	int utf8 = 0;

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 57:
			g_free(room);
			room = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 54:
			if (g_utf8_validate(pair->value, -1, NULL)) {
				who = pair->value;
			} else {
				purple_debug_warning("yahoo", "yahoo_process_conference_decline "
						"got non-UTF-8 string for key %d\n", pair->key);
			}
			break;
		case 14:
			g_free(msg);
			msg = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 97:
			utf8 = strtol(pair->value, NULL, 10);
			break;
		}
	}
	if (!purple_account_privacy_check(purple_connection_get_account(gc), who))
	{
		g_free(room);
		g_free(msg);
		return;
	}

	if (who && room) {
		/* make sure we're in the room before we process a decline message for it */
		if((c = yahoo_find_conference(gc, room))) {
			char *tmp = NULL, *msg_tmp = NULL;
			if(msg)
			{
				msg_tmp = yahoo_string_decode(gc, msg, utf8);
				msg = yahoo_codes_to_html(msg_tmp);
				purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c),
					who, PURPLE_MESSAGE_RECV, msg, time(NULL));
				g_free(msg_tmp);
				g_free(msg);
			}

			tmp = g_strdup_printf(_("%s has declined to join."), who);
			purple_conversation_write_system_message(PURPLE_CONVERSATION(c),
				tmp, PURPLE_MESSAGE_NO_LINKIFY);

			g_free(tmp);
		}

		g_free(room);
	}
}