示例#1
0
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt)
{
	struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
	GaimConversation *c = NULL;
	GSList *l;
	GList *members = NULL;
	char *room = NULL;
	char *topic = NULL;
	char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber;

	if (pkt->status == -1) {
		gaim_notify_error(gc, NULL, _("Failed to join chat"), _("Maybe the room is full?"));
		return;
	}

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

		switch (pair->key) {

		case 104:
			room = pair->value;
			break;
		case 105:
			topic = pair->value;
			break;
		case 128:
			someid = pair->value;
			break;
		case 108: /* number of joiners */
			break;
		case 129:
			someotherid = pair->value;
			break;
		case 130:
			somebase64orhashosomething = pair->value;
			break;
		case 126:
			somenegativenumber = pair->value;
			break;
		case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */
			break;
		case 61: /*this looks similiar to 130 */
			break;

		/* the previous section was just room info. this next section is
		   info about individual room members, (including us) */

		case 109: /* the yahoo id */
			members = g_list_append(members, pair->value);
			break;
		case 110: /* age */
			break;
		case 141: /* nickname */
			break;
		case 142: /* location */
			break;
		case 113: /* bitmask */
			break;
		}
	}

	if (!room)
		return;

	if (yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name))
		yahoo_c_leave(gc, YAHOO_CHAT_ID);

	c = gaim_find_chat(gc, YAHOO_CHAT_ID);

	if (!c) {
		c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
		if (topic)
			gaim_chat_set_topic(GAIM_CHAT(c), NULL, topic);
		yd->in_chat = 1;
		yd->chat_name = g_strdup(room);
		gaim_chat_add_users(GAIM_CHAT(c), members);
	} else {
		yahoo_chat_add_users(GAIM_CHAT(c), members);
	}

	g_list_free(members);
}
示例#2
0
文件: yahoochat.c 项目: VoxOx/VoxOx
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt)
{
	GaimAccount *account = gaim_connection_get_account(gc);
	struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
	GaimConversation *c = NULL;
	GSList *l;
	GList *members = NULL;
	GList *roomies = NULL;
	char *room = NULL;
	char *topic = NULL;
	char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber;

	if (pkt->status == -1) {
		/* We can't join */
		struct yahoo_pair *pair = pkt->hash->data;
		gchar const *failed_to_join = _("Failed to join chat");
		switch (atoi(pair->value)) {
			case 0xFFFFFFFA: /* -6 */
				gaim_notify_error(gc, NULL, failed_to_join, _("Unknown room"));
				break;
			case 0xFFFFFFF1: /* -15 */
				gaim_notify_error(gc, NULL, failed_to_join, _("Maybe the room is full"));
				break;
			case 0xFFFFFFDD: /* -35 */
				gaim_notify_error(gc, NULL, failed_to_join, _("Not available"));
				break;
			default:
				gaim_notify_error(gc, NULL, failed_to_join,
						_("Unknown error. You may need to logout and wait five minutes before being able to rejoin a chatroom"));
		}
		return;
	}

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

		switch (pair->key) {

		case 104:
			room = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 105:
			topic = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 128:
			someid = pair->value;
			break;
		case 108: /* number of joiners */
			break;
		case 129:
			someotherid = pair->value;
			break;
		case 130:
			somebase64orhashosomething = pair->value;
			break;
		case 126:
			somenegativenumber = pair->value;
			break;
		case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */
			break;
		case 61: /*this looks similar to 130 */
			break;

		/* the previous section was just room info. this next section is
		   info about individual room members, (including us) */

		case 109: /* the yahoo id */
			members = g_list_append(members, pair->value);
			break;
		case 110: /* age */
			break;
		case 141: /* nickname */
			break;
		case 142: /* location */
			break;
		case 113: /* bitmask */
			break;
		}
	}

	if (room && yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name))
		yahoo_chat_leave(gc, room,
				gaim_connection_get_display_name(gc), FALSE);

	c = gaim_find_chat(gc, YAHOO_CHAT_ID);

	if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members &&
	   ((g_list_length(members) > 1) ||
	     !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) {
		int i;
		GList *flags = NULL;
		for (i = 0; i < g_list_length(members); i++)
			flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE));
		if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) {
			/* this might be a hack, but oh well, it should nicely */
			char *tmpmsg;

			gaim_conversation_set_name(c, room);

			c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
			if (topic)
				gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
			yd->in_chat = 1;
			yd->chat_name = g_strdup(room);
			gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE);

			tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room);
			gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL));
			g_free(tmpmsg);
		} else {
			c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
			if (topic)
				gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
			yd->in_chat = 1;
			yd->chat_name = g_strdup(room);
			gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE);
		}
		g_list_free(flags);
	} else if (c) {
		yahoo_chat_add_users(GAIM_CONV_CHAT(c), members);
	}

	if (account->deny && c) {
		GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(c);
		for (l = account->deny; l != NULL; l = l->next) {
			for (roomies = members; roomies; roomies = roomies->next) {
				if (!gaim_utf8_strcasecmp((char *)l->data, roomies->data)) {
					gaim_debug_info("yahoo", "Ignoring room member %s in room %s\n" , roomies->data, room ? room : "");
					gaim_conv_chat_ignore(GAIM_CONV_CHAT(c),roomies->data);
					ops->chat_update_user(c, roomies->data);
				}
			}
		}
	}
	g_list_free(roomies);
	g_list_free(members);
	g_free(room);
	g_free(topic);
}
示例#3
0
void yahoo_process_chat_join(PurpleConnection *gc, struct yahoo_packet *pkt)
{
	PurpleAccount *account = purple_connection_get_account(gc);
	YahooData *yd = purple_connection_get_protocol_data(gc);
	PurpleChatConversation *c = NULL;
	GSList *l;
	GList *members = NULL;
	GList *roomies = NULL;
	char *room = NULL;
	char *topic = NULL;

	if (pkt->status == -1) {
		/* We can't join */
		struct yahoo_pair *pair = pkt->hash->data;
		gchar const *failed_to_join = _("Failed to join chat");
		switch (atoi(pair->value)) {
			case 0xFFFFFFFA: /* -6 */
				purple_notify_error(gc, NULL, failed_to_join,
					_("Unknown room"),
					purple_request_cpar_from_connection(gc));
				break;
			case 0xFFFFFFF1: /* -15 */
				purple_notify_error(gc, NULL, failed_to_join,
					_("Maybe the room is full"),
					purple_request_cpar_from_connection(gc));
				break;
			case 0xFFFFFFDD: /* -35 */
				purple_notify_error(gc, NULL, failed_to_join,
					_("Not available"),
					purple_request_cpar_from_connection(gc));
				break;
			default:
				purple_notify_error(gc, NULL, failed_to_join,
					_("Unknown error. You may need to "
					"logout and wait five minutes before "
					"being able to rejoin a chatroom"),
					purple_request_cpar_from_connection(gc));
		}
		return;
	}

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

		switch (pair->key) {

		case 104:
			g_free(room);
			room = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 105:
			g_free(topic);
			topic = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 128: /* some id */
			break;
		case 108: /* number of joiners */
			break;
		case 129: /* some other id */
			break;
		case 130: /* some base64 or hash or something */
			break;
		case 126: /* some negative number */
			break;
		case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */
			break;
		case 61: /*this looks similar to 130 */
			break;

		/* the previous section was just room info. this next section is
		   info about individual room members, (including us) */

		case 109: /* the yahoo id */
			if (g_utf8_validate(pair->value, -1, NULL)) {
				members = g_list_append(members, pair->value);
			} else {
				purple_debug_warning("yahoo", "yahoo_process_chat_join "
						"got non-UTF-8 string for key %d\n", pair->key);
			}
			break;
		case 110: /* age */
			break;
		case 141: /* nickname */
			break;
		case 142: /* location */
			break;
		case 113: /* bitmask */
			break;
		}
	}

	if (room && yd->chat_name && purple_utf8_strcasecmp(room, yd->chat_name))
		yahoo_chat_leave(gc, room,
				purple_connection_get_display_name(gc), FALSE);

	c = purple_conversations_find_chat(gc, YAHOO_CHAT_ID);

	if (room && (!c || purple_chat_conversation_has_left(c)) &&
	    members && (members->next ||
	     !g_ascii_strcasecmp(members->data, purple_connection_get_display_name(gc)))) {
		GList *l;
		GList *flags = NULL;
		for (l = members; l; l = l->next)
			flags = g_list_prepend(flags, GINT_TO_POINTER(PURPLE_CHAT_USER_NONE));
		if (c && purple_chat_conversation_has_left(c)) {
			/* this might be a hack, but oh well, it should nicely */
			char *tmpmsg;

			purple_conversation_set_name(PURPLE_CONVERSATION(c), room);

			c = purple_serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
			if (topic) {
				purple_chat_conversation_set_topic(c, NULL, topic);
				/* Also print the topic to the backlog so that the captcha link is clickable */
				purple_conversation_write_system_message(PURPLE_CONVERSATION(c), topic, 0);
			}
			yd->in_chat = 1;
			yd->chat_name = g_strdup(room);
			purple_chat_conversation_add_users(c, members, NULL, flags, FALSE);

			tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room);
			purple_conversation_write_system_message(PURPLE_CONVERSATION(c), tmpmsg, 0);
			g_free(tmpmsg);
		} else {
			c = purple_serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
			if (topic) {
				purple_chat_conversation_set_topic(c, NULL, topic);
				/* Also print the topic to the backlog so that the captcha link is clickable */
				purple_conversation_write_system_message(PURPLE_CONVERSATION(c), topic, 0);
			}
			yd->in_chat = 1;
			yd->chat_name = g_strdup(room);
			purple_chat_conversation_add_users(c, members, NULL, flags, FALSE);
		}
		g_list_free(flags);
	} else if (c) {
		if (topic) {
			const char *cur_topic = purple_chat_conversation_get_topic(c);
			if (cur_topic == NULL || strcmp(cur_topic, topic) != 0)
				purple_chat_conversation_set_topic(c, NULL, topic);
		}
		yahoo_chat_add_users(c, members);
	}

	if (purple_account_privacy_get_denied(account) && c) {
		PurpleConversationUiOps *ops = purple_conversation_get_ui_ops(PURPLE_CONVERSATION(c));
		for (l = purple_account_privacy_get_denied(account); l != NULL; l = l->next) {
			for (roomies = members; roomies; roomies = roomies->next) {
				if (!purple_utf8_strcasecmp((char *)l->data, roomies->data)) {
					purple_debug_info("yahoo", "Ignoring room member %s in room %s\n" , (char *)roomies->data, room ? room : "");
					purple_chat_conversation_ignore(c,roomies->data);
					ops->chat_update_user(purple_chat_conversation_find_user(c, roomies->data));
				}
			}
		}
	}
	g_list_free(roomies);
	g_list_free(members);
	g_free(room);
	g_free(topic);
}