summaryrefslogtreecommitdiff
path: root/plugins/YAMN/account.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/YAMN/account.cpp')
-rw-r--r--plugins/YAMN/account.cpp588
1 files changed, 205 insertions, 383 deletions
diff --git a/plugins/YAMN/account.cpp b/plugins/YAMN/account.cpp
index bc52aa0371..532640c15b 100644
--- a/plugins/YAMN/account.cpp
+++ b/plugins/YAMN/account.cpp
@@ -12,187 +12,14 @@
#include <stdio.h>
#endif
-//- imported ---------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------------
-
-extern PSWMRG PluginBrowserSO;
-extern TCHAR AccountFileName[];
-extern TCHAR *CurDir;
-extern PLUGININFO pluginInfo;
-extern YAMN_VARIABLES YAMNVar;
-
-extern BOOL WINAPI SWMRGInitialize(PSWMRG pSWMRG,TCHAR *Name);
-extern void WINAPI SWMRGDelete(PSWMRG pSWMRG);
-extern DWORD WINAPI SWMRGWaitToWrite(PSWMRG pSWMRG,DWORD dwTimeout);
-extern void WINAPI SWMRGDoneWriting(PSWMRG pSWMRG);
-extern DWORD WINAPI SWMRGWaitToRead(PSWMRG pSWMRG, DWORD dwTimeout);
-extern void WINAPI SWMRGDoneReading(PSWMRG pSWMRG);
-extern DWORD WINAPI WaitToReadFcn(PSWMRG SObject);
-extern void WINAPI ReadDoneFcn(PSWMRG SObject);
-extern HYAMNPROTOPLUGIN FindPlugin(DWORD PluginID);
-
-extern void WINAPI DeleteMessagesToEndFcn(HACCOUNT Account,HYAMNMAIL From);
-
-//--------------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------------
-
-// SMALL INTRO
-// Accounts are queued in a queue (chained list). Pointer to first account is called "FirstAccount"
-// Account queue is ended with NULL- pointered account (NULL handle)
-// FirstAccount has every plugin in its own YAMN_PLUGIN structure
-
//Account status CS
//When we check some account, thread should change status of account to idle, connecting etc.
//So if we want to read status, we have to successfully write and then read.
-LPCRITICAL_SECTION AccountStatusCS;
+CRITICAL_SECTION AccountStatusCS;
//File Writing CS
//When 2 threads want to write to file...
-LPCRITICAL_SECTION FileWritingCS;
-
-// Creates new account, which has plugin specified structure
-INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam);
-
-// Deletes account from memory
-INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM);
-
-// Initializes standard YAMN account parameters
-int InitAccount(HACCOUNT Which);
-
-// Deinitializes (deletes) standard YAMN account parameters
-void DeInitAccount(HACCOUNT Which);
-
-// Sends signal (sets event) in AccountAccessSO and MessagesAccessSO
-// This event makes that all calls to ...WaitToRead or ...WaitToWrite are returned to WAIT_FAILED
-void StopSignalFcn(HACCOUNT Which);
-
-// Function used to encrypt password (codes / decodes string)
-// There's a problem when a character is going to be encrypted to (TCHAR)0, (end of string)
-// Dest- input and output string (input/output length of string is 1:1)
-// Encrypt- TRUE for encryption, FALSE for decryption
-void CodeDecodeString(TCHAR *Dest,BOOL Encrypt);
-
-// Only do the main work for FileToMemoryX functions. FileToMemoryX only opens file.
-static DWORD PostFileToMemory(HANDLE File,TCHAR **MemFile,TCHAR **End);
-
-// Reads the file and stores the content to allocated memory
-// FileName- name of file
-// MemFile- pointer to the pointer of TCHAR, new allocated memory by this function
-// End- where new allocated memory filled with file contents ends
-DWORD FileToMemoryA(char *FileName,TCHAR **MemFile,TCHAR **End);
-
-// Same as FileToMemoryA, but Unicode filename
-DWORD FileToMemoryW(char *FileName,TCHAR **MemFile,TCHAR **End);
-
-// Reads string that ends with character 0 and copies it to new allocated memory
-// Parser-pointer to memory with string
-// function sets this parameter to point at the next char after read string
-// End-information how long this string can be (in pointer to last possible char)
-// StoreTo-function allocates memory and copies the string, allocated memory returned in StoreTo
-// DebugString-the debug message showed in debug version
-#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
-DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo,TCHAR *DebugString);
-#endif
-DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo);
-#ifndef UNICODE
- #if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
-DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *DebugString);
- #endif //if defined(DEBUG...)
-DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo);
-#endif //ifdef Unicode
-
-// Reads notification parameters from memory
-// Parser-pointer to memory with string
-// function sets this parameter to point at the next char after read string
-// End-information how long this string can be (in pointer to last possible char)
-// Which-pointer to notification structure to fill with read parameters
-static DWORD ReadNotificationFromMemory(TCHAR **Parser,TCHAR *End,YAMN_NOTIFICATION *Which);
-
-// Reads messages from memory
-// Which- address of account that mails (messages) belong to
-// Parser- pointer to data from memory, function changes it to the next char after messages read
-// End- the last possible char of messages
-DWORD ReadMessagesFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End);
-
-// Does all needed operations to read account
-static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHAR *End);
-
-// Read one account from memory
-// Which- address of account
-// Parser- pointer to data from memory, function changes it to the next char after account read
-// End- the last possible char of account
-DWORD ReadAccountFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End);
-
-// Inserts accounts read from file to actual account queue
-INT_PTR AddAccountsFromFileASvc(WPARAM wParam,LPARAM lParam);
-
-// Same as AddAccountsFromFileA, but filename is (WCHAR *) type- Unicode string
-INT_PTR AddAccountsFromFileWSvc(WPARAM,LPARAM);
-
-// Writes simple string to file
-// File- handle of open file for writing
-// Source- string to write, ended with zero character
-DWORD WriteStringToFile(HANDLE File,TCHAR *Source);
-#ifndef UNICODE
-DWORD WriteStringToFileW(HANDLE File,WCHAR *Source);
-#else
-#define ReadStringFromMemoryW ReadStringFromMemory
-#endif
-
-// Writes mails to file
-// File- handle of file
-// Which- address of account that mails belong to
-DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which);
-
-// Does all needed operations to write account to file
-static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File);
-
-// Writes accounts to file
-// Accounts are read from plugin's account queue
-// Function writes account data and calls WriteMessagesToFile to store account mails
-INT_PTR WriteAccountsToFileASvc(WPARAM wParam,LPARAM lParam);
-
-// Same as WriteAccountsToFileA, but filename is (WCHAR *) type- Unicode string
-INT_PTR WriteAccountsToFileWSvc(WPARAM wParam,LPARAM lParam);
-
-// Finds account by name and returns a pointer to it, or NULL when not found
-// we do not have to synchronize accounts for read access, because we never change name of account
-// (so if we want to change name of account we have to delete and create the new one)
-INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam);
-
-// Allocates a new account, and returns pointer to it
-// calling function should have write access (using AccountBrowserSO)
-// because new account is queues do account queue
-INT_PTR GetNextFreeAccountSvc(WPARAM wParam,LPARAM lParam);
-
-// Finds account for plugin
-//int FindPluginAccount(WPARAM wParam,LPARAM lParam);
-
-// Removes requested account from queue
-// and deletes it in memory calling new thread function, that does it in the background
-// This is very easy and the most secure way for plugins to delete account
-INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM);
-
-// This function is used as a thread function, that waits to signal for deleting account from memory
-// This signal is signaled in UsingAccount.Event (this signales that no thread will be use account in the future)
-DWORD WINAPI DeleteAccountInBackground(LPVOID Which);
-
-// Sends signal that all works with Plugin accounts should be stopped and accounts should not be used anymore.
-int StopAccounts(HYAMNPROTOPLUGIN Plugin);
-
-// Wait for accounts to finish its work
-int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess=FALSE);
-
-// Deletes protocol accounts using protocol defined delete function.
-int DeleteAccounts(HYAMNPROTOPLUGIN Plugin);
-
-// If you want to get directly account status, call this function
-// You don't have to be in read-access to account and you can call this to retrieve status
-void WINAPI GetStatusFcn(HACCOUNT Which,char *Value);
-
-// If you want to set directly account status, call this function
-// You don't have to be in write-access to account and you can call this to retrieve status
-void WINAPI SetStatusFcn(HACCOUNT Which,char *Value);
+CRITICAL_SECTION FileWritingCS;
struct CExportedFunctions AccountExportedFcn[]=
{
@@ -223,12 +50,12 @@ INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam)
HACCOUNT NewAccount;
//test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match)
- if(AccountVersion!=YAMN_ACCOUNTVERSION)
+ if (AccountVersion!=YAMN_ACCOUNTVERSION)
return NULL;
- if(Plugin!=NULL)
+ if (Plugin!=NULL)
{
- if(Plugin->Fcn->NewAccountFcnPtr!=NULL)
+ if (Plugin->Fcn->NewAccountFcnPtr!=NULL)
{
//Let plugin create its own structure, which can be derived from CAccount structure
NewAccount=Plugin->Fcn->NewAccountFcnPtr(Plugin,YAMN_ACCOUNTVERSION);
@@ -241,7 +68,7 @@ INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam)
NewAccount->Plugin=Plugin;
}
//If not created successfully
- if(NewAccount==NULL)
+ if (NewAccount==NULL)
return NULL;
//Init every members of structure, used by YAMN
InitAccount(NewAccount);
@@ -255,11 +82,11 @@ INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM)
{
HACCOUNT OldAccount=(HACCOUNT)wParam;
- if(OldAccount->Plugin->Fcn!=NULL)
+ if (OldAccount->Plugin->Fcn!=NULL)
{
//Deinit every members and allocated fields of structure used by YAMN
DeInitAccount(OldAccount);
- if(OldAccount->Plugin->Fcn->DeleteAccountFcnPtr!=NULL)
+ if (OldAccount->Plugin->Fcn->DeleteAccountFcnPtr!=NULL)
{
//Let plugin delete its own CAccount derived structure
OldAccount->Plugin->Fcn->DeleteAccountFcnPtr(OldAccount);
@@ -309,15 +136,15 @@ int InitAccount(HACCOUNT Which)
void DeInitAccount(HACCOUNT Which)
{
//delete YAMN allocated fields
- if(Which->Name!=NULL)
+ if (Which->Name!=NULL)
delete[] Which->Name;
- if(Which->Server->Name!=NULL)
+ if (Which->Server->Name!=NULL)
delete[] Which->Server->Name;
- if(Which->Server->Login!=NULL)
+ if (Which->Server->Login!=NULL)
delete[] Which->Server->Login;
- if(Which->Server->Passwd!=NULL)
+ if (Which->Server->Passwd!=NULL)
delete[] Which->Server->Passwd;
- if(Which->Server!=NULL)
+ if (Which->Server!=NULL)
delete[] Which->Server;
SWMRGDelete(Which->AccountAccessSO);
@@ -341,16 +168,16 @@ void StopSignalFcn(HACCOUNT Which)
SetEvent(Which->MessagesAccessSO->hFinishEV);
}
-void CodeDecodeString(TCHAR *Dest,BOOL Encrypt)
+void CodeDecodeString(char *Dest,BOOL Encrypt)
{
TCHAR Code=STARTCODEPSW;
- if(Dest==NULL)
+ if (Dest==NULL)
return;
for(;*Dest!=(TCHAR)0;Dest++)
{
- if(Encrypt)
+ if (Encrypt)
*Dest=*Dest+Code;
else
*Dest=*Dest-Code;
@@ -358,55 +185,55 @@ void CodeDecodeString(TCHAR *Dest,BOOL Encrypt)
}
}
-static DWORD PostFileToMemory(HANDLE File,TCHAR **MemFile,TCHAR **End)
+static DWORD PostFileToMemory(HANDLE File,char **MemFile,char **End)
{
DWORD FileSize,ReadBytes;
-
- if(!(FileSize=GetFileSize(File,NULL)))
- {
+ if (!(FileSize=GetFileSize(File,NULL))) {
CloseHandle(File);
return EACC_FILESIZE;
}
-//allocate space in memory, where we copy the whole file
- if(NULL==(*MemFile=(char *)new char[FileSize]))
+
+ //allocate space in memory, where we copy the whole file
+ if (NULL==(*MemFile = new char[FileSize]))
{
CloseHandle(File);
return EACC_ALLOC;
}
-//copy file to memory
- if(!ReadFile(File,(LPVOID)*MemFile,FileSize,&ReadBytes,NULL))
+
+ //copy file to memory
+ if (!ReadFile(File,(LPVOID)*MemFile,FileSize,&ReadBytes,NULL))
{
CloseHandle(File);
delete[] *MemFile;
return EACC_SYSTEM;
}
CloseHandle(File);
- *End=*MemFile+FileSize/sizeof(TCHAR);
+ *End = *MemFile + FileSize;
return 0;
}
-DWORD FileToMemoryA(char *FileName,TCHAR **MemFile,TCHAR **End)
+DWORD FileToMemoryA(char *FileName,char **MemFile,char **End)
{
HANDLE File;
- if(INVALID_HANDLE_VALUE==(File=CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL)))
+ if (INVALID_HANDLE_VALUE==(File=CreateFileA(FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL)))
return EACC_SYSTEM;
return PostFileToMemory(File,MemFile,End);
}
-DWORD FileToMemoryW(WCHAR *FileName,TCHAR **MemFile,TCHAR **End)
+DWORD FileToMemoryW(WCHAR *FileName,char **MemFile,char **End)
{
HANDLE File;
- if(INVALID_HANDLE_VALUE==(File=CreateFileW(FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL)))
+ if (INVALID_HANDLE_VALUE==(File=CreateFileW(FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL)))
return EACC_SYSTEM;
return PostFileToMemory(File,MemFile,End);
}
#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
-DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo,TCHAR *DebugString)
+DWORD ReadStringFromMemory(char **Parser,TCHAR *End,char **StoreTo,TCHAR *DebugString)
{
//This is the debug version of ReadStringFromMemory function. This version shows MessageBox where
//read string is displayed
@@ -418,11 +245,11 @@ DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo,TCHAR *Debu
while((*Finder!=(TCHAR)0) && (Finder<=End)) Finder++;
_stprintf(Debug,_T("%s: %s,length is %d, remaining %d chars"),DebugString,*Parser,Finder-*Parser,End-Finder);
MessageBox(NULL,Debug,_T("debug"),MB_OK);
- if(Finder>=End)
+ if (Finder>=End)
return EACC_FILECOMPATIBILITY;
- if(Size=Finder-*Parser)
+ if (Size=Finder-*Parser)
{
- if(NULL==(Dest=*StoreTo=new TCHAR[Size+1]))
+ if (NULL==(Dest=*StoreTo=new TCHAR[Size+1]))
return EACC_ALLOC;
for(;*Parser<=Finder;(*Parser)++,Dest++)
*Dest=**Parser;
@@ -436,18 +263,18 @@ DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo,TCHAR *Debu
}
#endif
-DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo)
+DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo)
{
- TCHAR *Dest,*Finder;
+ char *Dest,*Finder;
DWORD Size;
Finder=*Parser;
while((*Finder!=(TCHAR)0) && (Finder<=End)) Finder++;
- if(Finder>=End)
+ if (Finder>=End)
return EACC_FILECOMPATIBILITY;
- if(Size=Finder-*Parser)
+ if (Size=Finder-*Parser)
{
- if(NULL==(Dest=*StoreTo=new TCHAR[Size+1]))
+ if (NULL==(Dest=*StoreTo=new char[Size+1]))
return EACC_ALLOC;
for(;*Parser<=Finder;(*Parser)++,Dest++)
*Dest=**Parser;
@@ -460,7 +287,6 @@ DWORD ReadStringFromMemory(TCHAR **Parser,TCHAR *End,TCHAR **StoreTo)
return 0;
}
-#ifndef UNICODE
#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *DebugString)
{
@@ -474,11 +300,11 @@ DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *Deb
while((*Finder!=(WCHAR)0) && (Finder<=(WCHAR *)End)) Finder++;
swprintf(Debug,L"%s: %s,length is %d, remaining %d chars",DebugString,*Parser,Finder-*Parser,(WCHAR *)End-Finder);
MessageBoxW(NULL,Debug,L"debug",MB_OK);
- if(Finder>=(WCHAR *)End)
+ if (Finder>=(WCHAR *)End)
return EACC_FILECOMPATIBILITY;
- if(Size=Finder-*Parser)
+ if (Size=Finder-*Parser)
{
- if(NULL==(Dest=*StoreTo=new WCHAR[Size+1]))
+ if (NULL==(Dest=*StoreTo=new WCHAR[Size+1]))
return EACC_ALLOC;
for(;*Parser<=Finder;(*Parser)++,Dest++)
*Dest=**Parser;
@@ -499,11 +325,11 @@ DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo)
Finder=*Parser;
while((*Finder!=(WCHAR)0) && (Finder<=(WCHAR *)End)) Finder++;
- if(Finder>=(WCHAR *)End)
+ if (Finder>=(WCHAR *)End)
return EACC_FILECOMPATIBILITY;
- if(Size=Finder-*Parser)
+ if (Size=Finder-*Parser)
{
- if(NULL==(Dest=*StoreTo=new WCHAR[Size+1]))
+ if (NULL==(Dest=*StoreTo=new WCHAR[Size+1]))
return EACC_ALLOC;
for(;*Parser<=Finder;(*Parser)++,Dest++)
*Dest=**Parser;
@@ -515,9 +341,8 @@ DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo)
}
return 0;
}
-#endif //ifdef unicode
-static DWORD ReadNotificationFromMemory(TCHAR **Parser,TCHAR *End,YAMN_NOTIFICATION *Which)
+static DWORD ReadNotificationFromMemory(char **Parser,char *End,YAMN_NOTIFICATION *Which)
{
DWORD Stat;
#ifdef DEBUG_FILEREAD
@@ -525,8 +350,8 @@ static DWORD ReadNotificationFromMemory(TCHAR **Parser,TCHAR *End,YAMN_NOTIFICAT
#endif
Which->Flags=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(Debug,_T("NFlags: %04x, remaining %d chars"),Which->Flags,End-*Parser);
@@ -534,24 +359,24 @@ static DWORD ReadNotificationFromMemory(TCHAR **Parser,TCHAR *End,YAMN_NOTIFICAT
#endif
Which->PopUpB=*(COLORREF *)(*Parser);
- (*Parser)+=sizeof(COLORREF)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(COLORREF);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(Debug,_T("PopUpB: %04x, remaining %d chars"),Which->PopUpB,End-*Parser);
MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
Which->PopUpT=*(COLORREF *)(*Parser);
- (*Parser)+=sizeof(COLORREF)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(COLORREF);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(Debug,_T("PopUpT: %04x, remaining %d chars"),Which->PopUpT,End-*Parser);
MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
Which->PopUpTime=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(Debug,_T("PopUpTime: %04x, remaining %d chars"),Which->PopUpTime,End-*Parser);
@@ -559,23 +384,23 @@ static DWORD ReadNotificationFromMemory(TCHAR **Parser,TCHAR *End,YAMN_NOTIFICAT
#endif
#ifdef DEBUG_FILEREAD
- if(Stat=ReadStringFromMemoryW((WCHAR **)Parser,End,&Which->App,L"App"))
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->App,L"App"))
#else
- if(Stat=ReadStringFromMemoryW((WCHAR **)Parser,End,&Which->App))
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->App))
#endif
return Stat;
#ifdef DEBUG_FILEREAD
- if(Stat=ReadStringFromMemoryW((WCHAR **)Parser,End,&Which->AppParam,L"AppParam"))
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->AppParam,L"AppParam"))
#else
- if(Stat=ReadStringFromMemoryW((WCHAR **)Parser,End,&Which->AppParam))
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->AppParam))
#endif
return Stat;
return 0;
}
-DWORD ReadMessagesFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End)
+DWORD ReadMessagesFromMemory(HACCOUNT Which,char **Parser,char *End)
{
- TCHAR *Finder;
+ char *Finder;
DWORD Size,Stat;
HYAMNMAIL ActualMail=NULL;
struct CMimeItem *items;
@@ -588,77 +413,77 @@ DWORD ReadMessagesFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End)
{
Finder=*Parser;
while((*Finder!=(TCHAR)0) && (Finder<=End)) Finder++;
- if(Finder>=End)
+ if (Finder>=End)
return EACC_FILECOMPATIBILITY;
- if(Size=Finder-*Parser)
+ if (Size=Finder-*Parser)
{
- if(Which->Mails==NULL) //First message in queue
+ if (Which->Mails==NULL) //First message in queue
{
- if(NULL==(Which->Mails=ActualMail=CreateAccountMail(Which)))
+ if (NULL==(Which->Mails=ActualMail=CreateAccountMail(Which)))
return EACC_ALLOC;
}
else
{
- if(NULL==(ActualMail->Next=CreateAccountMail(Which))){
+ if (NULL==(ActualMail->Next=CreateAccountMail(Which))){
return EACC_ALLOC;
}
ActualMail=ActualMail->Next;
}
items=NULL;
#ifdef DEBUG_FILEREADMESSAGES
- if(Stat=ReadStringFromMemory(Parser,End,&ActualMail->ID,_T("ID")))
+ if (Stat=ReadStringFromMemory(Parser,End,&ActualMail->ID,_T("ID")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&ActualMail->ID))
+ if (Stat=ReadStringFromMemory(Parser,End,&ActualMail->ID))
#endif
return Stat;
// ActualMail->MailData=new MAILDATA; !!! mem leake !!! this is alloc by CreateAccountMail, no need for doubble alloc !!!!
ActualMail->MailData->Size=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
ActualMail->Flags=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
ActualMail->Number=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
- if((NULL!=Which->Plugin->MailFcn) && (NULL!=Which->Plugin->MailFcn->ReadMailOptsFcnPtr))
+ if ((NULL!=Which->Plugin->MailFcn) && (NULL!=Which->Plugin->MailFcn->ReadMailOptsFcnPtr))
Which->Plugin->MailFcn->ReadMailOptsFcnPtr(ActualMail,Parser,End); //read plugin mail settings from file
do
{
-#ifdef DEBUG_FILEREADMESSAGES
- if(Stat=ReadStringFromMemory(Parser,End,&ReadString,_T("Name")))
+#if defined(DEBUG_FILEREADMESSAGES) || defined(DEBUG_FILEREAD)
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString,_T("Name")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&ReadString))
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString))
#endif
return Stat;
- if(ReadString==NULL)
+ if (ReadString==NULL)
break;
#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<read name>%s</read name>",ReadString);
#endif
- if(items==NULL)
+ if (items==NULL)
items=ActualMail->MailData->TranslatedHeader=new struct CMimeItem;
else
{
items->Next=new struct CMimeItem;
items=items->Next;
}
- if(items==NULL)
+ if (items==NULL)
return EACC_ALLOC;
items->name=ReadString;
#ifdef DEBUG_FILEREADMESSAGES
- if(Stat=ReadStringFromMemory(Parser,End,&ReadString,_T("Value")))
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString,_T("Value")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&ReadString))
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString))
#endif
return Stat;
items->value=ReadString;
@@ -675,97 +500,98 @@ DWORD ReadMessagesFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End)
return 0;
}
-DWORD ReadAccountFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End)
+DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End)
{
DWORD Stat;
#ifdef DEBUG_FILEREAD
TCHAR Debug[65536];
#endif
-//Read name of account
+ //Read name of account
+
#ifdef DEBUG_FILEREAD
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Name,_T("Name")))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Name,_T("Name")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Name))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Name))
#endif
return Stat;
- if(Which->Name==NULL)
+ if (Which->Name==NULL)
return EACC_FILECOMPATIBILITY;
-//Read server parameters
+ //Read server parameters
#ifdef DEBUG_FILEREAD
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name,_T("Server")))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name,_T("Server")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name))
#endif
return Stat;
Which->Server->Port=*(WORD *)(*Parser);
- (*Parser)+=sizeof(WORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(WORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(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")))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login,_T("Login")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login))
#endif
return Stat;
#ifdef DEBUG_FILEREAD
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd,_T("Password")))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd,_T("Password")))
#else
- if(Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd))
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd))
#endif
return Stat;
CodeDecodeString(Which->Server->Passwd,FALSE);
-//Read account flags
+ //Read account flags
Which->Flags=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(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)/sizeof(TCHAR);
+ (*Parser)+=sizeof(DWORD);
#ifdef DEBUG_FILEREAD
_stprintf(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)/sizeof(TCHAR);
+ (*Parser)+=sizeof(DWORD);
#ifdef DEBUG_FILEREAD
_stprintf(Debug,_T("PFlags: %04x, remaining %d chars"),Which->PluginFlags,End-*Parser);
MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
-//Read account miscellaneous parameters
+ //Read account miscellaneous parameters
Which->Interval=*(WORD *)(*Parser);
Which->TimeLeft=Which->Interval; //check on loading
- (*Parser)+=sizeof(WORD)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(WORD);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(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))
+ //Read notification parameters
+ if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NewMailN))
return Stat;
- if(Stat=ReadNotificationFromMemory(Parser,End,&Which->NoNewMailN))
+ if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NoNewMailN))
return Stat;
- if(Stat=ReadNotificationFromMemory(Parser,End,&Which->BadConnectN))
+ 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))
+ //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
+ //Read mails
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write wait\n");
#endif
@@ -773,7 +599,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End)
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write enter\n");
#endif
- if(Stat=ReadMessagesFromMemory(Which,Parser,End))
+ if (Stat=ReadMessagesFromMemory(Which,Parser,End))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write done\n");
@@ -786,60 +612,60 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,TCHAR **Parser,TCHAR *End)
#endif
WriteDoneFcn(Which->MessagesAccessSO);
-//Read timestamps
+ //Read timestamps
Which->LastChecked=*(SYSTEMTIME *)(*Parser);
- (*Parser)+=sizeof(SYSTEMTIME)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(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)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(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)/sizeof(TCHAR);
- if(*Parser>=End)
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>=End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(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)/sizeof(TCHAR);
- if(*Parser>End) //WARNING! There's only > at the end of testing
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>End) //WARNING! There's only > at the end of testing
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
_stprintf(Debug,_T("LastMail: %04x, remaining %d chars"),Which->LastMail,End-*Parser);
MessageBox(NULL,Debug,_T("debug"),MB_OK);
#endif
- if(*Parser==End)
+ if (*Parser==End)
return EACC_ENDOFFILE;
return 0;
-
+
}
-static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHAR *End)
+static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char *End)
{
-//Retrieve info for account from memory
- TCHAR *Parser;
+ //Retrieve info for account from memory
+ char *Parser;
DWORD Ver,Stat;
HACCOUNT ActualAccount,FirstAllocatedAccount;
Ver=*(DWORD *)MemFile;
- if(Ver>YAMN_ACCOUNTFILEVERSION)
+ if (Ver>YAMN_ACCOUNTFILEVERSION)
{
delete[] MemFile;
return EACC_FILEVERSION;
}
- Parser=MemFile+sizeof(Ver)/sizeof(TCHAR);
+ Parser=MemFile+sizeof(Ver);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write wait\n");
@@ -848,7 +674,7 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write enter\n");
#endif
- if(NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION)))
+ if (NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION)))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
@@ -858,7 +684,7 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
return EACC_ALLOC;
}
FirstAllocatedAccount=ActualAccount;
-
+
do
{
HACCOUNT Temp;
@@ -872,10 +698,10 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
#endif
Stat=ReadAccountFromMemory(ActualAccount,&Parser,End);
- if(ActualAccount->StatusFlags & (YAMN_ACC_STARTA | YAMN_ACC_STARTS))
+ if (ActualAccount->StatusFlags & (YAMN_ACC_STARTA | YAMN_ACC_STARTS))
ActualAccount->TimeLeft=1; //check on loading
- if(Stat && (Stat!=EACC_ENDOFFILE))
+ if (Stat && (Stat!=EACC_ENDOFFILE))
{
for(ActualAccount=FirstAllocatedAccount;ActualAccount!=NULL;ActualAccount=Temp)
{
@@ -883,7 +709,7 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
delete ActualAccount;
}
delete[] MemFile;
- if(Plugin->FirstAccount==FirstAllocatedAccount)
+ if (Plugin->FirstAccount==FirstAllocatedAccount)
Plugin->FirstAccount=NULL;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write done\n");
@@ -891,13 +717,13 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
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))))
+ if ((Stat!=EACC_ENDOFFILE) && (NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION))))
{
for(ActualAccount=FirstAllocatedAccount;ActualAccount!=NULL;ActualAccount=Temp)
{
@@ -905,7 +731,7 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
delete ActualAccount;
}
delete[] MemFile;
- if(Plugin->FirstAccount==FirstAllocatedAccount)
+ if (Plugin->FirstAccount==FirstAllocatedAccount)
Plugin->FirstAccount=NULL;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
@@ -924,46 +750,44 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,TCHAR *MemFile,TCHA
return 0;
}
+// Add accounts from file to memory
INT_PTR AddAccountsFromFileASvc(WPARAM wParam,LPARAM lParam)
-//Add accounts from file to memory
{
DWORD Stat;
- TCHAR *MemFile,*End;
+ char *MemFile,*End;
- if(Stat=FileToMemoryA((char *)lParam,&MemFile,&End))
+ if (Stat=FileToMemoryA((char *)lParam,&MemFile,&End))
return (INT_PTR)Stat;
return PerformAccountReading((HYAMNPROTOPLUGIN)wParam,MemFile,End);
-
}
INT_PTR AddAccountsFromFileWSvc(WPARAM wParam,LPARAM lParam)
//Add accounts from file to memory
{
DWORD Stat;
- TCHAR *MemFile,*End;
+ char *MemFile,*End;
- if(Stat=FileToMemoryW((WCHAR *)lParam,&MemFile,&End))
+ if (Stat=FileToMemoryW((WCHAR *)lParam,&MemFile,&End))
return (INT_PTR)Stat;
return PerformAccountReading((HYAMNPROTOPLUGIN)wParam,MemFile,End);
-
}
-DWORD WriteStringToFile(HANDLE File,TCHAR *Source)
+DWORD WriteStringToFile(HANDLE File,char *Source)
{
DWORD Length,WrittenBytes;
- TCHAR null=(TCHAR)0;
+ char null = 0;
- if((Source==NULL) || !(Length=(DWORD)_tcslen(Source)))
+ if ((Source==NULL) || !(Length=(DWORD)strlen(Source)))
{
- if(!WriteFile(File,&null,sizeof(TCHAR),&WrittenBytes,NULL))
+ if (!WriteFile(File,&null,1,&WrittenBytes,NULL))
{
CloseHandle(File);
return EACC_SYSTEM;
}
}
- else if(!WriteFile(File,Source,(Length+1)*sizeof(TCHAR),&WrittenBytes,NULL))
+ else if (!WriteFile(File,Source,(Length+1),&WrittenBytes,NULL))
{
CloseHandle(File);
return EACC_SYSTEM;
@@ -971,25 +795,23 @@ DWORD WriteStringToFile(HANDLE File,TCHAR *Source)
return 0;
}
-#ifndef UNICODE
DWORD WriteStringToFileW(HANDLE File,WCHAR *Source)
{
DWORD Length,WrittenBytes;
WCHAR null=(WCHAR)0;
- if((Source==NULL) || !(Length=(DWORD)wcslen(Source)))
+ if ((Source==NULL) || !(Length=(DWORD)wcslen(Source)))
{
- if(!WriteFile(File,&null,sizeof(WCHAR),&WrittenBytes,NULL))
+ if (!WriteFile(File,&null,sizeof(WCHAR),&WrittenBytes,NULL))
{
CloseHandle(File);
return EACC_SYSTEM;
}
}
- else if(!WriteFile(File,Source,(Length+1)*sizeof(WCHAR),&WrittenBytes,NULL))
+ else if (!WriteFile(File,Source,(Length+1)*sizeof(WCHAR),&WrittenBytes,NULL))
return EACC_SYSTEM;
return 0;
}
-#endif
DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which)
{
@@ -999,26 +821,26 @@ DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which)
while(ActualMail!=NULL)
{
- if(Stat=WriteStringToFile(File,ActualMail->ID))
+ if (Stat=WriteStringToFile(File,ActualMail->ID))
return Stat;
- if(!WriteFile(File,(char *)&ActualMail->MailData->Size,sizeof(ActualMail->MailData->Size),&WrittenBytes,NULL) ||
+ if (!WriteFile(File,(char *)&ActualMail->MailData->Size,sizeof(ActualMail->MailData->Size),&WrittenBytes,NULL) ||
!WriteFile(File,(char *)&ActualMail->Flags,sizeof(ActualMail->Flags),&WrittenBytes,NULL) ||
!WriteFile(File,(char *)&ActualMail->Number,sizeof(ActualMail->Number),&WrittenBytes,NULL))
return EACC_SYSTEM;
- if((NULL!=Which->Plugin->MailFcn) && (NULL!=Which->Plugin->MailFcn->WriteMailOptsFcnPtr))
+ if ((NULL!=Which->Plugin->MailFcn) && (NULL!=Which->Plugin->MailFcn->WriteMailOptsFcnPtr))
Which->Plugin->MailFcn->WriteMailOptsFcnPtr(File,ActualMail); //write plugin mail options to file
for(items=ActualMail->MailData->TranslatedHeader;items!=NULL;items=items->Next)
{
- if(Stat=WriteStringToFile(File,items->name))
+ if (Stat=WriteStringToFile(File,items->name))
return Stat;
- if(Stat=WriteStringToFile(File,items->value))
+ if (Stat=WriteStringToFile(File,items->value))
return Stat;
}
- if(Stat=WriteStringToFile(File,_T("")))
+ if (Stat=WriteStringToFile(File,""))
return Stat;
ActualMail=ActualMail->Next;
}
- if(Stat=WriteStringToFile(File,_T("")))
+ if (Stat=WriteStringToFile(File,""))
return Stat;
return 0;
}
@@ -1051,7 +873,7 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait\n");
#endif
EnterCode=WaitToReadFcn(ActualAccount->AccountAccessSO);
- if(EnterCode==WAIT_FINISH) //account is about to delete
+ if (EnterCode==WAIT_FINISH) //account is about to delete
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait failed\n");
@@ -1059,12 +881,12 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
ActualAccount=ActualAccount->Next;
continue;
}
- if(EnterCode==WAIT_FAILED) //account is deleted
+ if (EnterCode==WAIT_FAILED) //account is deleted
break;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read enter\n");
#endif
- if((ActualAccount->Name==NULL) || (*ActualAccount->Name==(TCHAR)0))
+ if ((ActualAccount->Name==NULL) || (*ActualAccount->Name==(TCHAR)0))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
@@ -1073,72 +895,72 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
continue;
}
- if(!Writed && !WriteFile(File,&Ver,sizeof(Ver),&WrittenBytes,NULL))
+ if (!Writed && !WriteFile(File,&Ver,sizeof(Ver),&WrittenBytes,NULL))
throw (DWORD)EACC_SYSTEM;
Writed=TRUE;
- if(Stat=WriteStringToFile(File,ActualAccount->Name))
+ if (Stat=WriteStringToFile(File,ActualAccount->Name))
throw (DWORD)Stat;
- if(Stat=WriteStringToFile(File,ActualAccount->Server->Name))
+ if (Stat=WriteStringToFile(File,ActualAccount->Server->Name))
throw (DWORD)Stat;
- if(!WriteFile(File,(char *)&ActualAccount->Server->Port,2,&WrittenBytes,NULL))
+ if (!WriteFile(File,(char *)&ActualAccount->Server->Port,2,&WrittenBytes,NULL))
throw (DWORD)EACC_SYSTEM;
- if((Stat=WriteStringToFile(File,ActualAccount->Server->Login)))
+ if ((Stat=WriteStringToFile(File,ActualAccount->Server->Login)))
throw (DWORD)Stat;
CodeDecodeString(ActualAccount->Server->Passwd,TRUE);
- if(Stat=WriteStringToFile(File,ActualAccount->Server->Passwd))
+ if (Stat=WriteStringToFile(File,ActualAccount->Server->Passwd))
{
CodeDecodeString(ActualAccount->Server->Passwd,FALSE);
throw (DWORD)Stat;
}
CodeDecodeString(ActualAccount->Server->Passwd,FALSE);
- if((!WriteFile(File,(char *)&ActualAccount->Flags,sizeof(DWORD),&WrittenBytes,NULL) ||
+ if ((!WriteFile(File,(char *)&ActualAccount->Flags,sizeof(DWORD),&WrittenBytes,NULL) ||
(!WriteFile(File,(char *)&ActualAccount->StatusFlags,sizeof(DWORD),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->PluginFlags,sizeof(DWORD),&WrittenBytes,NULL))))
throw (DWORD)EACC_SYSTEM;
- if(!WriteFile(File,(char *)&ActualAccount->Interval,sizeof(WORD),&WrittenBytes,NULL))
+ if (!WriteFile(File,(char *)&ActualAccount->Interval,sizeof(WORD),&WrittenBytes,NULL))
throw (DWORD)EACC_SYSTEM;
- if((!WriteFile(File,(char *)&ActualAccount->NewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ if ((!WriteFile(File,(char *)&ActualAccount->NewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->NewMailN.PopUpB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->NewMailN.PopUpT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->NewMailN.PopUpTime,sizeof(DWORD),&WrittenBytes,NULL)))
throw (DWORD)EACC_SYSTEM;
- if((Stat=WriteStringToFileW(File,ActualAccount->NewMailN.App)) ||
+ if ((Stat=WriteStringToFileW(File,ActualAccount->NewMailN.App)) ||
(Stat=WriteStringToFileW(File,ActualAccount->NewMailN.AppParam)))
throw (DWORD)Stat;
- if((!WriteFile(File,(char *)&ActualAccount->NoNewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ if ((!WriteFile(File,(char *)&ActualAccount->NoNewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopUpB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopUpT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopUpTime,sizeof(DWORD),&WrittenBytes,NULL)))
throw (DWORD)EACC_SYSTEM;
- if((Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.App)) ||
+ if ((Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.App)) ||
(Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.AppParam)))
throw (DWORD)Stat;
- if((!WriteFile(File,(char *)&ActualAccount->BadConnectN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ if ((!WriteFile(File,(char *)&ActualAccount->BadConnectN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopUpB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopUpT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopUpTime,sizeof(DWORD),&WrittenBytes,NULL)))
throw (DWORD)EACC_SYSTEM;
- if((Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.App)) ||
+ if ((Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.App)) ||
(Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.AppParam)))
throw (DWORD)Stat;
//Let plugin write its own values into file
- if(ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr!=NULL)
- if(Stat=ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr(File,ActualAccount))
+ if (ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr!=NULL)
+ if (Stat=ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr(File,ActualAccount))
throw (DWORD)Stat;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read wait\n");
@@ -1147,7 +969,7 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read enter\n");
#endif
- if(Stat=WriteMessagesToFile(File,ActualAccount))
+ if (Stat=WriteMessagesToFile(File,ActualAccount))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read done\n");
@@ -1160,7 +982,7 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
#endif
ReadDoneFcn(ActualAccount->MessagesAccessSO);
- if((!WriteFile(File,(char *)&ActualAccount->LastChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
+ if ((!WriteFile(File,(char *)&ActualAccount->LastChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->LastSChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->LastSynchronised,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
(!WriteFile(File,(char *)&ActualAccount->LastMail,sizeof(SYSTEMTIME),&WrittenBytes,NULL)))
@@ -1196,13 +1018,13 @@ INT_PTR WriteAccountsToFileASvc(WPARAM wParam,LPARAM lParam)
HANDLE File;
- EnterCriticalSection(FileWritingCS);
- if(INVALID_HANDLE_VALUE==(File=CreateFileA(FileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL)))
+ EnterCriticalSection(&FileWritingCS);
+ if (INVALID_HANDLE_VALUE==(File=CreateFileA(FileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL)))
{
- LeaveCriticalSection(FileWritingCS);
+ LeaveCriticalSection(&FileWritingCS);
return EACC_SYSTEM;
}
- LeaveCriticalSection(FileWritingCS);
+ LeaveCriticalSection(&FileWritingCS);
return PerformAccountWriting(Plugin,File);
}
@@ -1216,16 +1038,16 @@ INT_PTR WriteAccountsToFileWSvc(WPARAM wParam,LPARAM lParam)
HANDLE File;
- EnterCriticalSection(FileWritingCS);
- if(INVALID_HANDLE_VALUE==(File=CreateFileW(FileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL)))
+ EnterCriticalSection(&FileWritingCS);
+ if (INVALID_HANDLE_VALUE==(File=CreateFileW(FileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL)))
{
- LeaveCriticalSection(FileWritingCS);
+ LeaveCriticalSection(&FileWritingCS);
return EACC_SYSTEM;
}
rv=PerformAccountWriting(Plugin,File);
- LeaveCriticalSection(FileWritingCS);
+ LeaveCriticalSection(&FileWritingCS);
return rv;
}
@@ -1233,7 +1055,7 @@ INT_PTR WriteAccountsToFileWSvc(WPARAM wParam,LPARAM lParam)
INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam)
{
HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
- TCHAR *SearchedAccount=(TCHAR *)lParam;
+ char *SearchedAccount=(char *)lParam;
HACCOUNT Finder;
#ifdef DEBUG_SYNCHRO
@@ -1244,7 +1066,7 @@ INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam)
DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read enter\n");
#endif
for(Finder=Plugin->FirstAccount;Finder!=NULL;Finder=Finder->Next)
- if((Finder->Name!=NULL) && (0==_tcscmp(SearchedAccount,Finder->Name)))
+ if ((Finder->Name!=NULL) && (0 == strcmp(SearchedAccount,Finder->Name)))
break;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read done\n");
@@ -1258,7 +1080,7 @@ INT_PTR GetNextFreeAccountSvc(WPARAM wParam,LPARAM lParam)
HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
HACCOUNT Finder;
- if(Plugin->FirstAccount==NULL)
+ if (Plugin->FirstAccount==NULL)
{
Plugin->FirstAccount=(HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT,wParam,lParam);
return (INT_PTR)Plugin->FirstAccount;
@@ -1274,7 +1096,7 @@ int FindPluginAccount(WPARAM wParam,LPARAM lParam)
HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
HACCOUNT Finder=(HACCOUNT)lParam;
- if(Finder=NULL) Finder=Plugin->FirstAccount;
+ if (Finder=NULL) Finder=Plugin->FirstAccount;
// for(;Finder!=NULL && Finder->PluginID!=Plugin->PluginInfo->PluginID;Finder=(HACCOUNT)Finder->Next);
return (int)Finder;
@@ -1315,7 +1137,7 @@ INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM lParam)
//1. set stop signal
StopSignalFcn(Which);
WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_STOPACCOUNT,(WPARAM)Which,(LPARAM)0);
- if(Plugin->Fcn->StopAccountFcnPtr!=NULL)
+ if (Plugin->Fcn->StopAccountFcnPtr!=NULL)
Plugin->Fcn->StopAccountFcnPtr(Which);
//2. wait to get write access
@@ -1328,7 +1150,7 @@ INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM lParam)
#endif
//3. remove from queue (chained list)
- if(Plugin->FirstAccount==NULL)
+ if (Plugin->FirstAccount==NULL)
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write done\n");
@@ -1336,7 +1158,7 @@ INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM lParam)
SWMRGDoneWriting(Plugin->AccountBrowserSO);
return 0;
}
- if(Plugin->FirstAccount==Which)
+ if (Plugin->FirstAccount==Which)
{
Finder=Plugin->FirstAccount->Next;
Plugin->FirstAccount=Finder;
@@ -1358,7 +1180,7 @@ INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM lParam)
// No, of course not. We will create new thread, that will wait and additionally remove our thread in background.
//5. So, the last point (deleting from memory) is performed in new DeleteAccountInBackground thread
- if((Plugin->Fcn!=NULL) && (Plugin->Fcn->WriteAccountsFcnPtr!=NULL))
+ if ((Plugin->Fcn!=NULL) && (Plugin->Fcn->WriteAccountsFcnPtr!=NULL))
Plugin->Fcn->WriteAccountsFcnPtr();
CloseHandle(CreateThread(NULL,0,DeleteAccountInBackground,(LPVOID)Which,0,&tid));
@@ -1392,7 +1214,7 @@ int StopAccounts(HYAMNPROTOPLUGIN Plugin)
//2. set stop signal
StopSignalFcn(Finder);
WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_STOPACCOUNT,(WPARAM)Finder,(LPARAM)0);
- if(Plugin->Fcn->StopAccountFcnPtr!=NULL)
+ if (Plugin->Fcn->StopAccountFcnPtr!=NULL)
Plugin->Fcn->StopAccountFcnPtr(Finder);
}
@@ -1410,7 +1232,7 @@ int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess)
{
HACCOUNT Finder;
- if(GetAccountBrowserAccess)
+ if (GetAccountBrowserAccess)
{
//1. wait to get write access
#ifdef DEBUG_SYNCHRO
@@ -1433,7 +1255,7 @@ int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess)
DebugLog(SynchroFile,"WaitForAllAccounts:UsingThreadEV signaled\n");
#endif
}
- if(GetAccountBrowserAccess)
+ if (GetAccountBrowserAccess)
{
//leave write access
#ifdef DEBUG_SYNCHRO
@@ -1476,15 +1298,15 @@ int DeleteAccounts(HYAMNPROTOPLUGIN Plugin)
return 1;
}
-void WINAPI GetStatusFcn(HACCOUNT Which,char *Value)
+void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value)
{
- if(Which==NULL)
+ if (Which==NULL)
return;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs wait\n");
#endif
- EnterCriticalSection(AccountStatusCS);
+ EnterCriticalSection(&AccountStatusCS);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs enter\n");
#endif
@@ -1492,19 +1314,19 @@ void WINAPI GetStatusFcn(HACCOUNT Which,char *Value)
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs done\n");
#endif
- LeaveCriticalSection(AccountStatusCS);
+ LeaveCriticalSection(&AccountStatusCS);
return;
}
-void WINAPI SetStatusFcn(HACCOUNT Which,char *Value)
+void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value)
{
- if(Which==NULL)
+ if (Which==NULL)
return;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs wait\n");
#endif
- EnterCriticalSection(AccountStatusCS);
+ EnterCriticalSection(&AccountStatusCS);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs enter\n");
#endif
@@ -1513,7 +1335,7 @@ void WINAPI SetStatusFcn(HACCOUNT Which,char *Value)
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs done\n");
#endif
- LeaveCriticalSection(AccountStatusCS);
+ LeaveCriticalSection(&AccountStatusCS);
}
/*