From d926369611fbf2dc975e0080cbd60cfa111c7d11 Mon Sep 17 00:00:00 2001 From: sje Date: Mon, 19 Nov 2007 23:27:48 +0000 Subject: fix utf8 messages with non-unicode popups (thx Pescuma) git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@380 4f64403b-2f21-0410-a795-97e2b3489a10 --- message_notify/messagenotify.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'message_notify/messagenotify.cpp') diff --git a/message_notify/messagenotify.cpp b/message_notify/messagenotify.cpp index c6b4b94..4d9e319 100644 --- a/message_notify/messagenotify.cpp +++ b/message_notify/messagenotify.cpp @@ -16,6 +16,9 @@ Map open_msg_windows; HINSTANCE hInst; PLUGINLINK *pluginLink; +MM_INTERFACE mmi; +UTF8_INTERFACE utfi; + HANDLE mainThread; bool metacontacts_installed; @@ -29,7 +32,7 @@ DWORD focusTimerId = 0; PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), "Message Notify", - PLUGIN_MAKE_VERSION(0, 4, 0, 1), + PLUGIN_MAKE_VERSION(0, 4, 1, 0), "Show a popup when a message is received", "Scott Ellis", "mail@scottellis.com.au", @@ -240,8 +243,15 @@ unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) { char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)cd->hContact, 0); if(szCDN && szCDN[0]) { if(cd->blobsize) { - if((options.flags & MNNF_POPUP) && options.show_msg) ShowPopup(cd->hContact, szCDN, (char *)cd->blob); - if(options.flags & MNNF_SPEAK) Speak_SayExA("messages", cd->hContact, (char *)cd->blob); + if(cd->flags & DBEF_UTF) { + char *msg = mir_utf8decodecp((char *)cd->blob, code_page, 0); + if((options.flags & MNNF_POPUP) && options.show_msg) ShowPopup(cd->hContact, szCDN, (char *)msg); + if(options.flags & MNNF_SPEAK) Speak_SayExA("messages", cd->hContact, (char *)msg); + mir_free(msg); + } else { + if((options.flags & MNNF_POPUP) && options.show_msg) ShowPopup(cd->hContact, szCDN, (char *)cd->blob); + if(options.flags & MNNF_SPEAK) Speak_SayExA("messages", cd->hContact, (char *)cd->blob); + } } else { if(options.flags & MNNF_POPUP) ShowPopup(cd->hContact, szCDN, 0); if(options.flags & MNNF_SPEAK) Speak_SayExA("messages", cd->hContact, "empty message"); @@ -418,6 +428,9 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) pluginLink = link; DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 ); + mir_getMMI(&mmi); + mir_getUTFI(&utfi); + char szVer[128]; unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode")); -- cgit v1.2.3