diff options
author | George Hazan <george.hazan@gmail.com> | 2016-02-19 12:05:55 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-02-19 12:05:55 +0000 |
commit | 5b796cb19202cbd63634ff68bda89520a5efc0c3 (patch) | |
tree | d06195813c1c422bea0c673e6e58f098b2d739eb /plugins/YAMN/src/account.cpp | |
parent | a886e1caf3d3d563b43aaa230144b3e8f40a3d4e (diff) |
YAMN:
- incorrect Unicode processing fixed;
- critical sections removed;
- translation fix;
- code cleaning;
git-svn-id: http://svn.miranda-ng.org/main/trunk@16308 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/YAMN/src/account.cpp')
-rw-r--r-- | plugins/YAMN/src/account.cpp | 84 |
1 files changed, 17 insertions, 67 deletions
diff --git a/plugins/YAMN/src/account.cpp b/plugins/YAMN/src/account.cpp index 676dfe0b50..3d7648a76f 100644 --- a/plugins/YAMN/src/account.cpp +++ b/plugins/YAMN/src/account.cpp @@ -8,14 +8,14 @@ #include "stdafx.h" -//Account status CS -//When we check some account, thread should change status of account to idle, connecting etc. -//So if we want to read status, we have to successfully write and then read. -CRITICAL_SECTION AccountStatusCS; +// Account status CS +// When we check some account, thread should change status of account to idle, connecting etc. +// So if we want to read status, we have to successfully write and then read. +static mir_cs csAccountStatusCS; -//File Writing CS -//When 2 threads want to write to file... -CRITICAL_SECTION FileWritingCS; +// File Writing CS +// When 2 threads want to write to file... +static mir_cs csFileWritingCS; struct CExportedFunctions AccountExportedFcn[] = { @@ -970,23 +970,17 @@ static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin, HANDLE File) return 0; } -//Writes accounts to file +// Writes accounts to file INT_PTR WriteAccountsToFileSvc(WPARAM wParam, LPARAM 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) { - LeaveCriticalSection(&FileWritingCS); + mir_cslock lck(csFileWritingCS); + HANDLE hFile = CreateFile((TCHAR*)lParam, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) return EACC_SYSTEM; - } - INT_PTR rv = PerformAccountWriting(Plugin, hFile); - LeaveCriticalSection(&FileWritingCS); - - return rv; + return PerformAccountWriting(Plugin, hFile); } INT_PTR FindAccountByNameSvc(WPARAM wParam, LPARAM lParam) @@ -1229,7 +1223,6 @@ int DeleteAccounts(HYAMNPROTOPLUGIN Plugin) DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write done\n"); #endif SWMRGDoneWriting(Plugin->AccountBrowserSO); - return 1; } @@ -1238,59 +1231,16 @@ void WINAPI GetStatusFcn(HACCOUNT Which, TCHAR *Value) if (Which == NULL) return; -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs wait\n"); -#endif - EnterCriticalSection(&AccountStatusCS); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs enter\n"); -#endif + mir_cslock lck(csAccountStatusCS); mir_tstrcpy(Value, Which->Status); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs done\n"); -#endif - LeaveCriticalSection(&AccountStatusCS); - return; } void WINAPI SetStatusFcn(HACCOUNT Which, TCHAR *Value) { - if (Which == NULL) - return; + if (Which != NULL) { + mir_cslock lck(csAccountStatusCS); + mir_tstrcpy(Which->Status, Value); + } -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs wait\n"); -#endif - EnterCriticalSection(&AccountStatusCS); -#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); -#ifdef DEBUG_SYNCHRO - DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs done\n"); -#endif - LeaveCriticalSection(&AccountStatusCS); } - -/* -#ifdef DEBUG_ACCOUNTS -int GetAccounts() -{ -HACCOUNT Finder; -int cnt=0; - -for (Finder=Account;Finder != NULL;Finder=Finder->Next) -cnt++; -return cnt; -} - -void WriteAccounts() -{ -HACCOUNT Finder; - -for (Finder=Account;Finder != NULL;Finder=Finder->Next) -MessageBoxA(NULL,Finder->Name,"Browsing account",MB_OK); -} -#endif -*/ |