diff options
author | George Hazan <george.hazan@gmail.com> | 2012-05-26 21:22:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-05-26 21:22:43 +0000 |
commit | c5bc8f21d5b87482f737c5ca64a4d46ebe7a2497 (patch) | |
tree | c13b62a3f1224750108aa33919ef6f9a32a2767d /plugins/YAMN/yamn.cpp | |
parent | 17f839d0a607c05ae390d6306d81ecea19c7ea45 (diff) |
YAMN became partially Unicode
git-svn-id: http://svn.miranda-ng.org/main/trunk@186 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/YAMN/yamn.cpp')
-rw-r--r-- | plugins/YAMN/yamn.cpp | 164 |
1 files changed, 43 insertions, 121 deletions
diff --git a/plugins/YAMN/yamn.cpp b/plugins/YAMN/yamn.cpp index 467f3d6bba..652ce01712 100644 --- a/plugins/YAMN/yamn.cpp +++ b/plugins/YAMN/yamn.cpp @@ -1,17 +1,16 @@ /*
* This code implements miscellaneous usefull functions
- *
+ *
* (c) majvan 2002-2004
*/
+
+#include "yamn.h"
+
#include "m_yamn.h"
#include "m_protoplugin.h"
#include "m_messages.h"
#include "m_synchro.h"
#include "main.h"
-#include "yamn.h"
-#ifdef DEBUG_SYNCHRO
- #include <stdio.h>
-#endif
//- imported ---------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
@@ -47,14 +46,9 @@ extern struct CExportedServices MailExportedSvc[5]; //--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
-//MessageWndCS
-//We want to send messages to all windows in the queue
-//When we send messages, no other window can register itself to the queue for receiving messages
-LPCRITICAL_SECTION MessageWndCS;
-
//Plugin registration CS
//Used if we add (register) plugin to YAMN plugins and when we browse through registered plugins
-LPCRITICAL_SECTION PluginRegCS;
+CRITICAL_SECTION PluginRegCS;
//AccountWriterCS
//We want to store number of writers of Accounts (number of Accounts used for writing)
@@ -106,31 +100,31 @@ INT_PTR GetFcnPtrSvc(WPARAM wParam,LPARAM lParam) register int i;
for(i=0;i<sizeof(ProtoPluginExportedFcn)/sizeof(ProtoPluginExportedFcn[0]);i++)
- if(0==lstrcmp((char *)wParam,ProtoPluginExportedFcn[i].ID))
+ if (0==lstrcmpA((char *)wParam,ProtoPluginExportedFcn[i].ID))
return (INT_PTR)ProtoPluginExportedFcn[i].Ptr;
for(i=0;i<sizeof(ProtoPluginExportedSvc)/sizeof(ProtoPluginExportedSvc[0]);i++)
- if(0==lstrcmp((char *)wParam,ProtoPluginExportedSvc[i].ID))
+ if (0==lstrcmpA((char *)wParam,ProtoPluginExportedSvc[i].ID))
return (INT_PTR)ProtoPluginExportedSvc[i].Ptr;
for(i=0;i<sizeof(SynchroExportedFcn)/sizeof(SynchroExportedFcn[0]);i++)
- if(0==lstrcmp((char *)wParam,SynchroExportedFcn[i].ID))
+ if (0==lstrcmpA((char *)wParam,SynchroExportedFcn[i].ID))
return (INT_PTR)SynchroExportedFcn[i].Ptr;
for(i=0;i<sizeof(AccountExportedFcn)/sizeof(AccountExportedFcn[0]);i++)
- if(0==lstrcmp((char *)wParam,AccountExportedFcn[i].ID))
+ if (0==lstrcmpA((char *)wParam,AccountExportedFcn[i].ID))
return (INT_PTR)AccountExportedFcn[i].Ptr;
for(i=0;i<sizeof(AccountExportedSvc)/sizeof(AccountExportedSvc[0]);i++)
- if(0==lstrcmp((char *)wParam,AccountExportedSvc[i].ID))
+ if (0==lstrcmpA((char *)wParam,AccountExportedSvc[i].ID))
return (INT_PTR)AccountExportedSvc[i].Ptr;
for(i=0;i<sizeof(MailExportedFcn)/sizeof(MailExportedFcn[0]);i++)
- if(0==lstrcmp((char *)wParam,MailExportedFcn[i].ID))
+ if (0==lstrcmpA((char *)wParam,MailExportedFcn[i].ID))
return (INT_PTR)MailExportedFcn[i].Ptr;
for(i=0;i<sizeof(MailExportedSvc)/sizeof(MailExportedSvc[0]);i++)
- if(0==lstrcmp((char *)wParam,MailExportedSvc[i].ID))
+ if (0==lstrcmpA((char *)wParam,MailExportedSvc[i].ID))
return (INT_PTR)MailExportedSvc[i].Ptr;
for(i=0;i<sizeof(FilterPluginExportedFcn)/sizeof(FilterPluginExportedFcn[0]);i++)
- if(0==lstrcmp((char *)wParam,FilterPluginExportedFcn[i].ID))
+ if (0==lstrcmpA((char *)wParam,FilterPluginExportedFcn[i].ID))
return (INT_PTR)FilterPluginExportedFcn[i].Ptr;
for(i=0;i<sizeof(FilterPluginExportedSvc)/sizeof(FilterPluginExportedSvc[0]);i++)
- if(0==lstrcmp((char *)wParam,FilterPluginExportedSvc[i].ID))
+ if (0==lstrcmpA((char *)wParam,FilterPluginExportedSvc[i].ID))
return (INT_PTR)FilterPluginExportedSvc[i].Ptr;
return (INT_PTR)NULL;
}
@@ -146,8 +140,8 @@ DWORD WINAPI YAMNHotKeyThread(LPVOID Param) WORD HotKey = LOWORD(Param);
int HotKeyID;
-// register hotkey for main YAMN thread first
- if(!(HotKeyID=RegisterHotKey(NULL,(int)GlobalAddAtom(YAMN_HKCHECKMAIL),HIBYTE(HotKey),LOBYTE(HotKey))))
+// register hotkey for main YAMN thread first
+ if (!(HotKeyID=RegisterHotKey(NULL,(int)GlobalAddAtomA(YAMN_HKCHECKMAIL),HIBYTE(HotKey),LOBYTE(HotKey))))
return 0;
while(1)
@@ -155,7 +149,7 @@ DWORD WINAPI YAMNHotKeyThread(LPVOID Param) GetMessage(&WinMessage,NULL,WM_HOTKEY,WM_YAMN_CHANGEHOTKEY);
// if we want to close miranda, we get event and do not run pop3 checking anymore
- if(WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
+ if (WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
break;
switch(WinMessage.message)
@@ -167,7 +161,7 @@ DWORD WINAPI YAMNHotKeyThread(LPVOID Param) // hotkey changed
case WM_YAMN_CHANGEHOTKEY:
UnregisterHotKey(NULL,HotKeyID);
- HotKeyID=RegisterHotKey(NULL,(int)GlobalAddAtom(YAMN_HKCHECKMAIL),WinMessage.wParam,WinMessage.lParam);
+ HotKeyID=RegisterHotKey(NULL,(int)GlobalAddAtomA(YAMN_HKCHECKMAIL),WinMessage.wParam,WinMessage.lParam);
break;
}
}
@@ -182,26 +176,26 @@ void CALLBACK TimerProc(HWND,UINT,UINT,DWORD) DWORD Status,tid;
// we use event to signal, that running thread has all needed stack parameters copied
- if(NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ if (NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
return;
// if we want to close miranda, we get event and do not run checking anymore
- if(WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
+ if (WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
return;
// Get actual status of current user in Miranda
Status=CallService(MS_CLIST_GETSTATUSMODE,0,0);
- EnterCriticalSection(PluginRegCS);
+ EnterCriticalSection(&PluginRegCS);
for(ActualPlugin=FirstProtoPlugin;ActualPlugin!=NULL;ActualPlugin=ActualPlugin->Next)
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"TimerProc:AccountBrowserSO-read wait\n");
#endif
- if(WAIT_OBJECT_0!=SWMRGWaitToRead(ActualPlugin->Plugin->AccountBrowserSO,0)) //we want to access accounts immiadtelly
+ if (WAIT_OBJECT_0!=SWMRGWaitToRead(ActualPlugin->Plugin->AccountBrowserSO,0)) //we want to access accounts immiadtelly
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"TimerProc:AccountBrowserSO-read enter failed\n");
#endif
- LeaveCriticalSection(PluginRegCS);
+ LeaveCriticalSection(&PluginRegCS);
return;
}
#ifdef DEBUG_SYNCHRO
@@ -209,12 +203,12 @@ void CALLBACK TimerProc(HWND,UINT,UINT,DWORD) #endif
for(ActualAccount=ActualPlugin->Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=ActualAccount->Next)
{
- if(ActualAccount->Plugin==NULL || ActualAccount->Plugin->Fcn==NULL) //account not inited
+ if (ActualAccount->Plugin==NULL || ActualAccount->Plugin->Fcn==NULL) //account not inited
continue;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"TimerProc:ActualAccountSO-read wait\n");
#endif
- if(WAIT_OBJECT_0!=SWMRGWaitToRead(ActualAccount->AccountAccessSO,0))
+ if (WAIT_OBJECT_0!=SWMRGWaitToRead(ActualAccount->AccountAccessSO,0))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"TimerProc:ActualAccountSO-read wait failed\n");
@@ -222,7 +216,7 @@ void CALLBACK TimerProc(HWND,UINT,UINT,DWORD) continue;
}
#ifdef DEBUG_SYNCHRO
-
+
switch(Status)
{
case ID_STATUS_OFFLINE:
@@ -261,7 +255,7 @@ void CALLBACK TimerProc(HWND,UINT,UINT,DWORD) }
#endif
BOOL isAccountCounting = 0;
- if(
+ if (
(ActualAccount->Flags & YAMN_ACC_ENA) &&
(((ActualAccount->StatusFlags & YAMN_ACC_ST0) && (Status<=ID_STATUS_OFFLINE)) ||
((ActualAccount->StatusFlags & YAMN_ACC_ST1) && (Status==ID_STATUS_ONLINE)) ||
@@ -275,11 +269,11 @@ void CALLBACK TimerProc(HWND,UINT,UINT,DWORD) ((ActualAccount->StatusFlags & YAMN_ACC_ST9) && (Status==ID_STATUS_OUTTOLUNCH))))
{
- if((!ActualAccount->Interval && !ActualAccount->TimeLeft) || ActualAccount->Plugin->Fcn->TimeoutFcnPtr==NULL)
+ if ((!ActualAccount->Interval && !ActualAccount->TimeLeft) || ActualAccount->Plugin->Fcn->TimeoutFcnPtr==NULL)
{
goto ChangeIsCountingStatusLabel;
}
- if(ActualAccount->TimeLeft){
+ if (ActualAccount->TimeLeft){
ActualAccount->TimeLeft--;
isAccountCounting = TRUE;
}
@@ -287,13 +281,13 @@ void CALLBACK TimerProc(HWND,UINT,UINT,DWORD) DebugLog(SynchroFile,"TimerProc:time left : %i\n",ActualAccount->TimeLeft);
#endif
WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_CHANGETIME,(WPARAM)ActualAccount,(LPARAM)ActualAccount->TimeLeft);
- if(!ActualAccount->TimeLeft)
+ if (!ActualAccount->TimeLeft)
{
struct CheckParam ParamToPlugin={YAMN_CHECKVERSION,ThreadRunningEV,ActualAccount,YAMN_NORMALCHECK,(void *)0,NULL};
HANDLE NewThread;
-
+
ActualAccount->TimeLeft=ActualAccount->Interval;
- if(NULL==(NewThread=CreateThread(NULL,0,(YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->TimeoutFcnPtr,&ParamToPlugin,0,&tid)))
+ if (NULL==(NewThread=CreateThread(NULL,0,(YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->TimeoutFcnPtr,&ParamToPlugin,0,&tid)))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"TimerProc:ActualAccountSO-read done\n");
@@ -330,7 +324,7 @@ ChangeIsCountingStatusLabel: #endif
SWMRGDoneReading(ActualPlugin->Plugin->AccountBrowserSO);
}
- LeaveCriticalSection(PluginRegCS);
+ LeaveCriticalSection(&PluginRegCS);
CloseHandle(ThreadRunningEV);
return;
}
@@ -343,29 +337,29 @@ INT_PTR ForceCheckSvc(WPARAM,LPARAM) DWORD tid;
//we use event to signal, that running thread has all needed stack parameters copied
- if(NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ if (NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
return 0;
//if we want to close miranda, we get event and do not run pop3 checking anymore
- if(WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
+ if (WAIT_OBJECT_0==WaitForSingleObject(ExitEV,0))
return 0;
- EnterCriticalSection(PluginRegCS);
+ EnterCriticalSection(&PluginRegCS);
for(ActualPlugin=FirstProtoPlugin;ActualPlugin!=NULL;ActualPlugin=ActualPlugin->Next)
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ForceCheck:AccountBrowserSO-read wait\n");
- #endif
+ #endif
SWMRGWaitToRead(ActualPlugin->Plugin->AccountBrowserSO,INFINITE);
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ForceCheck:AccountBrowserSO-read enter\n");
#endif
for(ActualAccount=ActualPlugin->Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=ActualAccount->Next)
{
- if(ActualAccount->Plugin->Fcn==NULL) //account not inited
+ if (ActualAccount->Plugin->Fcn==NULL) //account not inited
continue;
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ForceCheck:ActualAccountSO-read wait\n");
#endif
- if(WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
{
#ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ForceCheck:ActualAccountSO-read wait failed\n");
@@ -375,16 +369,16 @@ INT_PTR ForceCheckSvc(WPARAM,LPARAM) #ifdef DEBUG_SYNCHRO
DebugLog(SynchroFile,"ForceCheck:ActualAccountSO-read enter\n");
#endif
- if((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE)) //account cannot be forced to check
+ if ((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE)) //account cannot be forced to check
{
- if(ActualAccount->Plugin->Fcn->ForceCheckFcnPtr==NULL)
+ if (ActualAccount->Plugin->Fcn->ForceCheckFcnPtr==NULL)
{
ReadDoneFcn(ActualAccount->AccountAccessSO);
continue;
}
struct CheckParam ParamToPlugin={YAMN_CHECKVERSION,ThreadRunningEV,ActualAccount,YAMN_FORCECHECK,(void *)0,NULL};
- if(NULL==CreateThread(NULL,0,(YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr,&ParamToPlugin,0,&tid))
+ if (NULL==CreateThread(NULL,0,(YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr,&ParamToPlugin,0,&tid))
{
ReadDoneFcn(ActualAccount->AccountAccessSO);
continue;
@@ -399,80 +393,8 @@ INT_PTR ForceCheckSvc(WPARAM,LPARAM) #endif
SWMRGDoneReading(ActualPlugin->Plugin->AccountBrowserSO);
}
- LeaveCriticalSection(PluginRegCS);
+ LeaveCriticalSection(&PluginRegCS);
CloseHandle(ThreadRunningEV);
CallService(MS_TTB_SETBUTTONSTATE,(WPARAM)hTTButton,(LPARAM)TTBST_RELEASED);
return 1;
}
-/*
-int ExitProc(WPARAM wParam,LPARAM lParam)
-{
- THIS WILL BE IMPLEMENTED LATER
-// First, no thread must add or delete accounts. This is achieved by entering browsing through accounts
-// If any thread want to delete or add, it waits for write-access to browse accounts (so it waits infinite time)
-#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"ExitProc:AccountBrowserSO-wait to obtain read access\n"));
-#endif
- if(WAIT_TIMEOUT==SWMRGWaitToRead(AccountBrowserSO,0))
- {
-#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"ExitProc:AccountBrowserSO-read access obtain failed, I'll try later\n"));
-#endif
- return 1;
- }
-#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"ExitProc:AccountBrowserSO-read access obtained\n"));
-#endif
-#ifdef DEBUG_SYNCHRO
- TCHAR Debug[100];
-
- _stprintf(Debug,_T("ExitProc:Writers: %d\n"),AccountWriterSO->GetNumber());
- DEBUG_SYNCHRO2F(Debug);
- DebugLog(SynchroFile,"ExitProc:NoWriterEV-test\n"));
-#endif
-// next, threads must not write to any account. This works like hFinishEV event in AccountAccessSO and MessagesAccessSO.
-// When hFinishEV is set, any beginning with reading and writing to account (messages) is failed.
-// This is similar, but the difference is, that we can finish the whole work (we can decide: if ExitEV is set, should we
-// end immidialtelly or should we continue (to end operation successfully)?
-// E.g. I decided that once we started checking account, we get all new mails and then we can end.
-// The second and more significant difference is, that ExitEV is signal to all accounts and messages, not only to one account.
-
- SetEvent(ExitEV);
- if(WAIT_TIMEOUT==WaitForSingleObject(AccountWriterSO->Event,0))
- {
-// There exists a thread writing to account, so we ca try later to write accounts to file, if no thread is writting
-#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"ExitProc:NoWriterEV-writer(s) exists, I'll try later\n"));
-#endif
- SWMRGDoneReading(AccountBrowserSO);
- return 1;
- }
-
-#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"ExitProc:NoWriterEV-no writer, going to save!\n"));
-#endif
-// Save to file
- WriteAccountsToFile();
- SWMRGDoneReading(AccountBrowserSO);
-// Now, all is saved, we can safe exit from Miranda
- return 0;
-}
-*/
-/*
-DWORD WINAPI FileWritingThread(PVOID)
-{
- HACCOUNT ActualAccount=FirstAccount;
-
- while(1)
- {
- WaitForSingleObject(WriteToFileEV,INFINITE);
-#ifdef DEBUG_SYNCHRO
- DebugLog(SynchroFile,"FileWriting:WriteToFileEV-signaled\n"));
-#endif
-// now, write accounts and messages if it is possible. If it is not possible e.g. to read messages from one account,
-// function will wait until messages are not used and then writes messages
- WriteAccountsToFile();
- }
- return 0;
-}
-*/
|