diff options
author | George Hazan <george.hazan@gmail.com> | 2013-03-11 15:11:36 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-03-11 15:11:36 +0000 |
commit | 6aeafa47b02b966067d3ff83453c9ae8f9b0fc70 (patch) | |
tree | 30a31a165c2712d6af297cf4819fc5787f5344d7 | |
parent | 1ba746b6a4c979841a3b3452347da0aa78964f95 (diff) |
only a few real mir_forkthreadex survived
git-svn-id: http://svn.miranda-ng.org/main/trunk@3977 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_commonprototypes.h | 12 | ||||
-rw-r--r-- | plugins/Clist_modern/src/hdr/modern_static_clui.h | 14 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_awaymsg.cpp | 47 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clui.cpp | 48 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_gettextasync.cpp | 26 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 6 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/contact.cpp | 43 | ||||
-rw-r--r-- | plugins/SeenPlugin/src/utils.cpp | 40 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 212 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.h | 63 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 12 | ||||
-rw-r--r-- | plugins/TabSRMM/src/trayicon.cpp | 6 | ||||
-rw-r--r-- | plugins/TipperYM/src/message_pump.cpp | 4 | ||||
-rw-r--r-- | protocols/GTalkExt/src/inbox.cpp | 26 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/libgadu/pthread.c | 1 | ||||
-rw-r--r-- | src/modules/netlib/netlibautoproxy.cpp | 26 | ||||
-rw-r--r-- | src/modules/netlib/netlibbind.cpp | 10 |
18 files changed, 259 insertions, 343 deletions
diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h index 69516c1d5d..8e71682180 100644 --- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h @@ -67,7 +67,8 @@ extern BOOL g_bTransparentFlag; extern HINSTANCE g_hInst;
extern HIMAGELIST hCListImages;
extern BOOL g_mutex_bChangingMode;
-extern UINT g_dwMainThreadID, g_dwAwayMsgThreadID, g_dwGetTextAsyncThreadID, g_dwSmoothAnimationThreadID;
+extern UINT g_dwMainThreadID;
+extern HANDLE g_hAwayMsgThread, g_hGetTextAsyncThread, g_hSmoothAnimationThread;
extern HWND g_hwndViewModeFrame;
extern HANDLE hSmileyAddOptionsChangedHook,hAvatarChanged,hIconChangedHook;
extern BYTE gl_TrimText;
@@ -76,6 +77,15 @@ extern BYTE gl_TrimText; /* TYPE DEFS */
/************************************************************************/
+class thread_catcher
+{
+ HANDLE &m_ptr;
+
+public:
+ __forceinline thread_catcher(HANDLE ¶m) : m_ptr(param) {}
+ __forceinline ~thread_catcher() { m_ptr = 0; }
+};
+
typedef INT_PTR (*PSYNCCALLBACKPROC)(WPARAM,LPARAM);
/************************************************************************/
diff --git a/plugins/Clist_modern/src/hdr/modern_static_clui.h b/plugins/Clist_modern/src/hdr/modern_static_clui.h index 22925fc4d2..fb15b1e25a 100644 --- a/plugins/Clist_modern/src/hdr/modern_static_clui.h +++ b/plugins/Clist_modern/src/hdr/modern_static_clui.h @@ -41,9 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TM_WINDOWUPDATE 100 #define TM_STATUSBARUPDATE 200 - - - #define MS_CLUI_SHOWMAINMENU "CList/ShowMainMenu" #define MS_CLUI_SHOWSTATUSMENU "CList/ShowStatusMenu" @@ -98,17 +95,10 @@ void RowHeight_InitModernRow(); int UnhookAll(); - -/* External variables */ - - /* Global variables */ - -UINT g_dwMainThreadID = 0, - g_dwAwayMsgThreadID = 0, - g_dwGetTextAsyncThreadID = 0, - g_dwSmoothAnimationThreadID = 0; +UINT g_dwMainThreadID = 0; +HANDLE g_hAwayMsgThread = 0, g_hGetTextAsyncThread = 0, g_hSmoothAnimationThread = 0; HMENU g_hMenuMain; BOOL g_bTransparentFlag=FALSE; diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index 4c6241c18e..09506e02cc 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -115,29 +115,27 @@ static HANDLE amGetCurrentChain() /*
* Tread sub to ask protocol to retrieve away message
*/
-static unsigned __stdcall amThreadProc(void *)
+static void amThreadProc(void *)
{
- DWORD time;
- HANDLE hContact;
- HANDLE ACK = 0;
+ thread_catcher lck(g_hAwayMsgThread);
+
ClcCacheEntry dnce;
- memset( &dnce, 0, sizeof(dnce));
+ memset(&dnce, 0, sizeof(dnce));
- while (!MirandaExiting())
- {
- hContact = amGetCurrentChain();
+ while (!MirandaExiting()) {
+ HANDLE hContact = amGetCurrentChain();
while (hContact) {
- time = GetTickCount();
+ DWORD time = GetTickCount();
if ((time-amRequestTick) < AMASKPERIOD) {
SleepEx(AMASKPERIOD-(time-amRequestTick)+10, TRUE);
- if (MirandaExiting()) {
- g_dwAwayMsgThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ return;
}
CListSettings_FreeCacheItemData(&dnce);
dnce.hContact = (HANDLE)hContact;
- Sync(CLUI_SyncGetPDNCE, (WPARAM) 0, (LPARAM)&dnce);
+ Sync(CLUI_SyncGetPDNCE, (WPARAM) 0, (LPARAM)&dnce);
+
+ HANDLE ACK = 0;
if (dnce.ApparentMode != ID_STATUS_OFFLINE) //don't ask if contact is always invisible (should be done with protocol)
ACK = (HANDLE)CallContactService(hContact,PSS_GETAWAYMSG, 0, 0);
if ( !ACK) {
@@ -163,26 +161,19 @@ static unsigned __stdcall amThreadProc(void *) while (i < AMASKPERIOD/50 && !MirandaExiting());
}
else break;
- if (MirandaExiting()) {
- g_dwAwayMsgThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ return;
}
WaitForSingleObjectEx(hamProcessEvent, INFINITE, TRUE);
ResetEvent(hamProcessEvent);
- if (MirandaExiting())
- {
- g_dwAwayMsgThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ break;
}
- g_dwAwayMsgThreadID = 0;
- return 1;
}
BOOL amWakeThread()
{
- if (hamProcessEvent && g_dwAwayMsgThreadID) {
+ if (hamProcessEvent && g_hAwayMsgThread) {
SetEvent(hamProcessEvent);
return TRUE;
}
@@ -209,14 +200,14 @@ void InitAwayMsgModule() {
InitializeCriticalSection(&amLockChain);
hamProcessEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
- mir_forkthreadex(amThreadProc, 0, &g_dwAwayMsgThreadID);
+ g_hAwayMsgThread = mir_forkthread(amThreadProc, 0);
}
void UninitAwayMsgModule()
{
SetEvent(hamProcessEvent);
- while (g_dwAwayMsgThreadID)
+ while (g_hAwayMsgThread)
SleepEx(50, TRUE);
CloseHandle(hamProcessEvent);
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index cb072264db..a457d7f17f 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -514,16 +514,16 @@ static BOOL CLUI_WaitThreadsCompletion(HWND hwnd) if (bEntersCount < bcMAX_AWAITING_RETRY &&
( g_mutex_nCalcRowHeightLock ||
g_CluiData.mutexPaintLock ||
- g_dwAwayMsgThreadID ||
- g_dwGetTextAsyncThreadID ||
- g_dwSmoothAnimationThreadID) && !Miranda_Terminated())
+ g_hAwayMsgThread ||
+ g_hGetTextAsyncThread ||
+ g_hSmoothAnimationThread) && !Miranda_Terminated())
{
TRACE("Waiting threads");
TRACEVAR("g_mutex_nCalcRowHeightLock: %x",g_mutex_nCalcRowHeightLock);
TRACEVAR("g_CluiData.mutexPaintLock: %x",g_CluiData.mutexPaintLock);
- TRACEVAR("g_dwAwayMsgThreadID: %x",g_dwAwayMsgThreadID);
- TRACEVAR("g_dwGetTextAsyncThreadID: %x",g_dwGetTextAsyncThreadID);
- TRACEVAR("g_dwSmoothAnimationThreadID: %x",g_dwSmoothAnimationThreadID);
+ TRACEVAR("g_hAwayMsgThread: %x",g_hAwayMsgThread);
+ TRACEVAR("g_hGetTextAsyncThread: %x",g_hGetTextAsyncThread);
+ TRACEVAR("g_hSmoothAnimationThread: %x",g_hSmoothAnimationThread);
bEntersCount++;
SleepEx(10, TRUE);
@@ -1451,31 +1451,25 @@ static int CLUI_SyncSmoothAnimation(WPARAM wParam, LPARAM lParam) return CLUI_SmoothAlphaThreadTransition((HWND)lParam);
}
-static unsigned __stdcall CLUI_SmoothAnimationThreadProc(void *param)
+static void CLUI_SmoothAnimationThreadProc(void *param)
{
- if ( !mutex_bAnimationInProgress) {
- g_dwSmoothAnimationThreadID = 0;
- return 0; /// Should be some locked to avoid painting against contact deletion.
- }
+ thread_catcher lck(g_hSmoothAnimationThread);
- do {
- if ( !g_mutex_bLockUpdating) {
- if ( !MirandaExiting())
- Sync(CLUI_SyncSmoothAnimation, 0, (LPARAM)param);
+ if (mutex_bAnimationInProgress) {
+ do {
+ if ( !g_mutex_bLockUpdating) {
+ if ( MirandaExiting())
+ return;
- SleepEx(20, TRUE);
- if (MirandaExiting()) {
- g_dwSmoothAnimationThreadID = 0;
- return 0;
+ Sync(CLUI_SyncSmoothAnimation, 0, (LPARAM)param);
+ SleepEx(20, TRUE);
+ if ( MirandaExiting())
+ return;
}
+ else SleepEx(0, TRUE);
}
- else SleepEx(0, TRUE);
-
+ while (mutex_bAnimationInProgress);
}
- while (mutex_bAnimationInProgress);
-
- g_dwSmoothAnimationThreadID = 0;
- return 0;
}
static int CLUI_SmoothAlphaThreadTransition(HWND hwnd)
@@ -1563,10 +1557,10 @@ int CLUI_SmoothAlphaTransition(HWND hwnd, BYTE GoalAlpha, BOOL wParam) g_CluiData.bCurrentAlpha = 1;
ske_UpdateWindowImage();
}
- if (IsWindowVisible(hwnd) && !g_dwSmoothAnimationThreadID) {
+ if (IsWindowVisible(hwnd) && !g_hSmoothAnimationThread) {
mutex_bAnimationInProgress = 1;
if (g_CluiData.fSmoothAnimation)
- mir_forkthreadex(CLUI_SmoothAnimationThreadProc, pcli->hwndContactList, &g_dwSmoothAnimationThreadID);
+ g_hSmoothAnimationThread = mir_forkthread(CLUI_SmoothAnimationThreadProc, pcli->hwndContactList);
}
}
}
diff --git a/plugins/Clist_modern/src/modern_gettextasync.cpp b/plugins/Clist_modern/src/modern_gettextasync.cpp index 1244e8b49c..4c4bbe5b89 100644 --- a/plugins/Clist_modern/src/modern_gettextasync.cpp +++ b/plugins/Clist_modern/src/modern_gettextasync.cpp @@ -76,18 +76,18 @@ static BOOL gtaGetItem(GTACHAINITEM * mpChain) return FALSE;
}
-static unsigned __stdcall gtaThreadProc(void * lpParam)
+static void gtaThreadProc(void *lpParam)
{
+ thread_catcher lck(g_hGetTextAsyncThread);
HWND hwnd = pcli->hwndContactList;
- struct SHORTDATA data = {0};
+ SHORTDATA data = {0};
while (!MirandaExiting()) {
Sync(CLUI_SyncGetShortData,(WPARAM)pcli->hwndContactTree,(LPARAM)&data);
while (true) {
- if (MirandaExiting()) {
- g_dwGetTextAsyncThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ return;
+
SleepEx(0, TRUE); //1000 contacts per second
GTACHAINITEM mpChain = {0};
@@ -102,10 +102,8 @@ static unsigned __stdcall gtaThreadProc(void * lpParam) Sync(CLUI_SyncGetShortData,(WPARAM)mpChain.dat->hWnd,(LPARAM)&dat2);
dat = &dat2;
}
- if ( MirandaExiting()) {
- g_dwGetTextAsyncThreadID = 0;
- return 0;
- }
+ if ( MirandaExiting())
+ return;
ClcCacheEntry cacheEntry;
memset(&cacheEntry, 0, sizeof(cacheEntry));
@@ -124,13 +122,11 @@ static unsigned __stdcall gtaThreadProc(void * lpParam) WaitForSingleObjectEx(hgtaWakeupEvent, INFINITE, TRUE);
ResetEvent(hgtaWakeupEvent);
}
- g_dwGetTextAsyncThreadID = 0;
- return 1;
}
BOOL gtaWakeThread()
{
- if (hgtaWakeupEvent && g_dwGetTextAsyncThreadID) {
+ if (hgtaWakeupEvent && g_hGetTextAsyncThread) {
SetEvent(hgtaWakeupEvent);
return TRUE;
}
@@ -178,14 +174,14 @@ void InitCacheAsync() {
InitializeCriticalSection(>aCS);
hgtaWakeupEvent = CreateEvent(NULL,FALSE,FALSE,NULL);
- mir_forkthreadex(gtaThreadProc, 0, &g_dwGetTextAsyncThreadID);
+ g_hGetTextAsyncThread = mir_forkthread(gtaThreadProc, 0);
HookEvent(ME_SYSTEM_PRESHUTDOWN, gtaOnModulesUnload);
}
void UninitCacheAsync()
{
SetEvent(hgtaWakeupEvent);
- while(g_dwGetTextAsyncThreadID)
+ while(g_hGetTextAsyncThread)
SleepEx(50, TRUE);
CloseHandle(hgtaWakeupEvent);
diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index e15a91409b..c63cd319d7 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -30,9 +30,10 @@ HFONT __fastcall ChangeToFont(HDC hdc, struct ClcData *dat, int id, int *fontHei extern HWND g_hwndViewModeFrame, g_hwndEventArea;
extern int mf_updatethread_running;
-extern DWORD WINAPI MF_UpdateThread(LPVOID p);
extern HANDLE hThreadMFUpdate;;
+void MF_UpdateThread(LPVOID);
+
HANDLE hStatusBarShowToolTipEvent, hStatusBarHideToolTipEvent;
HANDLE g_hEventThread = 0;
@@ -3280,7 +3281,7 @@ static int CLUIFrameOnModulesLoad(WPARAM wParam, LPARAM lParam) {
mir_sntprintf(g_ptszEventName, SIZEOF(g_ptszEventName), _T("mf_update_evt_%d"), GetCurrentThreadId());
g_hEventThread = CreateEvent(NULL, TRUE, FALSE, g_ptszEventName);
- hThreadMFUpdate = (HANDLE)mir_forkthreadex(reinterpret_cast<pThreadFuncEx>(MF_UpdateThread), NULL, NULL);
+ hThreadMFUpdate = mir_forkthread(MF_UpdateThread, NULL);
SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_IDLE);
CLUIFramesLoadMainMenu();
CLUIFramesCreateMenuForFrame(-1, -1, 000010000, Menu_AddContextFrameMenuItem);
@@ -3294,7 +3295,6 @@ static int CLUIFrameOnModulesUnload(WPARAM wParam, LPARAM lParam) SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_NORMAL);
SetEvent(g_hEventThread);
WaitForSingleObject(hThreadMFUpdate, 2000);
- CloseHandle(hThreadMFUpdate);
CloseHandle(g_hEventThread);
CallService(MS_CLIST_REMOVECONTEXTFRAMEMENUITEM, (LPARAM)contMIVisible, 0);
diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index d4a0188164..672c10b3bb 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -114,29 +114,28 @@ static void MF_CalcFrequency(HANDLE hContact, DWORD dwCutoffDays, int doSleep) extern TCHAR g_ptszEventName[];
-DWORD WINAPI MF_UpdateThread(LPVOID p)
+void MF_UpdateThread(LPVOID)
{
- HANDLE hContact;
- HANDLE hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, g_ptszEventName);
-
- WaitForSingleObject(hEvent, 20000);
- ResetEvent(hEvent);
-
- while(mf_updatethread_running) {
- hContact = db_find_first();
- while (hContact != NULL && mf_updatethread_running) {
- MF_CalcFrequency(hContact, 50, 1);
- if (mf_updatethread_running)
- WaitForSingleObject(hEvent, 5000);
- ResetEvent(hEvent);
- hContact = db_find_next(hContact);
- }
- if (mf_updatethread_running)
- WaitForSingleObject(hEvent, 1000000);
- ResetEvent(hEvent);
- }
- CloseHandle(hEvent);
- return 0;
+ HANDLE hContact;
+ HANDLE hEvent = OpenEvent(EVENT_ALL_ACCESS, FALSE, g_ptszEventName);
+
+ WaitForSingleObject(hEvent, 20000);
+ ResetEvent(hEvent);
+
+ while(mf_updatethread_running) {
+ hContact = db_find_first();
+ while (hContact != NULL && mf_updatethread_running) {
+ MF_CalcFrequency(hContact, 50, 1);
+ if (mf_updatethread_running)
+ WaitForSingleObject(hEvent, 5000);
+ ResetEvent(hEvent);
+ hContact = db_find_next(hContact);
+ }
+ if (mf_updatethread_running)
+ WaitForSingleObject(hEvent, 1000000);
+ ResetEvent(hEvent);
+ }
+ CloseHandle(hEvent);
}
static BOOL mc_hgh_removed = FALSE;
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index 5783d1f53b..0fc11a7c90 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -563,8 +563,10 @@ int addContactToQueue(HANDLE hContact){ return i;
}
-static DWORD __stdcall waitThread(logthread_info* infoParam)
+static void waitThread(void *param)
{
+ logthread_info* infoParam = (logthread_info*)param;
+
WORD prevStatus = db_get_w(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
Sleep(1500); // I hope in 1.5 second all the needed info will be set
if (includeIdle)
@@ -581,11 +583,8 @@ static DWORD __stdcall waitThread(logthread_info* infoParam) contactQueue[infoParam->queueIndex] = 0;
free(infoParam);
- return 0;
}
-
-
int UpdateValues(WPARAM wparam,LPARAM lparam)
{
// to make this code faster
@@ -664,9 +663,7 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) if (!(index = isContactQueueActive((HANDLE)wparam))) {
index = addContactToQueue((HANDLE)wparam);
strncpy(contactQueue[index]->sProtoName,cws->szModule,MAXMODULELABELLENGTH);
-
- unsigned int dwThreadId;
- mir_forkthreadex((pThreadFuncEx)waitThread, contactQueue[index], &dwThreadId);
+ mir_forkthread(waitThread, contactQueue[index]);
}
contactQueue[index]->courStatus = isIdleEvent ? db_get_w((HANDLE)wparam, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal;
} }
@@ -674,8 +671,10 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) return 0;
}
-static DWORD __stdcall cleanThread(logthread_info* infoParam)
+static void cleanThread(void *param)
{
+ logthread_info* infoParam = (logthread_info*)param;
+
Sleep(10000); // I hope in 10 secons all logged-in contacts will be listed
HANDLE hcontact = db_find_first();
@@ -700,12 +699,9 @@ static DWORD __stdcall cleanThread(logthread_info* infoParam) mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",infoParam->sProtoName);
db_unset(NULL,S_MOD,str);
free(str);
-
free(infoParam);
- return 0;
}
-
int ModeChange(WPARAM wparam,LPARAM lparam)
{
ACKDATA *ack=(ACKDATA *)lparam;
@@ -713,10 +709,7 @@ int ModeChange(WPARAM wparam,LPARAM lparam) if (ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0;
courProtoName = (char *)ack->szModule;
if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName,"MetaContacts",12))
- {
- //MessageBox(NULL,"Protocol not watched",courProtoName,0);
return 0;
- }
DBWriteTimeTS(time(NULL),NULL);
@@ -732,10 +725,10 @@ int ModeChange(WPARAM wparam,LPARAM lparam) info->hContact = 0;
info->courStatus = 0;
- unsigned int dwThreadId;
- CloseHandle( mir_forkthreadex((pThreadFuncEx)cleanThread, info, &dwThreadId));
+ mir_forkthread(cleanThread, info);
}
- } else if ((isetting==ID_STATUS_OFFLINE)&&((WORD)ack->hProcess>ID_STATUS_OFFLINE)) {
+ }
+ else if ((isetting==ID_STATUS_OFFLINE)&&((WORD)ack->hProcess>ID_STATUS_OFFLINE)) {
//we have just loged-off
if (IsWatchedProtocol(ack->szModule)) {
char *str = (char *)malloc(MAXMODULELABELLENGTH+9);
@@ -744,19 +737,18 @@ int ModeChange(WPARAM wparam,LPARAM lparam) mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",ack->szModule);
db_set_dw(NULL,S_MOD,str,t);
free(str);
- } }
- if (isetting==db_get_w(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0;
+ }
+ }
+
+ if (isetting==db_get_w(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE))
+ return 0;
+
db_set_w(NULL,S_MOD,courProtoName,isetting);
- // log "myself"
if ( db_get_b(NULL,S_MOD,"FileOutput",0))
FileWrite(NULL);
-// if (isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline
-// SetOffline();
-
courProtoName = NULL;
-
return 0;
}
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index ed591ba6d1..37756aecbe 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -2664,9 +2664,9 @@ LABEL_SHOWWINDOW: }
break;
- case GC_SCROLLTOBOTTOM: {
- return(DM_ScrollToBottom(dat, wParam, lParam));
- }
+ case GC_SCROLLTOBOTTOM:
+ DM_ScrollToBottom(dat, wParam, lParam);
+ return 0;
case WM_TIMER:
if (wParam == TIMERID_FLASHWND)
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index e8654cfacb..182bfc68ab 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1087,47 +1087,47 @@ void TSAPI DM_SetDBButtonStates(HWND hwndChild, struct TWindowData *dat) }
}
-LRESULT TSAPI DM_ScrollToBottom(TWindowData *dat, WPARAM wParam, LPARAM lParam)
+void TSAPI DM_ScrollToBottom(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
- if (dat) {
+ if (dat == NULL)
+ return;
- if (dat->dwFlagsEx & MWF_SHOW_SCROLLINGDISABLED)
- return 0;
+ if (dat->dwFlagsEx & MWF_SHOW_SCROLLINGDISABLED)
+ return;
- if (IsIconic(dat->pContainer->hwnd))
- dat->dwFlags |= MWF_DEFERREDSCROLL;
+ if ( IsIconic(dat->pContainer->hwnd))
+ dat->dwFlags |= MWF_DEFERREDSCROLL;
- if (dat->hwndIEView) {
- PostMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
- return 0;
- } else if (dat->hwndHPP) {
- SendMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
- return 0;
- } else {
- HWND hwnd = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_LOG : IDC_CHAT_LOG);
- if (lParam)
- SendMessage(hwnd, WM_SIZE, 0, 0);
+ if (dat->hwndIEView) {
+ PostMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
+ return;
+ }
+ if (dat->hwndHPP) {
+ SendMessage(dat->hwnd, DM_SCROLLIEVIEW, 0, 0);
+ return;
+ }
- if (wParam == 1 && lParam == 1) {
- RECT rc;
- int len;
+ HWND hwnd = GetDlgItem(dat->hwnd, dat->bType == SESSIONTYPE_IM ? IDC_LOG : IDC_CHAT_LOG);
+ if (lParam)
+ SendMessage(hwnd, WM_SIZE, 0, 0);
- GetClientRect(hwnd, &rc);
- len = GetWindowTextLengthA(hwnd);
- SendMessage(hwnd, EM_SETSEL, len - 1, len - 1);
- }
- if (wParam)
- SendMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- else
- PostMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- if (lParam)
- InvalidateRect(hwnd, NULL, FALSE);
- }
+ if (wParam == 1 && lParam == 1) {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ int len = GetWindowTextLengthA(hwnd);
+ SendMessage(hwnd, EM_SETSEL, len - 1, len - 1);
}
- return 0;
+
+ if (wParam)
+ SendMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+ else
+ PostMessage(hwnd, WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+
+ if (lParam)
+ InvalidateRect(hwnd, NULL, FALSE);
}
-static unsigned __stdcall LoadKLThread(LPVOID vParam)
+static void LoadKLThread(LPVOID vParam)
{
HANDLE hContact = reinterpret_cast<HANDLE>(vParam);
DBVARIANT dbv = {0};
@@ -1138,54 +1138,34 @@ static unsigned __stdcall LoadKLThread(LPVOID vParam) PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_SETLOCALE, (WPARAM)hContact, (LPARAM)hkl);
DBFreeVariant(&dbv);
}
- return 0;
}
-
-LRESULT TSAPI DM_LoadLocale(TWindowData *dat)
+void TSAPI DM_LoadLocale(TWindowData *dat)
{
- /*
- * set locale if saved to contact
- */
- if (dat) {
- if (dat->dwFlags & MWF_WASBACKGROUNDCREATE)
- return 0;
-
- if (PluginConfig.m_AutoLocaleSupport) {
- DBVARIANT dbv;
- int res;
- TCHAR szKLName[KL_NAMELENGTH+1];
- UINT flags = KLF_ACTIVATE;
+ if (dat == NULL || !PluginConfig.m_AutoLocaleSupport)
+ return;
- res = DBGetContactSettingTString(dat->hContact, SRMSGMOD_T, "locale", &dbv);
- if (res == 0) {
+ if (dat->dwFlags & MWF_WASBACKGROUNDCREATE)
+ return;
- /*
- dat->hkl = LoadKeyboardLayout(dbv.ptszVal, KLF_REPLACELANG | KLF_NOTELLSHELL);
- GetLocaleID(dat, dbv.ptszVal);
- PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0);*/
- DBFreeVariant(&dbv);
- CloseHandle((HANDLE)mir_forkthreadex(LoadKLThread, dat->hContact, NULL));
- } else {
- if (!PluginConfig.m_dontUseDefaultKbd) {
- TCHAR szBuf[20];
-
- GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, szBuf, 20);
- mir_sntprintf(szKLName, KL_NAMELENGTH, _T("0000%s"), szBuf);
- M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
- }
- else {
- GetKeyboardLayoutName(szKLName);
- M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
- }
- /*dat->hkl = LoadKeyboardLayout(szKLName, KLF_NOTELLSHELL | KLF_REPLACELANG);
- GetLocaleID(dat, szKLName);
- PostMessage(dat->hwnd, DM_SETLOCALE, 0, 0);*/
- CloseHandle((HANDLE)mir_forkthreadex(LoadKLThread, reinterpret_cast<void *>(dat->hContact), NULL));
- }
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString(dat->hContact, SRMSGMOD_T, "locale", &dbv))
+ DBFreeVariant(&dbv);
+ else {
+ TCHAR szKLName[KL_NAMELENGTH+1];
+ if (!PluginConfig.m_dontUseDefaultKbd) {
+ TCHAR szBuf[20];
+ GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, szBuf, 20);
+ mir_sntprintf(szKLName, KL_NAMELENGTH, _T("0000%s"), szBuf);
+ M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
+ }
+ else {
+ GetKeyboardLayoutName(szKLName);
+ M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
}
}
- return 0;
+
+ mir_forkthread(LoadKLThread, dat->hContact);
}
LRESULT TSAPI DM_RecalcPictureSize(TWindowData *dat)
@@ -1207,68 +1187,58 @@ LRESULT TSAPI DM_RecalcPictureSize(TWindowData *dat) return 0;
}
-LRESULT TSAPI DM_UpdateLastMessage(const TWindowData *dat)
+void TSAPI DM_UpdateLastMessage(const TWindowData *dat)
{
- if (dat) {
- if (dat->pContainer->hwndStatus == 0)
- return 0;
- if (dat->pContainer->hwndActive != dat->hwnd)
- return 0;
- if (dat->showTyping) {
- TCHAR szBuf[80];
+ if (dat == NULL)
+ return;
- mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("%s is typing a message."), dat->cache->getNick());
- SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM) szBuf);
- SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, (LPARAM) PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
- return 0;
- }
- else
- SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, 0);
+ if (dat->pContainer->hwndStatus == 0 || dat->pContainer->hwndActive != dat->hwnd)
+ return;
- if (dat->lastMessage || dat->pContainer->dwFlags & CNT_UINSTATUSBAR) {
- TCHAR date[64], time[64];
+ TCHAR szBuf[100];
+ if (dat->showTyping) {
+ SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, (LPARAM) PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]);
+ mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("%s is typing a message."), dat->cache->getNick());
+ }
+ else {
+ SendMessage(dat->pContainer->hwndStatus, SB_SETICON, 0, 0);
- if (!(dat->pContainer->dwFlags & CNT_UINSTATUSBAR)) {
- tmi.printTimeStamp(NULL, dat->lastMessage, _T("d"), date, SIZEOF(date), 0);
- if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR && lstrlen(date) > 6)
- date[lstrlen(date) - 5] = 0;
- tmi.printTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0);
- }
- if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR) {
- TCHAR fmt[100];
- mir_sntprintf(fmt, SIZEOF(fmt), _T("UID: %s"), dat->cache->getUIN());
- SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)fmt);
- } else {
- TCHAR fmt[100];
- mir_sntprintf(fmt, SIZEOF(fmt), TranslateT("Last received: %s at %s"), date, time);
- SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM) fmt);
- }
- } else
- SendMessageA(dat->pContainer->hwndStatus, SB_SETTEXTA, 0, (LPARAM) "");
+ if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR)
+ mir_sntprintf(szBuf, SIZEOF(szBuf), _T("UID: %s"), dat->cache->getUIN());
+ else if (dat->lastMessage) {
+ TCHAR date[64], time[64];
+ tmi.printTimeStamp(NULL, dat->lastMessage, _T("d"), date, SIZEOF(date), 0);
+ if (dat->pContainer->dwFlags & CNT_UINSTATUSBAR && lstrlen(date) > 6)
+ date[lstrlen(date) - 5] = 0;
+ tmi.printTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0);
+ mir_sntprintf(szBuf, SIZEOF(szBuf), TranslateT("Last received: %s at %s"), date, time);
+ }
+ else szBuf[0] = 0;
}
- return 0;
+
+ SendMessage(dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szBuf);
}
/*
* save current keyboard layout for the given contact
*/
-LRESULT TSAPI DM_SaveLocale(TWindowData *dat, WPARAM wParam, LPARAM lParam)
+void TSAPI DM_SaveLocale(TWindowData *dat, WPARAM wParam, LPARAM lParam)
{
- if (dat) {
- if (PluginConfig.m_AutoLocaleSupport && dat->hContact && dat->pContainer->hwndActive == dat->hwnd) {
- TCHAR szKLName[KL_NAMELENGTH + 1];
- if ((HKL)lParam != dat->hkl) {
- dat->hkl = (HKL)lParam;
- ActivateKeyboardLayout(dat->hkl, 0);
- GetKeyboardLayoutName(szKLName);
- M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
- GetLocaleID(dat, szKLName);
- UpdateReadChars(dat);
- }
+ if (!dat)
+ return;
+
+ if (PluginConfig.m_AutoLocaleSupport && dat->hContact && dat->pContainer->hwndActive == dat->hwnd) {
+ TCHAR szKLName[KL_NAMELENGTH + 1];
+ if ((HKL)lParam != dat->hkl) {
+ dat->hkl = (HKL)lParam;
+ ActivateKeyboardLayout(dat->hkl, 0);
+ GetKeyboardLayoutName(szKLName);
+ M->WriteTString(dat->hContact, SRMSGMOD_T, "locale", szKLName);
+ GetLocaleID(dat, szKLName);
+ UpdateReadChars(dat);
}
}
- return 0;
}
/*
diff --git a/plugins/TabSRMM/src/generic_msghandlers.h b/plugins/TabSRMM/src/generic_msghandlers.h index 4916a90c06..a355d0538d 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.h +++ b/plugins/TabSRMM/src/generic_msghandlers.h @@ -30,36 +30,37 @@ *
*/
-void TSAPI DM_SetDBButtonStates (HWND hwndChild, struct TWindowData *dat);
-int TSAPI BTN_GetStockItem (ButtonItem *item, const TCHAR *szName);
-HWND TSAPI DM_CreateClist (TWindowData *dat);
+void TSAPI DM_SetDBButtonStates(HWND hwndChild, struct TWindowData *dat);
+int TSAPI BTN_GetStockItem (ButtonItem *item, const TCHAR *szName);
+HWND TSAPI DM_CreateClist(TWindowData *dat);
-void TSAPI DM_OptionsApplied (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-void TSAPI DM_UpdateTitle (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_ScrollToBottom (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_LoadLocale (TWindowData *dat);
-LRESULT TSAPI DM_SaveLocale (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_UpdateLastMessage (const TWindowData *dat);
-LRESULT __stdcall DM_RecalcPictureSize (TWindowData *dat);
-LRESULT TSAPI DM_WMCopyHandler (HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_MouseWheelHandler (HWND hwnd, HWND hwndParent, struct TWindowData *mwdat, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_ThemeChanged (TWindowData *dat);
-void TSAPI DM_Typing (TWindowData *dat, bool fForceOff = false);
-void TSAPI DM_FreeTheme (TWindowData *dat);
-void TSAPI DM_NotifyTyping (TWindowData *dat, int mode);
-int TSAPI DM_SplitterGlobalEvent (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-void TSAPI BB_InitDlgButtons (TWindowData *dat);
+void TSAPI DM_OptionsApplied(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_UpdateTitle(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_ScrollToBottom(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_LoadLocale(TWindowData *dat);
+void TSAPI DM_SaveLocale(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_UpdateLastMessage(const TWindowData *dat);
+LRESULT TSAPI DM_WMCopyHandler(HWND hwnd, WNDPROC oldWndProc, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_MouseWheelHandler(HWND hwnd, HWND hwndParent, struct TWindowData *mwdat, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_ThemeChanged(TWindowData *dat);
+void TSAPI DM_Typing(TWindowData *dat, bool fForceOff = false);
+void TSAPI DM_FreeTheme(TWindowData *dat);
+void TSAPI DM_NotifyTyping(TWindowData *dat, int mode);
+int TSAPI DM_SplitterGlobalEvent(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI BB_InitDlgButtons(TWindowData *dat);
-BOOL TSAPI BB_SetButtonsPos (TWindowData *dat);
-void TSAPI BB_RedrawButtons (TWindowData *dat);
-void TSAPI BB_CustomButtonClick (TWindowData *dat,DWORD idFrom ,HWND hwndFrom, BOOL code) ;
-void TSAPI DM_EventAdded (TWindowData *dat, WPARAM wParam, LPARAM lParam);
-void TSAPI DM_InitRichEdit (TWindowData *dat);
-LRESULT TSAPI DM_ContainerCmdHandler (TContainerData *pContainer, UINT cmd, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_MsgWindowCmdHandler (HWND hwndDlg, TContainerData *pContainer, TWindowData *dat, UINT cmd, WPARAM wParam, LPARAM lParam);
-LRESULT TSAPI DM_GenericHotkeysCheck (MSG *message, TWindowData *dat);
-void TSAPI DM_DismissTip (TWindowData *dat, const POINT& pt);
-void TSAPI DM_InitTip (TWindowData *dat);
-void TSAPI DM_HandleAutoSizeRequest(TWindowData *dat, REQRESIZE* rr);
-void TSAPI DM_SaveLogAsRTF (const TWindowData* dat);
-void TSAPI DM_CheckAutoHide (const TWindowData* dat, WPARAM wParam, LPARAM lParam);
+BOOL TSAPI BB_SetButtonsPos(TWindowData *dat);
+void TSAPI BB_RedrawButtons(TWindowData *dat);
+void TSAPI BB_CustomButtonClick(TWindowData *dat,DWORD idFrom ,HWND hwndFrom, BOOL code) ;
+void TSAPI DM_EventAdded(TWindowData *dat, WPARAM wParam, LPARAM lParam);
+void TSAPI DM_InitRichEdit(TWindowData *dat);
+LRESULT TSAPI DM_ContainerCmdHandler(TContainerData *pContainer, UINT cmd, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_MsgWindowCmdHandler(HWND hwndDlg, TContainerData *pContainer, TWindowData *dat, UINT cmd, WPARAM wParam, LPARAM lParam);
+LRESULT TSAPI DM_GenericHotkeysCheck(MSG *message, TWindowData *dat);
+void TSAPI DM_DismissTip(TWindowData *dat, const POINT& pt);
+void TSAPI DM_InitTip(TWindowData *dat);
+void TSAPI DM_HandleAutoSizeRequest(TWindowData *dat, REQRESIZE* rr);
+void TSAPI DM_SaveLogAsRTF(const TWindowData* dat);
+void TSAPI DM_CheckAutoHide(const TWindowData* dat, WPARAM wParam, LPARAM lParam);
+
+LRESULT __stdcall DM_RecalcPictureSize(TWindowData *dat);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index bb3424ad7b..a9838ac9d2 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -2611,16 +2611,20 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP HWND hwnd = GetDlgItem(hwndDlg, IDC_LOG);
int len;
- if (wParam == 0 && lParam == 0)
- return(DM_ScrollToBottom(dat, 0, 1));
+ if (wParam == 0 && lParam == 0) {
+ DM_ScrollToBottom(dat, 0, 1);
+ return 0;
+ }
if (dat->hwndIEView == 0 && dat->hwndHPP == 0) {
len = GetWindowTextLengthA(GetDlgItem(hwndDlg, IDC_LOG));
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETSEL, len - 1, len - 1);
}
- if (psi == NULL)
- return(DM_ScrollToBottom(dat, 0, 0));
+ if (psi == NULL) {
+ DM_ScrollToBottom(dat, 0, 0);
+ return 0;
+ }
if ((UINT)psi->nPos >= (UINT)psi->nMax - psi->nPage - 5 || psi->nMax - psi->nMin - psi->nPage < 50)
DM_ScrollToBottom(dat, 0, 0);
diff --git a/plugins/TabSRMM/src/trayicon.cpp b/plugins/TabSRMM/src/trayicon.cpp index 48d6cb2417..1684601ae2 100644 --- a/plugins/TabSRMM/src/trayicon.cpp +++ b/plugins/TabSRMM/src/trayicon.cpp @@ -43,7 +43,7 @@ HANDLE g_hEvent = 0; static TCHAR g_eventName[100];
-static unsigned __stdcall TrayAnimThread(LPVOID vParam)
+static void TrayAnimThread(LPVOID vParam)
{
int iAnimMode = (PluginConfig.m_AnimTrayIcons[0] && PluginConfig.m_AnimTrayIcons[1] && PluginConfig.m_AnimTrayIcons[2] &&
PluginConfig.m_AnimTrayIcons[3]);
@@ -94,7 +94,6 @@ static unsigned __stdcall TrayAnimThread(LPVOID vParam) }
while (isAnimThreadRunning);
CloseHandle(hEvent);
- return 0;
}
void TSAPI CreateTrayMenus(int mode)
@@ -103,7 +102,7 @@ void TSAPI CreateTrayMenus(int mode) mir_sntprintf(g_eventName, 100, _T("tsr_evt_%d"), GetCurrentThreadId());
g_hEvent = CreateEvent(NULL, FALSE, FALSE, g_eventName);
isAnimThreadRunning = TRUE;
- hTrayAnimThread = (HANDLE)mir_forkthreadex(TrayAnimThread, NULL, NULL);
+ hTrayAnimThread = mir_forkthread(TrayAnimThread, NULL);
PluginConfig.g_hMenuTrayUnread = CreatePopupMenu();
PluginConfig.g_hMenuFavorites = CreatePopupMenu();
@@ -119,7 +118,6 @@ void TSAPI CreateTrayMenus(int mode) isAnimThreadRunning = FALSE;
SetEvent(g_hEvent);
WaitForSingleObject(hTrayAnimThread, 5000);
- CloseHandle(hTrayAnimThread);
CloseHandle(g_hEvent);
g_hEvent = 0;
hTrayAnimThread = 0;
diff --git a/plugins/TipperYM/src/message_pump.cpp b/plugins/TipperYM/src/message_pump.cpp index 5980612f49..f0a52cdc9a 100644 --- a/plugins/TipperYM/src/message_pump.cpp +++ b/plugins/TipperYM/src/message_pump.cpp @@ -249,14 +249,12 @@ void InitMessagePump() RegisterClassEx(&wcl);
HMODULE hUserDll = LoadLibrary(_T("user32.dll"));
- if (hUserDll)
- {
+ if (hUserDll) {
MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes");
MyUpdateLayeredWindow = (BOOL (WINAPI *)(HWND hwnd, HDC hdcDST, POINT *pptDst, SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, BLENDFUNCTION *pblend, DWORD dwFlags))GetProcAddress(hUserDll, "UpdateLayeredWindow");
MyAnimateWindow =(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll, "AnimateWindow");
MyMonitorFromPoint = (HMONITOR (WINAPI*)(POINT, DWORD))GetProcAddress(hUserDll, "MonitorFromPoint");
MyGetMonitorInfo = (BOOL (WINAPI*)(HMONITOR, LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoW");
-
}
HMODULE hDwmapiDll = LoadLibrary(_T("dwmapi.dll"));
diff --git a/protocols/GTalkExt/src/inbox.cpp b/protocols/GTalkExt/src/inbox.cpp index e52939aa10..b1c8531b9d 100644 --- a/protocols/GTalkExt/src/inbox.cpp +++ b/protocols/GTalkExt/src/inbox.cpp @@ -234,8 +234,10 @@ HANDLE FindNetUserHandle(LPCSTR acc) return *pResult;
}
-unsigned __stdcall OpenUrlThread(OPEN_URL_HEADER* data)
+void OpenUrlThread(void *param)
{
+ OPEN_URL_HEADER* data = (OPEN_URL_HEADER*)param;
+
__try {
HANDLE hUser = FindNetUserHandle(data->acc);
if (!hUser || !AuthAndOpen(hUser, data->url, data->mailbox, data->pwd))
@@ -244,7 +246,6 @@ unsigned __stdcall OpenUrlThread(OPEN_URL_HEADER* data) __finally {
free(data);
}
- return 0;
}
void __forceinline DecryptString(LPSTR str, int len)
@@ -315,11 +316,8 @@ BOOL OpenUrlWithAuth(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url) data->acc = acc;
- if (HANDLE h = mir_forkthreadex((pThreadFuncEx)OpenUrlThread, data, NULL)) {
- CloseHandle(h);
- data = NULL;
- }
- else return FALSE;
+ mir_forkthread(OpenUrlThread, data);
+ data = NULL;
}
__finally {
free(data);
@@ -328,7 +326,7 @@ BOOL OpenUrlWithAuth(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url) return TRUE;
}
-unsigned __stdcall ShellExecuteThread(PVOID param)
+static void ShellExecuteThread(PVOID param)
{
__try {
ShellExecute(0, NULL, (LPTSTR)param, NULL, NULL, SW_SHOW);
@@ -336,21 +334,11 @@ unsigned __stdcall ShellExecuteThread(PVOID param) __finally {
free(param);
}
- return 0;
}
void StartShellExecuteThread(LPCTSTR url)
{
- LPTSTR urlCopy = _tcsdup(url);
- __try {
- if (HANDLE h = mir_forkthreadex(ShellExecuteThread, urlCopy, NULL)) {
- CloseHandle(h);
- urlCopy = NULL;
- }
- }
- __finally {
- free(urlCopy);
- }
+ mir_forkthread(ShellExecuteThread, _tcsdup(url));
}
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url)
diff --git a/protocols/Gadu-Gadu/src/libgadu/pthread.c b/protocols/Gadu-Gadu/src/libgadu/pthread.c index 9a8988a358..11362add17 100644 --- a/protocols/Gadu-Gadu/src/libgadu/pthread.c +++ b/protocols/Gadu-Gadu/src/libgadu/pthread.c @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int pthread_create(pthread_t *tid, const pthread_attr_t *attr, void *(__stdcall * thread_start) (void *), void *param)
{
tid->hThread = (HANDLE)mir_forkthreadex((pThreadFuncEx)*(void**)&thread_start, param, (unsigned *)&tid->dwThreadId);
-
return 0;
}
diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp index 3d46a739f8..204f23ae29 100644 --- a/src/modules/netlib/netlibautoproxy.cpp +++ b/src/modules/netlib/netlibautoproxy.cpp @@ -266,13 +266,12 @@ struct IeProxyParam char *szProxy;
};
-static unsigned __stdcall NetlibIeProxyThread(void * arg)
+static void NetlibIeProxyThread(void *arg)
{
IeProxyParam *param = (IeProxyParam*)arg;
param->szProxy = NULL;
- if ( !bAutoProxyInit)
- {
+ if ( !bAutoProxyInit) {
WaitForSingleObject(hIeProxyMutex, INFINITE);
NetlibInitAutoProxy();
ReleaseMutex(hIeProxyMutex);
@@ -280,14 +279,12 @@ static unsigned __stdcall NetlibIeProxyThread(void * arg) BOOL res;
char *loc = strstr(szAutoUrlStr, "file://");
- if (loc || strstr(szAutoUrlStr, "://") == NULL)
- {
+ if (loc || strstr(szAutoUrlStr, "://") == NULL) {
NetlibLogf(NULL, "Autoproxy Init file: %s", loc);
loc = loc ? loc + 7 : szAutoUrlStr;
res = pInternetInitializeAutoProxyDll(0, loc, NULL, NULL /*&HelperFunctions*/, NULL);
}
- else
- {
+ else {
NetlibLogf(NULL, "Autoproxy Init %d", abuf.dwScriptBufferSize);
if (abuf.dwScriptBufferSize)
res = pInternetInitializeAutoProxyDll(0, NULL, NULL, NULL /*&HelperFunctions*/, &abuf);
@@ -295,8 +292,7 @@ static unsigned __stdcall NetlibIeProxyThread(void * arg) res = false;
}
- if (res)
- {
+ if (res) {
char proxyBuffer[1024];
char *proxy = proxyBuffer;
DWORD dwProxyLen = sizeof(proxyBuffer);
@@ -308,10 +304,7 @@ static unsigned __stdcall NetlibIeProxyThread(void * arg) NetlibLogf(NULL, "Autoproxy got response %s, Param: %s %s", param->szProxy, param->szUrl, param->szHost);
pInternetDeInitializeAutoProxyDll(NULL, 0);
}
- else
- NetlibLogf(NULL, "Autoproxy init failed");
-
- return 0;
+ else NetlibLogf(NULL, "Autoproxy init failed");
}
char* NetlibGetIeProxy(char *szUrl)
@@ -352,13 +345,10 @@ char* NetlibGetIeProxy(char *szUrl) return res;
}
- if (szAutoUrlStr[0])
- {
- unsigned dwThreadId;
+ if (szAutoUrlStr[0]) {
IeProxyParam param = { szUrl, szHost, NULL };
- HANDLE hThread = (HANDLE)mir_forkthreadex(NetlibIeProxyThread, ¶m, &dwThreadId);
+ HANDLE hThread = mir_forkthread(NetlibIeProxyThread, ¶m);
WaitForSingleObject(hThread, INFINITE);
- CloseHandle(hThread);
res = param.szProxy;
}
return res;
diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp index 01ed2b7413..9e1752cd33 100644 --- a/src/modules/netlib/netlibbind.cpp +++ b/src/modules/netlib/netlibbind.cpp @@ -113,13 +113,12 @@ int NetlibFreeBoundPort(struct NetlibBoundPort *nlbp) closesocket(nlbp->s);
closesocket(nlbp->s6);
WaitForSingleObject(nlbp->hThread, INFINITE);
- CloseHandle(nlbp->hThread);
NetlibLogf(nlbp->nlu, "(%u) Port %u closed for incoming connections", nlbp->s, nlbp->wPort);
mir_free(nlbp);
return 1;
}
-static unsigned __stdcall NetlibBindAcceptThread(void* param)
+static void NetlibBindAcceptThread(void* param)
{
SOCKET s;
SOCKADDR_INET_M sin;
@@ -169,7 +168,6 @@ static unsigned __stdcall NetlibBindAcceptThread(void* param) nlbp->pfnNewConnectionV2(nlc, ntohl(sin.Ipv4.sin_addr.S_un.S_addr), nlbp->pExtra);
}
NetlibUPnPDeletePortMapping(nlbp->wExPort, "TCP");
- return 0;
}
INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam)
@@ -180,7 +178,6 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) SOCKADDR_IN sin = {0};
SOCKADDR_IN6 sin6 = {0};
int foundPort = 0;
- UINT dwThreadId;
if (GetNetlibHandleType(nlu) != NLH_USER || !(nlu->user.flags & NUF_INCOMING) ||
nlb == NULL || nlb->pfnNewConnection == NULL)
@@ -319,14 +316,13 @@ INT_PTR NetlibBindPort(WPARAM wParam, LPARAM lParam) NetlibLogf(NULL, "UPnP disabled. Internal Port: %u\n", nlb->wPort);
nlbp->wExPort = 0;
- if (nlb->cbSize > NETLIBBIND_SIZEOF_V2)
- {
+ if (nlb->cbSize > NETLIBBIND_SIZEOF_V2) {
nlb->wExPort = nlb->wPort;
nlb->dwExternalIP = nlb->dwInternalIP;
}
}
}
- nlbp->hThread = (HANDLE)mir_forkthreadex(NetlibBindAcceptThread, nlbp, &dwThreadId);
+ nlbp->hThread = mir_forkthread(NetlibBindAcceptThread, nlbp);
return (INT_PTR)nlbp;
}
|