summaryrefslogtreecommitdiff
path: root/protocols/MRA
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-09-27 08:09:54 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-09-27 08:09:54 +0000
commit4a57667c0372692f38be7457a1d11346af5e17c1 (patch)
treec0b65afce8acd7f062b38fe7bfe389da567327ab /protocols/MRA
parent86651ea27acb5ba7f4cba2fdeb8a8a1d6bd3165f (diff)
- fix for MRA avatar path
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@1677 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA')
-rw-r--r--protocols/MRA/MraAvatars.cpp457
-rw-r--r--protocols/MRA/MraFilesQueue.cpp18
-rw-r--r--protocols/MRA/MraMPop.cpp4
-rw-r--r--protocols/MRA/MraMRIMProxy.cpp4
-rw-r--r--protocols/MRA/MraOfflineMsg.cpp2
-rw-r--r--protocols/MRA/MraRTFMsg.cpp2
-rw-r--r--protocols/MRA/MraSendQueue.cpp8
-rw-r--r--protocols/MRA/Mra_functions.cpp16
-rw-r--r--protocols/MRA/Mra_proto.cpp12
9 files changed, 242 insertions, 281 deletions
diff --git a/protocols/MRA/MraAvatars.cpp b/protocols/MRA/MraAvatars.cpp
index b8c1d1584e..78989906ee 100644
--- a/protocols/MRA/MraAvatars.cpp
+++ b/protocols/MRA/MraAvatars.cpp
@@ -123,85 +123,67 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle)
void CMraProto::MraAvatarsQueueClear(HANDLE hAvatarsQueueHandle)
{
- if (hAvatarsQueueHandle)
- {
- MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
- MRA_AVATARS_QUEUE_ITEM *pmraaqiAvatarsQueueItem;
- PROTO_AVATAR_INFORMATIONT pai = {0};
+ if ( !hAvatarsQueueHandle)
+ return;
- pai.cbSize = sizeof(pai);
- //pai.hContact = pmraaqiAvatarsQueueItem->hContact;
- pai.format = PA_FORMAT_UNKNOWN;
- //pai.filename[0] = 0;
+ MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
+ MRA_AVATARS_QUEUE_ITEM *pmraaqiAvatarsQueueItem;
- while(FifoMTItemPop(pmraaqAvatarsQueue, NULL, (LPVOID*)&pmraaqiAvatarsQueueItem) == NO_ERROR)
- {
- pai.hContact = pmraaqiAvatarsQueueItem->hContact;
- ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&pai, 0);
- mir_free(pmraaqiAvatarsQueueItem);
- }
+ PROTO_AVATAR_INFORMATIONT pai = {0};
+ pai.cbSize = sizeof(pai);
+ pai.format = PA_FORMAT_UNKNOWN;
+
+ while (FifoMTItemPop(pmraaqAvatarsQueue, NULL, (LPVOID*)&pmraaqiAvatarsQueueItem) == NO_ERROR) {
+ pai.hContact = pmraaqiAvatarsQueueItem->hContact;
+ ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE)&pai, 0);
+ mir_free(pmraaqiAvatarsQueueItem);
}
}
void CMraProto::MraAvatarsQueueDestroy(HANDLE hAvatarsQueueHandle)
{
- if (hAvatarsQueueHandle)
- {
- MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
+ if ( !hAvatarsQueueHandle)
+ return;
- InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, FALSE);
- SetEvent(pmraaqAvatarsQueue->hThreadEvent);
+ MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
- WaitForMultipleObjects(pmraaqAvatarsQueue->dwThreadsCount, (HANDLE*)&pmraaqAvatarsQueue->hThread[0], TRUE, (WAIT_FOR_THREAD_TIMEOUT*1000));
+ InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, FALSE);
+ SetEvent(pmraaqAvatarsQueue->hThreadEvent);
- if (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
- {// Иногда они не завершаются, хотя уведомление говорит об обратном %)
- while(InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
- {// ждём пока точно все завершатся
- SleepEx(100, TRUE);
- }
- }
+ WaitForMultipleObjects(pmraaqAvatarsQueue->dwThreadsCount, (HANDLE*)&pmraaqAvatarsQueue->hThread[0], TRUE, (WAIT_FOR_THREAD_TIMEOUT*1000));
- CloseHandle(pmraaqAvatarsQueue->hThreadEvent);
+ if (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
+ while (InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount, 0))
+ SleepEx(100, TRUE);
- MraAvatarsQueueClear(hAvatarsQueueHandle);
+ CloseHandle(pmraaqAvatarsQueue->hThreadEvent);
- FifoMTDestroy(pmraaqAvatarsQueue);
- Netlib_CloseHandle(pmraaqAvatarsQueue->hNetlibUser);
- mir_free(pmraaqAvatarsQueue);
- }
+ MraAvatarsQueueClear(hAvatarsQueueHandle);
+
+ FifoMTDestroy(pmraaqAvatarsQueue);
+ Netlib_CloseHandle(pmraaqAvatarsQueue->hNetlibUser);
+ mir_free(pmraaqAvatarsQueue);
}
DWORD CMraProto::MraAvatarsQueueAdd(HANDLE hAvatarsQueueHandle, DWORD dwFlags, HANDLE hContact, DWORD *pdwAvatarsQueueID)
{
- DWORD dwRetErrorCode;
+ if ( !hAvatarsQueueHandle)
+ return ERROR_INVALID_HANDLE;
- if (hAvatarsQueueHandle)
- {
- MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
- MRA_AVATARS_QUEUE_ITEM *pmraaqiAvatarsQueueItem;
+ MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
+ MRA_AVATARS_QUEUE_ITEM *pmraaqiAvatarsQueueItem = (MRA_AVATARS_QUEUE_ITEM*)mir_calloc(sizeof(MRA_AVATARS_QUEUE_ITEM));
+ if ( !pmraaqiAvatarsQueueItem)
+ return GetLastError();
- pmraaqiAvatarsQueueItem = (MRA_AVATARS_QUEUE_ITEM*)mir_calloc(sizeof(MRA_AVATARS_QUEUE_ITEM));
- if (pmraaqiAvatarsQueueItem)
- {
- //pmraaqiAvatarsQueueItem->ffmtiFifoItem;
- pmraaqiAvatarsQueueItem->dwAvatarsQueueID = GetTickCount();
- pmraaqiAvatarsQueueItem->dwFlags = dwFlags;
- pmraaqiAvatarsQueueItem->hContact = hContact;
-
- FifoMTItemPush(pmraaqAvatarsQueue, pmraaqiAvatarsQueueItem, (LPVOID)pmraaqiAvatarsQueueItem);
- if (pdwAvatarsQueueID) (*pdwAvatarsQueueID) = pmraaqiAvatarsQueueItem->dwAvatarsQueueID;
- SetEvent(pmraaqAvatarsQueue->hThreadEvent);
-
- dwRetErrorCode = NO_ERROR;
- }else {
- dwRetErrorCode = GetLastError();
- ShowFormattedErrorMessage(L"Avatars: can't add request to queue, error", dwRetErrorCode);
- }
- }else {
- dwRetErrorCode = ERROR_INVALID_HANDLE;
- }
- return dwRetErrorCode;
+ pmraaqiAvatarsQueueItem->dwAvatarsQueueID = GetTickCount();
+ pmraaqiAvatarsQueueItem->dwFlags = dwFlags;
+ pmraaqiAvatarsQueueItem->hContact = hContact;
+
+ FifoMTItemPush(pmraaqAvatarsQueue, pmraaqiAvatarsQueueItem, (LPVOID)pmraaqiAvatarsQueueItem);
+ if (pdwAvatarsQueueID)
+ *pdwAvatarsQueueID = pmraaqiAvatarsQueueItem->dwAvatarsQueueID;
+ SetEvent(pmraaqAvatarsQueue->hThreadEvent);
+ return NO_ERROR;
}
void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter)
@@ -213,12 +195,12 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter)
WCHAR wszFileName[MAX_FILEPATH], szErrorText[2048];
BOOL bContinue, bKeepAlive, bUseKeepAliveConn, bFailed, bDownloadNew, bDefaultAvt;
BYTE btBuff[BUFF_SIZE_RCV];
- DWORD dwResultCode, dwAvatarFormat, dwReceived, dwWritten, dwServerPort, dwErrorCode;
+ DWORD dwResultCode, dwAvatarFormat, dwReceived, dwServerPort, dwErrorCode;
LPSTR lpszUser, lpszDomain;
size_t dwEMailSize, dwAvatarSizeServer, dwFileNameSize;
FILETIME ftLastModifiedTimeServer, ftLastModifiedTimeLocal;
SYSTEMTIME stAvatarLastModifiedTimeLocal;
- HANDLE hConnection = NULL, hFile;
+ HANDLE hConnection = NULL;
NETLIBSELECT nls = {0};
INTERNET_TIME itAvatarLastModifiedTimeServer;
PROTO_AVATAR_INFORMATIONT pai;
@@ -228,10 +210,8 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter)
InterlockedIncrement((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount);
- while(InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, 0))
- {
- if (FifoMTItemPop(pmraaqAvatarsQueue, NULL, (LPVOID*)&pmraaqiAvatarsQueueItem) == NO_ERROR)
- {
+ while ( InterlockedExchangeAdd((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, 0)) {
+ if ( FifoMTItemPop(pmraaqAvatarsQueue, NULL, (LPVOID*)&pmraaqiAvatarsQueueItem) == NO_ERROR) {
bFailed = TRUE;
bDownloadNew = FALSE;
bDefaultAvt = FALSE;
@@ -240,133 +220,133 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter)
dwServerPort = DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "ServerPort", MRA_AVT_DEFAULT_SERVER_PORT);
bUseKeepAliveConn = db_get_b(NULL, MRA_AVT_SECT_NAME, "UseKeepAliveConn", MRA_AVT_DEFAULT_USE_KEEPALIVE_CONN);
- if (mraGetStaticStringA(pmraaqiAvatarsQueueItem->hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize)) {
+ if ( mraGetStaticStringA(pmraaqiAvatarsQueueItem->hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize)) {
BuffToLowerCase(szEMail, szEMail, dwEMailSize);
- if (lpszDomain = (LPSTR)MemoryFindByte(0, szEMail, dwEMailSize, '@'))
- if (lpszUser = (LPSTR)MemoryFindByte((lpszDomain-szEMail), szEMail, dwEMailSize, '.')) {
- *lpszUser = 0;
- lpszUser = szEMail;
- *lpszDomain = 0;
- lpszDomain++;
-
- ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_CONNECTING, NULL, 0);
- if (hConnection == NULL) hConnection = MraAvatarsHttpConnect(pmraaqAvatarsQueue->hNetlibUser, szServer, dwServerPort);
- if (hConnection) {
- ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_CONNECTED, NULL, 0);
- ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_SENTREQUEST, NULL, 0);
- if (MraAvatarsHttpTransaction(hConnection, REQUEST_HEAD, lpszUser, lpszDomain, szServer, MAHTRO_AVTMRIM, bUseKeepAliveConn, &dwResultCode, &bKeepAlive, &dwAvatarFormat, &dwAvatarSizeServer, &itAvatarLastModifiedTimeServer) == NO_ERROR)
- {
- switch (dwResultCode) {
- case 200:
- if (MraAvatarsGetContactTime(pmraaqiAvatarsQueueItem->hContact, "AvatarLastModifiedTime", &stAvatarLastModifiedTimeLocal)) {
- SystemTimeToFileTime(&itAvatarLastModifiedTimeServer.stTime, &ftLastModifiedTimeServer);
- SystemTimeToFileTime(&stAvatarLastModifiedTimeLocal, &ftLastModifiedTimeLocal);
-
- if ((*((DWORDLONG*)&ftLastModifiedTimeServer)) != (*((DWORDLONG*)&ftLastModifiedTimeLocal)))
- {// need check for update
- bDownloadNew = TRUE;
- //ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, 0, 0);
- }
- else {// avatar is valid
- if (MraAvatarsGetFileName(pmraaqAvatarsQueue, pmraaqiAvatarsQueueItem->hContact, dwAvatarFormat, wszFileName, SIZEOF(wszFileName), NULL) == NO_ERROR) {
- if ( IsFileExist( wszFileName ))
- bFailed = FALSE;
- else
- bDownloadNew = TRUE;
- }
- }
- }
- else // need update
+ lpszDomain = (LPSTR)MemoryFindByte(0, szEMail, dwEMailSize, '@');
+ lpszUser = (LPSTR)MemoryFindByte((lpszDomain-szEMail), szEMail, dwEMailSize, '.');
+ if (lpszDomain && lpszUser) {
+ *lpszUser = 0;
+ lpszUser = szEMail;
+ *lpszDomain = 0;
+ lpszDomain++;
+
+ ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_CONNECTING, NULL, 0);
+ if (hConnection == NULL)
+ hConnection = MraAvatarsHttpConnect(pmraaqAvatarsQueue->hNetlibUser, szServer, dwServerPort);
+ if (hConnection) {
+ ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_CONNECTED, NULL, 0);
+ ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_SENTREQUEST, NULL, 0);
+ if ( !MraAvatarsHttpTransaction(hConnection, REQUEST_HEAD, lpszUser, lpszDomain, szServer, MAHTRO_AVTMRIM, bUseKeepAliveConn, &dwResultCode, &bKeepAlive, &dwAvatarFormat, &dwAvatarSizeServer, &itAvatarLastModifiedTimeServer)) {
+ switch (dwResultCode) {
+ case 200:
+ if (MraAvatarsGetContactTime(pmraaqiAvatarsQueueItem->hContact, "AvatarLastModifiedTime", &stAvatarLastModifiedTimeLocal)) {
+ SystemTimeToFileTime(&itAvatarLastModifiedTimeServer.stTime, &ftLastModifiedTimeServer);
+ SystemTimeToFileTime(&stAvatarLastModifiedTimeLocal, &ftLastModifiedTimeLocal);
+
+ if ((*((DWORDLONG*)&ftLastModifiedTimeServer)) != (*((DWORDLONG*)&ftLastModifiedTimeLocal)))
+ {// need check for update
bDownloadNew = TRUE;
-
- break;
- case 404:// return def avatar
- if (MraAvatarsGetFileName((HANDLE)pmraaqAvatarsQueue, NULL, PA_FORMAT_DEFAULT, wszFileName, SIZEOF(wszFileName), &dwFileNameSize) == NO_ERROR) {
- if ( IsFileExist( wszFileName )) {
- dwAvatarFormat = MraAvatarsGetFileFormat(wszFileName, dwFileNameSize);
- bFailed = FALSE;
+ //ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, 0, 0);
+ }
+ else {// avatar is valid
+ if (MraAvatarsGetFileName(pmraaqAvatarsQueue, pmraaqiAvatarsQueueItem->hContact, dwAvatarFormat, wszFileName, SIZEOF(wszFileName), NULL) == NO_ERROR) {
+ if ( IsFileExist( wszFileName ))
+ bFailed = FALSE;
+ else
+ bDownloadNew = TRUE;
}
- else//loading default avatar
- bDownloadNew = TRUE;
-
- bDefaultAvt = TRUE;
}
- break;
+ }
+ else // need update
+ bDownloadNew = TRUE;
+
+ break;
+ case 404:// return def avatar
+ if (MraAvatarsGetFileName((HANDLE)pmraaqAvatarsQueue, NULL, PA_FORMAT_DEFAULT, wszFileName, SIZEOF(wszFileName), &dwFileNameSize) == NO_ERROR) {
+ if ( IsFileExist( wszFileName )) {
+ dwAvatarFormat = MraAvatarsGetFileFormat(wszFileName, dwFileNameSize);
+ bFailed = FALSE;
+ }
+ else//loading default avatar
+ bDownloadNew = TRUE;
- default:
- mir_sntprintf(szErrorText, SIZEOF(szErrorText), TranslateW(L"Avatars: server return HTTP code: %lu"), dwResultCode);
- ShowFormattedErrorMessage(szErrorText, NO_ERROR);
- break;
+ bDefaultAvt = TRUE;
}
+ break;
+
+ default:
+ mir_sntprintf(szErrorText, SIZEOF(szErrorText), TranslateW(L"Avatars: server return HTTP code: %lu"), dwResultCode);
+ ShowFormattedErrorMessage(szErrorText, NO_ERROR);
+ break;
}
- if (bUseKeepAliveConn == FALSE || bKeepAlive == FALSE) NETLIB_CLOSEHANDLE(hConnection);
}
+ if (bUseKeepAliveConn == FALSE || bKeepAlive == FALSE) NETLIB_CLOSEHANDLE(hConnection);
+ }
+ if (bDownloadNew) {
+ if (hConnection == NULL)
+ hConnection = MraAvatarsHttpConnect(pmraaqAvatarsQueue->hNetlibUser, szServer, dwServerPort);
- if (bDownloadNew)
- {
- if (hConnection == NULL) hConnection = MraAvatarsHttpConnect(pmraaqAvatarsQueue->hNetlibUser, szServer, dwServerPort);
- if (hConnection)
- {
- ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_DATA, NULL, 0);
- if (MraAvatarsHttpTransaction(hConnection, REQUEST_GET, lpszUser, lpszDomain, szServer, MAHTRO_AVT, bUseKeepAliveConn, &dwResultCode, &bKeepAlive, &dwAvatarFormat, &dwAvatarSizeServer, &itAvatarLastModifiedTimeServer) == NO_ERROR && dwResultCode == 200)
- {
- if (bDefaultAvt) dwAvatarFormat = PA_FORMAT_DEFAULT;
- if (MraAvatarsGetFileName(pmraaqAvatarsQueue, pmraaqiAvatarsQueueItem->hContact, dwAvatarFormat, wszFileName, SIZEOF(wszFileName), NULL) == NO_ERROR)
- {
- hFile = CreateFile(wszFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile != INVALID_HANDLE_VALUE) {
- dwWritten = 0;
- bContinue = TRUE;
- nls.dwTimeout = (1000*DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "TimeOutReceive", MRA_AVT_DEFAULT_TIMEOUT_RECV));
- nls.hReadConns[0] = hConnection;
-
- while ( bContinue ) {
- switch (CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls)) {
- case SOCKET_ERROR:
- case 0:// Time out
+ if (hConnection) {
+ ProtoBroadcastAck(m_szModuleName, pmraaqiAvatarsQueueItem->hContact, ACKTYPE_AVATAR, ACKRESULT_DATA, NULL, 0);
+ if (MraAvatarsHttpTransaction(hConnection, REQUEST_GET, lpszUser, lpszDomain, szServer, MAHTRO_AVT, bUseKeepAliveConn, &dwResultCode, &bKeepAlive, &dwAvatarFormat, &dwAvatarSizeServer, &itAvatarLastModifiedTimeServer) == NO_ERROR && dwResultCode == 200) {
+ if (bDefaultAvt)
+ dwAvatarFormat = PA_FORMAT_DEFAULT;
+
+ if ( !MraAvatarsGetFileName(pmraaqAvatarsQueue, pmraaqiAvatarsQueueItem->hContact, dwAvatarFormat, wszFileName, SIZEOF(wszFileName), NULL)) {
+ HANDLE hFile = CreateFile(wszFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ DWORD dwWritten = 0;
+ bContinue = TRUE;
+ nls.dwTimeout = (1000*DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "TimeOutReceive", MRA_AVT_DEFAULT_TIMEOUT_RECV));
+ nls.hReadConns[0] = hConnection;
+
+ while ( bContinue ) {
+ switch (CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls)) {
+ case SOCKET_ERROR:
+ case 0:// Time out
+ dwErrorCode = GetLastError();
+ ShowFormattedErrorMessage(L"Avatars: error on receive file data", dwErrorCode);
+ bContinue = FALSE;
+ break;
+ case 1:
+ dwReceived = Netlib_Recv(hConnection, (LPSTR)&btBuff, SIZEOF(btBuff), 0);
+ if (dwReceived == 0 || dwReceived == SOCKET_ERROR) {
dwErrorCode = GetLastError();
ShowFormattedErrorMessage(L"Avatars: error on receive file data", dwErrorCode);
bContinue = FALSE;
- break;
- case 1:
- dwReceived = Netlib_Recv(hConnection, (LPSTR)&btBuff, SIZEOF(btBuff), 0);
- if (dwReceived == 0 || dwReceived == SOCKET_ERROR) {
- dwErrorCode = GetLastError();
- ShowFormattedErrorMessage(L"Avatars: error on receive file data", dwErrorCode);
- bContinue = FALSE;
+ }
+ else {
+ if ( WriteFile( hFile, (LPVOID)&btBuff, dwReceived, &dwReceived, NULL)) {
+ dwWritten += dwReceived;
+ if (dwWritten >= dwAvatarSizeServer)
+ bContinue = FALSE;
}
else {
- if ( WriteFile( hFile, (LPVOID)&btBuff, dwReceived, &dwReceived, NULL)) {
- dwWritten += dwReceived;
- if (dwWritten >= dwAvatarSizeServer)
- bContinue = FALSE;
- }
- else {
- dwErrorCode = GetLastError();
- ShowFormattedErrorMessage(L"Avatars: cant write file data, error", dwErrorCode);
- bContinue = FALSE;
- }
+ dwErrorCode = GetLastError();
+ ShowFormattedErrorMessage(L"Avatars: cant write file data, error", dwErrorCode);
+ bContinue = FALSE;
}
- break;
}
+ break;
}
- CloseHandle(hFile);
- bFailed = FALSE;
- }
- else {
- dwErrorCode = GetLastError();
- mir_sntprintf(szErrorText, SIZEOF(szErrorText), TranslateW(L"Avatars: cant open file %s, error"), wszFileName);
- ShowFormattedErrorMessage(szErrorText, dwErrorCode);
}
+ CloseHandle(hFile);
+ bFailed = FALSE;
+ }
+ else {
+ dwErrorCode = GetLastError();
+ mir_sntprintf(szErrorText, SIZEOF(szErrorText), TranslateW(L"Avatars: cant open file %s, error"), wszFileName);
+ ShowFormattedErrorMessage(szErrorText, dwErrorCode);
}
}
- else DebugBreak();
-
- if (bUseKeepAliveConn == FALSE || bKeepAlive == FALSE) NETLIB_CLOSEHANDLE(hConnection);
}
+ else DebugBreak();
+
+ if (bUseKeepAliveConn == FALSE || bKeepAlive == FALSE) NETLIB_CLOSEHANDLE(hConnection);
}
}
+ }
}
if (bFailed) {
@@ -404,15 +384,9 @@ void CMraProto::MraAvatarsThreadProc(LPVOID lpParameter)
InterlockedDecrement((volatile LONG*)&pmraaqAvatarsQueue->lThreadsRunningCount);
}
-
HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPSTR lpszHost, DWORD dwPort)
{
- HANDLE hConnection;
- DWORD dwConnectReTryCount, dwCurConnectReTryCount;
NETLIBOPENCONNECTION nloc = {0};
-
- dwConnectReTryCount = DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "ConnectReTryCount", MRA_AVT_DEFAULT_CONN_RETRY_COUNT);
-
nloc.cbSize = sizeof(nloc);
nloc.flags = (NLOCF_HTTP|NLOCF_V2);
nloc.szHost = lpszHost;
@@ -421,17 +395,17 @@ HANDLE MraAvatarsHttpConnect(HANDLE hNetlibUser, LPSTR lpszHost, DWORD dwPort)
if (nloc.timeout<MRA_TIMEOUT_CONN_MIN) nloc.timeout = MRA_TIMEOUT_CONN_MIN;
if (nloc.timeout>MRA_TIMEOUT_CONN_МАХ) nloc.timeout = MRA_TIMEOUT_CONN_МАХ;
-
- dwCurConnectReTryCount = dwConnectReTryCount;
+ DWORD dwConnectReTryCount = DBGetContactSettingDword(NULL, MRA_AVT_SECT_NAME, "ConnectReTryCount", MRA_AVT_DEFAULT_CONN_RETRY_COUNT);
+ DWORD dwCurConnectReTryCount = dwConnectReTryCount;
+ HANDLE hConnection;
do {
hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
}
- while(--dwCurConnectReTryCount && hConnection == NULL);
+ while (--dwCurConnectReTryCount && hConnection == NULL);
- return(hConnection);
+ return hConnection;
}
-
DWORD MraAvatarsHttpTransaction(HANDLE hConnection, DWORD dwRequestType, LPSTR lpszUser, LPSTR lpszDomain, LPSTR lpszHost, DWORD dwReqObj, BOOL bUseKeepAliveConn, DWORD *pdwResultCode, BOOL *pbKeepAlive, DWORD *pdwFormat, size_t *pdwAvatarSize, INTERNET_TIME *pitLastModifiedTime)
{
if (pdwResultCode) *pdwResultCode = 0;
@@ -511,65 +485,53 @@ DWORD MraAvatarsHttpTransaction(HANDLE hConnection, DWORD dwRequestType, LPSTR l
BOOL CMraProto::MraAvatarsGetContactTime(HANDLE hContact, LPSTR lpszValueName, SYSTEMTIME *pstTime)
{
- BOOL bRet = FALSE;
-
- if (lpszValueName && pstTime)
- {
+ if (lpszValueName && pstTime) {
char szBuff[MAX_PATH];
size_t dwBuffSize;
INTERNET_TIME itAvatarLastModifiedTimeLocal;
if (mraGetStaticStringA(hContact, lpszValueName, (LPSTR)szBuff, SIZEOF(szBuff), &dwBuffSize))
- if (InternetTimeGetTime(szBuff, dwBuffSize, &itAvatarLastModifiedTimeLocal) == NO_ERROR)
- {
+ if (InternetTimeGetTime(szBuff, dwBuffSize, &itAvatarLastModifiedTimeLocal) == NO_ERROR) {
memmove(pstTime, &itAvatarLastModifiedTimeLocal.stTime, sizeof(SYSTEMTIME));
- bRet = TRUE;
+ return TRUE;
}
}
-return(bRet);
+ return FALSE;
}
void CMraProto::MraAvatarsSetContactTime(HANDLE hContact, LPSTR lpszValueName, SYSTEMTIME *pstTime)
{
- if (lpszValueName)
- {
- char szBuff[MAX_PATH];
- size_t dwBuffUsedSize;
- INTERNET_TIME itTime;
+ if (!lpszValueName)
+ return;
- if (pstTime)
- {
- itTime.lTimeZone = 0;
- memmove(&itTime.stTime, pstTime, sizeof(SYSTEMTIME));
- }else {
- InternetTimeGetCurrentTime(&itTime);
- }
+ char szBuff[MAX_PATH];
+ size_t dwBuffUsedSize;
+ INTERNET_TIME itTime;
- if (itTime.stTime.wYear)
- {
- InternetTimeGetString(&itTime, (LPSTR)szBuff, SIZEOF(szBuff), &dwBuffUsedSize);
- mraSetStringExA(hContact, lpszValueName, (LPSTR)szBuff, dwBuffUsedSize);
- }else {
- mraDelValue(hContact, lpszValueName);
- }
+ if (pstTime) {
+ itTime.lTimeZone = 0;
+ memmove(&itTime.stTime, pstTime, sizeof(SYSTEMTIME));
}
-}
+ else InternetTimeGetCurrentTime(&itTime);
+ if (itTime.stTime.wYear) {
+ InternetTimeGetString(&itTime, (LPSTR)szBuff, SIZEOF(szBuff), &dwBuffUsedSize);
+ mraSetStringExA(hContact, lpszValueName, (LPSTR)szBuff, dwBuffUsedSize);
+ }
+ else mraDelValue(hContact, lpszValueName);
+}
DWORD MraAvatarsGetFileFormat(LPTSTR lpszPath, size_t dwPathSize)
{
- DWORD dwRet = -1;
TCHAR dwExt[ 5 ];
-
BuffToLowerCase(&dwExt, lpszPath+(dwPathSize-4), 4);
- for ( DWORD i = 0; i < PA_FORMAT_MAX; i++ ) {
- if ( !_tcscmp( dwExt, lpcszExtensions[i])) {
- dwRet = i;
- break;
- }
- }
- return dwRet;
+
+ for ( DWORD i = 0; i < PA_FORMAT_MAX; i++ )
+ if ( !_tcscmp( dwExt, lpcszExtensions[i]))
+ return i;
+
+ return -1;
}
@@ -585,16 +547,16 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta
size_t dwEMailSize;
MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
- DWORD dwRetErrorCode = ERROR_INSUFFICIENT_BUFFER;
- if ( !bFoldersPresent ) {
+ if ( !bFoldersPresent ) {
// default path
- LPTSTR lpszPathToAvatarsCache = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- dwEMailSize = mir_sntprintf(lpszPath, dwPathSize, _T("%s\\%s\\"), lpszPathToAvatarsCache, m_tszUserName);
- mir_free(lpszPathToAvatarsCache);
+ mir_ptr<TCHAR> lpszPathToAvatarsCache( Utils_ReplaceVarsT( _T("%miranda_avatarcache%")));
+ dwEMailSize = mir_sntprintf(lpszPath, dwPathSize, _T("%s\\%s\\"), (TCHAR*)lpszPathToAvatarsCache, m_tszUserName);
}
else {
FoldersGetCustomPathT( pmraaqAvatarsQueue->hAvatarsPath, lpszCurPath, int(dwPathSize), _T(""));
dwEMailSize = lstrlen( lpszCurPath );
+ _tcscpy( lpszCurPath + dwEMailSize, _T("\\"));
+ dwEMailSize++;
}
dwPathSize -= dwEMailSize;
@@ -605,7 +567,7 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta
CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)lpszPath);
if (dwFormat != PA_FORMAT_DEFAULT) {
- if ( mraGetStaticStringW(hContact, "e-mail", lpszCurPath, (dwPathSize-5), &dwEMailSize)) {
+ if ( mraGetStaticStringW(hContact, "e-mail", lpszCurPath, dwPathSize-5, &dwEMailSize)) {
BuffToLowerCase(lpszCurPath, lpszCurPath, dwEMailSize);
lpszCurPath += dwEMailSize;
_tcscpy( lpszCurPath, lpcszExtensions[dwFormat] );
@@ -614,7 +576,7 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta
if ( pdwPathSizeRet )
*pdwPathSizeRet = lpszCurPath - lpszPath;
- dwRetErrorCode = NO_ERROR;
+ return NO_ERROR;
}
}
else {
@@ -624,12 +586,12 @@ DWORD CMraProto::MraAvatarsGetFileName(HANDLE hAvatarsQueueHandle, HANDLE hConta
if (pdwPathSizeRet)
*pdwPathSizeRet = lpszCurPath - lpszPath;
- dwRetErrorCode = NO_ERROR;
+ return NO_ERROR;
}
}
}
- return dwRetErrorCode;
+ return ERROR_INSUFFICIENT_BUFFER;
}
DWORD CMraProto::MraAvatarsQueueGetAvatar(HANDLE hAvatarsQueueHandle, DWORD dwFlags, HANDLE hContact, DWORD *pdwAvatarsQueueID, DWORD *pdwFormat, LPTSTR lpszPath)
@@ -638,15 +600,14 @@ DWORD CMraProto::MraAvatarsQueueGetAvatar(HANDLE hAvatarsQueueHandle, DWORD dwFl
if (hAvatarsQueueHandle)
if (db_get_b(NULL, MRA_AVT_SECT_NAME, "Enable", MRA_AVT_DEFAULT_ENABLE))
- if (IsContactChatAgent(hContact) == FALSE)
- {// not @chat.agent conference
+ if (IsContactChatAgent(hContact) == FALSE) {
+ // not @chat.agent conference
BOOL bQueueAdd = TRUE;// check for updates
MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = (MRA_AVATARS_QUEUE*)hAvatarsQueueHandle;
SYSTEMTIME stAvatarLastCheckTime;
- if ((dwFlags&GAIF_FORCE) == 0)// если флаг принудит. обновления, то даже не проверяем времени последнего обновления
- if (MraAvatarsGetContactTime(hContact, "AvatarLastCheckTime", &stAvatarLastCheckTime))
- {
+ if ((dwFlags & GAIF_FORCE) == 0)// если флаг принудит. обновления, то даже не проверяем времени последнего обновления
+ if (MraAvatarsGetContactTime(hContact, "AvatarLastCheckTime", &stAvatarLastCheckTime)) {
TCHAR wszFileName[MAX_FILEPATH];
size_t dwPathSize;
FILETIME ftCurrentTime, ftExpireTime;
@@ -665,25 +626,24 @@ DWORD CMraProto::MraAvatarsQueueGetAvatar(HANDLE hAvatarsQueueHandle, DWORD dwFl
else
CallService( MS_UTILS_PATHTORELATIVET, (WPARAM)wszFileName, (LPARAM)lpszPath );
}
- if (pdwFormat) (*pdwFormat) = GetContactAvatarFormat(hContact, PA_FORMAT_DEFAULT);
+ if (pdwFormat)
+ *pdwFormat = GetContactAvatarFormat(hContact, PA_FORMAT_DEFAULT);
dwRetCode = GAIR_SUCCESS;
bQueueAdd = FALSE;
}
}
- if (bQueueAdd || (dwFlags&GAIF_FORCE))
- if (MraAvatarsQueueAdd(hAvatarsQueueHandle, dwFlags, hContact, pdwAvatarsQueueID) == NO_ERROR)
- {
+ if (bQueueAdd || (dwFlags & GAIF_FORCE))
+ if ( !MraAvatarsQueueAdd(hAvatarsQueueHandle, dwFlags, hContact, pdwAvatarsQueueID)) {
MraAvatarsSetContactTime(hContact, "AvatarLastCheckTime", NULL);
dwRetCode = GAIR_WAITFOR;
}
}
-return(dwRetCode);
+ return dwRetCode;
}
-
DWORD CMraProto::MraAvatarsQueueGetAvatarSimple(HANDLE hAvatarsQueueHandle, DWORD dwFlags, HANDLE hContact, DWORD dwSourceID)
-{//***deb dwSourceID - for filtering cals from different places
+{
DWORD dwRetCode = GAIR_NOAVATAR;
PROTO_AVATAR_INFORMATIONT pai = {0};
@@ -696,17 +656,20 @@ DWORD CMraProto::MraAvatarsQueueGetAvatarSimple(HANDLE hAvatarsQueueHandle, DWOR
ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
}
- return(dwRetCode);
+ return dwRetCode;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Avatars options
+
WORD wMraAvatarsControlsList[] = {
- IDC_SERVER,
- IDC_SERVERPORT,
- IDC_BUTTON_DEFAULT,
- IDC_USE_KEEPALIVE_CONN,
- IDC_UPD_CHECK_INTERVAL,
- IDC_RETURN_ABC_PATH,
- IDC_DELETE_AVT_ON_CONTACT_DELETE
+ IDC_SERVER,
+ IDC_SERVERPORT,
+ IDC_BUTTON_DEFAULT,
+ IDC_USE_KEEPALIVE_CONN,
+ IDC_UPD_CHECK_INTERVAL,
+ IDC_RETURN_ABC_PATH,
+ IDC_DELETE_AVT_ON_CONTACT_DELETE
};
INT_PTR CALLBACK MraAvatarsQueueDlgProcOpts(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -790,5 +753,3 @@ DWORD CMraProto::MraAvatarsDeleteContactAvatarFile(HANDLE hAvatarsQueueHandle, H
}
return NO_ERROR;
}
-
-
diff --git a/protocols/MRA/MraFilesQueue.cpp b/protocols/MRA/MraFilesQueue.cpp
index 28a8979037..a5a3660c53 100644
--- a/protocols/MRA/MraFilesQueue.cpp
+++ b/protocols/MRA/MraFilesQueue.cpp
@@ -166,7 +166,7 @@ void MraFilesQueueDestroy(HANDLE hFilesQueueHandle)
MRA_FILES_QUEUE_ITEM *dat;
ListMTLock(pmrafqFilesQueue);
- while( ListMTItemGetFirst(pmrafqFilesQueue, NULL, (LPVOID*)&dat) == NO_ERROR)
+ while ( ListMTItemGetFirst(pmrafqFilesQueue, NULL, (LPVOID*)&dat) == NO_ERROR)
MraFilesQueueItemFree(dat);
ListMTUnLock(pmrafqFilesQueue);
@@ -197,7 +197,7 @@ DWORD MraFilesQueueItemFindByID(HANDLE hFilesQueueHandle, DWORD dwIDRequest, MRA
break;
}
}
- while(ListMTIteratorMoveNext(&lmtiIterator));
+ while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(pmrafqFilesQueue);
return dwRetErrorCode;
}
@@ -256,7 +256,7 @@ size_t CMraProto::MraFilesQueueGetLocalAddressesList(LPSTR lpszBuff, size_t dwBu
if (gethostname(szHostName, SIZEOF(szHostName)) == 0)
if ((sh = gethostbyname((LPSTR)&szHostName))) {
- while(sh->h_addr_list[dwAdapter]) {
+ while (sh->h_addr_list[dwAdapter]) {
lpszCurPos += mir_snprintf(lpszCurPos, (dwBuffSize-((size_t)lpszCurPos-(size_t)lpszBuff)), "%s:%lu;", inet_ntoa(*((struct in_addr*)sh->h_addr_list[dwAdapter])), dwPort);
dwAdapter++;
}
@@ -389,7 +389,7 @@ DWORD MraFilesQueueFree(HANDLE hFilesQueueHandle, DWORD dwIDRequest)
break;
}
}
- while(ListMTIteratorMoveNext(&lmtiIterator));
+ while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(pmrafqFilesQueue);
return dwRetErrorCode;
}
@@ -513,7 +513,7 @@ HANDLE CMraProto::MraFilesQueueConnectOut(MRA_FILES_QUEUE_ITEM *dat)
do {
dat->hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
}
- while(--dwCurConnectReTryCount && dat->hConnection == NULL);
+ while (--dwCurConnectReTryCount && dat->hConnection == NULL);
if (dat->hConnection) {
ProtoBroadcastAck(m_szModuleName, dat->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)dat->dwIDRequest, 0);
@@ -694,7 +694,7 @@ DWORD CMraProto::MraFilesQueueAddReceive(HANDLE hFilesQueueHandle, DWORD dwFlags
dat->dwFilesTotalSize = 0;
dat->pmfqfFiles = (MRA_FILES_QUEUE_FILE*)mir_calloc((sizeof(MRA_FILES_QUEUE_FILE)*dwAllocatedCount));
lpwszCurrentItem = lpwszFiles;
- while(TRUE) {
+ while (TRUE) {
lpwszDelimiter = (LPWSTR)MemoryFind(((size_t)lpwszCurrentItem-(size_t)lpwszFiles), lpwszFiles, (dwFilesSize*sizeof(WCHAR)), ";", 2);
if (!lpwszDelimiter)
break;
@@ -887,7 +887,7 @@ void CMraProto::MraFilesQueueRecvThreadProc(LPVOID lpParameter)
nls.hReadConns[0] = dat->hConnection;
ProtoBroadcastAck(m_szModuleName, dat->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)dat->dwIDRequest, (LPARAM)&pfts);
- while(bContinue)
+ while (bContinue)
{
switch (CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls)) {
case SOCKET_ERROR:
@@ -1094,7 +1094,7 @@ void CMraProto::MraFilesQueueSendThreadProc(LPVOID lpParameter)
ProtoBroadcastAck(m_szModuleName, dat->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, (HANDLE)dat->dwIDRequest, 0);
dwBuffSizeUsed = 0;
- while(TRUE) {
+ while (TRUE) {
dwReceived = Netlib_Recv(dat->hConnection, ((LPSTR)btBuff+dwBuffSizeUsed), (SIZEOF(btBuff)-dwBuffSizeUsed), 0);
if (dwReceived == 0 || dwReceived == SOCKET_ERROR) { // err on receive file name to send
dwRetErrorCode = GetLastError();
@@ -1141,7 +1141,7 @@ void CMraProto::MraFilesQueueSendThreadProc(LPVOID lpParameter)
WideCharToMultiByte(MRA_CODE_PAGE, 0, dat->pmfqfFiles[j].lpwszName, dat->pmfqfFiles[j].dwNameLen, szFileName, SIZEOF(szFileName), NULL, NULL);
ProtoBroadcastAck(m_szModuleName, dat->hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)dat->dwIDRequest, (LPARAM)&pfts);
- while(TRUE) { // read and sending
+ while (TRUE) { // read and sending
if (ReadFile(hFile, btBuff, dwSendBlockSize, (DWORD*)&dwBuffSizeUsed, NULL)) {
dwReceived = Netlib_Send(dat->hConnection, (LPSTR)btBuff, dwBuffSizeUsed, 0);
if (dwBuffSizeUsed == dwReceived) {
diff --git a/protocols/MRA/MraMPop.cpp b/protocols/MRA/MraMPop.cpp
index 55bc9dda4e..ec49686f5e 100644
--- a/protocols/MRA/MraMPop.cpp
+++ b/protocols/MRA/MraMPop.cpp
@@ -43,7 +43,7 @@ void MraMPopSessionQueueClear(HANDLE hMPopSessionQueue)
pmpsqMPopSessionQueue->dwMPOPKeySize = 0;
MRA_MPOP_SESSION_QUEUE_ITEM *pmpsqi;
- while( !FifoMTItemPop(pmpsqMPopSessionQueue, NULL, (LPVOID*)&pmpsqi))
+ while ( !FifoMTItemPop(pmpsqMPopSessionQueue, NULL, (LPVOID*)&pmpsqi))
mir_free(pmpsqi);
}
}
@@ -52,7 +52,7 @@ void CMraProto::MraMPopSessionQueueFlush(HANDLE hMPopSessionQueue)
{
if (hMPopSessionQueue) {
MRA_MPOP_SESSION_QUEUE *pmpsqMPopSessionQueue = (MRA_MPOP_SESSION_QUEUE*)hMPopSessionQueue;
- while( FifoMTGetCount(pmpsqMPopSessionQueue)) {
+ while ( FifoMTGetCount(pmpsqMPopSessionQueue)) {
MraMPopSessionQueueSetNewMPopKey(hMPopSessionQueue, NULL, 0);
MraMPopSessionQueueStart(hMPopSessionQueue);
}
diff --git a/protocols/MRA/MraMRIMProxy.cpp b/protocols/MRA/MraMRIMProxy.cpp
index d0690141a4..01a46ecc49 100644
--- a/protocols/MRA/MraMRIMProxy.cpp
+++ b/protocols/MRA/MraMRIMProxy.cpp
@@ -132,7 +132,7 @@ DWORD CMraProto::MraMrimProxyConnect(HANDLE hMraMrimProxyData, HANDLE *phConnect
do {
pmmpd->hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
}
- while(--dwCurConnectReTryCount && pmmpd->hConnection == NULL);
+ while (--dwCurConnectReTryCount && pmmpd->hConnection == NULL);
if (pmmpd->hConnection) {
nls.cbSize = sizeof(nls);
@@ -145,7 +145,7 @@ DWORD CMraProto::MraMrimProxyConnect(HANDLE hMraMrimProxyData, HANDLE *phConnect
ProtoBroadcastAck(m_szModuleName, MraHContactFromEmail(pmmpd->lpszEMail, pmmpd->dwEMailSize, FALSE, TRUE, NULL), ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)pmmpd->dwIDRequest, 0);
MraSendPacket(nls.hReadConns[0], 0, MRIM_CS_PROXY_HELLO, &pmmpd->mguidSessionID, sizeof(MRA_GUID));
- while(bContinue) {
+ while (bContinue) {
switch (CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls)) {
case SOCKET_ERROR:
case 0:// Time out
diff --git a/protocols/MRA/MraOfflineMsg.cpp b/protocols/MRA/MraOfflineMsg.cpp
index abf7bf45d2..868b23dcc6 100644
--- a/protocols/MRA/MraOfflineMsg.cpp
+++ b/protocols/MRA/MraOfflineMsg.cpp
@@ -107,7 +107,7 @@ DWORD MraOfflineMessageGet(MRA_LPS *plpsMsg, DWORD *pdwTime, DWORD *pdwFlags, MR
i = 0;
lpszCurMIMEPos = lpszBody;
- while(MraOfflineMessageGetNextMIMEPart(lpszBody, dwBodySize, lpszBoundary, dwBoundarySize, &lpszCurMIMEPos, &lpszMIMEPart, &dwMIMEPartSize) == NO_ERROR)
+ while (MraOfflineMessageGetNextMIMEPart(lpszBody, dwBodySize, lpszBoundary, dwBoundarySize, &lpszCurMIMEPos, &lpszMIMEPart, &dwMIMEPartSize) == NO_ERROR)
{
if (MraOfflineMessageGetMIMEHeadAndBody(lpszMIMEPart, dwMIMEPartSize, &lpszMIMEHeader, &dwMIMEHeaderSize, &lpszMIMEBody, &dwMIMEBodySize) == NO_ERROR)
{
diff --git a/protocols/MRA/MraRTFMsg.cpp b/protocols/MRA/MraRTFMsg.cpp
index 02e3a371e4..0e6e76f4ce 100644
--- a/protocols/MRA/MraRTFMsg.cpp
+++ b/protocols/MRA/MraRTFMsg.cpp
@@ -153,7 +153,7 @@ DWORD MraSymbolsToRTFTags(DWORD dwFlags, LPSTR lpszMessage, size_t dwMessageSize
if (lpszFounded[i]) dwFoundCount++;
}
- while(dwFoundCount) {
+ while (dwFoundCount) {
for (i = 0;i<SYMBOLS_COUNT;i++)
if (lpszFounded[i] && (lpszFounded[i]<lpszFounded[dwFirstFoundIndex] || lpszFounded[dwFirstFoundIndex] == NULL))
dwFirstFoundIndex = i;
diff --git a/protocols/MRA/MraSendQueue.cpp b/protocols/MRA/MraSendQueue.cpp
index a4f0891ccb..7482e86863 100644
--- a/protocols/MRA/MraSendQueue.cpp
+++ b/protocols/MRA/MraSendQueue.cpp
@@ -67,7 +67,7 @@ void MraSendQueueDestroy(HANDLE hSendQueueHandle)
MRA_SEND_QUEUE_ITEM *pmrasqiSendQueueItem;
ListMTLock(&pmrasqSendQueue->lmtListMT);
- while(ListMTItemGetFirst(&pmrasqSendQueue->lmtListMT, NULL, (LPVOID*)&pmrasqiSendQueueItem) == NO_ERROR)
+ while (ListMTItemGetFirst(&pmrasqSendQueue->lmtListMT, NULL, (LPVOID*)&pmrasqiSendQueueItem) == NO_ERROR)
{
ListMTItemDelete(&pmrasqSendQueue->lmtListMT, &pmrasqiSendQueueItem->lmtListMTItem);
//mir_free(pmrasqiSendQueueItem->lpbData);
@@ -140,7 +140,7 @@ DWORD MraSendQueueFree(HANDLE hSendQueueHandle, DWORD dwCMDNum)
dwRetErrorCode = NO_ERROR;
break;
}
- }while(ListMTIteratorMoveNext(&lmtiIterator));
+ }while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(&pmrasqSendQueue->lmtListMT);
}else {
dwRetErrorCode = ERROR_INVALID_HANDLE;
@@ -175,7 +175,7 @@ DWORD MraSendQueueFind(HANDLE hSendQueueHandle, DWORD dwCMDNum, DWORD *pdwFlags,
dwRetErrorCode = NO_ERROR;
break;
}
- }while(ListMTIteratorMoveNext(&lmtiIterator));
+ }while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(&pmrasqSendQueue->lmtListMT);
}else {
dwRetErrorCode = ERROR_INVALID_HANDLE;
@@ -214,7 +214,7 @@ DWORD MraSendQueueFindOlderThan(HANDLE hSendQueueHandle, DWORD dwTime, DWORD *pd
dwRetErrorCode = NO_ERROR;
break;
}
- }while(ListMTIteratorMoveNext(&lmtiIterator));
+ }while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(&pmrasqSendQueue->lmtListMT);
}else {
dwRetErrorCode = ERROR_INVALID_HANDLE;
diff --git a/protocols/MRA/Mra_functions.cpp b/protocols/MRA/Mra_functions.cpp
index 45ee8b9a2d..28799c574e 100644
--- a/protocols/MRA/Mra_functions.cpp
+++ b/protocols/MRA/Mra_functions.cpp
@@ -141,7 +141,7 @@ DWORD MraAddrListGetFromBuff(LPSTR lpszAddreses, size_t dwAddresesSize, MRA_ADDR
pmalAddrList->pmaliAddress = (MRA_ADDR_LIST_ITEM*)mir_calloc(sizeof(MRA_ADDR_LIST_ITEM)*dwAllocatedCount);
lpszCurrentItem = lpszAddreses;
- while(TRUE) {
+ while (TRUE) {
lpszEndItem = (LPSTR)MemoryFindByte((lpszCurrentItem-lpszAddreses), lpszAddreses, dwAddresesSize, ';');
if (lpszEndItem == NULL) lpszEndItem = (lpszAddreses+dwAddresesSize);
if (!lpszEndItem)
@@ -532,7 +532,7 @@ DWORD CMraProto::SetContactBasicInfoW(HANDLE hContact, DWORD dwSetInfoFlags, DWO
i = 0;
lpszCurPhone = lpszPhones;
lpszPhoneNext = lpszPhones;
- while(lpszPhoneNext) {
+ while (lpszPhoneNext) {
lpszPhoneNext = (LPSTR)MemoryFindByte((lpszCurPhone-lpszPhones), lpszPhones, dwPhonesSize, ',');
if (lpszPhoneNext)
dwCurPhoneSize = lpszPhoneNext - lpszCurPhone;
@@ -1097,7 +1097,7 @@ void MraAPCQueueProcess(PFIFO_MT pffmtAPCQueue)
LPVOID lpData;
MRA_APC_QUEUE_ITEM *pqiApcQueueItem;
- while(FifoMTItemPop(pffmtAPCQueue, (PFIFO_MT_ITEM*)&pqiApcQueueItem, &lpData) == NO_ERROR) {
+ while (FifoMTItemPop(pffmtAPCQueue, (PFIFO_MT_ITEM*)&pqiApcQueueItem, &lpData) == NO_ERROR) {
SleepEx(10, FALSE);
pqiApcQueueItem->pfnAPC((ULONG_PTR)lpData);
mir_free(pqiApcQueueItem);
@@ -1113,7 +1113,7 @@ void CMraProto::MraAPCQueueDestroy(PFIFO_MT pffmtAPCQueue)
FifoMTLock(pffmtAPCQueue);
- while( FifoMTItemPop(pffmtAPCQueue, &pffmtiFifoItem, &lpData) == NO_ERROR) {
+ while ( FifoMTItemPop(pffmtAPCQueue, &pffmtiFifoItem, &lpData) == NO_ERROR) {
mir_free(lpData);
mir_free(pffmtiFifoItem);
}
@@ -1190,7 +1190,7 @@ void CMraProto::MraUserAPCThreadProc(LPVOID lpParameter)
dwNextCheckTime = 0;
dwFailCounter = 0;
- while( InterlockedExchangeAdd((volatile LONG*)&dwAPCThreadRunning, 0)) {
+ while ( InterlockedExchangeAdd((volatile LONG*)&dwAPCThreadRunning, 0)) {
MraAPCQueueProcess(&ffmtAPCQueue);
if (hThreadWorker)
@@ -1661,7 +1661,7 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DWORD
do {
dwPathLen-=prdsiItems[dwRecDeepCurPos].dwFileNameLen;
- while(dwRetErrorCode == ERROR_FILE_NOT_FOUND && FindNextFile(prdsiItems[dwRecDeepCurPos].hFind, &prdsiItems[dwRecDeepCurPos].w32fdFindFileData)) {
+ while (dwRetErrorCode == ERROR_FILE_NOT_FOUND && FindNextFile(prdsiItems[dwRecDeepCurPos].hFind, &prdsiItems[dwRecDeepCurPos].w32fdFindFileData)) {
if (prdsiItems[dwRecDeepCurPos].w32fdFindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {// folder
if (CompareString( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, -1, L".", 1) != CSTR_EQUAL)
if (CompareString( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, prdsiItems[dwRecDeepCurPos].w32fdFindFileData.cFileName, -1, L"..", 2) != CSTR_EQUAL) {
@@ -1703,7 +1703,7 @@ DWORD FindFile(LPWSTR lpszFolder, DWORD dwFolderLen, LPWSTR lpszFileName, DWORD
if (prdsiItems) FindClose(prdsiItems[dwRecDeepCurPos].hFind);
dwRecDeepCurPos--;
}
- while(dwRecDeepCurPos != -1);
+ while (dwRecDeepCurPos != -1);
}
mir_free(prdsiItems);
}
@@ -1897,7 +1897,7 @@ DWORD ReplaceInBuff(LPVOID lpInBuff, size_t dwInBuffSize, size_t dwReplaceItemsC
dwFoundCount++;
}
- while(dwFoundCount) {
+ while (dwFoundCount) {
for (i = 0; i < dwReplaceItemsCount; i++)
if (plpbtFounded[i] && (plpbtFounded[i] < plpbtFounded[dwFirstFoundIndex] || plpbtFounded[dwFirstFoundIndex] == NULL))
dwFirstFoundIndex = i;
diff --git a/protocols/MRA/Mra_proto.cpp b/protocols/MRA/Mra_proto.cpp
index 710672d458..6abb2fbd3e 100644
--- a/protocols/MRA/Mra_proto.cpp
+++ b/protocols/MRA/Mra_proto.cpp
@@ -70,7 +70,7 @@ void CMraProto::MraThreadProc(LPVOID lpParameter)
InterlockedExchange((volatile LONG*)&dwThreadWorkerLastPingTime, GetTickCount());
hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
}
- while(--dwCurConnectReTryCount && hConnection == NULL);
+ while (--dwCurConnectReTryCount && hConnection == NULL);
if (hConnection)
bConnected = TRUE;
@@ -93,7 +93,7 @@ void CMraProto::MraThreadProc(LPVOID lpParameter)
InterlockedExchange((volatile LONG*)&dwThreadWorkerLastPingTime, GetTickCount());
hConnection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
}
- while(--dwCurConnectReTryCount && hConnection == NULL);
+ while (--dwCurConnectReTryCount && hConnection == NULL);
if (hConnection) {
bConnected = TRUE;
@@ -163,7 +163,7 @@ DWORD CMraProto::MraGetNLBData(LPSTR lpszHost, size_t dwHostBuffSize, WORD *pwPo
InterlockedExchange((volatile LONG*)&dwThreadWorkerLastPingTime, GetTickCount());
nls.hReadConns[0] = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&nloc);
}
- while(--dwCurConnectReTryCount && nls.hReadConns[0] == NULL);
+ while (--dwCurConnectReTryCount && nls.hReadConns[0] == NULL);
if (nls.hReadConns[0]) {
nls.cbSize = sizeof(nls);
@@ -236,7 +236,7 @@ DWORD CMraProto::MraNetworkDispatcher()
dwCMDNum = 0;
MraSendCMD(MRIM_CS_HELLO, NULL, 0);
InterlockedExchange((volatile LONG*)&dwThreadWorkerLastPingTime, GetTickCount());
- while(m_iStatus != ID_STATUS_OFFLINE && bContinue)
+ while (m_iStatus != ID_STATUS_OFFLINE && bContinue)
{
dwSelectRet = CallService(MS_NETLIB_SELECT, 0, (LPARAM)&nls);
switch (dwSelectRet) {
@@ -299,7 +299,7 @@ DWORD CMraProto::MraNetworkDispatcher()
if (dwBytesReceived && dwBytesReceived != SOCKET_ERROR) {
dwRcvBuffSizeUsed += dwBytesReceived;
- while(TRUE) {
+ while (TRUE) {
dwDataCurrentBuffSize = (dwRcvBuffSize-dwDataCurrentBuffOffset);
dwDataCurrentBuffSizeUsed = (dwRcvBuffSizeUsed-dwDataCurrentBuffOffset);
pmaHeader = (mrim_packet_header_t*)(lpbBufferRcv+dwDataCurrentBuffOffset);
@@ -2039,7 +2039,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, MRA_LPS *pl
pre.lParam = WideCharToMultiByte(MRA_CODE_PAGE, 0, lpwszMessage, dwMessageSize, (LPSTR)lpbBuffer, (dwMessageSize+MAX_PATH), NULL, NULL);
lpbBufferCurPos = lpbBuffer;
- while(TRUE) { // цикл замены ; на 0
+ while (TRUE) { // цикл замены ; на 0
lpbBufferCurPos = (LPBYTE)MemoryFindByte((lpbBufferCurPos-lpbBuffer), lpbBuffer, pre.lParam, ';');
if (!lpbBufferCurPos)
break;