示例#1
0
INT_PTR FilterMailSvc(WPARAM wParam,LPARAM lParam)
{
	HACCOUNT Account=(HACCOUNT)wParam;
	HYAMNMAIL Mail=(HYAMNMAIL)lParam;
	PYAMN_FILTERPLUGINQUEUE ActualPlugin;

	EnterCriticalSection(&PluginRegCS);
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"FilterMail:ActualAccountMsgsSO-write wait\n");
#endif
	WaitToWriteFcn(Account->MessagesAccessSO);
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"FilterMail:ActualAccountMsgsSO-write enter\n");
#endif
	for (ActualPlugin=FirstFilterPlugin;ActualPlugin != NULL;ActualPlugin=ActualPlugin->Next)
	{
		if (ActualPlugin->Plugin->FilterFcn->FilterMailFcnPtr != NULL)
		{
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"\tFiltering Mail, running plugin %0x to filter mail\n",ActualPlugin->Plugin);
#endif
			ActualPlugin->Plugin->FilterFcn->FilterMailFcnPtr(Account,YAMN_ACCOUNTVERSION,Mail,YAMN_MAILVERSION);
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"\tFiltering Mail done\n");
#endif
		}
	}
	Mail->Flags|=YAMN_MSG_FILTERED;

//Set mail flags according to spamlevel settings
	if ((Mail->Flags & YAMN_MSG_SPAMMASK) > YAMN_MSG_SPAML1)
		Mail->Flags=Mail->Flags & ~(YAMN_MSG_BROWSER | YAMN_MSG_POPUP | YAMN_MSG_SYSTRAY | YAMN_MSG_SOUND | YAMN_MSG_APP | YAMN_MSG_NEVENT);
	if (YAMN_MSG_SPAML(Mail->Flags,YAMN_MSG_SPAML3) || YAMN_MSG_SPAML(Mail->Flags,YAMN_MSG_SPAML4))
		Mail->Flags=Mail->Flags | (YAMN_MSG_AUTODELETE | YAMN_MSG_DELETEOK);	//set message to delete
	if (YAMN_MSG_SPAML(Mail->Flags,YAMN_MSG_SPAML3))
		Mail->Flags=Mail->Flags & ~(YAMN_MSG_MEMDELETE);	//set message not to delete it immidiatelly from memory
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"FilterMail:ActualAccountMsgsSO-write done\n");
#endif
	WriteDoneFcn(Account->MessagesAccessSO);
	LeaveCriticalSection(&PluginRegCS);
	return 1;
}
示例#2
0
static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char *End)
{
	//Retrieve info for account from memory
	char *Parser;
	DWORD Ver,Stat;

	HACCOUNT ActualAccount,FirstAllocatedAccount;

	Ver=*(DWORD *)MemFile;
	if (Ver>YAMN_ACCOUNTFILEVERSION)
	{
		delete[] MemFile;
		return EACC_FILEVERSION;
	}
	Parser=MemFile+sizeof(Ver);

#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write wait\n");
#endif
	SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE);
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write enter\n");
#endif
	if (NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION)))
	{
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
#endif
		SWMRGDoneWriting(Plugin->AccountBrowserSO);
		delete[] MemFile;
		return EACC_ALLOC;
	}
	FirstAllocatedAccount=ActualAccount;

	do
	{
		HACCOUNT Temp;

#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write wait\n");
#endif
		WaitToWriteFcn(ActualAccount->AccountAccessSO);
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write enter\n");
#endif
		Stat=ReadAccountFromMemory(ActualAccount,&Parser,End);

		if (ActualAccount->StatusFlags & (YAMN_ACC_STARTA | YAMN_ACC_STARTS))
			ActualAccount->TimeLeft=1;		//check on loading

		if (Stat && (Stat != EACC_ENDOFFILE))
		{
			for (ActualAccount=FirstAllocatedAccount;ActualAccount != NULL;ActualAccount=Temp)
			{
				Temp=ActualAccount->Next;
				delete ActualAccount;
			}
			delete[] MemFile;
			if (Plugin->FirstAccount==FirstAllocatedAccount)
				Plugin->FirstAccount=NULL;
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write done\n");
#endif
			SWMRGDoneWriting(Plugin->AccountBrowserSO);
			return (INT_PTR)Stat;
		}

#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write done\n");
#endif
		WriteDoneFcn(ActualAccount->AccountAccessSO);

		if ((Stat != EACC_ENDOFFILE) && (NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION))))
		{
			for (ActualAccount=FirstAllocatedAccount;ActualAccount != NULL;ActualAccount=Temp)
			{
				Temp=ActualAccount->Next;
				delete ActualAccount;
			}
			delete[] MemFile;
			if (Plugin->FirstAccount==FirstAllocatedAccount)
				Plugin->FirstAccount=NULL;
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
#endif
			SWMRGDoneWriting(Plugin->AccountBrowserSO);
			return EACC_ALLOC;
		}
	}while(Stat != EACC_ENDOFFILE);

#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
#endif
	SWMRGDoneWriting(Plugin->AccountBrowserSO);
	delete[] MemFile;

	return 0;
}
示例#3
0
DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End)
{
	DWORD Stat;
#ifdef DEBUG_FILEREAD
	TCHAR Debug[65536];
#endif
	//Read name of account	

#ifdef DEBUG_FILEREAD
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Name,_T("Name")))
#else
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Name))
#endif
		return Stat;
	if (Which->Name==NULL)
		return EACC_FILECOMPATIBILITY;

	//Read server parameters
#ifdef	DEBUG_FILEREAD
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name,_T("Server")))
#else
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name))
#endif
		return Stat;
	Which->Server->Port=*(WORD *)(*Parser);
	(*Parser)+=sizeof(WORD);
	if (*Parser>=End)
		return EACC_FILECOMPATIBILITY;
#ifdef	DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("Port: %d, remaining %d chars"), Which->Server->Port, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
#ifdef	DEBUG_FILEREAD
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login,_T("Login")))
#else
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login))
#endif
		return Stat;
#ifdef	DEBUG_FILEREAD
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd,_T("Password")))
#else
	if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd))
#endif
		return Stat;
	CodeDecodeString(Which->Server->Passwd,FALSE);

	//Read account flags
	Which->Flags=*(DWORD *)(*Parser);
	(*Parser)+=sizeof(DWORD);
	if (*Parser>=End)
		return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("Flags: %04x, remaining %d chars"), Which->Flags, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
	Which->StatusFlags=*(DWORD *)(*Parser);
	(*Parser)+=sizeof(DWORD);
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("STFlags: %04x, remaining %d chars"), Which->StatusFlags, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
	Which->PluginFlags=*(DWORD *)(*Parser);
	(*Parser)+=sizeof(DWORD);
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("PFlags: %04x, remaining %d chars"), Which->PluginFlags, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif

	//Read account miscellaneous parameters
	Which->Interval=*(WORD *)(*Parser);
	Which->TimeLeft=Which->Interval;		//check on loading
	(*Parser)+=sizeof(WORD);
	if (*Parser>=End)
		return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("Interval: %d, remaining %d chars"), Which->Interval, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif

	//Read notification parameters
	if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NewMailN))
		return Stat;
	if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NoNewMailN))
		return Stat;
	if (Stat=ReadNotificationFromMemory(Parser,End,&Which->BadConnectN))
		return Stat;

	//Let plugin read its own data stored in file
	if (Which->Plugin->Fcn != NULL && Which->Plugin->Fcn->ReadPluginOptsFcnPtr != NULL)
		if (Stat=Which->Plugin->Fcn->ReadPluginOptsFcnPtr(Which,Parser,End))
			return Stat;
	//Read mails
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write wait\n");
#endif
	WaitToWriteFcn(Which->MessagesAccessSO);
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write enter\n");
#endif
	if (Stat=ReadMessagesFromMemory(Which,Parser,End))
	{
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write done\n");
#endif
		WriteDoneFcn(Which->MessagesAccessSO);
		return Stat;
	}
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write done\n");
#endif
	WriteDoneFcn(Which->MessagesAccessSO);

	//Read timestamps
	Which->LastChecked=*(SYSTEMTIME *)(*Parser);
	(*Parser)+=sizeof(SYSTEMTIME);
	if (*Parser>=End)
		return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("LastChecked: %04x, remaining %d chars"), Which->LastChecked, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
	Which->LastSChecked=*(SYSTEMTIME *)(*Parser);
	(*Parser)+=sizeof(SYSTEMTIME);
	if (*Parser>=End)
		return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("LastSChecked: %04x, remaining %d chars"), Which->LastSChecked, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
	Which->LastSynchronised=*(SYSTEMTIME *)(*Parser);
	(*Parser)+=sizeof(SYSTEMTIME);
	if (*Parser>=End)
		return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("LastSynchronised: %04x, remaining %d chars"), Which->LastSynchronised, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
	Which->LastMail=*(SYSTEMTIME *)(*Parser);
	(*Parser)+=sizeof(SYSTEMTIME);
	if (*Parser>End)		//WARNING! There's only > at the end of testing
		return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
	mir_sntprintf(Debug, SIZEOF(Debug), _T("LastMail: %04x, remaining %d chars"), Which->LastMail, End-*Parser);
	MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
	if (*Parser==End)
		return EACC_ENDOFFILE;
	return 0;

}