summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/MRA/src/MraPopUp.cpp64
-rw-r--r--protocols/MRA/src/MraProto.cpp8
-rw-r--r--protocols/MRA/src/MraProto.h2
-rw-r--r--protocols/MRA/src/Mra_proto.cpp46
4 files changed, 38 insertions, 82 deletions
diff --git a/protocols/MRA/src/MraPopUp.cpp b/protocols/MRA/src/MraPopUp.cpp
index 5d70971e06..d0f219200d 100644
--- a/protocols/MRA/src/MraPopUp.cpp
+++ b/protocols/MRA/src/MraPopUp.cpp
@@ -152,20 +152,6 @@ struct MraPopupData
int iPopupType;
};
-void CALLBACK MraPopupThreadMarandaCallback(ULONG_PTR dwParam)
-{
- if (dwParam == 0)
- return;
-
- MraPopupData *dat = (MraPopupData*)((POPUPDATAW*)dwParam)->PluginData;
- if (dat->iPopupType == MRA_POPUP_TYPE_EMAIL_STATUS && dat->ppro->hWndEMailPopupStatus)
- PUChangeTextW(dat->ppro->hWndEMailPopupStatus, ((POPUPDATAW*)dwParam)->lpwzText);
- else
- PUAddPopupW((POPUPDATAW*)dwParam);
-
- mir_free((void*)dwParam);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
// Popup plugin window proc
@@ -226,19 +212,15 @@ void CMraProto::MraPopupShowFromContactW(HANDLE hContact, DWORD dwType, DWORD dw
MraPopupShowW(hContact, dwType, dwFlags, szTitle, lpszMessage);
}
-
void CMraProto::MraPopupShowW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWSTR lpszTitle, LPCWSTR lpszMessage)
{
if (getByte("PopupsEnabled", MRA_DEFAULT_POPUPS_ENABLED))
if (GetBit(getDword("PopupsEventFilter", MRA_DEFAULT_POPUPS_EVENT_FILTER), dwType))
if ( ServiceExists(MS_POPUP_ADDPOPUPW)) {
- BOOL bUseWinColors;
- char szBuff[MAX_PATH];
- POPUPDATAT *ppd = (POPUPDATAT*)mir_calloc(sizeof(POPUPDATAT));
+ POPUPDATAT ppd = { 0 };
- //if ( ServiceExists(MS_POPUP2_SHOW) == FALSE)// yapp used
+ // delete old email popup
if (dwType == MRA_POPUP_TYPE_EMAIL_STATUS && hWndEMailPopupStatus) {
- // delete old email popup
PUDeletePopup(hWndEMailPopupStatus);
hWndEMailPopupStatus = NULL;
}
@@ -246,25 +228,25 @@ void CMraProto::MraPopupShowW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWS
// load icon
switch (dwType) {
case MRA_POPUP_TYPE_NONE:// proto icon
- ppd->lchIcon = g_hMainIcon;
+ ppd.lchIcon = g_hMainIcon;
break;
case MRA_POPUP_TYPE_DEBUG:// IDI_APPLICATION
- ppd->lchIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(NULL, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_SHARED);
break;
case MRA_POPUP_TYPE_INFORMATION:// IDI_INFORMATION
- ppd->lchIcon = (HICON)LoadImage(NULL, IDI_INFORMATION, IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(NULL, IDI_INFORMATION, IMAGE_ICON, 0, 0, LR_SHARED);
break;
case MRA_POPUP_TYPE_QUESTION:// IDI_QUESTION
- ppd->lchIcon = (HICON)LoadImage(NULL, IDI_QUESTION, IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(NULL, IDI_QUESTION, IMAGE_ICON, 0, 0, LR_SHARED);
break;
case MRA_POPUP_TYPE_WARNING:// IDI_WARNING
- ppd->lchIcon = (HICON)LoadImage(NULL, IDI_WARNING, IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(NULL, IDI_WARNING, IMAGE_ICON, 0, 0, LR_SHARED);
break;
case MRA_POPUP_TYPE_ERROR:// IDI_ERROR
- ppd->lchIcon = (HICON)LoadImage(NULL, IDI_ERROR, IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(NULL, IDI_ERROR, IMAGE_ICON, 0, 0, LR_SHARED);
break;
case MRA_POPUP_TYPE_EMAIL_STATUS:
- ppd->lchIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_MAIL_NOTIFY), IMAGE_ICON, 0, 0, LR_SHARED);
+ ppd.lchIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_MAIL_NOTIFY), IMAGE_ICON, 0, 0, LR_SHARED);
break;
}
@@ -272,32 +254,36 @@ void CMraProto::MraPopupShowW(HANDLE hContact, DWORD dwType, DWORD dwFlags, LPWS
dat->iPopupType = dwType;
dat->ppro = this;
- ppd->lchContact = hContact;
+ ppd.lchContact = hContact;
if (lpszTitle)
- lstrcpyn(ppd->lptzContactName, lpszTitle, MAX_CONTACTNAME);
+ lstrcpyn(ppd.lptzContactName, lpszTitle, MAX_CONTACTNAME);
if (lpszMessage)
- lstrcpyn(ppd->lptzText, lpszMessage, MAX_SECONDLINE);
- ppd->PluginWindowProc = MraPopupDlgProc;
- ppd->PluginData = dat;
+ lstrcpyn(ppd.lptzText, lpszMessage, MAX_SECONDLINE);
+ ppd.PluginWindowProc = MraPopupDlgProc;
+ ppd.PluginData = dat;
+ char szBuff[MAX_PATH];
mir_snprintf(szBuff, SIZEOF(szBuff), "PopupType%SUseWinColors", lpcwszPopupsTypes[dwType]);
- bUseWinColors = getByte(szBuff, MRA_DEFAULT_POPUP_USE_WIN_COLORS);
+ BOOL bUseWinColors = getByte(szBuff, MRA_DEFAULT_POPUP_USE_WIN_COLORS);
if (bUseWinColors) {
- ppd->colorBack = GetSysColor(COLOR_BTNFACE);
- ppd->colorText = GetSysColor(COLOR_WINDOWTEXT);
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
}
else {
mir_snprintf(szBuff, SIZEOF(szBuff), "PopupType%SColorBack", lpcwszPopupsTypes[dwType]);
- ppd->colorBack = getDword(szBuff, MRA_DEFAULT_POPUP_COLOR_BACK);
+ ppd.colorBack = getDword(szBuff, MRA_DEFAULT_POPUP_COLOR_BACK);
mir_snprintf(szBuff, SIZEOF(szBuff), "PopupType%SColorText", lpcwszPopupsTypes[dwType]);
- ppd->colorText = getDword(szBuff, MRA_DEFAULT_POPUP_COLOR_TEXT);
+ ppd.colorText = getDword(szBuff, MRA_DEFAULT_POPUP_COLOR_TEXT);
}
mir_snprintf(szBuff, SIZEOF(szBuff), "PopupType%STimeout", lpcwszPopupsTypes[dwType]);
- ppd->iSeconds = getDword(szBuff, MRA_DEFAULT_POPUP_TIMEOUT);
+ ppd.iSeconds = getDword(szBuff, MRA_DEFAULT_POPUP_TIMEOUT);
- MraPopupThreadMarandaCallback((ULONG_PTR)ppd);
+ if (dat->iPopupType == MRA_POPUP_TYPE_EMAIL_STATUS && dat->ppro->hWndEMailPopupStatus)
+ PUChangeTextW(dat->ppro->hWndEMailPopupStatus, ppd.lpwzText);
+ else
+ PUAddPopupW(&ppd);
}
else if (dwFlags & MRA_POPUP_ALLOW_MSGBOX)
MessageBox(NULL, lpszMessage, lpszTitle, MB_OK+(dwType == MRA_POPUP_TYPE_WARNING)?MB_ICONERROR:MB_ICONINFORMATION);
diff --git a/protocols/MRA/src/MraProto.cpp b/protocols/MRA/src/MraProto.cpp
index 753ba4a466..79349466bf 100644
--- a/protocols/MRA/src/MraProto.cpp
+++ b/protocols/MRA/src/MraProto.cpp
@@ -124,14 +124,6 @@ int CMraProto::OnPreShutdown(WPARAM, LPARAM)
{
SetStatus(ID_STATUS_OFFLINE);
MraAvatarsQueueDestroy(hAvatarsQueueHandle); hAvatarsQueueHandle = NULL;
-
- if (m_hThreadWorker) {
- if (IsThreadAlive(m_hThreadWorker))
- WaitForSingleObjectEx(m_hThreadWorker, (WAIT_FOR_THREAD_TIMEOUT*1000), FALSE);
- CloseHandle(m_hThreadWorker);
- m_hThreadWorker = NULL;
- }
-
return 0;
}
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h
index 791a15bc6d..8ed9b1696b 100644
--- a/protocols/MRA/src/MraProto.h
+++ b/protocols/MRA/src/MraProto.h
@@ -173,7 +173,6 @@ struct CMraProto : public PROTO<CMraProto>
HANDLE hSendQueueHandle, hFilesQueueHandle, hMPopSessionQueue;
HANDLE m_heNudgeReceived;
- HANDLE m_hThreadWorker;
HANDLE m_hConnection;
DWORD m_dwThreadWorkerLastPingTime, m_dwNextPingSendTickTime, m_dwPingPeriod;
DWORD m_dwThreadWorkerRunning;
@@ -251,7 +250,6 @@ struct CMraProto : public PROTO<CMraProto>
void MraUpdateEmailStatus(const CMStringA &szFrom, const CMStringA &szSubject, DWORD dwDate, DWORD dwUIDL);
DWORD MraConvertToRTFW(const CMStringW &wszMessage, CMStringA &szMessageRTF);
- void MraThreadClean();
DWORD StartConnect();
void __cdecl MraThreadProc(LPVOID lpParameter);
DWORD MraGetNLBData(CMStringA &szHost, WORD *pwPort);
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index abbbf9b687..554e284e0a 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -9,30 +9,21 @@ DWORD CMraProto::StartConnect()
return ERROR_OPERATION_ABORTED;
// поток ещё/уже не работал, поставили статус что работает и запускаем
- if (InterlockedCompareExchange((volatile LONG*)&m_dwThreadWorkerRunning, TRUE, FALSE) == FALSE) {
- CMStringA szEmail;
- mraGetStringA(NULL, "e-mail", szEmail);
+ if (InterlockedCompareExchange((volatile LONG*)&m_dwThreadWorkerRunning, TRUE, FALSE))
+ return 0;
- CMStringA szPass;
- if (szEmail.GetLength() > 5 && GetPassDB(szPass)) {
- InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
- m_hThreadWorker = ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0);
- if (m_hThreadWorker == NULL) {
- DWORD dwRetErrorCode = GetLastError();
- InterlockedExchange((volatile LONG*)&m_dwThreadWorkerRunning, FALSE);
- SetStatus(ID_STATUS_OFFLINE);
- return dwRetErrorCode;
- }
- }
- else {
- MraThreadClean();
- if (szEmail.GetLength() <= 5)
- MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup e-mail in options"));
- else
- MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup password in options"));
- }
- }
+ CMStringA szEmail;
+ mraGetStringA(NULL, "e-mail", szEmail);
+ CMStringA szPass;
+ if (szEmail.GetLength() <= 5)
+ MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup e-mail in options"));
+ else if (!GetPassDB(szPass))
+ MraPopupShowFromAgentW(MRA_POPUP_TYPE_WARNING, 0, TranslateT("Please, setup password in options"));
+ else {
+ InterlockedExchange((volatile LONG*)&m_dwThreadWorkerLastPingTime, GetTickCount());
+ ForkThreadEx(&CMraProto::MraThreadProc, NULL, 0);
+ }
return 0;
}
@@ -104,22 +95,11 @@ void CMraProto::MraThreadProc(LPVOID lpParameter)
}
}
- MraThreadClean();
-}
-
-void CMraProto::MraThreadClean()
-{
MraMPopSessionQueueFlush(hMPopSessionQueue);
Netlib_CloseHandle(m_hConnection);// called twice, if user set offline, its normal
m_hConnection = NULL;
dwCMDNum = 0;
- SleepEx(100, FALSE);// to prevent high CPU load by some status plugins like allwaysonline
-
- if (m_hThreadWorker) {
- CloseHandle(m_hThreadWorker);
- m_hThreadWorker = NULL;
- }
InterlockedExchange((volatile LONG*)&m_dwThreadWorkerRunning, FALSE);
SetStatus(ID_STATUS_OFFLINE);
}