From 8f5a7b54eb953bbfc877ec915e26b3a95ec28d00 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> Date: Sun, 21 Feb 2010 23:00:56 +0000 Subject: New updater with 3x reduced footprint and fully W7 and x64 compatible git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@476 4f64403b-2f21-0410-a795-97e2b3489a10 --- updater/popups.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'updater/popups.cpp') diff --git a/updater/popups.cpp b/updater/popups.cpp index 7e29a80..7d7e20a 100644 --- a/updater/popups.cpp +++ b/updater/popups.cpp @@ -62,7 +62,7 @@ LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM return DefWindowProc(hWnd, message, wParam, lParam); } -void __stdcall sttPopupProcA( ULONG_PTR dwParam ) +void __stdcall sttPopupProcA( void *dwParam ) { POPUPDATAEX* ppd = ( POPUPDATAEX* )dwParam; @@ -75,7 +75,7 @@ void __stdcall sttPopupProcA( ULONG_PTR dwParam ) free( ppd ); } -void __stdcall sttPopupProcW( ULONG_PTR dwParam ) +void __stdcall sttPopupProcW( void* dwParam ) { POPUPDATAW* ppd = ( POPUPDATAW* )dwParam; @@ -97,7 +97,7 @@ void ShowPopupA( HANDLE hContact, const char* line1, const char* line2, int flag char *message = new char[strlen(line1) + strlen(line2) + 2]; // newline and null terminator sprintf(message, "%s\n%s", line1, line2); MessageBoxA( NULL, message, title, MB_OK | MB_ICONINFORMATION ); - delete message; + delete[] message; } else if(line1) { MessageBoxA( NULL, line1, title, MB_OK | MB_ICONINFORMATION ); } else if(line2) { @@ -154,7 +154,7 @@ void ShowPopupA( HANDLE hContact, const char* line1, const char* line2, int flag ((PopupDataType*)ppd->PluginData)->flags = flags; ((PopupDataType*)ppd->PluginData)->hIcon = ppd->lchIcon; - QueueUserAPC( sttPopupProcA , mainThread, ( ULONG_PTR )ppd ); + CallFunctionAsync( sttPopupProcA , ppd ); } } @@ -164,13 +164,13 @@ void ShowPopupW( HANDLE hContact, const wchar_t* line1, const wchar_t* line2, in if ( !ServiceExists( MS_POPUP_ADDPOPUPW )) { wchar_t title[256]; - swprintf(title, L"%s Message", _T(MODULE)); + _snwprintf(title, SIZEOF(title), L"%s Message", _T(MODULE)); if(line1 && line2) { - wchar_t *message = new wchar_t[wcslen(line1) + wcslen(line2) + 2]; // newline and null terminator - swprintf(message, L"%s\n%s", line1, line2); + size_t len = wcslen(line1) + wcslen(line2) + 1; + wchar_t *message = (wchar_t*)alloca(len * sizeof(wchar_t)); // newline and null terminator + _snwprintf(message, len, L"%s\n%s", line1, line2); MessageBoxW( NULL, message, title, MB_OK | MB_ICONINFORMATION ); - delete message; } else if(line1) { MessageBoxW( NULL, line1, title, MB_OK | MB_ICONINFORMATION ); } else if(line2) { @@ -226,21 +226,21 @@ void ShowPopupW( HANDLE hContact, const wchar_t* line1, const wchar_t* line2, in ((PopupDataType*)ppd->PluginData)->flags = flags; ((PopupDataType*)ppd->PluginData)->hIcon = ppd->lchIcon; - QueueUserAPC( sttPopupProcW , mainThread, ( ULONG_PTR )ppd ); + CallFunctionAsync( sttPopupProcW , ppd ); } } void ShowWarning(TCHAR *msg) { if(ServiceExists(MS_POPUP_SHOWMESSAGE)) { TCHAR title[512]; - _stprintf(title, _T("%s Warning"), _T(MODULE)); + mir_sntprintf(title, SIZEOF(title), _T("%s Warning"), _T(MODULE)); TCHAR message[1024]; - _stprintf(message, _T("%s: %s"), _T(MODULE), msg); + mir_sntprintf(message, SIZEOF(message), _T("%s: %s"), _T(MODULE), msg); ShowPopup(0, title, message, 0, 10); //PUShowMessage(message, SM_WARNING); } else { TCHAR title[512]; - _stprintf(title, _T("%s Warning"), MODULE); + mir_sntprintf(title, SIZEOF(title), _T("%s Warning"), MODULE); MessageBox(0, msg, title, MB_OK | MB_ICONWARNING); } } @@ -250,17 +250,17 @@ void ShowPopup(HANDLE hContact, const TCHAR *line1, const TCHAR *line2, int flag if(ServiceExists(MS_POPUP_ADDPOPUPW)) ShowPopupW(hContact, line1, line2, flags, timeout); else { - char *al1 = w2a(line1), *al2 = w2a(line2); + char *al1 = mir_u2a(line1), *al2 = mir_u2a(line2); ShowPopupA(hContact, al1, al2, flags, timeout); - free(al1); free(al2); + mir_free(al1); mir_free(al2); } #else if(ServiceExists(MS_POPUP_ADDPOPUP)) ShowPopupA(hContact, line1, line2, flags, timeout); else { - wchar_t *wl1 = a2w(line1), *wl2 = a2w(line2); + wchar_t *wl1 = mir_a2u(line1), *wl2 = mir_a2u(line2); ShowPopupW(hContact, wl1, wl2, flags, timeout); - free(wl1); free(wl2); + mir_free(wl1); mir_free(wl2); } #endif @@ -269,14 +269,14 @@ void ShowPopup(HANDLE hContact, const TCHAR *line1, const TCHAR *line2, int flag void ShowError(TCHAR *msg) { if(ServiceExists(MS_POPUP_SHOWMESSAGE)) { TCHAR title[512]; - _stprintf(title, _T("%s Error"), _T(MODULE)); + mir_sntprintf(title, SIZEOF(title), _T("%s Error"), _T(MODULE)); TCHAR message[1024]; - _stprintf(message, _T("%s: %s"), _T(MODULE), msg); + mir_sntprintf(message, SIZEOF(message), _T("%s: %s"), _T(MODULE), msg); //PUShowMessage(message, SM_WARNING); ShowPopup(0, title, message, 0, 10); } else { TCHAR title[512]; - _stprintf(title, _T("%s Error"), _T(MODULE)); + mir_sntprintf(title, SIZEOF(title), _T("%s Error"), _T(MODULE)); MessageBox(0, msg, title, MB_OK | MB_ICONERROR); } } @@ -286,17 +286,17 @@ void ChangePopupText(HWND hwnd, TCHAR *text) { if(ServiceExists(MS_POPUP_CHANGETEXTW)) CallService(MS_POPUP_CHANGETEXTW, (WPARAM)hwnd, (LPARAM)text); else { - char *atext = w2a(text); + char *atext = mir_u2a(text); CallService(MS_POPUP_CHANGETEXT, (WPARAM)hwnd, (LPARAM)atext); - free(atext); + mir_free(atext); } #else if(ServiceExists(MS_POPUP_CHANGETEXT)) CallService(MS_POPUP_CHANGETEXT, (WPARAM)hwnd, (LPARAM)text); else { - wchar_t *wtext = a2w(text); + wchar_t *wtext = mir_a2u(text); CallService(MS_POPUP_CHANGETEXTW, (WPARAM)hwnd, (LPARAM)wtext); - free(wtext); + mir_free(wtext); } #endif } -- cgit v1.2.3