summaryrefslogtreecommitdiff
path: root/plugins/BasicHistory
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-07-26 21:40:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-07-26 21:40:50 +0300
commit1019387a8f6ccc087a113f138c5237146492a356 (patch)
tree50ef616016686e43ae119333ebac88bc90b2ff11 /plugins/BasicHistory
parentd61bc49d53578c26b50531fdec1bbd633e19b6ac (diff)
fixes #1527 (Remove obsolete g_hMainThread and QueueUSerAPC from plugins)
Diffstat (limited to 'plugins/BasicHistory')
-rw-r--r--plugins/BasicHistory/src/BasicHistory.cpp6
-rw-r--r--plugins/BasicHistory/src/Scheduler.cpp16
2 files changed, 9 insertions, 13 deletions
diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp
index a371fcdfa0..091d9b15d9 100644
--- a/plugins/BasicHistory/src/BasicHistory.cpp
+++ b/plugins/BasicHistory/src/BasicHistory.cpp
@@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MS_HISTORY_EXECUTE_TASK "BasicHistory/ExecuteTask"
HCURSOR hCurSplitNS, hCurSplitWE;
-HANDLE g_hMainThread = nullptr;
HANDLE *hEventIcons = nullptr;
int iconsNum = 3;
@@ -237,7 +236,6 @@ int ModulesLoaded(WPARAM, LPARAM)
int CMPlugin::Load()
{
hTaskMainMenu = nullptr;
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &g_hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
hCurSplitNS = LoadCursor(nullptr, IDC_SIZENS);
hCurSplitWE = LoadCursor(nullptr, IDC_SIZEWE);
@@ -261,10 +259,6 @@ int CMPlugin::Load()
int CMPlugin::Unload()
{
- if (g_hMainThread)
- CloseHandle(g_hMainThread);
- g_hMainThread = nullptr;
-
HistoryWindow::Deinit();
DestroyCursor(hCurSplitNS);
diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp
index 26dfcb3fb2..57b93a97c8 100644
--- a/plugins/BasicHistory/src/Scheduler.cpp
+++ b/plugins/BasicHistory/src/Scheduler.cpp
@@ -22,8 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "HistoryWindow.h"
// Sorry for plain C implementation
-#define MODULENAME "BasicHistory"
-extern HANDLE g_hMainThread;
+#define MODULENAME "BasicHistory"
+
bool bPopupsEnabled;
bool DoTask(TaskOptions& to);
bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top = nullptr, std::wstring* err = nullptr, std::wstring* errDescr = nullptr);
@@ -217,7 +217,7 @@ bool IsValidTask(TaskOptions& to, std::list<TaskOptions>* top, std::wstring* err
return true;
}
-static void CALLBACK DoRebuildEventsInMainAPCFunc(ULONG_PTR dwParam)
+static INT_PTR CALLBACK DoRebuildEventsInMainAPCFunc(void *dwParam)
{
MCONTACT *contacts = (MCONTACT*)dwParam;
size_t size = (size_t)contacts[0];
@@ -225,6 +225,7 @@ static void CALLBACK DoRebuildEventsInMainAPCFunc(ULONG_PTR dwParam)
HistoryWindow::RebuildEvents(contacts[i]);
delete[] contacts;
+ return 0;
}
bool DoTask(TaskOptions& to)
@@ -416,7 +417,7 @@ bool DoTask(TaskOptions& to)
for (std::list<MCONTACT>::iterator it = contactList.begin(); it != contactList.end(); ++it)
pContacts[i++] = *it;
- QueueUserAPC(DoRebuildEventsInMainAPCFunc, g_hMainThread, (ULONG_PTR)pContacts);
+ CallFunctionSync(DoRebuildEventsInMainAPCFunc, pContacts);
}
}
@@ -788,11 +789,12 @@ bool GetNextExportTime(bool init, time_t now)
return isExport;
}
-static void CALLBACK DoTaskFinishInMainAPCFunc(ULONG_PTR dwParam)
+static INT_PTR CALLBACK DoTaskFinishInMainAPCFunc(void *param)
{
- wchar_t *item = (wchar_t*)dwParam;
+ wchar_t *item = (wchar_t*)param;
MessageBox(nullptr, item, TranslateT("Task finished"), MB_OK | MB_ICONINFORMATION);
delete[] item;
+ return 0;
}
bool ExecuteCurrentTask(time_t now)
@@ -843,7 +845,7 @@ bool ExecuteCurrentTask(time_t now)
mir_snwprintf(name, size, TranslateT("Task '%s' execution failed"), to.taskName.c_str());
else
mir_snwprintf(name, size, TranslateT("Task '%s' finished successfully"), to.taskName.c_str());
- QueueUserAPC(DoTaskFinishInMainAPCFunc, g_hMainThread, (ULONG_PTR)name);
+ CallFunctionSync(DoTaskFinishInMainAPCFunc, name);
}
}
}