diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-05-11 15:43:52 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-05-11 15:43:52 +0000 |
commit | 683a19c3328e3a13916684de8827651990cf07ed (patch) | |
tree | 2336d3cd5ea080e4e4cc18f8f96f1cced16f6f9c /plugins/YAMN | |
parent | a9197f5d5921263a042979b0d14fc2c61e411320 (diff) |
minus CreateThread
git-svn-id: http://svn.miranda-ng.org/main/trunk@13544 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/YAMN')
-rw-r--r-- | plugins/YAMN/src/account.cpp | 808 | ||||
-rw-r--r-- | plugins/YAMN/src/browser/badconnect.cpp | 320 | ||||
-rw-r--r-- | plugins/YAMN/src/browser/mailbrowser.cpp | 2780 | ||||
-rw-r--r-- | plugins/YAMN/src/proto/pop3/pop3comm.cpp | 1197 | ||||
-rw-r--r-- | plugins/YAMN/src/yamn.h | 136 |
5 files changed, 2633 insertions, 2608 deletions
diff --git a/plugins/YAMN/src/account.cpp b/plugins/YAMN/src/account.cpp index 612ac7181a..f438bbf655 100644 --- a/plugins/YAMN/src/account.cpp +++ b/plugins/YAMN/src/account.cpp @@ -17,33 +17,33 @@ CRITICAL_SECTION AccountStatusCS; //When 2 threads want to write to file... CRITICAL_SECTION FileWritingCS; -struct CExportedFunctions AccountExportedFcn[]= +struct CExportedFunctions AccountExportedFcn[] = { - {YAMN_GETSTATUSID,(void *)GetStatusFcn}, - {YAMN_SETSTATUSID,(void *)SetStatusFcn}, + { YAMN_GETSTATUSID, (void *)GetStatusFcn }, + { YAMN_SETSTATUSID, (void *)SetStatusFcn }, }; -struct CExportedServices AccountExportedSvc[]= +struct CExportedServices AccountExportedSvc[] = { - {MS_YAMN_CREATEPLUGINACCOUNT,CreatePluginAccountSvc}, - {MS_YAMN_DELETEPLUGINACCOUNT,DeletePluginAccountSvc}, - {MS_YAMN_FINDACCOUNTBYNAME,FindAccountByNameSvc}, - {MS_YAMN_GETNEXTFREEACCOUNT,GetNextFreeAccountSvc}, - {MS_YAMN_DELETEACCOUNT,DeletePluginAccountSvc}, - {MS_YAMN_READACCOUNTS,AddAccountsFromFileSvc}, - {MS_YAMN_WRITEACCOUNTS,WriteAccountsToFileSvc}, + { MS_YAMN_CREATEPLUGINACCOUNT, CreatePluginAccountSvc }, + { MS_YAMN_DELETEPLUGINACCOUNT, DeletePluginAccountSvc }, + { MS_YAMN_FINDACCOUNTBYNAME, FindAccountByNameSvc }, + { MS_YAMN_GETNEXTFREEACCOUNT, GetNextFreeAccountSvc }, + { MS_YAMN_DELETEACCOUNT, DeletePluginAccountSvc }, + { MS_YAMN_READACCOUNTS, AddAccountsFromFileSvc }, + { MS_YAMN_WRITEACCOUNTS, WriteAccountsToFileSvc }, }; //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- -INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam) +INT_PTR CreatePluginAccountSvc(WPARAM wParam, LPARAM lParam) { - HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam; - DWORD AccountVersion=(DWORD)lParam; + HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam; + DWORD AccountVersion = (DWORD)lParam; HACCOUNT NewAccount; -//test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match) + //test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match) if (AccountVersion != YAMN_ACCOUNTVERSION) return NULL; @@ -51,20 +51,20 @@ INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam) { 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); - NewAccount->Plugin=Plugin; + //Let plugin create its own structure, which can be derived from CAccount structure + NewAccount = Plugin->Fcn->NewAccountFcnPtr(Plugin, YAMN_ACCOUNTVERSION); + NewAccount->Plugin = Plugin; } else { -//We suggest plugin uses standard CAccount structure, so we create it - NewAccount=new struct CAccount; - NewAccount->Plugin=Plugin; + //We suggest plugin uses standard CAccount structure, so we create it + NewAccount = new struct CAccount; + NewAccount->Plugin = Plugin; } -//If not created successfully - if (NewAccount==NULL) + //If not created successfully + if (NewAccount == NULL) return NULL; -//Init every members of structure, used by YAMN + //Init every members of structure, used by YAMN InitAccount(NewAccount); return (INT_PTR)NewAccount; @@ -72,17 +72,17 @@ INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam) return NULL; } -INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM) +INT_PTR DeletePluginAccountSvc(WPARAM wParam, LPARAM) { - HACCOUNT OldAccount=(HACCOUNT)wParam; + HACCOUNT OldAccount = (HACCOUNT)wParam; if (OldAccount->Plugin->Fcn != NULL) { -//Deinit every members and allocated fields of structure used by YAMN + //Deinit every members and allocated fields of structure used by YAMN DeInitAccount(OldAccount); if (OldAccount->Plugin->Fcn->DeleteAccountFcnPtr != NULL) { -//Let plugin delete its own CAccount derived structure + //Let plugin delete its own CAccount derived structure OldAccount->Plugin->Fcn->DeleteAccountFcnPtr(OldAccount); } else @@ -100,36 +100,36 @@ INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM) int InitAccount(HACCOUNT Which) { -//initialize synchronizing objects - Which->AccountAccessSO=new SWMRG; - SWMRGInitialize(Which->AccountAccessSO,NULL); - Which->MessagesAccessSO=new SWMRG; - SWMRGInitialize(Which->MessagesAccessSO,NULL); - Which->UsingThreads=new SCOUNTER; - SWMRGInitialize(Which->MessagesAccessSO,NULL); - -//zero memory, where timestamps are stored + //initialize synchronizing objects + Which->AccountAccessSO = new SWMRG; + SWMRGInitialize(Which->AccountAccessSO, NULL); + Which->MessagesAccessSO = new SWMRG; + SWMRGInitialize(Which->MessagesAccessSO, NULL); + Which->UsingThreads = new SCOUNTER; + SWMRGInitialize(Which->MessagesAccessSO, NULL); + + //zero memory, where timestamps are stored memset(&Which->LastChecked, 0, sizeof(Which->LastChecked)); memset(&Which->LastSChecked, 0, sizeof(Which->LastSChecked)); memset(&Which->LastSynchronised, 0, sizeof(Which->LastSynchronised)); memset(&Which->LastMail, 0, sizeof(Which->LastMail)); - Which->Name=NULL; - Which->Mails=NULL; - Which->Interval=0; - Which->Flags=0; - Which->StatusFlags=0; - Which->Next=NULL; + Which->Name = NULL; + Which->Mails = NULL; + Which->Interval = 0; + Which->Flags = 0; + Which->StatusFlags = 0; + Which->Next = NULL; - Which->Server=new struct CServer; - Which->AbleToWork=TRUE; + Which->Server = new struct CServer; + Which->AbleToWork = TRUE; return 1; } void DeInitAccount(HACCOUNT Which) { -//delete YAMN allocated fields + //delete YAMN allocated fields if (Which->Name != NULL) delete[] Which->Name; if (Which->Server != NULL) { @@ -147,7 +147,7 @@ void DeInitAccount(HACCOUNT Which) SWMRGDelete(Which->MessagesAccessSO); delete Which->MessagesAccessSO; delete Which->UsingThreads; - DeleteMessagesToEndFcn(Which,(HYAMNMAIL)Which->Mails); + DeleteMessagesToEndFcn(Which, (HYAMNMAIL)Which->Mails); } void StopSignalFcn(HACCOUNT Which) @@ -156,50 +156,50 @@ void StopSignalFcn(HACCOUNT Which) #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"\tStopSignalFcn:stop account: %x\n",Which); #endif - Which->AbleToWork=FALSE; -//do not use synchronizing objects anymore -//any access to these objects then ends with WAIT_FAILED + Which->AbleToWork = FALSE; + //do not use synchronizing objects anymore + //any access to these objects then ends with WAIT_FAILED SetEvent(Which->AccountAccessSO->hFinishEV); SetEvent(Which->MessagesAccessSO->hFinishEV); } -void CodeDecodeString(char *Dest,BOOL Encrypt) +void CodeDecodeString(char *Dest, BOOL Encrypt) { - TCHAR Code=STARTCODEPSW; + TCHAR Code = STARTCODEPSW; - if (Dest==NULL) + if (Dest == NULL) return; - for (;*Dest != (TCHAR)0;Dest++) + for (; *Dest != (TCHAR)0; Dest++) { if (Encrypt) - *Dest=*Dest+Code; + *Dest = *Dest + Code; else - *Dest=*Dest-Code; - Code+=(TCHAR)ADDCODEPSW; + *Dest = *Dest - Code; + Code += (TCHAR)ADDCODEPSW; } } -static DWORD PostFileToMemory(HANDLE File,char **MemFile,char **End) +static DWORD PostFileToMemory(HANDLE File, char **MemFile, char **End) { - DWORD FileSize,ReadBytes; - if (!(FileSize=GetFileSize(File,NULL))) { + DWORD FileSize, ReadBytes; + if (!(FileSize = GetFileSize(File, NULL))) { CloseHandle(File); return EACC_FILESIZE; } //allocate space in memory, where we copy the whole file - if (NULL==(*MemFile = new char[FileSize])) + if (NULL == (*MemFile = new char[FileSize])) { CloseHandle(File); return EACC_ALLOC; } //copy file to memory - if (!ReadFile(File,(LPVOID)*MemFile,FileSize,&ReadBytes,NULL)) + if (!ReadFile(File, (LPVOID)*MemFile, FileSize, &ReadBytes, NULL)) { CloseHandle(File); - delete[] *MemFile; + delete[] * MemFile; return EACC_SYSTEM; } CloseHandle(File); @@ -207,7 +207,7 @@ static DWORD PostFileToMemory(HANDLE File,char **MemFile,char **End) return 0; } -DWORD FileToMemory(TCHAR *FileName,char **MemFile,char **End) +DWORD FileToMemory(TCHAR *FileName, char **MemFile, char **End) { HANDLE hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) @@ -219,8 +219,8 @@ DWORD FileToMemory(TCHAR *FileName,char **MemFile,char **End) #if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES) 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 + //This is the debug version of ReadStringFromMemory function. This version shows MessageBox where + //read string is displayed TCHAR *Dest,*Finder; DWORD Size; TCHAR Debug[65536]; @@ -247,35 +247,35 @@ DWORD ReadStringFromMemory(char **Parser,TCHAR *End,char **StoreTo,TCHAR *DebugS } #endif -DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo) +DWORD ReadStringFromMemory(char **Parser, char *End, char **StoreTo) { - char *Dest,*Finder; + char *Dest, *Finder; DWORD Size; - Finder=*Parser; - while((*Finder != (TCHAR)0) && (Finder<=End)) Finder++; - if (Finder>=End) + Finder = *Parser; + while ((*Finder != (TCHAR)0) && (Finder <= End)) Finder++; + if (Finder >= End) return EACC_FILECOMPATIBILITY; - if (Size=Finder-*Parser) + if (Size = Finder - *Parser) { - if (NULL==(Dest=*StoreTo=new char[Size+1])) + if (NULL == (Dest = *StoreTo = new char[Size + 1])) return EACC_ALLOC; - for (;*Parser<=Finder;(*Parser)++,Dest++) - *Dest=**Parser; + for (; *Parser <= Finder; (*Parser)++, Dest++) + *Dest = **Parser; } else { - *StoreTo=NULL; + *StoreTo = NULL; (*Parser)++; } return 0; } - #if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES) +#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES) DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *DebugString) { -//This is the debug version of ReadStringFromMemoryW function. This version shows MessageBox where -//read string is displayed + //This is the debug version of ReadStringFromMemoryW function. This version shows MessageBox where + //read string is displayed WCHAR *Dest,*Finder; DWORD Size; WCHAR Debug[65536]; @@ -300,67 +300,67 @@ DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *Deb } return 0; } - #endif //if defined(DEBUG...) +#endif //if defined(DEBUG...) -DWORD ReadStringFromMemoryW(WCHAR **Parser,WCHAR *End,WCHAR **StoreTo) +DWORD ReadStringFromMemoryW(WCHAR **Parser, WCHAR *End, WCHAR **StoreTo) { - WCHAR *Dest,*Finder; + WCHAR *Dest, *Finder; DWORD Size; - Finder=*Parser; - while((*Finder != (WCHAR)0) && (Finder<=(WCHAR *)End)) Finder++; - if (Finder>=(WCHAR *)End) + Finder = *Parser; + while ((*Finder != (WCHAR)0) && (Finder <= (WCHAR *)End)) Finder++; + 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; + for (; *Parser <= Finder; (*Parser)++, Dest++) + *Dest = **Parser; } else { - *StoreTo=NULL; + *StoreTo = NULL; (*Parser)++; } return 0; } -static DWORD ReadNotificationFromMemory(char **Parser,char *End,YAMN_NOTIFICATION *Which) +static DWORD ReadNotificationFromMemory(char **Parser, char *End, YAMN_NOTIFICATION *Which) { DWORD Stat; #ifdef DEBUG_FILEREAD TCHAR Debug[65536]; #endif - Which->Flags=*(DWORD *)(*Parser); - (*Parser)+=sizeof(DWORD); - if (*Parser>=End) + Which->Flags = *(DWORD *)(*Parser); + (*Parser) += sizeof(DWORD); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD mir_sntprintf(Debug, SIZEOF(Debug), _T("NFlags: %04x, remaining %d chars"), Which->Flags, End-*Parser); MessageBox(NULL,Debug,_T("debug"),MB_OK); #endif - Which->PopupB=*(COLORREF *)(*Parser); - (*Parser)+=sizeof(COLORREF); - if (*Parser>=End) + Which->PopupB = *(COLORREF *)(*Parser); + (*Parser) += sizeof(COLORREF); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD mir_sntprintf(Debug, SIZEOF(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); - if (*Parser>=End) + Which->PopupT = *(COLORREF *)(*Parser); + (*Parser) += sizeof(COLORREF); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD mir_sntprintf(Debug, SIZEOF(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); - if (*Parser>=End) + Which->PopupTime = *(DWORD *)(*Parser); + (*Parser) += sizeof(DWORD); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; #ifdef DEBUG_FILEREAD mir_sntprintf(Debug, SIZEOF(Debug), _T("PopupTime: %04x, remaining %d chars"), Which->PopupTime, End-*Parser); @@ -370,23 +370,23 @@ static DWORD ReadNotificationFromMemory(char **Parser,char *End,YAMN_NOTIFICATIO #ifdef DEBUG_FILEREAD if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->App,L"App")) #else - if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->App)) + if (Stat = ReadStringFromMemoryW((WCHAR **)Parser, (WCHAR*)End, &Which->App)) #endif return Stat; #ifdef DEBUG_FILEREAD if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->AppParam,L"AppParam")) #else - if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->AppParam)) + if (Stat = ReadStringFromMemoryW((WCHAR **)Parser, (WCHAR*)End, &Which->AppParam)) #endif return Stat; return 0; } -DWORD ReadMessagesFromMemory(HACCOUNT Which,char **Parser,char *End) +DWORD ReadMessagesFromMemory(HACCOUNT Which, char **Parser, char *End) { char *Finder; - DWORD Size,Stat; - HYAMNMAIL ActualMail=NULL; + DWORD Size, Stat; + HYAMNMAIL ActualMail = NULL; struct CMimeItem *items; char *ReadString; @@ -395,96 +395,96 @@ DWORD ReadMessagesFromMemory(HACCOUNT Which,char **Parser,char *End) #endif do { - Finder=*Parser; - while((*Finder != (TCHAR)0) && (Finder<=End)) Finder++; - if (Finder>=End) + Finder = *Parser; + while ((*Finder != (TCHAR)0) && (Finder <= End)) Finder++; + 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; + ActualMail = ActualMail->Next; } - items=NULL; + items = NULL; #ifdef DEBUG_FILEREADMESSAGES 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=new MAILDATA; !!! mem leake !!! this is alloc by CreateAccountMail, no need for doubble alloc !!!! - ActualMail->MailData->Size=*(DWORD *)(*Parser); - (*Parser)+=sizeof(DWORD); - if (*Parser>=End) + ActualMail->MailData->Size = *(DWORD *)(*Parser); + (*Parser) += sizeof(DWORD); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; - ActualMail->Flags=*(DWORD *)(*Parser); - (*Parser)+=sizeof(DWORD); - if (*Parser>=End) + ActualMail->Flags = *(DWORD *)(*Parser); + (*Parser) += sizeof(DWORD); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; - ActualMail->Number=*(DWORD *)(*Parser); - (*Parser)+=sizeof(DWORD); - if (*Parser>=End) + ActualMail->Number = *(DWORD *)(*Parser); + (*Parser) += sizeof(DWORD); + if (*Parser >= End) return EACC_FILECOMPATIBILITY; if ((NULL != Which->Plugin->MailFcn) && (NULL != Which->Plugin->MailFcn->ReadMailOptsFcnPtr)) - Which->Plugin->MailFcn->ReadMailOptsFcnPtr(ActualMail,Parser,End); //read plugin mail settings from file + Which->Plugin->MailFcn->ReadMailOptsFcnPtr(ActualMail, Parser, End); //read plugin mail settings from file do { #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) - items=ActualMail->MailData->TranslatedHeader=new struct CMimeItem; + if (items == NULL) + items = ActualMail->MailData->TranslatedHeader = new struct CMimeItem; else { - items->Next=new struct CMimeItem; - items=items->Next; + items->Next = new struct CMimeItem; + items = items->Next; } - if (items==NULL) + if (items == NULL) return EACC_ALLOC; - items->name=ReadString; + items->name = ReadString; #ifdef DEBUG_FILEREADMESSAGES 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; + items->value = ReadString; #ifdef DEBUG_DECODE DebugLog(DecodeFile,"<read value>%s</read value>\n",ReadString); #endif - }while(1); + } while (1); } else break; //no next messages, new account! - }while(1); + } while (1); (*Parser)++; return 0; } -DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End) +DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, char *End) { DWORD Stat; #ifdef DEBUG_FILEREAD @@ -495,22 +495,22 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End) #ifdef DEBUG_FILEREAD 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 #ifdef DEBUG_FILEREAD 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); - if (*Parser>=End) + 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); @@ -519,44 +519,44 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End) #ifdef DEBUG_FILEREAD 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"))) #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); + CodeDecodeString(Which->Server->Passwd, FALSE); //Read account flags - Which->Flags=*(DWORD *)(*Parser); - (*Parser)+=sizeof(DWORD); - if (*Parser>=End) + 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); + 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); + 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) + 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); @@ -564,16 +564,16 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End) #endif //Read notification parameters - if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NewMailN)) + 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)) + if (Stat = Which->Plugin->Fcn->ReadPluginOptsFcnPtr(Which, Parser, End)) return Stat; //Read mails #ifdef DEBUG_SYNCHRO @@ -583,7 +583,7 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *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"); @@ -597,68 +597,68 @@ DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End) WriteDoneFcn(Which->MessagesAccessSO); //Read timestamps - Which->LastChecked=*(SYSTEMTIME *)(*Parser); - (*Parser)+=sizeof(SYSTEMTIME); - if (*Parser>=End) + 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) + 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) + 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 + 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) + if (*Parser == End) return EACC_ENDOFFILE; return 0; } -static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char *End) +static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin, char *MemFile, char *End) { //Retrieve info for account from memory char *Parser; - DWORD Ver,Stat; + DWORD Ver, Stat; - HACCOUNT ActualAccount,FirstAllocatedAccount; + HACCOUNT ActualAccount, FirstAllocatedAccount; - Ver=*(DWORD *)MemFile; - if (Ver>YAMN_ACCOUNTFILEVERSION) + Ver = *(DWORD *)MemFile; + if (Ver > YAMN_ACCOUNTFILEVERSION) { delete[] MemFile; return EACC_FILEVERSION; } - Parser=MemFile+sizeof(Ver); + Parser = MemFile + sizeof(Ver); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write wait\n"); #endif - SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE); + 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))) + if (NULL == (ActualAccount = (HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT, (WPARAM)Plugin, (LPARAM)YAMN_ACCOUNTVERSION))) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n"); @@ -667,7 +667,7 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char delete[] MemFile; return EACC_ALLOC; } - FirstAllocatedAccount=ActualAccount; + FirstAllocatedAccount = ActualAccount; do { @@ -680,21 +680,21 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write enter\n"); #endif - Stat=ReadAccountFromMemory(ActualAccount,&Parser,End); + Stat = ReadAccountFromMemory(ActualAccount, &Parser, End); if (ActualAccount->StatusFlags & (YAMN_ACC_STARTA | YAMN_ACC_STARTS)) - ActualAccount->TimeLeft=1; //check on loading + ActualAccount->TimeLeft = 1; //check on loading if (Stat && (Stat != EACC_ENDOFFILE)) { - for (ActualAccount=FirstAllocatedAccount;ActualAccount != NULL;ActualAccount=Temp) + for (ActualAccount = FirstAllocatedAccount; ActualAccount != NULL; ActualAccount = Temp) { - Temp=ActualAccount->Next; + Temp = ActualAccount->Next; delete ActualAccount; } delete[] MemFile; - if (Plugin->FirstAccount==FirstAllocatedAccount) - Plugin->FirstAccount=NULL; + if (Plugin->FirstAccount == FirstAllocatedAccount) + Plugin->FirstAccount = NULL; #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write done\n"); #endif @@ -707,23 +707,23 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char #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) + for (ActualAccount = FirstAllocatedAccount; ActualAccount != NULL; ActualAccount = Temp) { - Temp=ActualAccount->Next; + Temp = ActualAccount->Next; delete ActualAccount; } delete[] MemFile; - if (Plugin->FirstAccount==FirstAllocatedAccount) - Plugin->FirstAccount=NULL; + 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); + } while (Stat != EACC_ENDOFFILE); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n"); @@ -735,121 +735,121 @@ static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char } // Add accounts from file to memory -INT_PTR AddAccountsFromFileSvc(WPARAM wParam,LPARAM lParam) +INT_PTR AddAccountsFromFileSvc(WPARAM wParam, LPARAM lParam) { - char *MemFile,*End; - DWORD Stat = FileToMemory(( TCHAR* )lParam, &MemFile, &End); - if ( Stat != NO_ERROR ) + char *MemFile, *End; + DWORD Stat = FileToMemory((TCHAR*)lParam, &MemFile, &End); + if (Stat != NO_ERROR) return (INT_PTR)Stat; - return PerformAccountReading((HYAMNPROTOPLUGIN)wParam,MemFile,End); + return PerformAccountReading((HYAMNPROTOPLUGIN)wParam, MemFile, End); } -DWORD WriteStringToFile(HANDLE File,char *Source) +DWORD WriteStringToFile(HANDLE File, char *Source) { - DWORD Length,WrittenBytes; + DWORD Length, WrittenBytes; char null = 0; - if ((Source==NULL) || !(Length=(DWORD)strlen(Source))) { - if (!WriteFile(File,&null,1,&WrittenBytes,NULL)) { + if ((Source == NULL) || !(Length = (DWORD)strlen(Source))) { + if (!WriteFile(File, &null, 1, &WrittenBytes, NULL)) { CloseHandle(File); return EACC_SYSTEM; } } - else if (!WriteFile(File,Source,(Length+1),&WrittenBytes,NULL)) { + else if (!WriteFile(File, Source, (Length + 1), &WrittenBytes, NULL)) { CloseHandle(File); return EACC_SYSTEM; } return 0; } -DWORD WriteStringToFileW(HANDLE File,WCHAR *Source) +DWORD WriteStringToFileW(HANDLE File, WCHAR *Source) { - DWORD Length,WrittenBytes; - WCHAR null=(WCHAR)0; + 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; } -DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which) +DWORD WriteMessagesToFile(HANDLE File, HACCOUNT Which) { - DWORD WrittenBytes,Stat; - HYAMNMAIL ActualMail=(HYAMNMAIL)Which->Mails; + DWORD WrittenBytes, Stat; + HYAMNMAIL ActualMail = (HYAMNMAIL)Which->Mails; struct CMimeItem *items; - while(ActualMail != NULL) + 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) || - !WriteFile(File,(char *)&ActualMail->Flags,sizeof(ActualMail->Flags),&WrittenBytes,NULL) || - !WriteFile(File,(char *)&ActualMail->Number,sizeof(ActualMail->Number),&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)) - Which->Plugin->MailFcn->WriteMailOptsFcnPtr(File,ActualMail); //write plugin mail options to file - for (items=ActualMail->MailData->TranslatedHeader;items != NULL;items=items->Next) + 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,"")) + } + if (Stat = WriteStringToFile(File, "")) return Stat; - ActualMail=ActualMail->Next; + ActualMail = ActualMail->Next; } - if (Stat=WriteStringToFile(File,"")) + if (Stat = WriteStringToFile(File, "")) return Stat; return 0; } -static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File) +static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin, HANDLE File) { - DWORD WrittenBytes,Stat; + DWORD WrittenBytes, Stat; HACCOUNT ActualAccount; - DWORD Ver=YAMN_ACCOUNTFILEVERSION; - BOOL Writed=FALSE; - DWORD ReturnValue=0,EnterCode; - + DWORD Ver = YAMN_ACCOUNTFILEVERSION; + BOOL Writed = FALSE; + DWORD ReturnValue = 0, EnterCode; + #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read wait\n"); #endif - SWMRGWaitToRead(Plugin->AccountBrowserSO,INFINITE); + SWMRGWaitToRead(Plugin->AccountBrowserSO, INFINITE); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read enter\n"); #endif try { - for (ActualAccount=Plugin->FirstAccount;ActualAccount != NULL;ActualAccount=ActualAccount->Next) + for (ActualAccount = Plugin->FirstAccount; ActualAccount != NULL; ActualAccount = ActualAccount->Next) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait\n"); #endif - EnterCode=WaitToReadFcn(ActualAccount->AccountAccessSO); - if (EnterCode==WAIT_FINISH) //account is about to delete + EnterCode = WaitToReadFcn(ActualAccount->AccountAccessSO); + if (EnterCode == WAIT_FINISH) //account is about to delete { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait failed\n"); #endif - ActualAccount=ActualAccount->Next; + 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"); @@ -858,72 +858,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; + 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); + CodeDecodeString(ActualAccount->Server->Passwd, TRUE); - if (Stat=WriteStringToFile(File,ActualAccount->Server->Passwd)) + if (Stat = WriteStringToFile(File, ActualAccount->Server->Passwd)) { - CodeDecodeString(ActualAccount->Server->Passwd,FALSE); + CodeDecodeString(ActualAccount->Server->Passwd, FALSE); throw (DWORD)Stat; } - CodeDecodeString(ActualAccount->Server->Passwd,FALSE); + CodeDecodeString(ActualAccount->Server->Passwd, FALSE); - 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)))) + 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)) || - (!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))) + 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)) || - (Stat=WriteStringToFileW(File,ActualAccount->NewMailN.AppParam))) + 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)) || - (!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))) + 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)) || - (Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.AppParam))) + 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)) || - (!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))) + 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)) || - (Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.AppParam))) + if ((Stat = WriteStringToFileW(File, ActualAccount->BadConnectN.App)) || + (Stat = WriteStringToFileW(File, ActualAccount->BadConnectN.AppParam))) throw (DWORD)Stat; -//Let plugin write its own values into file + //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 (Stat = ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr(File, ActualAccount)) throw (DWORD)Stat; #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read wait\n"); @@ -932,7 +932,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"); @@ -945,10 +945,10 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File) #endif ReadDoneFcn(ActualAccount->MessagesAccessSO); - 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))) + 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))) throw (DWORD)Stat; #ifdef DEBUG_SYNCHRO @@ -957,13 +957,13 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File) ReadDoneFcn(ActualAccount->AccountAccessSO); } } - catch(DWORD ErrorCode) + catch (DWORD ErrorCode) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n"); #endif ReadDoneFcn(ActualAccount->AccountAccessSO); - ReturnValue=ErrorCode; + ReturnValue = ErrorCode; } #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read done\n"); @@ -974,14 +974,14 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File) } //Writes accounts to file -INT_PTR WriteAccountsToFileSvc(WPARAM wParam,LPARAM lParam) +INT_PTR WriteAccountsToFileSvc(WPARAM wParam, LPARAM lParam) { - HYAMNPROTOPLUGIN Plugin = ( HYAMNPROTOPLUGIN )wParam; - TCHAR* tszFileName = ( TCHAR* )lParam; + HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam; + TCHAR* tszFileName = (TCHAR*)lParam; - EnterCriticalSection( &FileWritingCS ); - HANDLE hFile = CreateFile(tszFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); - if ( hFile == INVALID_HANDLE_VALUE ) { + EnterCriticalSection(&FileWritingCS); + HANDLE hFile = CreateFile(tszFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { LeaveCriticalSection(&FileWritingCS); return EACC_SYSTEM; } @@ -992,105 +992,104 @@ INT_PTR WriteAccountsToFileSvc(WPARAM wParam,LPARAM lParam) return rv; } -INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam) +INT_PTR FindAccountByNameSvc(WPARAM wParam, LPARAM lParam) { - HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam; - char *SearchedAccount=(char *)lParam; + HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam; + char *SearchedAccount = (char *)lParam; HACCOUNT Finder; #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read wait\n"); #endif - SWMRGWaitToRead(Plugin->AccountBrowserSO,INFINITE); + SWMRGWaitToRead(Plugin->AccountBrowserSO, INFINITE); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read enter\n"); #endif - for (Finder=Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next) - if ((Finder->Name != NULL) && (0 == strcmp(SearchedAccount,Finder->Name))) + for (Finder = Plugin->FirstAccount; Finder != NULL; Finder = Finder->Next) + if ((Finder->Name != NULL) && (0 == strcmp(SearchedAccount, Finder->Name))) break; #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read done\n"); #endif SWMRGDoneReading(Plugin->AccountBrowserSO); - return (INT_PTR)Finder; + return (INT_PTR)Finder; } -INT_PTR GetNextFreeAccountSvc(WPARAM wParam,LPARAM lParam) +INT_PTR GetNextFreeAccountSvc(WPARAM wParam, LPARAM lParam) { - HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam; + HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam; HACCOUNT Finder; - if (Plugin->FirstAccount==NULL) + if (Plugin->FirstAccount == NULL) { - Plugin->FirstAccount=(HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT,wParam,lParam); + Plugin->FirstAccount = (HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT, wParam, lParam); return (INT_PTR)Plugin->FirstAccount; } - for (Finder=Plugin->FirstAccount;Finder->Next != NULL;Finder=Finder->Next); - Finder->Next=(HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT,wParam,lParam); + for (Finder = Plugin->FirstAccount; Finder->Next != NULL; Finder = Finder->Next); + Finder->Next = (HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT, wParam, lParam); return (INT_PTR)Finder->Next; } /* int FindPluginAccount(WPARAM wParam,LPARAM lParam) { - HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam; - HACCOUNT Finder=(HACCOUNT)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; +return (int)Finder; } */ -INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM lParam) +INT_PTR DeleteAccountSvc(WPARAM wParam, LPARAM lParam) { -//Deleting account works on these steps: -//1. set signal that account should stop activity (set event) -// setting this event we achieve, that any access to account is failed, -// so threads do not start any work with accounts (better saying threads of plugins should not start) -//2. wait to get write access to chained list of accounts -//3. we can write to chained list, so we change chain not to show to actual account -// now, any thread browsing list of accounts does not browse through actual account -// actual account seems to be hidden (it exists, but it is not in accounts chained list (chained list=queue)) -//Now, we should delete account from memory, BUT!!! -// Any thread can still be waked up and start asking account synchronizing object -// If account is deleted, asking about access to read account can throw memory exception (reading for -// a synchronizing object from memory, that was deleted) -//So, we cannot now delete account. We have to wait until we are sure no thread will be using account anymore -// (or to the end of Miranda, but problem is in allocated memory- it is allocated and Miranda is SMALLER, faster, easier, isn't it?) -// This deleting is achieved in 2 ways: -// We have event in UsingThreads synchronization objects. This event signals that no thread will use actual account -// 1. Any thread using account first increment UsingThread, so we know that account is used -// 2. If thread is about to close, it should decrement UsingThread -// 3. If thread creates another thread, that will use account, caller has to wait until the new thread does not -// increment UsingThreads (imagine that caller ends before the new thread set it: if no other thread is using -// account, account is automaticaly (decreasing UsingThreads) signaled as "not used" and we delete it. But then -// new thread is going to read account...). -//4. wait until UsingThread Event is signaled -//5. delete account from memory - - HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam; - HACCOUNT Which=(HACCOUNT)lParam; + //Deleting account works on these steps: + //1. set signal that account should stop activity (set event) + // setting this event we achieve, that any access to account is failed, + // so threads do not start any work with accounts (better saying threads of plugins should not start) + //2. wait to get write access to chained list of accounts + //3. we can write to chained list, so we change chain not to show to actual account + // now, any thread browsing list of accounts does not browse through actual account + // actual account seems to be hidden (it exists, but it is not in accounts chained list (chained list=queue)) + //Now, we should delete account from memory, BUT!!! + // Any thread can still be waked up and start asking account synchronizing object + // If account is deleted, asking about access to read account can throw memory exception (reading for + // a synchronizing object from memory, that was deleted) + //So, we cannot now delete account. We have to wait until we are sure no thread will be using account anymore + // (or to the end of Miranda, but problem is in allocated memory- it is allocated and Miranda is SMALLER, faster, easier, isn't it?) + // This deleting is achieved in 2 ways: + // We have event in UsingThreads synchronization objects. This event signals that no thread will use actual account + // 1. Any thread using account first increment UsingThread, so we know that account is used + // 2. If thread is about to close, it should decrement UsingThread + // 3. If thread creates another thread, that will use account, caller has to wait until the new thread does not + // increment UsingThreads (imagine that caller ends before the new thread set it: if no other thread is using + // account, account is automaticaly (decreasing UsingThreads) signaled as "not used" and we delete it. But then + // new thread is going to read account...). + //4. wait until UsingThread Event is signaled + //5. delete account from memory + + HYAMNPROTOPLUGIN Plugin = (HYAMNPROTOPLUGIN)wParam; + HACCOUNT Which = (HACCOUNT)lParam; HACCOUNT Finder; - DWORD tid; -//1. set stop signal + //1. set stop signal StopSignalFcn(Which); - WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_STOPACCOUNT,(WPARAM)Which,0); + WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_STOPACCOUNT, (WPARAM)Which, 0); if (Plugin->Fcn->StopAccountFcnPtr != NULL) Plugin->Fcn->StopAccountFcnPtr(Which); -//2. wait to get write access + //2. wait to get write access #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write wait\n"); #endif - SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE); + SWMRGWaitToWrite(Plugin->AccountBrowserSO, INFINITE); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write enter\n"); #endif -//3. remove from queue (chained list) - if (Plugin->FirstAccount==NULL) + //3. remove from queue (chained list) + if (Plugin->FirstAccount == NULL) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write done\n"); @@ -1098,98 +1097,97 @@ 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; + Finder = Plugin->FirstAccount->Next; + Plugin->FirstAccount = Finder; } else { - for (Finder=Plugin->FirstAccount;Which != Finder->Next;Finder=Finder->Next); - Finder->Next=Finder->Next->Next; + for (Finder = Plugin->FirstAccount; Which != Finder->Next; Finder = Finder->Next); + Finder->Next = Finder->Next->Next; } -//leave write access + //leave write access #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write done\n"); #endif SWMRGDoneWriting(Plugin->AccountBrowserSO); -//4. wait while event "UsingThread" is not signaled -// And what to do, if this event will be signaled in 1 hour? (Although it's paranoia, because we have sent "delete signal", so -// other threads do not start any new work with actual account) We will wait in blocked state? -// 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 + //4. wait while event "UsingThread" is not signaled + // And what to do, if this event will be signaled in 1 hour? (Although it's paranoia, because we have sent "delete signal", so + // other threads do not start any new work with actual account) We will wait in blocked state? + // 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)) - Plugin->Fcn->WriteAccountsFcnPtr(); - CloseHandle(CreateThread(NULL,0,DeleteAccountInBackground,(LPVOID)Which,0,&tid)); + Plugin->Fcn->WriteAccountsFcnPtr(); + CloseHandle(mir_forkthread(DeleteAccountInBackground, (void*)Which)); -//Now, plugin can consider account as deleted, but plugin really can achieve deleting this account from memory when using -//event UsingThreads. + //Now, plugin can consider account as deleted, but plugin really can achieve deleting this account from memory when using + //event UsingThreads. return 1; } -DWORD WINAPI DeleteAccountInBackground(LPVOID Value) +void __cdecl DeleteAccountInBackground(void *Value) { - HACCOUNT Which=(HACCOUNT)Value; - WaitForSingleObject(Which->UsingThreads->Event,INFINITE); - CallService(MS_YAMN_DELETEPLUGINACCOUNT,(WPARAM)Which,0); - return 0; + HACCOUNT Which = (HACCOUNT)Value; + WaitForSingleObject(Which->UsingThreads->Event, INFINITE); + CallService(MS_YAMN_DELETEPLUGINACCOUNT, (WPARAM)Which, 0); } int StopAccounts(HYAMNPROTOPLUGIN Plugin) { HACCOUNT Finder; -//1. wait to get write access + //1. wait to get write access #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"StopAccounts:AccountBrowserSO-write wait\n"); #endif - SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE); + SWMRGWaitToWrite(Plugin->AccountBrowserSO, INFINITE); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"StopAccounts:AccountBrowserSO-write enter\n"); #endif - for (Finder=Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next) + for (Finder = Plugin->FirstAccount; Finder != NULL; Finder = Finder->Next) { -//2. set stop signal + //2. set stop signal StopSignalFcn(Finder); - WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_STOPACCOUNT,(WPARAM)Finder,0); + WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_STOPACCOUNT, (WPARAM)Finder, 0); if (Plugin->Fcn->StopAccountFcnPtr != NULL) Plugin->Fcn->StopAccountFcnPtr(Finder); } -//leave write access + //leave write access #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"StopAccounts:AccountBrowserSO-write done\n"); #endif SWMRGDoneWriting(Plugin->AccountBrowserSO); -//Now, account is stopped. It can be removed from memory... + //Now, account is stopped. It can be removed from memory... return 1; } -int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess) +int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin, BOOL GetAccountBrowserAccess) { HACCOUNT Finder; if (GetAccountBrowserAccess) { -//1. wait to get write access + //1. wait to get write access #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WaitForAllAccounts:AccountBrowserSO-write wait\n"); #endif - SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE); + SWMRGWaitToWrite(Plugin->AccountBrowserSO, INFINITE); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WaitForAllAccounts:AccountBrowserSO-write enter\n"); #endif } - for (Finder=Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next) + for (Finder = Plugin->FirstAccount; Finder != NULL; Finder = Finder->Next) { -//2. wait for signal that account is not in use + //2. wait for signal that account is not in use #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WaitForAllAccounts:waiting for UsingThreadEV %x (account %x)\n",Finder->UsingThreads,Finder); #endif - WaitForSingleObject(Finder->UsingThreads->Event,INFINITE); + WaitForSingleObject(Finder->UsingThreads->Event, INFINITE); SetEvent(Finder->UsingThreads->Event); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WaitForAllAccounts:UsingThreadEV signaled\n"); @@ -1197,7 +1195,7 @@ int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess) } if (GetAccountBrowserAccess) { -//leave write access + //leave write access #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"WaitForAllAccounts:AccountBrowserSO-write done\n"); #endif @@ -1212,37 +1210,37 @@ int DeleteAccounts(HYAMNPROTOPLUGIN Plugin) HACCOUNT Finder; //1. wait to get write access - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write wait\n"); - #endif - SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE); - #ifdef DEBUG_SYNCHRO +#endif + SWMRGWaitToWrite(Plugin->AccountBrowserSO, INFINITE); +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write enter\n"); - #endif +#endif - WaitForAllAccounts(Plugin,FALSE); + WaitForAllAccounts(Plugin, FALSE); - for (Finder=Plugin->FirstAccount;Finder != NULL;) + for (Finder = Plugin->FirstAccount; Finder != NULL;) { HACCOUNT Next = Finder->Next; - DeletePluginAccountSvc((WPARAM)Finder,0); + DeletePluginAccountSvc((WPARAM)Finder, 0); Finder = Next; } //leave write access - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write done\n"); - #endif +#endif SWMRGDoneWriting(Plugin->AccountBrowserSO); return 1; } -void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *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 @@ -1250,7 +1248,7 @@ void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value) #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs enter\n"); #endif - mir_tstrcpy(Value,Which->Status); + mir_tstrcpy(Value, Which->Status); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs done\n"); #endif @@ -1258,9 +1256,9 @@ void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value) return; } -void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value) +void WINAPI SetStatusFcn(HACCOUNT Which, TCHAR *Value) { - if (Which==NULL) + if (Which == NULL) return; #ifdef DEBUG_SYNCHRO @@ -1270,8 +1268,8 @@ void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value) #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs enter\n"); #endif - mir_tstrcpy(Which->Status,Value); - WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_CHANGESTATUS,(WPARAM)Which,0); + mir_tstrcpy(Which->Status, Value); + WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGESTATUS, (WPARAM)Which, 0); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs done\n"); #endif @@ -1282,20 +1280,20 @@ void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value) #ifdef DEBUG_ACCOUNTS int GetAccounts() { - HACCOUNT Finder; - int cnt=0; +HACCOUNT Finder; +int cnt=0; - for (Finder=Account;Finder != NULL;Finder=Finder->Next) - cnt++; - return cnt; +for (Finder=Account;Finder != NULL;Finder=Finder->Next) +cnt++; +return cnt; } void WriteAccounts() { - HACCOUNT Finder; +HACCOUNT Finder; - for (Finder=Account;Finder != NULL;Finder=Finder->Next) - MessageBoxA(NULL,Finder->Name,"Browsing account",MB_OK); +for (Finder=Account;Finder != NULL;Finder=Finder->Next) +MessageBoxA(NULL,Finder->Name,"Browsing account",MB_OK); } #endif */ diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp index 6339ebaba5..213779ff26 100644 --- a/plugins/YAMN/src/browser/badconnect.cpp +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -11,39 +11,39 @@ //--------------------------------------------------------------------------------------------------
-LRESULT CALLBACK BadConnectPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
+LRESULT CALLBACK BadConnectPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
DWORD PluginParam;
- switch(msg) {
+ switch (msg) {
case WM_COMMAND:
// if clicked and it's new mail popup window
- if ((HIWORD(wParam)==STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam))) {
+ if ((HIWORD(wParam) == STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam))) {
PROCESS_INFORMATION pi;
STARTUPINFOW si;
memset(&si, 0, sizeof(si));
- si.cb=sizeof(si);
+ si.cb = sizeof(si);
HACCOUNT ActualAccount = (HACCOUNT)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n");
#endif
- if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) {
+ if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) {
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n");
#endif
if (ActualAccount->BadConnectN.App != NULL) {
WCHAR *Command;
if (ActualAccount->BadConnectN.AppParam != NULL)
- Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App)+wcslen(ActualAccount->BadConnectN.AppParam)+6];
+ Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App) + wcslen(ActualAccount->BadConnectN.AppParam) + 6];
else
- Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App)+6];
+ Command = new WCHAR[wcslen(ActualAccount->BadConnectN.App) + 6];
if (Command != NULL) {
- mir_wstrcpy(Command,L"\"");
- mir_wstrcat(Command,ActualAccount->BadConnectN.App);
- mir_wstrcat(Command,L"\" ");
+ mir_wstrcpy(Command, L"\"");
+ mir_wstrcat(Command, ActualAccount->BadConnectN.App);
+ mir_wstrcat(Command, L"\" ");
if (ActualAccount->BadConnectN.AppParam != NULL)
- mir_wstrcat(Command,ActualAccount->BadConnectN.AppParam);
- CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);
+ mir_wstrcat(Command, ActualAccount->BadConnectN.AppParam);
+ CreateProcessW(NULL, Command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
delete[] Command;
}
}
@@ -56,7 +56,7 @@ LRESULT CALLBACK BadConnectPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lPa else
DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n");
#endif
- SendMessage(hWnd,UM_DESTROYPOPUP,0,0);
+ SendMessage(hWnd, UM_DESTROYPOPUP, 0, 0);
}
break;
@@ -68,154 +68,154 @@ LRESULT CALLBACK BadConnectPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lPa //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
break;
case WM_CONTEXTMENU:
- SendMessage(hWnd,UM_DESTROYPOPUP,0,0);
+ SendMessage(hWnd, UM_DESTROYPOPUP, 0, 0);
break;
}
- return DefWindowProc(hWnd,msg,wParam,lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
-INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
+ switch (msg)
{
- case WM_INITDIALOG:
- {
- BOOL ShowPopup,ShowMsg,ShowIco;
- HACCOUNT ActualAccount;
- DWORD ErrorCode;
- char* TitleStrA;
- char *Message1A=NULL;
- TCHAR *Message1W=NULL;
- POPUPDATAT BadConnectPopup;
+ case WM_INITDIALOG:
+ {
+ BOOL ShowPopup, ShowMsg, ShowIco;
+ HACCOUNT ActualAccount;
+ DWORD ErrorCode;
+ char* TitleStrA;
+ char *Message1A = NULL;
+ TCHAR *Message1W = NULL;
+ POPUPDATAT BadConnectPopup;
- ActualAccount=((struct BadConnectionParam *)lParam)->account;
- ErrorCode=((struct BadConnectionParam *)lParam)->errcode;
+ ActualAccount = ((struct BadConnectionParam *)lParam)->account;
+ ErrorCode = ((struct BadConnectionParam *)lParam)->errcode;
#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
#endif
- if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO))
- {
+ if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
#endif
- return FALSE;
- }
+ return FALSE;
+ }
#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
#endif
- int size = (int)(strlen(ActualAccount->Name)+strlen(Translate(BADCONNECTTITLE)));
- TitleStrA = new char[size];
- mir_snprintf(TitleStrA, size, Translate(BADCONNECTTITLE), ActualAccount->Name);
+ int size = (int)(strlen(ActualAccount->Name) + strlen(Translate(BADCONNECTTITLE)));
+ TitleStrA = new char[size];
+ mir_snprintf(TitleStrA, size, Translate(BADCONNECTTITLE), ActualAccount->Name);
- ShowPopup=ActualAccount->BadConnectN.Flags & YAMN_ACC_POP;
- ShowMsg=ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG;
- ShowIco=ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO;
+ ShowPopup = ActualAccount->BadConnectN.Flags & YAMN_ACC_POP;
+ ShowMsg = ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG;
+ ShowIco = ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO;
- if (ShowPopup) {
- BadConnectPopup.lchIcon = g_LoadIconEx(3);
- BadConnectPopup.colorBack = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupB : GetSysColor(COLOR_BTNFACE);
- BadConnectPopup.colorText = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupT : GetSysColor(COLOR_WINDOWTEXT);
- BadConnectPopup.iSeconds = ActualAccount->BadConnectN.PopupTime;
+ if (ShowPopup) {
+ BadConnectPopup.lchIcon = g_LoadIconEx(3);
+ BadConnectPopup.colorBack = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupB : GetSysColor(COLOR_BTNFACE);
+ BadConnectPopup.colorText = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupT : GetSysColor(COLOR_WINDOWTEXT);
+ BadConnectPopup.iSeconds = ActualAccount->BadConnectN.PopupTime;
- BadConnectPopup.PluginWindowProc = BadConnectPopupProc;
- BadConnectPopup.PluginData = ActualAccount;
- mir_tstrncpy(BadConnectPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(BadConnectPopup.lptzContactName));
- }
+ BadConnectPopup.PluginWindowProc = BadConnectPopupProc;
+ BadConnectPopup.PluginData = ActualAccount;
+ mir_tstrncpy(BadConnectPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(BadConnectPopup.lptzContactName));
+ }
- if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) {
- Message1W = ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
- SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
- _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
- if (ShowPopup)
- PUAddPopupT(&BadConnectPopup);
- }
- else if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringAFcnPtr != NULL)
- {
- Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
- SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
- _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
- if (ShowPopup)
- PUAddPopupT(&BadConnectPopup);
- }
- else
- {
- Message1W=TranslateT("Unknown error");
- SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
- _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
- if (ShowPopup)
- PUAddPopupT(&BadConnectPopup);
- }
+ if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr != NULL) {
+ Message1W = ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
+ SetDlgItemText(hDlg, IDC_STATICMSG, Message1W);
+ _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
+ if (ShowPopup)
+ PUAddPopupT(&BadConnectPopup);
+ }
+ else if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->GetErrorStringAFcnPtr != NULL)
+ {
+ Message1W = ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
+ SetDlgItemText(hDlg, IDC_STATICMSG, Message1W);
+ _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
+ if (ShowPopup)
+ PUAddPopupT(&BadConnectPopup);
+ }
+ else
+ {
+ Message1W = TranslateT("Unknown error");
+ SetDlgItemText(hDlg, IDC_STATICMSG, Message1W);
+ _tcsncpy_s(BadConnectPopup.lptzText, Message1W, _TRUNCATE);
+ if (ShowPopup)
+ PUAddPopupT(&BadConnectPopup);
+ }
- if (!ShowMsg && !ShowIco)
- DestroyWindow(hDlg);
+ if (!ShowMsg && !ShowIco)
+ DestroyWindow(hDlg);
#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
#endif
- ReadDoneFcn(ActualAccount->AccountAccessSO);
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
- SetWindowTextA(hDlg, TitleStrA);
- delete[] TitleStrA;
- if (Message1A != NULL)
- delete[] Message1A;
- if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr != NULL && Message1A != NULL)
- ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1A);
- if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr != NULL && Message1W != NULL)
- ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1W);
- return 0;
+ SetWindowTextA(hDlg, TitleStrA);
+ delete[] TitleStrA;
+ if (Message1A != NULL)
+ delete[] Message1A;
+ if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr != NULL && Message1A != NULL)
+ ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1A);
+ if (ActualAccount->Plugin->Fcn != NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr != NULL && Message1W != NULL)
+ ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1W);
+ return 0;
+ }
+ case WM_DESTROY:
+ {
+ NOTIFYICONDATA nid;
+
+ memset(&nid, 0, sizeof(NOTIFYICONDATA));
+ nid.cbSize = sizeof(NOTIFYICONDATA);
+ nid.hWnd = hDlg;
+ nid.uID = 0;
+ Shell_NotifyIcon(NIM_DELETE, &nid);
+ PostQuitMessage(0);
+ break;
+ }
+ case WM_YAMN_NOTIFYICON:
+ switch (lParam)
+ {
+ case WM_LBUTTONDBLCLK:
+ ShowWindow(hDlg, SW_SHOWNORMAL);
+ SetForegroundWindow(hDlg);
+ break;
}
- case WM_DESTROY:
+ return 0;
+ case WM_CHAR:
+ switch ((TCHAR)wParam)
{
- NOTIFYICONDATA nid;
-
- memset(&nid, 0, sizeof(NOTIFYICONDATA));
- nid.cbSize=sizeof(NOTIFYICONDATA);
- nid.hWnd=hDlg;
- nid.uID=0;
- Shell_NotifyIcon(NIM_DELETE,&nid);
- PostQuitMessage(0);
+ case 27:
+ case 13:
+ DestroyWindow(hDlg);
break;
}
- case WM_YAMN_NOTIFYICON:
- switch (lParam)
- {
- case WM_LBUTTONDBLCLK:
- ShowWindow(hDlg,SW_SHOWNORMAL);
- SetForegroundWindow(hDlg);
- break;
- }
- return 0;
- case WM_CHAR:
- switch((TCHAR)wParam)
- {
- case 27:
- case 13:
- DestroyWindow(hDlg);
- break;
- }
+ break;
+ case WM_SYSCOMMAND:
+ switch (wParam)
+ {
+ case SC_CLOSE:
+ DestroyWindow(hDlg);
break;
- case WM_SYSCOMMAND:
- switch(wParam)
- {
- case SC_CLOSE:
- DestroyWindow(hDlg);
- break;
- }
- case WM_COMMAND:
+ }
+ case WM_COMMAND:
+ {
+ WORD wNotifyCode = HIWORD(wParam);
+ switch (LOWORD(wParam))
{
- WORD wNotifyCode = HIWORD(wParam);
- switch(LOWORD(wParam))
- {
- case IDC_BTNOK:
- DestroyWindow(hDlg);
- break;
- }
+ case IDC_BTNOK:
+ DestroyWindow(hDlg);
break;
}
+ break;
+ }
}
return 0;
}
-DWORD WINAPI BadConnection(LPVOID Param)
+void __cdecl BadConnection(void *Param)
{
MSG msg;
HWND hBadConnect;
@@ -226,29 +226,29 @@ DWORD WINAPI BadConnection(LPVOID Param) TCHAR *dest;
int i;
- MyParam=*(struct BadConnectionParam *)Param;
- ActualAccount=MyParam.account;
+ MyParam = *(struct BadConnectionParam *)Param;
+ ActualAccount = MyParam.account;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"BadConnect:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
SCIncFcn(ActualAccount->UsingThreads);
-// we will not use params in stack anymore
+ // we will not use params in stack anymore
SetEvent(MyParam.ThreadRunningEV);
__try
{
- hBadConnect=CreateDialogParam(YAMNVar.hInst,MAKEINTRESOURCE(IDD_DLGBADCONNECT),NULL,DlgProcYAMNBadConnection,(LPARAM)&MyParam);
- SendMessage(hBadConnect,WM_SETICON,ICON_BIG,(LPARAM)g_LoadIconEx(3));
- SendMessage(hBadConnect,WM_SETICON,ICON_SMALL,(LPARAM)g_LoadIconEx(3));
+ hBadConnect = CreateDialogParam(YAMNVar.hInst, MAKEINTRESOURCE(IDD_DLGBADCONNECT), NULL, DlgProcYAMNBadConnection, (LPARAM)&MyParam);
+ SendMessage(hBadConnect, WM_SETICON, ICON_BIG, (LPARAM)g_LoadIconEx(3));
+ SendMessage(hBadConnect, WM_SETICON, ICON_SMALL, (LPARAM)g_LoadIconEx(3));
memset(&nid, 0, sizeof(nid));
- nid.cbSize=sizeof(NOTIFYICONDATA);
- nid.hWnd=hBadConnect;
- nid.hIcon=g_LoadIconEx(3);
- nid.uID=0;
- nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
- nid.uCallbackMessage=WM_YAMN_NOTIFYICON;
+ nid.cbSize = sizeof(NOTIFYICONDATA);
+ nid.hWnd = hBadConnect;
+ nid.hIcon = g_LoadIconEx(3);
+ nid.uID = 0;
+ nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage = WM_YAMN_NOTIFYICON;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
@@ -258,34 +258,34 @@ DWORD WINAPI BadConnection(LPVOID Param) #ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
#endif
- return 0;
+ return;
}
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
#endif
- for (src=ActualAccount->Name,dest=nid.szTip,i=0;(*src != (TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
- for (src=NotIconText;(*src != (TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
- *dest=(TCHAR)0;
+ for (src = ActualAccount->Name, dest = nid.szTip, i = 0; (*src != (TCHAR)0) && (i + 1 < sizeof(nid.szTip)); *dest++ = *src++);
+ for (src = NotIconText; (*src != (TCHAR)0) && (i + 1 < sizeof(nid.szTip)); *dest++ = *src++);
+ *dest = (TCHAR)0;
if (ActualAccount->BadConnectN.Flags & YAMN_ACC_SND)
- CallService(MS_SKIN_PLAYSOUND,0,(LPARAM)YAMN_CONNECTFAILSOUND);
+ CallService(MS_SKIN_PLAYSOUND, 0, (LPARAM)YAMN_CONNECTFAILSOUND);
if (ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG)
- ShowWindow(hBadConnect,SW_SHOWNORMAL);
+ ShowWindow(hBadConnect, SW_SHOWNORMAL);
if (ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO)
- Shell_NotifyIcon(NIM_ADD,&nid);
+ Shell_NotifyIcon(NIM_ADD, &nid);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
#endif
ReadDoneFcn(ActualAccount->AccountAccessSO);
UpdateWindow(hBadConnect);
- while(GetMessage(&msg,NULL,0,0))
+ while (GetMessage(&msg, NULL, 0, 0))
{
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
}
-// now, write to file. Why? Because we want to write when was new mail last checked
+ // now, write to file. Why? Because we want to write when was new mail last checked
if ((ActualAccount->Plugin->Fcn != NULL) && (ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr != NULL) && ActualAccount->AbleToWork)
ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr();
}
@@ -296,32 +296,30 @@ DWORD WINAPI BadConnection(LPVOID Param) #endif
SCDecFcn(ActualAccount->UsingThreads);
}
- return 0;
}
-INT_PTR RunBadConnectionSvc(WPARAM wParam,LPARAM lParam)
+INT_PTR RunBadConnectionSvc(WPARAM wParam, LPARAM lParam)
{
- DWORD tid;
-//an event for successfull copy parameters to which point a pointer in stack for new thread
+ //an event for successfull copy parameters to which point a pointer in stack for new thread
HANDLE ThreadRunningEV;
- PYAMN_BADCONNECTIONPARAM Param=(PYAMN_BADCONNECTIONPARAM)wParam;
+ PYAMN_BADCONNECTIONPARAM Param = (PYAMN_BADCONNECTIONPARAM)wParam;
if ((DWORD)lParam != YAMN_BADCONNECTIONVERSION)
return 0;
- if (NULL != (ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ if (NULL != (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL)))
{
HANDLE NewThread;
- Param->ThreadRunningEV=ThreadRunningEV;
- if (NULL != (NewThread=CreateThread(NULL,0,BadConnection,Param,0,&tid)))
+ Param->ThreadRunningEV = ThreadRunningEV;
+ if (NULL != (NewThread = mir_forkthread(BadConnection, (void*)Param)))
{
- WaitForSingleObject(ThreadRunningEV,INFINITE);
+ WaitForSingleObject(ThreadRunningEV, INFINITE);
CloseHandle(NewThread);
}
CloseHandle(ThreadRunningEV);
-
+
return 1;
}
return 0;
diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp index 84596f43ce..9170ca9af2 100644 --- a/plugins/YAMN/src/browser/mailbrowser.cpp +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -19,19 +19,19 @@ //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- char* s_MonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -bool bDate = false,bSub=false,bSize=false,bFrom=false; -int PosX=0,PosY=0,SizeX=460,SizeY=100; +bool bDate = false, bSub = false, bSize = false, bFrom = false; +int PosX = 0, PosY = 0, SizeX = 460, SizeY = 100; int HeadSizeX = 0x2b2, HeadSizeY = 0x0b5, HeadPosX = 100, HeadPosY = 100; -int HeadSplitPos=250; // per-mils of the size -static int FromWidth=250,SubjectWidth=280,SizeWidth=50,SizeDate=205; -unsigned char optDateTime = (SHOWDATELONG | SHOWDATENOTODAY); +int HeadSplitPos = 250; // per-mils of the size +static int FromWidth = 250, SubjectWidth = 280, SizeWidth = 50, SizeDate = 205; +unsigned char optDateTime = (SHOWDATELONG | SHOWDATENOTODAY); struct CMailNumbersSub { int Total; //any mail int New; //uses YAMN_MSG_NEW flag int UnSeen; //uses YAMN_MSG_UNSEEN flag -// int Browser; //uses YAMN_MSG_BROWSER flag + // int Browser; //uses YAMN_MSG_BROWSER flag int BrowserUC; //uses YAMN_MSG_BROWSER flag and YAMN_MSG_UNSEEN flag int Display; //uses YAMN_MSG_DISPLAY flag int DisplayTC; //uses YAMN_MSG_DISPLAY flag and YAMN_MSG_DISPLAYC flag @@ -42,11 +42,11 @@ struct CMailNumbersSub int PopupRun; //uses YAMN_MSG_POPUP flag and YAMN_MSG_NEW flag int PopupSL2NC; //uses YAMN_MSG_SPAML2 flag and YAMN_MSG_NEW flag int PopupSL3NC; //uses YAMN_MSG_SPAML3 flag and YAMN_MSG_NEW flag -// int SysTray; //uses YAMN_MSG_SYSTRAY flag + // int SysTray; //uses YAMN_MSG_SYSTRAY flag int SysTrayUC; //uses YAMN_MSG_SYSTRAY flag and YAMN_MSG_UNSEEN flag -// int Sound; //uses YAMN_MSG_SOUND flag + // int Sound; //uses YAMN_MSG_SOUND flag int SoundNC; //uses YAMN_MSG_SOUND flag and YAMN_MSG_NEW flag -// int App; //uses YAMN_MSG_APP flag + // int App; //uses YAMN_MSG_APP flag int AppNC; //uses YAMN_MSG_APP flag and YAMN_MSG_NEW flag int EventNC; //uses YAMN_MSG_NEVENT flag and YAMN_MSG_NEW flag }; @@ -92,11 +92,11 @@ inline HACCOUNT GetWindowAccount(HWND hDialog); //Looks to mail flags and increment mail counter (e.g. if mail is new, increments the new mail counter // msgq- mail, which increments the counters // MN- counnters structure -void IncrementMailCounters(HYAMNMAIL msgq,struct CMailNumbers *MN); +void IncrementMailCounters(HYAMNMAIL msgq, struct CMailNumbers *MN); enum { - UPDATE_FAIL=0, //function failed + UPDATE_FAIL = 0, //function failed UPDATE_NONE, //none update has been performed UPDATE_OK, //some changes occured, update performed }; @@ -106,7 +106,7 @@ enum // nflags- flags what to do when new mail arrives // nnflags- flags what to do when no new mail arrives // returns one of UPDATE_XXX value(not implemented yet) -int UpdateMails(HWND hDlg,HACCOUNT ActualAccount,DWORD nflags,DWORD nnflags); +int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags); //When new mail occurs, shows window, plays sound, runs application... // hDlg- dialog handle. Dialog of mailbrowser is already created and actions are performed over this window @@ -115,14 +115,14 @@ int UpdateMails(HWND hDlg,HACCOUNT ActualAccount,DWORD nflags,DWORD nnflags); // nflags- what to do or not to do (e.g. to show mailbrowser window or prohibit to show) // nflags- flags what to do when new mail arrives // nnflags- flags what to do when no new mail arrives -void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWORD nflags,DWORD nnflags); +void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, DWORD nflags, DWORD nnflags); //Looks for items in mailbrowser and if they were deleted, delete them from browser window // hListView- handle of listview window // ActualAccount- handle of account, whose mails are show // MailNumbers- pointer to structure, in which function stores numbers of mails with some property // returns one of UPDATE_XXX value (not implemented yet) -int ChangeExistingMailStatus(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MN); +int ChangeExistingMailStatus(HWND hListView, HACCOUNT ActualAccount, struct CMailNumbers *MN); //Adds new mails to ListView and if any new, shows multi popup (every new message is new popup window created by popup plugin) // hListView- handle of listview window @@ -131,69 +131,69 @@ int ChangeExistingMailStatus(HWND hListView,HACCOUNT ActualAccount,struct CMailN // MailNumbers- pointer to structure, in which function stores numbers of mails with some property // nflags- flags what to do when new mail arrives // returns one of UPDATE_XXX value (not implemented yet) -int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MailNumbers,DWORD nflags); +int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, struct CMailNumbers *MailNumbers, DWORD nflags); //Window callback procedure for popup window (created by popup plugin) -LRESULT CALLBACK NewMailPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam); +LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); //Window callback procedure for popup window (created by popup plugin) -LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam); +LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); //Dialog callback procedure for mail browser -INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam); +INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); //MailBrowser thread function creates window if needed, tray icon and plays sound -DWORD WINAPI MailBrowser(LPVOID Param); +void __cdecl MailBrowser(void *Param); LRESULT CALLBACK ListViewSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); //Runs mail browser in new thread -INT_PTR RunMailBrowserSvc(WPARAM,LPARAM); +INT_PTR RunMailBrowserSvc(WPARAM, LPARAM); #define YAMN_BROWSER_SHOWPOPUP 0x01 - // list view items' order criteria - #define LVORDER_NOORDER -1 - #define LVORDER_STRING 0 - #define LVORDER_NUMERIC 1 - #define LVORDER_DATETIME 2 +// list view items' order criteria +#define LVORDER_NOORDER -1 +#define LVORDER_STRING 0 +#define LVORDER_NUMERIC 1 +#define LVORDER_DATETIME 2 - // list view order direction - #define LVORDER_ASCENDING 1 - #define LVORDER_NONE 0 - #define LVORDER_DESCENDING -1 +// list view order direction +#define LVORDER_ASCENDING 1 +#define LVORDER_NONE 0 +#define LVORDER_DESCENDING -1 - // list view sort type - #define LVSORTPRIORITY_NONE -1 +// list view sort type +#define LVSORTPRIORITY_NONE -1 - // List view column info. - typedef struct _SAMPLELISTVIEWCOLUMN - { - UINT uCXCol; // index - int nSortType; // sorting type (STRING = 0, NUMERIC, DATE, DATETIME) - int nSortOrder; // sorting order (ASCENDING = -1, NONE, DESCENDING) - int nPriority; // sort priority (-1 for none, 0, 1, ..., nColumns - 1 maximum) - TCHAR lpszName[128]; // column name - } SAMPLELISTVIEWCOLUMN; - - // Compare priority - typedef struct _LVCOMPAREINFO - { - int iIdx; // Index - int iPriority; // Priority - } LVCOMPAREINFO, *LPLVCOMPAREINFO; +// List view column info. +typedef struct _SAMPLELISTVIEWCOLUMN +{ + UINT uCXCol; // index + int nSortType; // sorting type (STRING = 0, NUMERIC, DATE, DATETIME) + int nSortOrder; // sorting order (ASCENDING = -1, NONE, DESCENDING) + int nPriority; // sort priority (-1 for none, 0, 1, ..., nColumns - 1 maximum) + TCHAR lpszName[128]; // column name +} SAMPLELISTVIEWCOLUMN; + +// Compare priority +typedef struct _LVCOMPAREINFO +{ + int iIdx; // Index + int iPriority; // Priority +} LVCOMPAREINFO, *LPLVCOMPAREINFO; //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- -LPARAM readItemLParam(HWND hwnd,DWORD iItem) +LPARAM readItemLParam(HWND hwnd, DWORD iItem) { LVITEM item; item.mask = LVIF_PARAM; item.iItem = iItem; item.iSubItem = 0; - SendMessage(hwnd,LVM_GETITEM,0,(LPARAM)&item); + SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM)&item); return item.lParam; } @@ -201,12 +201,12 @@ inline HACCOUNT GetWindowAccount(HWND hDlg) { struct CMailWinUserInfo *mwui; - if (NULL==(mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER))) + if (NULL == (mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER))) return NULL; return mwui->Account; } -void IncrementMailCounters(HYAMNMAIL msgq,struct CMailNumbers *MN) +void IncrementMailCounters(HYAMNMAIL msgq, struct CMailNumbers *MN) { if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.Total++; @@ -263,54 +263,54 @@ void IncrementMailCounters(HYAMNMAIL msgq,struct CMailNumbers *MN) MN->Virtual.PopupRun++; else MN->Real.PopupRun++; - if ((msgq->Flags & YAMN_MSG_NEW) && YAMN_MSG_SPAML(msgq->Flags,YAMN_MSG_SPAML2)) + if ((msgq->Flags & YAMN_MSG_NEW) && YAMN_MSG_SPAML(msgq->Flags, YAMN_MSG_SPAML2)) if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.PopupSL2NC++; else MN->Real.PopupSL2NC++; - if ((msgq->Flags & YAMN_MSG_NEW) && YAMN_MSG_SPAML(msgq->Flags,YAMN_MSG_SPAML3)) + if ((msgq->Flags & YAMN_MSG_NEW) && YAMN_MSG_SPAML(msgq->Flags, YAMN_MSG_SPAML3)) if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.PopupSL3NC++; else MN->Real.PopupSL3NC++; -/* if (msgq->MailData->Flags & YAMN_MSG_SYSTRAY) - if (msgq->Flags & YAMN_MSG_VIRTUAL) + /* if (msgq->MailData->Flags & YAMN_MSG_SYSTRAY) + if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.SysTray++; - else + else MN->Real.SysTray++; -*/ if ((msgq->Flags & (YAMN_MSG_UNSEEN | YAMN_MSG_SYSTRAY)) == (YAMN_MSG_UNSEEN|YAMN_MSG_SYSTRAY)) - if (msgq->Flags & YAMN_MSG_VIRTUAL) - MN->Virtual.SysTrayUC++; - else - MN->Real.SysTrayUC++; -/* if (msgq->MailData->Flags & YAMN_MSG_SOUND) - if (msgq->Flags & YAMN_MSG_VIRTUAL) + */ if ((msgq->Flags & (YAMN_MSG_UNSEEN | YAMN_MSG_SYSTRAY)) == (YAMN_MSG_UNSEEN | YAMN_MSG_SYSTRAY)) + if (msgq->Flags & YAMN_MSG_VIRTUAL) + MN->Virtual.SysTrayUC++; + else + MN->Real.SysTrayUC++; + /* if (msgq->MailData->Flags & YAMN_MSG_SOUND) + if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.Sound++; - else + else MN->Real.Sound++; -*/ if ((msgq->Flags & (YAMN_MSG_NEW|YAMN_MSG_SOUND)) == (YAMN_MSG_NEW|YAMN_MSG_SOUND)) - if (msgq->Flags & YAMN_MSG_VIRTUAL) - MN->Virtual.SoundNC++; - else - MN->Real.SoundNC++; -/* if (msgq->MailData->Flags & YAMN_MSG_APP) - if (msgq->Flags & YAMN_MSG_VIRTUAL) + */ if ((msgq->Flags & (YAMN_MSG_NEW | YAMN_MSG_SOUND)) == (YAMN_MSG_NEW | YAMN_MSG_SOUND)) + if (msgq->Flags & YAMN_MSG_VIRTUAL) + MN->Virtual.SoundNC++; + else + MN->Real.SoundNC++; + /* if (msgq->MailData->Flags & YAMN_MSG_APP) + if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.App++; - else + else MN->Real.App++; -*/ if ((msgq->Flags & (YAMN_MSG_NEW|YAMN_MSG_APP)) == (YAMN_MSG_NEW|YAMN_MSG_APP)) - if (msgq->Flags & YAMN_MSG_VIRTUAL) - MN->Virtual.AppNC++; - else - MN->Real.AppNC++; - if ((msgq->Flags & (YAMN_MSG_NEW|YAMN_MSG_NEVENT)) == (YAMN_MSG_NEW|YAMN_MSG_NEVENT)) + */ if ((msgq->Flags & (YAMN_MSG_NEW | YAMN_MSG_APP)) == (YAMN_MSG_NEW | YAMN_MSG_APP)) + if (msgq->Flags & YAMN_MSG_VIRTUAL) + MN->Virtual.AppNC++; + else + MN->Real.AppNC++; + if ((msgq->Flags & (YAMN_MSG_NEW | YAMN_MSG_NEVENT)) == (YAMN_MSG_NEW | YAMN_MSG_NEVENT)) if (msgq->Flags & YAMN_MSG_VIRTUAL) MN->Virtual.EventNC++; else MN->Real.EventNC++; } -int UpdateMails(HWND hDlg,HACCOUNT ActualAccount,DWORD nflags,DWORD nnflags) +int UpdateMails(HWND hDlg, HACCOUNT ActualAccount, DWORD nflags, DWORD nnflags) { #define MAILBROWSERTITLE LPGEN("%s - %d new mail messages, %d total") @@ -319,161 +319,161 @@ int UpdateMails(HWND hDlg,HACCOUNT ActualAccount,DWORD nflags,DWORD nnflags) HYAMNMAIL msgq; BOOL Loaded; - BOOL RunMailBrowser,RunPopups; + BOOL RunMailBrowser, RunPopups; - mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER); + mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); //now we ensure read access for account and write access for its mails - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read wait\n"); - #endif +#endif if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read wait failed\n"); - #endif - PostMessage(hDlg,WM_DESTROY,0,0); +#endif + PostMessage(hDlg, WM_DESTROY, 0, 0); return UPDATE_FAIL; } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read enter\n"); - #endif +#endif - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write wait\n"); - #endif +#endif if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) { - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write wait failed\n"); DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read done\n"); - #endif +#endif ReadDoneFcn(ActualAccount->AccountAccessSO); - PostMessage(hDlg,WM_DESTROY,0,0); + PostMessage(hDlg, WM_DESTROY, 0, 0); return UPDATE_FAIL; } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write enter\n"); - #endif +#endif memset(&MN, 0, sizeof(MN)); - for (msgq=(HYAMNMAIL)ActualAccount->Mails;msgq != NULL;msgq=msgq->Next) + for (msgq = (HYAMNMAIL)ActualAccount->Mails; msgq != NULL; msgq = msgq->Next) { if (!LoadedMailData(msgq)) //check if mail is already in memory { - Loaded=false; - if (NULL==LoadMailData(msgq)) //if we could not load mail to memory, consider this mail deleted and do not display it + Loaded = false; + if (NULL == LoadMailData(msgq)) //if we could not load mail to memory, consider this mail deleted and do not display it continue; } else - Loaded=true; + Loaded = true; - IncrementMailCounters(msgq,&MN); + IncrementMailCounters(msgq, &MN); if (!Loaded) UnloadMailData(msgq); //do not keep data for mail in memory } if (mwui != NULL) - mwui->UpdateMailsMessagesAccess=TRUE; + mwui->UpdateMailsMessagesAccess = TRUE; //Now we are going to check if extracting data from mail headers are needed. //If popups will be displayed or mailbrowser window - if ((((mwui != NULL) && !(mwui->RunFirstTime)) && - ( - ((nnflags & YAMN_ACC_MSGP) && !(MN.Real.BrowserUC+MN.Virtual.BrowserUC)) || - ((nflags & YAMN_ACC_MSGP) && (MN.Real.BrowserUC+MN.Virtual.BrowserUC)) - ) - ) || //if mail window was displayed before and flag YAMN_ACC_MSGP is set - ((nnflags & YAMN_ACC_MSG) && !(MN.Real.BrowserUC+MN.Virtual.BrowserUC)) || //if needed to run mailbrowser when no unseen and no unseen mail found - ((nflags & YAMN_ACC_MSG) && (MN.Real.BrowserUC+MN.Virtual.BrowserUC)) || //if unseen mails found, we sure run mailbrowser - ((nflags & YAMN_ACC_ICO) && (MN.Real.SysTrayUC+MN.Virtual.SysTrayUC)) + if ((((mwui != NULL) && !(mwui->RunFirstTime)) && + ( + ((nnflags & YAMN_ACC_MSGP) && !(MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || + ((nflags & YAMN_ACC_MSGP) && (MN.Real.BrowserUC + MN.Virtual.BrowserUC)) + ) + ) || //if mail window was displayed before and flag YAMN_ACC_MSGP is set + ((nnflags & YAMN_ACC_MSG) && !(MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || //if needed to run mailbrowser when no unseen and no unseen mail found + ((nflags & YAMN_ACC_MSG) && (MN.Real.BrowserUC + MN.Virtual.BrowserUC)) || //if unseen mails found, we sure run mailbrowser + ((nflags & YAMN_ACC_ICO) && (MN.Real.SysTrayUC + MN.Virtual.SysTrayUC)) ) //if needed to run systray - RunMailBrowser=TRUE; - else RunMailBrowser=FALSE; + RunMailBrowser = TRUE; + else RunMailBrowser = FALSE; - if ( (nflags & YAMN_ACC_POP) && + if ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && - (MN.Real.PopupNC+MN.Virtual.PopupNC)) //if some popups with mails are needed to show - RunPopups=TRUE; - else RunPopups=FALSE; + (MN.Real.PopupNC + MN.Virtual.PopupNC)) //if some popups with mails are needed to show + RunPopups = TRUE; + else RunPopups = FALSE; if (RunMailBrowser) - ChangeExistingMailStatus(GetDlgItem(hDlg,IDC_LISTMAILS),ActualAccount,&MN); + ChangeExistingMailStatus(GetDlgItem(hDlg, IDC_LISTMAILS), ActualAccount, &MN); if (RunMailBrowser || RunPopups) - AddNewMailsToListView(hDlg==NULL ? NULL : GetDlgItem(hDlg,IDC_LISTMAILS),ActualAccount,&MN,nflags); + AddNewMailsToListView(hDlg == NULL ? NULL : GetDlgItem(hDlg, IDC_LISTMAILS), ActualAccount, &MN, nflags); if (RunMailBrowser) { - size_t len = strlen(ActualAccount->Name)+strlen(Translate(MAILBROWSERTITLE))+10; //+10 chars for numbers - char *TitleStrA=new char[len]; - WCHAR *TitleStrW=new WCHAR[len]; + size_t len = strlen(ActualAccount->Name) + strlen(Translate(MAILBROWSERTITLE)) + 10; //+10 chars for numbers + char *TitleStrA = new char[len]; + WCHAR *TitleStrW = new WCHAR[len]; mir_snprintf(TitleStrA, len, Translate(MAILBROWSERTITLE), ActualAccount->Name, MN.Real.DisplayUC + MN.Virtual.DisplayUC, MN.Real.Display + MN.Virtual.Display); - MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,TitleStrA,-1,TitleStrW,(int)strlen(TitleStrA)+1); + MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, TitleStrA, -1, TitleStrW, (int)strlen(TitleStrA) + 1); SetWindowTextW(hDlg, TitleStrW); delete[] TitleStrA; delete[] TitleStrW; } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:Do mail actions\n"); - #endif +#endif - DoMailActions(hDlg,ActualAccount,&MN,nflags,nnflags); + DoMailActions(hDlg, ActualAccount, &MN, nflags, nnflags); - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:Do mail actions done\n"); - #endif - - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_NEW,0,YAMN_MSG_NEW,YAMN_FLAG_REMOVE); //rempve the new flag +#endif + + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_NEW, 0, YAMN_MSG_NEW, YAMN_FLAG_REMOVE); //rempve the new flag if (!RunMailBrowser) - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_UNSEEN,YAMN_MSG_STAYUNSEEN,YAMN_MSG_UNSEEN,YAMN_FLAG_REMOVE); //remove the unseen flag when it was not displayed and it has not "stay unseen" flag set + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_UNSEEN, YAMN_MSG_STAYUNSEEN, YAMN_MSG_UNSEEN, YAMN_FLAG_REMOVE); //remove the unseen flag when it was not displayed and it has not "stay unseen" flag set if (mwui != NULL) { - mwui->UpdateMailsMessagesAccess=FALSE; - mwui->RunFirstTime=FALSE; + mwui->UpdateMailsMessagesAccess = FALSE; + mwui->RunFirstTime = FALSE; } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write done\n"); DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read done\n"); - #endif +#endif WriteDoneFcn(ActualAccount->MessagesAccessSO); ReadDoneFcn(ActualAccount->AccountAccessSO); if (RunMailBrowser) - UpdateWindow(GetDlgItem(hDlg,IDC_LISTMAILS)); + UpdateWindow(GetDlgItem(hDlg, IDC_LISTMAILS)); else if (hDlg != NULL) DestroyWindow(hDlg); return 1; } -int ChangeExistingMailStatus(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MN) +int ChangeExistingMailStatus(HWND hListView, HACCOUNT ActualAccount, struct CMailNumbers *MN) { - int i,in; + int i, in; LVITEMW item; - HYAMNMAIL mail,msgq; + HYAMNMAIL mail, msgq; - in=ListView_GetItemCount(hListView); - item.mask=LVIF_PARAM; + in = ListView_GetItemCount(hListView); + item.mask = LVIF_PARAM; - for (i=0;i<in;i++) + for (i = 0; i < in; i++) { - item.iItem=i; - item.iSubItem=0; - if (TRUE==ListView_GetItem(hListView,&item)) - mail=(HYAMNMAIL)item.lParam; + item.iItem = i; + item.iSubItem = 0; + if (TRUE == ListView_GetItem(hListView, &item)) + mail = (HYAMNMAIL)item.lParam; else continue; - for (msgq=(HYAMNMAIL)ActualAccount->Mails;(msgq != NULL)&&(msgq != mail);msgq=msgq->Next); //found the same mail in account queue - if (msgq==NULL) //if mail was not found - if (TRUE==ListView_DeleteItem(hListView,i)) + for (msgq = (HYAMNMAIL)ActualAccount->Mails; (msgq != NULL) && (msgq != mail); msgq = msgq->Next); //found the same mail in account queue + if (msgq == NULL) //if mail was not found + if (TRUE == ListView_DeleteItem(hListView, i)) { - in--;i--; + in--; i--; continue; } } @@ -482,77 +482,77 @@ int ChangeExistingMailStatus(HWND hListView,HACCOUNT ActualAccount,struct CMailN } void MimeDateToLocalizedDateTime(char *datein, WCHAR *dateout, int lendateout); -int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWORD nflags) +int AddNewMailsToListView(HWND hListView, HACCOUNT ActualAccount, struct CMailNumbers *MN, DWORD nflags) { HYAMNMAIL msgq; - POPUPDATAT NewMailPopup = {0}; + POPUPDATAT NewMailPopup = { 0 }; WCHAR *FromStr; WCHAR SizeStr[20]; WCHAR LocalDateStr[128]; LVITEMW item; - LVFINDINFO fi; + LVFINDINFO fi; - int foundi,lfoundi; + int foundi, lfoundi; struct CHeader UnicodeHeader; - BOOL Loaded,Extracted,FromStrNew=FALSE; + BOOL Loaded, Extracted, FromStrNew = FALSE; memset(&item, 0, sizeof(item)); memset(&UnicodeHeader, 0, sizeof(UnicodeHeader)); if (hListView != NULL) { - item.mask=LVIF_TEXT | LVIF_PARAM; - item.iItem=0; + item.mask = LVIF_TEXT | LVIF_PARAM; + item.iItem = 0; memset(&fi, 0, sizeof(fi)); - fi.flags=LVFI_PARAM; //let's go search item by lParam number - lfoundi=0; + fi.flags = LVFI_PARAM; //let's go search item by lParam number + lfoundi = 0; } - NewMailPopup.lchContact=(ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; - NewMailPopup.lchIcon=g_LoadIconEx(2); - NewMailPopup.colorBack=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupB : GetSysColor(COLOR_BTNFACE); - NewMailPopup.colorText=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupT : GetSysColor(COLOR_WINDOWTEXT); - NewMailPopup.iSeconds=ActualAccount->NewMailN.PopupTime; + NewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; + NewMailPopup.lchIcon = g_LoadIconEx(2); + NewMailPopup.colorBack = nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupB : GetSysColor(COLOR_BTNFACE); + NewMailPopup.colorText = nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupT : GetSysColor(COLOR_WINDOWTEXT); + NewMailPopup.iSeconds = ActualAccount->NewMailN.PopupTime; - NewMailPopup.PluginWindowProc=NewMailPopupProc; - NewMailPopup.PluginData=(void *)0; //it's new mail popup + NewMailPopup.PluginWindowProc = NewMailPopupProc; + NewMailPopup.PluginData = (void *)0; //it's new mail popup - for (msgq=(HYAMNMAIL)ActualAccount->Mails;msgq != NULL;msgq=msgq->Next,lfoundi++) + for (msgq = (HYAMNMAIL)ActualAccount->Mails; msgq != NULL; msgq = msgq->Next, lfoundi++) { -// now we hide mail pointer to item's lParam member. We can later use it to retrieve mail datas + // now we hide mail pointer to item's lParam member. We can later use it to retrieve mail datas - Extracted=FALSE;FromStr=NULL;FromStrNew=FALSE; + Extracted = FALSE; FromStr = NULL; FromStrNew = FALSE; if (hListView != NULL) { - fi.lParam=(LPARAM)msgq; - if (-1 != (foundi=ListView_FindItem(hListView,-1,&fi))) //if mail is already in window + fi.lParam = (LPARAM)msgq; + if (-1 != (foundi = ListView_FindItem(hListView, -1, &fi))) //if mail is already in window { - lfoundi=foundi; + lfoundi = foundi; continue; //do not insert any item } - item.iItem=lfoundi; //insert after last found item - item.lParam=(LPARAM)msgq; + item.iItem = lfoundi; //insert after last found item + item.lParam = (LPARAM)msgq; } if (!LoadedMailData(msgq)) //check if mail is already in memory { - Loaded=false; - if (NULL==LoadMailData(msgq)) //if we could not load mail to memory, consider this mail deleted and do not display it + Loaded = false; + if (NULL == LoadMailData(msgq)) //if we could not load mail to memory, consider this mail deleted and do not display it continue; } else - Loaded=true; + Loaded = true; if (((hListView != NULL) && (msgq->Flags & YAMN_MSG_DISPLAY)) || ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW))) { - if (!Extracted) ExtractHeader(msgq->MailData->TranslatedHeader,msgq->MailData->CP,&UnicodeHeader); - Extracted=TRUE; + if (!Extracted) ExtractHeader(msgq->MailData->TranslatedHeader, msgq->MailData->CP, &UnicodeHeader); + Extracted = TRUE; if ((UnicodeHeader.From != NULL) && (UnicodeHeader.FromNick != NULL)) { size_t size = wcslen(UnicodeHeader.From) + wcslen(UnicodeHeader.FromNick) + 4; @@ -561,13 +561,13 @@ int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumb FromStrNew = TRUE; } else if (UnicodeHeader.From != NULL) - FromStr=UnicodeHeader.From; + FromStr = UnicodeHeader.From; else if (UnicodeHeader.FromNick != NULL) - FromStr=UnicodeHeader.FromNick; + FromStr = UnicodeHeader.FromNick; else if (UnicodeHeader.ReturnPath != NULL) - FromStr=UnicodeHeader.ReturnPath; + FromStr = UnicodeHeader.ReturnPath; - if (NULL==FromStr) { + if (NULL == FromStr) { FromStr = L""; FromStrNew = FALSE; } @@ -576,28 +576,28 @@ int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumb if ((hListView != NULL) && (msgq->Flags & YAMN_MSG_DISPLAY)) { item.iSubItem = 0; item.pszText = FromStr; - item.iItem = SendMessageW(hListView,LVM_INSERTITEMW,0,(LPARAM)&item); + item.iItem = SendMessageW(hListView, LVM_INSERTITEMW, 0, (LPARAM)&item); item.iSubItem = 1; item.pszText = (NULL != UnicodeHeader.Subject ? UnicodeHeader.Subject : (WCHAR*)L""); - SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item); + SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); item.iSubItem = 2; mir_sntprintf(SizeStr, SIZEOF(SizeStr), L"%d kB", msgq->MailData->Size / 1024); item.pszText = SizeStr; - SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item); + SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); item.iSubItem = 3; item.pszText = L""; - + for (CMimeItem *heads = msgq->MailData->TranslatedHeader; heads != NULL; heads = heads->Next) { - if ( !_stricmp(heads->name, "Date")) { + if (!_stricmp(heads->name, "Date")) { MimeDateToLocalizedDateTime(heads->value, LocalDateStr, 128); item.pszText = LocalDateStr; break; } } - SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item); + SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); } if ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW)) { @@ -615,8 +615,8 @@ int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumb } if ((msgq->Flags & YAMN_MSG_UNSEEN) && (ActualAccount->NewMailN.Flags & YAMN_ACC_KBN)) - CallService(MS_KBDNOTIFY_EVENTSOPENED,1,NULL); - + CallService(MS_KBDNOTIFY_EVENTSOPENED, 1, NULL); + if (FromStrNew) delete[] FromStr; @@ -636,22 +636,22 @@ int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumb return TRUE; } -void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWORD nflags,DWORD nnflags) +void DoMailActions(HWND hDlg, HACCOUNT ActualAccount, struct CMailNumbers *MN, DWORD nflags, DWORD nnflags) { char *NotIconText = Translate("- new mail message(s)"); NOTIFYICONDATA nid; memset(&nid, 0, sizeof(nid)); - if (MN->Real.EventNC+MN->Virtual.EventNC) - NotifyEventHooks(hNewMailHook,0,0); + if (MN->Real.EventNC + MN->Virtual.EventNC) + NotifyEventHooks(hNewMailHook, 0, 0); - if ((nflags & YAMN_ACC_KBN) && (MN->Real.PopupRun+MN->Virtual.PopupRun)) + if ((nflags & YAMN_ACC_KBN) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) { - CallService(MS_KBDNOTIFY_STARTBLINK,(WPARAM)MN->Real.PopupNC+MN->Virtual.PopupNC,NULL); + CallService(MS_KBDNOTIFY_STARTBLINK, (WPARAM)MN->Real.PopupNC + MN->Virtual.PopupNC, NULL); } - if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun+MN->Virtual.PopupRun)) + if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun)) { char sMsg[250]; mir_snprintf(sMsg, SIZEOF(sMsg), Translate("%s : %d new mail message(s), %d total"), ActualAccount->Name, MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); @@ -665,27 +665,27 @@ void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWOR cEvent.pszService = MS_YAMN_CLISTDBLCLICK; cEvent.pszTooltip = sMsg; cEvent.flags = 0; - CallServiceSync(MS_CLIST_ADDEVENT, 0,(LPARAM)&cEvent); + CallServiceSync(MS_CLIST_ADDEVENT, 0, (LPARAM)&cEvent); } db_set_s(ActualAccount->hContact, "CList", "StatusMsg", sMsg); - + if (nflags & YAMN_ACC_CONTNICK) { - db_set_s(ActualAccount->hContact, YAMN_DBMODULE, "Nick",sMsg); + db_set_s(ActualAccount->hContact, YAMN_DBMODULE, "Nick", sMsg); } } - if ((nflags & YAMN_ACC_POP) && - !(ActualAccount->Flags & YAMN_ACC_POPN) && - (MN->Real.PopupRun+MN->Virtual.PopupRun)) + if ((nflags & YAMN_ACC_POP) && + !(ActualAccount->Flags & YAMN_ACC_POPN) && + (MN->Real.PopupRun + MN->Virtual.PopupRun)) { - POPUPDATAT NewMailPopup ={0}; + POPUPDATAT NewMailPopup = { 0 }; - NewMailPopup.lchContact=(ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; - NewMailPopup.lchIcon=g_LoadIconEx(2); - NewMailPopup.colorBack=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupB : GetSysColor(COLOR_BTNFACE); - NewMailPopup.colorText=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupT : GetSysColor(COLOR_WINDOWTEXT); - NewMailPopup.iSeconds=ActualAccount->NewMailN.PopupTime; + NewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; + NewMailPopup.lchIcon = g_LoadIconEx(2); + NewMailPopup.colorBack = nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupB : GetSysColor(COLOR_BTNFACE); + NewMailPopup.colorText = nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopupT : GetSysColor(COLOR_WINDOWTEXT); + NewMailPopup.iSeconds = ActualAccount->NewMailN.PopupTime; NewMailPopup.PluginWindowProc = NewMailPopupProc; NewMailPopup.PluginData = (void *)0; //multiple popups @@ -696,116 +696,116 @@ void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWOR } //destroy tray icon if no new mail - if ((MN->Real.SysTrayUC+MN->Virtual.SysTrayUC==0) && (hDlg != NULL)) + if ((MN->Real.SysTrayUC + MN->Virtual.SysTrayUC == 0) && (hDlg != NULL)) { - nid.hWnd=hDlg; - nid.uID=0; - Shell_NotifyIcon(NIM_DELETE,&nid); + nid.hWnd = hDlg; + nid.uID = 0; + Shell_NotifyIcon(NIM_DELETE, &nid); } //and remove the event - if ((nflags & YAMN_ACC_CONT) && (!(nflags & YAMN_ACC_CONTNOEVENT)) && (MN->Real.UnSeen + MN->Virtual.UnSeen==0)) { - CallService(MS_CLIST_REMOVEEVENT,(WPARAM)ActualAccount->hContact,(LPARAM)ActualAccount->hContact); + if ((nflags & YAMN_ACC_CONT) && (!(nflags & YAMN_ACC_CONTNOEVENT)) && (MN->Real.UnSeen + MN->Virtual.UnSeen == 0)) { + CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ActualAccount->hContact, (LPARAM)ActualAccount->hContact); } - if ((MN->Real.BrowserUC+MN->Virtual.BrowserUC==0) && (hDlg != NULL)) + if ((MN->Real.BrowserUC + MN->Virtual.BrowserUC == 0) && (hDlg != NULL)) { if (!IsWindowVisible(hDlg) && !(nflags & YAMN_ACC_MSG)) - PostMessage(hDlg,WM_DESTROY,0,0); //destroy window if no new mail and window is not visible + PostMessage(hDlg, WM_DESTROY, 0, 0); //destroy window if no new mail and window is not visible if (nnflags & YAMN_ACC_MSG) //if no new mail and msg should be executed { SetForegroundWindow(hDlg); - ShowWindow(hDlg,SW_SHOWNORMAL); + ShowWindow(hDlg, SW_SHOWNORMAL); } } - else + else if (hDlg != NULL) //else insert icon and set window if new mails { SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_SCROLL, 0, (LPARAM)0x7ffffff); - if ((nflags & YAMN_ACC_ICO) && (MN->Real.SysTrayUC+MN->Virtual.SysTrayUC)) + if ((nflags & YAMN_ACC_ICO) && (MN->Real.SysTrayUC + MN->Virtual.SysTrayUC)) { char* src; TCHAR *dest; int i; - for (src=ActualAccount->Name,dest=nid.szTip,i=0;(*src != (TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++); - for (src=NotIconText;(*src != (TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++); - *dest=(TCHAR)0; - nid.cbSize=sizeof(NOTIFYICONDATA); - nid.hWnd=hDlg; - nid.hIcon=g_LoadIconEx(2); - nid.uID=0; - nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP; - nid.uCallbackMessage=WM_YAMN_NOTIFYICON; - Shell_NotifyIcon(NIM_ADD,&nid); - SetTimer(hDlg,TIMER_FLASHING,500,NULL); + for (src = ActualAccount->Name, dest = nid.szTip, i = 0; (*src != (TCHAR)0) && (i + 1 < sizeof(nid.szTip)); *dest++ = *src++); + for (src = NotIconText; (*src != (TCHAR)0) && (i + 1 < sizeof(nid.szTip)); *dest++ = *src++); + *dest = (TCHAR)0; + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hDlg; + nid.hIcon = g_LoadIconEx(2); + nid.uID = 0; + nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + nid.uCallbackMessage = WM_YAMN_NOTIFYICON; + Shell_NotifyIcon(NIM_ADD, &nid); + SetTimer(hDlg, TIMER_FLASHING, 500, NULL); } if (nflags & YAMN_ACC_MSG) //if no new mail and msg should be executed - ShowWindow(hDlg,SW_SHOWNORMAL); + ShowWindow(hDlg, SW_SHOWNORMAL); } - if (MN->Real.AppNC+MN->Virtual.AppNC != 0) + if (MN->Real.AppNC + MN->Virtual.AppNC != 0) { if (nflags & YAMN_ACC_APP) { PROCESS_INFORMATION pi; STARTUPINFOW si; memset(&si, 0, sizeof(si)); - si.cb=sizeof(si); + si.cb = sizeof(si); if (ActualAccount->NewMailN.App != NULL) { WCHAR *Command; if (ActualAccount->NewMailN.AppParam != NULL) - Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+wcslen(ActualAccount->NewMailN.AppParam)+6]; + Command = new WCHAR[wcslen(ActualAccount->NewMailN.App) + wcslen(ActualAccount->NewMailN.AppParam) + 6]; else - Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+6]; - + Command = new WCHAR[wcslen(ActualAccount->NewMailN.App) + 6]; + if (Command != NULL) { - mir_wstrcpy(Command,L"\""); - mir_wstrcat(Command,ActualAccount->NewMailN.App); - mir_wstrcat(Command,L"\" "); + mir_wstrcpy(Command, L"\""); + mir_wstrcat(Command, ActualAccount->NewMailN.App); + mir_wstrcat(Command, L"\" "); if (ActualAccount->NewMailN.AppParam != NULL) - mir_wstrcat(Command,ActualAccount->NewMailN.AppParam); - CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); + mir_wstrcat(Command, ActualAccount->NewMailN.AppParam); + CreateProcessW(NULL, Command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); delete[] Command; } } } } - if (MN->Real.SoundNC+MN->Virtual.SoundNC != 0) + if (MN->Real.SoundNC + MN->Virtual.SoundNC != 0) if (nflags & YAMN_ACC_SND) - CallService(MS_SKIN_PLAYSOUND,0,(LPARAM)YAMN_NEWMAILSOUND); + CallService(MS_SKIN_PLAYSOUND, 0, (LPARAM)YAMN_NEWMAILSOUND); - if ((nnflags & YAMN_ACC_POP) && (MN->Real.PopupRun+MN->Virtual.PopupRun==0)) + if ((nnflags & YAMN_ACC_POP) && (MN->Real.PopupRun + MN->Virtual.PopupRun == 0)) { POPUPDATAT NoNewMailPopup; - NoNewMailPopup.lchContact=(ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; - NoNewMailPopup.lchIcon=g_LoadIconEx(1); - NoNewMailPopup.colorBack=ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? ActualAccount->NoNewMailN.PopupB : GetSysColor(COLOR_BTNFACE); - NoNewMailPopup.colorText=ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? ActualAccount->NoNewMailN.PopupT : GetSysColor(COLOR_WINDOWTEXT); - NoNewMailPopup.iSeconds=ActualAccount->NoNewMailN.PopupTime; + NoNewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (MCONTACT)ActualAccount; + NoNewMailPopup.lchIcon = g_LoadIconEx(1); + NoNewMailPopup.colorBack = ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? ActualAccount->NoNewMailN.PopupB : GetSysColor(COLOR_BTNFACE); + NoNewMailPopup.colorText = ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? ActualAccount->NoNewMailN.PopupT : GetSysColor(COLOR_WINDOWTEXT); + NoNewMailPopup.iSeconds = ActualAccount->NoNewMailN.PopupTime; - NoNewMailPopup.PluginWindowProc=NoNewMailPopupProc; - NoNewMailPopup.PluginData=(void *)0; //it's not new mail popup + NoNewMailPopup.PluginWindowProc = NoNewMailPopupProc; + NoNewMailPopup.PluginData = (void *)0; //it's not new mail popup - mir_tstrncpy(NoNewMailPopup.lptzContactName,_A2T(ActualAccount->Name),SIZEOF(NoNewMailPopup.lptzContactName)); - if (MN->Real.PopupSL2NC+MN->Virtual.PopupSL2NC) + mir_tstrncpy(NoNewMailPopup.lptzContactName, _A2T(ActualAccount->Name), SIZEOF(NoNewMailPopup.lptzContactName)); + if (MN->Real.PopupSL2NC + MN->Virtual.PopupSL2NC) mir_sntprintf(NoNewMailPopup.lptzText, SIZEOF(NoNewMailPopup.lptzText), TranslateT("No new mail message, %d spam(s)"), MN->Real.PopupSL2NC + MN->Virtual.PopupSL2NC); else - mir_tstrncpy(NoNewMailPopup.lptzText,TranslateT("No new mail message"),SIZEOF(NoNewMailPopup.lptzText)); + mir_tstrncpy(NoNewMailPopup.lptzText, TranslateT("No new mail message"), SIZEOF(NoNewMailPopup.lptzText)); PUAddPopupT(&NoNewMailPopup); } - if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun+MN->Virtual.PopupRun==0)) + if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopupRun + MN->Virtual.PopupRun == 0)) { if (ActualAccount->hContact != NULL) { - if (MN->Real.PopupTC+MN->Virtual.PopupTC) + if (MN->Real.PopupTC + MN->Virtual.PopupTC) { char tmp[255]; mir_snprintf(tmp, SIZEOF(tmp), Translate("%d new mail message(s), %d total"), MN->Real.PopupNC + MN->Virtual.PopupNC, MN->Real.PopupTC + MN->Virtual.PopupTC); @@ -820,231 +820,232 @@ void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWOR return; } -DWORD WINAPI ShowEmailThread(LPVOID Param); -LRESULT CALLBACK NewMailPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) +void __cdecl ShowEmailThread(void *Param); +LRESULT CALLBACK NewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - INT_PTR PluginParam=0; - switch(msg) + INT_PTR PluginParam = 0; + switch (msg) { - case WM_COMMAND: - //if clicked and it's new mail popup window - if ((HIWORD(wParam)==STN_CLICKED) && (-1 != (PluginParam=CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hWnd,(LPARAM)&PluginParam)))) - { - MCONTACT hContact = 0; - HACCOUNT Account; - if (PluginParam) { - PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM; - memcpy(MailParam,(PINT_PTR)PluginParam,sizeof(YAMN_MAILSHOWPARAM)); - hContact = MailParam->account->hContact; - Account = MailParam->account; - if (NULL != (MailParam->ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL))) { - HANDLE NewThread; - if (NULL != (NewThread=CreateThread(NULL,0,ShowEmailThread,(LPVOID)MailParam,0,NULL))) - { - CloseHandle(NewThread); - } - CloseHandle(MailParam->ThreadRunningEV); - } - //delete MailParam; - } else { - DBVARIANT dbv; - - hContact=(MCONTACT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0); - - if (!db_get((MCONTACT)hContact,YAMN_DBMODULE,"Id",&dbv)) - { - Account=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal); - db_free(&dbv); - } - else - Account = (HACCOUNT)hContact; //???? - - - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); - #endif - if (WAIT_OBJECT_0==WaitToReadFcn(Account->AccountAccessSO)) + case WM_COMMAND: + //if clicked and it's new mail popup window + if ((HIWORD(wParam) == STN_CLICKED) && (-1 != (PluginParam = CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&PluginParam)))) + { + MCONTACT hContact = 0; + HACCOUNT Account; + if (PluginParam) { + PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM; + memcpy(MailParam, (PINT_PTR)PluginParam, sizeof(YAMN_MAILSHOWPARAM)); + hContact = MailParam->account->hContact; + Account = MailParam->account; + if (NULL != (MailParam->ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { + HANDLE NewThread; + if (NULL != (NewThread = mir_forkthread(ShowEmailThread, (void*)MailParam))) { - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); - #endif - switch(msg) - { - case WM_COMMAND: - { - YAMN_MAILBROWSERPARAM Param={(HANDLE)0,Account, - (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG, - (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG}; - - RunMailBrowserSvc((WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION); - } - break; - } - #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); - #endif - ReadDoneFcn(Account->AccountAccessSO); + CloseHandle(NewThread); } - #ifdef DEBUG_SYNCHRO - else - DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); - #endif - } - if ((Account->NewMailN.Flags & YAMN_ACC_CONT) && !(Account->NewMailN.Flags & YAMN_ACC_CONTNOEVENT)) { - CallService(MS_CLIST_REMOVEEVENT, hContact, hContact); + CloseHandle(MailParam->ThreadRunningEV); } + //delete MailParam; } - // fall through - case WM_CONTEXTMENU: - SendMessageW(hWnd,UM_DESTROYPOPUP,0,0); - break; - case UM_FREEPLUGINDATA:{ - PYAMN_MAILSHOWPARAM mpd = (PYAMN_MAILSHOWPARAM)PUGetPluginData(hWnd); - MCONTACT hContact = 0; - if ((mpd) && (INT_PTR)mpd != -1)free(mpd); - return FALSE; - } - case UM_INITPOPUP: - //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. - WindowList_Add(YAMNVar.MessageWnds,hWnd,NULL); - break; - case UM_DESTROYPOPUP: - WindowList_Remove(YAMNVar.MessageWnds,hWnd); - break; - case WM_YAMN_STOPACCOUNT: - { - HACCOUNT ActualAccount; - MCONTACT hContact; - DBVARIANT dbv; - - hContact=(MCONTACT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0); - - if (!db_get((MCONTACT) hContact,YAMN_DBMODULE,"Id",&dbv)) - { - ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal); - db_free(&dbv); - } - else - ActualAccount = (HACCOUNT) hContact; - - if ((HACCOUNT)wParam != ActualAccount) - break; - DestroyWindow(hWnd); - return 0; - } - case WM_NOTIFY: - default: - break; - } - return DefWindowProc(hWnd,msg,wParam,lParam); -} - -LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) - { - case WM_COMMAND: - if ((HIWORD(wParam)==STN_CLICKED) && (msg==WM_COMMAND)) - { - HACCOUNT ActualAccount; - MCONTACT hContact; + else { DBVARIANT dbv; - hContact=(MCONTACT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0); + hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); - if (!db_get((MCONTACT)hContact,YAMN_DBMODULE,"Id",&dbv)) + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) { - ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal); + Account = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); db_free(&dbv); } else - ActualAccount = (HACCOUNT) hContact; + Account = (HACCOUNT)hContact; //???? - #ifdef DEBUG_SYNCHRO + +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); - #endif - if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) +#endif + if (WAIT_OBJECT_0 == WaitToReadFcn(Account->AccountAccessSO)) { - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); - #endif - switch(msg) +#endif + switch (msg) { - case WM_COMMAND: - { - YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualAccount->NewMailN.Flags,ActualAccount->NoNewMailN.Flags,0}; - - Param.nnflags=Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account - Param.nnflags=Param.nnflags & ~YAMN_ACC_POP; - - Param.nflags=Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account - Param.nflags=Param.nflags & ~YAMN_ACC_POP; + case WM_COMMAND: + { + YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, Account, + (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG, + (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG }; - RunMailBrowserSvc((WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION); - } - break; + RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); } - #ifdef DEBUG_SYNCHRO + break; + } +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); - #endif - ReadDoneFcn(ActualAccount->AccountAccessSO); +#endif + ReadDoneFcn(Account->AccountAccessSO); } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO else DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); - #endif - SendMessageW(hWnd,UM_DESTROYPOPUP,0,0); +#endif } - break; - - case WM_CONTEXTMENU: - SendMessageW(hWnd,UM_DESTROYPOPUP,0,0); - break; + if ((Account->NewMailN.Flags & YAMN_ACC_CONT) && !(Account->NewMailN.Flags & YAMN_ACC_CONTNOEVENT)) { + CallService(MS_CLIST_REMOVEEVENT, hContact, hContact); + } + } + // fall through + case WM_CONTEXTMENU: + SendMessageW(hWnd, UM_DESTROYPOPUP, 0, 0); + break; + case UM_FREEPLUGINDATA:{ + PYAMN_MAILSHOWPARAM mpd = (PYAMN_MAILSHOWPARAM)PUGetPluginData(hWnd); + MCONTACT hContact = 0; + if ((mpd) && (INT_PTR)mpd != -1)free(mpd); + return FALSE; + } + case UM_INITPOPUP: + //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. + WindowList_Add(YAMNVar.MessageWnds, hWnd, NULL); + break; + case UM_DESTROYPOPUP: + WindowList_Remove(YAMNVar.MessageWnds, hWnd); + break; + case WM_YAMN_STOPACCOUNT: + { + HACCOUNT ActualAccount; + MCONTACT hContact; + DBVARIANT dbv; - case UM_FREEPLUGINDATA: - //Here we'd free our own data, if we had it. - return FALSE; - case UM_INITPOPUP: - //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. - WindowList_Add(YAMNVar.MessageWnds,hWnd,NULL); - break; - case UM_DESTROYPOPUP: - WindowList_Remove(YAMNVar.MessageWnds,hWnd); + hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); + + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) + { + ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); + db_free(&dbv); + } + else + ActualAccount = (HACCOUNT)hContact; + + if ((HACCOUNT)wParam != ActualAccount) break; - case WM_YAMN_STOPACCOUNT: + DestroyWindow(hWnd); + return 0; + } + case WM_NOTIFY: + default: + break; + } + return DefWindowProc(hWnd, msg, wParam, lParam); +} + +LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_COMMAND: + if ((HIWORD(wParam) == STN_CLICKED) && (msg == WM_COMMAND)) { HACCOUNT ActualAccount; MCONTACT hContact; DBVARIANT dbv; - hContact=(MCONTACT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0); + hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); - if (!db_get((MCONTACT) hContact,YAMN_DBMODULE,"Id",&dbv)) + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) { - ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal); + ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); db_free(&dbv); } else - ActualAccount = (HACCOUNT) hContact; - - if ((HACCOUNT)wParam != ActualAccount) - break; + ActualAccount = (HACCOUNT)hContact; - DestroyWindow(hWnd); - return 0; - } - case WM_NOTIFY: -/* switch(((LPNMHDR)lParam)->code) +#ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read wait\n"); +#endif + if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) { - case NM_CLICK: +#ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter\n"); +#endif + switch (msg) { + case WM_COMMAND: + { + YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, 0 }; + + Param.nnflags = Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account + Param.nnflags = Param.nnflags & ~YAMN_ACC_POP; + + Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account + Param.nflags = Param.nflags & ~YAMN_ACC_POP; + + RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION); } + break; + } +#ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read done\n"); +#endif + ReadDoneFcn(ActualAccount->AccountAccessSO); } +#ifdef DEBUG_SYNCHRO + else + DebugLog(SynchroFile,"PopupProc:LEFTCLICK:ActualAccountSO-read enter failed\n"); +#endif + SendMessageW(hWnd, UM_DESTROYPOPUP, 0, 0); + } + break; + + case WM_CONTEXTMENU: + SendMessageW(hWnd, UM_DESTROYPOPUP, 0, 0); + break; + + case UM_FREEPLUGINDATA: + //Here we'd free our own data, if we had it. + return FALSE; + case UM_INITPOPUP: + //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups. + WindowList_Add(YAMNVar.MessageWnds, hWnd, NULL); + break; + case UM_DESTROYPOPUP: + WindowList_Remove(YAMNVar.MessageWnds, hWnd); + break; + case WM_YAMN_STOPACCOUNT: + { + HACCOUNT ActualAccount; + MCONTACT hContact; + DBVARIANT dbv; + + hContact = (MCONTACT)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0); + + if (!db_get((MCONTACT)hContact, YAMN_DBMODULE, "Id", &dbv)) + { + ActualAccount = (HACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal); + db_free(&dbv); + } + else + ActualAccount = (HACCOUNT)hContact; + + if ((HACCOUNT)wParam != ActualAccount) break; -*/ default: - break; + + DestroyWindow(hWnd); + return 0; } - return DefWindowProc(hWnd,msg,wParam,lParam); + case WM_NOTIFY: + /* switch(((LPNMHDR)lParam)->code) + { + case NM_CLICK: + { + } + } + break; + */ default: + break; + } + return DefWindowProc(hWnd, msg, wParam, lParam); } #ifdef __GNUC__ @@ -1059,10 +1060,10 @@ LRESULT CALLBACK NoNewMailPopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lPar ULONGLONG MimeDateToFileTime(char *datein) { - char *day=0, *month=0, *year=0, *time=0, *shift=0; + char *day = 0, *month = 0, *year = 0, *time = 0, *shift = 0; SYSTEMTIME st; - ULONGLONG res=0; - int wShiftSeconds = CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0); + ULONGLONG res = 0; + int wShiftSeconds = CallService(MS_DB_TIME_TIMESTAMPTOLOCAL, 0, 0); GetLocalTime(&st); //datein = "Xxx, 1 Jan 2060 5:29:1 +0530 XXX"; //datein = "Xxx, 1 Jan 2060 05:29:10 "; @@ -1070,70 +1071,75 @@ ULONGLONG MimeDateToFileTime(char *datein) //datein = "Xxx, 35 February 20 :29:10 "; //datein = "01.12.2007 (22:38:17)"; // if (datein) { - char tmp [64]; - while ( datein[0]==' ') datein++; // eat leading spaces - strncpy(tmp,datein,63); tmp [63]=0; + char tmp[64]; + while (datein[0] == ' ') datein++; // eat leading spaces + strncpy(tmp, datein, 63); tmp[63] = 0; if (atoi(tmp)) { // Parseable integer on DayOfWeek field? Buggy mime date. day = tmp; - } else { + } + else { int i = 0; - while (tmp[i]==' ')i++; if (day = strchr(&tmp[i],' ')) {day[0]=0; day++;} + while (tmp[i] == ' ')i++; if (day = strchr(&tmp[i], ' ')) { day[0] = 0; day++; } } - if (day) {while ( day[0]==' ') day++;if (month= strchr(day, ' ')) {month[0]=0; month++;}} - if (month) {while (month[0]==' ')month++;if (year = strchr(month,' ')) { year[0]=0; year++;}} - if (year) {while ( year[0]==' ') year++;if (time = strchr(year, ' ')) { time[0]=0; time++;}} - if (time) {while ( time[0]==' ') time++;if (shift= strchr(time, ' ')) {shift[0]=0; shift++;shift[5]=0;}} + if (day) { while (day[0] == ' ') day++; if (month = strchr(day, ' ')) { month[0] = 0; month++; } } + if (month) { while (month[0] == ' ')month++; if (year = strchr(month, ' ')) { year[0] = 0; year++; } } + if (year) { while (year[0] == ' ') year++; if (time = strchr(year, ' ')) { time[0] = 0; time++; } } + if (time) { while (time[0] == ' ') time++; if (shift = strchr(time, ' ')) { shift[0] = 0; shift++; shift[5] = 0; } } if (year) { st.wYear = atoi(year); - if (strlen(year)<4) if (st.wYear<70)st.wYear += 2000; else st.wYear += 1900; + if (strlen(year) < 4) if (st.wYear < 70)st.wYear += 2000; else st.wYear += 1900; }; - if (month) for (int i=0;i<12;i++) if (strncmp(month,s_MonthNames[i],3)==0) {st.wMonth = i + 1; break;} + if (month) for (int i = 0; i < 12; i++) if (strncmp(month, s_MonthNames[i], 3) == 0) { st.wMonth = i + 1; break; } if (day) st.wDay = atoi(day); if (time) { char *h, *m, *s; h = time; - if (m = strchr(h,':')) { - m[0]=0; m++; - if (s = strchr(m,':')) {s[0] = 0; s++;} - } else s=0; + if (m = strchr(h, ':')) { + m[0] = 0; m++; + if (s = strchr(m, ':')) { s[0] = 0; s++; } + } + else s = 0; st.wHour = atoi(h); - st.wMinute = m?atoi(m):0; - st.wSecond = s?atoi(s):0; - } else {st.wHour=st.wMinute=st.wSecond=0;} + st.wMinute = m ? atoi(m) : 0; + st.wSecond = s ? atoi(s) : 0; + } + else { st.wHour = st.wMinute = st.wSecond = 0; } if (shift) { - if (strlen(shift)<4) { + if (strlen(shift) < 4) { //has only hour - wShiftSeconds = (atoi(shift))*3600; - } else { - char *smin = shift + strlen(shift)-2; + wShiftSeconds = (atoi(shift)) * 3600; + } + else { + char *smin = shift + strlen(shift) - 2; int ismin = atoi(smin); smin[0] = 0; int ishour = atoi(shift); - wShiftSeconds = (ishour*60+(ishour<0?-1:1)*ismin)*60; + wShiftSeconds = (ishour * 60 + (ishour < 0 ? -1 : 1)*ismin) * 60; } } } // if (datein) FILETIME ft; - if (SystemTimeToFileTime(&st,&ft)) { - res = ((ULONGLONG)ft.dwHighDateTime<<32)|((ULONGLONG)ft.dwLowDateTime); - LONGLONG w100nano = Int32x32To64((DWORD)wShiftSeconds,10000000); - res -= w100nano; - }else{ - res=0; + if (SystemTimeToFileTime(&st, &ft)) { + res = ((ULONGLONG)ft.dwHighDateTime << 32) | ((ULONGLONG)ft.dwLowDateTime); + LONGLONG w100nano = Int32x32To64((DWORD)wShiftSeconds, 10000000); + res -= w100nano; + } + else{ + res = 0; } return res; } void FileTimeToLocalizedDateTime(LONGLONG filetime, WCHAR *dateout, int lendateout) { - int localeID = CallService(MS_LANGPACK_GETLOCALE,0,0); + int localeID = CallService(MS_LANGPACK_GETLOCALE, 0, 0); //int localeID = MAKELCID(LANG_URDU, SORT_DEFAULT); - if (localeID==CALLSERVICE_NOTFOUND) localeID=LOCALE_USER_DEFAULT; - if (filetime>MAXFILETIME) filetime = MAXFILETIME; - else if (filetime<=0) { - wcsncpy(dateout,TranslateW(L"Invalid"),lendateout); + if (localeID == CALLSERVICE_NOTFOUND) localeID = LOCALE_USER_DEFAULT; + if (filetime > MAXFILETIME) filetime = MAXFILETIME; + else if (filetime <= 0) { + wcsncpy(dateout, TranslateW(L"Invalid"), lendateout); return; } SYSTEMTIME st; @@ -1149,23 +1155,25 @@ void FileTimeToLocalizedDateTime(LONGLONG filetime, WCHAR *dateout, int lendateo ft.dwLowDateTime = (DWORD)filetime; ft.dwHighDateTime = (DWORD)(filetime >> 32); FILETIME localft; - if (!FileTimeToLocalFileTime(&ft,&localft)) { - // this should never happen - wcsncpy(dateout,L"Incorrect FileTime",lendateout); - } else { - if (!FileTimeToSystemTime(&localft,&st)) { + if (!FileTimeToLocalFileTime(&ft, &localft)) { + // this should never happen + wcsncpy(dateout, L"Incorrect FileTime", lendateout); + } + else { + if (!FileTimeToSystemTime(&localft, &st)) { // this should never happen - wcsncpy(dateout,L"Incorrect LocalFileTime",lendateout); - } else { - dateout[lendateout-1]=0; + wcsncpy(dateout, L"Incorrect LocalFileTime", lendateout); + } + else { + dateout[lendateout - 1] = 0; int templen = 0; - if (!willShowDate) willShowDate = (wTodayYear != st.wYear)||(wTodayMonth != st.wMonth)||(wTodayDay != st.wDay); + if (!willShowDate) willShowDate = (wTodayYear != st.wYear) || (wTodayMonth != st.wMonth) || (wTodayDay != st.wDay); if (willShowDate) { - templen = GetDateFormatW(localeID,(optDateTime&SHOWDATELONG)?DATE_LONGDATE:DATE_SHORTDATE,&st,NULL,dateout,lendateout-2); - dateout[templen-1] = ' '; + templen = GetDateFormatW(localeID, (optDateTime&SHOWDATELONG) ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, dateout, lendateout - 2); + dateout[templen - 1] = ' '; } - if (templen<(lendateout-1)) { - GetTimeFormatW(localeID,(optDateTime&SHOWDATENOSECONDS)?TIME_NOSECONDS:0,&st,NULL,&dateout[templen],lendateout-templen-1); + if (templen < (lendateout - 1)) { + GetTimeFormatW(localeID, (optDateTime&SHOWDATENOSECONDS) ? TIME_NOSECONDS : 0, &st, NULL, &dateout[templen], lendateout - templen - 1); } } } @@ -1174,88 +1182,88 @@ void FileTimeToLocalizedDateTime(LONGLONG filetime, WCHAR *dateout, int lendateo void MimeDateToLocalizedDateTime(char *datein, WCHAR *dateout, int lendateout) { ULONGLONG ft = MimeDateToFileTime(datein); - FileTimeToLocalizedDateTime(ft,dateout,lendateout); + FileTimeToLocalizedDateTime(ft, dateout, lendateout); } -int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2,LPARAM lParamSort ) { +int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { if (lParam1 == NULL || lParam2 == NULL) return 0; - int nResult = 0; + int nResult = 0; char *str1; char *str2; - HYAMNMAIL email1 = (HYAMNMAIL)lParam1; - HYAMNMAIL email2 = (HYAMNMAIL)lParam2; + HYAMNMAIL email1 = (HYAMNMAIL)lParam1; + HYAMNMAIL email2 = (HYAMNMAIL)lParam2; struct CShortHeader Header1; struct CShortHeader Header2; memset(&Header1, 0, sizeof(Header1)); memset(&Header2, 0, sizeof(Header2)); try { - ExtractShortHeader(email1->MailData->TranslatedHeader,&Header1); - ExtractShortHeader(email2->MailData->TranslatedHeader,&Header2); + ExtractShortHeader(email1->MailData->TranslatedHeader, &Header1); + ExtractShortHeader(email2->MailData->TranslatedHeader, &Header2); - switch((int)lParamSort) + switch ((int)lParamSort) { - case 0: //From - if (Header1.FromNick == NULL) - str1 = Header1.From; - else str1 = Header1.FromNick; + case 0: //From + if (Header1.FromNick == NULL) + str1 = Header1.From; + else str1 = Header1.FromNick; - if (Header2.FromNick == NULL) - str2 = Header2.From; - else str2 = Header2.FromNick; + if (Header2.FromNick == NULL) + str2 = Header2.From; + else str2 = Header2.FromNick; - nResult = strcmp(str1, str2); + nResult = strcmp(str1, str2); - if (bFrom) nResult = -nResult; - break; - case 1: //Subject - if (Header1.Subject == NULL) - str1 = " "; - else str1 = Header1.Subject; + if (bFrom) nResult = -nResult; + break; + case 1: //Subject + if (Header1.Subject == NULL) + str1 = " "; + else str1 = Header1.Subject; - if (Header2.Subject == NULL) - str2 = " "; - else str2 = Header2.Subject; + if (Header2.Subject == NULL) + str2 = " "; + else str2 = Header2.Subject; - nResult = strcmp(str1, str2); + nResult = strcmp(str1, str2); - if (bSub) nResult = -nResult; - break; - case 2: //Size - if (email1->MailData->Size == email2->MailData->Size) nResult = 0; - if (email1->MailData->Size > email2->MailData->Size) nResult = 1; - if (email1->MailData->Size < email2->MailData->Size) nResult = -1; + if (bSub) nResult = -nResult; + break; + case 2: //Size + if (email1->MailData->Size == email2->MailData->Size) nResult = 0; + if (email1->MailData->Size > email2->MailData->Size) nResult = 1; + if (email1->MailData->Size < email2->MailData->Size) nResult = -1; - if (bSize) nResult = -nResult; - break; + if (bSize) nResult = -nResult; + break; - case 3: //Date - { - ULONGLONG ts1 = 0, ts2 = 0; - ts1 = MimeDateToFileTime(Header1.Date); - ts2 = MimeDateToFileTime(Header2.Date); - if (ts1 > ts2) nResult = 1; - else if (ts1 < ts2) nResult = -1; - else nResult = 0; - } - if (bDate) nResult = -nResult; - break; + case 3: //Date + { + ULONGLONG ts1 = 0, ts2 = 0; + ts1 = MimeDateToFileTime(Header1.Date); + ts2 = MimeDateToFileTime(Header2.Date); + if (ts1 > ts2) nResult = 1; + else if (ts1 < ts2) nResult = -1; + else nResult = 0; + } + if (bDate) nResult = -nResult; + break; - default: - if (Header1.Subject == NULL) str1 = " "; - else str1 = Header1.Subject; + default: + if (Header1.Subject == NULL) str1 = " "; + else str1 = Header1.Subject; - if (Header2.Subject == NULL) str2 = " "; - else str2 = Header2.Subject; + if (Header2.Subject == NULL) str2 = " "; + else str2 = Header2.Subject; - nResult = strcmp(str1, str2); - break; + nResult = strcmp(str1, str2); + break; } //MessageBox(NULL,str1,str2,0); } - catch( ... ) + catch (...) { } @@ -1264,7 +1272,7 @@ int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2,LPARAM lParamSor DeleteShortHeaderContent(&Header2); return nResult; -} +} HCURSOR hCurSplitNS, hCurSplitWE; #define DM_SPLITTERMOVED (WM_USER+15) @@ -1287,7 +1295,7 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (GetCapture() == hwnd) { RECT rc; GetClientRect(hwnd, &rc); - SendMessage(GetParent(hwnd), DM_SPLITTERMOVED, (short) HIWORD(GetMessagePos()) + rc.bottom / 2, (LPARAM) hwnd); + SendMessage(GetParent(hwnd), DM_SPLITTERMOVED, (short)HIWORD(GetMessagePos()) + rc.bottom / 2, (LPARAM)hwnd); } return 0; @@ -1298,221 +1306,224 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return mir_callNextSubclass(hwnd, SplitterSubclassProc, msg, wParam, lParam); } -void ConvertCodedStringToUnicode(char *stream,WCHAR **storeto,DWORD cp,int mode); -int ConvertStringToUnicode(char *stream,unsigned int cp,WCHAR **out); +void ConvertCodedStringToUnicode(char *stream, WCHAR **storeto, DWORD cp, int mode); +int ConvertStringToUnicode(char *stream, unsigned int cp, WCHAR **out); -INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_INITDIALOG: - { - PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)lParam; - WCHAR *iHeaderW=NULL; - WCHAR *iValueW=NULL; - int StrLen; - HWND hListView = GetDlgItem(hDlg,IDC_LISTHEADERS); - mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterSubclassProc); - SetWindowLongPtr(hDlg,DWLP_USER,(LONG_PTR)MailParam); - SendMessageW(hDlg,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)g_LoadIconEx(2, true)); - SendMessageW(hDlg,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)g_LoadIconEx(2)); - - ListView_SetUnicodeFormat(hListView,TRUE); - ListView_SetExtendedListViewStyle(hListView,LVS_EX_FULLROWSELECT); - - StrLen=MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Header"),-1,NULL,0); - iHeaderW=new WCHAR[StrLen+1]; - MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Header"),-1,iHeaderW,StrLen); - - StrLen=MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Value"),-1,NULL,0); - iValueW=new WCHAR[StrLen+1]; - MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Value"),-1,iValueW,StrLen); - - LVCOLUMNW lvc0={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,130,iHeaderW,0,0}; - LVCOLUMNW lvc1={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,400,iValueW,0,0}; - SendMessageW(hListView,LVM_INSERTCOLUMNW,0,(LPARAM)&lvc0); - SendMessageW(hListView,LVM_INSERTCOLUMNW,1,(LPARAM)&lvc1); - if (NULL != iHeaderW) - delete[] iHeaderW; - if (NULL != iValueW) - delete[] iValueW; - - //WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL); - //WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg,ActualAccount); - SendMessage(hDlg,WM_YAMN_CHANGECONTENT,0,(LPARAM)MailParam); - MoveWindow(hDlg,HeadPosX,HeadPosY,HeadSizeX,HeadSizeY,0); - ShowWindow(hDlg,SW_SHOWNORMAL); - } - break; + { + PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)lParam; + WCHAR *iHeaderW = NULL; + WCHAR *iValueW = NULL; + int StrLen; + HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); + mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterSubclassProc); + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)MailParam); + SendMessageW(hDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)g_LoadIconEx(2, true)); + SendMessageW(hDlg, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_LoadIconEx(2)); + + ListView_SetUnicodeFormat(hListView, TRUE); + ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT); + + StrLen = MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Header"), -1, NULL, 0); + iHeaderW = new WCHAR[StrLen + 1]; + MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Header"), -1, iHeaderW, StrLen); + + StrLen = MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Value"), -1, NULL, 0); + iValueW = new WCHAR[StrLen + 1]; + MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, Translate("Value"), -1, iValueW, StrLen); + + LVCOLUMNW lvc0 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, 130, iHeaderW, 0, 0 }; + LVCOLUMNW lvc1 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, 400, iValueW, 0, 0 }; + SendMessageW(hListView, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); + SendMessageW(hListView, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); + if (NULL != iHeaderW) + delete[] iHeaderW; + if (NULL != iValueW) + delete[] iValueW; + + //WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL); + //WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg,ActualAccount); + SendMessage(hDlg, WM_YAMN_CHANGECONTENT, 0, (LPARAM)MailParam); + MoveWindow(hDlg, HeadPosX, HeadPosY, HeadSizeX, HeadSizeY, 0); + ShowWindow(hDlg, SW_SHOWNORMAL); + } + break; case WM_YAMN_CHANGECONTENT: + { + PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) + (lParam ? lParam : GetWindowLongPtr(hDlg, DWLP_USER)); + HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); + HWND hEdit = GetDlgItem(hDlg, IDC_EDITBODY); + //do not redraw + SendMessage(hListView, WM_SETREDRAW, 0, 0); + ListView_DeleteAllItems(hListView); + struct CMimeItem *Header; + LVITEMW item; + item.mask = LVIF_TEXT | LVIF_PARAM; + WCHAR *From = 0, *Subj = 0; + char *contentType = 0, *transEncoding = 0, *body = 0; //should not be delete[]-ed + for (Header = MailParam->mail->MailData->TranslatedHeader; Header != NULL; Header = Header->Next) { - PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) - (lParam?lParam:GetWindowLongPtr(hDlg,DWLP_USER)); - HWND hListView = GetDlgItem(hDlg,IDC_LISTHEADERS); - HWND hEdit = GetDlgItem(hDlg,IDC_EDITBODY); - //do not redraw - SendMessage(hListView, WM_SETREDRAW, 0, 0); - ListView_DeleteAllItems(hListView); - struct CMimeItem *Header; - LVITEMW item; - item.mask=LVIF_TEXT | LVIF_PARAM; - WCHAR *From=0,*Subj=0; - char *contentType=0, *transEncoding=0, *body=0; //should not be delete[]-ed - for (Header=MailParam->mail->MailData->TranslatedHeader;Header != NULL;Header=Header->Next) + WCHAR *str1 = 0; + WCHAR *str2 = 0; + WCHAR str_nul[2] = { 0 }; + if (!body) if (!_stricmp(Header->name, "Body")) { body = Header->value; continue; } + if (!contentType) if (!_stricmp(Header->name, "Content-Type")) contentType = Header->value; + if (!transEncoding) if (!_stricmp(Header->name, "Content-Transfer-Encoding")) transEncoding = Header->value; + //ConvertCodedStringToUnicode(Header->name,&str1,MailParam->mail->MailData->CP,1); { - WCHAR *str1 = 0; - WCHAR *str2 = 0; - WCHAR str_nul[2] = {0}; - if (!body) if (!_stricmp(Header->name,"Body")) {body = Header->value; continue;} - if (!contentType) if (!_stricmp(Header->name,"Content-Type")) contentType = Header->value; - if (!transEncoding) if (!_stricmp(Header->name,"Content-Transfer-Encoding")) transEncoding = Header->value; - //ConvertCodedStringToUnicode(Header->name,&str1,MailParam->mail->MailData->CP,1); - { - int streamsize = MultiByteToWideChar(20127,0,Header->name,-1,NULL,0); - str1 = (WCHAR *)malloc(sizeof(WCHAR) * (streamsize + 1)); - MultiByteToWideChar(20127,0,Header->name,-1,str1,streamsize);//US-ASCII - } - ConvertCodedStringToUnicode(Header->value,&str2,MailParam->mail->MailData->CP,1); - if (!str2) { str2 = (WCHAR *)str_nul; }// the header value may be NULL - if (!From) if (!_stricmp(Header->name,"From")) { - From =new WCHAR[wcslen(str2)+1]; - wcscpy(From,str2); - } - if (!Subj) if (!_stricmp(Header->name,"Subject")) { - Subj =new WCHAR[wcslen(str2)+1]; - wcscpy(Subj,str2); + int streamsize = MultiByteToWideChar(20127, 0, Header->name, -1, NULL, 0); + str1 = (WCHAR *)malloc(sizeof(WCHAR) * (streamsize + 1)); + MultiByteToWideChar(20127, 0, Header->name, -1, str1, streamsize);//US-ASCII + } + ConvertCodedStringToUnicode(Header->value, &str2, MailParam->mail->MailData->CP, 1); + if (!str2) { str2 = (WCHAR *)str_nul; }// the header value may be NULL + if (!From) if (!_stricmp(Header->name, "From")) { + From = new WCHAR[wcslen(str2) + 1]; + wcscpy(From, str2); + } + if (!Subj) if (!_stricmp(Header->name, "Subject")) { + Subj = new WCHAR[wcslen(str2) + 1]; + wcscpy(Subj, str2); + } + //if (!hasBody) if (!strcmp(Header->name,"Body")) hasBody = true; + int count = 0; WCHAR **split = 0; + int ofs = 0; + while (str2[ofs]) { + if ((str2[ofs] == 0x266A) || (str2[ofs] == 0x25D9) || (str2[ofs] == 0x25CB) || + (str2[ofs] == 0x09) || (str2[ofs] == 0x0A) || (str2[ofs] == 0x0D))count++; + ofs++; + } + split = new WCHAR*[count + 1]; + count = 0; ofs = 0; + split[0] = str2; + while (str2[ofs]) { + if ((str2[ofs] == 0x266A) || (str2[ofs] == 0x25D9) || (str2[ofs] == 0x25CB) || + (str2[ofs] == 0x09) || (str2[ofs] == 0x0A) || (str2[ofs] == 0x0D)) { + if (str2[ofs - 1]) { + count++; + } + split[count] = (WCHAR *)(str2 + ofs + 1); + str2[ofs] = 0; } - //if (!hasBody) if (!strcmp(Header->name,"Body")) hasBody = true; - int count = 0; WCHAR **split=0; - int ofs = 0; - while (str2[ofs]) { - if ((str2[ofs]==0x266A)||(str2[ofs]==0x25D9)||(str2[ofs]==0x25CB)|| - (str2[ofs]==0x09)||(str2[ofs]==0x0A)||(str2[ofs]==0x0D))count++; - ofs++; + ofs++; + }; + + if (!_stricmp(Header->name, "From") || !_stricmp(Header->name, "To") || !_stricmp(Header->name, "Date") || !_stricmp(Header->name, "Subject")) + item.iItem = 0; + else + item.iItem = 999; + for (int i = 0; i <= count; i++) { + item.iSubItem = 0; + if (i == 0) + item.pszText = str1; + else { + item.iItem++; + item.pszText = 0; } - split=new WCHAR*[count+1]; - count=0; ofs=0; - split[0]=str2; - while (str2[ofs]) { - if ((str2[ofs]==0x266A)||(str2[ofs]==0x25D9)||(str2[ofs]==0x25CB)|| - (str2[ofs]==0x09)||(str2[ofs]==0x0A)||(str2[ofs]==0x0D)) { - if (str2[ofs-1]) { - count++; - } - split[count]=(WCHAR *)(str2+ofs+1); - str2[ofs]=0; - } - ofs++; - }; - - if (!_stricmp(Header->name,"From")||!_stricmp(Header->name,"To")||!_stricmp(Header->name,"Date")||!_stricmp(Header->name,"Subject")) - item.iItem = 0; - else - item.iItem = 999; - for (int i=0;i<=count;i++) { - item.iSubItem=0; - if (i==0) - item.pszText=str1; - else { - item.iItem++; - item.pszText=0; - } - item.iItem=SendMessageW(hListView,LVM_INSERTITEMW,0,(LPARAM)&item); - item.iSubItem=1; - item.pszText=str2?split[i]:0; - SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item); - } - delete[] split; - - if (str1) - free(str1); - if (str2 != (WCHAR *)str_nul) - free(str2); + item.iItem = SendMessageW(hListView, LVM_INSERTITEMW, 0, (LPARAM)&item); + item.iSubItem = 1; + item.pszText = str2 ? split[i] : 0; + SendMessageW(hListView, LVM_SETITEMTEXTW, (WPARAM)item.iItem, (LPARAM)&item); } - if (body) { - WCHAR *bodyDecoded = 0; - char *localBody=0; - if (contentType) { - if (!_strnicmp(contentType,"text",4)) { - if (transEncoding) { - if (!_stricmp(transEncoding,"base64")) { - int size = (int)strlen(body)*3/4+5; - localBody = new char[size+1]; - DecodeBase64(body,localBody,size); - } else if (!_stricmp(transEncoding,"quoted-printable")) { - int size = (int)strlen(body)+2; - localBody = new char[size+1]; - DecodeQuotedPrintable(body,localBody,size,FALSE); - } + delete[] split; + + if (str1) + free(str1); + if (str2 != (WCHAR *)str_nul) + free(str2); + } + if (body) { + WCHAR *bodyDecoded = 0; + char *localBody = 0; + if (contentType) { + if (!_strnicmp(contentType, "text", 4)) { + if (transEncoding) { + if (!_stricmp(transEncoding, "base64")) { + int size = (int)strlen(body) * 3 / 4 + 5; + localBody = new char[size + 1]; + DecodeBase64(body, localBody, size); } - } else if (!_strnicmp(contentType,"multipart/",10)) { - char *bondary=NULL; - if (NULL != (bondary=ExtractFromContentType(contentType,"boundary="))) - { - bodyDecoded = ParseMultipartBody(body,bondary); - delete[] bondary; + else if (!_stricmp(transEncoding, "quoted-printable")) { + int size = (int)strlen(body) + 2; + localBody = new char[size + 1]; + DecodeQuotedPrintable(body, localBody, size, FALSE); } } } - if (!bodyDecoded)ConvertStringToUnicode(localBody?localBody:body,MailParam->mail->MailData->CP,&bodyDecoded); - SetWindowTextW(hEdit, bodyDecoded); - delete[] bodyDecoded; - if (localBody) delete[] localBody; - SetFocus(hEdit); - } - if (!(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)) { - MailParam->mail->Flags |= YAMN_MSG_BODYREQUESTED; - CallService(MS_YAMN_ACCOUNTCHECK,(WPARAM)MailParam->account,0); - } else { - if (MailParam->mail->Flags & YAMN_MSG_UNSEEN) { - MailParam->mail->Flags&=~YAMN_MSG_UNSEEN; //mark the message as seen - HWND hMailBrowser; - if (hMailBrowser=WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)MailParam->account)) { - struct CChangeContent Params={MailParam->account->NewMailN.Flags|YAMN_ACC_MSGP,MailParam->account->NoNewMailN.Flags|YAMN_ACC_MSGP}; - SendMessageW(hMailBrowser,WM_YAMN_CHANGECONTENT,(WPARAM)MailParam->account,(LPARAM)&Params); + else if (!_strnicmp(contentType, "multipart/", 10)) { + char *bondary = NULL; + if (NULL != (bondary = ExtractFromContentType(contentType, "boundary="))) + { + bodyDecoded = ParseMultipartBody(body, bondary); + delete[] bondary; } - else UpdateMails(NULL,MailParam->account,MailParam->account->NewMailN.Flags,MailParam->account->NoNewMailN.Flags); } } - ShowWindow(GetDlgItem(hDlg, IDC_SPLITTER),(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)?SW_SHOW:SW_HIDE); - ShowWindow(hEdit,(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)?SW_SHOW:SW_HIDE); - WCHAR *title=0; - size_t size = (From ? wcslen(From) : 0) + (Subj ? wcslen(Subj) : 0) + 4; - title = new WCHAR[size]; - if (From && Subj) - mir_sntprintf(title, size, L"%s (%s)", Subj, From); - else if (From) - _tcsncpy_s(title, size, From, _TRUNCATE); - else if (Subj) - _tcsncpy_s(title, size, Subj, _TRUNCATE); - else - _tcsncpy_s(title, size, L"none", _TRUNCATE); - if (Subj) delete[] Subj; - if (From) delete[] From; - SetWindowTextW(hDlg, title); - delete[] title; - // turn on redrawing - SendMessage(hListView, WM_SETREDRAW, 1, 0); - SendMessage(hDlg, WM_SIZE, 0, HeadSizeY<<16|HeadSizeX); - } break; + if (!bodyDecoded)ConvertStringToUnicode(localBody ? localBody : body, MailParam->mail->MailData->CP, &bodyDecoded); + SetWindowTextW(hEdit, bodyDecoded); + delete[] bodyDecoded; + if (localBody) delete[] localBody; + SetFocus(hEdit); + } + if (!(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)) { + MailParam->mail->Flags |= YAMN_MSG_BODYREQUESTED; + CallService(MS_YAMN_ACCOUNTCHECK, (WPARAM)MailParam->account, 0); + } + else { + if (MailParam->mail->Flags & YAMN_MSG_UNSEEN) { + MailParam->mail->Flags &= ~YAMN_MSG_UNSEEN; //mark the message as seen + HWND hMailBrowser; + if (hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)MailParam->account)) { + struct CChangeContent Params = { MailParam->account->NewMailN.Flags | YAMN_ACC_MSGP, MailParam->account->NoNewMailN.Flags | YAMN_ACC_MSGP }; + SendMessageW(hMailBrowser, WM_YAMN_CHANGECONTENT, (WPARAM)MailParam->account, (LPARAM)&Params); + } + else UpdateMails(NULL, MailParam->account, MailParam->account->NewMailN.Flags, MailParam->account->NoNewMailN.Flags); + } + } + ShowWindow(GetDlgItem(hDlg, IDC_SPLITTER), (MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED) ? SW_SHOW : SW_HIDE); + ShowWindow(hEdit, (MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED) ? SW_SHOW : SW_HIDE); + WCHAR *title = 0; + size_t size = (From ? wcslen(From) : 0) + (Subj ? wcslen(Subj) : 0) + 4; + title = new WCHAR[size]; + if (From && Subj) + mir_sntprintf(title, size, L"%s (%s)", Subj, From); + else if (From) + _tcsncpy_s(title, size, From, _TRUNCATE); + else if (Subj) + _tcsncpy_s(title, size, Subj, _TRUNCATE); + else + _tcsncpy_s(title, size, L"none", _TRUNCATE); + if (Subj) delete[] Subj; + if (From) delete[] From; + SetWindowTextW(hDlg, title); + delete[] title; + // turn on redrawing + SendMessage(hListView, WM_SETREDRAW, 1, 0); + SendMessage(hDlg, WM_SIZE, 0, HeadSizeY << 16 | HeadSizeX); + } break; case WM_YAMN_STOPACCOUNT: - { - PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) - (lParam?lParam:GetWindowLongPtr(hDlg,DWLP_USER)); + { + PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM) + (lParam ? lParam : GetWindowLongPtr(hDlg, DWLP_USER)); - if (NULL==MailParam) - break; - if ((HACCOUNT)wParam != MailParam->account) - break; + if (NULL == MailParam) + break; + if ((HACCOUNT)wParam != MailParam->account) + break; #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"ShowMessage:STOPACCOUNT:sending destroy msg\n"); + DebugLog(SynchroFile,"ShowMessage:STOPACCOUNT:sending destroy msg\n"); #endif - DestroyWindow(hDlg); - } - return 1; + DestroyWindow(hDlg); + } + return 1; - case WM_CTLCOLORSTATIC: + case WM_CTLCOLORSTATIC: //here should be check if this is our edittext control. //but we have only one static control (for now); SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); @@ -1520,21 +1531,21 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); case WM_DESTROY: - { - RECT coord; - if (GetWindowRect(hDlg,&coord)) { - HeadPosX=coord.left; - HeadSizeX=coord.right-coord.left; - HeadPosY=coord.top; - HeadSizeY=coord.bottom-coord.top; - } - - PostQuitMessage(1); + { + RECT coord; + if (GetWindowRect(hDlg, &coord)) { + HeadPosX = coord.left; + HeadSizeX = coord.right - coord.left; + HeadPosY = coord.top; + HeadSizeY = coord.bottom - coord.top; } - break; + + PostQuitMessage(1); + } + break; case WM_SYSCOMMAND: - switch(wParam) { + switch (wParam) { case SC_CLOSE: DestroyWindow(hDlg); break; @@ -1542,69 +1553,70 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM break; case WM_MOVE: - HeadPosX=LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; - HeadPosY=HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; + HeadPosX = LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; + HeadPosY = HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; return 0; case DM_SPLITTERMOVED: - if ((HWND) lParam == GetDlgItem(hDlg, IDC_SPLITTER)) { + if ((HWND)lParam == GetDlgItem(hDlg, IDC_SPLITTER)) { POINT pt; pt.x = 0; pt.y = wParam; ScreenToClient(hDlg, &pt); - HeadSplitPos = (pt.y*1000)/HeadSizeY;//+rc.bottom-rc.top; - if (HeadSplitPos>=1000) HeadSplitPos = 999; - else if (HeadSplitPos<=0) HeadSplitPos = 1; - else SendMessage(hDlg, WM_SIZE, 0, HeadSizeY<<16|HeadSizeX); + HeadSplitPos = (pt.y * 1000) / HeadSizeY;//+rc.bottom-rc.top; + if (HeadSplitPos >= 1000) HeadSplitPos = 999; + else if (HeadSplitPos <= 0) HeadSplitPos = 1; + else SendMessage(hDlg, WM_SIZE, 0, HeadSizeY << 16 | HeadSizeX); } return 0; case WM_SIZE: if (wParam == SIZE_RESTORED) { - HWND hList = GetDlgItem(hDlg,IDC_LISTHEADERS); - HWND hEdit = GetDlgItem(hDlg,IDC_EDITBODY); + HWND hList = GetDlgItem(hDlg, IDC_LISTHEADERS); + HWND hEdit = GetDlgItem(hDlg, IDC_EDITBODY); BOOL changeX = LOWORD(lParam) != HeadSizeX; - BOOL isBodyShown = ((PYAMN_MAILSHOWPARAM)(GetWindowLongPtr(hDlg,DWLP_USER)))->mail->Flags & YAMN_MSG_BODYRECEIVED; - HeadSizeX=LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; - HeadSizeY=HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; - int localSplitPos = (HeadSplitPos*HeadSizeY)/1000; + BOOL isBodyShown = ((PYAMN_MAILSHOWPARAM)(GetWindowLongPtr(hDlg, DWLP_USER)))->mail->Flags & YAMN_MSG_BODYRECEIVED; + HeadSizeX = LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; + HeadSizeY = HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; + int localSplitPos = (HeadSplitPos*HeadSizeY) / 1000; int localSizeX; RECT coord; - MoveWindow(GetDlgItem(hDlg,IDC_SPLITTER),5,localSplitPos,HeadSizeX-10,2,TRUE); - MoveWindow(hEdit,5,localSplitPos+6,HeadSizeX-10,HeadSizeY-localSplitPos-11,TRUE); //where to put text window while resizing - MoveWindow(hList, 5 ,5 ,HeadSizeX-10 ,(isBodyShown?localSplitPos:HeadSizeY)-10,TRUE); //where to put headers list window while resizing + MoveWindow(GetDlgItem(hDlg, IDC_SPLITTER), 5, localSplitPos, HeadSizeX - 10, 2, TRUE); + MoveWindow(hEdit, 5, localSplitPos + 6, HeadSizeX - 10, HeadSizeY - localSplitPos - 11, TRUE); //where to put text window while resizing + MoveWindow(hList, 5, 5, HeadSizeX - 10, (isBodyShown ? localSplitPos : HeadSizeY) - 10, TRUE); //where to put headers list window while resizing //if (changeX) { - if (GetClientRect(hList,&coord)) { - localSizeX=coord.right-coord.left; - } else localSizeX=HeadSizeX; - LONG iNameWidth = ListView_GetColumnWidth(hList,0); - ListView_SetColumnWidth(hList,1,(localSizeX<=iNameWidth)?0:(localSizeX-iNameWidth)); + if (GetClientRect(hList, &coord)) { + localSizeX = coord.right - coord.left; + } + else localSizeX = HeadSizeX; + LONG iNameWidth = ListView_GetColumnWidth(hList, 0); + ListView_SetColumnWidth(hList, 1, (localSizeX <= iNameWidth) ? 0 : (localSizeX - iNameWidth)); //} } return 0; case WM_CONTEXTMENU: - if ( GetWindowLongPtr(( HWND )wParam, GWLP_ID ) == IDC_LISTHEADERS) { + if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == IDC_LISTHEADERS) { //MessageBox(0,"LISTHEADERS","Debug",0); - HWND hList = GetDlgItem( hDlg, IDC_LISTHEADERS ); - POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) }; + HWND hList = GetDlgItem(hDlg, IDC_LISTHEADERS); + POINT pt = { (signed short)LOWORD(lParam), (signed short)HIWORD(lParam) }; HTREEITEM hItem = 0; - if (pt.x==-1) pt.x = 0; - if (pt.y==-1) pt.y = 0; + if (pt.x == -1) pt.x = 0; + if (pt.y == -1) pt.y = 0; if (int numRows = ListView_GetItemCount(hList)) { HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, TranslateT("Copy Selected")); AppendMenu(hMenu, MF_STRING, (UINT_PTR)2, TranslateT("Copy All")); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel")); - int nReturnCmd = TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL ); - DestroyMenu( hMenu ); - if (nReturnCmd>0) { - int courRow=0; + int nReturnCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL); + DestroyMenu(hMenu); + if (nReturnCmd > 0) { + int courRow = 0; size_t sizeNeeded = 0; - TCHAR headname[64]={0}, headvalue[256]={0}; - for (courRow=0; courRow < numRows; courRow++) { - if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue; + TCHAR headname[64] = { 0 }, headvalue[256] = { 0 }; + for (courRow = 0; courRow < numRows; courRow++) { + if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; ListView_GetItemText(hList, courRow, 0, headname, SIZEOF(headname)); ListView_GetItemText(hList, courRow, 1, headvalue, SIZEOF(headvalue)); size_t headnamelen = _tcslen(headname); @@ -1613,19 +1625,19 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM } if (sizeNeeded && OpenClipboard(hDlg)) { EmptyClipboard(); - HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE,(sizeNeeded+1)*sizeof(TCHAR)); - TCHAR *buff = ( TCHAR* )GlobalLock(hData); + HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (sizeNeeded + 1)*sizeof(TCHAR)); + TCHAR *buff = (TCHAR*)GlobalLock(hData); int courPos = 0; - for (courRow=0;courRow<numRows;courRow++) { - if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue; + for (courRow = 0; courRow < numRows; courRow++) { + if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; ListView_GetItemText(hList, courRow, 0, headname, SIZEOF(headname)); ListView_GetItemText(hList, courRow, 1, headvalue, SIZEOF(headvalue)); - if ( _tcslen(headname)) courPos += mir_sntprintf(&buff[courPos], sizeNeeded + 1, _T("%s:\t%s\r\n"), headname, headvalue); + if (_tcslen(headname)) courPos += mir_sntprintf(&buff[courPos], sizeNeeded + 1, _T("%s:\t%s\r\n"), headname, headvalue); else courPos += mir_sntprintf(&buff[courPos], sizeNeeded + 1, _T("\t%s\r\n"), headvalue); } GlobalUnlock(hData); - SetClipboardData(CF_UNICODETEXT,hData); + SetClipboardData(CF_UNICODETEXT, hData); CloseClipboard(); } @@ -1637,627 +1649,629 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM return 0; } -DWORD WINAPI ShowEmailThread(LPVOID Param) { +void __cdecl ShowEmailThread(void *Param) { struct MailShowMsgWinParam MyParam; - MyParam=*(struct MailShowMsgWinParam *)Param; + MyParam = *(struct MailShowMsgWinParam *)Param; - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"ShowMessage:Incrementing \"using threads\" %x (account %x)\n",MyParam.account->UsingThreads,MyParam.account); - #endif +#endif SCIncFcn(MyParam.account->UsingThreads); SetEvent(MyParam.ThreadRunningEV); if (MyParam.mail->MsgWindow) { //if (!BringWindowToTop(MyParam.mail->MsgWindow)) { if (!SetForegroundWindow(MyParam.mail->MsgWindow)) { - SendMessage(MyParam.mail->MsgWindow,WM_DESTROY,0,0); + SendMessage(MyParam.mail->MsgWindow, WM_DESTROY, 0, 0); MyParam.mail->MsgWindow = 0; goto CREADTEVIEWMESSAGEWINDOW; - }else{ + } + else{ if (IsIconic(MyParam.mail->MsgWindow)) { OpenIcon(MyParam.mail->MsgWindow); } } - } else { -CREADTEVIEWMESSAGEWINDOW: - MyParam.mail->MsgWindow = CreateDialogParamW(YAMNVar.hInst,MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE),NULL,DlgProcYAMNShowMessage,(LPARAM)&MyParam); - WindowList_Add(YAMNVar.MessageWnds,MyParam.mail->MsgWindow,NULL); + } + else { + CREADTEVIEWMESSAGEWINDOW: + MyParam.mail->MsgWindow = CreateDialogParamW(YAMNVar.hInst, MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE), NULL, DlgProcYAMNShowMessage, (LPARAM)&MyParam); + WindowList_Add(YAMNVar.MessageWnds, MyParam.mail->MsgWindow, NULL); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { if (MyParam.mail->MsgWindow == NULL || !IsDialogMessage(MyParam.mail->MsgWindow, &msg)) { /* Wine fix. */ TranslateMessage(&msg); DispatchMessage(&msg); - } } - WindowList_Remove(YAMNVar.MessageWnds,MyParam.mail->MsgWindow); + } + } + WindowList_Remove(YAMNVar.MessageWnds, MyParam.mail->MsgWindow); MyParam.mail->MsgWindow = NULL; } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"ShowMessage:Decrementing \"using threads\" %x (account %x)\n",MyParam.account->UsingThreads,MyParam.account); - #endif +#endif SCDecFcn(MyParam.account->UsingThreads); delete Param; - return 1; } -INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam) +INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) { + switch (msg) { case WM_INITDIALOG: - { - HACCOUNT ActualAccount; - struct MailBrowserWinParam *MyParam=(struct MailBrowserWinParam *)lParam; - struct CMailWinUserInfo *mwui; - - ListView_SetUnicodeFormat(GetDlgItem(hDlg,IDC_LISTMAILS),TRUE); - ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_LISTMAILS),LVS_EX_FULLROWSELECT); - - ActualAccount=MyParam->account; - mwui=new struct CMailWinUserInfo; - mwui->Account=ActualAccount; - mwui->TrayIconState=0; - mwui->UpdateMailsMessagesAccess=FALSE; - mwui->Seen=FALSE; - mwui->RunFirstTime=TRUE; - - SetWindowLongPtr(hDlg,DWLP_USER,(LONG_PTR)mwui); + { + HACCOUNT ActualAccount; + struct MailBrowserWinParam *MyParam = (struct MailBrowserWinParam *)lParam; + struct CMailWinUserInfo *mwui; + + ListView_SetUnicodeFormat(GetDlgItem(hDlg, IDC_LISTMAILS), TRUE); + ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, IDC_LISTMAILS), LVS_EX_FULLROWSELECT); + + ActualAccount = MyParam->account; + mwui = new struct CMailWinUserInfo; + mwui->Account = ActualAccount; + mwui->TrayIconState = 0; + mwui->UpdateMailsMessagesAccess = FALSE; + mwui->Seen = FALSE; + mwui->RunFirstTime = TRUE; + + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)mwui); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read wait\n"); + DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read wait\n"); #endif - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) - { + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter failed\n"); + DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter failed\n"); #endif - DestroyWindow(hDlg); - return FALSE; - } + DestroyWindow(hDlg); + return FALSE; + } #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter\n"); + DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter\n"); #endif - SetDlgItemTextW(hDlg, IDC_BTNAPP, TranslateW(L"Run application")); - SetDlgItemTextW(hDlg, IDC_BTNDEL, TranslateW(L"Delete selected")); - SetDlgItemTextW(hDlg, IDC_BTNCHECKALL,TranslateW(L"Select All")); - SetDlgItemTextW(hDlg, IDC_BTNOK, TranslateW(L"OK")); - - LVCOLUMNW lvc0={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,FromWidth,TranslateW(L"From"),0,0}; - LVCOLUMNW lvc1={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,SubjectWidth,TranslateW(L"Subject"),0,0}; - LVCOLUMNW lvc2={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,SizeWidth,TranslateW(L"Size"),0,0}; - LVCOLUMNW lvc3={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,SizeDate,TranslateW(L"Date"),0,0}; - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)2, (LPARAM)&lvc2); - SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)3, (LPARAM)&lvc3); - - if ((ActualAccount->NewMailN.App != NULL) && (wcslen(ActualAccount->NewMailN.App))) - EnableWindow(GetDlgItem(hDlg,IDC_BTNAPP),TRUE); - else - EnableWindow(GetDlgItem(hDlg,IDC_BTNAPP),FALSE); + SetDlgItemTextW(hDlg, IDC_BTNAPP, TranslateW(L"Run application")); + SetDlgItemTextW(hDlg, IDC_BTNDEL, TranslateW(L"Delete selected")); + SetDlgItemTextW(hDlg, IDC_BTNCHECKALL, TranslateW(L"Select All")); + SetDlgItemTextW(hDlg, IDC_BTNOK, TranslateW(L"OK")); + + LVCOLUMNW lvc0 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, FromWidth, TranslateW(L"From"), 0, 0 }; + LVCOLUMNW lvc1 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SubjectWidth, TranslateW(L"Subject"), 0, 0 }; + LVCOLUMNW lvc2 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SizeWidth, TranslateW(L"Size"), 0, 0 }; + LVCOLUMNW lvc3 = { LVCF_FMT | LVCF_TEXT | LVCF_WIDTH, LVCFMT_LEFT, SizeDate, TranslateW(L"Date"), 0, 0 }; + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 0, (LPARAM)&lvc0); + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, 1, (LPARAM)&lvc1); + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)2, (LPARAM)&lvc2); + SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_INSERTCOLUMNW, (WPARAM)3, (LPARAM)&lvc3); + + if ((ActualAccount->NewMailN.App != NULL) && (wcslen(ActualAccount->NewMailN.App))) + EnableWindow(GetDlgItem(hDlg, IDC_BTNAPP), TRUE); + else + EnableWindow(GetDlgItem(hDlg, IDC_BTNAPP), FALSE); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read done\n"); + DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read done\n"); #endif - ReadDoneFcn(ActualAccount->AccountAccessSO); + ReadDoneFcn(ActualAccount->AccountAccessSO); - WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL); - WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg, (MCONTACT)ActualAccount); + WindowList_Add(YAMNVar.MessageWnds, hDlg, NULL); + WindowList_Add(YAMNVar.NewMailAccountWnd, hDlg, (MCONTACT)ActualAccount); - { - TCHAR accstatus[512]; - GetStatusFcn(ActualAccount,accstatus); - SetDlgItemText(hDlg,IDC_STSTATUS,accstatus); - } - SetTimer(hDlg,TIMER_FLASHING,500,NULL); + { + TCHAR accstatus[512]; + GetStatusFcn(ActualAccount, accstatus); + SetDlgItemText(hDlg, IDC_STSTATUS, accstatus); + } + SetTimer(hDlg, TIMER_FLASHING, 500, NULL); - if (ActualAccount->hContact != NULL) - CallService(MS_CLIST_REMOVEEVENT,(WPARAM)ActualAccount->hContact,(LPARAM)"yamn new mail message"); + if (ActualAccount->hContact != NULL) + CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ActualAccount->hContact, (LPARAM)"yamn new mail message"); - mir_subclassWindow( GetDlgItem(hDlg, IDC_LISTMAILS), ListViewSubclassProc); - } - break; + mir_subclassWindow(GetDlgItem(hDlg, IDC_LISTMAILS), ListViewSubclassProc); + } + break; case WM_DESTROY: - { - HACCOUNT ActualAccount; - RECT coord; - LVCOLUMNW ColInfo; - NOTIFYICONDATA nid; - HYAMNMAIL Parser; - struct CMailWinUserInfo *mwui; - - mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER); - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; - ColInfo.mask=LVCF_WIDTH; - if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),0,&ColInfo)) - FromWidth=ColInfo.cx; - if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),1,&ColInfo)) - SubjectWidth=ColInfo.cx; - if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),2,&ColInfo)) - SizeWidth=ColInfo.cx; - if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),3,&ColInfo)) - SizeDate=ColInfo.cx; + { + HACCOUNT ActualAccount; + RECT coord; + LVCOLUMNW ColInfo; + NOTIFYICONDATA nid; + HYAMNMAIL Parser; + struct CMailWinUserInfo *mwui; + + mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + ColInfo.mask = LVCF_WIDTH; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 0, &ColInfo)) + FromWidth = ColInfo.cx; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 1, &ColInfo)) + SubjectWidth = ColInfo.cx; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 2, &ColInfo)) + SizeWidth = ColInfo.cx; + if (ListView_GetColumn(GetDlgItem(hDlg, IDC_LISTMAILS), 3, &ColInfo)) + SizeDate = ColInfo.cx; #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:save window position\n"); + DebugLog(SynchroFile,"MailBrowser:DESTROY:save window position\n"); #endif - if (!YAMNVar.Shutdown && GetWindowRect(hDlg,&coord)) //the YAMNVar.Shutdown testing is because M<iranda strange functionality at shutdown phase, when call to DBWriteContactSetting freezes calling thread - { - PosX=coord.left; - SizeX=coord.right-coord.left; - PosY=coord.top; - SizeY=coord.bottom-coord.top; - db_set_dw(NULL,YAMN_DBMODULE,YAMN_DBPOSX,PosX); - db_set_dw(NULL,YAMN_DBMODULE,YAMN_DBPOSY,PosY); - db_set_dw(NULL,YAMN_DBMODULE,YAMN_DBSIZEX,SizeX); - db_set_dw(NULL,YAMN_DBMODULE,YAMN_DBSIZEY,SizeY); - } - KillTimer(hDlg,TIMER_FLASHING); + if (!YAMNVar.Shutdown && GetWindowRect(hDlg, &coord)) //the YAMNVar.Shutdown testing is because M<iranda strange functionality at shutdown phase, when call to DBWriteContactSetting freezes calling thread + { + PosX = coord.left; + SizeX = coord.right - coord.left; + PosY = coord.top; + SizeY = coord.bottom - coord.top; + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSX, PosX); + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBPOSY, PosY); + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEX, SizeX); + db_set_dw(NULL, YAMN_DBMODULE, YAMN_DBSIZEY, SizeY); + } + KillTimer(hDlg, TIMER_FLASHING); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:remove window from list\n"); + DebugLog(SynchroFile,"MailBrowser:DESTROY:remove window from list\n"); #endif - WindowList_Remove(YAMNVar.NewMailAccountWnd,hDlg); - WindowList_Remove(YAMNVar.MessageWnds,hDlg); + WindowList_Remove(YAMNVar.NewMailAccountWnd, hDlg); + WindowList_Remove(YAMNVar.MessageWnds, hDlg); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait\n"); + DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait\n"); #endif - if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { + if (WAIT_OBJECT_0 != WaitToWriteFcn(ActualAccount->MessagesAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait failed\n"); + DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait failed\n"); #endif - break; - } + break; + } #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write enter\n"); + DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write enter\n"); #endif - //delete mails from queue, which are deleted from server (spam level 3 mails e.g.) - for (Parser=(HYAMNMAIL)ActualAccount->Mails;Parser != NULL;Parser=Parser->Next) + //delete mails from queue, which are deleted from server (spam level 3 mails e.g.) + for (Parser = (HYAMNMAIL)ActualAccount->Mails; Parser != NULL; Parser = Parser->Next) + { + if ((Parser->Flags & YAMN_MSG_DELETED) && YAMN_MSG_SPAML(Parser->Flags, YAMN_MSG_SPAML3) && mwui->Seen) //if spaml3 was already deleted and user knows about it { - if ((Parser->Flags & YAMN_MSG_DELETED) && YAMN_MSG_SPAML(Parser->Flags,YAMN_MSG_SPAML3) && mwui->Seen) //if spaml3 was already deleted and user knows about it - { - DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails,Parser,1); - CallService(MS_YAMN_DELETEACCOUNTMAIL,(WPARAM)ActualAccount->Plugin,(LPARAM)Parser); - } + DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails, Parser, 1); + CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)ActualAccount->Plugin, (LPARAM)Parser); } + } - //mark mails as read (remove "new" and "unseen" flags) - if (mwui->Seen) - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_DISPLAY,0,YAMN_MSG_NEW | YAMN_MSG_UNSEEN,0); + //mark mails as read (remove "new" and "unseen" flags) + if (mwui->Seen) + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY, 0, YAMN_MSG_NEW | YAMN_MSG_UNSEEN, 0); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write done\n"); + DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write done\n"); #endif - WriteDoneFcn(ActualAccount->MessagesAccessSO); + WriteDoneFcn(ActualAccount->MessagesAccessSO); - memset(&nid, 0, sizeof(NOTIFYICONDATA)); + memset(&nid, 0, sizeof(NOTIFYICONDATA)); - delete mwui; - SetWindowLongPtr(hDlg,DWLP_USER,(LONG_PTR)NULL); + delete mwui; + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NULL); - nid.cbSize=sizeof(NOTIFYICONDATA); - nid.hWnd=hDlg; - nid.uID=0; - Shell_NotifyIcon(NIM_DELETE,&nid); - PostQuitMessage(0); - } - break; + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hDlg; + nid.uID = 0; + Shell_NotifyIcon(NIM_DELETE, &nid); + PostQuitMessage(0); + } + break; case WM_SHOWWINDOW: - { - struct CMailWinUserInfo *mwui; + { + struct CMailWinUserInfo *mwui; - if (NULL==(mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER))) - return 0; - mwui->Seen=TRUE; - } + if (NULL == (mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER))) + return 0; + mwui->Seen = TRUE; + } case WM_YAMN_CHANGESTATUS: - { - HACCOUNT ActualAccount; - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; + { + HACCOUNT ActualAccount; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; - if ((HACCOUNT)wParam != ActualAccount) - break; + if ((HACCOUNT)wParam != ActualAccount) + break; - TCHAR accstatus[512]; - GetStatusFcn(ActualAccount,accstatus); - SetDlgItemText(hDlg,IDC_STSTATUS,accstatus); - } - return 1; + TCHAR accstatus[512]; + GetStatusFcn(ActualAccount, accstatus); + SetDlgItemText(hDlg, IDC_STSTATUS, accstatus); + } + return 1; case WM_YAMN_CHANGECONTENT: - { - struct CUpdateMails UpdateParams; - BOOL ThisThreadWindow=(GetCurrentThreadId()==GetWindowThreadProcessId(hDlg,NULL)); + { + struct CUpdateMails UpdateParams; + BOOL ThisThreadWindow = (GetCurrentThreadId() == GetWindowThreadProcessId(hDlg, NULL)); - if (NULL==(UpdateParams.Copied=CreateEvent(NULL,FALSE,FALSE,NULL))) - { - DestroyWindow(hDlg); - return 0; - } - UpdateParams.Flags=(struct CChangeContent *)lParam; - UpdateParams.Waiting=!ThisThreadWindow; + if (NULL == (UpdateParams.Copied = CreateEvent(NULL, FALSE, FALSE, NULL))) + { + DestroyWindow(hDlg); + return 0; + } + UpdateParams.Flags = (struct CChangeContent *)lParam; + UpdateParams.Waiting = !ThisThreadWindow; #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:posting UPDATEMAILS\n"); + DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:posting UPDATEMAILS\n"); #endif - if (ThisThreadWindow) - { - if (!UpdateMails(hDlg,(HACCOUNT)wParam,UpdateParams.Flags->nflags,UpdateParams.Flags->nnflags)) - DestroyWindow(hDlg); - } - else if (PostMessage(hDlg,WM_YAMN_UPDATEMAILS,wParam,(LPARAM)&UpdateParams)) //this ensures UpdateMails will execute the thread who created the browser window + if (ThisThreadWindow) + { + if (!UpdateMails(hDlg, (HACCOUNT)wParam, UpdateParams.Flags->nflags, UpdateParams.Flags->nnflags)) + DestroyWindow(hDlg); + } + else if (PostMessage(hDlg, WM_YAMN_UPDATEMAILS, wParam, (LPARAM)&UpdateParams)) //this ensures UpdateMails will execute the thread who created the browser window + { + if (!ThisThreadWindow) { - if (!ThisThreadWindow) - { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:waiting for event\n"); + DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:waiting for event\n"); #endif - WaitForSingleObject(UpdateParams.Copied,INFINITE); + WaitForSingleObject(UpdateParams.Copied, INFINITE); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:event signaled\n"); + DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:event signaled\n"); #endif - } } - - CloseHandle(UpdateParams.Copied); } - return 1; + + CloseHandle(UpdateParams.Copied); + } + return 1; case WM_YAMN_UPDATEMAILS: - { - HACCOUNT ActualAccount; + { + HACCOUNT ActualAccount; - struct CUpdateMails *um=(struct CUpdateMails *)lParam; - DWORD nflags,nnflags; + struct CUpdateMails *um = (struct CUpdateMails *)lParam; + DWORD nflags, nnflags; #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:UPDATEMAILS\n"); + DebugLog(SynchroFile,"MailBrowser:UPDATEMAILS\n"); #endif - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - return 0; - if ((HACCOUNT)wParam != ActualAccount) - return 0; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + return 0; + if ((HACCOUNT)wParam != ActualAccount) + return 0; - nflags=um->Flags->nflags; - nnflags=um->Flags->nnflags; + nflags = um->Flags->nflags; + nnflags = um->Flags->nnflags; - if (um->Waiting) - SetEvent(um->Copied); + if (um->Waiting) + SetEvent(um->Copied); - if (!UpdateMails(hDlg,ActualAccount,nflags,nnflags)) - DestroyWindow(hDlg); - } - return 1; + if (!UpdateMails(hDlg, ActualAccount, nflags, nnflags)) + DestroyWindow(hDlg); + } + return 1; case WM_YAMN_STOPACCOUNT: - { - HACCOUNT ActualAccount; + { + HACCOUNT ActualAccount; - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; - if ((HACCOUNT)wParam != ActualAccount) - break; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + if ((HACCOUNT)wParam != ActualAccount) + break; #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:STOPACCOUNT:sending destroy msg\n"); + DebugLog(SynchroFile,"MailBrowser:STOPACCOUNT:sending destroy msg\n"); #endif - PostQuitMessage(0); - } - return 1; + PostQuitMessage(0); + } + return 1; case WM_YAMN_NOTIFYICON: - { - HACCOUNT ActualAccount; - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; + { + HACCOUNT ActualAccount; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; - switch(lParam) - { - case WM_LBUTTONDBLCLK: + switch (lParam) + { + case WM_LBUTTONDBLCLK: #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait\n"); + DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait\n"); #endif - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) - { + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait failed\n"); + DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait failed\n"); #endif - return 0; - } + return 0; + } #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read enter\n"); + DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read enter\n"); #endif - if (ActualAccount->AbilityFlags & YAMN_ACC_BROWSE) - { - ShowWindow(hDlg,SW_SHOWNORMAL); - SetForegroundWindow(hDlg); - } - else - DestroyWindow(hDlg); + if (ActualAccount->AbilityFlags & YAMN_ACC_BROWSE) + { + ShowWindow(hDlg, SW_SHOWNORMAL); + SetForegroundWindow(hDlg); + } + else + DestroyWindow(hDlg); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read done\n"); + DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read done\n"); #endif - ReadDoneFcn(ActualAccount->AccountAccessSO); - break; - } + ReadDoneFcn(ActualAccount->AccountAccessSO); break; } + break; + } case WM_YAMN_SHOWSELECTED: + { + int iSelect; + iSelect = SendDlgItemMessage(hDlg, IDC_LISTMAILS, LVM_GETNEXTITEM, -1, MAKELPARAM((UINT)LVNI_FOCUSED, 0)); // return item selected + + if (iSelect != -1) { - int iSelect; - iSelect = SendDlgItemMessage(hDlg, IDC_LISTMAILS, LVM_GETNEXTITEM, -1, MAKELPARAM((UINT)LVNI_FOCUSED, 0)); // return item selected + LV_ITEMW item; + HYAMNMAIL ActualMail; - if (iSelect != -1) + item.iItem = iSelect; + item.iSubItem = 0; + item.mask = LVIF_PARAM | LVIF_STATE; + item.stateMask = 0xFFFFFFFF; + ListView_GetItem(GetDlgItem(hDlg, IDC_LISTMAILS), &item); + ActualMail = (HYAMNMAIL)item.lParam; + if (NULL != ActualMail) { - LV_ITEMW item; - HYAMNMAIL ActualMail; - - item.iItem=iSelect; - item.iSubItem=0; - item.mask=LVIF_PARAM | LVIF_STATE; - item.stateMask=0xFFFFFFFF; - ListView_GetItem(GetDlgItem(hDlg,IDC_LISTMAILS),&item); - ActualMail=(HYAMNMAIL)item.lParam; - if (NULL != ActualMail) - { - //ShowEmailThread - PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM; - MailParam->account = GetWindowAccount(hDlg); - MailParam->mail = ActualMail; - if (NULL != (MailParam->ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL))) { - HANDLE NewThread; - if (NULL != (NewThread=CreateThread(NULL,0,ShowEmailThread,MailParam,0,NULL))) - { - //WaitForSingleObject(MailParam->ThreadRunningEV,INFINITE); - CloseHandle(NewThread); - } - CloseHandle(MailParam->ThreadRunningEV); + //ShowEmailThread + PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM; + MailParam->account = GetWindowAccount(hDlg); + MailParam->mail = ActualMail; + if (NULL != (MailParam->ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { + HANDLE NewThread; + if (NULL != (NewThread = mir_forkthread(ShowEmailThread, (void*)MailParam))) + { + //WaitForSingleObject(MailParam->ThreadRunningEV,INFINITE); + CloseHandle(NewThread); } - //delete MailParam; + CloseHandle(MailParam->ThreadRunningEV); } + //delete MailParam; } - } break; + } + } break; case WM_SYSCOMMAND: - { - HACCOUNT ActualAccount; + { + HACCOUNT ActualAccount; - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; - switch(wParam) - { - case SC_CLOSE: - DestroyWindow(hDlg); - break; - } + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; + switch (wParam) + { + case SC_CLOSE: + DestroyWindow(hDlg); + break; } - break; + } + break; case WM_COMMAND: - { - HACCOUNT ActualAccount; - int Items; + { + HACCOUNT ActualAccount; + int Items; - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; - switch(LOWORD(wParam)) - { - case IDC_BTNCHECKALL: - ListView_SetItemState(GetDlgItem(hDlg,IDC_LISTMAILS), -1, 0, LVIS_SELECTED); // deselect all items - ListView_SetItemState(GetDlgItem(hDlg,IDC_LISTMAILS),-1, LVIS_SELECTED ,LVIS_SELECTED); - Items = ListView_GetItemCount(GetDlgItem(hDlg,IDC_LISTMAILS)); - ListView_RedrawItems(GetDlgItem(hDlg,IDC_LISTMAILS), 0, Items); - UpdateWindow(GetDlgItem(hDlg,IDC_LISTMAILS)); - SetFocus(GetDlgItem(hDlg,IDC_LISTMAILS)); - break; + switch (LOWORD(wParam)) + { + case IDC_BTNCHECKALL: + ListView_SetItemState(GetDlgItem(hDlg, IDC_LISTMAILS), -1, 0, LVIS_SELECTED); // deselect all items + ListView_SetItemState(GetDlgItem(hDlg, IDC_LISTMAILS), -1, LVIS_SELECTED, LVIS_SELECTED); + Items = ListView_GetItemCount(GetDlgItem(hDlg, IDC_LISTMAILS)); + ListView_RedrawItems(GetDlgItem(hDlg, IDC_LISTMAILS), 0, Items); + UpdateWindow(GetDlgItem(hDlg, IDC_LISTMAILS)); + SetFocus(GetDlgItem(hDlg, IDC_LISTMAILS)); + break; - case IDC_BTNOK: - DestroyWindow(hDlg); - break; + case IDC_BTNOK: + DestroyWindow(hDlg); + break; - case IDC_BTNAPP: - { - PROCESS_INFORMATION pi; - STARTUPINFOW si; + case IDC_BTNAPP: + { + PROCESS_INFORMATION pi; + STARTUPINFOW si; - memset(&si, 0, sizeof(si)); - si.cb=sizeof(si); + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read wait\n"); + DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read wait\n"); #endif - if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) - { + if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter\n"); + DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter\n"); #endif - if (ActualAccount->NewMailN.App != NULL) - { - WCHAR *Command; - if (ActualAccount->NewMailN.AppParam != NULL) - Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+wcslen(ActualAccount->NewMailN.AppParam)+6]; - else - Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+6]; + if (ActualAccount->NewMailN.App != NULL) + { + WCHAR *Command; + if (ActualAccount->NewMailN.AppParam != NULL) + Command = new WCHAR[wcslen(ActualAccount->NewMailN.App) + wcslen(ActualAccount->NewMailN.AppParam) + 6]; + else + Command = new WCHAR[wcslen(ActualAccount->NewMailN.App) + 6]; - if (Command != NULL) - { - mir_wstrcpy(Command,L"\""); - mir_wstrcat(Command,ActualAccount->NewMailN.App); - mir_wstrcat(Command,L"\" "); - if (ActualAccount->NewMailN.AppParam != NULL) - mir_wstrcat(Command,ActualAccount->NewMailN.AppParam); - CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); - delete[] Command; - } - } + if (Command != NULL) + { + mir_wstrcpy(Command, L"\""); + mir_wstrcat(Command, ActualAccount->NewMailN.App); + mir_wstrcat(Command, L"\" "); + if (ActualAccount->NewMailN.AppParam != NULL) + mir_wstrcat(Command, ActualAccount->NewMailN.AppParam); + CreateProcessW(NULL, Command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); + delete[] Command; + } + } #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n"); + DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n"); #endif - ReadDoneFcn(ActualAccount->AccountAccessSO); - } + ReadDoneFcn(ActualAccount->AccountAccessSO); + } #ifdef DEBUG_SYNCHRO - else - DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter failed\n"); + else + DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter failed\n"); #endif - if (!(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000)) - DestroyWindow(hDlg); + if (!(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000)) + DestroyWindow(hDlg); - } - break; - case IDC_BTNDEL: - { - LVITEMW item; - HYAMNMAIL FirstMail=NULL,ActualMail; - HANDLE ThreadRunningEV; - DWORD tid,Total=0; + } + break; + case IDC_BTNDEL: + { + LVITEMW item; + HYAMNMAIL FirstMail = NULL, ActualMail; + HANDLE ThreadRunningEV; + DWORD Total = 0; - // we use event to signal, that running thread has all needed stack parameters copied - if (NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL))) - break; - int Items=ListView_GetItemCount(GetDlgItem(hDlg,IDC_LISTMAILS)); + // we use event to signal, that running thread has all needed stack parameters copied + if (NULL == (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) + break; + int Items = ListView_GetItemCount(GetDlgItem(hDlg, IDC_LISTMAILS)); - item.stateMask=0xFFFFFFFF; + item.stateMask = 0xFFFFFFFF; #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); + DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); #endif - if (WAIT_OBJECT_0==WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { + if (WAIT_OBJECT_0 == WaitToWriteFcn(ActualAccount->MessagesAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); + DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); #endif - for (int i=0;i<Items;i++) - { - item.iItem=i; - item.iSubItem=0; - item.mask=LVIF_PARAM | LVIF_STATE; - item.stateMask=0xFFFFFFFF; - ListView_GetItem(GetDlgItem(hDlg,IDC_LISTMAILS),&item); - ActualMail=(HYAMNMAIL)item.lParam; - if (NULL==ActualMail) - break; - if (item.state & LVIS_SELECTED) - { - ActualMail->Flags|=YAMN_MSG_USERDELETE; //set to mail we are going to delete it - Total++; - } - } + for (int i = 0; i < Items; i++) + { + item.iItem = i; + item.iSubItem = 0; + item.mask = LVIF_PARAM | LVIF_STATE; + item.stateMask = 0xFFFFFFFF; + ListView_GetItem(GetDlgItem(hDlg, IDC_LISTMAILS), &item); + ActualMail = (HYAMNMAIL)item.lParam; + if (NULL == ActualMail) + break; + if (item.state & LVIS_SELECTED) + { + ActualMail->Flags |= YAMN_MSG_USERDELETE; //set to mail we are going to delete it + Total++; + } + } - // Enable write-access to mails + // Enable write-access to mails #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); + DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); #endif - WriteDoneFcn(ActualAccount->MessagesAccessSO); + WriteDoneFcn(ActualAccount->MessagesAccessSO); - if (Total) - { - TCHAR DeleteMsg[1024]; + if (Total) + { + TCHAR DeleteMsg[1024]; - mir_sntprintf(DeleteMsg, SIZEOF(DeleteMsg), TranslateT("Do you really want to delete %d selected mails?"),Total); - if (IDOK==MessageBox(hDlg,DeleteMsg,TranslateT("Delete confirmation"),MB_OKCANCEL | MB_ICONWARNING)) - { - struct DeleteParam ParamToDeleteMails={YAMN_DELETEVERSION,ThreadRunningEV,ActualAccount,NULL}; + mir_sntprintf(DeleteMsg, SIZEOF(DeleteMsg), TranslateT("Do you really want to delete %d selected mails?"), Total); + if (IDOK == MessageBox(hDlg, DeleteMsg, TranslateT("Delete confirmation"), MB_OKCANCEL | MB_ICONWARNING)) + { + struct DeleteParam ParamToDeleteMails = { YAMN_DELETEVERSION, ThreadRunningEV, ActualAccount, NULL }; - // Find if there's mail marked to delete, which was deleted before + // Find if there's mail marked to delete, which was deleted before #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); + DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n"); #endif - if (WAIT_OBJECT_0==WaitToWriteFcn(ActualAccount->MessagesAccessSO)) - { -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); -#endif - for (ActualMail=(HYAMNMAIL)ActualAccount->Mails;ActualMail != NULL;ActualMail=ActualMail->Next) - { - if ((ActualMail->Flags & YAMN_MSG_DELETED) && ((ActualMail->Flags & YAMN_MSG_USERDELETE))) //if selected mail was already deleted - { - DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails,ActualMail,1); - CallService(MS_YAMN_DELETEACCOUNTMAIL,(WPARAM)ActualAccount->Plugin,(LPARAM)ActualMail); //delete it from memory - continue; - } - } - // Set flag to marked mails that they can be deleted - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE,0,YAMN_MSG_DELETEOK,1); - // Create new thread which deletes marked mails. - HANDLE NewThread; - - if (NULL != (NewThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ActualAccount->Plugin->Fcn->DeleteMailsFcnPtr,(LPVOID)&ParamToDeleteMails,0,&tid))) - { - WaitForSingleObject(ThreadRunningEV,INFINITE); - CloseHandle(NewThread); - } - // Enable write-access to mails + if (WAIT_OBJECT_0 == WaitToWriteFcn(ActualAccount->MessagesAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); + DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n"); #endif - WriteDoneFcn(ActualAccount->MessagesAccessSO); + for (ActualMail = (HYAMNMAIL)ActualAccount->Mails; ActualMail != NULL; ActualMail = ActualMail->Next) + { + if ((ActualMail->Flags & YAMN_MSG_DELETED) && ((ActualMail->Flags & YAMN_MSG_USERDELETE))) //if selected mail was already deleted + { + DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails, ActualMail, 1); + CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)ActualAccount->Plugin, (LPARAM)ActualMail); //delete it from memory + continue; } } - else - //else mark messages that they are not to be deleted - SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE,0,YAMN_MSG_USERDELETE,0); + // Set flag to marked mails that they can be deleted + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE, 0, YAMN_MSG_DELETEOK, 1); + // Create new thread which deletes marked mails. + HANDLE NewThread; + + if (NULL != (NewThread = mir_forkthread(ActualAccount->Plugin->Fcn->DeleteMailsFcnPtr, (void*)&ParamToDeleteMails))) + { + WaitForSingleObject(ThreadRunningEV, INFINITE); + CloseHandle(NewThread); + } + // Enable write-access to mails +#ifdef DEBUG_SYNCHRO + DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n"); +#endif + WriteDoneFcn(ActualAccount->MessagesAccessSO); } } - CloseHandle(ThreadRunningEV); - if (db_get_b(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, 0)) - DestroyWindow(hDlg); - + else + //else mark messages that they are not to be deleted + SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails, YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE, 0, YAMN_MSG_USERDELETE, 0); } - break; } + CloseHandle(ThreadRunningEV); + if (db_get_b(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, 0)) + DestroyWindow(hDlg); + } break; + } + } + break; case WM_SIZE: - if (wParam==SIZE_RESTORED) + if (wParam == SIZE_RESTORED) { - LONG x=LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; - LONG y=HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; - MoveWindow(GetDlgItem(hDlg,IDC_BTNDEL), 5 ,y-5-25,(x-20)/3,25,TRUE); //where to put DELETE button while resizing - MoveWindow(GetDlgItem(hDlg,IDC_BTNCHECKALL),10+ (x-20)/3,y-5-25,(x-20)/6,25,TRUE); //where to put CHECK ALL button while resizing - MoveWindow(GetDlgItem(hDlg,IDC_BTNAPP), 15+ (x-20)/3 + (x-20)/6,y-5-25,(x-20)/3,25,TRUE); //where to put RUN APP button while resizing - MoveWindow(GetDlgItem(hDlg,IDC_BTNOK), 20+2*(x-20)/3 + (x-20)/6 ,y-5-25,(x-20)/6,25,TRUE); //where to put OK button while resizing - MoveWindow(GetDlgItem(hDlg,IDC_LISTMAILS), 5 ,5 ,x-10 ,y-55,TRUE); //where to put list mail window while resizing - MoveWindow(GetDlgItem(hDlg,IDC_STSTATUS), 5 ,y-5-45 ,x-10 ,15,TRUE); //where to put account status text while resizing + LONG x = LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left; + LONG y = HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top; + MoveWindow(GetDlgItem(hDlg, IDC_BTNDEL), 5, y - 5 - 25, (x - 20) / 3, 25, TRUE); //where to put DELETE button while resizing + MoveWindow(GetDlgItem(hDlg, IDC_BTNCHECKALL), 10 + (x - 20) / 3, y - 5 - 25, (x - 20) / 6, 25, TRUE); //where to put CHECK ALL button while resizing + MoveWindow(GetDlgItem(hDlg, IDC_BTNAPP), 15 + (x - 20) / 3 + (x - 20) / 6, y - 5 - 25, (x - 20) / 3, 25, TRUE); //where to put RUN APP button while resizing + MoveWindow(GetDlgItem(hDlg, IDC_BTNOK), 20 + 2 * (x - 20) / 3 + (x - 20) / 6, y - 5 - 25, (x - 20) / 6, 25, TRUE); //where to put OK button while resizing + MoveWindow(GetDlgItem(hDlg, IDC_LISTMAILS), 5, 5, x - 10, y - 55, TRUE); //where to put list mail window while resizing + MoveWindow(GetDlgItem(hDlg, IDC_STSTATUS), 5, y - 5 - 45, x - 10, 15, TRUE); //where to put account status text while resizing } // break; return 0; case WM_GETMINMAXINFO: - ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=MAILBROWSER_MINXSIZE; - ((LPMINMAXINFO)lParam)->ptMinTrackSize.y=MAILBROWSER_MINYSIZE; + ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = MAILBROWSER_MINXSIZE; + ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = MAILBROWSER_MINYSIZE; return 0; case WM_TIMER: - { - NOTIFYICONDATA nid; - struct CMailWinUserInfo *mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER); - - memset(&nid, 0, sizeof(nid)); - nid.cbSize=sizeof(NOTIFYICONDATA); - nid.hWnd=hDlg; - nid.uID=0; - nid.uFlags=NIF_ICON; - if (mwui->TrayIconState==0) - nid.hIcon=g_LoadIconEx(0); - else - nid.hIcon=g_LoadIconEx(2); - Shell_NotifyIcon(NIM_MODIFY,&nid); - mwui->TrayIconState=!mwui->TrayIconState; - // UpdateWindow(hDlg); - } - break; + { + NOTIFYICONDATA nid; + struct CMailWinUserInfo *mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); + + memset(&nid, 0, sizeof(nid)); + nid.cbSize = sizeof(NOTIFYICONDATA); + nid.hWnd = hDlg; + nid.uID = 0; + nid.uFlags = NIF_ICON; + if (mwui->TrayIconState == 0) + nid.hIcon = g_LoadIconEx(0); + else + nid.hIcon = g_LoadIconEx(2); + Shell_NotifyIcon(NIM_MODIFY, &nid); + mwui->TrayIconState = !mwui->TrayIconState; + // UpdateWindow(hDlg); + } + break; case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { + switch (((LPNMHDR)lParam)->idFrom) { case IDC_LISTMAILS: - switch(((LPNMHDR)lParam)->code) { + switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: - SendMessage(hDlg,WM_YAMN_SHOWSELECTED,0,0); + SendMessage(hDlg, WM_YAMN_SHOWSELECTED, 0, 0); break; case LVN_COLUMNCLICK: HACCOUNT ActualAccount; - if (NULL != (ActualAccount=GetWindowAccount(hDlg))) { + if (NULL != (ActualAccount = GetWindowAccount(hDlg))) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam; - if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO)) + if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) { #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:COLUMNCLICK:ActualAccountSO-read enter\n"); #endif - switch((int)pNMListView->iSubItem) + switch ((int)pNMListView->iSubItem) { case 0: bFrom = !bFrom; @@ -2274,7 +2288,7 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM default: break; } - ListView_SortItems(pNMListView->hdr.hwndFrom,ListViewCompareProc,pNMListView->iSubItem); + ListView_SortItems(pNMListView->hdr.hwndFrom, ListViewCompareProc, pNMListView->iSubItem); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n"); #endif @@ -2284,124 +2298,124 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM break; case NM_CUSTOMDRAW: - { - HACCOUNT ActualAccount; - LPNMLVCUSTOMDRAW cd=(LPNMLVCUSTOMDRAW)lParam; - LONG_PTR PaintCode; + { + HACCOUNT ActualAccount; + LPNMLVCUSTOMDRAW cd = (LPNMLVCUSTOMDRAW)lParam; + LONG_PTR PaintCode; - if (NULL==(ActualAccount=GetWindowAccount(hDlg))) - break; + if (NULL == (ActualAccount = GetWindowAccount(hDlg))) + break; - switch(cd->nmcd.dwDrawStage) { - case CDDS_PREPAINT: - PaintCode=CDRF_NOTIFYITEMDRAW; - break; - case CDDS_ITEMPREPAINT: - PaintCode=CDRF_NOTIFYSUBITEMDRAW; - break; - case CDDS_ITEMPREPAINT | CDDS_SUBITEM: - { - // COLORREF crText, crBkgnd; - // crText= RGB(128,128,255); - HYAMNMAIL ActualMail; - BOOL umma; + switch (cd->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + PaintCode = CDRF_NOTIFYITEMDRAW; + break; + case CDDS_ITEMPREPAINT: + PaintCode = CDRF_NOTIFYSUBITEMDRAW; + break; + case CDDS_ITEMPREPAINT | CDDS_SUBITEM: + { + // COLORREF crText, crBkgnd; + // crText= RGB(128,128,255); + HYAMNMAIL ActualMail; + BOOL umma; - { - struct CMailWinUserInfo *mwui; - mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER); - umma= mwui->UpdateMailsMessagesAccess; - } - ActualMail=(HYAMNMAIL)cd->nmcd.lItemlParam; - if (!ActualMail) - ActualMail=(HYAMNMAIL)readItemLParam(cd->nmcd.hdr.hwndFrom,cd->nmcd.dwItemSpec); + { + struct CMailWinUserInfo *mwui; + mwui = (struct CMailWinUserInfo *)GetWindowLongPtr(hDlg, DWLP_USER); + umma = mwui->UpdateMailsMessagesAccess; + } + ActualMail = (HYAMNMAIL)cd->nmcd.lItemlParam; + if (!ActualMail) + ActualMail = (HYAMNMAIL)readItemLParam(cd->nmcd.hdr.hwndFrom, cd->nmcd.dwItemSpec); #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait\n"); + DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait\n"); #endif - if (!umma) - if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->MessagesAccessSO)) - { + if (!umma) + if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->MessagesAccessSO)) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait failed\n"); + DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait failed\n"); #endif - return 0; - } + return 0; + } #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read enter\n"); + DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read enter\n"); #endif - switch(ActualMail->Flags & YAMN_MSG_SPAMMASK) - { - case YAMN_MSG_SPAML1: - case YAMN_MSG_SPAML2: - cd->clrText=RGB(150,150,150); - break; - case YAMN_MSG_SPAML3: - cd->clrText=RGB(200,200,200); - cd->clrTextBk=RGB(160,160,160); - break; - case 0: - if (cd->nmcd.dwItemSpec & 1) - cd->clrTextBk=RGB(230,230,230); - break; - default: - break; - } - if (ActualMail->Flags & YAMN_MSG_UNSEEN) - cd->clrTextBk=RGB(220,235,250); - PaintCode=CDRF_DODEFAULT; + switch (ActualMail->Flags & YAMN_MSG_SPAMMASK) + { + case YAMN_MSG_SPAML1: + case YAMN_MSG_SPAML2: + cd->clrText = RGB(150, 150, 150); + break; + case YAMN_MSG_SPAML3: + cd->clrText = RGB(200, 200, 200); + cd->clrTextBk = RGB(160, 160, 160); + break; + case 0: + if (cd->nmcd.dwItemSpec & 1) + cd->clrTextBk = RGB(230, 230, 230); + break; + default: + break; + } + if (ActualMail->Flags & YAMN_MSG_UNSEEN) + cd->clrTextBk = RGB(220, 235, 250); + PaintCode = CDRF_DODEFAULT; - if (!umma) - { + if (!umma) + { #ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read done\n"); + DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read done\n"); #endif - ReadDoneFcn(ActualAccount->MessagesAccessSO); - } - - break; - } + ReadDoneFcn(ActualAccount->MessagesAccessSO); } - SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PaintCode); - return 1; + + break; + } } + SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PaintCode); + return 1; + } } } break; case WM_CONTEXTMENU: - if ( GetWindowLongPtr(( HWND )wParam, GWLP_ID ) == IDC_LISTMAILS) { + if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == IDC_LISTMAILS) { //MessageBox(0,"LISTHEADERS","Debug",0); - HWND hList = GetDlgItem( hDlg, IDC_LISTMAILS ); - POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) }; + HWND hList = GetDlgItem(hDlg, IDC_LISTMAILS); + POINT pt = { (signed short)LOWORD(lParam), (signed short)HIWORD(lParam) }; HTREEITEM hItem = 0; - if (pt.x==-1) pt.x = 0; - if (pt.y==-1) pt.y = 0; + if (pt.x == -1) pt.x = 0; + if (pt.y == -1) pt.y = 0; if (int numRows = ListView_GetItemCount(hList)) { HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, TranslateT("Copy Selected")); AppendMenu(hMenu, MF_STRING, (UINT_PTR)2, TranslateT("Copy All")); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel")); - int nReturnCmd = TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL ); - DestroyMenu( hMenu ); - if (nReturnCmd>0) { - int courRow=0; + int nReturnCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL); + DestroyMenu(hMenu); + if (nReturnCmd > 0) { + int courRow = 0; size_t sizeNeeded = 0; - TCHAR from[128]={0}, subject[256]={0}, size[16]={0}, date[64]={0}; - for (courRow=0;courRow<numRows;courRow++) { - if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue; + TCHAR from[128] = { 0 }, subject[256] = { 0 }, size[16] = { 0 }, date[64] = { 0 }; + for (courRow = 0; courRow < numRows; courRow++) { + if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; ListView_GetItemText(hList, courRow, 0, from, SIZEOF(from)); ListView_GetItemText(hList, courRow, 1, subject, SIZEOF(subject)); ListView_GetItemText(hList, courRow, 2, size, SIZEOF(size)); ListView_GetItemText(hList, courRow, 3, date, SIZEOF(date)); - sizeNeeded += 5+_tcslen(from)+_tcslen(subject)+_tcslen(size)+_tcslen(date); + sizeNeeded += 5 + _tcslen(from) + _tcslen(subject) + _tcslen(size) + _tcslen(date); } if (sizeNeeded && OpenClipboard(hDlg)) { EmptyClipboard(); - HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE,(sizeNeeded+1)*sizeof(TCHAR)); + HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (sizeNeeded + 1)*sizeof(TCHAR)); TCHAR *buff = (TCHAR *)GlobalLock(hData); int courPos = 0; - for (courRow=0; courRow < numRows; courRow++) { - if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue; + for (courRow = 0; courRow < numRows; courRow++) { + if ((nReturnCmd == 1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED) == 0)) continue; ListView_GetItemText(hList, courRow, 0, from, SIZEOF(from)); ListView_GetItemText(hList, courRow, 1, subject, SIZEOF(subject)); ListView_GetItemText(hList, courRow, 2, size, SIZEOF(size)); @@ -2410,7 +2424,7 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM } GlobalUnlock(hData); - SetClipboardData(CF_UNICODETEXT,hData); + SetClipboardData(CF_UNICODETEXT, hData); CloseClipboard(); } @@ -2425,114 +2439,114 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM LRESULT CALLBACK ListViewSubclassProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndParent = GetParent(hDlg); - - switch(msg) { - case WM_GETDLGCODE : - { - LPMSG lpmsg; - if ( ( lpmsg = (LPMSG)lParam ) != NULL ) { - if ( lpmsg->message == WM_KEYDOWN - && lpmsg->wParam == VK_RETURN) - return DLGC_WANTALLKEYS; - } - break; - } - case WM_KEYDOWN: - { - - BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000; - BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000; - BOOL isAlt = GetKeyState(VK_MENU) & 0x8000; - - switch (wParam) - { - case 'A': // ctrl-a - if (!isAlt && !isShift && isCtrl) SendMessage(hwndParent,WM_COMMAND,IDC_BTNCHECKALL,0); - break; - case VK_RETURN: - case VK_SPACE: - if (!isAlt && !isShift && !isCtrl) SendMessage(hwndParent,WM_YAMN_SHOWSELECTED,0,0); - break; - case VK_DELETE: - SendMessage(hwndParent,WM_COMMAND,IDC_BTNDEL,0); - break; - } - - break; + switch (msg) { + case WM_GETDLGCODE: + { + LPMSG lpmsg; + if ((lpmsg = (LPMSG)lParam) != NULL) { + if (lpmsg->message == WM_KEYDOWN + && lpmsg->wParam == VK_RETURN) + return DLGC_WANTALLKEYS; } + break; + } + case WM_KEYDOWN: + { + + BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000; + BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000; + BOOL isAlt = GetKeyState(VK_MENU) & 0x8000; + + switch (wParam) + { + case 'A': // ctrl-a + if (!isAlt && !isShift && isCtrl) SendMessage(hwndParent, WM_COMMAND, IDC_BTNCHECKALL, 0); + break; + case VK_RETURN: + case VK_SPACE: + if (!isAlt && !isShift && !isCtrl) SendMessage(hwndParent, WM_YAMN_SHOWSELECTED, 0, 0); + break; + case VK_DELETE: + SendMessage(hwndParent, WM_COMMAND, IDC_BTNDEL, 0); + break; + } + + break; + + } } return mir_callNextSubclass(hDlg, ListViewSubclassProc, msg, wParam, lParam); } -DWORD WINAPI MailBrowser(LPVOID Param) +void __cdecl MailBrowser(void *Param) { MSG msg; HWND hMailBrowser; - BOOL WndFound=FALSE; + BOOL WndFound = FALSE; HACCOUNT ActualAccount; struct MailBrowserWinParam MyParam; - MyParam=*(struct MailBrowserWinParam *)Param; - ActualAccount=MyParam.account; - #ifdef DEBUG_SYNCHRO + MyParam = *(struct MailBrowserWinParam *)Param; + ActualAccount = MyParam.account; +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount); - #endif +#endif SCIncFcn(ActualAccount->UsingThreads); -// we will not use params in stack anymore + // we will not use params in stack anymore SetEvent(MyParam.ThreadRunningEV); __try { - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read wait\n"); - #endif +#endif if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO)) { - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read wait failed\n"); - #endif - return 0; +#endif + return; } - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read enter\n"); - #endif +#endif if (!(ActualAccount->AbilityFlags & YAMN_ACC_BROWSE)) { - MyParam.nflags=MyParam.nflags & ~YAMN_ACC_MSG; - MyParam.nnflags=MyParam.nnflags & ~YAMN_ACC_MSG; + MyParam.nflags = MyParam.nflags & ~YAMN_ACC_MSG; + MyParam.nnflags = MyParam.nnflags & ~YAMN_ACC_MSG; } if (!(ActualAccount->AbilityFlags & YAMN_ACC_POPUP)) - MyParam.nflags=MyParam.nflags & ~YAMN_ACC_POP; - #ifdef DEBUG_SYNCHRO + MyParam.nflags = MyParam.nflags & ~YAMN_ACC_POP; +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read done\n"); - #endif +#endif ReadDoneFcn(ActualAccount->AccountAccessSO); - if (NULL != (hMailBrowser=WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)ActualAccount))) - WndFound=TRUE; - if ((hMailBrowser==NULL) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) + if (NULL != (hMailBrowser = WindowList_Find(YAMNVar.NewMailAccountWnd, (MCONTACT)ActualAccount))) + WndFound = TRUE; + if ((hMailBrowser == NULL) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) { - hMailBrowser=CreateDialogParamW(YAMNVar.hInst,MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES),NULL,DlgProcYAMNMailBrowser,(LPARAM)&MyParam); - SendMessageW(hMailBrowser,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)g_LoadIconEx(2,true)); - SendMessageW(hMailBrowser,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)g_LoadIconEx(2)); - MoveWindow(hMailBrowser,PosX,PosY,SizeX,SizeY,TRUE); + hMailBrowser = CreateDialogParamW(YAMNVar.hInst, MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), NULL, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); + SendMessageW(hMailBrowser, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)g_LoadIconEx(2, true)); + SendMessageW(hMailBrowser, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_LoadIconEx(2)); + MoveWindow(hMailBrowser, PosX, PosY, SizeX, SizeY, TRUE); } if (hMailBrowser != NULL) { - struct CChangeContent Params={MyParam.nflags,MyParam.nnflags}; //if this thread created window, just post message to update mails + struct CChangeContent Params = { MyParam.nflags, MyParam.nnflags }; //if this thread created window, just post message to update mails - SendMessageW(hMailBrowser,WM_YAMN_CHANGECONTENT,(WPARAM)ActualAccount,(LPARAM)&Params); //we ensure this will do the thread who created the browser window + SendMessageW(hMailBrowser, WM_YAMN_CHANGECONTENT, (WPARAM)ActualAccount, (LPARAM)&Params); //we ensure this will do the thread who created the browser window } else - UpdateMails(NULL,ActualAccount,MyParam.nflags,MyParam.nnflags); //update mails without displaying or refreshing any window + UpdateMails(NULL, ActualAccount, MyParam.nflags, MyParam.nnflags); //update mails without displaying or refreshing any window if ((hMailBrowser != NULL) && !WndFound) //we process message loop only for thread that created window { - while(GetMessage(&msg,NULL,0,0)) + while (GetMessage(&msg, NULL, 0, 0)) { if (hMailBrowser == NULL || !IsDialogMessage(hMailBrowser, &msg)) { /* Wine fix. */ TranslateMessage(&msg); @@ -2546,32 +2560,30 @@ DWORD WINAPI MailBrowser(LPVOID Param) } __finally { - #ifdef DEBUG_SYNCHRO +#ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"MailBrowser:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount); - #endif +#endif SCDecFcn(ActualAccount->UsingThreads); } - return 1; } -INT_PTR RunMailBrowserSvc(WPARAM wParam,LPARAM lParam) +INT_PTR RunMailBrowserSvc(WPARAM wParam, LPARAM lParam) { - DWORD tid; //an event for successfull copy parameters to which point a pointer in stack for new thread HANDLE ThreadRunningEV; - PYAMN_MAILBROWSERPARAM Param=(PYAMN_MAILBROWSERPARAM)wParam; + PYAMN_MAILBROWSERPARAM Param = (PYAMN_MAILBROWSERPARAM)wParam; if ((DWORD)lParam != YAMN_MAILBROWSERVERSION) return 0; - if (NULL != (ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL))) + if (NULL != (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL))) { HANDLE NewThread; - Param->ThreadRunningEV=ThreadRunningEV; - if (NULL != (NewThread=CreateThread(NULL,0,MailBrowser,Param,0,&tid))) + Param->ThreadRunningEV = ThreadRunningEV; + if (NULL != (NewThread = mir_forkthread(MailBrowser, (void*)Param))) { - WaitForSingleObject(ThreadRunningEV,INFINITE); + WaitForSingleObject(ThreadRunningEV, INFINITE); CloseHandle(NewThread); } CloseHandle(ThreadRunningEV); diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp index e2994d88b9..4bebbbbd91 100644 --- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -7,7 +7,7 @@ *
* (c) majvan 2002-2004
* 18/08
-*/
+ */
#include "../../yamn.h"
@@ -16,11 +16,11 @@ //--------------------------------------------------------------------------------------------------
-HANDLE hNetLib = NULL;
-PSCOUNTER CPOP3Account::AccountWriterSO = NULL;
+HANDLE hNetLib = NULL;
+PSCOUNTER CPOP3Account::AccountWriterSO = NULL;
//Creates new CPOP3Account structure
-HACCOUNT WINAPI CreatePOP3Account(HYAMNPROTOPLUGIN Plugin,DWORD CAccountVersion);
+HACCOUNT WINAPI CreatePOP3Account(HYAMNPROTOPLUGIN Plugin, DWORD CAccountVersion);
//Deletes CPOP3Account structure
void WINAPI DeletePOP3Account(HACCOUNT Which);
@@ -29,7 +29,7 @@ void WINAPI DeletePOP3Account(HACCOUNT Which); void WINAPI StopPOP3Account(HACCOUNT Which);
//Function registers standard functions for YAMN
-int RegisterPOP3Plugin(WPARAM,LPARAM);
+int RegisterPOP3Plugin(WPARAM, LPARAM);
//Unloads all variables created on heap (delete[])
DWORD WINAPI UnLoadPOP3(void *);
@@ -38,17 +38,17 @@ DWORD WINAPI UnLoadPOP3(void *); DWORD WINAPI WritePOP3Accounts();
//Function stores plugin's data for account to file
-DWORD WINAPI WritePOP3Options(HANDLE,HACCOUNT);
+DWORD WINAPI WritePOP3Options(HANDLE, HACCOUNT);
//Function reads plugin's data for account from file
-DWORD WINAPI ReadPOP3Options(HACCOUNT,char **,char *);
+DWORD WINAPI ReadPOP3Options(HACCOUNT, char **, char *);
//Creates new mail for an account
-HYAMNMAIL WINAPI CreatePOP3Mail(HACCOUNT Account,DWORD CMimeMailVersion);
+HYAMNMAIL WINAPI CreatePOP3Mail(HACCOUNT Account, DWORD CMimeMailVersion);
//Function does all needed work when connection failed or any error occured
//Creates structure containing error code, closes internet session, runs "bad connect" function
-static void PostErrorProc(HPOP3ACCOUNT ActualAccount,void *ParamToBadConnect,DWORD POP3PluginParam,BOOL UseSSL);
+static void PostErrorProc(HPOP3ACCOUNT ActualAccount, void *ParamToBadConnect, DWORD POP3PluginParam, BOOL UseSSL);
//Checks POP3 account and stores all info to account. It deletes old mails=> synchro
// WhichTemp- pointer to strucure containing needed information
@@ -57,7 +57,7 @@ DWORD WINAPI SynchroPOP3(struct CheckParam *WhichTemp); //Deletes mails from POP3 server
// WhichTemp- structure containing needed information (queued messages to delete)
//Function deletes from memory queue in WhichTemp structure
-DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp);
+void __cdecl DeleteMailsPOP3(void *param);
//Function makes readable message about error. It sends it back to YAMN, so YAMN then
//can show it to the message window
@@ -71,24 +71,24 @@ void WINAPI DeleteErrorString(LPVOID String); // len- length of source string
// mboxsize- adreess to integer, that receives size of mailbox
// mails- adreess to integer, that receives number of mails
-void ExtractStat(char *stream,int len,int *mboxsize,int *mails);
+void ExtractStat(char *stream, int len, int *mboxsize, int *mails);
//Extracts mail ID on mailbox
// stream- source string
// len- length of source string
// queue- address of first message, where first ID will be stored
-void ExtractUIDL(char *stream,int len,HYAMNMAIL queue);
+void ExtractUIDL(char *stream, int len, HYAMNMAIL queue);
//Extracts mail size on mailbox
// stream- source string
// len- length of source string
// queue- address of first message, where size of message #1 will be stored
-void ExtractList(char *stream,int len,HYAMNMAIL queue);
+void ExtractList(char *stream, int len, HYAMNMAIL queue);
-void ExtractMail(char *stream,int len,HYAMNMAIL queue);
+void ExtractMail(char *stream, int len, HYAMNMAIL queue);
-YAMNExportedFcns *pYAMNFcn = NULL;
-MailExportedFcns *pYAMNMailFcn = NULL;
+YAMNExportedFcns *pYAMNFcn = NULL;
+MailExportedFcns *pYAMNMailFcn = NULL;
YAMN_PROTOIMPORTFCN POP3ProtocolFunctions =
{
@@ -117,8 +117,8 @@ YAMN_MAILIMPORTFCN POP3MailFunctions = NULL,
};
-PYAMN_VARIABLES pYAMNVar = NULL;
-HYAMNPROTOPLUGIN POP3Plugin = NULL;
+PYAMN_VARIABLES pYAMNVar = NULL;
+HYAMNPROTOPLUGIN POP3Plugin = NULL;
YAMN_PROTOREGISTRATION POP3ProtocolRegistration =
{
@@ -139,14 +139,14 @@ HANDLE RegisterNLClient(const char *name); CPOP3Account::CPOP3Account()
{
-//NOTE! This constructor constructs CAccount structure. If your plugin is not internal,
-//you will need these constructors. All you need is in Account.cpp. Just copy to your source code
-//constructor and destructor of CAccount.
- UseInternetFree=CreateEvent(NULL,FALSE,TRUE,NULL);
- InternetQueries=new SCOUNTER;
- AbilityFlags=YAMN_ACC_BROWSE | YAMN_ACC_POPUP;
-
- SetAccountStatus((HACCOUNT)this,TranslateT("Disconnected"));
+ //NOTE! This constructor constructs CAccount structure. If your plugin is not internal,
+ //you will need these constructors. All you need is in Account.cpp. Just copy to your source code
+ //constructor and destructor of CAccount.
+ UseInternetFree = CreateEvent(NULL, FALSE, TRUE, NULL);
+ InternetQueries = new SCOUNTER;
+ AbilityFlags = YAMN_ACC_BROWSE | YAMN_ACC_POPUP;
+
+ SetAccountStatus((HACCOUNT)this, TranslateT("Disconnected"));
}
CPOP3Account::~CPOP3Account()
@@ -156,15 +156,15 @@ CPOP3Account::~CPOP3Account() delete InternetQueries;
}
-HACCOUNT WINAPI CreatePOP3Account(HYAMNPROTOPLUGIN Plugin,DWORD CAccountVersion)
+HACCOUNT WINAPI CreatePOP3Account(HYAMNPROTOPLUGIN Plugin, DWORD CAccountVersion)
{
-//First, we should check whether CAccountVersion matches.
-//But this is internal plugin, so YAMN's CAccount structure and our CAccount structure are
-//the same, so we do not need to test version. Otherwise, if CAccount version does not match
-//in your plugin, you should return NULL, like this:
-// if (CAccountVersion != YAMN_ACCOUNTVERSION) return NULL;
+ //First, we should check whether CAccountVersion matches.
+ //But this is internal plugin, so YAMN's CAccount structure and our CAccount structure are
+ //the same, so we do not need to test version. Otherwise, if CAccount version does not match
+ //in your plugin, you should return NULL, like this:
+ // if (CAccountVersion != YAMN_ACCOUNTVERSION) return NULL;
-//Now it is needed to construct our POP3 account and return its handle
+ //Now it is needed to construct our POP3 account and return its handle
return (HACCOUNT)new struct CPOP3Account();
}
@@ -175,110 +175,118 @@ void WINAPI DeletePOP3Account(HACCOUNT Which) void WINAPI StopPOP3Account(HACCOUNT Which)
{
- ((HPOP3ACCOUNT)Which)->Client.Stopped=TRUE;
+ ((HPOP3ACCOUNT)Which)->Client.Stopped = TRUE;
if (((HPOP3ACCOUNT)Which)->Client.NetClient != NULL) //we should inform also network client. Usefull only when network client implements this feature
- ((HPOP3ACCOUNT)Which)->Client.NetClient->Stopped=TRUE;
+ ((HPOP3ACCOUNT)Which)->Client.NetClient->Stopped = TRUE;
}
//This function is like main function for POP3 internal protocol
-int RegisterPOP3Plugin(WPARAM,LPARAM)
+int RegisterPOP3Plugin(WPARAM, LPARAM)
{
//Get YAMN variables we can use
- if (NULL==(pYAMNVar=(PYAMN_VARIABLES)CallService(MS_YAMN_GETVARIABLES,(WPARAM)YAMN_VARIABLESVERSION,0)))
+ if (NULL == (pYAMNVar = (PYAMN_VARIABLES)CallService(MS_YAMN_GETVARIABLES, (WPARAM)YAMN_VARIABLESVERSION, 0)))
return 0;
//We have to get pointers to YAMN exported functions: allocate structure and fill it
- if (NULL==(pYAMNFcn=new struct YAMNExportedFcns))
- {UnLoadPOP3(0); return 0;}
+ if (NULL == (pYAMNFcn = new struct YAMNExportedFcns))
+ {
+ UnLoadPOP3(0); return 0;
+ }
//Register new pop3 user in netlib
- if (NULL==(hNetLib=RegisterNLClient("YAMN-POP3")))
- {UnLoadPOP3(0); return 0;}
-
- pYAMNFcn->SetProtocolPluginFcnImportFcn=(YAMN_SETPROTOCOLPLUGINFCNIMPORTFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SETPROTOCOLPLUGINFCNIMPORTID,0);
- pYAMNFcn->WaitToWriteFcn=(YAMN_WAITTOWRITEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_WAITTOWRITEID,0);
- pYAMNFcn->WriteDoneFcn=(YAMN_WRITEDONEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_WRITEDONEID,0);
- pYAMNFcn->WaitToReadFcn=(YAMN_WAITTOREADFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_WAITTOREADID,0);
- pYAMNFcn->ReadDoneFcn=(YAMN_READDONEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_READDONEID,0);
- pYAMNFcn->SCGetNumberFcn=(YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SCGETNUMBERID,0);
- pYAMNFcn->SCIncFcn=(YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SCINCID,0);
- pYAMNFcn->SCDecFcn=(YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SCDECID,0);
- pYAMNFcn->SetStatusFcn=(YAMN_SETSTATUSFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SETSTATUSID,0);
- pYAMNFcn->GetStatusFcn=(YAMN_GETSTATUSFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_GETSTATUSID,0);
-
- if (NULL==(pYAMNMailFcn=new struct MailExportedFcns))
- {UnLoadPOP3(0); return 0;}
-
- pYAMNMailFcn->SynchroMessagesFcn=(YAMN_SYNCHROMIMEMSGSFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SYNCHROMIMEMSGSID,0);
- pYAMNMailFcn->TranslateHeaderFcn=(YAMN_TRANSLATEHEADERFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_TRANSLATEHEADERID,0);
- pYAMNMailFcn->AppendQueueFcn=(YAMN_APPENDQUEUEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_APPENDQUEUEID,0);
- pYAMNMailFcn->DeleteMessagesToEndFcn=(YAMN_DELETEMIMEQUEUEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_DELETEMIMEQUEUEID,0);
- pYAMNMailFcn->DeleteMessageFromQueueFcn=(YAMN_DELETEMIMEMESSAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_DELETEMIMEMESSAGEID,0);
- pYAMNMailFcn->FindMessageByIDFcn=(YAMN_FINDMIMEMESSAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_FINDMIMEMESSAGEID,0);
- pYAMNMailFcn->CreateNewDeleteQueueFcn=(YAMN_CREATENEWDELETEQUEUEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_CREATENEWDELETEQUEUEID,0);
+ if (NULL == (hNetLib = RegisterNLClient("YAMN-POP3")))
+ {
+ UnLoadPOP3(0); return 0;
+ }
+
+ pYAMNFcn->SetProtocolPluginFcnImportFcn = (YAMN_SETPROTOCOLPLUGINFCNIMPORTFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_SETPROTOCOLPLUGINFCNIMPORTID, 0);
+ pYAMNFcn->WaitToWriteFcn = (YAMN_WAITTOWRITEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_WAITTOWRITEID, 0);
+ pYAMNFcn->WriteDoneFcn = (YAMN_WRITEDONEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_WRITEDONEID, 0);
+ pYAMNFcn->WaitToReadFcn = (YAMN_WAITTOREADFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_WAITTOREADID, 0);
+ pYAMNFcn->ReadDoneFcn = (YAMN_READDONEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_READDONEID, 0);
+ pYAMNFcn->SCGetNumberFcn = (YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_SCGETNUMBERID, 0);
+ pYAMNFcn->SCIncFcn = (YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_SCINCID, 0);
+ pYAMNFcn->SCDecFcn = (YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_SCDECID, 0);
+ pYAMNFcn->SetStatusFcn = (YAMN_SETSTATUSFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_SETSTATUSID, 0);
+ pYAMNFcn->GetStatusFcn = (YAMN_GETSTATUSFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_GETSTATUSID, 0);
+
+ if (NULL == (pYAMNMailFcn = new struct MailExportedFcns))
+ {
+ UnLoadPOP3(0); return 0;
+ }
+
+ pYAMNMailFcn->SynchroMessagesFcn = (YAMN_SYNCHROMIMEMSGSFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_SYNCHROMIMEMSGSID, 0);
+ pYAMNMailFcn->TranslateHeaderFcn = (YAMN_TRANSLATEHEADERFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_TRANSLATEHEADERID, 0);
+ pYAMNMailFcn->AppendQueueFcn = (YAMN_APPENDQUEUEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_APPENDQUEUEID, 0);
+ pYAMNMailFcn->DeleteMessagesToEndFcn = (YAMN_DELETEMIMEQUEUEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_DELETEMIMEQUEUEID, 0);
+ pYAMNMailFcn->DeleteMessageFromQueueFcn = (YAMN_DELETEMIMEMESSAGEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_DELETEMIMEMESSAGEID, 0);
+ pYAMNMailFcn->FindMessageByIDFcn = (YAMN_FINDMIMEMESSAGEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_FINDMIMEMESSAGEID, 0);
+ pYAMNMailFcn->CreateNewDeleteQueueFcn = (YAMN_CREATENEWDELETEQUEUEFCN)CallService(MS_YAMN_GETFCNPTR, (WPARAM)YAMN_CREATENEWDELETEQUEUEID, 0);
//set static variable
- if (CPOP3Account::AccountWriterSO==NULL) {
- if (NULL==(CPOP3Account::AccountWriterSO=new SCOUNTER))
- {UnLoadPOP3(0); return 0;}
+ if (CPOP3Account::AccountWriterSO == NULL) {
+ if (NULL == (CPOP3Account::AccountWriterSO = new SCOUNTER))
+ {
+ UnLoadPOP3(0); return 0;
+ }
}
//First, we register this plugin
//it is quite impossible this function returns zero (failure) as YAMN and internal plugin structre versions are the same
POP3ProtocolRegistration.Name = Translate("POP3 protocol (internal)");
POP3ProtocolRegistration.Description = Translate(__DESCRIPTION);
- if (NULL==(POP3Plugin=(HYAMNPROTOPLUGIN)CallService(MS_YAMN_REGISTERPROTOPLUGIN,(WPARAM)&POP3ProtocolRegistration,(LPARAM)YAMN_PROTOREGISTRATIONVERSION)))
+ if (NULL == (POP3Plugin = (HYAMNPROTOPLUGIN)CallService(MS_YAMN_REGISTERPROTOPLUGIN, (WPARAM)&POP3ProtocolRegistration, (LPARAM)YAMN_PROTOREGISTRATIONVERSION)))
return 0;
//Next we set our imported functions for YAMN
- if (!SetProtocolPluginFcnImport(POP3Plugin,&POP3ProtocolFunctions,YAMN_PROTOIMPORTFCNVERSION,&POP3MailFunctions,YAMN_MAILIMPORTFCNVERSION))
+ if (!SetProtocolPluginFcnImport(POP3Plugin, &POP3ProtocolFunctions, YAMN_PROTOIMPORTFCNVERSION, &POP3MailFunctions, YAMN_MAILIMPORTFCNVERSION))
return 0;
//Then, we read all mails for accounts.
//You must first register account, before using this function as YAMN must use CreatePOP3Account function to add new accounts
//But if CreatePOP3Account is not implemented (equals to NULL), YAMN creates account as YAMN's standard HACCOUNT
- if (FileName) CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName, 0); //shoud not happen (only for secure)
- FileName = (TCHAR *)CallService(MS_YAMN_GETFILENAME,(WPARAM)_T("pop3"), 0);
-
- switch(CallService(MS_YAMN_READACCOUNTS,(WPARAM)POP3Plugin,(LPARAM)FileName)) {
- case EACC_FILEVERSION:
- MessageBox(NULL,TranslateT("Found new version of account book, not compatible with this version of YAMN."),TranslateT("YAMN (internal POP3) read error"),MB_OK);
- CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
- FileName = NULL;
- return 0;
- case EACC_FILECOMPATIBILITY:
- MessageBox(NULL,TranslateT("Error reading account file. Account file corrupted."),TranslateT("YAMN (internal POP3) read error"),MB_OK);
- CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
- FileName = NULL;
- return 0;
- case EACC_ALLOC:
- MessageBox(NULL,TranslateT("Memory allocation error while data reading"),TranslateT("YAMN (internal POP3) read error"),MB_OK);
- CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
+ if (FileName) CallService(MS_YAMN_DELETEFILENAME, (WPARAM)FileName, 0); //shoud not happen (only for secure)
+ FileName = (TCHAR *)CallService(MS_YAMN_GETFILENAME, (WPARAM)_T("pop3"), 0);
+
+ switch (CallService(MS_YAMN_READACCOUNTS, (WPARAM)POP3Plugin, (LPARAM)FileName)) {
+ case EACC_FILEVERSION:
+ MessageBox(NULL, TranslateT("Found new version of account book, not compatible with this version of YAMN."), TranslateT("YAMN (internal POP3) read error"), MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME, (WPARAM)FileName, 0);
+ FileName = NULL;
+ return 0;
+ case EACC_FILECOMPATIBILITY:
+ MessageBox(NULL, TranslateT("Error reading account file. Account file corrupted."), TranslateT("YAMN (internal POP3) read error"), MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME, (WPARAM)FileName, 0);
+ FileName = NULL;
+ return 0;
+ case EACC_ALLOC:
+ MessageBox(NULL, TranslateT("Memory allocation error while data reading"), TranslateT("YAMN (internal POP3) read error"), MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME, (WPARAM)FileName, 0);
+ FileName = NULL;
+ return 0;
+ case EACC_SYSTEM:
+ if (ERROR_FILE_NOT_FOUND != GetLastError())
+ {
+ TCHAR temp[1024] = { 0 };
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Reading file error. File already in use?"), FileName);
+ MessageBox(NULL, temp, TranslateT("YAMN (internal POP3) read error"), MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME, (WPARAM)FileName, 0);
FileName = NULL;
return 0;
- case EACC_SYSTEM:
- if (ERROR_FILE_NOT_FOUND != GetLastError())
- {
- TCHAR temp[1024] = {0};
- mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Reading file error. File already in use?"), FileName);
- MessageBox(NULL,temp,TranslateT("YAMN (internal POP3) read error"),MB_OK);
- CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
- FileName = NULL;
- return 0;
- }
- break;
+ }
+ break;
}
//HookEvent(ME_OPT_INITIALISE,POP3OptInit);
HACCOUNT Finder;
DBVARIANT dbv;
- for (Finder=POP3Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next) {
+ for (Finder = POP3Plugin->FirstAccount; Finder != NULL; Finder = Finder->Next) {
Finder->hContact = NULL;
for (MCONTACT hContact = db_find_first(YAMN_DBMODULE); hContact; hContact = db_find_next(hContact, YAMN_DBMODULE)) {
- if (!db_get_s(hContact,YAMN_DBMODULE,"Id",&dbv)) {
- if ( strcmp( dbv.pszVal, Finder->Name) == 0) {
+ if (!db_get_s(hContact, YAMN_DBMODULE, "Id", &dbv)) {
+ if (strcmp(dbv.pszVal, Finder->Name) == 0) {
Finder->hContact = hContact;
db_set_w(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE);
db_set_s(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message"));
@@ -296,9 +304,9 @@ int RegisterPOP3Plugin(WPARAM,LPARAM) //No account contact found, have to create one
Finder->hContact = CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, Finder->hContact, (LPARAM)YAMN_DBMODULE);
- db_set_s(Finder->hContact,YAMN_DBMODULE,"Id",Finder->Name);
- db_set_s(Finder->hContact,YAMN_DBMODULE,"Nick",Finder->Name);
- db_set_s(Finder->hContact,"Protocol","p",YAMN_DBMODULE);
+ db_set_s(Finder->hContact, YAMN_DBMODULE, "Id", Finder->Name);
+ db_set_s(Finder->hContact, YAMN_DBMODULE, "Nick", Finder->Name);
+ db_set_s(Finder->hContact, "Protocol", "p", YAMN_DBMODULE);
db_set_w(Finder->hContact, YAMN_DBMODULE, "Status", YAMN_STATUS);
}
}
@@ -310,61 +318,66 @@ DWORD WINAPI UnLoadPOP3(void *) {
//pYAMNVar is only a pointr, no need delete or free
if (hNetLib) {
- Netlib_CloseHandle(hNetLib); hNetLib = NULL;}
+ Netlib_CloseHandle(hNetLib); hNetLib = NULL;
+ }
if (CPOP3Account::AccountWriterSO) {
- delete CPOP3Account::AccountWriterSO; CPOP3Account::AccountWriterSO = NULL;}
+ delete CPOP3Account::AccountWriterSO; CPOP3Account::AccountWriterSO = NULL;
+ }
if (pYAMNMailFcn) {
- delete pYAMNMailFcn; pYAMNMailFcn = NULL;}
+ delete pYAMNMailFcn; pYAMNMailFcn = NULL;
+ }
if (pYAMNFcn) {
- delete pYAMNFcn; pYAMNFcn = NULL;}
+ delete pYAMNFcn; pYAMNFcn = NULL;
+ }
if (FileName) {
- CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0); FileName = NULL;}
+ CallService(MS_YAMN_DELETEFILENAME, (WPARAM)FileName, 0); FileName = NULL;
+ }
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"UnLoadPOP3:done\n");
- #endif
+#endif
return 1;
}
DWORD WINAPI WritePOP3Accounts()
{
- DWORD ReturnValue = CallService(MS_YAMN_WRITEACCOUNTS,(WPARAM)POP3Plugin,(LPARAM)FileName);
+ DWORD ReturnValue = CallService(MS_YAMN_WRITEACCOUNTS, (WPARAM)POP3Plugin, (LPARAM)FileName);
if (ReturnValue == EACC_SYSTEM) {
- TCHAR temp[1024] = {0};
+ TCHAR temp[1024] = { 0 };
mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Error while copying data to disk occurred. Is file in use?"), FileName);
- MessageBox(NULL, temp, TranslateT("POP3 plugin - write file error"), MB_OK );
+ MessageBox(NULL, temp, TranslateT("POP3 plugin - write file error"), MB_OK);
}
return ReturnValue;
}
-DWORD WINAPI WritePOP3Options(HANDLE File,HACCOUNT Which)
+DWORD WINAPI WritePOP3Options(HANDLE File, HACCOUNT Which)
{
DWORD WrittenBytes;
- DWORD Ver=POP3_FILEVERSION;
+ DWORD Ver = POP3_FILEVERSION;
- if ((!WriteFile(File,(char *)&Ver,sizeof(DWORD),&WrittenBytes,NULL)) ||
- (!WriteFile(File,(char *)&((HPOP3ACCOUNT)Which)->CP,sizeof(WORD),&WrittenBytes,NULL)))
+ if ((!WriteFile(File, (char *)&Ver, sizeof(DWORD), &WrittenBytes, NULL)) ||
+ (!WriteFile(File, (char *)&((HPOP3ACCOUNT)Which)->CP, sizeof(WORD), &WrittenBytes, NULL)))
return EACC_SYSTEM;
return 0;
}
-DWORD WINAPI ReadPOP3Options(HACCOUNT Which,char **Parser,char *End)
+DWORD WINAPI ReadPOP3Options(HACCOUNT Which, char **Parser, char *End)
{
DWORD Ver;
#ifdef DEBUG_FILEREAD
TCHAR Debug[256];
#endif
- Ver=*(DWORD *)(*Parser);
- (*Parser)+=sizeof(DWORD);
- if (*Parser>=End)
+ Ver = *(DWORD *)(*Parser);
+ (*Parser) += sizeof(DWORD);
+ if (*Parser >= End)
return EACC_FILECOMPATIBILITY;
if (Ver != POP3_FILEVERSION)
return EACC_FILECOMPATIBILITY;
- ((HPOP3ACCOUNT)Which)->CP=*(WORD *)(*Parser);
- (*Parser)+=sizeof(WORD);
- if (*Parser>=End)
+ ((HPOP3ACCOUNT)Which)->CP = *(WORD *)(*Parser);
+ (*Parser) += sizeof(WORD);
+ if (*Parser >= End)
return EACC_FILECOMPATIBILITY;
#ifdef DEBUG_FILEREAD
mir_sntprintf(Debug, SIZEOF(Debug), _T("CodePage: %d, remaining %d chars"), ((HPOP3ACCOUNT)Which)->CP, End-*Parser);
@@ -373,25 +386,25 @@ DWORD WINAPI ReadPOP3Options(HACCOUNT Which,char **Parser,char *End) return 0;
}
-HYAMNMAIL WINAPI CreatePOP3Mail(HACCOUNT Account,DWORD MailDataVersion)
+HYAMNMAIL WINAPI CreatePOP3Mail(HACCOUNT Account, DWORD MailDataVersion)
{
HYAMNMAIL NewMail;
-//First, we should check whether MAILDATA matches.
-//But this is internal plugin, so YAMN's MAILDATA structure and our MAILDATA structure are
-//the same, so we do not need to test version. Otherwise, if MAILDATA version does not match
-//in your plugin, you should return NULL, like this:
-// if (MailDataVersion != YAMN_MAILDATAVERSION) return NULL;
-
-//Now it is needed to construct our POP3 account and return its handle
- if (NULL==(NewMail=new YAMNMAIL))
+ //First, we should check whether MAILDATA matches.
+ //But this is internal plugin, so YAMN's MAILDATA structure and our MAILDATA structure are
+ //the same, so we do not need to test version. Otherwise, if MAILDATA version does not match
+ //in your plugin, you should return NULL, like this:
+ // if (MailDataVersion != YAMN_MAILDATAVERSION) return NULL;
+
+ //Now it is needed to construct our POP3 account and return its handle
+ if (NULL == (NewMail = new YAMNMAIL))
return NULL;
-
- if (NULL==(NewMail->MailData=new MAILDATA))
+
+ if (NULL == (NewMail->MailData = new MAILDATA))
{
delete NewMail;
return NULL;
}
- NewMail->MailData->CP=((HPOP3ACCOUNT)Account)->CP;
+ NewMail->MailData->CP = ((HPOP3ACCOUNT)Account)->CP;
return (HYAMNMAIL)NewMail;
}
@@ -401,65 +414,65 @@ static void SetContactStatus(HACCOUNT account, int status) { }
}
-static void PostErrorProc(HPOP3ACCOUNT ActualAccount,void *ParamToBadConnection,DWORD POP3PluginParam,BOOL UseSSL)
+static void PostErrorProc(HPOP3ACCOUNT ActualAccount, void *ParamToBadConnection, DWORD POP3PluginParam, BOOL UseSSL)
{
char *DataRX;
-//We create new structure, that we pass to bad connection dialog procedure. This procedure next calls YAMN imported fuction
-//from POP3 protocol to determine the description of error. We can describe error from our error code structure, because later,
-//when YAMN calls our function, it passes us our error code. This is pointer to structure for POP3 protocol in fact.
+ //We create new structure, that we pass to bad connection dialog procedure. This procedure next calls YAMN imported fuction
+ //from POP3 protocol to determine the description of error. We can describe error from our error code structure, because later,
+ //when YAMN calls our function, it passes us our error code. This is pointer to structure for POP3 protocol in fact.
PPOP3_ERRORCODE ErrorCode;
-//We store status before we do Quit(), because quit can destroy our errorcode status
- if (NULL != (ErrorCode=new POP3_ERRORCODE))
+ //We store status before we do Quit(), because quit can destroy our errorcode status
+ if (NULL != (ErrorCode = new POP3_ERRORCODE))
{
- ErrorCode->SSL=UseSSL;
- ErrorCode->AppError=ActualAccount->SystemError;
- ErrorCode->POP3Error=ActualAccount->Client.POP3Error;
- ErrorCode->NetError=ActualAccount->Client.NetClient->NetworkError;
- ErrorCode->SystemError=ActualAccount->Client.NetClient->SystemError;
+ ErrorCode->SSL = UseSSL;
+ ErrorCode->AppError = ActualAccount->SystemError;
+ ErrorCode->POP3Error = ActualAccount->Client.POP3Error;
+ ErrorCode->NetError = ActualAccount->Client.NetClient->NetworkError;
+ ErrorCode->SystemError = ActualAccount->Client.NetClient->SystemError;
}
- if (POP3PluginParam==(DWORD)NULL) //if it was normal YAMN call (force check or so on)
+ if (POP3PluginParam == (DWORD)NULL) //if it was normal YAMN call (force check or so on)
{
try
{
- DataRX=ActualAccount->Client.Quit();
+ DataRX = ActualAccount->Client.Quit();
if (DataRX != NULL)
free(DataRX);
}
- catch(...)
+ catch (...)
{
}
-//We always close connection if error occured
+ //We always close connection if error occured
try
{
ActualAccount->Client.NetClient->Disconnect();
}
- catch(...)
+ catch (...)
{
}
- SetAccountStatus(ActualAccount,TranslateT("Disconnected"));
+ SetAccountStatus(ActualAccount, TranslateT("Disconnected"));
-//If we cannot allocate memory, do nothing
- if (ErrorCode==NULL)
+ //If we cannot allocate memory, do nothing
+ if (ErrorCode == NULL)
{
SetEvent(ActualAccount->UseInternetFree);
return;
}
}
else //else it was called from POP3 plugin, probably error when deleting old mail (POP3 synchro calls POP3 delete)
- if (ErrorCode==NULL)
+ if (ErrorCode == NULL)
return;
if ((ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG) || (ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO) || (ActualAccount->BadConnectN.Flags & YAMN_ACC_POP))
{
- YAMN_BADCONNECTIONPARAM cp={(HANDLE)0,ActualAccount,(UINT_PTR)ErrorCode,ParamToBadConnection};
+ YAMN_BADCONNECTIONPARAM cp = { (HANDLE)0, ActualAccount, (UINT_PTR)ErrorCode, ParamToBadConnection };
- CallService(MS_YAMN_BADCONNECTION,(WPARAM)&cp,(LPARAM)YAMN_BADCONNECTIONVERSION);
+ CallService(MS_YAMN_BADCONNECTION, (WPARAM)&cp, (LPARAM)YAMN_BADCONNECTIONVERSION);
}
- if (POP3PluginParam==(DWORD)NULL) //if it was normal YAMN call
+ if (POP3PluginParam == (DWORD)NULL) //if it was normal YAMN call
SetEvent(ActualAccount->UseInternetFree);
}
@@ -468,13 +481,13 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) {
HPOP3ACCOUNT ActualAccount;
CPop3Client *MyClient;
- HYAMNMAIL NewMails=NULL,MsgQueuePtr=NULL;
- char* DataRX=NULL,*Temp;
- int mboxsize,msgs,i;
+ HYAMNMAIL NewMails = NULL, MsgQueuePtr = NULL;
+ char* DataRX = NULL, *Temp;
+ int mboxsize, msgs, i;
SYSTEMTIME now;
LPVOID YAMNParam;
DWORD CheckFlags;
- BOOL UsingInternet=FALSE;
+ BOOL UsingInternet = FALSE;
struct {
char *ServerName;
DWORD ServerPort;
@@ -496,57 +509,57 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) // //and then we can in our GetErrorStringFcn e.g. return string "Uncompatible version of YAMN".
// }
- ActualAccount=(HPOP3ACCOUNT)WhichTemp->AccountParam; //copy address of structure from calling thread to stack of this thread
- YAMNParam=WhichTemp->BrowserParam;
- CheckFlags=WhichTemp->Flags;
- #ifdef DEBUG_SYNCHRO
+ ActualAccount = (HPOP3ACCOUNT)WhichTemp->AccountParam; //copy address of structure from calling thread to stack of this thread
+ YAMNParam = WhichTemp->BrowserParam;
+ CheckFlags = WhichTemp->Flags;
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
- #endif
+#endif
SCInc(ActualAccount->UsingThreads);
//Unblock YAMN, signal that we have copied all parameters from YAMN thread stack
if (INVALID_HANDLE_VALUE != WhichTemp->ThreadRunningEV)
SetEvent(WhichTemp->ThreadRunningEV);
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read wait\n");
- #endif
+#endif
if (WAIT_OBJECT_0 != WaitToRead(ActualAccount))
{
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read wait failed\n");
- #endif
- #ifdef DEBUG_SYNCHRO
+#endif
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
- #endif
+#endif
SCDec(ActualAccount->UsingThreads);
return 0;
}
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read enter\n");
- #endif
- MyClient=&ActualAccount->Client;
+#endif
+ MyClient = &ActualAccount->Client;
//Now, copy all needed information about account to local variables, so ActualAccount is not blocked in read mode during all connection process, which can last for several minutes.
ActualCopied.ServerName = _strdup(ActualAccount->Server->Name);
- ActualCopied.ServerPort=ActualAccount->Server->Port;
- ActualCopied.Flags=ActualAccount->Flags;
- ActualCopied.ServerLogin=_strdup(ActualAccount->Server->Login);
- ActualCopied.ServerPasswd=_strdup(ActualAccount->Server->Passwd);
- ActualCopied.NFlags=ActualAccount->NewMailN.Flags;
- ActualCopied.NNFlags=ActualAccount->NoNewMailN.Flags;
-
- #ifdef DEBUG_SYNCHRO
+ ActualCopied.ServerPort = ActualAccount->Server->Port;
+ ActualCopied.Flags = ActualAccount->Flags;
+ ActualCopied.ServerLogin = _strdup(ActualAccount->Server->Login);
+ ActualCopied.ServerPasswd = _strdup(ActualAccount->Server->Passwd);
+ ActualCopied.NFlags = ActualAccount->NewMailN.Flags;
+ ActualCopied.NNFlags = ActualAccount->NoNewMailN.Flags;
+
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read done\n");
- #endif
+#endif
ReadDone(ActualAccount);
SCInc(ActualAccount->InternetQueries); //increment counter, that there is one more thread waiting for connection
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-wait\n");
- #endif
- WaitForSingleObject(ActualAccount->UseInternetFree,INFINITE); //wait until we can use connection
- #ifdef DEBUG_SYNCHRO
+#endif
+ WaitForSingleObject(ActualAccount->UseInternetFree, INFINITE); //wait until we can use connection
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-enter\n");
- #endif
+#endif
SCDec(ActualAccount->InternetQueries);
//OK, we enter the "use internet" section. But after we start communication, we can test if we did not enter the "use internet" section only for the reason,
@@ -554,299 +567,300 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) //the second one waiting for network access- the first one ends because we want to stop account, this one is released, but should be stopped as well).
if (!ActualAccount->AbleToWork)
{
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:stop signal-InternetFreeEV-done\n");
- #endif
+#endif
SetEvent(ActualAccount->UseInternetFree);
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:stop signal-Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
- #endif
+#endif
SCDec(ActualAccount->UsingThreads);
return 0;
}
- UsingInternet=TRUE;
+ UsingInternet = TRUE;
GetLocalTime(&now);
- ActualAccount->SystemError=0; //now we can use internet for this socket. First, clear errorcode.
+ ActualAccount->SystemError = 0; //now we can use internet for this socket. First, clear errorcode.
try
{
- SetContactStatus(ActualAccount,ID_STATUS_OCCUPIED);
- #ifdef DEBUG_COMM
+ SetContactStatus(ActualAccount, ID_STATUS_OCCUPIED);
+#ifdef DEBUG_COMM
DebugLog(CommFile,"<--------Communication-------->\n");
- #endif
+#endif
// if we are already connected, we have open session (another thread left us open session), so we don't need to login
// note that connected state without logging cannot occur, because if we close session, we always close socket too (we must close socket is the right word :))
- if ((MyClient->NetClient==NULL) || !MyClient->NetClient->Connected())
+ if ((MyClient->NetClient == NULL) || !MyClient->NetClient->Connected())
{
- SetAccountStatus(ActualAccount,TranslateT("Connecting to server"));
+ SetAccountStatus(ActualAccount, TranslateT("Connecting to server"));
- DataRX=MyClient->Connect(ActualCopied.ServerName,ActualCopied.ServerPort,ActualCopied.Flags & YAMN_ACC_SSL23,ActualCopied.Flags & YAMN_ACC_NOTLS);
- char *timestamp=NULL;
+ DataRX = MyClient->Connect(ActualCopied.ServerName, ActualCopied.ServerPort, ActualCopied.Flags & YAMN_ACC_SSL23, ActualCopied.Flags & YAMN_ACC_NOTLS);
+ char *timestamp = NULL;
if (DataRX != NULL)
{
if (ActualCopied.Flags & YAMN_ACC_APOP)
{
- char *lpos=strchr(DataRX,'<');
- char *rpos=strchr(DataRX,'>');
- if (lpos && rpos && rpos>lpos) {
- int sz=(int)(rpos-lpos+2);
- timestamp=new char[sz];
- memcpy(timestamp, lpos, sz-1);
- timestamp[sz-1]='\0';
+ char *lpos = strchr(DataRX, '<');
+ char *rpos = strchr(DataRX, '>');
+ if (lpos && rpos && rpos > lpos) {
+ int sz = (int)(rpos - lpos + 2);
+ timestamp = new char[sz];
+ memcpy(timestamp, lpos, sz - 1);
+ timestamp[sz - 1] = '\0';
}
}
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
}
- SetAccountStatus(ActualAccount,TranslateT("Entering POP3 account"));
+ SetAccountStatus(ActualAccount, TranslateT("Entering POP3 account"));
if (ActualCopied.Flags & YAMN_ACC_APOP)
{
- DataRX=MyClient->APOP(ActualCopied.ServerLogin,ActualCopied.ServerPasswd,timestamp);
+ DataRX = MyClient->APOP(ActualCopied.ServerLogin, ActualCopied.ServerPasswd, timestamp);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
delete[] timestamp;
- } else {
- DataRX=MyClient->User(ActualCopied.ServerLogin);
+ }
+ else {
+ DataRX = MyClient->User(ActualCopied.ServerLogin);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
- DataRX=MyClient->Pass(ActualCopied.ServerPasswd);
+ DataRX = NULL;
+ DataRX = MyClient->Pass(ActualCopied.ServerPasswd);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
}
}
- SetAccountStatus(ActualAccount,TranslateT("Searching for new mail message"));
+ SetAccountStatus(ActualAccount, TranslateT("Searching for new mail message"));
- DataRX=MyClient->Stat();
+ DataRX = MyClient->Stat();
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<--------Account checking-------->\n");
DebugLog(DecodeFile,"<Extracting stat>\n");
- #endif
- ExtractStat(DataRX,MyClient->NetClient->Rcv,&mboxsize,&msgs);
- #ifdef DEBUG_DECODE
+#endif
+ ExtractStat(DataRX, MyClient->NetClient->Rcv, &mboxsize, &msgs);
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<MailBoxSize>%d</MailBoxSize>\n",mboxsize);
DebugLog(DecodeFile,"<Msgs>%d</Msgs>\n",msgs);
DebugLog(DecodeFile,"</Extracting stat>\n");
- #endif
+#endif
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
- for (i=0;i<msgs;i++)
+ DataRX = NULL;
+ for (i = 0; i < msgs; i++)
{
if (!i)
- MsgQueuePtr=NewMails=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
+ MsgQueuePtr = NewMails = (HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL, (WPARAM)ActualAccount, (LPARAM)YAMN_MAILVERSION);
else
{
- MsgQueuePtr->Next=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
- MsgQueuePtr=MsgQueuePtr->Next;
+ MsgQueuePtr->Next = (HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL, (WPARAM)ActualAccount, (LPARAM)YAMN_MAILVERSION);
+ MsgQueuePtr = MsgQueuePtr->Next;
}
- if (MsgQueuePtr==NULL)
+ if (MsgQueuePtr == NULL)
{
- ActualAccount->SystemError=EPOP3_QUEUEALLOC;
+ ActualAccount->SystemError = EPOP3_QUEUEALLOC;
throw (DWORD)ActualAccount->SystemError;
}
}
if (msgs)
{
- DataRX=MyClient->List();
- #ifdef DEBUG_DECODE
+ DataRX = MyClient->List();
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Extracting list>\n");
- #endif
- ExtractList(DataRX,MyClient->NetClient->Rcv,NewMails);
- #ifdef DEBUG_DECODE
+#endif
+ ExtractList(DataRX, MyClient->NetClient->Rcv, NewMails);
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"</Extracting list>\n");
- #endif
+#endif
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Extracting UIDL>\n");
- #endif
- DataRX=MyClient->Uidl();
- ExtractUIDL(DataRX,MyClient->NetClient->Rcv,NewMails);
- #ifdef DEBUG_DECODE
+#endif
+ DataRX = MyClient->Uidl();
+ ExtractUIDL(DataRX, MyClient->NetClient->Rcv, NewMails);
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"</Extracting UIDL>\n");
- #endif
+#endif
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
}
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait\n");
- #endif
+#endif
if (WAIT_OBJECT_0 != MsgsWaitToWrite(ActualAccount))
{
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait failed\n");
- #endif
- throw (DWORD)(ActualAccount->SystemError=EACC_STOPPED);
+#endif
+ throw (DWORD)(ActualAccount->SystemError = EACC_STOPPED);
}
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write enter\n");
- #endif
- ActualAccount->LastChecked=now;
- for (MsgQueuePtr=(HYAMNMAIL)ActualAccount->Mails;MsgQueuePtr != NULL;MsgQueuePtr=MsgQueuePtr->Next) {
+#endif
+ ActualAccount->LastChecked = now;
+ for (MsgQueuePtr = (HYAMNMAIL)ActualAccount->Mails; MsgQueuePtr != NULL; MsgQueuePtr = MsgQueuePtr->Next) {
if (MsgQueuePtr->Flags&YAMN_MSG_BODYREQUESTED) {
- HYAMNMAIL NewMsgsPtr=NULL;
- for (NewMsgsPtr=(HYAMNMAIL)NewMails;NewMsgsPtr != NULL;NewMsgsPtr=NewMsgsPtr->Next) {
- if (!strcmp(MsgQueuePtr->ID,NewMsgsPtr->ID)) {
+ HYAMNMAIL NewMsgsPtr = NULL;
+ for (NewMsgsPtr = (HYAMNMAIL)NewMails; NewMsgsPtr != NULL; NewMsgsPtr = NewMsgsPtr->Next) {
+ if (!strcmp(MsgQueuePtr->ID, NewMsgsPtr->ID)) {
TCHAR accstatus[512];
mir_sntprintf(accstatus, SIZEOF(accstatus), TranslateT("Reading body %s"), NewMsgsPtr->ID);
- SetAccountStatus(ActualAccount,accstatus);
- DataRX=MyClient->Top(MsgQueuePtr->Number,100);
- #ifdef DEBUG_DECODE
+ SetAccountStatus(ActualAccount, accstatus);
+ DataRX = MyClient->Top(MsgQueuePtr->Number, 100);
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Reading body>\n");
DebugLog(DecodeFile,"<Header>%s</Header>\n",DataRX);
- #endif
+#endif
if (DataRX != NULL)
{
- Temp=DataRX;
- while((Temp<DataRX+MyClient->NetClient->Rcv) && (WS(Temp) || ENDLINE(Temp))) Temp++;
-
+ Temp = DataRX;
+ while ((Temp < DataRX + MyClient->NetClient->Rcv) && (WS(Temp) || ENDLINE(Temp))) Temp++;
+
if (OKLINE(DataRX))
- for (Temp=DataRX;(Temp<DataRX+MyClient->NetClient->Rcv) && (!ENDLINE(Temp));Temp++);
- while((Temp<DataRX+MyClient->NetClient->Rcv) && ENDLINE(Temp)) Temp++;
+ for (Temp = DataRX; (Temp < DataRX + MyClient->NetClient->Rcv) && (!ENDLINE(Temp)); Temp++);
+ while ((Temp < DataRX + MyClient->NetClient->Rcv) && ENDLINE(Temp)) Temp++;
}
else
continue;
//delete all the headers of the old mail MsgQueuePtr->MailData->TranslatedHeader
struct CMimeItem *TH = MsgQueuePtr->MailData->TranslatedHeader;
- if (TH) for (;MsgQueuePtr->MailData->TranslatedHeader != NULL;)
+ if (TH) for (; MsgQueuePtr->MailData->TranslatedHeader != NULL;)
{
- TH=TH->Next;
+ TH = TH->Next;
if (MsgQueuePtr->MailData->TranslatedHeader->name != NULL)
delete[] MsgQueuePtr->MailData->TranslatedHeader->name;
if (MsgQueuePtr->MailData->TranslatedHeader->value != NULL)
delete[] MsgQueuePtr->MailData->TranslatedHeader->value;
delete MsgQueuePtr->MailData->TranslatedHeader;
- MsgQueuePtr->MailData->TranslatedHeader=TH;
+ MsgQueuePtr->MailData->TranslatedHeader = TH;
}
- TranslateHeader(Temp,MyClient->NetClient->Rcv-(Temp-DataRX),&MsgQueuePtr->MailData->TranslatedHeader);
-
+ TranslateHeader(Temp, MyClient->NetClient->Rcv - (Temp - DataRX), &MsgQueuePtr->MailData->TranslatedHeader);
+
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"</Reading body>\n");
- #endif
- MsgQueuePtr->Flags|=YAMN_MSG_BODYRECEIVED;
+#endif
+ MsgQueuePtr->Flags |= YAMN_MSG_BODYRECEIVED;
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
break;
}
}
}
}
- SynchroMessages(ActualAccount,(HYAMNMAIL *)&ActualAccount->Mails,NULL,(HYAMNMAIL *)&NewMails,NULL); //we get only new mails on server!
-// NewMails=NULL;
+ SynchroMessages(ActualAccount, (HYAMNMAIL *)&ActualAccount->Mails, NULL, (HYAMNMAIL *)&NewMails, NULL); //we get only new mails on server!
+ // NewMails=NULL;
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write done\n");
- #endif
+#endif
MsgsWriteDone(ActualAccount);
- for (MsgQueuePtr=(HYAMNMAIL)ActualAccount->Mails;MsgQueuePtr != NULL;MsgQueuePtr=MsgQueuePtr->Next) {
+ for (MsgQueuePtr = (HYAMNMAIL)ActualAccount->Mails; MsgQueuePtr != NULL; MsgQueuePtr = MsgQueuePtr->Next) {
if ((MsgQueuePtr->Flags&YAMN_MSG_BODYREQUESTED) && (MsgQueuePtr->Flags&YAMN_MSG_BODYRECEIVED)) {
- MsgQueuePtr->Flags&=~YAMN_MSG_BODYREQUESTED;
+ MsgQueuePtr->Flags &= ~YAMN_MSG_BODYREQUESTED;
if (MsgQueuePtr->MsgWindow)
- SendMessage(MsgQueuePtr->MsgWindow,WM_YAMN_CHANGECONTENT,0,0);
+ SendMessage(MsgQueuePtr->MsgWindow, WM_YAMN_CHANGECONTENT, 0, 0);
}
}
- for (msgs=0,MsgQueuePtr=NewMails;MsgQueuePtr != NULL;MsgQueuePtr=MsgQueuePtr->Next,msgs++); //get number of new mails
+ for (msgs = 0, MsgQueuePtr = NewMails; MsgQueuePtr != NULL; MsgQueuePtr = MsgQueuePtr->Next, msgs++); //get number of new mails
try
{
TCHAR accstatus[512];
- for (i=0,MsgQueuePtr=NewMails;MsgQueuePtr != NULL;i++)
+ for (i = 0, MsgQueuePtr = NewMails; MsgQueuePtr != NULL; i++)
{
BOOL autoretr = (ActualAccount->Flags & YAMN_ACC_BODY) != 0;
- DataRX=MyClient->Top(MsgQueuePtr->Number,autoretr?100:0);
+ DataRX = MyClient->Top(MsgQueuePtr->Number, autoretr ? 100 : 0);
mir_sntprintf(accstatus, SIZEOF(accstatus), TranslateT("Reading new mail messages (%d%% done)"), 100 * i / msgs);
- SetAccountStatus(ActualAccount,accstatus);
+ SetAccountStatus(ActualAccount, accstatus);
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<New mail>\n");
DebugLog(DecodeFile,"<Header>%s</Header>\n",DataRX);
- #endif
+#endif
if (DataRX != NULL)
{
- Temp=DataRX;
- while((Temp<DataRX+MyClient->NetClient->Rcv) && (WS(Temp) || ENDLINE(Temp))) Temp++;
-
+ Temp = DataRX;
+ while ((Temp < DataRX + MyClient->NetClient->Rcv) && (WS(Temp) || ENDLINE(Temp))) Temp++;
+
if (OKLINE(DataRX))
- for (Temp=DataRX;(Temp<DataRX+MyClient->NetClient->Rcv) && (!ENDLINE(Temp));Temp++);
- while((Temp<DataRX+MyClient->NetClient->Rcv) && ENDLINE(Temp)) Temp++;
+ for (Temp = DataRX; (Temp < DataRX + MyClient->NetClient->Rcv) && (!ENDLINE(Temp)); Temp++);
+ while ((Temp < DataRX + MyClient->NetClient->Rcv) && ENDLINE(Temp)) Temp++;
}
else
continue;
-
- TranslateHeader(Temp,MyClient->NetClient->Rcv-(Temp-DataRX),&MsgQueuePtr->MailData->TranslatedHeader);
-
- #ifdef DEBUG_DECODE
+ TranslateHeader(Temp, MyClient->NetClient->Rcv - (Temp - DataRX), &MsgQueuePtr->MailData->TranslatedHeader);
+
+
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"</New mail>\n");
- #endif
- MsgQueuePtr->Flags|=YAMN_MSG_NORMALNEW;
- if (autoretr) MsgQueuePtr->Flags|=YAMN_MSG_BODYRECEIVED;
+#endif
+ MsgQueuePtr->Flags |= YAMN_MSG_NORMALNEW;
+ if (autoretr) MsgQueuePtr->Flags |= YAMN_MSG_BODYRECEIVED;
//We are going to filter mail. Warning!- we must not be in read access neither write access to mails when calling this service
//This is done, because the "NewMails" queue is not synchronised. It is because it is new queue. Only this thread uses new queue yet, it is not
//connected to account mail queue.
// CallService(MS_YAMN_FILTERMAIL,(WPARAM)ActualAccount,(LPARAM)MsgQueuePtr);
- FilterMailSvc((WPARAM)ActualAccount,(LPARAM)MsgQueuePtr);
+ FilterMailSvc((WPARAM)ActualAccount, (LPARAM)MsgQueuePtr);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
//MsgQueuePtr->MailData->Body=MyClient->Retr(MsgQueuePtr->Number);
- MsgQueuePtr=MsgQueuePtr->Next;
+ MsgQueuePtr = MsgQueuePtr->Next;
}
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"</--------Account checking-------->\n");
- #endif
+#endif
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait\n");
- #endif
+#endif
if (WAIT_OBJECT_0 != MsgsWaitToWrite(ActualAccount))
{
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait failed\n");
- #endif
- throw (DWORD)ActualAccount->SystemError==EACC_STOPPED;
+#endif
+ throw (DWORD)ActualAccount->SystemError == EACC_STOPPED;
}
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write enter\n");
- #endif
- if (ActualAccount->Mails==NULL)
- ActualAccount->Mails=NewMails;
+#endif
+ if (ActualAccount->Mails == NULL)
+ ActualAccount->Mails = NewMails;
else
{
- ActualAccount->LastMail=ActualAccount->LastChecked;
- AppendQueue((HYAMNMAIL)ActualAccount->Mails,NewMails);
+ ActualAccount->LastMail = ActualAccount->LastChecked;
+ AppendQueue((HYAMNMAIL)ActualAccount->Mails, NewMails);
}
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write done\n");
- #endif
+#endif
MsgsWriteDone(ActualAccount);
// we are going to delete mails having SPAM flag level3 and 4 (see m_mails.h) set
{
- struct DeleteParam ParamToDeleteMails={YAMN_DELETEVERSION,INVALID_HANDLE_VALUE,ActualAccount,YAMNParam,(void *)POP3_DELETEFROMCHECK};
+ struct DeleteParam ParamToDeleteMails = { YAMN_DELETEVERSION, INVALID_HANDLE_VALUE, ActualAccount, YAMNParam, (void *)POP3_DELETEFROMCHECK };
// Delete mails from server. Here we should not be in write access for account's mails
DeleteMailsPOP3(&ParamToDeleteMails);
@@ -854,119 +868,121 @@ DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp) // if there is no waiting thread for internet connection close it
// else leave connection open
- if (0==SCGetNumber(ActualAccount->InternetQueries))
+ if (0 == SCGetNumber(ActualAccount->InternetQueries))
{
- DataRX=MyClient->Quit();
+ DataRX = MyClient->Quit();
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
MyClient->NetClient->Disconnect();
- SetAccountStatus(ActualAccount,TranslateT("Disconnected"));
+ SetAccountStatus(ActualAccount, TranslateT("Disconnected"));
}
- UsingInternet=FALSE;
- #ifdef DEBUG_SYNCHRO
+ UsingInternet = FALSE;
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-done\n");
- #endif
+#endif
SetEvent(ActualAccount->UseInternetFree);
- ActualAccount->LastSChecked=ActualAccount->LastChecked;
- ActualAccount->LastSynchronised=ActualAccount->LastChecked;
+ ActualAccount->LastSChecked = ActualAccount->LastChecked;
+ ActualAccount->LastSynchronised = ActualAccount->LastChecked;
}
- catch(...)
+ catch (...)
{
throw; //go to the main exception handling
}
{
- YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualCopied.NFlags,ActualCopied.NNFlags,YAMNParam};
+ YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, ActualAccount, ActualCopied.NFlags, ActualCopied.NNFlags, YAMNParam };
if (CheckFlags & YAMN_FORCECHECK)
Param.nnflags |= YAMN_ACC_POP; //if force check, show popup anyway and if mailbrowser was opened, do not close
Param.nnflags |= YAMN_ACC_MSGP; //do not close browser if already open
- CallService(MS_YAMN_MAILBROWSER,(WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ CallService(MS_YAMN_MAILBROWSER, (WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION);
}
- SetContactStatus(ActualAccount,ActualAccount->isCounting?ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+ SetContactStatus(ActualAccount, ActualAccount->isCounting ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
}
- #ifdef DEBUG_COMM
+#ifdef DEBUG_COMM
catch(DWORD ErrorCode)
- #else
- catch(DWORD)
- #endif
+#else
+ catch (DWORD)
+#endif
{
- if (ActualAccount->Client.POP3Error==EPOP3_STOPPED)
- ActualAccount->SystemError=EACC_STOPPED;
- #ifdef DEBUG_COMM
+ if (ActualAccount->Client.POP3Error == EPOP3_STOPPED)
+ ActualAccount->SystemError = EACC_STOPPED;
+#ifdef DEBUG_COMM
DebugLog(CommFile,"ERROR: %x\n",ErrorCode);
- #endif
- #ifdef DEBUG_SYNCHRO
+#endif
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait\n");
- #endif
- if (WAIT_OBJECT_0==MsgsWaitToWrite(ActualAccount))
+#endif
+ if (WAIT_OBJECT_0 == MsgsWaitToWrite(ActualAccount))
{
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write enter\n");
- #endif
- ActualAccount->LastChecked=now;
- #ifdef DEBUG_SYNCHRO
+#endif
+ ActualAccount->LastChecked = now;
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write done\n");
- #endif
+#endif
MsgsWriteDone(ActualAccount);
}
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
else
DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait failed\n");
- #endif
+#endif
- DeleteMIMEQueue(ActualAccount,NewMails);
+ DeleteMIMEQueue(ActualAccount, NewMails);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
- switch(ActualAccount->SystemError)
+ DataRX = NULL;
+ switch (ActualAccount->SystemError)
{
- case EACC_QUEUEALLOC:
- case EACC_STOPPED:
- ActualAccount->Client.NetClient->Disconnect();
- break;
- default:
- PostErrorProc(ActualAccount,YAMNParam,(DWORD)NULL,MyClient->SSL); //it closes internet connection too
+ case EACC_QUEUEALLOC:
+ case EACC_STOPPED:
+ ActualAccount->Client.NetClient->Disconnect();
+ break;
+ default:
+ PostErrorProc(ActualAccount, YAMNParam, (DWORD)NULL, MyClient->SSL); //it closes internet connection too
}
if (UsingInternet) //if our thread still uses internet
{
- #ifdef DEBUG_SYNCHRO
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-done\n");
- #endif
+#endif
SetEvent(ActualAccount->UseInternetFree);
}
- SetContactStatus(ActualAccount,ID_STATUS_NA);
+ SetContactStatus(ActualAccount, ID_STATUS_NA);
}
free(ActualCopied.ServerName);
free(ActualCopied.ServerLogin);
free(ActualCopied.ServerPasswd);
- #ifdef DEBUG_COMM
+#ifdef DEBUG_COMM
DebugLog(CommFile,"</--------Communication-------->\n");
- #endif
-// WriteAccounts();
- #ifdef DEBUG_SYNCHRO
+#endif
+ // WriteAccounts();
+#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"CheckPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
- #endif
+#endif
SCDec(ActualAccount->UsingThreads);
return 0;
}
-DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp)
+void __cdecl DeleteMailsPOP3(void *param)
{
+ DeleteParam *WhichTemp = (DeleteParam *)param;
+
HPOP3ACCOUNT ActualAccount;
LPVOID YAMNParam;
UINT_PTR POP3PluginParam;
CPop3Client *MyClient;
- HYAMNMAIL DeleteMails,NewMails=NULL,MsgQueuePtr;
- char* DataRX=NULL;
- int mboxsize,msgs,i;
- BOOL UsingInternet=FALSE;
+ HYAMNMAIL DeleteMails, NewMails = NULL, MsgQueuePtr;
+ char* DataRX = NULL;
+ int mboxsize, msgs, i;
+ BOOL UsingInternet = FALSE;
struct {
char *ServerName;
DWORD ServerPort;
@@ -988,9 +1004,9 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) // //and then we can in our GetErrorStringFcn e.g. return string "Uncompatible version of YAMN".
// }
- ActualAccount=(HPOP3ACCOUNT)((struct DeleteParam *)WhichTemp)->AccountParam; //copy address of structure from calling thread to stack of this thread
- YAMNParam=((struct DeleteParam *)WhichTemp)->BrowserParam;
- POP3PluginParam=(UINT_PTR)((struct DeleteParam *)WhichTemp)->CustomParam;
+ ActualAccount = (HPOP3ACCOUNT)((struct DeleteParam *)WhichTemp)->AccountParam; //copy address of structure from calling thread to stack of this thread
+ YAMNParam = ((struct DeleteParam *)WhichTemp)->BrowserParam;
+ POP3PluginParam = (UINT_PTR)((struct DeleteParam *)WhichTemp)->CustomParam;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
@@ -1010,18 +1026,18 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) DebugLog(SynchroFile,"DeleteMailsPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
SCDec(ActualAccount->UsingThreads);
- return 0;
+ return;
}
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read enter\n");
#endif
- if (NULL==(DeleteMails=(HYAMNMAIL)CreateNewDeleteQueue((HYAMNMAIL)ActualAccount->Mails))) //if there's no mail for deleting, return
+ if (NULL == (DeleteMails = (HYAMNMAIL)CreateNewDeleteQueue((HYAMNMAIL)ActualAccount->Mails))) //if there's no mail for deleting, return
{
if (POP3_DELETEFROMCHECK != POP3PluginParam) //We do not wait for free internet when calling from SynchroPOP3. It is because UseInternetFree is blocked
{
- YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,YAMN_ACC_MSGP,YAMN_ACC_MSGP,YAMNParam}; //Just update the window
+ YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, ActualAccount, YAMN_ACC_MSGP, YAMN_ACC_MSGP, YAMNParam }; //Just update the window
- CallService(MS_YAMN_MAILBROWSER,(WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ CallService(MS_YAMN_MAILBROWSER, (WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION);
}
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read done\n");
@@ -1032,18 +1048,18 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) #endif
SCDec(ActualAccount->UsingThreads);
- return NO_MAIL_FOR_DELETE;
+ return;
}
- MyClient=&(ActualAccount->Client);
+ MyClient = &(ActualAccount->Client);
-//Now, copy all needed information about account to local variables, so ActualAccount is not blocked in read mode during all connection process, which can last for several minutes.
- ActualCopied.ServerName=_strdup(ActualAccount->Server->Name);
- ActualCopied.ServerPort=ActualAccount->Server->Port;
- ActualCopied.Flags=ActualAccount->Flags;
- ActualCopied.ServerLogin=_strdup(ActualAccount->Server->Login);
- ActualCopied.ServerPasswd=_strdup(ActualAccount->Server->Passwd);
- ActualCopied.NFlags=ActualAccount->NewMailN.Flags;
- ActualCopied.NNFlags=ActualAccount->NoNewMailN.Flags;
+ //Now, copy all needed information about account to local variables, so ActualAccount is not blocked in read mode during all connection process, which can last for several minutes.
+ ActualCopied.ServerName = _strdup(ActualAccount->Server->Name);
+ ActualCopied.ServerPort = ActualAccount->Server->Port;
+ ActualCopied.Flags = ActualAccount->Flags;
+ ActualCopied.ServerLogin = _strdup(ActualAccount->Server->Login);
+ ActualCopied.ServerPasswd = _strdup(ActualAccount->Server->Passwd);
+ ActualCopied.NFlags = ActualAccount->NewMailN.Flags;
+ ActualCopied.NNFlags = ActualAccount->NoNewMailN.Flags;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read done\n");
@@ -1056,59 +1072,60 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) #ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:InternetFreeEV-wait\n");
#endif
- WaitForSingleObject(ActualAccount->UseInternetFree,INFINITE);
+ WaitForSingleObject(ActualAccount->UseInternetFree, INFINITE);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:InternetFreeEV-enter\n");
#endif
}
SCDec(ActualAccount->InternetQueries);
- UsingInternet=TRUE;
+ UsingInternet = TRUE;
try
{
- SetContactStatus(ActualAccount,ID_STATUS_OCCUPIED);
+ SetContactStatus(ActualAccount, ID_STATUS_OCCUPIED);
#ifdef DEBUG_COMM
DebugLog(CommFile,"<--------Communication-------->\n");
#endif
- if ((MyClient->NetClient==NULL) || !MyClient->NetClient->Connected())
+ if ((MyClient->NetClient == NULL) || !MyClient->NetClient->Connected())
{
- SetAccountStatus(ActualAccount,TranslateT("Connecting to server"));
-
- DataRX=MyClient->Connect(ActualCopied.ServerName,ActualCopied.ServerPort,ActualCopied.Flags & YAMN_ACC_SSL23,ActualCopied.Flags & YAMN_ACC_NOTLS);
+ SetAccountStatus(ActualAccount, TranslateT("Connecting to server"));
+
+ DataRX = MyClient->Connect(ActualCopied.ServerName, ActualCopied.ServerPort, ActualCopied.Flags & YAMN_ACC_SSL23, ActualCopied.Flags & YAMN_ACC_NOTLS);
- char *timestamp=NULL;
+ char *timestamp = NULL;
if (DataRX != NULL) {
if (ActualAccount->Flags & YAMN_ACC_APOP) {
- char *lpos=strchr(DataRX,'<');
- char *rpos=strchr(DataRX,'>');
- if (lpos && rpos && rpos>lpos) {
- int sz=(int)(rpos-lpos+2);
- timestamp=new char[sz];
- memcpy(timestamp, lpos, sz-1);
- timestamp[sz-1]='\0';
+ char *lpos = strchr(DataRX, '<');
+ char *rpos = strchr(DataRX, '>');
+ if (lpos && rpos && rpos > lpos) {
+ int sz = (int)(rpos - lpos + 2);
+ timestamp = new char[sz];
+ memcpy(timestamp, lpos, sz - 1);
+ timestamp[sz - 1] = '\0';
}
}
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
}
- SetAccountStatus(ActualAccount,TranslateT("Entering POP3 account"));
+ SetAccountStatus(ActualAccount, TranslateT("Entering POP3 account"));
if (ActualAccount->Flags & YAMN_ACC_APOP)
{
- DataRX=MyClient->APOP(ActualCopied.ServerLogin,ActualCopied.ServerPasswd,timestamp);
+ DataRX = MyClient->APOP(ActualCopied.ServerLogin, ActualCopied.ServerPasswd, timestamp);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
delete[] timestamp;
- } else {
- DataRX=MyClient->User(ActualCopied.ServerLogin);
+ }
+ else {
+ DataRX = MyClient->User(ActualCopied.ServerLogin);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
- DataRX=MyClient->Pass(ActualCopied.ServerPasswd);
+ DataRX = NULL;
+ DataRX = MyClient->Pass(ActualCopied.ServerPasswd);
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
}
}
@@ -1117,14 +1134,14 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) #endif
if (POP3_DELETEFROMCHECK != POP3PluginParam) //We do not need to get mails on server as we have already it from check function
{
- SetAccountStatus(ActualAccount,TranslateT("Deleting requested mails"));
+ SetAccountStatus(ActualAccount, TranslateT("Deleting requested mails"));
- DataRX=MyClient->Stat();
+ DataRX = MyClient->Stat();
#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Extracting stat>\n");
#endif
- ExtractStat(DataRX,MyClient->NetClient->Rcv,&mboxsize,&msgs);
+ ExtractStat(DataRX, MyClient->NetClient->Rcv, &mboxsize, &msgs);
#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<MailBoxSize>%d</MailBoxSize>\n",mboxsize);
DebugLog(DecodeFile,"<Msgs>%d</Msgs>\n",msgs);
@@ -1132,43 +1149,43 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) #endif
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
- for (i=0;i<msgs;i++)
+ DataRX = NULL;
+ for (i = 0; i < msgs; i++)
{
if (!i)
- MsgQueuePtr=NewMails=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
+ MsgQueuePtr = NewMails = (HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL, (WPARAM)ActualAccount, (LPARAM)YAMN_MAILVERSION);
else
{
- MsgQueuePtr->Next=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
- MsgQueuePtr=MsgQueuePtr->Next;
+ MsgQueuePtr->Next = (HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL, (WPARAM)ActualAccount, (LPARAM)YAMN_MAILVERSION);
+ MsgQueuePtr = MsgQueuePtr->Next;
}
- if (MsgQueuePtr==NULL)
+ if (MsgQueuePtr == NULL)
{
- ActualAccount->SystemError=EPOP3_QUEUEALLOC;
+ ActualAccount->SystemError = EPOP3_QUEUEALLOC;
throw (DWORD)ActualAccount->SystemError;
}
}
-
+
if (msgs)
{
#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Extracting UIDL>\n");
#endif
- DataRX=MyClient->Uidl();
- ExtractUIDL(DataRX,MyClient->NetClient->Rcv,NewMails);
+ DataRX = MyClient->Uidl();
+ ExtractUIDL(DataRX, MyClient->NetClient->Rcv, NewMails);
#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"</Extracting UIDL>\n");
#endif
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
-// we get "new mails" on server (NewMails will contain all mails on server not found in DeleteMails)
-// but also in DeleteMails we get only those, which are still on server with their responsable numbers
- SynchroMessages(ActualAccount,(HYAMNMAIL *)&DeleteMails,NULL,(HYAMNMAIL *)&NewMails,NULL);
+ DataRX = NULL;
+ // we get "new mails" on server (NewMails will contain all mails on server not found in DeleteMails)
+ // but also in DeleteMails we get only those, which are still on server with their responsable numbers
+ SynchroMessages(ActualAccount, (HYAMNMAIL *)&DeleteMails, NULL, (HYAMNMAIL *)&NewMails, NULL);
}
}
else
- SetAccountStatus(ActualAccount,TranslateT("Deleting spam"));
+ SetAccountStatus(ActualAccount, TranslateT("Deleting spam"));
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write wait\n");
#endif
@@ -1182,26 +1199,26 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) #ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write enter\n");
#endif
- if (msgs || POP3_DELETEFROMCHECK==POP3PluginParam)
+ if (msgs || POP3_DELETEFROMCHECK == POP3PluginParam)
{
try
{
HYAMNMAIL Temp;
- for (i=0,MsgQueuePtr=DeleteMails;MsgQueuePtr != NULL;i++)
+ for (i = 0, MsgQueuePtr = DeleteMails; MsgQueuePtr != NULL; i++)
{
if (!(MsgQueuePtr->Flags & YAMN_MSG_VIRTUAL)) //of course we can only delete real mails, not virtual
{
- DataRX=MyClient->Dele(MsgQueuePtr->Number);
- Temp=MsgQueuePtr->Next;
- if (POP3_FOK==MyClient->AckFlag) //if server answers that mail was deleted
+ DataRX = MyClient->Dele(MsgQueuePtr->Number);
+ Temp = MsgQueuePtr->Next;
+ if (POP3_FOK == MyClient->AckFlag) //if server answers that mail was deleted
{
- DeleteMIMEMessage((HYAMNMAIL *)&DeleteMails,MsgQueuePtr);
- HYAMNMAIL DeletedMail=FindMIMEMessageByID((HYAMNMAIL)ActualAccount->Mails,MsgQueuePtr->ID);
+ DeleteMIMEMessage((HYAMNMAIL *)&DeleteMails, MsgQueuePtr);
+ HYAMNMAIL DeletedMail = FindMIMEMessageByID((HYAMNMAIL)ActualAccount->Mails, MsgQueuePtr->ID);
if ((MsgQueuePtr->Flags & YAMN_MSG_MEMDELETE)) //if mail should be deleted from memory (or disk)
{
- DeleteMIMEMessage((HYAMNMAIL *)&ActualAccount->Mails,DeletedMail); //remove from queue
- CallService(MS_YAMN_DELETEACCOUNTMAIL,(WPARAM)POP3Plugin,(LPARAM)DeletedMail);
+ DeleteMIMEMessage((HYAMNMAIL *)&ActualAccount->Mails, DeletedMail); //remove from queue
+ CallService(MS_YAMN_DELETEACCOUNTMAIL, (WPARAM)POP3Plugin, (LPARAM)DeletedMail);
}
else //else mark it only as "deleted mail"
{
@@ -1212,17 +1229,17 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) delete[] MsgQueuePtr->ID;
delete MsgQueuePtr;
}
- MsgQueuePtr=Temp;
+ MsgQueuePtr = Temp;
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
}
else
- MsgQueuePtr=MsgQueuePtr->Next;
+ MsgQueuePtr = MsgQueuePtr->Next;
}
}
- catch(...) //if any exception in the code where we have write-access to account occured, don't forget to leave write-access
+ catch (...) //if any exception in the code where we have write-access to account occured, don't forget to leave write-access
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write done\n");
@@ -1232,24 +1249,24 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) }
if (NewMails != NULL)
-// in ActualAccount->Mails we have all mails stored before calling this function
-// in NewMails we have all mails not found in DeleteMails (in other words: we performed new ID checking and we
-// stored all mails found on server, then we deleted the ones we wanted to delete in this function
-// and NewMails queue now contains actual state of mails on server). But we will not use NewMails as actual state, because NewMails does not contain header data (subject, from...)
-// We perform deleting from ActualAccount->Mails: we remove from original queue (ActualAccount->Mails) all deleted mails
- SynchroMessages(ActualAccount,(HYAMNMAIL *)&ActualAccount->Mails,NULL,(HYAMNMAIL *)&NewMails,NULL);
-// Now ActualAccount->Mails contains all mails when calling this function except the ones, we wanted to delete (these are in DeleteMails)
-// And in NewMails we have new mails (if any)
+ // in ActualAccount->Mails we have all mails stored before calling this function
+ // in NewMails we have all mails not found in DeleteMails (in other words: we performed new ID checking and we
+ // stored all mails found on server, then we deleted the ones we wanted to delete in this function
+ // and NewMails queue now contains actual state of mails on server). But we will not use NewMails as actual state, because NewMails does not contain header data (subject, from...)
+ // We perform deleting from ActualAccount->Mails: we remove from original queue (ActualAccount->Mails) all deleted mails
+ SynchroMessages(ActualAccount, (HYAMNMAIL *)&ActualAccount->Mails, NULL, (HYAMNMAIL *)&NewMails, NULL);
+ // Now ActualAccount->Mails contains all mails when calling this function except the ones, we wanted to delete (these are in DeleteMails)
+ // And in NewMails we have new mails (if any)
else if (POP3_DELETEFROMCHECK != POP3PluginParam)
{
- DeleteMIMEQueue(ActualAccount,(HYAMNMAIL)ActualAccount->Mails);
- ActualAccount->Mails=NULL;
+ DeleteMIMEQueue(ActualAccount, (HYAMNMAIL)ActualAccount->Mails);
+ ActualAccount->Mails = NULL;
}
}
else
{
- DeleteMIMEQueue(ActualAccount,(HYAMNMAIL)ActualAccount->Mails);
- ActualAccount->Mails=NULL;
+ DeleteMIMEQueue(ActualAccount, (HYAMNMAIL)ActualAccount->Mails);
+ ActualAccount->Mails = NULL;
}
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write done\n");
@@ -1259,58 +1276,58 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) DebugLog(DecodeFile,"</--------Deleting requested mails-------->\n");
#endif
-// TODO: now, we have in NewMails new mails. If NewMails is not NULL, we found some new mails, so Checking for new mail should be performed
-// now, we do not call CheckPOP3
+ // TODO: now, we have in NewMails new mails. If NewMails is not NULL, we found some new mails, so Checking for new mail should be performed
+ // now, we do not call CheckPOP3
-// if there is no waiting thread for internet connection close it
-// else leave connection open
-// if this functin was called from SynchroPOP3, then do not try to disconnect
+ // if there is no waiting thread for internet connection close it
+ // else leave connection open
+ // if this functin was called from SynchroPOP3, then do not try to disconnect
if (POP3_DELETEFROMCHECK != POP3PluginParam)
{
- YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualCopied.NFlags,YAMN_ACC_MSGP,YAMNParam};
+ YAMN_MAILBROWSERPARAM Param = { (HANDLE)0, ActualAccount, ActualCopied.NFlags, YAMN_ACC_MSGP, YAMNParam };
- CallService(MS_YAMN_MAILBROWSER,(WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ CallService(MS_YAMN_MAILBROWSER, (WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION);
- if (0==SCGetNumber(ActualAccount->InternetQueries))
+ if (0 == SCGetNumber(ActualAccount->InternetQueries))
{
- DataRX=MyClient->Quit();
+ DataRX = MyClient->Quit();
if (DataRX != NULL)
free(DataRX);
- DataRX=NULL;
+ DataRX = NULL;
MyClient->NetClient->Disconnect();
- SetAccountStatus(ActualAccount,TranslateT("Disconnected"));
+ SetAccountStatus(ActualAccount, TranslateT("Disconnected"));
}
- UsingInternet=FALSE;
+ UsingInternet = FALSE;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:InternetFreeEV-done\n");
#endif
SetEvent(ActualAccount->UseInternetFree);
}
- SetContactStatus(ActualAccount,ActualAccount->isCounting?ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+ SetContactStatus(ActualAccount, ActualAccount->isCounting ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
}
#ifdef DEBUG_COMM
catch(DWORD ErrorCode)
#else
- catch(DWORD)
+ catch (DWORD)
#endif
{
- if (ActualAccount->Client.POP3Error==EPOP3_STOPPED)
- ActualAccount->SystemError=EACC_STOPPED;
+ if (ActualAccount->Client.POP3Error == EPOP3_STOPPED)
+ ActualAccount->SystemError = EACC_STOPPED;
#ifdef DEBUG_COMM
DebugLog(CommFile,"ERROR %x\n",ErrorCode);
#endif
if (DataRX != NULL)
free(DataRX);
- switch(ActualAccount->SystemError)
+ switch (ActualAccount->SystemError)
{
- case EACC_QUEUEALLOC:
- case EACC_STOPPED:
- ActualAccount->Client.NetClient->Disconnect();
- break;
- default:
- PostErrorProc(ActualAccount,YAMNParam,POP3PluginParam,MyClient->SSL); //it closes internet connection too
+ case EACC_QUEUEALLOC:
+ case EACC_STOPPED:
+ ActualAccount->Client.NetClient->Disconnect();
+ break;
+ default:
+ PostErrorProc(ActualAccount, YAMNParam, POP3PluginParam, MyClient->SSL); //it closes internet connection too
}
if (UsingInternet && (POP3_DELETEFROMCHECK != POP3PluginParam)) //if our thread still uses internet and it is needed to release internet
@@ -1326,169 +1343,169 @@ DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp) free(ActualCopied.ServerLogin);
free(ActualCopied.ServerPasswd);
- DeleteMIMEQueue(ActualAccount,NewMails);
- DeleteMIMEQueue(ActualAccount,DeleteMails);
+ DeleteMIMEQueue(ActualAccount, NewMails);
+ DeleteMIMEQueue(ActualAccount, DeleteMails);
#ifdef DEBUG_COMM
DebugLog(CommFile,"</--------Communication-------->\n");
#endif
-// WriteAccounts();
+ // WriteAccounts();
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"DeleteMailsPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
SCDec(ActualAccount->UsingThreads);
- return 0;
+ return;
}
-void ExtractStat(char *stream,int len,int *mboxsize,int *mails)
+void ExtractStat(char *stream, int len, int *mboxsize, int *mails)
{
- char *finder=stream;
- while(WS(finder) || ENDLINE(finder)) finder++;
+ char *finder = stream;
+ while (WS(finder) || ENDLINE(finder)) finder++;
if (ACKLINE(finder))
{
- while(!WS(finder)) finder++;
- while(WS(finder)) finder++;
+ while (!WS(finder)) finder++;
+ while (WS(finder)) finder++;
}
- if (1 != sscanf(finder,"%d",mails))
+ if (1 != sscanf(finder, "%d", mails))
throw (DWORD)EPOP3_STAT;
- while(!WS(finder)) finder++;
- while(WS(finder)) finder++;
- if (1 != sscanf(finder,"%d",mboxsize))
+ while (!WS(finder)) finder++;
+ while (WS(finder)) finder++;
+ if (1 != sscanf(finder, "%d", mboxsize))
throw (DWORD)EPOP3_STAT;
}
-void ExtractMail(char *stream,int len,HYAMNMAIL queue)
+void ExtractMail(char *stream, int len, HYAMNMAIL queue)
{
- char *finder=stream;
+ char *finder = stream;
char *finderend;
- int msgnr,i;
- HYAMNMAIL queueptr=queue;
+ int msgnr, i;
+ HYAMNMAIL queueptr = queue;
- while(WS(finder) || ENDLINE(finder)) finder++;
- while(!ACKLINE(finder)) finder++;
- while(!ENDLINE(finder)) finder++; //now we at the end of first ack line
- while(finder<=(stream+len))
+ while (WS(finder) || ENDLINE(finder)) finder++;
+ while (!ACKLINE(finder)) finder++;
+ while (!ENDLINE(finder)) finder++; //now we at the end of first ack line
+ while (finder <= (stream + len))
{
- while(ENDLINE(finder)) finder++; //go to the new line
- if (DOTLINE(finder+1)) //at the end of stream
+ while (ENDLINE(finder)) finder++; //go to the new line
+ if (DOTLINE(finder + 1)) //at the end of stream
break;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Message>\n");
- #endif
- while(WS(finder)) finder++; //jump whitespace
- if (1 != sscanf(finder,"%d",&msgnr))
+#endif
+ while (WS(finder)) finder++; //jump whitespace
+ if (1 != sscanf(finder, "%d", &msgnr))
throw (DWORD)EPOP3_UIDL;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Nr>%d</Nr>\n",msgnr);
- #endif
-// for (i=1,queueptr=queue;(queueptr->Next != NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
-// if (i != msgnr)
-// throw (DWORD)EPOP3_UIDL;
- while(!WS(finder)) finder++; //jump characters
- while(WS(finder)) finder++; //jump whitespace
- finderend=finder+1;
- while(!WS(finderend) && !ENDLINE(finderend)) finderend++;
- queueptr->ID=new char[finderend-finder+1];
- for (i=0;finder != finderend;finder++,i++)
- queueptr->MailData->Body[i]=*finder;
- queueptr->MailData->Body[i]=0; //ends string
- queueptr->Number=msgnr;
- #ifdef DEBUG_DECODE
+#endif
+ // for (i=1,queueptr=queue;(queueptr->Next != NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
+ // if (i != msgnr)
+ // throw (DWORD)EPOP3_UIDL;
+ while (!WS(finder)) finder++; //jump characters
+ while (WS(finder)) finder++; //jump whitespace
+ finderend = finder + 1;
+ while (!WS(finderend) && !ENDLINE(finderend)) finderend++;
+ queueptr->ID = new char[finderend - finder + 1];
+ for (i = 0; finder != finderend; finder++, i++)
+ queueptr->MailData->Body[i] = *finder;
+ queueptr->MailData->Body[i] = 0; //ends string
+ queueptr->Number = msgnr;
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<ID>%s</ID>\n",queueptr->MailData->Body);
DebugLog(DecodeFile,"</Message>\n");
- #endif
- queueptr=queueptr->Next;
- while(!ENDLINE(finder)) finder++;
+#endif
+ queueptr = queueptr->Next;
+ while (!ENDLINE(finder)) finder++;
}
}
-void ExtractUIDL(char *stream,int len,HYAMNMAIL queue)
+void ExtractUIDL(char *stream, int len, HYAMNMAIL queue)
{
- char *finder=stream;
+ char *finder = stream;
char *finderend;
- int msgnr,i;
- HYAMNMAIL queueptr=queue;
+ int msgnr, i;
+ HYAMNMAIL queueptr = queue;
- while(WS(finder) || ENDLINE(finder)) finder++;
- while(!ACKLINE(finder)) finder++;
- while(!ENDLINE(finder)) finder++; //now we at the end of first ack line
- while(finder<=(stream+len))
+ while (WS(finder) || ENDLINE(finder)) finder++;
+ while (!ACKLINE(finder)) finder++;
+ while (!ENDLINE(finder)) finder++; //now we at the end of first ack line
+ while (finder <= (stream + len))
{
- while(ENDLINE(finder)) finder++; //go to the new line
- if (DOTLINE(finder+1)) //at the end of stream
+ while (ENDLINE(finder)) finder++; //go to the new line
+ if (DOTLINE(finder + 1)) //at the end of stream
break;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Message>\n");
- #endif
- while(WS(finder)) finder++; //jump whitespace
- if (1 != sscanf(finder,"%d",&msgnr))
+#endif
+ while (WS(finder)) finder++; //jump whitespace
+ if (1 != sscanf(finder, "%d", &msgnr))
throw (DWORD)EPOP3_UIDL;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Nr>%d</Nr>\n",msgnr);
- #endif
-// for (i=1,queueptr=queue;(queueptr->Next != NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
-// if (i != msgnr)
-// throw (DWORD)EPOP3_UIDL;
- while(!WS(finder)) finder++; //jump characters
- while(WS(finder)) finder++; //jump whitespace
- finderend=finder+1;
- while(!WS(finderend) && !ENDLINE(finderend)) finderend++;
- queueptr->ID=new char[finderend-finder+1];
- for (i=0;finder != finderend;finder++,i++)
- queueptr->ID[i]=*finder;
- queueptr->ID[i]=0; //ends string
- queueptr->Number=msgnr;
- #ifdef DEBUG_DECODE
+#endif
+ // for (i=1,queueptr=queue;(queueptr->Next != NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
+ // if (i != msgnr)
+ // throw (DWORD)EPOP3_UIDL;
+ while (!WS(finder)) finder++; //jump characters
+ while (WS(finder)) finder++; //jump whitespace
+ finderend = finder + 1;
+ while (!WS(finderend) && !ENDLINE(finderend)) finderend++;
+ queueptr->ID = new char[finderend - finder + 1];
+ for (i = 0; finder != finderend; finder++, i++)
+ queueptr->ID[i] = *finder;
+ queueptr->ID[i] = 0; //ends string
+ queueptr->Number = msgnr;
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<ID>%s</ID>\n",queueptr->ID);
DebugLog(DecodeFile,"</Message>\n");
- #endif
- queueptr=queueptr->Next;
- while(!ENDLINE(finder)) finder++;
+#endif
+ queueptr = queueptr->Next;
+ while (!ENDLINE(finder)) finder++;
}
}
-void ExtractList(char *stream,int len,HYAMNMAIL queue)
+void ExtractList(char *stream, int len, HYAMNMAIL queue)
{
- char *finder=stream;
+ char *finder = stream;
char *finderend;
- int msgnr,i;
+ int msgnr, i;
HYAMNMAIL queueptr;
- while(WS(finder) || ENDLINE(finder)) finder++;
- while(!ACKLINE(finder)) finder++;
- while(!ENDLINE(finder)) finder++; //now we at the end of first ack line
- while(finder<=(stream+len))
+ while (WS(finder) || ENDLINE(finder)) finder++;
+ while (!ACKLINE(finder)) finder++;
+ while (!ENDLINE(finder)) finder++; //now we at the end of first ack line
+ while (finder <= (stream + len))
{
- while(ENDLINE(finder)) finder++; //go to the new line
- if (DOTLINE(finder+1)) //at the end of stream
+ while (ENDLINE(finder)) finder++; //go to the new line
+ if (DOTLINE(finder + 1)) //at the end of stream
break;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Message>\n",NULL,0);
- #endif
- while(WS(finder)) finder++; //jump whitespace
- if (1 != sscanf(finder,"%d",&msgnr)) //message nr.
+#endif
+ while (WS(finder)) finder++; //jump whitespace
+ if (1 != sscanf(finder, "%d", &msgnr)) //message nr.
throw (DWORD)EPOP3_LIST;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Nr>%d</Nr>\n",msgnr);
- #endif
+#endif
- for (i=1,queueptr=queue;(queueptr->Next != NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
+ for (i = 1, queueptr = queue; (queueptr->Next != NULL) && (i < msgnr); queueptr = queueptr->Next, i++);
if (i != msgnr)
throw (DWORD)EPOP3_LIST;
- while(!WS(finder)) finder++; //jump characters
- while(WS(finder)) finder++; //jump whitespace
- finderend=finder+1;
- if (1 != sscanf(finder,"%d",&queueptr->MailData->Size))
+ while (!WS(finder)) finder++; //jump characters
+ while (WS(finder)) finder++; //jump whitespace
+ finderend = finder + 1;
+ if (1 != sscanf(finder, "%d", &queueptr->MailData->Size))
throw (DWORD)EPOP3_LIST;
- #ifdef DEBUG_DECODE
+#ifdef DEBUG_DECODE
DebugLog(DecodeFile,"<Nr>%d</Nr>\n",queueptr->MailData->Size);
- #endif
- while(!ENDLINE(finder)) finder++;
+#endif
+ while (!ENDLINE(finder)) finder++;
}
}
TCHAR* WINAPI GetErrorString(DWORD Code)
{
- static TCHAR *POP3Errors[]=
+ static TCHAR *POP3Errors[] =
{
LPGENT("Memory allocation error."), //memory allocation
LPGENT("Account is about to be stopped."), //stop account
@@ -1502,7 +1519,7 @@ TCHAR* WINAPI GetErrorString(DWORD Code) LPGENT("Error while executing POP3 command."),
};
- static TCHAR *NetlibErrors[]=
+ static TCHAR *NetlibErrors[] =
{
LPGENT("Cannot connect to server with NetLib."),
LPGENT("Cannot send data."),
@@ -1510,7 +1527,7 @@ TCHAR* WINAPI GetErrorString(DWORD Code) LPGENT("Cannot allocate memory for received data."),
};
- static TCHAR *SSLErrors[]=
+ static TCHAR *SSLErrors[] =
{
LPGENT("OpenSSL not loaded."),
LPGENT("Windows socket 2.0 init failed."),
@@ -1526,18 +1543,18 @@ TCHAR* WINAPI GetErrorString(DWORD Code) };
TCHAR *ErrorString = new TCHAR[ERRORSTR_MAXLEN];
- POP3_ERRORCODE *ErrorCode=(POP3_ERRORCODE *)(UINT_PTR)Code;
+ POP3_ERRORCODE *ErrorCode = (POP3_ERRORCODE *)(UINT_PTR)Code;
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, TranslateT("Error %d-%d-%d-%d:"), ErrorCode->AppError, ErrorCode->POP3Error, ErrorCode->NetError,ErrorCode->SystemError);
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, TranslateT("Error %d-%d-%d-%d:"), ErrorCode->AppError, ErrorCode->POP3Error, ErrorCode->NetError, ErrorCode->SystemError);
if (ErrorCode->POP3Error)
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(POP3Errors[ErrorCode->POP3Error-1]));
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(POP3Errors[ErrorCode->POP3Error - 1]));
if (ErrorCode->NetError) {
if (ErrorCode->SSL)
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(SSLErrors[ErrorCode->NetError-1]));
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(SSLErrors[ErrorCode->NetError - 1]));
else
- mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(NetlibErrors[ErrorCode->NetError-4]));
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"), ErrorString, TranslateTS(NetlibErrors[ErrorCode->NetError - 4]));
}
-
+
return ErrorString;
}
diff --git a/plugins/YAMN/src/yamn.h b/plugins/YAMN/src/yamn.h index 047f31696b..b3c85d73d4 100644 --- a/plugins/YAMN/src/yamn.h +++ b/plugins/YAMN/src/yamn.h @@ -48,7 +48,7 @@ void DestroyServiceFunctions(void); void HookEvents(void);
void UnhookEvents(void);
void RefreshContact(void);
-void ContactDoubleclicked(WPARAM wParam,LPARAM lParam);
+void ContactDoubleclicked(WPARAM wParam, LPARAM lParam);
INT_PTR ClistContactDoubleclicked(WPARAM wParam, LPARAM lParam);
extern CRITICAL_SECTION PluginRegCS;
@@ -66,10 +66,10 @@ void UnInitDebug(); //struct CExportedFunctions SynchroExported[];
//From yamn.cpp
-INT_PTR GetFcnPtrSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR GetVariablesSvc(WPARAM,LPARAM);
-void CALLBACK TimerProc(HWND,UINT,UINT_PTR,DWORD);
-INT_PTR ForceCheckSvc(WPARAM,LPARAM);
+INT_PTR GetFcnPtrSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR GetVariablesSvc(WPARAM, LPARAM);
+void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD);
+INT_PTR ForceCheckSvc(WPARAM, LPARAM);
extern struct YAMNExportedFcns *pYAMNFcn;
@@ -77,67 +77,67 @@ extern struct YAMNExportedFcns *pYAMNFcn; extern CRITICAL_SECTION AccountStatusCS;
extern CRITICAL_SECTION FileWritingCS;
-INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM);
+INT_PTR CreatePluginAccountSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR DeletePluginAccountSvc(WPARAM wParam, LPARAM);
int InitAccount(HACCOUNT Which);
void DeInitAccount(HACCOUNT Which);
void StopSignalFcn(HACCOUNT Which);
-void CodeDecodeString(char *Dest,BOOL Encrypt);
-DWORD FileToMemory(TCHAR *FileName,char **MemFile,char **End);
+void CodeDecodeString(char *Dest, BOOL Encrypt);
+DWORD FileToMemory(TCHAR *FileName, char **MemFile, char **End);
#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo,char *DebugString);
#endif
-DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo);
-DWORD ReadMessagesFromMemory(HACCOUNT Which,char **Parser,char *End);
-DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,TCHAR *End);
-INT_PTR AddAccountsFromFileSvc(WPARAM wParam,LPARAM lParam);
+DWORD ReadStringFromMemory(char **Parser, char *End, char **StoreTo);
+DWORD ReadMessagesFromMemory(HACCOUNT Which, char **Parser, char *End);
+DWORD ReadAccountFromMemory(HACCOUNT Which, char **Parser, TCHAR *End);
+INT_PTR AddAccountsFromFileSvc(WPARAM wParam, LPARAM lParam);
-DWORD WriteStringToFile(HANDLE File,char *Source);
-DWORD WriteStringToFileW(HANDLE File,WCHAR *Source);
+DWORD WriteStringToFile(HANDLE File, char *Source);
+DWORD WriteStringToFileW(HANDLE File, WCHAR *Source);
-DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which);
+DWORD WriteMessagesToFile(HANDLE File, HACCOUNT Which);
DWORD WINAPI WritePOP3Accounts();
-INT_PTR WriteAccountsToFileSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR GetNextFreeAccountSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR WriteAccountsToFileSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR FindAccountByNameSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR GetNextFreeAccountSvc(WPARAM wParam, LPARAM lParam);
-INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM);
-DWORD WINAPI DeleteAccountInBackground(LPVOID Which);
+INT_PTR DeleteAccountSvc(WPARAM wParam, LPARAM);
+void __cdecl DeleteAccountInBackground(void *Which);
int StopAccounts(HYAMNPROTOPLUGIN Plugin);
-int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess=FALSE);
+int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin, BOOL GetAccountBrowserAccess = FALSE);
int DeleteAccounts(HYAMNPROTOPLUGIN Plugin);
-void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value);
-void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value);
+void WINAPI GetStatusFcn(HACCOUNT Which, TCHAR *Value);
+void WINAPI SetStatusFcn(HACCOUNT Which, TCHAR *Value);
INT_PTR UnregisterProtoPlugins();
-INT_PTR RegisterProtocolPluginSvc(WPARAM,LPARAM);
-INT_PTR UnregisterProtocolPluginSvc(WPARAM,LPARAM);
-INT_PTR GetFileNameSvc(WPARAM,LPARAM);
-INT_PTR DeleteFileNameSvc(WPARAM,LPARAM);
+INT_PTR RegisterProtocolPluginSvc(WPARAM, LPARAM);
+INT_PTR UnregisterProtocolPluginSvc(WPARAM, LPARAM);
+INT_PTR GetFileNameSvc(WPARAM, LPARAM);
+INT_PTR DeleteFileNameSvc(WPARAM, LPARAM);
//From filterplugin.cpp
//struct CExportedFunctions FilterPluginExported[];
INT_PTR UnregisterFilterPlugins();
-INT_PTR RegisterFilterPluginSvc(WPARAM,LPARAM);
-INT_PTR UnregisterFilterPluginSvc(WPARAM,LPARAM);
-INT_PTR FilterMailSvc(WPARAM,LPARAM);
+INT_PTR RegisterFilterPluginSvc(WPARAM, LPARAM);
+INT_PTR UnregisterFilterPluginSvc(WPARAM, LPARAM);
+INT_PTR FilterMailSvc(WPARAM, LPARAM);
//From mails.cpp (MIME)
//struct CExportedFunctions MailExported[];
-INT_PTR CreateAccountMailSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam);
-INT_PTR UnloadMailDataSvc(WPARAM wParam,LPARAM);
-INT_PTR SaveMailDataSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR CreateAccountMailSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR DeleteAccountMailSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR LoadMailDataSvc(WPARAM wParam, LPARAM lParam);
+INT_PTR UnloadMailDataSvc(WPARAM wParam, LPARAM);
+INT_PTR SaveMailDataSvc(WPARAM wParam, LPARAM lParam);
//From mime.cpp
//void WINAPI ExtractHeaderFcn(char *,int,WORD,HYAMNMAIL); //already in MailExported
struct _tcptable
{
- char *NameBase,*NameSub;
+ char *NameBase, *NameSub;
BOOLEAN isValid;
unsigned short int CP;
};
@@ -146,28 +146,28 @@ extern int CPLENALL; extern struct _tcptable *CodePageNamesSupp; // in mime/decode.cpp
extern int CPLENSUPP;
-extern int PosX,PosY,SizeX,SizeY;
-extern int HeadPosX,HeadPosY,HeadSizeX,HeadSizeY,HeadSplitPos;
+extern int PosX, PosY, SizeX, SizeY;
+extern int HeadPosX, HeadPosY, HeadSizeX, HeadSizeY, HeadSplitPos;
//#define CPDEFINDEX 63 //ISO-8859-1
#define CPDEFINDEX 0 //ACP
//From pop3comm.cpp
-int RegisterPOP3Plugin(WPARAM,LPARAM);
+int RegisterPOP3Plugin(WPARAM, LPARAM);
//From mailbrowser.cpp
-INT_PTR RunMailBrowserSvc(WPARAM,LPARAM);
+INT_PTR RunMailBrowserSvc(WPARAM, LPARAM);
//From badconnect.cpp
-INT_PTR RunBadConnectionSvc(WPARAM,LPARAM);
+INT_PTR RunBadConnectionSvc(WPARAM, LPARAM);
//From YAMNopts.cpp
-int YAMNOptInitSvc(WPARAM,LPARAM);
+int YAMNOptInitSvc(WPARAM, LPARAM);
//From main.cpp
-int PostLoad(WPARAM,LPARAM); //Executed after all plugins loaded YAMN reads mails from file and notify every protocol it should set its functions
-int Shutdown(WPARAM,LPARAM); //Executed before Miranda is going to shutdown
-int AddTopToolbarIcon(WPARAM,LPARAM); //Executed when TopToolBar plugin loaded Adds bitmap to toolbar
+int PostLoad(WPARAM, LPARAM); //Executed after all plugins loaded YAMN reads mails from file and notify every protocol it should set its functions
+int Shutdown(WPARAM, LPARAM); //Executed before Miranda is going to shutdown
+int AddTopToolbarIcon(WPARAM, LPARAM); //Executed when TopToolBar plugin loaded Adds bitmap to toolbar
extern TCHAR UserDirectory[]; //e.g. "F:\WINNT\Profiles\UserXYZ"
extern TCHAR ProfileName[]; //e.g. "majvan"
@@ -178,45 +178,45 @@ extern HANDLE hTTButton; extern HCURSOR hCurSplitNS, hCurSplitWE;
extern UINT SecTimer;
-HANDLE WINAPI g_GetIconHandle( int idx );
-HICON WINAPI g_LoadIconEx( int idx, bool big = false );
-void WINAPI g_ReleaseIcon( HICON hIcon );
+HANDLE WINAPI g_GetIconHandle(int idx);
+HICON WINAPI g_LoadIconEx(int idx, bool big = false);
+void WINAPI g_ReleaseIcon(HICON hIcon);
//From synchro.cpp
-void WINAPI DeleteMessagesToEndFcn(HACCOUNT Account,HYAMNMAIL From);
-DWORD WINAPI WaitToWriteFcn(PSWMRG SObject,PSCOUNTER SCounter=NULL);
-void WINAPI WriteDoneFcn(PSWMRG SObject,PSCOUNTER SCounter=NULL);
+void WINAPI DeleteMessagesToEndFcn(HACCOUNT Account, HYAMNMAIL From);
+DWORD WINAPI WaitToWriteFcn(PSWMRG SObject, PSCOUNTER SCounter = NULL);
+void WINAPI WriteDoneFcn(PSWMRG SObject, PSCOUNTER SCounter = NULL);
DWORD WINAPI WaitToReadFcn(PSWMRG SObject);
void WINAPI ReadDoneFcn(PSWMRG SObject);
DWORD WINAPI SCIncFcn(PSCOUNTER SCounter);
DWORD WINAPI SCDecFcn(PSCOUNTER SCounter);
-BOOL WINAPI SWMRGInitialize(PSWMRG,TCHAR *);
+BOOL WINAPI SWMRGInitialize(PSWMRG, TCHAR *);
void WINAPI SWMRGDelete(PSWMRG);
-DWORD WINAPI SWMRGWaitToWrite(PSWMRG pSWMRG,DWORD dwTimeout);
+DWORD WINAPI SWMRGWaitToWrite(PSWMRG pSWMRG, DWORD dwTimeout);
void WINAPI SWMRGDoneWriting(PSWMRG pSWMRG);
DWORD WINAPI SWMRGWaitToRead(PSWMRG pSWMRG, DWORD dwTimeout);
void WINAPI SWMRGDoneReading(PSWMRG pSWMRG);
//From mails.cpp
-void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From,HYAMNMAIL Which,int mode);
-void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From,DWORD FlagsSet,DWORD FlagsNotSet,DWORD FlagsToSet,int mode);
+void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From, HYAMNMAIL Which, int mode);
+void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From, DWORD FlagsSet, DWORD FlagsNotSet, DWORD FlagsToSet, int mode);
//From mime.cpp
-void ExtractHeader(struct CMimeItem *items,int &CP,struct CHeader *head);
-void ExtractShortHeader(struct CMimeItem *items,struct CShortHeader *head);
+void ExtractHeader(struct CMimeItem *items, int &CP, struct CHeader *head);
+void ExtractShortHeader(struct CMimeItem *items, struct CShortHeader *head);
void DeleteHeaderContent(struct CHeader *head);
void DeleteShortHeaderContent(struct CShortHeader *head);
-char *ExtractFromContentType(char *ContentType,char *value);
+char *ExtractFromContentType(char *ContentType, char *value);
WCHAR *ParseMultipartBody(char *src, char *bond);
//From account.cpp
-void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value);
+void WINAPI GetStatusFcn(HACCOUNT Which, TCHAR *Value);
extern HYAMNPROTOPLUGIN POP3Plugin;
//from decode.cpp
-int DecodeQuotedPrintable(char *Src,char *Dst,int DstLen, BOOL isQ);
-int DecodeBase64(char *Src,char *Dst,int DstLen);
+int DecodeQuotedPrintable(char *Src, char *Dst, int DstLen, BOOL isQ);
+int DecodeBase64(char *Src, char *Dst, int DstLen);
//From filterplugin.cpp
extern PYAMN_FILTERPLUGINQUEUE FirstFilterPlugin;
@@ -242,18 +242,18 @@ extern char *iconDescs[]; extern char *iconNames[];
extern HIMAGELIST CSImages;
-extern void __stdcall SSL_DebugLog( const char *fmt, ... );
+extern void __stdcall SSL_DebugLog(const char *fmt, ...);
extern int YAMN_STATUS;
extern struct WndHandles *MessageWnd;
-extern int GetCharsetFromString(char *input,size_t size);
-extern void SendMsgToRecepients(struct WndHandles *FirstWin,UINT msg,WPARAM wParam,LPARAM lParam);
-extern void ConvertCodedStringToUnicode(char *stream,WCHAR **storeto,DWORD cp,int mode);
-extern DWORD WINAPI MailBrowser(LPVOID Param);
+extern int GetCharsetFromString(char *input, size_t size);
+extern void SendMsgToRecepients(struct WndHandles *FirstWin, UINT msg, WPARAM wParam, LPARAM lParam);
+extern void ConvertCodedStringToUnicode(char *stream, WCHAR **storeto, DWORD cp, int mode);
+extern void __cdecl MailBrowser(void *Param);
extern DWORD WINAPI NoNewMailProc(LPVOID Param);
-extern DWORD WINAPI BadConnection(LPVOID Param);
+extern void __cdecl BadConnection(void *Param);
extern PVOID TLSCtx;
extern PVOID SSLCtx;
|