Exemple #1
0
static void
irc_receiving_text(PurpleConnection *gc, const char **incoming, gpointer null)
{
	char **splits, *str;
	PurpleAccount *account = NULL;

	if (!incoming || !*incoming || !**incoming)   /* oh the fun .. I can do this all day! */
		return;

	splits = g_strsplit(*incoming, " ", -1);

	/* if there's not at least 5 elements in the string array, this isn't a kick; ignore  */
	if(g_strv_length(splits) < 5)
		return;

	account = purple_connection_get_account(gc);
	str = g_ascii_strdown(splits[1], -1);

	if (strcmp(str, "kick") == 0 && splits[2] && splits[3]) {
		char *name = splits[2];
		GList *chats = purple_get_chats();
		while (chats) {
			PurpleConversation *conv = chats->data;
			chats = chats->next;
			if (purple_conversation_get_account(conv) == account
					&& strcmp(purple_conversation_get_name(conv), name) == 0) {
				purple_timeout_add(100, show_them, conv);
				break;
			}
		}
	}

	g_free(str);
	g_strfreev(splits);
}
Exemple #2
0
void
_purple_conversations_update_cache(PurpleConversation *conv, const char *name,
		PurpleAccount *account)
{
	PurpleAccount *old_account;
	struct _purple_hconv *hc;

	g_return_if_fail(conv != NULL);
	g_return_if_fail(account != NULL || name != NULL);

	old_account = purple_conversation_get_account(conv);

	hc = g_new(struct _purple_hconv, 1);
	hc->im = PURPLE_IS_IM_CONVERSATION(conv);
	hc->account = old_account;
	hc->name = (gchar *)purple_normalize(old_account,
				purple_conversation_get_name(conv));

	g_hash_table_remove(conversation_cache, hc);

	if (account)
		hc->account = account;
	if (name)
		hc->name = g_strdup(purple_normalize(hc->account, name));

	g_hash_table_insert(conversation_cache, hc, conv);
}
Exemple #3
0
void PurpleChatMngr::UpdateBuddyTyping(PurpleConversation *conv, PurpleTypingState state)
{
	IMChat::TypingState mState;

	mConvInfo_t  *mConv   = (mConvInfo_t *)conv->ui_data;
	PurpleIMChat *mIMChat = FindIMChatByPurpleConv(conv);

	if (!mIMChat)
		return;

	switch (state)
	{
	case PURPLE_TYPING:
		mState = IMChat::TypingStateTyping;
		break;

	case PURPLE_TYPED:
		mState = IMChat::TypingStateStopTyping;
		break;

	default:
		mState = IMChat::TypingStateNotTyping;
		break;
	}

	// Get contact id. If it's a jabber contact, remove its ressource.
	const char*		name	  = purple_conversation_get_name(conv);
	PurpleAccount*	gAccount  = purple_conversation_get_account(conv);
	const char*		gPrclId	  = purple_account_get_protocol_id(gAccount);
	std::string		contactId = cleanContactId(name, PurpleIMPrcl::GetEnumIMProtocol(gPrclId));

//	mIMChat->typingStateChangedEvent(*mIMChat, *((IMChatSession *)(mConv->conv_session)), contactId, mState);
	mIMChat->typingStateChangedEvent(*mIMChat, *(mConv->conv_session), contactId, mState);		//VOXOX - JRT - 2009.07.09 
}
static void write_conv(PurpleConversation *conv, const char *who, const char *alias,
			const char *message, PurpleMessageFlags flags, time_t mtime)
{	
  if (im_handler != Qnil) {
    PurpleAccount* account = purple_conversation_get_account(conv);
    if (strcmp(purple_account_get_protocol_id(account), "prpl-msn") == 0 &&
         (strstr(message, "Message could not be sent") != NULL ||
          strstr(message, "Message was not sent") != NULL ||
          strstr(message, "Message may have not been sent") != NULL
         )
        ) {
      /* I have seen error like 'msn: Connection error from Switchboard server'.
       * In that case, libpurple will notify user with two regular im message.
       * The first message is an error message, the second one is the original message that failed to send.
       */
      notify_message(PURPLE_CONNECTION_ERROR_NETWORK_ERROR, message, purple_account_get_protocol_id(account), who);
    } else {
      VALUE args[3];
      args[0] = Data_Wrap_Struct(cAccount, NULL, NULL, account);
      args[1] = rb_str_new2(who);
      args[2] = rb_str_new2(message);
      check_callback(im_handler, "im_handler");
      rb_funcall2(im_handler, CALL, 3, args);
    }
  }
}
Exemple #5
0
static void pidginwhiteboard_button_start_press(GtkButton *button, gpointer data)
{
	PurpleConversation *conv = data;
	PurpleAccount *account = purple_conversation_get_account(conv);
	PurpleConnection *gc = purple_account_get_connection(account);
	char *to = (char*)(purple_conversation_get_name(conv));

	/* Only handle this if local client requested Doodle session (else local
	 * client would have sent one)
	 */
	PurpleWhiteboard *wb = purple_whiteboard_get(account, to);

	/* Write a local message to this conversation showing that a request for a
	 * Doodle session has been made
	 */
	/* XXXX because otherwise gettext will see this string, even though it's
	 * in an #if 0 block. Remove the XXXX if you want to use this code.
	 * But, it really shouldn't be a Yahoo-specific string. ;) */
	purple_conv_im_write(PURPLE_CONV_IM(conv), "", XXXX_("Sent Doodle request."),
					   PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_RECV, time(NULL));

	yahoo_doodle_command_send_request(gc, to);
	yahoo_doodle_command_send_ready(gc, to);

	/* Insert this 'session' in the list.  At this point, it's only a requested
	 * session.
	 */
	wb = purple_whiteboard_create(account, to, DOODLE_STATE_REQUESTING);
}
Exemple #6
0
static gboolean
chat_nick_matches_name(PurpleConversation *conv, const char *aname)
{
	PurpleConvChat *chat = NULL;
	char *nick = NULL;
	char *name = NULL;
	gboolean ret = FALSE;
	PurpleAccount *account;

	chat = purple_conversation_get_chat_data(conv);
	if (chat == NULL)
		return ret;

	account = purple_conversation_get_account(conv);
	nick = g_strdup(purple_normalize(account, chat->nick));
	name = g_strdup(purple_normalize(account, aname));

	if (g_utf8_collate(nick, name) == 0)
		ret = TRUE;

	g_free(nick);
	g_free(name);

	return ret;
}
static PurpleCmdRet
skypeweb_cmd_list(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
{
	purple_roomlist_show_with_account(purple_conversation_get_account(conv));
	
	return PURPLE_CMD_RET_OK;
}
static gboolean should_hide_notice(PurpleConversation *conv, const char *name,
                                   GHashTable *users)
{
	PurpleConvChat *chat;
	int threshold;
	struct joinpart_key key;
	time_t *last_said;

	g_return_val_if_fail(conv != NULL, FALSE);
	g_return_val_if_fail(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT, FALSE);

	/* If the room is small, don't bother. */
	chat = PURPLE_CONV_CHAT(conv);
	threshold = purple_prefs_get_int(THRESHOLD_PREF);
	if (g_list_length(purple_conv_chat_get_users(chat)) < threshold)
		return FALSE;

	if (!purple_prefs_get_bool(HIDE_BUDDIES_PREF) &&
	    purple_find_buddy(purple_conversation_get_account(conv), name))
		return FALSE;

	/* Only show the notice if the user has spoken recently. */
	key.conv = conv;
	key.user = (gchar *)name;
	last_said = g_hash_table_lookup(users, &key);
	if (last_said != NULL)
	{
		int delay = purple_prefs_get_int(DELAY_PREF);
		if (delay > 0 && (*last_said + (delay * 60)) >= time(NULL))
			return FALSE;
	}

	return TRUE;
}
Exemple #9
0
GList *
otrg_conversation_get_contexts(PurpleConversation *conv)
{
	PurpleAccount *account;
	const gchar *accountname, *protocol;
	gchar *username;
	ConnContext *it = NULL;
	GList *contexts = NULL;

	g_return_val_if_fail(conv != NULL, NULL);

	g_return_val_if_fail(PURPLE_IS_IM_CONVERSATION(conv), NULL);

	account = purple_conversation_get_account(conv);
	accountname = purple_account_get_username(account);
	protocol = purple_account_get_protocol_id(account);
	username = g_strdup(purple_normalize(account,
		purple_conversation_get_name(conv)));

	for (it = otrg_plugin_userstate->context_root; it; it = it->next) {
		if (g_strcmp0(it->accountname, accountname) != 0)
			continue;
		if (g_strcmp0(it->protocol, protocol) != 0)
			continue;
		if (g_strcmp0(it->username, username) != 0)
			continue;
		contexts = g_list_append(contexts, it);
	}

	g_free(username);

	return contexts;
}
Exemple #10
0
void
purple_conversations_add(PurpleConversation *conv)
{
	PurpleAccount *account;
	struct _purple_hconv *hc;

	g_return_if_fail(conv != NULL);

	if (g_list_find(conversations, conv) != NULL)
		return;

	conversations = g_list_prepend(conversations, conv);

	if (PURPLE_IS_IM_CONVERSATION(conv))
		ims = g_list_prepend(ims, conv);
	else
		chats = g_list_prepend(chats, conv);

	account = purple_conversation_get_account(conv);

	hc = g_new(struct _purple_hconv, 1);
	hc->name = g_strdup(purple_normalize(account,
				purple_conversation_get_name(conv)));
	hc->account = account;
	hc->im = PURPLE_IS_IM_CONVERSATION(conv);

	g_hash_table_insert(conversation_cache, hc, conv);
}
Exemple #11
0
void PurpleLine::signal_conversation_created(PurpleConversation *conv) {
    if (purple_conversation_get_account(conv) != acct)
        return;

    // Start queuing messages while the history is fetched
    purple_conversation_set_data(conv, "line-message-queue", new std::vector<line::Message>());

    fetch_conversation_history(conv, 10, false);
}
Exemple #12
0
static void
purple_prpl_attention(PurpleConversation *conv, const char *who,
	guint type, PurpleMessageFlags flags, time_t mtime)
{
	PurpleAccount *account = purple_conversation_get_account(conv);
	purple_signal_emit(purple_conversations_get_handle(),
		flags == PURPLE_MESSAGE_SEND ? "sent-attention" : "got-attention",
		account, who, conv, type);
}
Exemple #13
0
JabberChat *jabber_chat_find_by_conv(PurpleConversation *conv)
{
	PurpleAccount *account = purple_conversation_get_account(conv);
	PurpleConnection *gc = purple_account_get_connection(account);
	JabberStream *js = gc->proto_data;
	int id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv));

	return jabber_chat_find_by_id(js, id);
}
static void twitter_conv_icon_conversation_created_cb(PurpleConversation * conv, PurpleAccount * account)
{
    GList         **conv_icons;
    if (purple_conversation_get_account(conv) != account)
        return;
    conv_icons = g_new0(GList *, 1);

    purple_conversation_set_data(conv, PLUGIN_ID "-conv-icons", conv_icons);
}
Exemple #15
0
PurpleBuddy *
otrg_purple_conversation_get_buddy(PurpleConversation *conv)
{
	if (!PURPLE_IS_IM_CONVERSATION(conv))
		return NULL;

	return purple_blist_find_buddy(
		purple_conversation_get_account(conv),
		purple_conversation_get_name(conv));
}
Exemple #16
0
/* **************** IMWRAPPER/PURPLE INTERFACE ****************** */
PurpleIMChat *PurpleChatMngr::FindIMChatByPurpleConv(void *gConv)
{
	PurpleAccount *gAccount = purple_conversation_get_account((PurpleConversation *) gConv);
	const char *gPrclId = purple_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(purple_account_get_username(gAccount),
													PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	PurpleIMChat *mChat = FindIMChat(*account);

	return mChat;
}
Exemple #17
0
static gchar *
conversation_id(PurpleConversation *conv)
{
	PurpleAccount *account = purple_conversation_get_account(conv);

	return g_strconcat((PURPLE_IS_IM_CONVERSATION(conv) ? "im" :
				PURPLE_IS_CHAT_CONVERSATION(conv) ? "chat" : "misc"), ":",
			purple_conversation_get_name(conv), ":",
			purple_account_get_username(account), ":",
			purple_account_get_protocol_id(account), NULL);
}
static void twitter_conv_icon_deleting_conversation_cb(PurpleConversation * conv, PurpleAccount * account)
{
    GList         **conv_icons;
    if (purple_conversation_get_account(conv) != account)
        return;

    twitter_conv_icon_remove_conversation_conv_icons(conv);

    conv_icons = purple_conversation_get_data(conv, PLUGIN_ID "-conv-icons");
    g_free(conv_icons);
}
static void twitter_conv_icon_remove_conv(TwitterConvIcon * conv_icon, PurpleConversation * conv)
{
    conv_icon->convs = g_list_remove(conv_icon->convs, conv);

    if (!conv_icon->convs) {
        PurpleAccount  *account = purple_conversation_get_account(conv);
        PurpleConnection *gc = purple_account_get_connection(account);
        TwitterConnectionData *twitter = gc->proto_data;
        //Free the conv icon
        g_hash_table_remove(twitter->icons, conv_icon->username);
    }
}
Exemple #20
0
bool PurpleIMChat::sendMessageCbk(void * dataIn)
{
	Mutex::ScopedLock lock(PurpleIMChat::_mutex);

	PurpleIMChatCallbackData* cbData = (PurpleIMChatCallbackData*) dataIn;

	IMChatSession* chatSession = cbData->getIMChatSession();
//	const char * message = (const char *)((misc_t *)data)->data_ptr2;
//	char *cleanMess = (char *) message;
//	bool cleaned = false;
	std::string cleanMsg = cbData->getMessage();

	mConvInfo_t *mConv = FindChatStructById(chatSession->getId());
	PurpleConversation *gConv = mConv->purple_conv_session;		//VOXOX - JRT - 2009.07.09 

	// special case for ICQ
	PurpleAccount *gAccount = purple_conversation_get_account(gConv);
	PurplePlugin *prpl = purple_find_prpl(purple_account_get_protocol_id(gAccount));
	if (prpl)
	{
		PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
		if (prpl_info->list_icon != NULL)
		{
			if (!strcmp("icq", prpl_info->list_icon(gAccount, NULL))) 
			{
//				cleanMess = (char *) purple_markup_strip_html(message);
				cleanMsg= purple_markup_strip_html( cbData->getMessage().c_str() );
//				cleaned   = true;
			}
		}
	}

	if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_IM)
	{
		purple_conv_im_send_with_flags(PURPLE_CONV_IM(gConv), cleanMsg.c_str(), PURPLE_MESSAGE_SEND);
	}
	else if (purple_conversation_get_type(gConv) == PURPLE_CONV_TYPE_CHAT)
	{
		purple_conv_chat_send_with_flags(PURPLE_CONV_CHAT(gConv), cleanMsg.c_str(), PURPLE_MESSAGE_SEND);
	}
	
//	if (cleaned) 
//	{
//		g_free(cleanMess);
//	}

	timeoutRemove( cbData );

	delete cbData;

	return TRUE;
}
Exemple #21
0
static void
timezone_createconv_cb(PurpleConversation * conv, void *data)
{
    const char *name;
    PurpleBuddy *buddy;
    struct tm tm;
    const char *timezone;
    double diff;
    int ret;

    if (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM)
        return;

    name = purple_conversation_get_name(conv);
    buddy = purple_find_buddy(purple_conversation_get_account(conv), name);
    if (!buddy)
        return;

    timezone = buddy_get_timezone((PurpleBlistNode *) buddy, TRUE, NULL);

    if (!timezone)
        return;

    ret = timezone_get_time(timezone, &tm, &diff, NULL);

    if (ret == 0)
    {
        const char *text = purple_time_format(&tm);

        char *str;
	if (diff < 0)
	{
            diff = 0 - diff;
            str = g_strdup_printf(dngettext(GETTEXT_PACKAGE,
                                            "Remote Local Time: %s (%.4g hour behind)",
                                            "Remote Local Time: %s (%.4g hours behind)", diff),
                                  text, diff);
	}
	else
	{
            str = g_strdup_printf(dngettext(GETTEXT_PACKAGE,
                                            "Remote Local Time: %s (%.4g hour ahead)",
                                            "Remote Local Time: %s (%.4g hours ahead)", diff),
                                  text, diff);
	}

        purple_conversation_write(conv, PLUGIN_STATIC_NAME, str, PURPLE_MESSAGE_SYSTEM, time(NULL));

        g_free(str);
    }
}
Exemple #22
0
static gboolean
chat_nick_matches_name(PurpleChatConversation *chat, const char *aname)
{
	char *nick = NULL;
	char *name = NULL;
	gboolean ret = FALSE;

	if (chat==NULL)
		return ret;

	nick = g_strdup(purple_normalize(purple_conversation_get_account(
			PURPLE_CONVERSATION(chat)), purple_chat_conversation_get_nick(chat)));
	name = g_strdup(purple_normalize(purple_conversation_get_account(
			PURPLE_CONVERSATION(chat)), aname));

	if (g_utf8_collate(nick, name) == 0)
		ret = TRUE;

	g_free(nick);
	g_free(name);

	return ret;
}
static gboolean _elim_strippable ( PurpleConversation   *conv  , 
                                   PurpleMessageFlags    flag  )
{
    PurpleConnectionFlags feat = purple_conversation_get_features( conv );
    PurpleAccount        *acct = purple_conversation_get_account ( conv );
    const char          *proto = purple_account_get_protocol_id  ( acct );
    // µblog plugin gets this wrong:
    if( strstr( (proto ? proto : "") , "-mbpurple-" ) ) 
        feat = feat|PURPLE_CONNECTION_HTML;

    return ( (feat & PURPLE_CONNECTION_HTML) &&
           //(flag & PURPLE_MESSAGE_RECV   ) &&
            !(flag & PURPLE_MESSAGE_RAW    )  ) ? TRUE : FALSE;
}
Exemple #24
0
static PurpleCmdRet send_whisper(PurpleConversation *conv, const gchar *cmd,
                                 gchar **args, gchar **error, void *userdata) {
  const char *to_username;
  const char *message;
  const char *from_username;
  PurpleChatUser *chat_user;
  PurpleConnection *to;

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

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

  from_username = purple_account_get_username(purple_conversation_get_account(conv));
  purple_debug_info("nullprpl", "%s whispers to %s in chat room %s: %s\n",
                    from_username, to_username,
                    purple_conversation_get_name(conv), message);

  chat_user = purple_chat_conversation_find_user(PURPLE_CHAT_CONVERSATION(conv), to_username);
  to = get_nullprpl_gc(to_username);

  if (!chat_user) {
    /* 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_conversation_write_message(conv, from_username, message_to,
                                      PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_WHISPER,
                                      time(NULL));
    g_free(message_to);

    /* send the whisper */
    purple_serv_chat_whisper(to, purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)),
                      from_username, message);

    return PURPLE_CMD_RET_OK;
  }
}
/*******************
 * Signal Handlers *
 *******************/
static void rc_at_conversation_event(PurpleConversation *conv)
{
  PurpleAccount *acct = purple_conversation_get_account(conv);
  const char * proto = purple_account_get_protocol_name(acct);
  const char * proto_id = purple_account_get_protocol_id(acct);
  const char * my_acct = purple_account_get_username(acct);
  const char * recv_acct = purple_conversation_get_name(conv);

  trace("Conversation event.. [%s: %s] account: %s to %s", proto_id,
      proto, my_acct, recv_acct); 

  rc_push_contact(acct, recv_acct);

}
Exemple #26
0
static PurpleCmdRet
plonk_cmd_cb(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) {
/* this is the funky 'mass block/ignore' routine.
 * given a/n list of ID/'s it'll add that|those to all block|ignore lists
 * of each account of the same prpl type.
 */
/*
 * gchar* g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter);
 * gchar** g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens);
 */
	PurpleConversationUiOps *ops;
	GSList *l;
	char *room = NULL;
	GList *plonks = NULL;
	GList *members = NULL;
	gchar **tmp;
	if(!args[0]) {
		purple_debug_info("Plonkers", "Bad arg: %s\n", args[0]);
		return PURPLE_CMD_RET_FAILED;
	}
	if(!g_utf8_validate(*args, -1, NULL)) {
		purple_debug_info("Plonkers", "Invalid UTF8: %s\n", args[0]);
		return PURPLE_CMD_RET_FAILED;
	}
	purple_debug_info("plonkers", "Plonk arg: %s\n", args[0]);
	g_strdelimit (*args, "_-|> <.,:;", ' ');
	purple_debug_info("plonkers", "Plonk delimited arg: %s\n", args[0]);
	tmp = g_strsplit(args[0], " ", 0);
	purple_debug_info("plonkers", "Plonk strsplit length: %i\n", g_strv_length(tmp));
	/* next step, remove duplicates in the array */

	ops = purple_conversation_get_ui_ops(c);
	
	PurpleAccount *account = purple_conversation_get_account(c);
	members = purple_conv_chat_get_users(PURPLE_CONV_CHAT(c));
	for (l = account->deny; l != NULL; l = l->next) {
		for (plonks = members; plonks; plonks = plonks->next) {
			if (!purple_utf8_strcasecmp((char *)l->data, plonks->data)) {
				purple_debug_info("plonkers", "Ignoring room member %s in room %s\n" ,(gchar *)plonks->data, room);
/*				purple_conv_chat_ignore(PURPLE_CONV_CHAT(c),plonks->data);
 *				ops->chat_update_user((c), plonks->data); */
			}
		}
	}
	g_list_free(plonks);
	g_list_free(members);
	g_strfreev(tmp);
	return PURPLE_CMD_RET_OK;
}
Exemple #27
0
/**
 * A function to send a chat or im message to the specific conversation
 * without emitting "sending-im" or "sending-chat" signal, which would
 * cause an infinite loop for this plugin.
 *
 * taken from conversation.c with signal emission removed.
 */
static void
splitter_common_send(PurpleConversation *conv, const char *message,
                     PurpleMessageFlags msgflags)
{
	PurpleConversationType type;
	PurpleAccount *account;
	PurpleConnection *gc;
	char *sent = NULL;

	if (strlen(message) == 0)
		return;

	account = purple_conversation_get_account(conv);
#if PURPLE_VERSION_CHECK(3,0,0)
	gc = purple_conversation_get_connection(conv);
#else
	gc = purple_conversation_get_gc(conv);
#endif

	g_return_if_fail(account != NULL);
	g_return_if_fail(gc != NULL);

	type = purple_conversation_get_type(conv);

	if ((purple_conversation_get_features(conv) & PURPLE_CONNECTION_HTML) &&
		!(msgflags & PURPLE_MESSAGE_RAW))
	{
		sent = purple_markup_linkify(message);
	}
	else
		sent = g_strdup(message);

	msgflags |= PURPLE_MESSAGE_SEND;

	splitter_injected_message = TRUE;

	if (type == PURPLE_CONV_TYPE_IM) {
		if (sent != NULL && sent[0] != '\0')
			purple_conv_im_send_with_flags(PURPLE_CONV_IM(conv), sent, msgflags);
	}
	else {
		if (sent != NULL && sent[0] != '\0')
			purple_conv_chat_send_with_flags(PURPLE_CONV_CHAT(conv), sent, msgflags);
	}

	splitter_injected_message = FALSE;

	g_free(sent);
}
static void
chat_buddy_left_cb(PurpleConversation *conv, const char *user,
				   const char *reason, void *data)
{
	char *notification;
	int len = s_strlen((char*)conv->title)+s_strlen((char*)user) + 7;
	
	DEBUG_MSG("chat_buddy_left_cb\n");
	
	g_return_if_fail( is_allowed(purple_conversation_get_account(conv)) );
		
	notification = malloc( len );
	g_snprintf(notification, len, "%s left %s", user, conv->title);
	
	gntp_notify("chat-buddy-sign-out", NULL, "Chat Leave", notification, NULL);
	free(notification);
}
Exemple #29
0
void PurpleChatMngr::ChatAddUsersCbk(PurpleConversation *conv, GList *users, gboolean new_arrivals)
{
	GList *l;
	PurpleAccount	*gAccount	 = purple_conversation_get_account(conv);
	const char		*gPrclId	 = purple_account_get_protocol_id(gAccount);
	IMAccount		*account	 = _accountMngr->FindIMAccount(purple_account_get_username(gAccount), PurpleIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t		*mConv		 = NULL;
	IMChatSession	*chatSession = NULL;
	PurpleIMChat	*mChat		 = FindIMChat(*account);

	if (!mChat)
		LOG_FATAL("Can't find IMChat !");

	mConv       = (mConvInfo_t *)   conv->ui_data;
	chatSession = mConv->conv_session;	//VOXOX - JRT - 2009.07.09 

	for (l = users; l != NULL; l = l->next)
	{
		PurpleConvChatBuddy *gCCBuddy = (PurpleConvChatBuddy *) l->data;

		if (gCCBuddy && strcmp(purple_account_get_username(gAccount), (char *) gCCBuddy->name))
		{
			std::string buddy((char *) gCCBuddy->name);
			IMContact imContact(*account, buddy);

			if (chatSession->getIMContactSet().find(imContact) != chatSession->getIMContactSet().end())
			{
				LOG_DEBUG("IMContact for " + imContact.getContactId() + " already in IMContactSet");
			}
			else
			{
				((IMContactSet &) chatSession->getIMContactSet()).insert(imContact);

				if (chatSession->getIMContactSet().size() == 1)
				{
					//Create session when first contact is added.
					mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession);
				}

				LOG_DEBUG("IMContact " + imContact.getContactId() + " added to IMContactSet");
			}
			mChat->contactAddedEvent(*mChat, *chatSession, imContact);
		}
	}
}
PurpleSmileyList *
pidgin_smiley_theme_for_conv(PurpleConversation *conv)
{
	PurpleAccount *acc = NULL;
	PurpleSmileyTheme *theme;
	const gchar *proto_name = NULL;

	theme = purple_smiley_theme_get_current();
	if (theme == NULL)
		return NULL;

	if (conv)
		acc = purple_conversation_get_account(conv);
	if (acc)
		proto_name = purple_account_get_protocol_name(acc);

	return purple_smiley_theme_get_smileys(theme, (gpointer)proto_name);
}