Example #1
0
void hon_parse_channel_auth_list(PurpleConnection *gc,gchar* buffer)
{
    PurpleConversation* chat;
    guint32 count,chatid = read_guint32(buffer);
    count = read_guint32(buffer);
    chat = purple_find_chat(gc,chatid);
    if (!chat)
        return;
    purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "", 
        _("Listing Authorized Users..."),
        PURPLE_MESSAGE_SYSTEM, time(NULL));
    if (count == 0)
    {
        purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "", 
            _("There are no authorized users for this channel."),
            PURPLE_MESSAGE_SYSTEM, time(NULL));
    } 
    else
    {
        while (count--)
        {
            purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "", 
                buffer,
                PURPLE_MESSAGE_SYSTEM, time(NULL));
            read_string(buffer);
        }
    }
    
}
Example #2
0
void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	char *chan, *topic, *msg, *nick, *tmp, *tmp2;
	PurpleConversation *convo;

	if (!strcmp(name, "topic")) {
		chan = args[0];
		topic = irc_mirc2txt (args[1]);
	} else {
		chan = args[1];
		topic = irc_mirc2txt (args[2]);
	}

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chan, irc->account);
	if (!convo) {
		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan);
		g_free(topic);
		return;
	}

	/* If this is an interactive update, print it out */
	tmp = g_markup_escape_text(topic, -1);
	tmp2 = purple_markup_linkify(tmp);
	g_free(tmp);
	if (!strcmp(name, "topic")) {
		const char *current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(convo));
		if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0))
		{
			char *nick_esc;
			nick = irc_mask_nick(from);
			nick_esc = g_markup_escape_text(nick, -1);
			purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), nick, topic);
			if (*tmp2)
				msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2);
			else
				msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc);
			g_free(nick_esc);
			g_free(nick);
			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), from, msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
			g_free(msg);
		}
	} else {
		char *chan_esc = g_markup_escape_text(chan, -1);
		msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2);
		g_free(chan_esc);
		purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic);
		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
		g_free(msg);
	}
	g_free(tmp2);
	g_free(topic);
}
Example #3
0
/* merge this with the function below when we get everyone on the same page wrt /commands */
void jabber_chat_change_topic(JabberChat *chat, const char *topic)
{
	if(topic && *topic) {
		JabberMessage *jm;
		jm = g_new0(JabberMessage, 1);
		jm->js = chat->js;
		jm->type = JABBER_MESSAGE_GROUPCHAT;
		jm->subject = purple_markup_strip_html(topic);
		jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
		jabber_message_send(jm);
		jabber_message_free(jm);
	} else {
		const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(chat->conv));
		char *buf, *tmp, *tmp2;

		if(cur) {
			tmp = g_markup_escape_text(cur, -1);
			tmp2 = purple_markup_linkify(tmp);
			buf = g_strdup_printf(_("current topic is: %s"), tmp2);
			g_free(tmp);
			g_free(tmp2);
		} else
			buf = g_strdup(_("No topic is set"));
		purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf,
				PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
		g_free(buf);
	}

}
Example #4
0
void PurpleLine::write_message(PurpleConversation *conv, std::string &from, std::string &text,
    time_t mtime, int flags)
{
    if (!conv)
        return;

    PurpleConversationType type = purple_conversation_get_type(conv);

    if (type == PURPLE_CONV_TYPE_IM) {
        purple_conv_im_write(
            PURPLE_CONV_IM(conv),
            from.c_str(),
            text.c_str(),
            (PurpleMessageFlags)flags,
            mtime);
    } else if (type == PURPLE_CONV_TYPE_CHAT) {
        purple_conv_chat_write(
            PURPLE_CONV_CHAT(conv),
            from.c_str(),
            text.c_str(),
            (PurpleMessageFlags)flags,
            mtime);
    } else {
        purple_debug_warning("line", "write_message for weird conversation type: %d\n", type);
    }
}
Example #5
0
void hon_parse_channel_ban_unban(PurpleConnection *gc,gchar* buffer,guint16 packet_id)
{
    hon_account* hon = gc->proto_data;
    guint32 chatid,kickerid;
    gchar* kicked,*kicker,*msg,*action;
    PurpleConversation* chat;
    chatid = read_guint32(buffer);
    kickerid = read_guint32(buffer);
    kicked = read_string(buffer);
    chat = purple_find_chat(gc,chatid);
    if (!chat)
        return;

    if (kickerid == hon->self.account_id)
        kicker = hon->self.nickname;
    else if((kicker = g_hash_table_lookup(hon->id2nick,GINT_TO_POINTER(kickerid))))
    {}
    else
        kicker = _("Someone");

    if (packet_id == HON_SC_CHANNEL_BAN)
        action = _("banned");
    else
        action = _("unbanned");
    

    msg = g_strdup_printf(_("%s was %s from the channel by %s."),kicked,action,kicker);
    purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
    g_free(msg);
}
Example #6
0
void jabber_chat_change_nick(JabberChat *chat, const char *nick)
{
	xmlnode *presence;
	char *full_jid;
	PurplePresence *gpresence;
	PurpleStatus *status;
	JabberBuddyState state;
	char *msg;
	int priority;

	if(!chat->muc) {
		purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "",
				_("Nick changing not supported in non-MUC chatrooms"),
				PURPLE_MESSAGE_SYSTEM, time(NULL));
		return;
	}

	gpresence = purple_account_get_presence(chat->js->gc->account);
	status = purple_presence_get_active_status(gpresence);

	purple_status_to_jabber(status, &state, &msg, &priority);

	presence = jabber_presence_create(state, msg, priority);
	full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, nick);
	xmlnode_set_attrib(presence, "to", full_jid);
	g_free(full_jid);
	g_free(msg);

	jabber_send(chat->js, presence);
	xmlnode_free(presence);
}
Example #7
0
void hon_parse_channel_auth_enable_disable(PurpleConnection *gc,gchar* buffer,guint16 packet_id)
{
    PurpleConversation* chat;
    guint32 chatid = read_guint32(buffer);
    chat = purple_find_chat(gc,chatid);
    if (!chat)
        return;
    if (packet_id == HON_SC_CHANNEL_AUTH_ENABLE)
        purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "", 
        _("Authorization has been enabled for this channel, you must now be on the authorized list to join."),
        PURPLE_MESSAGE_SYSTEM, time(NULL));
    else
        purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "",
        _("Authorization has been disabled for this channel, all users can now join."),
        PURPLE_MESSAGE_SYSTEM, time(NULL));
}
Example #8
0
static int waprpl_send_chat(PurpleConnection * gc, int id, const char *message, PurpleMessageFlags flags)
{
	whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
	PurpleAccount *account = purple_connection_get_account(gc);
	PurpleConversation *convo = purple_find_chat(gc, id);
	PurpleChat *ch = blist_find_chat_by_convo(gc, id);
	GHashTable *hasht = purple_chat_get_components(ch);
	char *chat_id = g_hash_table_lookup(hasht, "id");
	char *plain;

	purple_markup_html_to_xhtml(message, NULL, &plain);

	char msgid[128];
	waAPI_getmsgid(wconn->waAPI, msgid);

	purple_signal_emit(purple_connection_get_prpl(gc), "whatsapp-sending-message", gc, msgid, chat_id, message);

	waAPI_sendchat(wconn->waAPI, msgid, chat_id, plain);
	g_free(plain);

	waprpl_check_output(gc);

	const char *me = purple_account_get_string(account, "nick", "");
	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), me, message, PURPLE_MESSAGE_SEND, time(NULL));

	return 1;
}
Example #9
0
void hon_parse_channel_kick(PurpleConnection *gc,gchar* buffer){
    hon_account* hon = gc->proto_data;
    guint32 chatid,kickerid,kickedid;
    gchar* kicked,*kicker,*msg;
    PurpleConversation* chat;
    chatid = read_guint32(buffer);
    kickerid = read_guint32(buffer);
    kickedid = read_guint32(buffer);
    chat = purple_find_chat(gc,chatid);
    if (!chat)
        return;

    if (kickerid == hon->self.account_id)
        kicker = hon->self.nickname;
    else if((kicker = g_hash_table_lookup(hon->id2nick,GINT_TO_POINTER(kickerid))))
    {}
    else
        kicker = _("Someone");

    if (kickedid == hon->self.account_id)
        kicked = hon->self.nickname;
    else if((kicked = g_hash_table_lookup(hon->id2nick,GINT_TO_POINTER(kickedid))))
    {}
    else
        kicked = _("Someone");

    msg = g_strdup_printf(_("%s was kicked from the channel by %s"),kicked,kicker);
    purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));

    if (kickedid == hon->self.account_id)
        serv_got_chat_left(gc, chatid);

    g_free(msg);
}
Example #10
0
void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConnection *gc = purple_account_get_connection(irc->account);
	PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account);
	char *nick = irc_mask_nick(from), *buf;

	if (!gc) {
		g_free(nick);
		return;
	}

	if (!convo) {
		purple_debug(PURPLE_DEBUG_ERROR, "irc", "Recieved a KICK for unknown channel %s\n", args[0]);
		g_free(nick);
		return;
	}

	if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) {
		buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]);
		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
		g_free(buf);
		serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)));
	} else {
		buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]);
		purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf);
		g_free(buf);
	}

	g_free(nick);
	return;
}
Example #11
0
void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConversation *convo;

	if (!args || !args[0] || !args[1])
		return;

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
						      args[1], irc->account);

	if (!strcmp(name, "367")) {
		char *msg = NULL;
		/* Ban list entry */
		if (!args[2])
			return;
		if (args[3] && args[4]) {
			/* This is an extended syntax, not in RFC 1459 */
			int t1 = atoi(args[4]);
			time_t t2 = time(NULL);
			char *time = purple_str_seconds_to_string(t2 - t1);
			msg = g_strdup_printf(_("Ban on %s by %s, set %s ago"),
			                      args[2], args[3], time);
			g_free(time);
		} else {
			msg = g_strdup_printf(_("Ban on %s"), args[2]);
		}
		if (convo) {
			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg,
			                       PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
			                       time(NULL));
		} else {
			purple_debug_info("irc", "%s\n", msg);
		}
		g_free(msg);
	} else if (!strcmp(name, "368")) {
		if (!convo)
			return;
		/* End of ban list */
		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "",
		                       _("End of ban list"),
		                       PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
		                       time(NULL));
	}
}
Example #12
0
void hon_parse_channel_silenced(PurpleConnection* gc,gchar* buffer){
    PurpleConversation *convo;
    guint32 chan_id = read_guint32(buffer);
    convo = purple_find_chat(gc,chan_id);
    if (!convo) {
        purple_debug(PURPLE_DEBUG_ERROR, HON_DEBUG_PREFIX, "Got a silenced message for %d, which doesn't exist\n", chan_id);
        return;
    }
    purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", _("You are silenced in this channel and cannot talk."), PURPLE_MESSAGE_SYSTEM, time(NULL));
}
Example #13
0
void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);

	purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]);
	if (convo) {
		/*g_slist_remove(irc->gc->buddy_chats, convo);
		  purple_conversation_set_account(convo, NULL);*/
		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
	}
}
Example #14
0
static PurpleCmdRet
send_whisper(PurpleConversation *conv, const char *cmd, char **args,
    char **error, void *userdata)
{
  const char *to_username;
  const char *message;
  const char *from_username;
  PurpleConvChat *chat;
  PurpleConvChatBuddy *chat_buddy;
  PurpleConnection *to;

  // parse args
  to_username = args[0];
  message = args[1];

  if (!to_username || strlen(to_username) == 0) {
    *error = g_strdup(_("Whisper is missing recipient."));
    return PURPLE_CMD_RET_FAILED;
  } else if (!message || strlen(message) == 0) {
    *error = g_strdup(_("Whisper is missing message."));
    return PURPLE_CMD_RET_FAILED;
  }

  from_username = conv->account->username;
  purple_debug_info("purplemot", "%s whispers to %s in chat room %s: %s\n",
                    from_username, to_username, conv->name, message);

  chat = purple_conversation_get_chat_data(conv);
  chat_buddy = purple_conv_chat_cb_find(chat, to_username);
  to = get_purplemot_gc(to_username);

  if (!chat_buddy) {
    // this will be freed by the caller
    *error = g_strdup_printf(_("%s is not logged in."), to_username);
    return PURPLE_CMD_RET_FAILED;
  } else if (!to) {
    *error = g_strdup_printf(_("%s is not in this chat room."), to_username);
    return PURPLE_CMD_RET_FAILED;
  } else {
    // write the whisper in the sender's chat window
    char *message_to = g_strdup_printf("%s (to %s)", message, to_username);
    purple_conv_chat_write(chat, from_username, message_to,
                           PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER,
                           time(NULL));
    g_free(message_to);

    // send the whisper
    serv_chat_whisper(to, chat->id, from_username, message);

    return PURPLE_CMD_RET_OK;
  }
}
Example #15
0
void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConversation *convo;

	if (!args || !args[1] || !args[2])
		return;

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
	if (!convo)
		return;

	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL));
}
Example #16
0
void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConnection *gc;
	PurpleConversation *convo;

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
	if (convo) {
		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
	} else {
		if ((gc = purple_account_get_connection(irc->account)) == NULL)
			return;
		purple_notify_error(gc, NULL, _("Could not send"), args[2]);
	}
}
Example #17
0
void hon_parse_channel_silence_lifted(PurpleConnection* gc,gchar* buffer){
    PurpleConversation *convo;
    gchar * msg;
    convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,buffer,gc->account);
    if (!convo) {
        purple_debug(PURPLE_DEBUG_ERROR, HON_DEBUG_PREFIX, "Got an unsilenced message for %s, which doesn't exist\n", buffer);
    }
    else
    {
        msg = g_strdup_printf(_("Your silence has been lifted in the channel '%s'."),buffer);
        purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
        g_free(msg);
    }
}
Example #18
0
void hon_parse_channel_password_changed(PurpleConnection* gc,gchar* buffer){
    PurpleConversation *convo;
    gchar * msg;
    guint32 chan_id = read_guint32(buffer);
    convo = purple_find_chat(gc,chan_id);
    if (!convo) {
        purple_debug(PURPLE_DEBUG_ERROR, HON_DEBUG_PREFIX, "Got a message for %d, which doesn't exist\n", chan_id);
    }
    else
    {
        msg = g_strdup_printf(_("The password for this channel has been changed by %s."),buffer);
        purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
        g_free(msg);
    }
}
Example #19
0
void hon_parse_channel_silence_placed(PurpleConnection* gc,gchar* buffer){
    PurpleConversation *convo;
    gchar * msg , *silencer, *silenced,*chatname;
    guint32 duration;
    chatname = read_string(buffer);
    silencer = read_string(buffer);
    silenced = read_string(buffer);
    duration = read_guint32(buffer);
    convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,chatname,gc->account);
    if (!convo) {
        purple_debug(PURPLE_DEBUG_ERROR, HON_DEBUG_PREFIX, "Got a silenced message for %s, which doesn't exist\n", chatname);
        return;
    }
    msg = g_strdup_printf(_("%s has been silenced by %s for %d ms."),silenced,silencer,duration);
    purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
    g_free(msg);
}
Example #20
0
void flist_channel_show_message(FListAccount *fla, const gchar *channel) {
    PurpleConvChat *chat;
    gchar *to_print, *to_print_formatted;
    gboolean show_chat, show_ads;
    show_ads = flist_get_channel_show_ads(fla, channel);
    show_chat = flist_get_channel_show_chat(fla, channel);
    
    chat = PURPLE_CONV_CHAT(purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel, fla->pa));
    if(!chat) return;
    
    to_print = g_strdup_printf("We are currently [i]%s[/i] and [i]%s[/i].",
            show_chat ? "showing chat" : "[color=red]hiding chat[/color]",
            show_ads ? "showing ads" : "[color=red]hiding ads[/color]");
    to_print_formatted = flist_bbcode_to_html(fla, (PurpleConversation*) chat, to_print);
    purple_conv_chat_write(chat, "System", to_print_formatted, PURPLE_MESSAGE_SYSTEM, time(NULL));
    g_free(to_print);
    g_free(to_print_formatted);
}
Example #21
0
void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConversation *convo;
	char *buf, *escaped;

	if (!args || !args[1] || !args[2])
		return;

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
	if (!convo)	/* XXX punt on channels we are not in for now */
		return;

	escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL;
	buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : "");
	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL));
	g_free(escaped);
	g_free(buf);

	return;
}
Example #22
0
void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConversation *convo;
	char *buf, *nick;

	if (!args || !args[0] || !args[1] || !args[2])
		return;

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
	if (!convo)
		return;

	nick = g_markup_escape_text(args[2], -1);
	buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick);
	g_free(nick);
	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf,
			     PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG,
			     time(NULL));
	g_free(buf);
}
Example #23
0
void hon_parse_channel_auth_add_delete(PurpleConnection *gc,gchar* buffer,guint16 packet_id)
{
    PurpleConversation* chat;
    gchar* msg_template,*msg;
    guint32 chatid = read_guint32(buffer);
    chat = purple_find_chat(gc,chatid);
    if (!chat)
        return;
    if (packet_id == HON_SC_CHANNEL_AUTH_ADD)
        msg_template = _("%s has been added to the authorization list.");
    else if (packet_id == HON_SC_CHANNEL_AUTH_DELETE)
        msg_template = _("%s has been removed from the authorization list.");
    else if (packet_id == HON_SC_CHANNEL_ADD_AUTH_FAIL)
        msg_template = _("%s is already on the authorization list.");
    else /* if (packet_id == HON_SC_CHANNEL_DEL_AUTH_FAIL)*/
        msg_template = _("%s is not on the authorization list.");
    msg = g_strdup_printf(msg_template,buffer);
    purple_conv_chat_write(PURPLE_CONV_CHAT(chat), "",msg,
        PURPLE_MESSAGE_SYSTEM, time(NULL));
    g_free(msg);
}
Example #24
0
void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConversation *convo;
	PurpleConnection *gc;
	char **parts, *msg;
	time_t oldstamp;

	if (!args || !args[1])
		return;

	parts = g_strsplit(args[1], " ", 2);

	if (!parts[0] || !parts[1]) {
		g_strfreev(parts);
		return;
	}

	if (sscanf(parts[1], "%lu", &oldstamp) != 1) {
		msg = g_strdup(_("Error: invalid PONG from server"));
	} else {
		msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp);
	}

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account);
	g_strfreev(parts);
	if (convo) {
		if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT)
			purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
		else
			purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL));
	} else {
		gc = purple_account_get_connection(irc->account);
		if (!gc) {
			g_free(msg);
			return;
		}
		purple_notify_info(gc, NULL, "PONG", msg);
	}
	g_free(msg);
}
Example #25
0
static PurpleCmdRet
skypeweb_cmd_topic(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
{
	PurpleConnection *pc = NULL;
	PurpleChatConversation *chat;
	int id = -1;
	
	pc = purple_conversation_get_connection(conv);
	chat = PURPLE_CHAT_CONVERSATION(conv);
	id = purple_chat_conversation_get_id(chat);
	
	if (pc == NULL || id == -1)
		return PURPLE_CMD_RET_FAILED;

	if (!args || !args[0]) {
		gchar *buf;
		const gchar *topic = purple_chat_conversation_get_topic(chat);

		if (topic) {
			gchar *tmp, *tmp2;
			tmp = g_markup_escape_text(topic, -1);
			tmp2 = purple_markup_linkify(tmp);
			buf = g_strdup_printf(_("current topic is: %s"), tmp2);
			g_free(tmp);
			g_free(tmp2);
		} else {
			buf = g_strdup(_("No topic is set"));
		}
		
		purple_conv_chat_write(chat, NULL, buf, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
		
		g_free(buf);
		return PURPLE_CMD_RET_OK;
	}
	
	skypeweb_chat_set_topic(pc, id, args ? args[0] : NULL);
	
	return PURPLE_CMD_RET_OK;
}
Example #26
0
static void
jabber_chat_affiliation_list_cb(JabberStream *js, const char *from,
                                JabberIqType type, const char *id,
                                xmlnode *packet, gpointer data)
{
	JabberChat *chat;
	xmlnode *query, *item;
	int chat_id = GPOINTER_TO_INT(data);
	GString *buf;

	if(!(chat = jabber_chat_find_by_id(js, chat_id)))
		return;

	if (type == JABBER_IQ_ERROR)
		return;

	if(!(query = xmlnode_get_child(packet, "query")))
		return;

	buf = g_string_new(_("Affiliations:"));

	item = xmlnode_get_child(query, "item");
	if (item) {
		for( ; item; item = xmlnode_get_next_twin(item)) {
			const char *jid = xmlnode_get_attrib(item, "jid");
			const char *affiliation = xmlnode_get_attrib(item, "affiliation");
			if (jid && affiliation)
				g_string_append_printf(buf, "\n%s %s", jid, affiliation);
		}
    } else {
		buf = g_string_append_c(buf, '\n');
		buf = g_string_append_len(buf, _("No users found"), -1);
	}

	purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf->str,
    	PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));

	g_string_free(buf, TRUE);
}
Example #27
0
void hon_parse_chat_topic(PurpleConnection* gc,gchar* buffer){
    PurpleConversation *convo;
    gchar * topic_raw, * topic_html, * msg;
    guint32 chan_id = read_guint32(buffer);
    convo = purple_find_chat(gc,chan_id);
    if (!convo) {
        purple_debug(PURPLE_DEBUG_ERROR, HON_DEBUG_PREFIX, "Got a topic for %d, which doesn't exist\n", chan_id);
    }
    else
    {
        topic_raw = hon_strip(buffer,FALSE);
        topic_html = hon2html(buffer);
        msg = g_strdup_printf(_("Topic changed to '%s'."), topic_html);

        purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic_raw);
        purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL));

        g_free(topic_raw);
        g_free(topic_html);
        g_free(msg);
    }
}
Example #28
0
/*------------------------------------------------------------------------
 * User has selected to invite somebody to a chatroom.
 *
 *  @param gc			The connection object
 *  @param id			The chat room ID
 *  @param msg			The invitation message entered by the user
 *  @param name			The username of the person to invite
 */
void mxit_chat_invite(PurpleConnection *gc, int id, const char *msg, const char *username)
{
	struct MXitSession* session = (struct MXitSession*) gc->proto_data;
	struct multimx* multimx = NULL;
	PurpleBuddy* buddy;
	PurpleConversation *convo;
	char* tmp;

	purple_debug_info(MXIT_PLUGIN_ID, "Groupchat invite to '%s'\n", username);

	/* Find matching MultiMX group */
	multimx = find_room_by_id(session, id);
	if (multimx == NULL) {
		purple_debug_error(MXIT_PLUGIN_ID, "Could not find groupchat %i\n", id);
		return;
	}

	/* Send invite to MXit */
	mxit_send_groupchat_invite(session, multimx->roomid, 1, &username);

	/* Find the buddy information for this contact (reference: "libpurple/blist.h") */
	buddy = purple_find_buddy(session->acc, username);
	if (!buddy) {
		purple_debug_warning(MXIT_PLUGIN_ID, "mxit_chat_invite: unable to find the buddy '%s'\n", username);
		return;
	}

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, multimx->roomname, session->acc);
	if (convo == NULL) {
		purple_debug_error(MXIT_PLUGIN_ID, "Conversation '%s' not found\n", multimx->roomname);
		return;
	}

	/* Display system message in chat window */
	tmp = g_strdup_printf("%s: %s", _("You have invited"), purple_buddy_get_alias(buddy));
	purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "MXit", tmp, PURPLE_MESSAGE_SYSTEM, time(NULL));
	g_free(tmp);
}
Example #29
0
/*------------------------------------------------------------------------
 * A user was kicked from the GroupChat.
 *
 *  @param session		The MXit session object
 *  @param multimx		The MultiMX room object
 *  @param nickname		The nickname of the user who was kicked
 */
static void member_kicked(struct MXitSession* session, struct multimx* multimx, const char* nickname)
{
	PurpleConversation *convo;

	purple_debug_info(MXIT_PLUGIN_ID, "member_kicked: '%s'\n", nickname);

	convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, multimx->roomname, session->acc);
	if (convo == NULL) {
		purple_debug_error(MXIT_PLUGIN_ID, "Conversation '%s' not found\n", multimx->roomname);
		return;
	}

	/* who was kicked? - compare to our original nickname */
	if (purple_utf8_strcasecmp(nickname, multimx->nickname) == 0)
	{
		/* you were kicked */
		purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "MXit", _("You have been kicked from this MultiMX."), PURPLE_MESSAGE_SYSTEM, time(NULL));
		purple_conv_chat_clear_users(PURPLE_CONV_CHAT(convo));
		serv_got_chat_left(session->con, multimx->chatid);
	}
	else
		purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nickname, _("was kicked"));
}
Example #30
0
void hon_parse_clan_message(PurpleConnection *gc,gchar* buffer){
    hon_account* hon = gc->proto_data;
    guint32 buddy_id;
    gchar* message,*user;
    PurpleConversation* clanConv;
    GString* clan_chat_name;
    buddy_id = read_guint32(buffer);
    message = hon2html(buffer);
    clan_chat_name = g_string_new("Clan ");
    clan_chat_name = g_string_append(clan_chat_name,hon->self.clan_name);
    clanConv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,clan_chat_name->str,gc->account);
    g_string_free(clan_chat_name,TRUE);
    if (clanConv)
    {
#ifndef MINBIF
        gchar* tmp = message;
        message = g_strdup_printf("[%s] %s" , _("WHISPER"),message);
        g_free(tmp);
#endif
        user = g_hash_table_lookup(hon->id2nick,GINT_TO_POINTER(buddy_id));
        purple_conv_chat_write(PURPLE_CONV_CHAT(clanConv), user,message, PURPLE_MESSAGE_WHISPER, time(NULL));
    }
    g_free(message);
}