diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-01-29 04:21:54 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-01-29 04:21:54 +0000 |
commit | f7e590b0e13548d0f3282ec9ab183a17862da385 (patch) | |
tree | 8bb781ebfd8f1b411e2467588fa3e4c927f27d7f | |
parent | cba2982d3301ab94ad475da6f9f354c24a0e0248 (diff) |
use miranda thread api if available
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@83 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r-- | message_notify/messagenotify.cpp | 17 | ||||
-rw-r--r-- | message_notify/messagenotify.vcproj | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/message_notify/messagenotify.cpp b/message_notify/messagenotify.cpp index ccf1b47..cde42b1 100644 --- a/message_notify/messagenotify.cpp +++ b/message_notify/messagenotify.cpp @@ -16,6 +16,7 @@ HANDLE mainThread; bool metacontacts_installed;
bool unicode_system;
+bool thread_api = false;
int code_page = CP_ACP;
@@ -26,7 +27,7 @@ DWORD focusTimerId = 0; PLUGININFO pluginInfo={
sizeof(PLUGININFO),
"Message Notify",
- PLUGIN_MAKE_VERSION(0,1,2,0),
+ PLUGIN_MAKE_VERSION(0,1,3,0),
"Show a popup when a message is received",
"Scott Ellis",
"mail@scottellis.com.au",
@@ -147,10 +148,12 @@ typedef struct { HANDLE hContact;
BYTE *blob;
int blobsize;
+ HANDLE hEvent;
} CheckWindowData;
unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
CheckWindowData *cd = (CheckWindowData *)dwParam;
+ if(!thread_api) SetEvent(cd->hEvent);
Sleep(500); // wait for message window to open from event, if it's going to
@@ -255,7 +258,15 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { cd->blobsize = 0;
// spawn a thread to deal with the copied data
- CloseHandle((HANDLE)_beginthreadex(0, 0, sttCheckWindowProc, (VOID *)cd, 0, 0));
+ if(thread_api)
+ CallService(MS_SYSTEM_FORK_THREAD, (WPARAM)sttCheckWindowProc, (LPARAM)(VOID *)cd);
+ else {
+ cd->hEvent = CreateEvent(0, 0, 0, 0);
+ CloseHandle((HANDLE)_beginthreadex(0, 0, sttCheckWindowProc, (VOID *)cd, 0, 0));
+ WaitForSingleObject(cd->hEvent, INFINITE);
+ CloseHandle(cd->hEvent);
+ }
+
return 0;
}
@@ -349,6 +360,8 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
+ thread_api = (ServiceExists(MS_SYSTEM_FORK_THREAD) != 0);
+
InitWindowList();
LoadOptions();
diff --git a/message_notify/messagenotify.vcproj b/message_notify/messagenotify.vcproj index c2a4a18..dcd6151 100644 --- a/message_notify/messagenotify.vcproj +++ b/message_notify/messagenotify.vcproj @@ -83,7 +83,6 @@ SuppressStartupBanner="true"
IgnoreDefaultLibraryNames="Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib"
GenerateDebugInformation="true"
- ProgramDatabaseFile=".\Debug/messagenotify.pdb"
ImportLibrary="$(IntDir)/$(TargetName).lib"
TargetMachine="1"
/>
@@ -182,7 +181,6 @@ LinkIncremental="1"
SuppressStartupBanner="true"
IgnoreDefaultLibraryNames="Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib"
- ProgramDatabaseFile=".\Release/messagenotify.pdb"
OptimizeReferences="2"
EnableCOMDATFolding="2"
BaseAddress="0x22080000"
|