Ejemplo n.º 1
0
static void ggp_chat_left(ggp_chat_local_info *chat, uin_t uin)
{
	uin_t me;
	int idx = ggp_chat_participant_find(chat, uin);

	if (idx < 0) {
		purple_debug_warning("gg", "ggp_chat_joined: "
			"user %u isn't present in chat %" G_GUINT64_FORMAT "\n",
			uin, chat->id);
		return;
	}
	chat->participants[idx] =
		chat->participants[chat->participants_count - 1];
	chat->participants_count--;
	chat->participants = g_realloc(chat->participants,
		sizeof(uin) * chat->participants_count);

	if (chat->conv == NULL)
		return;

	me = ggp_str_to_uin(purple_account_get_username(
		purple_connection_get_account(chat->gc)));

	if (me == uin) {
		purple_conversation_write_system_message(
			PURPLE_CONVERSATION(chat->conv),
			_("You have left the chat"), 0);
		purple_serv_got_chat_left(chat->gc, chat->local_id);
		chat->conv = NULL;
		chat->left = TRUE;
	}
	purple_chat_conversation_remove_user(chat->conv, ggp_uin_to_str(uin), NULL);
}
Ejemplo n.º 2
0
/* put Message to User Conversation
 *
 * 	passport - the one want to talk to you
 */
void
msn_session_report_user(MsnSession *session,const char *passport,const char *msg,PurpleMessageFlags flags)
{
	PurpleIMConversation * im;

	if ((im = msn_session_get_im(session,passport)) != NULL){
		purple_conversation_write_system_message(
			PURPLE_CONVERSATION(im), msg, flags);
	}
}
Ejemplo n.º 3
0
int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
{
	PurpleConversation *convo = purple_conversations_find_with_account(target, irc->account);
	char *buf;

	if (!convo)
		return 1;

	buf = g_strdup_printf(_("Unknown command: %s"), cmd);
	purple_conversation_write_system_message(convo, buf, PURPLE_MESSAGE_NO_LOG);
	g_free(buf);

	return 1;
}
Ejemplo n.º 4
0
/******************************************************************************
 * Functions
 *****************************************************************************/
PurpleCmdRet yahoo_doodle_purple_cmd_start(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data)
{
	PurpleAccount *account;
	PurpleConnection *gc;
	const gchar *name;

	if(*args && args[0])
		return PURPLE_CMD_RET_FAILED;

	account = purple_conversation_get_account(conv);
	gc = purple_account_get_connection(account);
	name = purple_conversation_get_name(conv);
	yahoo_doodle_initiate(gc, name);

	/* Write a local message to this conversation showing that a request for a
	 * Doodle session has been made
	 */
	purple_conversation_write_system_message(conv, _("Sent Doodle request."),
		PURPLE_MESSAGE_NICK);

	return PURPLE_CMD_RET_OK;
}
Ejemplo n.º 5
0
static void ggp_chat_open_conv(ggp_chat_local_info *chat)
{
	int i;

	if (chat->conv != NULL)
		return;

	chat->conv = purple_serv_got_joined_chat(chat->gc, chat->local_id,
		ggp_chat_get_name_from_id(chat->id));
	if (chat->previously_joined) {
		purple_conversation_write_system_message(
			PURPLE_CONVERSATION(chat->conv),
			_("You have re-joined the chat"), 0);
	}
	chat->previously_joined = TRUE;

	purple_chat_conversation_clear_users(chat->conv);
	for (i = 0; i < chat->participants_count; i++) {
		purple_chat_conversation_add_user(chat->conv,
			ggp_uin_to_str(chat->participants[i]), NULL,
			PURPLE_CHAT_USER_NONE, FALSE);
	}
}
Ejemplo n.º 6
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);
}
Ejemplo n.º 7
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);
	}
}