예제 #1
0
static char *
gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account)
{
	GaimPlugin *prpl;
	GaimPluginProtocolInfo *prpl_info;
	const char *prpl_name;
	char *acct_name;
	const char *target;
	char *dir;

	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
	if (!prpl)
		return NULL;
	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
	prpl_name = prpl_info->list_icon(account, NULL);

	acct_name = g_strdup(gaim_escape_filename(gaim_normalize(account,
				gaim_account_get_username(account))));

	if (type == GAIM_LOG_CHAT) {
		char *temp = g_strdup_printf("%s.chat", gaim_normalize(account, name));
		target = gaim_escape_filename(temp);
		g_free(temp);
	} else if(type == GAIM_LOG_SYSTEM) {
		target = ".system";
	} else {
		target = gaim_escape_filename(gaim_normalize(account, name));
	}

	dir = g_build_filename(gaim_user_dir(), "logs", prpl_name, acct_name, target, NULL);

	g_free(acct_name);

	return dir;
}
예제 #2
0
/* **************** IMWRAPPER/GAIM INTERFACE ****************** */
GaimIMChat *GaimChatMngr::FindIMChatByGaimConv(void *gConv)
{
	GaimAccount *gAccount = gaim_conversation_get_account((GaimConversation *) gConv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
													GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	GaimIMChat *mChat = FindIMChat(*account);

	return mChat;
}
예제 #3
0
static GaimChat *gaym_find_blist_chat(GaimAccount * account,
                                      const char *name)
{
    char *chat_name;
    GaimChat *chat;
    GaimPlugin *prpl;
    GaimPluginProtocolInfo *prpl_info = NULL;
    struct proto_chat_entry *pce;
    GaimBlistNode *node, *group;
    GList *parts;

    GaimBuddyList *gaimbuddylist = gaim_get_blist();

    g_return_val_if_fail(gaimbuddylist != NULL, NULL);
    g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL);

    if (!gaim_account_is_connected(account))
        return NULL;

    prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
    prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);

    for (group = gaimbuddylist->root; group != NULL; group = group->next) {
        for (node = group->child; node != NULL; node = node->next) {
            if (GAIM_BLIST_NODE_IS_CHAT(node)) {

                chat = (GaimChat *) node;

                if (account != chat->account)
                    continue;

                parts =
                    prpl_info->
                    chat_info(gaim_account_get_connection(chat->account));

                pce = parts->data;
                chat_name = g_hash_table_lookup(chat->components,
                                                pce->identifier);

                if (chat->account == account && chat_name != NULL &&
                    name != NULL
                    && g_pattern_match_simple(chat_name, name)) {

                    return chat;
                }
            }
        }
    }

    return NULL;
}
예제 #4
0
static void redo_im_window(GaimConversation * c)
{
    gaim_debug_misc("chaticon","GOT CONVERSATION CREATED FOR %s\n",c->name);
    if (!g_strrstr(gaim_account_get_protocol_id(c->account), "prpl-gaym"))
        return;
    if (c && c->type == GAIM_CONV_IM)
        add_im_popup_stuff(c);
    else if (c->type == GAIM_CONV_CHAT)
    {
	add_chat_sort_functions(c);
	add_chat_popup_stuff(c);
	add_chat_icon_stuff(c);
    }
    
}
예제 #5
0
void GaimChatMngr::CreateConversationCbk(GaimConversation *conv, bool userCreated)
{
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	GaimConversationType chatType = gaim_conversation_get_type(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
		GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	GaimIMChat *mChat = FindIMChat(*account);
	mConvInfo_t *mConv;

	if (chatType == GAIM_CONV_TYPE_IM)
	{
		IMChatSession *chatSession = NULL;

		// Check if it's a jabber contact, and remove his ressource
		std::string contactId = cleanContactId(std::string(gaim_conversation_get_name(conv)),
			GaimIMPrcl::GetEnumIMProtocol(gPrclId));

		IMContact imContact(*account, contactId);

		mConv = mChat->CreateChatSession(userCreated, *mChat);
		mConv->gaim_conv_session = conv;
 		conv->ui_data = mConv;

		chatSession = (IMChatSession *) mConv->conv_session;

		((IMContactSet &) chatSession->getIMContactSet()).insert(imContact);
		mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession);

		mChat->contactAddedEvent(*mChat, *chatSession, imContact);
	}
	else if (chatType == GAIM_CONV_TYPE_CHAT)
	{
		int id = GetGaimConversationId(gaim_conversation_get_name(conv));

		if ((mConv = mChat->FindChatStructById(id)) == NULL)
		{
			mConv = mChat->CreateChatSession(userCreated, *mChat);
		}

		if (mConv->gaim_conv_session)
			gaim_conversation_destroy((GaimConversation *)mConv->gaim_conv_session);

		mConv->gaim_conv_session = conv;
		conv->ui_data = mConv;
	}
}
예제 #6
0
void GaimChatMngr::ChatAddUsersCbk(GaimConversation *conv, GList *users, gboolean new_arrivals)
{
	GList *l;
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
								GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	GaimIMChat *mChat = FindIMChat(*account);

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

	mConv = (mConvInfo_t *) conv->ui_data;
	chatSession = (IMChatSession *) mConv->conv_session;

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

		if (gCCBuddy && strcmp(gaim_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)
					mChat->newIMChatSessionCreatedEvent(*mChat, *chatSession);

				LOG_DEBUG("IMContact " + imContact.getContactId() + " added to IMContactSet");
			}
			mChat->contactAddedEvent(*mChat, *chatSession, imContact);
		}
	}
}
예제 #7
0
void GaimPresenceMngr::UpdateAccountStatus(GaimAccount *gAccount, 
										   GaimStatus *old, 
										   GaimStatus *newstatus)
{
	GaimIMPresence *mIMPresence = NULL;
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
		GaimIMPrcl::GetEnumIMProtocol(gPrclId));

	if (!account)
		return;

	mIMPresence = FindIMPresence(*account);
	if (!mIMPresence)
	{
		LOG_FATAL("IMPresence not found!");
		return;
	}

	mIMPresence->myPresenceStatusEvent(*mIMPresence, EnumPresenceState::MyPresenceStatusOk, "");

}
예제 #8
0
void GaimChatMngr::UpdateBuddyTyping(GaimConversation *conv, GaimTypingState state)
{
	IMChat::TypingState mState;

	mConvInfo_t *mConv = (mConvInfo_t *)conv->ui_data;
	GaimIMChat *mIMChat = FindIMChatByGaimConv(conv);

	if (!mIMChat)
		return;

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

		case GAIM_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 = gaim_conversation_get_name(conv);
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	std::string contactId = cleanContactId(name,
		GaimIMPrcl::GetEnumIMProtocol(gPrclId));

	mIMChat->typingStateChangedEvent(*mIMChat, *((IMChatSession *)(mConv->conv_session)),
									contactId, mState);

}
예제 #9
0
void GaimChatMngr::ChatRemoveUsersCbk(GaimConversation *conv, GList *users)
{
	GList *l;
	GaimAccount *gAccount = gaim_conversation_get_account(conv);
	const char *gPrclId = gaim_account_get_protocol_id(gAccount);
	IMAccount *account = _accountMngr->FindIMAccount(gaim_account_get_username(gAccount),
								GaimIMPrcl::GetEnumIMProtocol(gPrclId));
	mConvInfo_t *mConv = NULL;
	IMChatSession *chatSession = NULL;
	GaimIMChat *mChat = FindIMChat(*account);

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

	mConv = (mConvInfo_t *) conv->ui_data;
	chatSession = (IMChatSession *) mConv->conv_session;

	for (l = users; l != NULL; l = l->next)
	{
		if (strcmp(gaim_account_get_username(gAccount), (char *) l->data))
		{
			std::string buddy((char *) l->data);
			IMContact imContact(*account, buddy);

			if (chatSession->getIMContactSet().find(imContact) == chatSession->getIMContactSet().end())
			{
				LOG_ERROR("IMContact for " + imContact.getContactId() + " not in IMContactSet");
			}
			else
			{
				LOG_DEBUG("IMContact " + imContact.getContactId() + " removed from IMContactSet");
				mChat->contactRemovedEvent(*mChat, *chatSession, buddy);
			}
		}
	}
}
예제 #10
0
void GaimChatMngr::WriteConvCbk(GaimConversation *conv, const char *name, const char *alias,
							const char *message, GaimMessageFlags flags,
							time_t mtime)
{
	if ((flags & GAIM_MESSAGE_RECV))
	{
		mConvInfo_t *mConv = (mConvInfo_t *)conv->ui_data;
		GaimIMChat *mIMChat = FindIMChatByGaimConv(conv);

		// Prevent from double message during a chat session
		if (strcmp(gaim_account_get_username(conv->account), name) == 0)
			return;

		// Check if it's a jabber contact, and remove his ressource
		GaimAccount *gAccount = gaim_conversation_get_account(conv);
		const char *gPrclId = gaim_account_get_protocol_id(gAccount);
		std::string contactId = cleanContactId(name,
			GaimIMPrcl::GetEnumIMProtocol(gPrclId));

		mIMChat->messageReceivedEvent(*mIMChat, 
			*((IMChatSession *)(mConv->conv_session)),
			contactId, std::string(message));
	}
}
예제 #11
0
static void update_info_cb(GaimAccount * account, char *name)
{
    if (!g_strrstr(gaim_account_get_protocol_id(account), "prpl-gaym"))
        return;
    gaim_debug_misc("gaym-extras", "info update\n");
}
예제 #12
0
파일: connection.c 프로젝트: VoxOx/VoxOx
void
gaim_connection_new(GaimAccount *account, gboolean regist, const char *password)
{
	GaimConnection *gc;
	GaimPlugin *prpl;
	GaimPluginProtocolInfo *prpl_info;

	g_return_if_fail(account != NULL);

	if (!gaim_account_is_disconnected(account))
		return;

	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));

	if (prpl != NULL)
		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
	else {
		gchar *message;

		message = g_strdup_printf(_("Missing protocol plugin for %s"),
			gaim_account_get_username(account));
		gaim_notify_error(NULL, regist ? _("Registration Error") :
						  _("Connection Error"), message, NULL);
		g_free(message);
		return;
	}

	if (regist)
	{
		if (prpl_info->register_user == NULL)
			return;
	}
	else
	{
		if (((password == NULL) || (*password == '\0')) &&
			!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
		{
			gaim_debug_error("connection", "Can not connect to account %s without "
							 "a password.\n", gaim_account_get_username(account));
			return;
		}
	}

	gc = g_new0(GaimConnection, 1);
	GAIM_DBUS_REGISTER_POINTER(gc, GaimConnection);

	gc->prpl = prpl;
	if ((password != NULL) && (*password != '\0'))
		gc->password = g_strdup(password);
	gaim_connection_set_account(gc, account);
	gaim_connection_set_state(gc, GAIM_CONNECTING);
	connections = g_list_append(connections, gc);
	gaim_account_set_connection(account, gc);

	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);

	if (regist)
	{
		gaim_debug_info("connection", "Registering.  gc = %p\n", gc);

		/* set this so we don't auto-reconnect after registering */
		gc->wants_to_die = TRUE;

		prpl_info->register_user(account);
	}
	else
	{
		gaim_debug_info("connection", "Connecting. gc = %p\n", gc);

		gaim_signal_emit(gaim_accounts_get_handle(), "account-connecting", account);
		prpl_info->login(account);
	}
}