summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-03 16:02:14 +0200
committerGeorge Hazan <ghazan@miranda.im>2018-05-03 16:02:14 +0200
commit3ad2582c4a4a6378f294f9256ecbcbdf0ae88e3a (patch)
tree412a28ef6a572efc7039df1c363bf47a3dec4b19 /src/mir_app
parent9a6f750a482d1d1ebf4281bb7bf8133e547ad438 (diff)
mir_forkThread<typename> - stronger typizatioin for thread function parameter
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/chat_opts.cpp2
-rw-r--r--src/mir_app/src/chat_tools.cpp2
-rw-r--r--src/mir_app/src/meta_services.cpp5
-rw-r--r--src/mir_app/src/netlibautoproxy.cpp5
-rw-r--r--src/mir_app/src/netlibbind.cpp5
-rw-r--r--src/mir_app/src/netlibupnp.cpp4
-rw-r--r--src/mir_app/src/proto_accs.cpp5
-rw-r--r--src/mir_app/src/searchresults.cpp17
8 files changed, 20 insertions, 25 deletions
diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp
index d210d62d31..705d74a125 100644
--- a/src/mir_app/src/chat_opts.cpp
+++ b/src/mir_app/src/chat_opts.cpp
@@ -285,7 +285,7 @@ void SetIndentSize()
LOGFONT lf;
LoadMsgDlgFont(0, &lf, nullptr);
HFONT hFont = CreateFontIndirect(&lf);
- int iText = Chat_GetTextPixelSize(MakeTimeStamp(g_Settings->pszTimeStamp, time(nullptr)), hFont, TRUE);
+ int iText = Chat_GetTextPixelSize(MakeTimeStamp(g_Settings->pszTimeStamp, time(0)), hFont, TRUE);
DeleteObject(hFont);
g_Settings->LogTextIndent = iText * 12 / 10;
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index c7def6e4d8..71d0a830ea 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -519,7 +519,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
long trimlimit = g_Settings->LoggingLimit * 1024;
if (dwSize > trimlimit) {
- time_t now = time(nullptr);
+ time_t now = time(0);
wchar_t tszTimestamp[20];
wcsftime(tszTimestamp, 20, L"%Y%m%d-%H%M%S", _localtime32((__time32_t *)&now));
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp
index 86649645e4..135f979d8d 100644
--- a/src/mir_app/src/meta_services.cpp
+++ b/src/mir_app/src/meta_services.cpp
@@ -188,9 +188,8 @@ struct TFakeAckParams
char msg[512];
};
-static void __cdecl sttFakeAckFail(void *param)
+static void __cdecl sttFakeAckFail(TFakeAckParams *tParam)
{
- TFakeAckParams *tParam = (TFakeAckParams*)param;
WaitForSingleObject(tParam->hEvent, INFINITE);
Sleep(100);
@@ -243,7 +242,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam, LPARAM lParam)
tfap->id = 10;
strncpy(tfap->msg, Translate("No online contacts found."), _countof(tfap->msg) - 1);
- CloseHandle(mir_forkthread(sttFakeAckFail, (void*)tfap));
+ mir_forkThread<TFakeAckParams>(sttFakeAckFail, tfap);
SetEvent(hEvent);
return 10;
}
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp
index 04b70cabbf..e005643e7f 100644
--- a/src/mir_app/src/netlibautoproxy.cpp
+++ b/src/mir_app/src/netlibautoproxy.cpp
@@ -176,9 +176,8 @@ struct IeProxyParam
char *szProxy;
};
-static void NetlibIeProxyThread(void *arg)
+static void __cdecl NetlibIeProxyThread(IeProxyParam *param)
{
- IeProxyParam *param = (IeProxyParam*)arg;
param->szProxy = nullptr;
if (!bAutoProxyInit) {
@@ -261,7 +260,7 @@ char* NetlibGetIeProxy(char *szUrl)
if (szAutoUrlStr[0]) {
IeProxyParam param = { szUrl, szHost, nullptr };
- HANDLE hThread = mir_forkthread(NetlibIeProxyThread, &param);
+ HANDLE hThread = mir_forkThread<IeProxyParam>(NetlibIeProxyThread, &param);
WaitForSingleObject(hThread, INFINITE);
res = param.szProxy;
}
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp
index e71ac0a92b..2a592dce89 100644
--- a/src/mir_app/src/netlibbind.cpp
+++ b/src/mir_app/src/netlibbind.cpp
@@ -119,9 +119,8 @@ int NetlibFreeBoundPort(NetlibBoundPort *nlbp)
return 1;
}
-static void NetlibBindAcceptThread(void* param)
+static void __cdecl NetlibBindAcceptThread(NetlibBoundPort *nlbp)
{
- NetlibBoundPort *nlbp = (NetlibBoundPort*)param;
Netlib_Logf(nlbp->nlu, "(%u) Port %u opened for incoming connections", nlbp->s, nlbp->wPort);
while (true) {
@@ -281,7 +280,7 @@ LBL_Error:
nlb->dwExternalIP = nlb->dwInternalIP;
}
- nlbp->hThread = mir_forkthread(NetlibBindAcceptThread, nlbp);
+ nlbp->hThread = mir_forkThread<NetlibBoundPort>(NetlibBindAcceptThread, nlbp);
return nlbp;
}
diff --git a/src/mir_app/src/netlibupnp.cpp b/src/mir_app/src/netlibupnp.cpp
index cdc0668fdf..920334e467 100644
--- a/src/mir_app/src/netlibupnp.cpp
+++ b/src/mir_app/src/netlibupnp.cpp
@@ -644,10 +644,10 @@ static void discoverUPnP(void)
static bool findUPnPGateway(void)
{
- if ((time(nullptr) - lastDiscTime) >= expireTime) {
+ if ((time(0) - lastDiscTime) >= expireTime) {
WaitForSingleObject(portListMutex, INFINITE);
- time_t curTime = time(nullptr);
+ time_t curTime = time(0);
if ((curTime - lastDiscTime) >= expireTime) {
gatewayFound = false;
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 15174fc395..1d3037eb61 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -337,7 +337,7 @@ struct DeactivationThreadParam
pfnUninitProto GetProtocolDestructor(char *szProto);
-static int DeactivationThread(DeactivationThreadParam* param)
+static void __cdecl DeactivationThread(DeactivationThreadParam *param)
{
PROTO_INTERFACE *p = (PROTO_INTERFACE*)param->ppro;
p->SetStatus(ID_STATUS_OFFLINE);
@@ -366,7 +366,6 @@ static int DeactivationThread(DeactivationThreadParam* param)
EraseAccount(szModuleName);
delete param;
- return 0;
}
void DeactivateAccount(PROTOACCOUNT *pa, int flags)
@@ -394,7 +393,7 @@ void DeactivateAccount(PROTOACCOUNT *pa, int flags)
param->flags = flags;
pa->ppro = nullptr;
if (flags & DAF_FORK)
- mir_forkthread((pThreadFunc)DeactivationThread, param);
+ mir_forkThread<DeactivationThreadParam>(DeactivationThread, param);
else
DeactivationThread(param);
}
diff --git a/src/mir_app/src/searchresults.cpp b/src/mir_app/src/searchresults.cpp
index 7b8ba22fdd..333e4c74fd 100644
--- a/src/mir_app/src/searchresults.cpp
+++ b/src/mir_app/src/searchresults.cpp
@@ -179,17 +179,16 @@ void FreeSearchResults(HWND hwndResults)
}
// on its own thread
-static void BeginSearchFailed(void *arg)
+static void __cdecl BeginSearchFailed(wchar_t *protoName)
{
- wchar_t buf[128];
- if (arg != nullptr) {
- const wchar_t *protoName = (wchar_t*)arg;
- mir_snwprintf(buf,
+ CMStringW buf;
+ if (protoName != nullptr) {
+ buf.Format(
TranslateT("Could not start a search on '%s', there was a problem - is %s connected?"),
protoName, protoName);
- mir_free((char*)arg);
+ mir_free(protoName);
}
- else mir_wstrncpy(buf, TranslateT("Could not search on any of the protocols, are you online?"), _countof(buf));
+ else buf = TranslateT("Could not search on any of the protocols, are you online?");
MessageBox(nullptr, buf, TranslateT("Problem with search"), MB_OK | MB_ICONERROR);
}
@@ -215,7 +214,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha
if (failures) {
// infuriatingly vague error message. fixme.
if (dat->searchCount == 0) {
- mir_forkthread(BeginSearchFailed);
+ mir_forkThread<wchar_t>(BeginSearchFailed, nullptr);
mir_free(dat->search);
dat->search = nullptr;
return 1;
@@ -230,7 +229,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha
if (dat->search[0].hProcess == nullptr) {
// infuriatingly vague error message. fixme.
PROTOACCOUNT *pa = Proto_GetAccount(szProto);
- mir_forkthread(BeginSearchFailed, mir_wstrdup(pa->tszAccountName));
+ mir_forkThread<wchar_t>(BeginSearchFailed, mir_wstrdup(pa->tszAccountName));
mir_free(dat->search);
dat->search = nullptr;
dat->searchCount = 0;