示例#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;
}
示例#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;
}
示例#3
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;
}
示例#4
0
int CMsnProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
{
	DBCONTACTWRITESETTING* cws = (DBCONTACTWRITESETTING*)lParam;

	if (!msnLoggedIn || MyOptions.netId != NETID_MSN)
		return 0;

	if (hContact == NULL) {
		if (MyOptions.SlowSend && strcmp(cws->szSetting, "MessageTimeout") == 0 &&
			(strcmp(cws->szModule, "SRMM") == 0 || strcmp(cws->szModule, "SRMsg") == 0)) {
			if (cws->value.dVal < 60000)
				MessageBox(NULL, TranslateT("MSN requires message send timeout in your Message window plugin to be not less then 60 sec. Please correct the timeout value."),
				TranslateT("MSN Protocol"), MB_OK | MB_ICONINFORMATION);
		}
		return 0;
	}

	if (!strcmp(cws->szSetting, "ApparentMode")) {
		char tEmail[MSN_MAX_EMAIL_LEN];
		if (!db_get_static(hContact, m_szModuleName, "wlid", tEmail, sizeof(tEmail)) ||
			!db_get_static(hContact, m_szModuleName, "e-mail", tEmail, sizeof(tEmail))) {
			bool isBlocked = Lists_IsInList(LIST_BL, tEmail);

			if (isBlocked && (cws->value.type == DBVT_DELETED || cws->value.wVal == 0)) {
				MSN_AddUser(hContact, tEmail, 0, LIST_BL + LIST_REMOVE);
				MSN_AddUser(hContact, tEmail, 0, LIST_AL);
			}
			else if (!isBlocked && cws->value.wVal == ID_STATUS_OFFLINE) {
				MSN_AddUser(hContact, tEmail, 0, LIST_AL + LIST_REMOVE);
				MSN_AddUser(hContact, tEmail, 0, LIST_BL);
			}
		}
	}

	if (!strcmp(cws->szSetting, "MyHandle") && !strcmp(cws->szModule, "CList")) {
		bool isMe = MSN_IsMeByContact(hContact);
		if (!isMe || !nickChg) {
			char szContactID[100];
			if (!db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID))) {
				if (cws->value.type != DBVT_DELETED) {
					if (cws->value.type == DBVT_UTF8)
						MSN_ABUpdateNick(cws->value.pszVal, szContactID);
					else
						MSN_ABUpdateNick(UTF8(cws->value.pszVal), szContactID);
				}
				else MSN_ABUpdateNick(NULL, szContactID);
			}

			if (isMe)
				displayEmailCount(hContact);
		}
	}
	return 0;
}
示例#5
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;
}
示例#6
0
void CMsnProto::sttNotificationMessage(char* msgBody, bool isInitial)
{
	TCHAR tBuffer[512];
	TCHAR tBuffer2[512];
	int  UnreadMessages = mUnreadMessages;
	int  UnreadJunkEmails = mUnreadJunkEmails;
	bool ShowPopup = isInitial;

	MimeHeaders tFileInfo;
	tFileInfo.readFromBuffer(msgBody);

	const char* From = tFileInfo["From"];
	const char* Subject = tFileInfo["Subject"];
	const char* Fromaddr = tFileInfo["From-Addr"];
	const char* MsgDelta = tFileInfo["Message-Delta"];
	const char* SrcFolder = tFileInfo["Src-Folder"];
	const char* DestFolder = tFileInfo["Dest-Folder"];
	const char* InboxUnread = tFileInfo["Inbox-Unread"];
	const char* FoldersUnread = tFileInfo["Folders-Unread"];

	if (InboxUnread != NULL)
		mUnreadMessages = atol(InboxUnread);
	if (FoldersUnread != NULL)
		mUnreadJunkEmails = atol(FoldersUnread);

	if (MsgDelta != NULL) {
		int iDelta = atol(MsgDelta);
		if (SrcFolder && mir_strcmp(SrcFolder, "ACTIVE") == 0)
			mUnreadMessages -= iDelta;
		else if (DestFolder && mir_strcmp(DestFolder, "ACTIVE") == 0)
			mUnreadMessages += iDelta;
		if (SrcFolder && mir_strcmp(SrcFolder, "HM_BuLkMail_") == 0)
			mUnreadJunkEmails -= iDelta;
		else if (DestFolder && mir_strcmp(DestFolder, "HM_BuLkMail_") == 0)
			mUnreadJunkEmails += iDelta;

		if (mUnreadJunkEmails < 0) mUnreadJunkEmails = 0;
		if (mUnreadMessages < 0) mUnreadMessages = 0;
	}

	if (From != NULL && Subject != NULL && Fromaddr != NULL) {
		if (DestFolder != NULL && SrcFolder == NULL) {
			mUnreadMessages += mir_strcmp(DestFolder, "ACTIVE") == 0;
			mUnreadJunkEmails += mir_strcmp(DestFolder, "HM_BuLkMail_") == 0;
		}

		wchar_t* mimeFromW = tFileInfo.decode(From);
		wchar_t* mimeSubjectW = tFileInfo.decode(Subject);


		mir_sntprintf(tBuffer2, TranslateT("Subject: %s"), mimeSubjectW);



		TCHAR* msgtxt = _stricmp(From, Fromaddr) ?
			TranslateT("Hotmail from %s (%S)") : TranslateT("Hotmail from %s");

		mir_sntprintf(tBuffer, msgtxt, mimeFromW, Fromaddr);
		mir_free(mimeFromW);
		mir_free(mimeSubjectW);
		ShowPopup = true;
	}
	else {
		const char* MailData = tFileInfo["Mail-Data"];
		if (MailData != NULL) processMailData((char*)MailData);

		mir_sntprintf(tBuffer, m_tszUserName);
		mir_sntprintf(tBuffer2, TranslateT("Unread mail is available: %d in Inbox and %d in other folders."), mUnreadMessages, mUnreadJunkEmails);
	}

	if (UnreadMessages == mUnreadMessages && UnreadJunkEmails == mUnreadJunkEmails  && !isInitial)
		return;

	ShowPopup &= mUnreadMessages != 0 || (mUnreadJunkEmails != 0 && !getByte("DisableHotmailJunk", 0));

	MCONTACT hContact = MSN_HContactFromEmail(MyOptions.szEmail);
	if (hContact) {
		pcli->pfnRemoveEvent(hContact, 1);
		displayEmailCount(hContact);

		if (ShowPopup && !getByte("DisableHotmailTray", 1)) {
			char buf[64];
			mir_snprintf(buf, "%s%s", m_szModuleName, MS_GOTO_INBOX);

			CLISTEVENT cle = {};
			cle.hContact = hContact;
			cle.hDbEvent = 1;
			cle.flags = CLEF_URGENT | CLEF_TCHAR;
			cle.hIcon = Skin_LoadIcon(SKINICON_OTHER_SENDEMAIL);
			cle.ptszTooltip = tBuffer2;
			cle.pszService = buf;
			pcli->pfnAddEvent(&cle);
		}
	}

	ProtoBroadcastAck(NULL, ACKTYPE_EMAIL, ACKRESULT_STATUS, NULL, 0);

	// Disable to notify receiving hotmail
	if (ShowPopup && !getByte("DisableHotmail", 0)) {
		SkinPlaySound(mailsoundname);

		const char *msgurl = tFileInfo["Message-URL"];
		if (msgurl) {
			const char *p = strchr(msgurl, '&'); if (p) *(char*)p = 0;
			p = strstr(msgurl, "getmsg"); if (p) msgurl = p;
		}
		else
			msgurl = "inbox";

		char szUrl[256];
		mir_snprintf(szUrl, "http://mail.live.com?rru=%s", msgurl);

		MSN_ShowPopup(tBuffer, tBuffer2,
			MSN_ALLOW_ENTER | MSN_ALLOW_MSGBOX | MSN_HOTMAIL_POPUP,
			szUrl);
	}

	if (!getByte("RunMailerOnHotmail", 0) || !ShowPopup || isInitial)
		return;

	char mailerpath[MAX_PATH];
	if (!db_get_static(NULL, m_szModuleName, "MailerPath", mailerpath, sizeof(mailerpath))) {
		if (mailerpath[0]) {
			char* tParams = NULL;
			char* tCmd = mailerpath;

			if (*tCmd == '\"') {
				++tCmd;
				char* tEndPtr = strchr(tCmd, '\"');
				if (tEndPtr != NULL) {
					*tEndPtr = 0;
					tParams = tEndPtr + 1;
				}
			}

			if (tParams == NULL) {
				tParams = strchr(tCmd, ' ');
				tParams = tParams ? tParams + 1 : strchr(tCmd, '\0');
			}

			while (*tParams == ' ') ++tParams;

			debugLogA("Running mailer \"%s\" with params \"%s\"", tCmd, tParams);
			ShellExecuteA(NULL, "open", tCmd, tParams, NULL, TRUE);
		}
	}
}