Beispiel #1
0
int __cdecl CMsnProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
{	
	if (msnLoggedIn) 
	{
		char email[MSN_MAX_EMAIL_LEN];
		if (getStaticString(hContact, "e-mail", email, sizeof(email))) 
			return 1;

		char* szMsg = mir_utf8encodeT(szMessage);

//			int netId = Lists_GetNetId(email);
//			if (netId == NETID_UNKNOWN)
		int netId = strncmp(email, "tel:", 4) == 0 ? NETID_MOB : NETID_MSN;
		if (MSN_AddUser(hContact, email, netId, LIST_FL, szMsg))
		{
			MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);
			MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
			MSN_AddUser(hContact, email, netId, LIST_AL);
		}
		MSN_SetContactDb(hContact, email);
		mir_free(szMsg);

		if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact);
		return 0;
	}
	return 1;
}
Beispiel #2
0
HANDLE CMsnProto::AddToListByEmail(const char *email, const char *nick, DWORD flags)
{
	HANDLE hContact = MSN_HContactFromEmail(email, nick, true, flags & PALF_TEMPORARY);

	if (flags & PALF_TEMPORARY) 
	{
		if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1) 
			DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
	}
	else 
	{
		DBDeleteContactSetting(hContact, "CList", "Hidden");
		if (msnLoggedIn) 
		{
//			int netId = Lists_GetNetId(email);
//			if (netId == NETID_UNKNOWN)
			int netId = strncmp(email, "tel:", 4) ? NETID_MSN : NETID_MOB;
			if (MSN_AddUser(hContact, email, netId, LIST_FL))
			{
				MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);
				MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
				MSN_AddUser(hContact, email, netId, LIST_AL);
				DBDeleteContactSetting(hContact, "CList", "Hidden");
			}
			MSN_SetContactDb(hContact, email);

			if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact);
		}
		else hContact = NULL;
	}
	return hContact;
}
Beispiel #3
0
// MsnAuthAllow - called after successful authorization
int CMsnProto::Authorize(MEVENT hDbEvent)
{
	if (!msnLoggedIn)
		return 1;

	DBEVENTINFO dbei = { sizeof(dbei) };
	if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
		return 1;

	dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
	if (db_event_get(hDbEvent, &dbei))
		return 1;

	if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
		return 1;

	if (mir_strcmp(dbei.szModule, m_szModuleName))
		return 1;

	char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2);
	char *firstName = nick + mir_strlen(nick) + 1;
	char *lastName = firstName + mir_strlen(firstName) + 1;
	char *email = lastName + mir_strlen(lastName) + 1;

	MCONTACT hContact = MSN_HContactFromEmail(email, nick, true, 0);
	int netId = Lists_GetNetId(email);

	MSN_AddUser(hContact, email, netId, LIST_AL);
	MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
	MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);

	MSN_SetContactDb(hContact, email);
	return 0;
}
Beispiel #4
0
// MsnAddToList - adds contact to the server list
MCONTACT CMsnProto::AddToListByEmail(const char *email, const char *nick, DWORD flags)
{
	MCONTACT hContact = MSN_HContactFromEmail(email, nick, true, flags & PALF_TEMPORARY);

	if (flags & PALF_TEMPORARY) {
		if (db_get_b(hContact, "CList", "NotOnList", 0) == 1)
			db_set_b(hContact, "CList", "Hidden", 1);
	}
	else {
		db_unset(hContact, "CList", "Hidden");
		if (msnLoggedIn) {
			int netId = strncmp(email, "tel:", 4) ? NETID_MSN : NETID_MOB;
			if (MSN_AddUser(hContact, email, netId, LIST_FL)) {
				MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);
				MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
				MSN_AddUser(hContact, email, netId, LIST_AL);
				db_unset(hContact, "CList", "Hidden");
			}
			MSN_SetContactDb(hContact, email);

			if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact);
		}
		else hContact = NULL;
	}
	return hContact;
}
Beispiel #5
0
void CMsnProto::MSN_CleanupLists(void)
{
	for (int i=contList.getCount(); i--;) {
		MsnContact& p = contList[i];
		if (p.list & LIST_FL)
			MSN_SetContactDb(p.hContact, p.email);

		if (p.list & LIST_PL) {
			if (p.list & (LIST_AL | LIST_BL))
				MSN_AddUser(NULL, p.email, p.netId, LIST_PL + LIST_REMOVE);
			else
				MSN_AddAuthRequest(p.email, p.nick, p.invite);
		}

		if (p.hContact && !(p.list & (LIST_LL | LIST_FL | LIST_PL)) && p.list != LIST_RL) {
			int count = db_event_count(p.hContact);
			if (count) {
				TCHAR text[256];
				TCHAR *sze = mir_a2t(p.email);
				mir_sntprintf(text, SIZEOF(text), TranslateT("Contact %s has been removed from the server.\nWould you like to keep it as \"Local Only\" contact to preserve history?"), sze);
				mir_free(sze);

				TCHAR title[128];
				mir_sntprintf(title, SIZEOF(title), TranslateT("%s protocol"), m_tszUserName);

				if (MessageBox(NULL, text, title, MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND) == IDYES) {
					MSN_AddUser(p.hContact, p.email, 0, LIST_LL);
					setByte(p.hContact, "LocalList", 1);
					continue;
				}
			}

			if (!(p.list & (LIST_LL | LIST_FL))) {
				CallService(MS_DB_CONTACT_DELETE, (WPARAM)p.hContact, 0);
				p.hContact = NULL;
			}
		}

		if (p.list & (LIST_LL | LIST_FL) && p.hContact) {
			TCHAR path[MAX_PATH];
			MSN_GetCustomSmileyFileName(p.hContact, path, SIZEOF(path), "", 0);
			if (path[0]) {
				SMADD_CONT cont;
				cont.cbSize = sizeof(SMADD_CONT);
				cont.hContact = p.hContact;
				cont.type = 0;
				cont.path = path;

				CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
			}
		}
	}
}
Beispiel #6
0
// PSS_AUTHREQUEST
int __cdecl CMsnProto::AuthRequest(MCONTACT hContact, const TCHAR* szMessage)
{
	if (msnLoggedIn) {
		char email[MSN_MAX_EMAIL_LEN];
		if (db_get_static(hContact, m_szModuleName, "wlid", email, sizeof(email)) &&
			db_get_static(hContact, m_szModuleName, "e-mail", email, sizeof(email)))
			return 1;

		int netId = strncmp(email, "tel:", 4) == 0 ? NETID_MOB : (strncmp(email, "live:", 5) == 0 ? NETID_SKYPE : NETID_MSN);
		if (MSN_AddUser(hContact, email, netId, LIST_FL, T2Utf(szMessage))) {
			MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);
			MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
			MSN_AddUser(hContact, email, netId, LIST_AL);
		}
		MSN_SetContactDb(hContact, email);

		if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact);
		return 0;
	}
	return 1;
}
Beispiel #7
0
int CMsnProto::Authorize(HANDLE hDbEvent)
{
	if (!msnLoggedIn)
		return 1;

	DBEVENTINFO dbei = { 0 };
	dbei.cbSize = sizeof(dbei);

	if ((int)(dbei.cbBlob = MSN_CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == -1)
		return 1;

	dbei.pBlob = (PBYTE)_malloca(dbei.cbBlob);
	if (MSN_CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei))
		return 1;

	if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
		return 1;

	if (strcmp(dbei.szModule, m_szModuleName))
		return 1;

	char* nick = (char*)(dbei.pBlob + sizeof(DWORD) + sizeof(HANDLE));
	char* firstName = nick + strlen(nick) + 1;
	char* lastName = firstName + strlen(firstName) + 1;
	char* email = lastName + strlen(lastName) + 1;

	HANDLE hContact = MSN_HContactFromEmail(email, nick, true, 0);
	int netId = Lists_GetNetId(email);

	MSN_AddUser(hContact, email, netId, LIST_AL);
	MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE);
	MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE);

	MSN_SetContactDb(hContact, email);
	return 0;
}