示例#1
0
void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
	debugLogA("CVkProto::OnReceiveFriends %d", reply->resultCode);
	if (reply->resultCode != 200 || !IsOnline())
		return;

	JSONNode jnRoot;
	const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
	if (!jnResponse)
		return;
	
	CVkSendMsgParam *param = (CVkSendMsgParam *)pReq->pUserInfo;
	bool bCleanContacts = getBool("AutoClean") || (param->iMsgID != 0);
	delete param;

	LIST<void> arContacts(10, PtrKeySortT);
		
	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		if (!isChatRoom(hContact))
			setByte(hContact, "Auth", 1);
		db_unset(hContact, m_szModuleName, "ReqAuth");
		SetMirVer(hContact, -1);
		if (bCleanContacts && !isChatRoom(hContact))
			arContacts.insert((HANDLE)hContact);
	}

	const JSONNode &jnItems = jnResponse["items"];

	if (jnItems)
		for (auto it = jnItems.begin(); it != jnItems.end(); ++it) {
			MCONTACT hContact = SetContactInfo((*it), true);

			if (hContact == NULL || hContact == INVALID_CONTACT_ID)
				continue;

			arContacts.remove((HANDLE)hContact);
			setByte(hContact, "Auth", 0);
		}

	if (bCleanContacts)
		for (int i = 0; i < arContacts.getCount(); i++) {
			MCONTACT hContact = (UINT_PTR)arContacts[i];
			LONG userID = getDword(hContact, "ID", -1);
			if (userID == m_myUserId || userID == VK_FEED_USER)
				continue;
			CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact);
		}
	
	arContacts.destroy();
}
示例#2
0
MCONTACT FacebookProto::ContactIDToHContact(const std::string &user_id)
{
	if (user_id.empty()) {
		debugLogA("!!! Calling ContactIDToHContact() with empty user_id");
		return 0;
	}

	// First check cache
	std::map<std::string, MCONTACT>::iterator it = facy.user_id_to_hcontact.find(user_id);
	if (it != facy.user_id_to_hcontact.end()) {
		// Check if contact is still valid
		if (CallService(MS_DB_CONTACT_IS, (WPARAM)it->second) == 1)
			return it->second;
		else
			facy.user_id_to_hcontact.erase(it);
	}

	// Go through all local contacts
	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		if (isChatRoom(hContact))
			continue;

		ptrA id(getStringA(hContact, FACEBOOK_KEY_ID));
		if (id && !mir_strcmp(id, user_id.c_str())) {
			facy.user_id_to_hcontact.insert(std::make_pair(user_id, hContact));
			return hContact;
		}
	}

	return 0;
}
示例#3
0
void TwitterProto::SetChatStatus(int status)
{
	GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
	GCEVENT gce = { sizeof(gce), &gcd };

	if (status == ID_STATUS_ONLINE) {
		// Add all friends to contact list
		for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
			if (isChatRoom(hContact))
				continue;

			DBVARIANT uid, nick;
			if (getString(hContact, TWITTER_KEY_UN, &uid))
				continue;

			if (!db_get_s(hContact, "CList", "MyHandle", &nick)) {
				AddChatContact(uid.pszVal, nick.pszVal);
				db_free(&nick);
			}
			else
				AddChatContact(uid.pszVal);

			db_free(&uid);
		}

		// For some reason, I have to send an INITDONE message, even if I'm not actually
		// initializing the room...
		CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, reinterpret_cast<LPARAM>(&gce));
		CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
	}
	else
		CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
}
示例#4
0
bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo)
{
	DBVARIANT dbv;

	DisconnectAllDCCSessions(false);

	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		if (isChatRoom(hContact))
			continue;

		if (getByte(hContact, "DCC", 0) != 0) {
			if (ChatsToo)
				setWord(hContact, "Status", ID_STATUS_OFFLINE);
		}
		else if (!getTString(hContact, "Default", &dbv)) {
			setTString(hContact, "Nick", dbv.ptszVal);
			setWord(hContact, "Status", ID_STATUS_OFFLINE);
			db_free(&dbv);
		}
		db_unset(hContact, m_szModuleName, "IP");
		setString(hContact, "User", "");
		setString(hContact, "Host", "");
	}
	return true;
}
示例#5
0
int GGPROTO::details_init(WPARAM wParam, LPARAM lParam)
{
	MCONTACT hContact = lParam;
	char* pszTemplate;

	if (hContact == NULL){
		// View/Change My Details
		pszTemplate = MAKEINTRESOURCEA(IDD_CHINFO_GG);
	} else {
		// Other user details
		char* szProto = GetContactProto(hContact);
		if (szProto == NULL)
			return 0;
		if (mir_strcmp(szProto, m_szModuleName) || isChatRoom(hContact))
			return 0;
		pszTemplate = MAKEINTRESOURCEA(IDD_INFO_GG);
	}

	OPTIONSDIALOGPAGE odp = { 0 };
	odp.flags = ODPF_DONTTRANSLATE | ODPF_TCHAR;
	odp.hInstance = hInstance;
	odp.pfnDlgProc = gg_detailsdlgproc;
	odp.position = -1900000000;
	odp.pszTemplate = pszTemplate;
	odp.ptszTitle = m_tszUserName;
	odp.dwInitParam = (LPARAM)this;
	UserInfo_AddPage(wParam, &odp);

	// Start search for user data
	if (hContact == NULL)
		GetInfo(NULL, 0);

	return 0;
}
示例#6
0
/**
 * Sets statusbar text of hContact with last read time (from facy.readers map)
 */
void FacebookProto::MessageRead(MCONTACT hContact)
{
	/*std::map<MCONTACT, time_t>::iterator it = facy.readers.find(hContact);
	if (it == facy.readers.end())
	return;*/

	// We may use this instead of checing map as we have this info already in memory (this value is resident)
	time_t time = getDword(hContact, FACEBOOK_KEY_MESSAGE_READ, 0);
	if (!time)
		return;

	TCHAR ttime[64];
	_tcsftime(ttime, _countof(ttime), _T("%X"), localtime(&time));

	StatusTextData st = { 0 };
	st.cbSize = sizeof(st);
	st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("read"));

	if (isChatRoom(hContact)) {
		// Load readers names
		ptrT treaders(getTStringA(hContact, FACEBOOK_KEY_MESSAGE_READERS));
		mir_sntprintf(st.tszText, TranslateT("Message read: %s by %s"), ttime, treaders ? treaders : _T("???"));
		CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
	} else if (!ServiceExists(MS_MESSAGESTATE_UPDATE)){
		mir_sntprintf(st.tszText, TranslateT("Message read: %s"), ttime);
		CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
	}
}
示例#7
0
bool FacebookProto::IsSpecialChatRoom(MCONTACT hContact) {
	if (!isChatRoom(hContact))
		return false;

	ptrA id(getStringA(hContact, "ChatRoomID"));
	return id && !mir_strcmp(id, FACEBOOK_NOTIFICATIONS_CHATROOM);
}
示例#8
0
int CMsnProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
	if (!MSN_IsMyContact(hContact))
		return 0;

	char szEmail[MSN_MAX_EMAIL_LEN];
	bool isMe = MSN_IsMeByContact(hContact, szEmail);
	if (szEmail[0]) {
		int listId = Lists_GetMask(szEmail);
		bool noChat = !(listId & LIST_FL) || isMe || isChatRoom(hContact);

		Menu_ModifyItem(hBlockMenuItem, (listId & LIST_BL) ? LPGENT("&Unblock") : LPGENT("&Block"));
		Menu_ShowItem(hBlockMenuItem, !noChat);

		Menu_ModifyItem(hOpenInboxMenuItem, isMe ? LPGENT("Open &Hotmail Inbox") : LPGENT("Send &Hotmail E-mail"));
		Menu_ShowItem(hOpenInboxMenuItem, emailEnabled);

#ifdef OBSOLETE
		Menu_ShowItem(hNetmeetingMenuItem, !noChat);
#endif
		Menu_ShowItem(hChatInviteMenuItem, !noChat);
	}

	return 0;
}
示例#9
0
int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
	if (!hContact)
		return 0;

	if (m_iStatus < ID_STATUS_ONLINE)
		return 0;

	if (isChatRoom(hContact))
	{
		return 0;
	}

	bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
	bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
	bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
	bool isBlocked = getBool(hContact, "IsBlocked", false);

	Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
	Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
	Menu_ShowItem(ContactMenuItems[CMI_BLOCK], true);
	Menu_ShowItem(ContactMenuItems[CMI_UNBLOCK], isCtrlPressed || isBlocked);
	Menu_ShowItem(ContactMenuItems[CMI_GETSERVERHISTORY], true);

	return 0;
}
示例#10
0
int __cdecl CIrcProto::OnInitUserInfo(WPARAM wParam, LPARAM lParam)
{
	MCONTACT hContact = lParam;
	char *szProto = GetContactProto(hContact);
	if (!hContact || !szProto || mir_strcmpi(szProto, m_szModuleName))
		return 0;

	if (isChatRoom(hContact))
		return 0;

	if (getByte(hContact, "DCC", 0) != 0)
		return 0;

	DBVARIANT dbv;
	if (!getTString(hContact, "Default", &dbv)) {
		if (IsChannel(dbv.ptszVal)) {
			db_free(&dbv);
			return 0;
		}
		db_free(&dbv);
	}

	OPTIONSDIALOGPAGE odp = { sizeof(odp) };
	odp.flags = ODPF_DONTTRANSLATE;
	odp.pszTitle = m_szModuleName;
	odp.hIcon = NULL;
	odp.dwInitParam = (LPARAM)this;
	odp.hInstance = hInst;
	odp.position = -1900000000;
	odp.pfnDlgProc = UserDetailsDlgProc;
	odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
	odp.pszTitle = m_szModuleName;
	UserInfo_AddPage(wParam, &odp);
	return 0;
}
示例#11
0
int FacebookProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
{
	MCONTACT hContact = MCONTACT(wParam);
	bool bIsChatroom = isChatRoom(hContact);

	Menu_ShowItem(g_hContactMenuVisitProfile, !bIsChatroom);
	Menu_ShowItem(g_hContactMenuVisitFriendship, !bIsChatroom);
	Menu_ShowItem(g_hContactMenuVisitConversation, true);
	Menu_ShowItem(g_hContactMenuPostStatus, !bIsChatroom);

	if (!isOffline() && !bIsChatroom)
	{
		bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
		BYTE type = getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0);

		Menu_ShowItem(g_hContactMenuAuthAsk, ctrlPressed || type == CONTACT_NONE || !type);
		Menu_ShowItem(g_hContactMenuAuthGrant, ctrlPressed || type == CONTACT_APPROVE);
		Menu_ShowItem(g_hContactMenuAuthDeny, ctrlPressed || type == CONTACT_APPROVE);
		Menu_ShowItem(g_hContactMenuAuthRevoke, ctrlPressed || type == CONTACT_FRIEND);
		Menu_ShowItem(g_hContactMenuAuthCancel, ctrlPressed || type == CONTACT_REQUEST);

		Menu_ShowItem(g_hContactMenuPoke, true);
	}

	return 0;
}
示例#12
0
int CJabberProto::OnContactDeleted(WPARAM wParam, LPARAM)
{
	if (!m_bJabberOnline)	// should never happen
		return 0;

	HANDLE hContact = (HANDLE)wParam;
	ptrT jid(getTStringA(hContact, isChatRoom(hContact) ? "ChatRoomID" : "jid"));
	if (jid == NULL)
		return 0;

	if (ListGetItemPtr(LIST_ROSTER, jid)) {
		if (!_tcschr(jid, _T('@'))) {
			TCHAR szStrippedJid[JABBER_MAX_JID_LEN];
			JabberStripJid(m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid));
			TCHAR *szDog = _tcschr(szStrippedJid, _T('@'));
			if (szDog && _tcsicmp(szDog + 1, jid))
				m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), jid) << XQUERY(JABBER_FEAT_REGISTER) << XCHILD(_T("remove")));
		}

		// Remove from roster, server also handles the presence unsubscription process.
		m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext()) << XQUERY(JABBER_FEAT_IQ_ROSTER)
			<< XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("subscription"), _T("remove")));
	}
	return 0;
}
示例#13
0
int CAimProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
{
	bool bIsChatRoom = isChatRoom(hContact);

	//see if we should add the html away message context menu items
	Menu_ShowItem(hHTMLAwayContextMenuItem, getWord(hContact, AIM_KEY_ST, ID_STATUS_OFFLINE) == ID_STATUS_AWAY && !bIsChatRoom);
	Menu_ShowItem(hAddToServerListContextMenuItem, !getBuddyId(hContact, 1) && state != 0 && !bIsChatRoom);

	ptrA id(getStringA(hContact, AIM_KEY_SN));
	if (id == NULL)
		return 0;

	switch (pd_mode) {
	case 1:
		Menu_ModifyItem(hBlockContextMenuItem, LPGENT("&Block"));
		break;

	case 2:
		Menu_ModifyItem(hBlockContextMenuItem, LPGENT("&Unblock"));
		break;

	case 3:
		Menu_ModifyItem(hBlockContextMenuItem, allow_list.find_id(id) ? LPGENT("&Block") : LPGENT("&Unblock"));
		break;

	case 4:
		Menu_ModifyItem(hBlockContextMenuItem, block_list.find_id(id) ? LPGENT("&Unblock") : LPGENT("&Block"));
		break;

	default:
		Menu_ShowItem(hBlockContextMenuItem, false);
		break;
	}
	return 0;
}
示例#14
0
// обновляет иконки в clist и в messagew
void ShowStatusIcon(HANDLE hContact, int mode)
{
	HANDLE hMC = getMetaContact(hContact);

	// обновить иконки в clist
	if (mode != -1) {
		HANDLE hIcon = mode2clicon(mode, 1);
		ExtraIcon_SetIcon(g_hCLIcon, hContact, hIcon);
		if (hMC)
			ExtraIcon_SetIcon(g_hCLIcon, hMC, hIcon);
	}
	else {
		ExtraIcon_Clear(g_hCLIcon, hContact);
		if (hMC)
			ExtraIcon_Clear(g_hCLIcon, hMC);
	}

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = (char*)MODULENAME;
	for (int i = MODE_NATIVE; i < MODE_CNT; i++) {
		sid.dwId = i;
		sid.flags = (mode & SECURED) ? 0 : MBF_DISABLED;
		if (mode == -1 || (mode & 0x0f) != i || isChatRoom(hContact))
			sid.flags |= MBF_HIDDEN;  // отключаем все ненужные иконки
		Srmm_ModifyIcon(hContact, &sid);
		if (hMC)
			Srmm_ModifyIcon(hMC, &sid);
	}
}
示例#15
0
int CSkypeProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
	if (!IsOnline()) return 1;

	if (hContact && !isChatRoom(hContact))
		PushRequest(new DeleteContactRequest(li, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))));
	return 0;
}
示例#16
0
int CSkypeProto::GetInfo(MCONTACT hContact, int)
{
	if (!isChatRoom(hContact))
		PushRequest(
			new GetProfileRequest(li, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))),
			&CSkypeProto::LoadProfile);
	return 0;
}
示例#17
0
MCONTACT CIrcProto::CList_FindContact(CONTACT *user)
{
	if (!user || !user->name)
		return 0;

	TCHAR* lowercasename = mir_tstrdup(user->name);
	CharLower(lowercasename);

	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
		if (isChatRoom(hContact))
			continue;

		MCONTACT  hContact_temp = NULL;
		ptrT DBNick(getTStringA(hContact, "Nick"));
		ptrT DBUser(getTStringA(hContact, "UUser"));
		ptrT DBHost(getTStringA(hContact, "UHost"));
		ptrT DBDefault(getTStringA(hContact, "Default"));
		ptrT DBWildcard(getTStringA(hContact, "UWildcard"));

		if (DBWildcard)
			CharLower(DBWildcard);
		if (IsChannel(user->name)) {
			if (DBDefault && !lstrcmpi(DBDefault, user->name))
				hContact_temp = (MCONTACT)-1;
		}
		else if (user->ExactNick && DBNick && !lstrcmpi(DBNick, user->name))
			hContact_temp = hContact;

		else if (user->ExactOnly && DBDefault && !lstrcmpi(DBDefault, user->name))
			hContact_temp = hContact;

		else if (user->ExactWCOnly) {
			if (DBWildcard && !lstrcmpi(DBWildcard, lowercasename)
				|| (DBWildcard && !lstrcmpi(DBNick, lowercasename) && !WCCmp(DBWildcard, lowercasename))
				|| (!DBWildcard && !lstrcmpi(DBNick, lowercasename))) {
				hContact_temp = hContact;
			}
		}
		else if (_tcschr(user->name, ' ') == 0) {
			if ((DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) ||
				DBWildcard && WCCmp(DBWildcard, lowercasename))
				&& (WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host))) {
				hContact_temp = hContact;
			}
		}

		if (hContact_temp != NULL) {
			mir_free(lowercasename);
			if (hContact_temp != (MCONTACT)-1)
				return hContact_temp;
			return 0;
		}
	}
	mir_free(lowercasename);
	return 0;
}
示例#18
0
bool FacebookProto::IsMyContact(HANDLE hContact, bool include_chat)
{
    const char *proto = GetContactProto(hContact);
    if (proto && !strcmp(m_szModuleName, proto)) {
        if (include_chat)
            return true;
        return !isChatRoom(hContact);
    }
    return false;
}
示例#19
0
bool TwitterProto::IsMyContact(MCONTACT hContact, bool include_chat)
{
	char *proto = GetContactProto(hContact);
	if (proto && mir_strcmp(m_szModuleName, proto) == 0) {
		if (include_chat)
			return true;
		return !isChatRoom(hContact);
	}
	else return false;
}
示例#20
0
void CSkypeProto::SetAllContactsStatus(WORD status)
{
	for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
	{
		if (!isChatRoom(hContact))
			SetContactStatus(hContact, status);
	}
	if (status == ID_STATUS_OFFLINE)
		CloseAllChatChatSessions();
}
示例#21
0
int WhatsAppProto::OnDeleteChat(WPARAM hContact, LPARAM lParam)
{
	if (isChatRoom(hContact) && isOnline()) {
		ptrT tszID(getTStringA(hContact, WHATSAPP_KEY_ID));
		if (tszID)
			m_pConnection->sendJoinLeaveGroup(_T2A(tszID), false);
	}

	return 0;
}
示例#22
0
INT_PTR CMsnProto::OnLeaveChat(WPARAM hContact, LPARAM)
{
	if (isChatRoom(hContact) != 0) {
		DBVARIANT dbv;
		if (getTString(hContact, "ChatRoomID", &dbv) == 0) {
			MSN_KillChatSession(dbv.ptszVal);
			db_free(&dbv);
		}
	}
	return 0;
}
示例#23
0
HANDLE CVkProto::SendFile(MCONTACT hContact, const TCHAR *desc, TCHAR **files)
{
	debugLogA("CVkProto::SendFile");

	LONG userID = getDword(hContact, "ID", -1);
	if (!IsOnline() || ((userID == -1 || userID == VK_FEED_USER) && !isChatRoom(hContact)))
		return (HANDLE)0;

	CVkFileUploadParam *fup = new CVkFileUploadParam(hContact, desc, files);
	ForkThread(&CVkProto::SendFileThread, (void *)fup);
	return (HANDLE)fup;
}
示例#24
0
MCONTACT CMsnProto::MSN_GetChatInernalHandle(MCONTACT hContact)
{
	MCONTACT result = hContact;
	if (isChatRoom(hContact)) {
		DBVARIANT dbv;
		if (getString(hContact, "ChatRoomID", &dbv) == 0) {
			result = (MCONTACT)(-atol(dbv.pszVal));
			db_free(&dbv);
		}
	}
	return result;
}
示例#25
0
INT_PTR __cdecl CJabberProto::OnMenuConvertChatContact(WPARAM hContact, LPARAM)
{
    BYTE bIsChatRoom = isChatRoom(hContact);
    const char *szSetting = (bIsChatRoom) ? "ChatRoomID" : "jid";

    ptrT jid(getTStringA(hContact, szSetting));
    if (jid != NULL) {
        delSetting(hContact, szSetting);
        setTString(hContact, szSetting, jid);
        setByte(hContact, "ChatRoom", !bIsChatRoom);
    }
    return 0;
}
示例#26
0
void CToxProto::ChatValidateContact(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact)
{
	bool isProtoContact = mir_strcmpi(GetContactProto(hContact), m_szModuleName) == 0;
	if (isProtoContact && !isChatRoom(hContact))
	{
		if (std::find(contacts.begin(), contacts.end(), hContact) != contacts.end())
		{
			SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hContact, 0);
		}
		return;
	}
	SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hContact, 0);
}
示例#27
0
int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
{
	LONG userID = getDword(hContact, "ID", -1);
	bool bisFriend = (getBool(hContact, "Auth", true) == 0);
	bool bisBroadcast = !(IsEmpty(ptrT(db_get_tsa(hContact, m_szModuleName, "AudioUrl"))));
	Menu_ShowItem(g_hContactMenuItems[CMI_VISITPROFILE], !isChatRoom(hContact) && userID != VK_FEED_USER);
	Menu_ShowItem(g_hContactMenuItems[CMI_WALLPOST], !isChatRoom(hContact));
	Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend && !isChatRoom(hContact) && userID != VK_FEED_USER);
	Menu_ShowItem(g_hContactMenuItems[CMI_DELETEFRIEND], bisFriend && userID != VK_FEED_USER);
	Menu_ShowItem(g_hContactMenuItems[CMI_BANUSER], !isChatRoom(hContact) && userID != VK_FEED_USER);
	Menu_ShowItem(g_hContactMenuItems[CMI_REPORTABUSE], !isChatRoom(hContact) && userID != VK_FEED_USER);
	Menu_ShowItem(g_hContactMenuItems[CMI_DESTROYKICKCHAT], isChatRoom(hContact) && getBool(hContact, "off"));
	Menu_ShowItem(g_hContactMenuItems[CMI_OPENBROADCAST], !isChatRoom(hContact) && bisBroadcast);
	Menu_ShowItem(g_hContactMenuItems[CMI_GETSERVERHISTORY], !isChatRoom(hContact) && userID != VK_FEED_USER);
	Menu_ShowItem(g_hContactMenuItems[CMI_LOADVKNEWS], userID == VK_FEED_USER);
	for (int i = 0; i < CHMI_COUNT; i++)
		Menu_ShowItem(g_hContactHistoryMenuItems[i], !isChatRoom(hContact) && userID != VK_FEED_USER);
	return 0;
}
示例#28
0
MCONTACT CSkypeProto::FindChatRoom(const char *chatname)
{
	MCONTACT hContact = NULL;
	for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
	{
		if (!isChatRoom(hContact))
			continue;

		ptrA cChatname(getStringA(hContact, "ChatRoomID"));
		if (!mir_strcmpi(chatname, cChatname))
			break;
	}
	return hContact;
}
示例#29
0
int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
{
	debugLogA("CVkProto::SendMsg");
	if (!IsOnline())
		return 0;

	bool bIsChat = isChatRoom(hContact);
	LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID" , -1);

	if (iUserID == -1 || iUserID == VK_FEED_USER) {
		ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact));
		return 0;
	}

	int StickerId = 0;
	ptrA pszRetMsg(GetStickerId(szMsg, StickerId));

	ULONG uMsgId = ::InterlockedIncrement(&m_msgId);
	AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, bIsChat? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
		<< INT_PARAM(bIsChat ? "chat_id" : "user_id", iUserID)
		<< INT_PARAM("random_id", ((LONG) time(NULL)) * 100 + uMsgId % 100);
	pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");

	if (StickerId)
		pReq << INT_PARAM("sticker_id", StickerId);
	else {
		pReq << CHAR_PARAM("message", szMsg);
		if (m_vkOptions.bSendVKLinksAsAttachments) {
			CMStringA szAttachments = GetAttachmentsFromMessage(szMsg);
			if (!szAttachments.IsEmpty()) {
				debugLogA("CVkProto::SendMsg Attachments = %s", szAttachments);
				pReq << CHAR_PARAM("attachment", szAttachments);
			}
		}
	}

	if (!bIsChat)
		pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
	
	Push(pReq);

	if (!m_bServerDelivery && !bIsChat)
		ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact, uMsgId));

	if (!IsEmpty(pszRetMsg)) 
		SendMsg(hContact, 0, pszRetMsg);

	return uMsgId;
}
示例#30
0
void FacebookProto::SendTypingWorker(void *p)
{
	if (p == NULL)
		return;

	send_typing *typing = static_cast<send_typing*>(p);

	// Dont send typing notifications to not friends - Facebook won't give them that info anyway
	if (!isChatRoom(typing->hContact) && getWord(typing->hContact, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND) {
		delete typing;
		return;
	}

	const char *value = (isChatRoom(typing->hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID);
	ptrA id(getStringA(typing->hContact, value));
	if (id != NULL) {
		bool isChat = isChatRoom(typing->hContact);
		std::string idEncoded = utils::url::encode(std::string(id));

		std::string data = (typing->status == PROTOTYPE_SELFTYPING_ON ? "typ=1" : "typ=0");
		data += "&to=" + (isChat ? "" : idEncoded);
		data += "&source=mercury-chat";
		data += "&thread=" + idEncoded;
		data += "&__user="******"&__dyn=" + facy.__dyn();
		data += "&__req=" + facy.__req();

		data += "&fb_dtsg=" + facy.dtsg_;
		data += "&ttsamp=" + facy.ttstamp_;
		data += "&__rev=" + facy.__rev();

		http::response resp = facy.flap(REQUEST_TYPING_SEND, &data); // NOTE: Request revised 11.2.2016
	}

	delete typing;
}