From e3cefc7b6ca803e3f87dbadae54a110332778490 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 5 Jul 2012 22:41:06 +0000 Subject: - first of the /Core standard plugins; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@778 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/commonheaders.h | 1 + src/core/miranda.cpp | 55 +- src/core/miranda.h | 21 +- src/core/modules.cpp | 10 +- src/core/stdplug.h | 23 + src/core/stduserinfo/commonheaders.cpp | 2 + src/core/stduserinfo/commonheaders.h | 96 +++ src/core/stduserinfo/contactinfo.cpp | 528 ++++++++++++ src/core/stduserinfo/main.cpp | 90 ++ src/core/stduserinfo/res/cursor_hyperlink.cur | Bin 0 -> 326 bytes src/core/stduserinfo/resource.rc | 303 +++++++ src/core/stduserinfo/stdinfo.cpp | 612 +++++++++++++ src/core/stduserinfo/stduserinfo_10.vcxproj | 218 +++++ .../stduserinfo/stduserinfo_10.vcxproj.filters | 50 ++ src/core/stduserinfo/userinfo.cpp | 629 ++++++++++++++ src/core/stduserinfo/version.h | 14 + src/core/stduserinfo/version.rc | 38 + src/miranda32.def | 20 +- src/miranda32_10.vcxproj | 10 +- src/miranda32_10.vcxproj.filters | 15 +- src/modules/addcontact/addcontact.cpp | 16 +- src/modules/button/button.cpp | 26 +- src/modules/clist/Docking.cpp | 2 +- src/modules/clist/clc.cpp | 12 +- src/modules/clist/clcfiledrop.cpp | 4 +- src/modules/clist/clcitems.cpp | 16 +- src/modules/clist/clcutils.cpp | 6 +- src/modules/clist/clistevents.cpp | 66 +- src/modules/clist/clistmenus.cpp | 104 +-- src/modules/clist/clistmod.cpp | 14 +- src/modules/clist/clistsettings.cpp | 2 +- src/modules/clist/clisttray.cpp | 58 +- src/modules/clist/clui.cpp | 18 +- src/modules/clist/cluiservices.cpp | 6 +- src/modules/clist/contact.cpp | 4 +- src/modules/clist/genmenu.cpp | 48 +- src/modules/clist/genmenuopt.cpp | 166 ++-- src/modules/clist/groups.cpp | 12 +- src/modules/clist/keyboard.cpp | 42 +- src/modules/clist/movetogroup.cpp | 26 +- src/modules/clist/protocolorder.cpp | 34 +- src/modules/contacts/contacts.cpp | 42 +- src/modules/database/database.cpp | 54 +- src/modules/database/dbini.cpp | 96 +-- src/modules/database/dbutils.cpp | 6 +- src/modules/database/profilemanager.cpp | 98 +-- src/modules/database/profilemanager.h | 10 +- src/modules/findadd/findadd.cpp | 314 +++---- src/modules/findadd/searchresults.cpp | 88 +- src/modules/fonts/FontOptions.cpp | 74 +- src/modules/fonts/services.cpp | 22 +- src/modules/help/about.cpp | 14 +- src/modules/help/help.cpp | 6 +- src/modules/history/history.cpp | 66 +- src/modules/icolib/extracticon.cpp | 8 +- src/modules/icolib/skin2icons.cpp | 20 +- src/modules/icolib/skin2opts.cpp | 14 +- src/modules/idle/idle.cpp | 18 +- src/modules/ignore/ignore.cpp | 148 ++-- src/modules/json/JSONChildren.cpp | 50 +- src/modules/json/JSONDebug.cpp | 54 +- src/modules/json/JSONIterators.cpp | 56 +- src/modules/json/JSONMemory.cpp | 50 +- src/modules/json/JSONMemory.h | 2 +- src/modules/json/JSONNode.cpp | 52 +- src/modules/json/JSONNode.h | 4 +- src/modules/json/JSONWorker.cpp | 42 +- src/modules/json/JSONWriter.cpp | 4 +- src/modules/json/JSON_Base64.cpp | 58 +- src/modules/json/NumberToString.h | 4 +- src/modules/json/json.cpp | 8 +- src/modules/netlib/netlib.cpp | 164 ++-- src/modules/netlib/netlib.h | 4 +- src/modules/netlib/netlibautoproxy.cpp | 12 +- src/modules/netlib/netlibbind.cpp | 4 +- src/modules/netlib/netlibhttp.cpp | 23 +- src/modules/netlib/netlibhttpproxy.cpp | 36 +- src/modules/netlib/netliblog.cpp | 106 +-- src/modules/netlib/netlibopenconn.cpp | 40 +- src/modules/netlib/netlibopts.cpp | 134 +-- src/modules/netlib/netlibpktrecver.cpp | 32 +- src/modules/netlib/netlibsecurity.cpp | 6 +- src/modules/netlib/netlibsock.cpp | 10 +- src/modules/netlib/netlibssl.cpp | 116 +-- src/modules/netlib/netlibupnp.cpp | 50 +- src/modules/options/descbutton.cpp | 78 +- src/modules/options/filter.cpp | 8 +- src/modules/options/filter.h | 14 +- src/modules/options/headerbar.cpp | 80 +- src/modules/options/iconheader.cpp | 128 +-- src/modules/options/options.cpp | 38 +- src/modules/plugins/newplugins.cpp | 142 +++- src/modules/plugins/pluginopts.cpp | 26 +- src/modules/plugins/plugins.h | 16 +- src/modules/protocols/protoaccs.cpp | 10 +- src/modules/protocols/protochains.cpp | 8 +- src/modules/protocols/protocols.cpp | 22 +- src/modules/protocols/protoopts.cpp | 16 +- src/modules/skin/hotkey_opts.cpp | 14 +- src/modules/skin/hotkeys.cpp | 30 +- src/modules/skin/skinicons.cpp | 36 +- src/modules/skin/sounds.cpp | 10 +- src/modules/srauth/auth.cpp | 2 +- src/modules/srauth/authdialogs.cpp | 24 +- src/modules/srawaymsg/awaymsg.cpp | 14 +- src/modules/srawaymsg/sendmsg.cpp | 6 +- src/modules/sremail/email.cpp | 4 +- src/modules/srfile/file.cpp | 46 +- src/modules/srfile/file.h | 10 +- src/modules/srfile/fileexistsdlg.cpp | 80 +- src/modules/srfile/fileopts.cpp | 18 +- src/modules/srfile/filerecvdlg.cpp | 70 +- src/modules/srfile/filesenddlg.cpp | 36 +- src/modules/srfile/filexferdlg.cpp | 124 +-- src/modules/srfile/ftmanager.cpp | 20 +- src/modules/srurl/url.cpp | 46 +- src/modules/srurl/urldialogs.cpp | 152 ++-- src/modules/updatenotify/updatenotify.cpp | 2 +- src/modules/userinfo/contactinfo.cpp | 515 ----------- src/modules/userinfo/stdinfo.cpp | 612 ------------- src/modules/userinfo/userinfo.cpp | 634 -------------- src/modules/useronline/useronline.cpp | 22 +- src/modules/utils/bmpfilter.cpp | 72 +- src/modules/utils/colourpicker.cpp | 44 +- src/modules/utils/hyperlink.cpp | 106 +-- src/modules/utils/imgconv.cpp | 2 +- src/modules/utils/path.cpp | 4 +- src/modules/utils/resizer.cpp | 52 +- src/modules/utils/timeutils.cpp | 2 +- src/modules/utils/timezones.cpp | 34 +- src/modules/utils/utils.cpp | 26 +- src/modules/utils/windowlist.cpp | 18 +- src/modules/visibility/visibility.cpp | 96 +-- src/modules/xml/xmlApi.cpp | 104 +-- src/modules/xml/xmlParser.cpp | 944 ++++++++++----------- src/modules/xml/xmlParser.h | 162 ++-- src/resource.rc | 238 +----- 137 files changed, 5644 insertions(+), 5009 deletions(-) create mode 100644 src/core/stdplug.h create mode 100644 src/core/stduserinfo/commonheaders.cpp create mode 100644 src/core/stduserinfo/commonheaders.h create mode 100644 src/core/stduserinfo/contactinfo.cpp create mode 100644 src/core/stduserinfo/main.cpp create mode 100644 src/core/stduserinfo/res/cursor_hyperlink.cur create mode 100644 src/core/stduserinfo/resource.rc create mode 100644 src/core/stduserinfo/stdinfo.cpp create mode 100644 src/core/stduserinfo/stduserinfo_10.vcxproj create mode 100644 src/core/stduserinfo/stduserinfo_10.vcxproj.filters create mode 100644 src/core/stduserinfo/userinfo.cpp create mode 100644 src/core/stduserinfo/version.h create mode 100644 src/core/stduserinfo/version.rc delete mode 100644 src/modules/userinfo/contactinfo.cpp delete mode 100644 src/modules/userinfo/stdinfo.cpp delete mode 100644 src/modules/userinfo/userinfo.cpp (limited to 'src') diff --git a/src/core/commonheaders.h b/src/core/commonheaders.h index 5e6c25da62..ca35d2ae4b 100644 --- a/src/core/commonheaders.h +++ b/src/core/commonheaders.h @@ -93,6 +93,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "miranda.h" +#include "stdplug.h" #include #include diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index a04846b217..4ee236537f 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -118,27 +118,27 @@ static void __cdecl compactHeapsThread(void*) HANDLE hHeaps[256]; DWORD hc; SleepEx((1000*60)*5, TRUE); // every 5 minutes - hc=GetProcessHeaps(255, (PHANDLE)&hHeaps); + hc = GetProcessHeaps(255, (PHANDLE)&hHeaps); if (hc != 0 && hc < 256) { DWORD j; - for (j=0; j < hc; j++) + for (j = 0; j < hc; j++) HeapCompact(hHeaps[j], 0); } } //while } -void (*SetIdleCallback) (void)=NULL; +void (*SetIdleCallback) (void) = NULL; static INT_PTR SystemSetIdleCallback(WPARAM, LPARAM lParam) { if (lParam && SetIdleCallback == NULL) { - SetIdleCallback=(void (*)(void))lParam; + SetIdleCallback = (void (*)(void))lParam; return 1; } return 0; } -static DWORD dwEventTime=0; +static DWORD dwEventTime = 0; void checkIdle(MSG * msg) { switch(msg->message) { @@ -209,9 +209,8 @@ void ParseCommandLine() int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { - DWORD myPid=0; - int messageloop=1; - HMODULE hUser32, hThemeAPI, hDwmApi, hShFolder = NULL; + DWORD myPid = 0; + int messageloop = 1; int result = 0; hInst = hInstance; @@ -222,23 +221,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif - hUser32 = GetModuleHandleA("user32"); + HINSTANCE hUser32 = GetModuleHandleA("user32"); openInputDesktop = (pfnOpenInputDesktop)GetProcAddress (hUser32, "OpenInputDesktop"); closeDesktop = (pfnCloseDesktop)GetProcAddress (hUser32, "CloseDesktop"); msgWaitForMultipleObjectsEx = (pfnMsgWaitForMultipleObjectsEx)GetProcAddress(hUser32, "MsgWaitForMultipleObjectsEx"); - animateWindow =(pfnAnimateWindow)GetProcAddress(hUser32, "AnimateWindow"); - setLayeredWindowAttributes =(pfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes"); + animateWindow = (pfnAnimateWindow)GetProcAddress(hUser32, "AnimateWindow"); + setLayeredWindowAttributes = (pfnSetLayeredWindowAttributes)GetProcAddress(hUser32, "SetLayeredWindowAttributes"); MyMonitorFromPoint = (pfnMyMonitorFromPoint)GetProcAddress(hUser32, "MonitorFromPoint"); MyMonitorFromRect = (pfnMyMonitorFromRect)GetProcAddress(hUser32, "MonitorFromRect"); MyMonitorFromWindow = (pfnMyMonitorFromWindow)GetProcAddress(hUser32, "MonitorFromWindow"); MyGetMonitorInfo = (pfnMyGetMonitorInfo)GetProcAddress(hUser32, "GetMonitorInfoW"); - hShFolder = GetModuleHandleA("shell32"); + HINSTANCE hShFolder = GetModuleHandleA("shell32"); shGetSpecialFolderPathA = (pfnSHGetSpecialFolderPathA)GetProcAddress(hShFolder, "SHGetSpecialFolderPathA"); shGetSpecialFolderPathW = (pfnSHGetSpecialFolderPathW)GetProcAddress(hShFolder, "SHGetSpecialFolderPathW"); if (shGetSpecialFolderPathA == NULL) { - hShFolder = LoadLibraryA("ShFolder.dll"); + HINSTANCE hShFolder = LoadLibraryA("ShFolder.dll"); shGetSpecialFolderPathA = (pfnSHGetSpecialFolderPathA)GetProcAddress(hShFolder, "SHGetSpecialFolderPathA"); shGetSpecialFolderPathW = (pfnSHGetSpecialFolderPathW)GetProcAddress(hShFolder, "SHGetSpecialFolderPathW"); } @@ -246,17 +245,17 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) shAutoComplete = (pfnSHAutoComplete)GetProcAddress(GetModuleHandleA("shlwapi"), "SHAutoComplete"); if ( IsWinVerXPPlus()) { - hThemeAPI = LoadLibraryA("uxtheme.dll"); + HINSTANCE hThemeAPI = LoadLibraryA("uxtheme.dll"); if (hThemeAPI) { openThemeData = (pfnOpenThemeData)GetProcAddress(hThemeAPI, "OpenThemeData"); isThemeBackgroundPartiallyTransparent = (pfnIsThemeBackgroundPartiallyTransparent)GetProcAddress(hThemeAPI, "IsThemeBackgroundPartiallyTransparent"); - drawThemeParentBackground = (pfnDrawThemeParentBackground)GetProcAddress(hThemeAPI, "DrawThemeParentBackground"); + drawThemeParentBackground = (pfnDrawThemeParentBackground)GetProcAddress(hThemeAPI, "DrawThemeParentBackground"); drawThemeBackground = (pfnDrawThemeBackground)GetProcAddress(hThemeAPI, "DrawThemeBackground"); drawThemeText = (pfnDrawThemeText)GetProcAddress(hThemeAPI, "DrawThemeText"); drawThemeTextEx = (pfnDrawThemeTextEx)GetProcAddress(hThemeAPI, "DrawThemeTextEx"); getThemeBackgroundContentRect = (pfnGetThemeBackgroundContentRect)GetProcAddress(hThemeAPI , "GetThemeBackgroundContentRect"); getThemeFont = (pfnGetThemeFont)GetProcAddress(hThemeAPI, "GetThemeFont"); - closeThemeData = (pfnCloseThemeData)GetProcAddress(hThemeAPI, "CloseThemeData"); + closeThemeData = (pfnCloseThemeData)GetProcAddress(hThemeAPI, "CloseThemeData"); enableThemeDialogTexture = (pfnEnableThemeDialogTexture)GetProcAddress(hThemeAPI, "EnableThemeDialogTexture"); setWindowTheme = (pfnSetWindowTheme)GetProcAddress(hThemeAPI, "SetWindowTheme"); setWindowThemeAttribute = (pfnSetWindowThemeAttribute)GetProcAddress(hThemeAPI, "SetWindowThemeAttribute"); @@ -270,7 +269,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) } if ( IsWinVerVistaPlus()) { - hDwmApi = LoadLibraryA("dwmapi.dll"); + HINSTANCE hDwmApi = LoadLibraryA("dwmapi.dll"); if (hDwmApi) { dwmExtendFrameIntoClientArea = (pfnDwmExtendFrameIntoClientArea)GetProcAddress(hDwmApi, "DwmExtendFrameIntoClientArea"); dwmIsCompositionEnabled = (pfnDwmIsCompositionEnabled)GetProcAddress(hDwmApi, "DwmIsCompositionEnabled"); @@ -306,12 +305,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) forkthread(compactHeapsThread, 0, NULL); CreateServiceFunction(MS_SYSTEM_SETIDLECALLBACK, SystemSetIdleCallback); CreateServiceFunction(MS_SYSTEM_GETIDLE, SystemGetIdle); - dwEventTime=GetTickCount(); - myPid=GetCurrentProcessId(); + dwEventTime = GetTickCount(); + myPid = GetCurrentProcessId(); while (messageloop) { MSG msg; DWORD rc; - BOOL dying=FALSE; + BOOL dying = FALSE; rc = MsgWaitForMultipleObjectsEx(waitObjectCount, hWaitObjects, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE); if (rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0 + waitObjectCount) { rc -= WAIT_OBJECT_0; @@ -320,7 +319,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) // while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message != WM_QUIT) { - HWND h=GetForegroundWindow(); + HWND h = GetForegroundWindow(); DWORD pid = 0; checkIdle(&msg); if (h != NULL && GetWindowThreadProcessId(h, &pid) && pid == myPid && GetClassLongPtr(h, GCW_ATOM) == 32770) @@ -344,7 +343,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) PostQuitMessage(0); } else if (dying) - messageloop=0; + messageloop = 0; } } @@ -358,12 +357,8 @@ exit: OleUninitialize(); - if (bufferedPaintUninit) bufferedPaintUninit(); - - if (hDwmApi) FreeLibrary(hDwmApi); - if (hThemeAPI) FreeLibrary(hThemeAPI); - if (hShFolder) FreeLibrary(hShFolder); - + if (bufferedPaintUninit) + bufferedPaintUninit(); return result; } @@ -401,8 +396,8 @@ static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam) PVOID pVerInfo; GetModuleFileName(NULL, filename, SIZEOF(filename)); - verInfoSize=GetFileVersionInfoSize(filename, &unused); - pVerInfo=mir_alloc(verInfoSize); + verInfoSize = GetFileVersionInfoSize(filename, &unused); + pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\ProductVersion"), (LPVOID*)&productVersion, &blockSize); #if defined(_WIN64) diff --git a/src/core/miranda.h b/src/core/miranda.h index 3446fc0a72..3b08c636ba 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -126,7 +126,7 @@ void KillModuleSounds(int hLangpack); /**** miranda.cpp **********************************************************************/ extern HINSTANCE hInst; -extern HANDLE hOkToExitEvent, hModulesLoadedEvent; +extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModule; /**** utf.cpp **************************************************************************/ @@ -145,20 +145,10 @@ HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name); /**** skin2icons.cpp *******************************************************************/ -HANDLE IcoLib_AddNewIcon(int hLangpack, SKINICONDESC* sid); -HICON IcoLib_GetIcon(const char* pszIconName, bool big); -HICON IcoLib_GetIconByHandle(HANDLE hItem, bool big); -HANDLE IcoLib_IsManaged(HICON hIcon); -int IcoLib_ReleaseIcon(HICON hIcon, char* szIconName, bool big); - void KillModuleIcons(int hLangpack); /**** skinicons.cpp ********************************************************************/ -HICON LoadSkinProtoIcon(const char* szProto, int status, bool big = false); -HICON LoadSkinIcon(int idx, bool big = false); -HANDLE GetSkinIconHandle(int idx); - HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared); int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource); int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource); @@ -167,20 +157,13 @@ int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId); int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char* szProto, int iconId); int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon); -void Button_SetIcon_IcoLib(HWND hDlg, int itemId, int iconId, const char* tooltip); -void Button_FreeIcon_IcoLib(HWND hDlg, int itemId); - -void Window_SetIcon_IcoLib(HWND hWnd, int iconId); -void Window_SetProtoIcon_IcoLib(HWND hWnd, const char* szProto, int iconId); -void Window_FreeIcon_IcoLib(HWND hWnd); - -#define IconLib_ReleaseIcon(hIcon, szName) IcoLib_ReleaseIcon(hIcon, szName, false); #define Safe_DestroyIcon(hIcon) if (hIcon) DestroyIcon(hIcon) /**** clistmenus.cpp ********************************************************************/ extern HANDLE hMainMenuObject, hContactMenuObject, hStatusMenuObject; extern HANDLE hPreBuildMainMenuEvent, hPreBuildContactMenuEvent; +extern HANDLE hShutdownEvent, hPreShutdownEvent; extern const int statusModeList[ MAX_STATUS_COUNT ]; extern const int skinIconStatusList[ MAX_STATUS_COUNT ]; diff --git a/src/core/modules.cpp b/src/core/modules.cpp index d1636a09a0..d33fc47a84 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -146,7 +146,14 @@ int LoadDefaultModules(void) if ( LoadIgnoreModule()) return 1; if ( LoadVisibilityModule()) return 1; - if ( !pluginDefault[ 0].pImpl) if ( LoadUserInfoModule()) return 1; + for (int i=0; i < 1; i++) { + if ( pluginDefault[i].pImpl ) + continue; + + if ( !LoadCorePlugin(pluginDefault[i])) + return 1; + } + if ( !pluginDefault[ 1].pImpl) if ( LoadSendRecvUrlModule()) return 1; if ( !pluginDefault[ 2].pImpl) if ( LoadSendRecvEMailModule()) return 1; if ( !pluginDefault[ 3].pImpl) if ( LoadSendRecvAuthModule()) return 1; @@ -157,6 +164,7 @@ int LoadDefaultModules(void) if ( !pluginDefault[ 8].pImpl) if ( LoadAutoAwayModule()) return 1; if ( !pluginDefault[ 9].pImpl) if ( LoadUserOnlineModule()) return 1; if ( !pluginDefault[10].pImpl) if ( LoadUpdateNotifyModule()) return 1; + return 0; } diff --git a/src/core/stdplug.h b/src/core/stdplug.h new file mode 100644 index 0000000000..269eeeba3d --- /dev/null +++ b/src/core/stdplug.h @@ -0,0 +1,23 @@ + +#ifdef _STATIC + #define MIRANDA_EXE_FUNC(T) extern "C" T __declspec(dllexport) +#else + #define MIRANDA_EXE_FUNC(T) extern "C" T __declspec(dllimport) +#endif + +MIRANDA_EXE_FUNC(HICON) LoadSkinProtoIcon(const char* szProto, int status, bool big = false); +MIRANDA_EXE_FUNC(HICON) LoadSkinIcon(int idx, bool big = false); +MIRANDA_EXE_FUNC(HANDLE) GetSkinIconHandle(int idx); + +MIRANDA_EXE_FUNC(HANDLE) IcoLib_AddNewIcon(int hLangpack, SKINICONDESC* sid); +MIRANDA_EXE_FUNC(HICON) IcoLib_GetIcon(const char* pszIconName, bool big); +MIRANDA_EXE_FUNC(HICON) IcoLib_GetIconByHandle(HANDLE hItem, bool big); +MIRANDA_EXE_FUNC(HANDLE) IcoLib_IsManaged(HICON hIcon); +MIRANDA_EXE_FUNC(int) IcoLib_ReleaseIcon(HICON hIcon, char* szIconName, bool big=false); + +MIRANDA_EXE_FUNC(void) Button_SetIcon_IcoLib(HWND hDlg, int itemId, int iconId, const char* tooltip); +MIRANDA_EXE_FUNC(void) Button_FreeIcon_IcoLib(HWND hDlg, int itemId); + +MIRANDA_EXE_FUNC(void) Window_SetIcon_IcoLib(HWND hWnd, int iconId); +MIRANDA_EXE_FUNC(void) Window_SetProtoIcon_IcoLib(HWND hWnd, const char* szProto, int iconId); +MIRANDA_EXE_FUNC(void) Window_FreeIcon_IcoLib(HWND hWnd); diff --git a/src/core/stduserinfo/commonheaders.cpp b/src/core/stduserinfo/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stduserinfo/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stduserinfo/commonheaders.h b/src/core/stduserinfo/commonheaders.h new file mode 100644 index 0000000000..b3fdcb29f3 --- /dev/null +++ b/src/core/stduserinfo/commonheaders.h @@ -0,0 +1,96 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; + +typedef HRESULT (STDAPICALLTYPE *pfnEnableThemeDialogTexture)(HWND hwnd, DWORD dwFlags); +extern pfnEnableThemeDialogTexture enableThemeDialogTexture; diff --git a/src/core/stduserinfo/contactinfo.cpp b/src/core/stduserinfo/contactinfo.cpp new file mode 100644 index 0000000000..031a9e40ab --- /dev/null +++ b/src/core/stduserinfo/contactinfo.cpp @@ -0,0 +1,528 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "commonheaders.h" + +static HFONT hEmailFont = NULL; +static HCURSOR hHandCursor = NULL; + +static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + if (*(char*)lParam) SetWindowText(hwndDlg, TranslateT("Edit E-Mail Address")); + TranslateDialogDefault(hwndDlg); + SetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)lParam); + EnableWindow(GetDlgItem(hwndDlg, IDOK), *(char*)lParam); + return TRUE; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDOK: + GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256); + //fall through + case IDCANCEL: + EndDialog(hwndDlg, wParam); + case IDC_EMAIL: + if (HIWORD(wParam) == EN_CHANGE) + EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EMAIL))); + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int noRecursion = 0; + + switch(msg) { + case WM_INITDIALOG: + { + char *szText = (char*)lParam; + int i, item, countryCount; + struct CountryListEntry *countries; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); + if (szText[0]) SetWindowText(hwndDlg, TranslateT("Edit Phone Number")); + TranslateDialogDefault(hwndDlg); + if (lstrlenA(szText)>4 && !lstrcmpA(szText+lstrlenA(szText)-4, " SMS")) { + CheckDlgButton(hwndDlg, IDC_SMS, BST_CHECKED); + szText[lstrlenA(szText)-4] = '\0'; + } + EnableWindow(GetDlgItem(hwndDlg, IDOK), szText[0]); + SendDlgItemMessage(hwndDlg, IDC_AREA, EM_LIMITTEXT, 31, 0); + SendDlgItemMessage(hwndDlg, IDC_NUMBER, EM_LIMITTEXT, 63, 0); + CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); + for (i=0;i 4) + isValid = 0; + else { + for (i = SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0)-1; i >= 0; i--) + if (country == SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, i, 0)) { + SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, i, 0); + break; + } + if (i < 0) + isValid = 0; + } + } + if (isValid) { + pArea = pText+strcspn(pText, "0123456789"); + pText = pArea+strspn(pArea, "0123456789"); + if (*pText) { + *pText = '\0'; + pNumber = pText+1+strcspn(pText+1, "0123456789"); + SetDlgItemTextA(hwndDlg, IDC_NUMBER, pNumber); + } + SetDlgItemTextA(hwndDlg, IDC_AREA, pArea); + } + if ( !isValid) { + SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, -1, 0); + SetDlgItemTextA(hwndDlg, IDC_AREA, ""); + SetDlgItemTextA(hwndDlg, IDC_NUMBER, ""); + } + } + noRecursion = 0; + EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PHONE))); + break; + } + break; + } + return FALSE; +} + +static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) +{ + RECT rc; + HWND hwndEmails; + TCHAR szText[256]; + HDC hdc; + SIZE textSize; + LVHITTESTINFO hti; + + hwndEmails = GetDlgItem(hwndDlg, IDC_EMAILS); + GetCursorPos(&hti.pt); + ScreenToClient(hwndEmails, &hti.pt); + GetClientRect(hwndEmails, &rc); + if ( !PtInRect(&rc, hti.pt)) return 0; + if (ListView_SubItemHitTest(hwndEmails, &hti) == -1) return 0; + if (hti.iSubItem != 1) return 0; + if ( !(hti.flags&LVHT_ONITEMLABEL)) return 0; + ListView_GetSubItemRect(hwndEmails, hti.iItem, 1, LVIR_LABEL, &rc); + szText[0] = 0; + ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, SIZEOF(szText)); + hdc = GetDC(hwndEmails); + SelectObject(hdc, hEmailFont); + GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textSize); + ReleaseDC(hwndEmails, hdc); + if (hti.pt.x4 && !lstrcmpA(dbv.pszVal+lstrlenA(dbv.pszVal)-4, " SMS")) { + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); + dbv.ptszVal[lstrlen(dbv.ptszVal)-4] = '\0'; + } + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + DBFreeVariant(&dbv); + lvi.iItem++; + } + if ( !DBGetContactSettingTString(hContact, szProto, "CompanyPhone", &dbv)) { + lvi.pszText = TranslateT("Work Phone"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + DBFreeVariant(&dbv); + lvi.iItem++; + } + if ( !DBGetContactSettingTString(hContact, szProto, "CompanyFax", &dbv)) { + lvi.pszText = TranslateT("Work Fax"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + DBFreeVariant(&dbv); + lvi.iItem++; + } + lvi.iSubItem = 0; + for (i=0;; i++) { + lvi.lParam = i; + mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d", i); + if (DBGetContactSettingTString(hContact, "UserInfo", idstr, &dbv)) + break; + lvi.pszText = idstr2; + mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + if (lstrlen(dbv.ptszVal)>4 && !lstrcmp(dbv.ptszVal+lstrlen(dbv.ptszVal)-4, _T(" SMS"))) { + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); + dbv.ptszVal[lstrlen(dbv.ptszVal)-4] = '\0'; + } + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); + DBFreeVariant(&dbv); + lvi.iItem++; + } + lvi.mask = LVIF_PARAM; + lvi.lParam = (LPARAM)(-2); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + } + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + break; + + case IDC_EMAILS: + case IDC_PHONES: + switch (((LPNMHDR)lParam)->code) { + case NM_CUSTOMDRAW: + { + NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW*)lParam; + switch(nm->nmcd.dwDrawStage) { + case CDDS_PREPAINT: + case CDDS_ITEMPREPAINT: + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW); + return TRUE; + case CDDS_SUBITEM|CDDS_ITEMPREPAINT: + { + RECT rc; + ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc); + if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) { + HFONT hoFont; + TCHAR szText[256] = {0}; + ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); + hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont); + SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255)); + DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); + SelectObject(nm->nmcd.hdc, hoFont); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); + return TRUE; + } + + HICON hIcon = NULL; + if (nm->nmcd.lItemlParam == (LPARAM)(-2) && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES)) + hIcon = LoadSkinIcon(SKINICON_OTHER_ADDCONTACT); + else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != (LPARAM)(-1) && nm->nmcd.lItemlParam != (LPARAM)(-2)) { + static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE}; + if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) { + TCHAR szText[2]; + ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); + if (szText[0]) hIcon = LoadSkinIcon(SKINICON_OTHER_SMS); + } + else hIcon = LoadSkinIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]); + } + else break; + DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + IcoLib_ReleaseIcon(hIcon, 0); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); + return TRUE; + } + } + } + break; + + case NM_CLICK: + { + NMLISTVIEW *nm = (NMLISTVIEW*)lParam; + LVITEM lvi; + TCHAR szEmail[256]; + HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + char *szIdTemplate = nm->hdr.idFrom == IDC_PHONES?"MyPhone%d":"Mye-mail%d"; + LVHITTESTINFO hti; + + if (IsOverEmail(hwndDlg, szEmail, SIZEOF(szEmail))) { + TCHAR szExec[264]; + mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); + ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); + break; + } + if (nm->iSubItem<2) break; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(nm->hdr.hwndFrom, &hti.pt); + if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break; + lvi.mask = LVIF_PARAM; + lvi.iItem = hti.iItem; + lvi.iSubItem = 0; + ListView_GetItem(nm->hdr.hwndFrom, &lvi); + if (lvi.lParam == (LPARAM)(-1)) break; + if (lvi.lParam == (LPARAM)(-2)) { + if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { + //add + char szNewData[256] = "", idstr[33]; + DBVARIANT dbv; + if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData)) + break; + for (int i=0;; i++) { + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); + if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break; + DBFreeVariant(&dbv); + } + DBWriteContactSettingString(hContact, "UserInfo", idstr, szNewData); + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + } + } + else { + if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { + //delete + int i; + char idstr[33]; + DBVARIANT dbv; + for (i = lvi.lParam;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i+1); + if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break; + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); + DBWriteContactSettingString(hContact, "UserInfo", idstr, dbv.pszVal); + DBFreeVariant(&dbv); + } + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); + DBDeleteContactSetting(hContact, "UserInfo", idstr); + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + } + else if (hti.iSubItem-2 == (nm->hdr.idFrom == IDC_PHONES)) { + //edit + char szText[256], idstr[33]; + DBVARIANT dbv; + mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, lvi.lParam); + if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break; + lstrcpynA(szText, dbv.pszVal, SIZEOF(szText)); + DBFreeVariant(&dbv); + if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText)) + break; + DBWriteContactSettingString(hContact, "UserInfo", idstr, szText); + SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); + } + } + break; + } + } + break; + } + break; + + case WM_SETCURSOR: + if (LOWORD(lParam) != HTCLIENT) break; + if (GetForegroundWindow() == GetParent(hwndDlg)) { + POINT pt; + GetCursorPos(&pt); + ScreenToClient(hwndDlg, &pt); + } + if (IsOverEmail(hwndDlg, NULL, 0)) { + SetCursor(hHandCursor); + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); + return TRUE; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + } + break; + } + return FALSE; +} diff --git a/src/core/stduserinfo/main.cpp b/src/core/stduserinfo/main.cpp new file mode 100644 index 0000000000..22420f0fa3 --- /dev/null +++ b/src/core/stduserinfo/main.cpp @@ -0,0 +1,90 @@ +/* + +Standard User Info plugin for Myranda IM + +Copyright (C) 2012 George Hazan + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "commonheaders.h" + +int LoadUserInfoModule(void); + +CLIST_INTERFACE* pcli; +TIME_API tmi; +HINSTANCE hInst; +int hLangpack; + +pfnEnableThemeDialogTexture enableThemeDialogTexture; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {8198DC94-0BC4-448A-8495-8FE832C1D333} + {0x8198dc94, 0xbc4, 0x448a, {0x84, 0x95, 0x8f, 0xe8, 0x32, 0xc1, 0xd3, 0x33 }} +}; + +static const MUUID interfaces[] = {MIID_UIUSERINFO, MIID_LAST}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +static int OnModulesLoaded(WPARAM, LPARAM) +{ + return 0; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getTMI(&tmi); + + pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + + if ( IsWinVerXPPlus()) { + HINSTANCE hThemeAPI = LoadLibraryA("uxtheme.dll"); + if (hThemeAPI) + enableThemeDialogTexture = (pfnEnableThemeDialogTexture)GetProcAddress(hThemeAPI, "EnableThemeDialogTexture"); + } + + LoadUserInfoModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stduserinfo/res/cursor_hyperlink.cur b/src/core/stduserinfo/res/cursor_hyperlink.cur new file mode 100644 index 0000000000..f0f548c828 Binary files /dev/null and b/src/core/stduserinfo/res/cursor_hyperlink.cur differ diff --git a/src/core/stduserinfo/resource.rc b/src/core/stduserinfo/resource.rc new file mode 100644 index 0000000000..4b2a37b640 --- /dev/null +++ b/src/core/stduserinfo/resource.rc @@ -0,0 +1,303 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Cursor +// + +IDC_HYPERLINKHAND CURSOR "res/cursor_hyperlink.cur" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ADDPHONE DIALOGEX 0, 0, 210, 91 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Add Phone Number" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Enter country, area code and phone number:",IDC_STATIC,5,5,200,8 + COMBOBOX IDC_COUNTRY,21,15,66,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_AREA,91,15,36,12,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_NUMBER,131,15,74,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "Or enter a full international number:",IDC_STATIC,5,30,200,8 + EDITTEXT IDC_PHONE,21,40,184,12,ES_AUTOHSCROLL + CONTROL "Phone can receive SMS text messages",IDC_SMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,56,200,10 + DEFPUSHBUTTON "OK",IDOK,47,72,50,14 + PUSHBUTTON "Cancel",IDCANCEL,113,72,50,14 +END + +IDD_ADDEMAIL DIALOGEX 0, 0, 187, 42 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Add E-Mail Address" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_EMAIL,5,5,177,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,36,23,50,14 + PUSHBUTTON "Cancel",IDCANCEL,102,23,50,14 +END + +IDD_DETAILS DIALOGEX 0, 0, 318, 210 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "%s: User Details" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "%s\nView personal user details and more",IDC_HEADERBAR, + "MHeaderbarCtrl",0x0,0,0,318,25 + CONTROL "",IDC_PAGETREE,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_TRACKSELECT | TVS_FULLROWSELECT | TVS_NONEVENHEIGHT | WS_HSCROLL | WS_TABSTOP,3,30,76,176,WS_EX_STATICEDGE + CONTROL "Tab1",IDC_TABS,"SysTabControl32",TCS_HOTTRACK | TCS_MULTILINE | WS_TABSTOP,85,29,228,158 + PUSHBUTTON "Update Now",IDC_UPDATE,85,191,55,14,WS_DISABLED + CTEXT "Updating",IDC_UPDATING,145,194,113,8,SS_NOPREFIX | SS_CENTERIMAGE + DEFPUSHBUTTON "OK",IDOK,263,191,50,14 +END + +IDD_INFO_SUMMARY DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Nickname:",IDC_STATIC,5,5,46,8 + EDITTEXT IDC_NICK,51,5,166,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "First name:",IDC_STATIC,5,18,46,8 + EDITTEXT IDC_FIRSTNAME,51,18,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Gender:",IDC_STATIC,126,18,44,8 + EDITTEXT IDC_GENDER,170,18,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Last name:",IDC_STATIC,5,31,46,8 + EDITTEXT IDC_LASTNAME,51,31,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Age:",IDC_STATIC,126,31,44,8 + EDITTEXT IDC_AGE,170,31,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "E-mail:",IDC_STATIC,5,44,46,8 + CONTROL "",IDC_EMAIL,"Hyperlink",WS_TABSTOP,51,44,166,8 + LTEXT "Date of birth:",IDC_STATIC,5,58,59,8 + EDITTEXT IDC_DOBDAY,66,58,8,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_DOBMONTH,76,58,16,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_DOBYEAR,94,58,20,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Marital status:",IDC_STATIC,5,71,76,8 + EDITTEXT IDC_MARITAL,83,71,87,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER +END + +IDD_INFO_CONTACT DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "E-mail:",IDC_STATIC,5,5,212,8 + CONTROL "List1",IDC_EMAILS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,14,212,50 + LTEXT "Phone:",IDC_STATIC,5,68,212,8 + CONTROL "List1",IDC_PHONES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,77,212,50 +END + +IDD_INFO_BACKGROUND DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Web page:",IDC_STATIC,5,5,44,8 + CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,49,5,168,8 + LTEXT "Past background:",IDC_STATIC,5,18,212,8 + CONTROL "List1",IDC_PAST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,27,212,44 + LTEXT "Interests:",IDC_STATIC,5,74,212,8 + CONTROL "List1",IDC_INTERESTS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,83,212,44 +END + +IDD_INFO_NOTES DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "About:",IDC_STATIC,5,5,212,8 + EDITTEXT IDC_ABOUT,5,13,212,45,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL + LTEXT "My notes:",IDC_STATIC,5,61,212,8 + EDITTEXT IDC_MYNOTES,5,69,212,58,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL +END + +IDD_INFO_LOCATION DIALOGEX 0, 0, 222, 147 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Street:",IDC_STATIC,5,5,51,8 + EDITTEXT IDC_STREET,56,5,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "City:",IDC_STATIC,5,22,51,8 + EDITTEXT IDC_CITY,56,22,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "State:",IDC_STATIC,5,33,51,8 + EDITTEXT IDC_STATE,56,33,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Postal code:",IDC_STATIC,5,44,51,8 + EDITTEXT IDC_ZIP,56,44,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Country:",IDC_STATIC,5,55,51,8 + EDITTEXT IDC_COUNTRY,56,55,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Spoken languages:",IDC_STATIC,5,70,51,16 + EDITTEXT IDC_LANGUAGE1,56,70,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_LANGUAGE2,56,78,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + EDITTEXT IDC_LANGUAGE3,56,86,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Timezone:",IDC_STATIC,5,97,51,8 + EDITTEXT IDC_TIMEZONE,56,97,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Local time:",IDC_STATIC,5,108,51,8 + EDITTEXT IDC_LOCALTIME,56,108,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + COMBOBOX IDC_TIMEZONESELECT,4,132,214,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Set custom time zone",IDC_STATIC,5,121,212,8 +END + +IDD_INFO_WORK DIALOGEX 0, 0, 222, 132 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "Company:",IDC_STATIC,5,5,51,8 + EDITTEXT IDC_COMPANY,56,5,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Department:",IDC_STATIC,5,17,51,8 + EDITTEXT IDC_DEPARTMENT,56,17,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Position:",IDC_STATIC,5,28,51,8 + EDITTEXT IDC_POSITION,56,28,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Street:",IDC_STATIC,5,48,51,8 + EDITTEXT IDC_STREET,56,48,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "City:",IDC_STATIC,5,65,51,8 + EDITTEXT IDC_CITY,56,65,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "State:",IDC_STATIC,5,76,51,8 + EDITTEXT IDC_STATE,56,76,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Postal code:",IDC_STATIC,5,87,51,8 + EDITTEXT IDC_ZIP,56,87,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Country:",IDC_STATIC,5,98,51,8 + EDITTEXT IDC_COUNTRY,56,98,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "Website:",IDC_STATIC,5,109,51,8 + CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,57,109,160,8 +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_INFO_CONTACT, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + END + + IDD_INFO_BACKGROUND, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 49 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + END + + IDD_INFO_NOTES, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + END + + IDD_INFO_LOCATION, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 56 + TOPMARGIN, 5 + BOTTOMMARGIN, 142 + HORZGUIDE, 22 + HORZGUIDE, 33 + HORZGUIDE, 45 + HORZGUIDE, 56 + HORZGUIDE, 70 + HORZGUIDE, 95 + HORZGUIDE, 106 + END + + IDD_INFO_WORK, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 217 + VERTGUIDE, 56 + VERTGUIDE, 126 + VERTGUIDE, 170 + TOPMARGIN, 5 + BOTTOMMARGIN, 127 + HORZGUIDE, 16 + HORZGUIDE, 27 + HORZGUIDE, 44 + HORZGUIDE, 61 + HORZGUIDE, 72 + HORZGUIDE, 83 + HORZGUIDE, 94 + HORZGUIDE, 105 + END + + IDD_ADDEMAIL, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 182 + TOPMARGIN, 5 + BOTTOMMARGIN, 37 + END + + IDD_ADDPHONE, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 205 + TOPMARGIN, 5 + BOTTOMMARGIN, 86 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED diff --git a/src/core/stduserinfo/stdinfo.cpp b/src/core/stduserinfo/stdinfo.cpp new file mode 100644 index 0000000000..008f2d0b74 --- /dev/null +++ b/src/core/stduserinfo/stdinfo.cpp @@ -0,0 +1,612 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "commonheaders.h" + +INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +#define SVS_NORMAL 0 +#define SVS_GENDER 1 +#define SVS_ZEROISUNSPEC 2 +#define SVS_IP 3 +#define SVS_COUNTRY 4 +#define SVS_MONTH 5 +#define SVS_SIGNED 6 +#define SVS_TIMEZONE 7 + +static int Proto_GetContactInfoSetting(HANDLE hContact, const char *szProto, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType) +{ + DBCONTACTGETSETTING cgs = {szModule, szSetting, dbv}; + dbv->type = (BYTE)nType; + + return CallProtoService(szProto, PS_GETINFOSETTING, (WPARAM)hContact, (LPARAM)&cgs); +} + +static void Proto_FreeInfoVariant(DBVARIANT *dbv) +{ + switch (dbv->type) { + case DBVT_ASCIIZ: + case DBVT_UTF8: + case DBVT_WCHAR: + { + mir_free(dbv->pszVal); + dbv->pszVal = 0; + break; + } + case DBVT_BLOB: + { + mir_free(dbv->pbVal); + dbv->pbVal = 0; + break; + } + } + dbv->type = 0; +} + +static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule, char *szSetting, int special) +{ + DBVARIANT dbv = { 0 }; + char str[80], *pstr = NULL; + TCHAR* ptstr = NULL; + int unspecified = 0; + char* szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + bool proto_service = szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC); + + dbv.type = DBVT_DELETED; + if (szModule == NULL) unspecified = 1; + else if (proto_service) unspecified = Proto_GetContactInfoSetting(hContact, szProto, szModule, szSetting, &dbv, 0); + else unspecified = DBGetContactSettingW(hContact, szModule, szSetting, &dbv); + if ( !unspecified) { + switch(dbv.type) { + case DBVT_BYTE: + if (special == SVS_GENDER) { + if (dbv.cVal == 'M') ptstr = TranslateT("Male"); + else if (dbv.cVal == 'F') ptstr = TranslateT("Female"); + else unspecified = 1; + } + else if (special == SVS_MONTH) { + if (dbv.bVal>0 && dbv.bVal <= 12) { + pstr = str; + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1+dbv.bVal, str, SIZEOF(str)); + } + else unspecified = 1; + } + else if (special == SVS_TIMEZONE) { + if (dbv.cVal == -100) unspecified = 1; + else { + pstr = str; + mir_snprintf(str, SIZEOF(str), dbv.cVal?"UTC%+d:%02d":"UTC", -dbv.cVal/2, (dbv.cVal&1)*30); + } + } + else { + unspecified = (special == SVS_ZEROISUNSPEC && dbv.bVal == 0); + pstr = _itoa(special == SVS_SIGNED?dbv.cVal:dbv.bVal, str, 10); + } + break; + case DBVT_WORD: + if (special == SVS_COUNTRY) { + WORD wSave = dbv.wVal; + if (wSave == (WORD)-1) { + char szSettingName[100]; + mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sName", szSetting); + if ( !DBGetContactSettingTString(hContact, szModule, szSettingName, &dbv)) { + ptstr = dbv.ptszVal; + unspecified = false; + break; + } + } + + pstr = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0)); + unspecified = pstr == NULL; + } + else { + unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0); + pstr = _itoa(special == SVS_SIGNED?dbv.sVal:dbv.wVal, str, 10); + } + break; + case DBVT_DWORD: + unspecified = (special == SVS_ZEROISUNSPEC && dbv.dVal == 0); + if (special == SVS_IP) { + struct in_addr ia; + ia.S_un.S_addr = htonl(dbv.dVal); + pstr = inet_ntoa(ia); + if (dbv.dVal == 0) unspecified = 1; + } + else pstr = _itoa(special == SVS_SIGNED?dbv.lVal:dbv.dVal, str, 10); + break; + case DBVT_ASCIIZ: + unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); + pstr = dbv.pszVal; + break; + case DBVT_UTF8: + unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); + if ( !unspecified) + { WCHAR* wszStr; + Utf8Decode(dbv.pszVal, &wszStr); + SetDlgItemTextW(hwndDlg, idCtrl, TranslateTS(wszStr)); + mir_free(wszStr); + goto LBL_Exit; + } + + pstr = dbv.pszVal; + Utf8Decode(dbv.pszVal, NULL); + break; + default: pstr = str; lstrcpyA(str, "???"); break; + } } + + if (unspecified) + SetDlgItemText(hwndDlg, idCtrl, TranslateT("")); + else if (ptstr != NULL) + SetDlgItemText(hwndDlg, idCtrl, ptstr); + else + SetDlgItemTextA(hwndDlg, idCtrl, pstr); + + +LBL_Exit: + + EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + DBFreeVariant(&dbv); +} + +static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + { char *szProto; + HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto == NULL) break; + SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0); + SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", 0); + SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", 0); + SetValue(hwndDlg, IDC_EMAIL, hContact, szProto, "e-mail", 0); + SetValue(hwndDlg, IDC_AGE, hContact, szProto, "Age", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER); + SetValue(hwndDlg, IDC_DOBDAY, hContact, szProto, "BirthDay", 0); + SetValue(hwndDlg, IDC_DOBMONTH, hContact, szProto, "BirthMonth", SVS_MONTH); + SetValue(hwndDlg, IDC_DOBYEAR, hContact, szProto, "BirthYear", 0); + SetValue(hwndDlg, IDC_MARITAL, hContact, szProto, "MaritalStatus", 0); + } } + break; + } + break; + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case IDC_EMAIL: + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) { + TCHAR szExec[264], szEmail[256]; + GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); + mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); + ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); + } + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + TranslateDialogDefault(hwndDlg); + SetTimer(hwndDlg, 1, 1000, NULL); + + tmi.prepareList((HANDLE)lParam, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); + SendMessage(hwndDlg, WM_TIMER, 0, 0); + break; + + case WM_TIMER: + { + HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + if (hContact != NULL) + { + TCHAR szTime[80]; + + if (tmi.printDateTimeByContact(hContact, _T("s"), szTime, SIZEOF(szTime), TZF_KNOWNONLY)) + { + EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE); + SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("")); + } + else + { + EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), TRUE); + SetDlgItemText(hwndDlg, IDC_LOCALTIME, szTime); + } + } + break; + } + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + { char *szProto; + HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto == NULL) break; + SetValue(hwndDlg, IDC_STREET, hContact, szProto, "Street", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_CITY, hContact, szProto, "City", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_STATE, hContact, szProto, "State", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "ZIP", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "Country", SVS_COUNTRY); + SetValue(hwndDlg, IDC_LANGUAGE1, hContact, szProto, "Language1", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_LANGUAGE2, hContact, szProto, "Language2", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_LANGUAGE3, hContact, szProto, "Language3", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_TIMEZONE, hContact, szProto, "Timezone", SVS_TIMEZONE); + } + } + break; + } + break; + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case IDC_TIMEZONESELECT: + if (HIWORD(wParam) == CBN_SELCHANGE) { + HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + tmi.storeListResults(hContact, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); + } + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + break; + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + { char *szProto; + HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto == NULL) break; + SetValue(hwndDlg, IDC_COMPANY, hContact, szProto, "Company", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_DEPARTMENT, hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_POSITION, hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_STREET, hContact, szProto, "CompanyStreet", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_CITY, hContact, szProto, "CompanyCity", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_STATE, hContact, szProto, "CompanyState", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "CompanyZIP", SVS_ZEROISUNSPEC); + SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "CompanyCountry", SVS_COUNTRY); + SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "CompanyHomepage", SVS_ZEROISUNSPEC); + } } + break; + } + break; + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case IDC_WEBPAGE: + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { + char szPage[256]; + GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); + CallService(MS_UTILS_OPENURL, 1, (LPARAM)szPage); + } + break; + } + break; + } + return FALSE; +} + +// Resizes all columns in a listview (report style) +// to make all text visible +void ResizeColumns(HWND hwndLV) +{ + int nCol = 0; LVCOLUMN lvCol; + lvCol.mask = LVCF_WIDTH; + while (ListView_GetColumn(hwndLV, nCol++, &lvCol)) + ListView_SetColumnWidth(hwndLV, nCol-1, LVSCW_AUTOSIZE); +} + +static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { LVCOLUMN lvc; + RECT rc; + GetClientRect(GetDlgItem(hwndDlg, IDC_PAST), &rc); + rc.right-=GetSystemMetrics(SM_CXVSCROLL); + lvc.mask = LVCF_WIDTH; + lvc.cx = rc.right/3; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 0, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 0, &lvc); + lvc.cx = rc.right-rc.right/3; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 1, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 1, &lvc); + } + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PAST), LVS_EX_LABELTIP, LVS_EX_LABELTIP); + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_INTERESTS), LVS_EX_LABELTIP, LVS_EX_LABELTIP); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) + { LVITEM lvi; + int i; + char idstr[33]; + DBVARIANT dbv, dbvText; + HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; + + if (hContact != NULL) { + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto == NULL) break; + bool proto_service = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC; + SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC); + + //past + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PAST)); + lvi.mask = LVIF_TEXT; + lvi.iSubItem = 0; + lvi.iItem = 0; + for (i=0;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), "Past%d", i); + if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || + ( !proto_service && DBGetContactSettingTString(hContact, szProto, idstr, &dbv))) + break; + mir_snprintf(idstr, SIZEOF(idstr), "Past%dText", i); + if (DBGetContactSettingTString(hContact, szProto, idstr, &dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} + lvi.pszText = dbv.ptszVal; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); + DBFreeVariant(&dbvText); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + DBFreeVariant(&dbv); + lvi.iItem++; + } + + for (i=0;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%d", i); + if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || + ( !proto_service && DBGetContactSettingTString(hContact, szProto, idstr, &dbv))) + break; + mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%dText", i); + if (DBGetContactSettingTString(hContact, szProto, idstr, &dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} + lvi.pszText = dbv.ptszVal; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); + DBFreeVariant(&dbvText); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + DBFreeVariant(&dbv); + lvi.iItem++; + } + + ResizeColumns(GetDlgItem(hwndDlg, IDC_PAST)); + + //interests + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_INTERESTS)); + lvi.mask = LVIF_TEXT; + lvi.iSubItem = 0; + lvi.iItem = 0; + for (i=0;;i++) { + mir_snprintf(idstr, SIZEOF(idstr), "Interest%dCat", i); + if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || + ( !proto_service && DBGetContactSettingTString(hContact, szProto, idstr, &dbv))) + break; + mir_snprintf(idstr, SIZEOF(idstr), "Interest%dText", i); + if (DBGetContactSettingTString(hContact, szProto, idstr, &dbvText)) + {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} + lvi.pszText = dbv.ptszVal; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_INTERESTS), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_INTERESTS), lvi.iItem, 1, dbvText.ptszVal); + DBFreeVariant(&dbvText); + if (proto_service) + Proto_FreeInfoVariant(&dbv); + else + DBFreeVariant(&dbv); + lvi.iItem++; + } + ResizeColumns(GetDlgItem(hwndDlg, IDC_INTERESTS)); + } } + break; + } + break; + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case IDC_WEBPAGE: + if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { + char szPage[256]; + GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); + CallService(MS_UTILS_OPENURL, 1, (LPARAM)szPage); + } + break; + } + break; + } + return FALSE; +} + +static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { DBVARIANT dbv; + HFONT hFont; + LOGFONT lf; + HDC hDC = GetDC(hwndDlg); + lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72); + ReleaseDC(hwndDlg, hDC); + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = FW_NORMAL; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + lstrcpy(lf.lfFaceName, _T("Courier New")); + lf.lfCharSet = DEFAULT_CHARSET; +// hFont = (HFONT) GetStockObject(ANSI_FIXED_FONT); + hFont = CreateFontIndirect(&lf); + SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0)); + + if ( !DBGetContactSettingString((HANDLE)lParam, "UserInfo", "MyNotes", &dbv)) { + SetDlgItemTextA(hwndDlg, IDC_MYNOTES, dbv.pszVal); + DBFreeVariant(&dbv); + } + } + SendDlgItemMessage(hwndDlg, IDC_MYNOTES, EM_LIMITTEXT, 2048, 0); + break; + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_INFOCHANGED: + { char *szProto; + HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; + if (hContact != NULL) { + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto == NULL) break; + SetValue(hwndDlg, IDC_ABOUT, hContact, szProto, "About", 0); + } + break; + } + case PSN_APPLY: + { HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam; + if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) { + char text[2048]; + GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text)); + DBWriteContactSettingString(hContact, "UserInfo", "MyNotes", text); + } + else DBDeleteContactSetting(hContact, "UserInfo", "MyNotes"); + break; + } + } + break; + } + break; + case WM_COMMAND: + if (wParam == MAKEWPARAM(IDC_MYNOTES, EN_CHANGE)) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + else if (LOWORD(wParam) == IDCANCEL) + SendMessage(GetParent(hwndDlg), msg, wParam, lParam); + break; + case WM_DESTROY: + { + HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_GETFONT, 0, 0); + DeleteObject(hFont); + } + break; + } + return FALSE; +} + +int DetailsInit(WPARAM wParam, LPARAM lParam) +{ + if (lParam == NULL) + return 0; + + if (CallService(MS_PROTO_GETCONTACTBASEPROTO, lParam, 0) == 0) + return 0; + + OPTIONSDIALOGPAGE odp; + odp.cbSize = sizeof(odp); + odp.hIcon = NULL; + odp.hInstance = hInst; + odp.flags = 0; + + odp.pfnDlgProc = SummaryDlgProc; + odp.position = -2100000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SUMMARY); + odp.pszTitle = LPGEN("Summary"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = ContactDlgProc; + odp.position = -1800000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_CONTACT); + odp.pszTitle = LPGEN("Contact"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = LocationDlgProc; + odp.position = -1500000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_LOCATION); + odp.pszTitle = LPGEN("Location"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = WorkDlgProc; + odp.position = -1200000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_WORK); + odp.pszTitle = LPGEN("Work"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = BackgroundDlgProc; + odp.position = -900000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_BACKGROUND); + odp.pszTitle = LPGEN("Background info"); + UserInfo_AddPage(wParam, &odp); + + odp.pfnDlgProc = NotesDlgProc; + odp.position = 0; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_NOTES); + odp.pszTitle = LPGEN("Notes"); + UserInfo_AddPage(wParam, &odp); + return 0; +} diff --git a/src/core/stduserinfo/stduserinfo_10.vcxproj b/src/core/stduserinfo/stduserinfo_10.vcxproj new file mode 100644 index 0000000000..af6d086e6d --- /dev/null +++ b/src/core/stduserinfo/stduserinfo_10.vcxproj @@ -0,0 +1,218 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stduserinfo + {1C856B14-54CD-4D07-B18B-5F7DB073AB51} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stduserinfo/stduserinfo_10.vcxproj.filters b/src/core/stduserinfo/stduserinfo_10.vcxproj.filters new file mode 100644 index 0000000000..ac101b1384 --- /dev/null +++ b/src/core/stduserinfo/stduserinfo_10.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stduserinfo/userinfo.cpp b/src/core/stduserinfo/userinfo.cpp new file mode 100644 index 0000000000..a36c134106 --- /dev/null +++ b/src/core/stduserinfo/userinfo.cpp @@ -0,0 +1,629 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "commonheaders.h" + +#define UPDATEANIMFRAMES 20 + +int DetailsInit(WPARAM wParam, LPARAM lParam); +static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +static HANDLE hWindowList = NULL; +static HANDLE hDetailsInitEvent; + +struct DetailsPageInit { + int pageCount; + OPTIONSDIALOGPAGE *odp; +}; + +struct DetailsPageData { + DLGTEMPLATE *pTemplate; + HINSTANCE hInst; + DLGPROC dlgProc; + LPARAM dlgParam; + HWND hwnd; + HTREEITEM hItem; + int changed; + TCHAR *ptszTitle, *ptszTab; +}; + +struct DetailsData { + HANDLE hContact; + HANDLE hProtoAckEvent; + HINSTANCE hInstIcmp; + HFONT hBoldFont; + int pageCount; + int currentPage; + struct DetailsPageData *opd; + RECT rcDisplay, rcDisplayTab; + int updateAnimFrame; + TCHAR szUpdating[64]; + int *infosUpdated; +}; + +static int PageSortProc(OPTIONSDIALOGPAGE *item1, OPTIONSDIALOGPAGE *item2) +{ + int res; + if ( !lstrcmp(item1->ptszTitle, TranslateT("Summary"))) return -1; + if ( !lstrcmp(item2->ptszTitle, TranslateT("Summary"))) return 1; + if (res = lstrcmp(item1->ptszTitle, item2->ptszTitle)) return res; + if (item1->ptszTab && !item2->ptszTab) return -1; + if ( !item1->ptszTab && item2->ptszTab) return 1; + if ( !item1->ptszTab && !item2->ptszTab) return 0; + if (item1->ptszTab && !lstrcmp(item1->ptszTab, TranslateT("General"))) return -1; + if (item2->ptszTab && !lstrcmp(item2->ptszTab, TranslateT("General"))) return 1; + return lstrcmp(item1->ptszTab, item2->ptszTab); +} + +static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM) +{ + HWND hwnd; + PROPSHEETHEADER psh; + struct DetailsPageInit opi; + int i; + + if (hwnd = WindowList_Find(hWindowList, (HANDLE)wParam)) { + SetForegroundWindow(hwnd); + SetFocus(hwnd); + return 0; + } + + opi.pageCount = 0; + opi.odp = NULL; + NotifyEventHooks(hDetailsInitEvent, (WPARAM)&opi, wParam); + if (opi.pageCount == 0) return 0; + qsort(opi.odp, opi.pageCount, sizeof(OPTIONSDIALOGPAGE), (int (*)(const void*, const void*))PageSortProc); + + ZeroMemory(&psh, sizeof(psh)); + psh.dwSize = sizeof(psh); + psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW; + psh.hwndParent = NULL; + psh.nPages = opi.pageCount; + psh.pStartPage = 0; + psh.pszCaption = (TCHAR*)wParam; //more abuses of structure: this is hContact + psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell + + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh); + for (i=0;icbSize != sizeof(OPTIONSDIALOGPAGE)) + return 1; + + opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1)); + dst = opi->odp + opi->pageCount; + dst->cbSize = sizeof(OPTIONSDIALOGPAGE); + dst->hInstance = odp->hInstance; + dst->pfnDlgProc = odp->pfnDlgProc; + dst->position = odp->position; + if ((DWORD_PTR)odp->pszTemplate&0xFFFF0000) dst->pszTemplate = mir_strdup(odp->pszTemplate); + else dst->pszTemplate = odp->pszTemplate; + + + if (odp->flags & ODPF_UNICODE) + { + dst->ptszTitle = (odp->ptszTitle == 0) ? NULL : mir_wstrdup(odp->ptszTitle); + dst->ptszTab = ( !(odp->flags & ODPF_USERINFOTAB) || !odp->ptszTab) ? NULL : mir_wstrdup(odp->ptszTab); + } + else + + { + if (odp->flags & ODPF_DONTTRANSLATE) + dst->ptszTitle = (odp->pszTitle == 0) ? NULL : mir_a2t(odp->pszTitle); + else + dst->ptszTitle = (odp->pszTitle == 0) ? NULL : Langpack_PcharToTchar(odp->pszTitle); + dst->ptszTab = ( !(odp->flags & ODPF_USERINFOTAB) || !odp->pszTab) ? NULL : Langpack_PcharToTchar(odp->pszTab); + } + + dst->pszGroup = NULL; + dst->groupPosition = odp->groupPosition; + dst->hGroupIcon = odp->hGroupIcon; + dst->hIcon = odp->hIcon; + if (odp->cbSize == sizeof(OPTIONSDIALOGPAGE)) + dst->dwInitParam = odp->dwInitParam; + opi->pageCount++; + return 0; +} + +static void ThemeDialogBackground(HWND hwnd) +{ + if (enableThemeDialogTexture) + enableThemeDialogTexture(hwnd, ETDT_ENABLETAB); +} + +static void CreateDetailsTabs(HWND hwndDlg, struct DetailsData* dat, struct DetailsPageData* ppg) +{ + HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); + int i, sel = 0, pages = 0; + TCITEM tie; + tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; + tie.iImage = -1; + TabCtrl_DeleteAllItems(hwndTab); + for (i=0; i < dat->pageCount; i++) { + if ( !dat->opd[i].ptszTab || lstrcmp(dat->opd[i].ptszTitle, ppg->ptszTitle)) continue; + + tie.pszText = TranslateTS(dat->opd[i].ptszTab); + tie.lParam = i; + TabCtrl_InsertItem(hwndTab, pages, &tie); + if ( !lstrcmp(dat->opd[i].ptszTab, ppg->ptszTab)) + sel = pages; + pages++; + } + TabCtrl_SetCurSel(hwndTab, sel); + + LONG style = GetWindowLongPtr(hwndTab, GWL_STYLE); + SetWindowLongPtr(hwndTab, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP); +} + +static void CreateDetailsPageWindow(HWND hwndDlg, struct DetailsData* dat, struct DetailsPageData* ppg) +{ + RECT *rc = ppg->ptszTab ? &dat->rcDisplayTab : &dat->rcDisplay; + ppg->hwnd = CreateDialogIndirectParam(ppg->hInst, ppg->pTemplate, hwndDlg, ppg->dlgProc, (LPARAM)dat->hContact); + ThemeDialogBackground(ppg->hwnd); + SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); + SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); + { + PSHNOTIFY pshn; + pshn.hdr.code = PSN_PARAMCHANGED; + pshn.hdr.hwndFrom = ppg->hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)ppg->dlgParam; + SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + + pshn.hdr.code = PSN_INFOCHANGED; + pshn.hdr.hwndFrom = ppg->hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + } +} + +static int UserInfoContactDelete(WPARAM wParam, LPARAM) +{ + HWND hwnd; + hwnd = WindowList_Find(hWindowList, (HANDLE)wParam); + if (hwnd != NULL) DestroyWindow(hwnd); + return 0; +} + +#define HM_PROTOACK (WM_USER+10) +#define M_CHECKONLINE (WM_USER+11) +static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + struct DetailsData *dat = (struct DetailsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_USERDETAILS); + { + PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam; + dat = (DetailsData*)mir_calloc(sizeof(DetailsData)); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + dat->hContact = (HANDLE)psh->pszCaption; + dat->hProtoAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_PROTOACK); + WindowList_Add(hWindowList, hwndDlg, dat->hContact); + { + TCHAR *name, oldTitle[256], newTitle[256]; + if (dat->hContact == NULL) + name = TranslateT("Owner"); + else + name = pcli->pfnGetContactDisplayName(dat->hContact, 0); + + GetWindowText(hwndDlg, oldTitle, SIZEOF(oldTitle)); + mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); + SetWindowText(hwndDlg, newTitle); + + GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); + mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); + SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); + } + { LOGFONT lf; + HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_NAME, WM_GETFONT, 0, 0); + GetObject(hNormalFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + dat->hBoldFont = CreateFontIndirect(&lf); + SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, (WPARAM)dat->hBoldFont, 0); + } + { OPTIONSDIALOGPAGE *odp; + int i; + TVINSERTSTRUCT tvis; + DBVARIANT dbv; + + HWND hwndTree = GetDlgItem(hwndDlg, IDC_PAGETREE); + + dat->currentPage = 0; + if (DBGetContactSettingTString(NULL, "UserInfo", "LastTab", &dbv)) + dbv.type = DBVT_DELETED; + dat->pageCount = psh->nPages; + dat->opd = (DetailsPageData*)mir_calloc(sizeof(DetailsPageData) * dat->pageCount); + odp = (OPTIONSDIALOGPAGE*)psh->ppsp; + + for (i=0; i < dat->pageCount; i++) { + dat->opd[i].pTemplate = (LPDLGTEMPLATE)LockResource(LoadResource(odp[i].hInstance, + FindResourceA(odp[i].hInstance, odp[i].pszTemplate, MAKEINTRESOURCEA(5)))); + dat->opd[i].dlgProc = odp[i].pfnDlgProc; + dat->opd[i].dlgParam = odp[i].dwInitParam; + dat->opd[i].hInst = odp[i].hInstance; + + dat->opd[i].ptszTitle = odp[i].ptszTitle; + dat->opd[i].ptszTab = odp[i].ptszTab; + + if (i && dat->opd[i].ptszTab && !lstrcmp(dat->opd[i-1].ptszTitle, dat->opd[i].ptszTitle)) { + dat->opd[i].hItem = dat->opd[i-1].hItem; + continue; + } + + tvis.hParent = NULL; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_TEXT | TVIF_PARAM; + tvis.item.lParam = (LPARAM) i; + if (odp[i].flags & ODPF_DONTTRANSLATE) + tvis.item.pszText = mir_tstrdup(odp[i].ptszTitle); + else + tvis.item.pszText = TranslateTS(odp[i].ptszTitle); + if (dbv.type != DBVT_DELETED && !lstrcmp(tvis.item.pszText, dbv.ptszVal)) + dat->currentPage = i; + dat->opd[i].hItem = TreeView_InsertItem(hwndTree, &tvis); + } + DBFreeVariant(&dbv); + } + + { + HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); + + TCITEM tci; + tci.mask = TCIF_TEXT | TCIF_IMAGE; + tci.iImage = -1; + tci.pszText = _T("X"); + TabCtrl_InsertItem(hwndTab, 0, &tci); + + GetWindowRect(hwndTab, &dat->rcDisplayTab); + TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplayTab); + { POINT pt = {0, 0}; + ClientToScreen(hwndDlg, &pt); + OffsetRect(&dat->rcDisplayTab, -pt.x, -pt.y); + } + + TabCtrl_DeleteAllItems(hwndTab); + + GetWindowRect(hwndTab, &dat->rcDisplay); + TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplay); + { POINT pt = {0, 0}; + ClientToScreen(hwndDlg, &pt); + OffsetRect(&dat->rcDisplay, -pt.x, -pt.y); + } } + + TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_PAGETREE), dat->opd[dat->currentPage].hItem); + + dat->updateAnimFrame = 0; + GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, SIZEOF(dat->szUpdating)); + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + if ( !CallContactService(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); + SetTimer(hwndDlg, 1, 100, NULL); + } else + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); + + SetFocus(GetDlgItem(hwndDlg, IDC_PAGETREE)); + + return TRUE; + } + case WM_TIMER: + { + TCHAR str[128]; + mir_sntprintf(str, SIZEOF(str), _T("%.*s%s%.*s"), dat->updateAnimFrame%10, _T("........."), dat->szUpdating, dat->updateAnimFrame%10, _T(".........")); + SetDlgItemText(hwndDlg, IDC_UPDATING, str); + if (++dat->updateAnimFrame == UPDATEANIMFRAMES) dat->updateAnimFrame = 0; + break; + } + case WM_CTLCOLORSTATIC: + switch (GetDlgCtrlID((HWND)lParam)) { + case IDC_WHITERECT: + SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); + return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); + case IDC_UPDATING: + { + COLORREF textCol, bgCol, newCol; + int ratio; + textCol = GetSysColor(COLOR_BTNTEXT); + bgCol = GetSysColor(COLOR_3DFACE); + ratio = abs(UPDATEANIMFRAMES/2-dat->updateAnimFrame)*510/UPDATEANIMFRAMES; + newCol = RGB(GetRValue(bgCol)+(GetRValue(textCol)-GetRValue(bgCol))*ratio/256, + GetGValue(bgCol)+(GetGValue(textCol)-GetGValue(bgCol))*ratio/256, + GetBValue(bgCol)+(GetBValue(textCol)-GetBValue(bgCol))*ratio/256); + SetTextColor((HDC)wParam, newCol); + SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE)); + return (INT_PTR)GetSysColorBrush(COLOR_3DFACE); + } + default: + SetBkMode((HDC)wParam, TRANSPARENT); + return (INT_PTR)GetStockObject(NULL_BRUSH); + } + break; + + case PSM_CHANGED: + dat->opd[dat->currentPage].changed = 1; + return TRUE; + + case PSM_FORCECHANGED: + { + int i; + PSHNOTIFY pshn; + pshn.hdr.code = PSN_INFOCHANGED; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + for (i=0;ipageCount;i++) { + pshn.hdr.hwndFrom = dat->opd[i].hwnd; + if (dat->opd[i].hwnd != NULL) + SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + } + break; + } + case M_CHECKONLINE: + { + char *szProto; + if (dat->hContact != NULL) { + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + if (szProto == NULL) {EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); break;} + if (CallProtoService(szProto, PS_GETSTATUS, 0, 0)hContact == NULL && ack->type == ACKTYPE_STATUS) { + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + break; + } + if (ack->hContact != dat->hContact) break; + if (ack->type != ACKTYPE_GETINFO) break; + SendMessage(hwndDlg, PSM_FORCECHANGED, 0, 0); + /* if they're not gonna send any more ACK's don't let that mean we should crash */ + if ( !ack->hProcess && !ack->lParam) { + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); + KillTimer(hwndDlg, 1); + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + break; + } //if + if (dat->infosUpdated == NULL) dat->infosUpdated = (int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); + if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED) dat->infosUpdated[ack->lParam] = 1; + for (i=0;i<(int)ack->hProcess;i++) + if (dat->infosUpdated[i] == 0) break; + if (i == (int)ack->hProcess) { + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); + KillTimer(hwndDlg, 1); + SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); + } } + break; + + case WM_NOTIFY: + switch(wParam) { + case IDC_TABS: + case IDC_PAGETREE: + switch(((LPNMHDR)lParam)->code) { + case TCN_SELCHANGING: + case TVN_SELCHANGING: + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) { + PSHNOTIFY pshn; + pshn.hdr.code = PSN_KILLACTIVE; + pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) { + SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); + return TRUE; + } + } + break; + + case TCN_SELCHANGE: + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) { + HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); + + TCITEM tie; + TVITEM tvi; + + tie.mask = TCIF_PARAM; + TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tie); + dat->currentPage = tie.lParam; + + tvi.hItem = TreeView_GetNextItem(GetDlgItem(hwndDlg, IDC_PAGETREE), NULL, TVGN_CARET); + tvi.mask = TVIF_PARAM; + tvi.lParam = dat->currentPage; + TreeView_SetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); + + if (dat->currentPage != -1) { + if (dat->opd[dat->currentPage].hwnd == NULL) + CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); + } + } + break; + + case TVN_SELCHANGED: + if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); + { + LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam; + TVITEM tvi = pnmtv->itemNew; + dat->currentPage = tvi.lParam; + + if (dat->currentPage != -1) { + CreateDetailsTabs(hwndDlg, dat, &dat->opd[dat->currentPage]); + if (dat->opd[dat->currentPage].hwnd == NULL) + CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); + + } + } + break; + } + break; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDCANCEL: + { + PSHNOTIFY pshn; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + pshn.hdr.code = PSN_RESET; + for (int i=0; i < dat->pageCount; i++) { + if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; + pshn.hdr.hwndFrom = dat->opd[i].hwnd; + SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); + } + DestroyWindow(hwndDlg); + } + break; + + case IDOK: + { + PSHNOTIFY pshn; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)dat->hContact; + if (dat->currentPage != -1) { + pshn.hdr.code = PSN_KILLACTIVE; + pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; + if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) + break; + } + + pshn.hdr.code = PSN_APPLY; + for (int i=0; i < dat->pageCount;i++) { + if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; + pshn.hdr.hwndFrom = dat->opd[i].hwnd; + if (SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) { + TreeView_Select(GetDlgItem(hwndDlg, IDC_PAGETREE), dat->opd[i].hItem, TVGN_CARET); + if (dat->currentPage != -1) ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); + dat->currentPage = i; + ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); + return 0; + } + } + DestroyWindow(hwndDlg); + } + break; + + case IDC_UPDATE: + if (dat->infosUpdated != NULL) {mir_free(dat->infosUpdated); dat->infosUpdated = NULL;} + if (dat->hContact != NULL) { + if ( !CallContactService(dat->hContact, PSS_GETINFO, 0, 0)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); + ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_SHOW); + SetTimer(hwndDlg, 1, 100, NULL); + } + } + break; + } + break; + + case WM_CLOSE: + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); + break; + + case WM_DESTROY: + { + TCHAR name[128]; + TVITEM tvi; + tvi.mask = TVIF_TEXT; + tvi.hItem = dat->opd[dat->currentPage].hItem; + tvi.pszText = name; + tvi.cchTextMax = SIZEOF(name); + TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); + DBWriteContactSettingTString(NULL, "UserInfo", "LastTab", name); + } + Window_FreeIcon_IcoLib(hwndDlg); + SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDC_WHITERECT, WM_GETFONT, 0, 0), 0); + DeleteObject(dat->hBoldFont); + WindowList_Remove(hWindowList, hwndDlg); + UnhookEvent(dat->hProtoAckEvent); + { + for (int i=0; i < dat->pageCount; i++) { + if (dat->opd[i].hwnd != NULL) DestroyWindow(dat->opd[i].hwnd); + mir_free(dat->opd[i].ptszTitle); + mir_free(dat->opd[i].ptszTab); + } + } + mir_free(dat->infosUpdated); + mir_free(dat->opd); + mir_free(dat); + break; + } + return FALSE; +} + +static int ShutdownUserInfo(WPARAM, LPARAM) +{ + WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); + return 0; +} + +int LoadUserInfoModule(void) +{ + CreateServiceFunction("UserInfo/AddPage", AddDetailsPage); + CreateServiceFunction(MS_USERINFO_SHOWDIALOG, ShowDetailsDialogCommand); + + hDetailsInitEvent = CreateHookableEvent(ME_USERINFO_INITIALISE); + + HookEvent(ME_USERINFO_INITIALISE, DetailsInit); + HookEvent(ME_DB_CONTACT_DELETED, UserInfoContactDelete); + HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownUserInfo); + + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.flags = CMIF_ICONFROMICOLIB; + mi.position = 1000050000; + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_USERDETAILS); + mi.pszName = LPGEN("User &Details"); + mi.pszService = MS_USERINFO_SHOWDIALOG; + Menu_AddContactMenuItem(&mi); + + mi.position = 500050000; + mi.pszName = LPGEN("View/Change My &Details..."); + Menu_AddMainMenuItem(&mi); + + hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + return 0; +} diff --git a/src/core/stduserinfo/version.h b/src/core/stduserinfo/version.h new file mode 100644 index 0000000000..b9df9bad73 --- /dev/null +++ b/src/core/stduserinfo/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stduserinfo" +#define __INTERNAL_NAME "stduserinfo" +#define __FILENAME "stduserinfo.dll" +#define __DESCRIPTION "Core module for providing user information." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stduserinfo/version.rc b/src/core/stduserinfo/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stduserinfo/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/miranda32.def b/src/miranda32.def index 667800545c..c36a1b6fc4 100644 --- a/src/miranda32.def +++ b/src/miranda32.def @@ -1,6 +1,18 @@ EXPORTS -CallContactService @1 -CallProtoService @2 -RecalculateTime @3 - +CallContactService @1 +CallProtoService @2 +RecalculateTime @3 +LoadSkinProtoIcon @4 +LoadSkinIcon @5 +Button_FreeIcon_IcoLib @6 +Button_SetIcon_IcoLib @7 +GetSkinIconHandle @8 +IcoLib_AddNewIcon @9 +IcoLib_GetIcon @10 +IcoLib_GetIconByHandle @11 +IcoLib_IsManaged @12 +IcoLib_ReleaseIcon @13 +Window_FreeIcon_IcoLib @14 +Window_SetIcon_IcoLib @15 +Window_SetProtoIcon_IcoLib @16 diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index 31d08d7b3c..852acd97b5 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -250,6 +250,7 @@ + @@ -503,15 +504,6 @@ ..\..\core\commonheaders.h - - ..\..\core\commonheaders.h - - - ..\..\core\commonheaders.h - - - ..\..\core\commonheaders.h - ..\..\core\commonheaders.h diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index 1edbf008b5..7e4c8a431e 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -76,9 +76,6 @@ {9074e889-f17c-4c90-a3cf-1cfb2e513491} - - {34172b4f-5cec-4166-8610-1537127749d9} - {daa4af16-7ada-4bd5-92bb-59f5ab815e9c} @@ -309,6 +306,9 @@ SDK + + Core + @@ -494,15 +494,6 @@ Modules\updater - - Modules\userinfo - - - Modules\userinfo - - - Modules\userinfo - Modules\useronline diff --git a/src/modules/addcontact/addcontact.cpp b/src/modules/addcontact/addcontact.cpp index ce03278281..30ed412bda 100644 --- a/src/modules/addcontact/addcontact.cpp +++ b/src/modules/addcontact/addcontact.cpp @@ -30,7 +30,7 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp case WM_INITDIALOG: { char szUin[10]; - acs=(ADDCONTACTSTRUCT *)lparam; + acs = (ADDCONTACTSTRUCT *)lparam; SetWindowLongPtr(hdlg, GWLP_USERDATA, (LONG_PTR)acs); TranslateDialogDefault(hdlg); @@ -38,9 +38,9 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp if (acs->handleType == HANDLE_EVENT) { DWORD dwUin; DBEVENTINFO dbei = { 0 }; - dbei.cbSize=sizeof(dbei); - dbei.cbBlob=sizeof(DWORD); - dbei.pBlob=(PBYTE)&dwUin; + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = sizeof(DWORD); + dbei.pBlob = (PBYTE)&dwUin; CallService(MS_DB_EVENT_GET, (WPARAM)acs->handle, (LPARAM)&dbei); _ltoa(dwUin, szUin, 10); acs->szProto = dbei.szModule; @@ -57,11 +57,11 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp HANDLE hcontact; ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)acs->handle, 0); - dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)acs->handle, 0); + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); CallService(MS_DB_EVENT_GET, (WPARAM)acs->handle, (LPARAM)&dbei); - hcontact=*((PHANDLE)(dbei.pBlob+sizeof(DWORD))); + hcontact = *((PHANDLE)(dbei.pBlob+sizeof(DWORD))); mir_free(dbei.pBlob); if (hcontact != INVALID_HANDLE_VALUE) { szName = cli.pfnGetContactDisplayName(hcontact, 0); diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp index 75c4148980..f3384f3fcc 100644 --- a/src/modules/button/button.cpp +++ b/src/modules/button/button.cpp @@ -260,7 +260,7 @@ static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - MButtonCtrl* bct = (MButtonCtrl *)GetWindowLongPtr(hwndDlg, 0); + MButtonCtrl* bct = (MButtonCtrl *)GetWindowLongPtr(hwndDlg, 0); if (bct && bct->fnWindowProc) { LRESULT res = bct->fnWindowProc(hwndDlg, msg, wParam, lParam); if (res) @@ -315,7 +315,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L bct->hwndToolTips = NULL; } } - if (bct->arrow) IconLib_ReleaseIcon(bct->arrow, 0); + if (bct->arrow) IcoLib_ReleaseIcon(bct->arrow, 0); DestroyTheme(bct); } break; // DONT! fall thru @@ -450,7 +450,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L } else { if (bct->arrow) { - IconLib_ReleaseIcon(bct->arrow, 0); + IcoLib_ReleaseIcon(bct->arrow, 0); bct->arrow = NULL; SetHwndPropInt(bct, OBJID_CLIENT, CHILDID_SELF, PROPID_ACC_ROLE, ROLE_SYSTEM_PUSHBUTTON); } @@ -620,18 +620,18 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L int LoadButtonModule(void) { - WNDCLASSEX wc = {0}; - - if (bModuleInitialized) return 0; + if (bModuleInitialized) + return 0; bModuleInitialized = TRUE; - wc.cbSize = sizeof(wc); - wc.lpszClassName = MIRANDABUTTONCLASS; - wc.lpfnWndProc = MButtonWndProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(MButtonCtrl*); - wc.hbrBackground = 0; - wc.style = CS_GLOBALCLASS; + WNDCLASSEX wc = {0}; + wc.cbSize = sizeof(wc); + wc.lpszClassName = MIRANDABUTTONCLASS; + wc.lpfnWndProc = MButtonWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(MButtonCtrl*); + wc.hbrBackground = 0; + wc.style = CS_GLOBALCLASS; RegisterClassEx(&wc); InitializeCriticalSection(&csTips); diff --git a/src/modules/clist/Docking.cpp b/src/modules/clist/Docking.cpp index b02a039f3f..382794b9d7 100644 --- a/src/modules/clist/Docking.cpp +++ b/src/modules/clist/Docking.cpp @@ -232,7 +232,7 @@ int fnDocking_ProcessWindowMessage(WPARAM wParam, LPARAM lParam) wp->y = rc.top; wp->cy = rc.bottom - rc.top; wp->cx = rc.right - rc.left; - wp->flags &= ~(SWP_NOSIZE | SWP_NOMOVE); + wp->flags &= ~(SWP_NOSIZE | SWP_NOMOVE); } } } diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp index 8a50469245..56a8b66c35 100644 --- a/src/modules/clist/clc.cpp +++ b/src/modules/clist/clc.cpp @@ -120,13 +120,13 @@ static int ClcSettingChanged(WPARAM wParam, LPARAM lParam) static int ClcAccountsChanged(WPARAM, LPARAM) { int i, cnt; - for (i = 0, cnt = 0; i < accounts.getCount(); ++i) + for (i=0, cnt=0; i < accounts.getCount(); ++i) if (Proto_IsAccountEnabled(accounts[i])) ++cnt; cli.hClcProtoCount = cnt; cli.clcProto = (ClcProtoStatus *) mir_realloc(cli.clcProto, sizeof(ClcProtoStatus) * cli.hClcProtoCount); - for (i = 0, cnt = 0; i < accounts.getCount(); ++i) { + for (i=0, cnt=0; i < accounts.getCount(); ++i) { if (Proto_IsAccountEnabled(accounts[i])) { cli.clcProto[cnt].szProto = accounts[i]->szModuleName; cli.clcProto[cnt].dwStatus = CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_GETSTATUS, 0, 0); @@ -151,7 +151,7 @@ static int ClcProtoAck(WPARAM, LPARAM lParam) if (ack->type == ACKTYPE_STATUS) { WindowList_BroadcastAsync(hClcWindowList, INTM_INVALIDATE, 0, 0); if (ack->result == ACKRESULT_SUCCESS) { - for (i = 0; i < cli.hClcProtoCount; i++) { + for (i=0; i < cli.hClcProtoCount; i++) { if ( !lstrcmpA(cli.clcProto[i].szProto, ack->szModule)) { cli.clcProto[i].dwStatus = (WORD) ack->lParam; break; @@ -268,7 +268,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, } { int i; - for (i = 0; i <= FONTID_MAX; i++) + for (i=0; i <= FONTID_MAX; i++) dat->fontInfo[i].changed = 1; } dat->selection = -1; @@ -401,7 +401,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, if (cli.pfnFindItem(hwnd, dat, (HANDLE) (groupId | HCONTACT_ISGROUP), &contact, &group, NULL)) { lstrcpy(szFullName, contact->szText); while (group->parent) { - for (i = 0; i < group->parent->cl.count; i++) + for (i=0; i < group->parent->cl.count; i++) if (group->parent->cl.items[i]->group == group) break; if (i == group->parent->cl.count) { @@ -1320,7 +1320,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, cli.pfnHideInfoTip(hwnd, dat); { int i; - for (i = 0; i <= FONTID_MAX; i++) + for (i=0; i <= FONTID_MAX; i++) if ( !dat->fontInfo[i].changed) DeleteObject(dat->fontInfo[i].hFont); } diff --git a/src/modules/clist/clcfiledrop.cpp b/src/modules/clist/clcfiledrop.cpp index 5c64082215..10d101e705 100644 --- a/src/modules/clist/clcfiledrop.cpp +++ b/src/modules/clist/clcfiledrop.cpp @@ -229,7 +229,7 @@ HRESULT CDropTarget::Drop(IDataObject * pDataObj, DWORD /*fKeyState*/, POINTL pt fileCount = DragQueryFile(hDrop, -1, NULL, 0); ppFiles = NULL; - for (i = 0; i < fileCount; i++) { + for (i=0; i < fileCount; i++) { DragQueryFile(hDrop, i, szFilename, SIZEOF(szFilename)); AddToFileList(&ppFiles, &totalCount, szFilename); } @@ -237,7 +237,7 @@ HRESULT CDropTarget::Drop(IDataObject * pDataObj, DWORD /*fKeyState*/, POINTL pt if ( !CallService(MS_FILE_SENDSPECIFICFILEST, (WPARAM) hContact, (LPARAM) ppFiles)) *pdwEffect = DROPEFFECT_COPY; - for (i = 0; ppFiles[i]; i++) + for (i=0; ppFiles[i]; i++) mir_free(ppFiles[i]); mir_free(ppFiles); } diff --git a/src/modules/clist/clcitems.cpp b/src/modules/clist/clcitems.cpp index 74e951c276..37aa09bb46 100644 --- a/src/modules/clist/clcitems.cpp +++ b/src/modules/clist/clcitems.cpp @@ -59,7 +59,7 @@ struct ClcGroup* fnAddGroup(HWND hwnd, struct ClcData *dat, const TCHAR *szName, pNextField = pBackslash + 1; } compareResult = 1; - for (i = 0; i < group->cl.count; i++) { + for (i=0; i < group->cl.count; i++) { if (group->cl.items[i]->type == CLCIT_CONTACT) break; if (group->cl.items[i]->type != CLCIT_GROUP) @@ -130,7 +130,7 @@ void fnFreeContact(struct ClcContact* p) void fnFreeGroup(struct ClcGroup *group) { int i; - for (i = 0; i < group->cl.count; i++) { + for (i=0; i < group->cl.count; i++) { cli.pfnFreeContact(group->cl.items[i]); mir_free(group->cl.items[i]); } @@ -143,7 +143,7 @@ void fnFreeGroup(struct ClcGroup *group) static int iInfoItemUniqueHandle = 0; int fnAddInfoItemToGroup(struct ClcGroup *group, int flags, const TCHAR *pszText) { - int i = 0; + int i=0; if (flags & CLCIIF_BELOWCONTACTS) i = group->cl.count; @@ -309,7 +309,7 @@ struct ClcGroup* fnRemoveItemFromGroup(HWND hwnd, struct ClcGroup *group, struct int i; if (group->parent == NULL) return group; - for (i = 0; i < group->parent->cl.count; i++) + for (i=0; i < group->parent->cl.count; i++) if (group->parent->cl.items[i]->type == CLCIT_GROUP && group->parent->cl.items[i]->groupId == group->groupId) break; if (i == group->parent->cl.count) @@ -337,7 +337,7 @@ void fnDeleteItemFromTree(HWND hwnd, HANDLE hItem) //decrease member counts of all parent groups too group = &dat->list; nameOffset = 0; - for (i = 0;; i++) { + for (i=0;; i++) { if (group->scanIndex == group->cl.count) break; if (group->cl.items[i]->type == CLCIT_GROUP) { @@ -502,7 +502,7 @@ static void SortGroup(struct ClcData *dat, struct ClcGroup *group, int useInsert List_Remove((SortedList*)&group->cl, i); } } - for (i = 0; i < group->cl.count; i++) + for (i=0; i < group->cl.count; i++) if (group->cl.items[i]->type != CLCIT_INFO) break; if (i > group->cl.count - 2) @@ -530,7 +530,7 @@ static void SortGroup(struct ClcData *dat, struct ClcGroup *group, int useInsert qsort(group->cl.items + i, sortCount, sizeof(void*), ContactSortProc); if (dat->exStyle & CLS_EX_DIVIDERONOFF) { int prevContactOnline = 0; - for (i = 0; i < group->cl.count; i++) { + for (i=0; i < group->cl.count; i++) { if (group->cl.items[i]->type != CLCIT_CONTACT) continue; if (group->cl.items[i]->flags & CONTACTF_ONLINE) @@ -685,7 +685,7 @@ void fnSaveStateAndRebuildList(HWND hwnd, struct ClcData *dat) group->scanIndex++; } - for (i = 0; i < saveInfo.getCount(); i++) { + for (i=0; i < saveInfo.getCount(); i++) { if (saveInfo[i].parentId == -1) group = &dat->list; else { diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index e49e9621b3..8617d82f9a 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -156,7 +156,7 @@ int fnHitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, struct ClcCo return hit; } - for (i = 0; i < dat->extraColumnsCount; i++) { + for (i=0; i < dat->extraColumnsCount; i++) { if (hitcontact->iExtraImage[i] == 0xFF) continue; if (testx >= clRect.right - dat->extraColumnSpacing * (dat->extraColumnsCount - i) && @@ -723,7 +723,7 @@ void fnLoadClcOptions(HWND hwnd, struct ClcData *dat) SIZE fontSize; HDC hdc = GetDC(hwnd); - for (i = 0; i <= FONTID_MAX; i++) + for (i=0; i <= FONTID_MAX; i++) { if ( !dat->fontInfo[i].changed) DeleteObject(dat->fontInfo[i].hFont); @@ -824,7 +824,7 @@ void fnSetGroupChildCheckboxes(struct ClcGroup *group, int checked) { int i; - for (i = 0; i < group->cl.count; i++) { + for (i=0; i < group->cl.count; i++) { if (group->cl.items[i]->type == CLCIT_GROUP) { cli.pfnSetGroupChildCheckboxes(group->cl.items[i]->group, checked); if (checked) diff --git a/src/modules/clist/clistevents.cpp b/src/modules/clist/clistevents.cpp index 8177e233d4..96d5a95a9e 100644 --- a/src/modules/clist/clistevents.cpp +++ b/src/modules/clist/clistevents.cpp @@ -49,7 +49,7 @@ int fnGetImlIconIndex(HICON hIcon) { int i; - for (i = 0; i < imlIconCount; i++) { + for (i=0; i < imlIconCount; i++) { if (imlIcon[i].hIcon == hIcon) return imlIcon[i].index; } @@ -89,7 +89,7 @@ static void ShowEventsInTray() int i; char ** pTrayProtos; char nTrayProtoCnt; - int nTrayCnt=cli.trayIconCount; + int nTrayCnt = cli.trayIconCount; if ( !cli.events.count || !nTrayCnt) return; if (cli.events.count == 1 || nTrayCnt == 1) { @@ -101,24 +101,24 @@ static void ShowEventsInTray() // lets use several icon to show events from protocols in different icons cli.pfnLockTray(); pTrayProtos = (char**)_alloca(sizeof(char*)*cli.trayIconCount); - nTrayProtoCnt=0; + nTrayProtoCnt = 0; for (i=0; i=nTrayProtoCnt) j=0; //event was not found so assume first icon + if (j>=nTrayProtoCnt) j = 0; //event was not found so assume first icon if (pTrayProtos[j]) //if not already set ShowOneEventInTray(i); //show it - pTrayProtos[j]=NULL; //and clear slot + pTrayProtos[j] = NULL; //and clear slot } } cli.pfnUnlockTray(); @@ -128,7 +128,7 @@ static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD) { int i, j; ShowEventsInTray(); - for (i = 0; i < cli.events.count; i++) { + for (i=0; i < cli.events.count; i++) { for (j = 0; j < i; j++) if (cli.events.items[j]->cle.hContact == cli.events.items[i]->cle.hContact) break; @@ -157,7 +157,7 @@ struct CListEvent* fnAddEvent(CLISTEVENT *cle) return NULL; if (cle->flags & CLEF_URGENT) { - for (i = 0; i < cli.events.count; i++) + for (i=0; i < cli.events.count; i++) if ( !(cli.events.items[i]->cle.flags & CLEF_URGENT)) break; } @@ -182,7 +182,7 @@ struct CListEvent* fnAddEvent(CLISTEVENT *cle) if (cle->flags&CLEF_PROTOCOLGLOBAL) szProto = cle->lpszProtocol; else - szProto=NULL; + szProto = NULL; } else szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cle->hContact, 0); @@ -201,10 +201,10 @@ int fnRemoveEvent(HANDLE hContact, HANDLE dbEvent) { int i; char *szProto; - int nSameProto=0; + int nSameProto = 0; // Find the event that should be removed - for (i = 0; i < cli.events.count; i++) + for (i=0; i < cli.events.count; i++) if ((cli.events.items[i]->cle.hContact == hContact) && (cli.events.items[i]->cle.hDbEvent == dbEvent)) break; @@ -224,12 +224,12 @@ int fnRemoveEvent(HANDLE hContact, HANDLE dbEvent) { //count same protocoled events char * szEventProto; - for (i = 0; i < cli.events.count; i++) + for (i=0; i < cli.events.count; i++) { if (cli.events.items[i]->cle.hContact) - szEventProto=(char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)(cli.events.items[i]->cle.hContact), 0); + szEventProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)(cli.events.items[i]->cle.hContact), 0); else if (cli.events.items[i]->cle.flags&CLEF_PROTOCOLGLOBAL) - szEventProto=(char *) cli.events.items[i]->cle.lpszProtocol; + szEventProto = (char *) cli.events.items[i]->cle.lpszProtocol; else szEventProto = NULL; if (szEventProto && szProto && !lstrcmpA(szEventProto, szProto)) @@ -262,7 +262,7 @@ CLISTEVENT* fnGetEvent(HANDLE hContact, int idx) return &cli.events.items[idx]->cle; } - for (int i = 0; i < cli.events.count; i++) + for (int i=0; i < cli.events.count; i++) if (cli.events.items[i]->cle.hContact == hContact) if (idx-- == 0) return &cli.events.items[i]->cle; @@ -271,7 +271,7 @@ CLISTEVENT* fnGetEvent(HANDLE hContact, int idx) int fnEventsProcessContactDoubleClick(HANDLE hContact) { - for (int i = 0; i < cli.events.count; i++) { + for (int i=0; i < cli.events.count; i++) { if (cli.events.items[i]->cle.hContact == hContact) { HANDLE hDbEvent = cli.events.items[i]->cle.hDbEvent; CallService(cli.events.items[i]->cle.pszService, (WPARAM) (HWND) NULL, (LPARAM) & cli.events.items[i]->cle); @@ -284,30 +284,30 @@ int fnEventsProcessContactDoubleClick(HANDLE hContact) int fnEventsProcessTrayDoubleClick(int index) { - BOOL click_in_first_icon=FALSE; + BOOL click_in_first_icon = FALSE; if (cli.events.count) { HANDLE hContact, hDbEvent; - int eventIndex=0; + int eventIndex = 0; cli.pfnLockTray(); if (cli.trayIconCount>1 && index>0) { int i; - char * szProto=NULL; + char * szProto = NULL; for (i=0; icle.hContact) - eventProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); + eventProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); if ( !eventProto) - eventProto=cli.events.items[i]->cle.lpszProtocol; + eventProto = cli.events.items[i]->cle.lpszProtocol; if ( !eventProto || !_strcmpi(eventProto, szProto)) { - eventIndex=i; + eventIndex = i; break; } } @@ -316,18 +316,18 @@ int fnEventsProcessTrayDoubleClick(int index) int j; if (click_in_first_icon) for (i=0; icle.hContact) - eventProto=(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); + eventProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); if ( !eventProto) - eventProto=cli.events.items[i]->cle.lpszProtocol; + eventProto = cli.events.items[i]->cle.lpszProtocol; if (eventProto) { - for (j=0; jpszContactOwner) ? mi->pszContactOwner : "", mi->ptszName); } - else buf[0]='\0'; + else buf[0] = '\0'; if (buf[0]) MO_SetOptionsMenuItem(menuHandle, OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf); return (INT_PTR)menuHandle; } @@ -331,7 +331,7 @@ static INT_PTR BuildContactMenu(WPARAM wParam, LPARAM) HANDLE hContact = (HANDLE)wParam; NotifyEventHooks(hPreBuildContactMenuEvent, (WPARAM)hContact, 0); - char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); BuildContactParam bcp; bcp.szProto = szProto; @@ -354,8 +354,8 @@ static INT_PTR BuildContactMenu(WPARAM wParam, LPARAM) INT_PTR ContactMenuExecService(WPARAM wParam, LPARAM lParam) { if (wParam != 0) { - lpContactMenuExecParam cmep=(lpContactMenuExecParam)wParam; - //call with wParam=(WPARAM)(HANDLE)hContact, lparam=popupposition + lpContactMenuExecParam cmep = (lpContactMenuExecParam)wParam; + //call with wParam = (WPARAM)(HANDLE)hContact, lparam = popupposition CallService(cmep->szServiceName, lParam, cmep->param); } return 0; @@ -474,7 +474,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) MenuItemData it = {0}; if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) { - MENUITEMINFO mi ={0}; + MENUITEMINFO mi = {0}; TCHAR d[100]; GetMenuString(it.OwnerMenu, it.position, d, SIZEOF(d), MF_BYPOSITION); @@ -517,14 +517,14 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) timi->mi.flags &= ~CMIF_CHECKED; } else if (( !smep || smep->proto) && timi->mi.pszName) { - int curProtoStatus=0; - BOOL IconNeedDestroy=FALSE; + int curProtoStatus = 0; + BOOL IconNeedDestroy = FALSE; char* prot; if (smep) prot = smep->proto; else { - char *prn=mir_u2a(timi->mi.ptszName); + char *prn = mir_u2a(timi->mi.ptszName); prot = NEWSTR_ALLOCA(prn); if (prn) mir_free(prn); } @@ -537,7 +537,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE) timi->mi.hIcon = LoadSkinProtoIcon(prot, curProtoStatus); else { - timi->mi.hIcon=(HICON)CallProtoServiceInt(NULL,prot, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); + timi->mi.hIcon = (HICON)CallProtoServiceInt(NULL,prot, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (timi->mi.hIcon == (HICON)CALLSERVICE_NOTFOUND) timi->mi.hIcon = NULL; else @@ -551,7 +551,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) DestroyIcon(timi->mi.hIcon); timi->mi.hIcon = NULL; } - else IconLib_ReleaseIcon(timi->mi.hIcon, 0); + else IcoLib_ReleaseIcon(timi->mi.hIcon, 0); } } return TRUE; @@ -569,9 +569,9 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) if (smep->status == 0 && smep->protoindex != 0 && smep->proto != NULL) { PMO_IntMenuItem pimi; char *prot = smep->proto; - char szHumanName[64]={0}; + char szHumanName[64] = {0}; PROTOACCOUNT * acc = Proto_GetAccount(smep->proto); - int i=(DBGetContactSettingByte(NULL, prot, "LockMainStatus", 0)?0:1); + int i = (DBGetContactSettingByte(NULL, prot, "LockMainStatus", 0)?0:1); DBWriteContactSettingByte(NULL, prot, "LockMainStatus", (BYTE)i); CallProtoServiceInt(NULL,smep->proto, PS_GETNAME, (WPARAM)SIZEOF(szHumanName), (LPARAM)szHumanName); @@ -684,7 +684,7 @@ BOOL FindMenuHanleByGlobalID(HMENU hMenu, PMO_IntMenuItem id, MenuItemData* itda int i; PMO_IntMenuItem pimi; MENUITEMINFO mii = {0}; - BOOL inSub=FALSE; + BOOL inSub = FALSE; if ( !itdat) return FALSE; @@ -843,7 +843,7 @@ void RebuildMenuOrder(void) tmp.CheckService = "StatusMenuCheckService"; tmp.name = "StatusMenu"; - hStatusMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT, (WPARAM)0, (LPARAM)&tmp); + hStatusMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, (WPARAM)0, (LPARAM)&tmp); MO_SetOptionsMenuObject(hStatusMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu"); hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(SIZEOF(statusModeList) * sizeof(PMO_IntMenuItem*)); @@ -854,7 +854,7 @@ void RebuildMenuOrder(void) FreeMenuProtos(); - for (s=0; s < accounts.getCount(); s++) { + for (s = 0; s < accounts.getCount(); s++) { i = cli.pfnGetAccountIndexByPos(s); if (i == -1) continue; @@ -917,7 +917,7 @@ void RebuildMenuOrder(void) ((lpStatusMenuExecParam)tmi.ownerdata)->protoindex = (int)menuHandle; MO_ModifyMenuItem(menuHandle, &tmi); - cli.menuProtos=(MenuProto*)mir_realloc(cli.menuProtos, sizeof(MenuProto)*(cli.menuProtoCount+1)); + cli.menuProtos = (MenuProto*)mir_realloc(cli.menuProtos, sizeof(MenuProto)*(cli.menuProtoCount+1)); memset(&(cli.menuProtos[cli.menuProtoCount]), 0, sizeof(MenuProto)); cli.menuProtos[cli.menuProtoCount].pMenu = rootmenu; cli.menuProtos[cli.menuProtoCount].szProto = mir_strdup(pa->szModuleName); @@ -931,7 +931,7 @@ void RebuildMenuOrder(void) DestroyIcon(ic); pos += 500000; - for (j=0; j < SIZEOF(statusModeList); j++) { + for (j = 0; j < SIZEOF(statusModeList); j++) { if ( !(flags & statusModePf2List[j])) continue; @@ -963,14 +963,14 @@ void RebuildMenuOrder(void) mir_snprintf(buf, SIZEOF(buf), "ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName); MO_SetOptionsMenuItem(hStatusMenuHandles[i].menuhandle[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf); } - IconLib_ReleaseIcon(tmi.hIcon, 0); + IcoLib_ReleaseIcon(tmi.hIcon, 0); } } NotifyEventHooks(cli.hPreBuildStatusMenuEvent, 0, 0); int pos = 200000; //add to root menu - for (j=0; j < SIZEOF(statusModeList); j++) { + for (j = 0; j < SIZEOF(statusModeList); j++) { for (i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; if ( !bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName)) @@ -1012,7 +1012,7 @@ void RebuildMenuOrder(void) mir_snprintf(buf, sizeof(buf), "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName); MO_SetOptionsMenuItem(hStatusMainMenuHandles[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf); } - IconLib_ReleaseIcon(tmi.hIcon, 0); + IcoLib_ReleaseIcon(tmi.hIcon, 0); break; } } @@ -1027,7 +1027,7 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) tmi.cbSize = sizeof(tmi); tmi.flags = CMIM_HOTKEY | CMIM_NAME | CMIF_TCHAR; - for (int j=0; j < SIZEOF(statusModeList); j++) { + for (int j = 0; j < SIZEOF(statusModeList); j++) { TCHAR buf[ 256 ], hotkeyName[ 100 ]; WORD hotKey = GetHotkeyValue(statusHotkeys[j]); HotkeyToName(hotkeyName, SIZEOF(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey)); @@ -1055,7 +1055,7 @@ int statustopos(int status) static int MenuProtoAck(WPARAM, LPARAM lParam) { - ACKDATA* ack=(ACKDATA*)lParam; + ACKDATA* ack = (ACKDATA*)lParam; if (ack->type != ACKTYPE_STATUS) return 0; if (ack->result != ACKRESULT_SUCCESS) return 0; if (hStatusMainMenuHandles == NULL) return 0; @@ -1068,7 +1068,7 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) if (overallStatus >= ID_STATUS_OFFLINE) { int pos = statustopos(cli.currentStatusMenuItem); if (pos == -1) - pos=0; + pos = 0; // reset all current possible checked statuses for (int pos2 = 0; pos2=0 && pos < hStatusMainMenuHandlesCnt) { tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE | CMIF_CHECKED; @@ -1087,13 +1087,13 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) } else { int pos = statustopos(cli.currentStatusMenuItem); - if (pos == -1) pos=0; + if (pos == -1) pos = 0; if (pos >= 0 && pos < hStatusMainMenuHandlesCnt) { tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE; MO_ModifyMenuItem(hStatusMainMenuHandles[pos], &tmi); } - cli.currentStatusMenuItem=0; + cli.currentStatusMenuItem = 0; } for (int i=0; i < accounts.getCount(); i++) { @@ -1208,7 +1208,7 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) } } if (wParam) { - int * res=(int*)wParam; + int * res = (int*)wParam; *res = (int)pRoot; } @@ -1217,13 +1217,13 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) if (mi->pszService) { smep = (lpStatusMenuExecParam)mir_calloc(sizeof(StatusMenuExecParam)); smep->custom = TRUE; - smep->svc=mir_strdup(mi->pszService); + smep->svc = mir_strdup(mi->pszService); { - char *buf=mir_strdup(mi->pszService); + char *buf = mir_strdup(mi->pszService); int i=0; while (buf[i] != '\0' && buf[i] != '/') i++; - buf[i]='\0'; - smep->proto=mir_strdup(buf); + buf[i] = '\0'; + smep->proto = mir_strdup(buf); mir_free(buf); } tmi.ownerdata = smep; @@ -1299,21 +1299,21 @@ void InitCustomMenus(void) CreateServiceFunction("CList/AddProtoMenuItem", AddProtoMenuItem); - hPreBuildContactMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDCONTACTMENU); - hPreBuildMainMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDMAINMENU); - cli.hPreBuildStatusMenuEvent=CreateHookableEvent(ME_CLIST_PREBUILDSTATUSMENU); + hPreBuildContactMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDCONTACTMENU); + hPreBuildMainMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDMAINMENU); + cli.hPreBuildStatusMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDSTATUSMENU); hStatusModeChangeEvent = CreateHookableEvent(ME_CLIST_STATUSMODECHANGE); - hAckHook=(HANDLE)HookEvent(ME_PROTO_ACK, MenuProtoAck); + hAckHook = (HANDLE)HookEvent(ME_PROTO_ACK, MenuProtoAck); hMainMenu = CreatePopupMenu(); hStatusMenu = CreatePopupMenu(); - hStatusMainMenuHandles=NULL; - hStatusMainMenuHandlesCnt=0; + hStatusMainMenuHandles = NULL; + hStatusMainMenuHandlesCnt = 0; - hStatusMenuHandles=NULL; - hStatusMenuHandlesCnt=0; + hStatusMenuHandles = NULL; + hStatusMenuHandlesCnt = 0; //new menu sys InitGenMenu(); @@ -1321,11 +1321,11 @@ void InitCustomMenus(void) //main menu { TMenuParam tmp = { 0 }; - tmp.cbSize=sizeof(tmp); - tmp.CheckService=NULL; - tmp.ExecService="MainMenuExecService"; - tmp.name="MainMenu"; - hMainMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT, (WPARAM)0, (LPARAM)&tmp); + tmp.cbSize = sizeof(tmp); + tmp.CheckService = NULL; + tmp.ExecService = "MainMenuExecService"; + tmp.name = "MainMenu"; + hMainMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, (WPARAM)0, (LPARAM)&tmp); } MO_SetOptionsMenuObject(hMainMenuObject, OPT_USERDEFINEDITEMS, TRUE); @@ -1334,11 +1334,11 @@ void InitCustomMenus(void) //contact menu { TMenuParam tmp = { 0 }; - tmp.cbSize=sizeof(tmp); - tmp.CheckService="ContactMenuCheckService"; - tmp.ExecService="ContactMenuExecService"; - tmp.name="ContactMenu"; - hContactMenuObject=(HANDLE)CallService(MO_CREATENEWMENUOBJECT, (WPARAM)0, (LPARAM)&tmp); + tmp.cbSize = sizeof(tmp); + tmp.CheckService = "ContactMenuCheckService"; + tmp.ExecService = "ContactMenuExecService"; + tmp.name = "ContactMenu"; + hContactMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, (WPARAM)0, (LPARAM)&tmp); } MO_SetOptionsMenuObject(hContactMenuObject, OPT_USERDEFINEDITEMS, TRUE); @@ -1351,7 +1351,7 @@ void InitCustomMenus(void) hkd.cbSize = sizeof(hkd); hkd.ptszSection = _T("Status"); hkd.dwFlags = HKD_TCHAR; - for (int i = 0; i < SIZEOF(statusHotkeys); i++) { + for (int i=0; i < SIZEOF(statusHotkeys); i++) { char szName[30]; mir_snprintf(szName, SIZEOF(szName), "StatusHotKey_%d", i); hkd.pszName = szName; @@ -1376,8 +1376,8 @@ void InitCustomMenus(void) AddMainMenuItem(0, (LPARAM)&mi); } - cli.currentStatusMenuItem=ID_STATUS_OFFLINE; - cli.currentDesiredStatusMode=ID_STATUS_OFFLINE; + cli.currentStatusMenuItem = ID_STATUS_OFFLINE; + cli.currentDesiredStatusMode = ID_STATUS_OFFLINE; if (IsWinVer98Plus()) HookEvent(ME_SKIN_ICONSCHANGED, MenuIconsChanged); diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp index 39047d9331..7c8d7527d7 100644 --- a/src/modules/clist/clistmod.cpp +++ b/src/modules/clist/clistmod.cpp @@ -177,7 +177,7 @@ int fnIconFromStatusMode(const char *szProto, int status, HANDLE) index = 0; if (szProto == NULL) return index + 1; - for (i = 0; i < protoIconIndex.getCount(); i++) { + for (i=0; i < protoIconIndex.getCount(); i++) { if (strcmp(szProto, protoIconIndex[i].szProto) == 0) return protoIconIndex[i].iIconBase + index; } @@ -197,7 +197,7 @@ static void AddProtoIconIndex(PROTOACCOUNT* pa) { ProtoIconIndex *pii = new ProtoIconIndex; pii->szProto = pa->szModuleName; - for (int i = 0; i < SIZEOF(statusModeList); i++) { + for (int i=0; i < SIZEOF(statusModeList); i++) { int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, statusModeList[i]); if (i == 0) pii->iIconBase = iImg; @@ -207,7 +207,7 @@ static void AddProtoIconIndex(PROTOACCOUNT* pa) static void RemoveProtoIconIndex(PROTOACCOUNT* pa) { - for (int i = 0; i < protoIconIndex.getCount(); i++) + for (int i=0; i < protoIconIndex.getCount(); i++) if (strcmp(protoIconIndex[i].szProto, pa->szModuleName) == 0) { protoIconIndex.remove(i); break; @@ -222,7 +222,7 @@ static int ContactListModulesLoaded(WPARAM, LPARAM) } RebuildMenuOrder(); - for (int i = 0; i < accounts.getCount(); i++) + for (int i=0; i < accounts.getCount(); i++) AddProtoIconIndex(accounts[i]); cli.pfnLoadContactTree(); @@ -282,11 +282,11 @@ static int CListIconsChanged(WPARAM, LPARAM) { int i, j; - for (i = 0; i < SIZEOF(statusModeList); i++) + for (i=0; i < SIZEOF(statusModeList); i++) ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, LoadSkinIcon(skinIconStatusList[i])); ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, LoadSkinIcon(SKINICON_OTHER_GROUPOPEN)); ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, LoadSkinIcon(SKINICON_OTHER_GROUPSHUT)); - for (i = 0; i < protoIconIndex.getCount(); i++) + for (i=0; i < protoIconIndex.getCount(); i++) for (j = 0; j < SIZEOF(statusModeList); j++) ImageList_ReplaceIcon_IconLibLoaded(hCListImages, protoIconIndex[i].iIconBase + j, LoadSkinProtoIcon(protoIconIndex[i].szProto, statusModeList[j])); cli.pfnTrayIconIconsChanged(); @@ -533,7 +533,7 @@ int LoadContactListModule2(void) ImageList_AddIcon_NotShared(hCListImages, MAKEINTRESOURCE(IDI_BLANK)); //now all core skin icons are loaded via icon lib. so lets release them - for (int i = 0; i < SIZEOF(statusModeList); i++) + for (int i=0; i < SIZEOF(statusModeList); i++) ImageList_AddIcon_IconLibLoaded(hCListImages, skinIconStatusList[i]); //see IMAGE_GROUP... in clist.h if you add more images above here diff --git a/src/modules/clist/clistsettings.cpp b/src/modules/clist/clistsettings.cpp index 710bd6aaf0..2e6f065628 100644 --- a/src/modules/clist/clistsettings.cpp +++ b/src/modules/clist/clistsettings.cpp @@ -40,7 +40,7 @@ void FreeDisplayNameCache(void) { if (clistCache != NULL) { int i; - for (i = 0; i < clistCache->realCount; i++) { + for (i=0; i < clistCache->realCount; i++) { cli.pfnFreeCacheItem((ClcCacheEntryBase*)clistCache->items[i]); mir_free(clistCache->items[i]); } diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp index e8a3a12d3b..91af2f6b21 100644 --- a/src/modules/clist/clisttray.cpp +++ b/src/modules/clist/clisttray.cpp @@ -35,7 +35,7 @@ static UINT WM_TASKBARBUTTONCREATED; static BOOL mToolTipTrayTips = FALSE; static UINT_PTR cycleTimerId = 0; static int cycleStep = 0; -static UINT_PTR RefreshTimerId=0; /////by FYR +static UINT_PTR RefreshTimerId = 0; /////by FYR static CRITICAL_SECTION trayLockCS; // don't move to win2k.h, need new and old versions to work on 9x/2000/XP @@ -47,7 +47,7 @@ static CRITICAL_SECTION trayLockCS; #define initcheck if ( !fTrayInited) return -static BOOL fTrayInited=FALSE; +static BOOL fTrayInited = FALSE; static TCHAR* sttGetXStatus(const char* szProto) { @@ -61,7 +61,7 @@ static TCHAR* sttGetXStatus(const char* szProto) char* dbTitle2 = NULL; int xstatus = CallProtoServiceInt(NULL,szProto, "/GetXStatus", (WPARAM)&dbTitle, (LPARAM)&dbTitle2); if (dbTitle && xstatus) { - DBVARIANT dbv={0}; + DBVARIANT dbv = {0}; if ( !DBGetContactSettingTString(NULL, szProto, dbTitle, &dbv)) { if (dbv.ptszVal[0] != 0) result = mir_tstrdup(dbv.ptszVal); @@ -86,7 +86,7 @@ static void SetTaskBarIcon(const HICON hIcon, const TCHAR *szNewTip) TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto) { TCHAR *szStatus, *szSeparator; - TCHAR *ProtoXStatus=NULL; + TCHAR *ProtoXStatus = NULL; int t; PROTOACCOUNT* pa; initcheck NULL; @@ -191,7 +191,7 @@ int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int s int i; initcheck 0; lock; - for (i = 0; i < cli.trayIconCount; i++) + for (i=0; i < cli.trayIconCount; i++) if (cli.trayIcon[i].id == 0) break; @@ -228,7 +228,7 @@ void fnTrayIconRemove(HWND hwnd, const char *szProto) int i; initcheck; lock; - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { struct trayIconInfo_t* pii = &cli.trayIcon[i]; if (pii->id != 0 && !lstrcmpA(szProto, pii->szProto)) { NOTIFYICONDATA nid = { 0 }; @@ -288,7 +288,7 @@ int fnTrayIconInit(HWND hwnd) (averageMode < 0 || DBGetContactSettingByte(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) { cli.trayIconCount = netProtoCount; - for (int i = 0; i < accounts.getCount(); ++i) + for (int i=0; i < accounts.getCount(); ++i) { int j = cli.pfnGetAccountIndexByPos(i); if (j >= 0) @@ -329,7 +329,7 @@ int fnTrayIconDestroy(HWND hwnd) nid.cbSize = (cli.shellVersion >= 5) ? sizeof(nid) : NOTIFYICONDATA_V1_SIZE; nid.hWnd = hwnd; - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; nid.uID = cli.trayIcon[i].id; @@ -358,7 +358,7 @@ static VOID CALLBACK RefreshTimerProc(HWND, UINT, UINT_PTR, DWORD) int i; if (RefreshTimerId) { KillTimer(NULL, RefreshTimerId); - RefreshTimerId=0; + RefreshTimerId = 0; } for (i=0; i < accounts.getCount(); i++) { cli.pfnTrayIconUpdateBase(accounts[i]->szModuleName); @@ -379,7 +379,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer if ( !hNewIcon) { ulock; return -1; } - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; if (lstrcmpA(cli.trayIcon[i].szProto, szPreferredProto)) @@ -404,7 +404,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer //if there wasn't a suitable icon, change all the icons { - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; nid.uID = cli.trayIcon[i].id; @@ -424,11 +424,11 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer cli.trayIcon[i].isBase = isBase; if (DBGetContactSettingByte(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) { - DWORD time1=DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT)*200; - DWORD time2=DBGetContactSettingWord(NULL, "CList", "IconFlashTime", 550)+1000; - DWORD time=max(max(2000, time1), time2); - if (RefreshTimerId) {KillTimer(NULL, RefreshTimerId); RefreshTimerId=0;} - RefreshTimerId=SetTimer(NULL, 0, time, RefreshTimerProc); // if unknown base was changed - than show preffered proto icon for 2 sec and reset it to original one after timeout + DWORD time1 = DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT)*200; + DWORD time2 = DBGetContactSettingWord(NULL, "CList", "IconFlashTime", 550)+1000; + DWORD time = max(max(2000, time1), time2); + if (RefreshTimerId) {KillTimer(NULL, RefreshTimerId); RefreshTimerId = 0;} + RefreshTimerId = SetTimer(NULL, 0, time, RefreshTimerProc); // if unknown base was changed - than show preffered proto icon for 2 sec and reset it to original one after timeout } { ulock; return i; } } @@ -443,7 +443,7 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto) lock; if (szPreferredProto) { - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; if (lstrcmpA(cli.trayIcon[i].szProto, szPreferredProto)) @@ -461,7 +461,7 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto) } //if there wasn't a specific icon, there will only be one suitable - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; @@ -521,7 +521,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto) cli.cycleTimerId = 0; } - for (i = 0; i < accounts.getCount(); i++) { + for (i=0; i < accounts.getCount(); i++) { if ( !lstrcmpA(szChangedProto, accounts[i]->szModuleName)) cycleStep = i - 1; } @@ -560,9 +560,9 @@ void fnTrayIconUpdateBase(const char *szChangedProto) break; } case SETTING_TRAYICON_CYCLE: - cli.cycleTimerId = + cli.cycleTimerId = SetTimer(NULL, 0, DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc); - changed = + changed = cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon (hCListImages, cli.pfnIconFromStatusMode(szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0), NULL), ILD_NORMAL), NULL); @@ -595,7 +595,7 @@ void fnTrayIconSetToBase(char *szPreferredProto) initcheck; lock; - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; if (lstrcmpA(cli.trayIcon[i].szProto, szPreferredProto)) @@ -605,7 +605,7 @@ void fnTrayIconSetToBase(char *szPreferredProto) } //if there wasn't a specific icon, there will only be one suitable - for (i = 0; i < cli.trayIconCount; i++) { + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; cli.pfnTrayIconUpdate(cli.trayIcon[i].hBaseIcon, NULL, szPreferredProto, 1); @@ -686,9 +686,9 @@ static void CALLBACK TrayToolTipTimerProc(HWND hwnd, UINT, UINT_PTR id, DWORD) if (n >= 0 && n < cli.trayIconCount) szTipCur = cli.trayIcon[n].ptszToolTip; } - ti.rcItem.left = pt.x - 10; - ti.rcItem.right = pt.x + 10; - ti.rcItem.top = pt.y - 10; + ti.rcItem.left = pt.x - 10; + ti.rcItem.right = pt.x + 10; + ti.rcItem.top = pt.y - 10; ti.rcItem.bottom = pt.y + 10; ti.cbSize = sizeof(ti); ti.isTreeFocused = GetFocus() == cli.hwndContactList ? 1 : 0; @@ -748,7 +748,7 @@ INT_PTR fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam) POINT pt; HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0); - for (int i = 0; i < cli.trayIconCount; ++i) + for (int i=0; i < cli.trayIconCount; ++i) { if ((unsigned)cli.trayIcon[i].id == msg->wParam) { @@ -945,12 +945,12 @@ void fnInitTray(void) InitializeCriticalSection(&trayLockCS); if (cli.shellVersion >= 5) CreateServiceFunction(MS_CLIST_SYSTRAY_NOTIFY, pfnCListTrayNotifyStub); - fTrayInited=TRUE; + fTrayInited = TRUE; } void fnUninitTray(void) { - fTrayInited=FALSE; + fTrayInited = FALSE; DeleteCriticalSection(&trayLockCS); } void fnLockTray(void) diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp index 8524a4cf3a..bdb0fe356c 100644 --- a/src/modules/clist/clui.cpp +++ b/src/modules/clist/clui.cpp @@ -247,10 +247,10 @@ LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l { LRESULT result; MSG m; - m.hwnd=hwnd; - m.message=msg; - m.wParam=wParam; - m.lParam=lParam; + m.hwnd = hwnd; + m.message = msg; + m.wParam = wParam; + m.lParam = lParam; if (cli.pfnDocking_ProcessWindowMessage((WPARAM)&m, (LPARAM)&result)) return result; if (cli.pfnTrayIconProcessMessage((WPARAM)&m, (LPARAM)&result)) @@ -485,7 +485,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { HICON hIcon = LoadSkinnedIcon(SKINICON_OTHER_MAINMENU); HBITMAP hBmp = ConvertIconToBitmap(hIcon, NULL, 0); - IconLib_ReleaseIcon(hIcon, NULL); + IcoLib_ReleaseIcon(hIcon, NULL); mii.cbSize = sizeof(mii); mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_DATA; @@ -638,7 +638,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (cluiopt.transparent) { if ( !transparentFocus && GetForegroundWindow() != hwnd && setLayeredWindowAttributes) { setLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)cluiopt.alpha, LWA_ALPHA); - transparentFocus=1; + transparentFocus = 1; SetTimer(hwnd, TM_AUTOALPHA, 250, NULL); } } @@ -1049,13 +1049,13 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM HICON hIcon = LoadSkinProtoIcon(szProto, status); DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - g_IconHeight) >> 1, hIcon, g_IconWidth, g_IconHeight, 0, NULL, DI_NORMAL); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); if (Proto_IsAccountLocked(Proto_GetAccount(szProto))) { hIcon = LoadSkinnedIcon(SKINICON_OTHER_STATUS_LOCKED); if (hIcon != NULL) { DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - g_IconHeight) >> 1, hIcon, g_IconWidth, g_IconHeight, 0, NULL, DI_NORMAL); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); } } @@ -1087,7 +1087,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (dis->itemData == MENU_MIRANDAMENU) { HICON hIcon = LoadSkinnedIcon(SKINICON_OTHER_MAINMENU); fnDrawMenuItem(dis, CopyIcon(hIcon), NULL); - IconLib_ReleaseIcon(hIcon, NULL); + IcoLib_ReleaseIcon(hIcon, NULL); return TRUE; } return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); diff --git a/src/modules/clist/cluiservices.cpp b/src/modules/clist/cluiservices.cpp index 30f1a55322..ea3c153d36 100644 --- a/src/modules/clist/cluiservices.cpp +++ b/src/modules/clist/cluiservices.cpp @@ -170,7 +170,7 @@ void fnCluiProtocolStatusChanged(int, const char*) RECT rc; GetClientRect(cli.hwndStatus, &rc); rc.right -= borders[0] * 2 + (DBGetContactSettingByte(NULL, "CLUI", "ShowGrip", 1) ? GetSystemMetrics(SM_CXVSCROLL) : 0); - for (i = 0; i < cli.menuProtoCount; i++) + for (i=0; i < cli.menuProtoCount; i++) partWidths[ i ] = (i+1) * rc.right / cli.menuProtoCount - (borders[2] >> 1); } else { @@ -180,7 +180,7 @@ void fnCluiProtocolStatusChanged(int, const char*) hdc = GetDC(NULL); SelectObject(hdc, (HFONT) SendMessage(cli.hwndStatus, WM_GETFONT, 0, 0)); - for (i = 0; i < cli.menuProtoCount; i++) { //count down since built in ones tend to go at the end + for (i=0; i < cli.menuProtoCount; i++) { //count down since built in ones tend to go at the end int x = 2; if (showOpts & 1) x += g_IconWidth; @@ -215,7 +215,7 @@ void fnCluiProtocolStatusChanged(int, const char*) flags = SBT_OWNERDRAW; if (DBGetContactSettingByte(NULL, "CLUI", "SBarBevel", 1) == 0) flags |= SBT_NOBORDERS; - for (i = 0; i < cli.menuProtoCount; i++) { + for (i=0; i < cli.menuProtoCount; i++) { SendMessage(cli.hwndStatus, SB_SETTEXT, i | flags, (LPARAM)cli.menuProtos[i].szProto); } } diff --git a/src/modules/clist/contact.cpp b/src/modules/clist/contact.cpp index 5fce5cb1f4..9404446db5 100644 --- a/src/modules/clist/contact.cpp +++ b/src/modules/clist/contact.cpp @@ -31,7 +31,7 @@ int sortByProto; static const struct { int status, order; -} statusModeOrder[]={ +} statusModeOrder[] = { {ID_STATUS_OFFLINE, 500}, {ID_STATUS_ONLINE, 10}, {ID_STATUS_AWAY, 200}, @@ -60,7 +60,7 @@ void fnChangeContactIcon(HANDLE hContact, int iIcon, int add) int GetStatusModeOrdering(int statusMode) { int i; - for (i = 0; i < SIZEOF(statusModeOrder); i++) + for (i=0; i < SIZEOF(statusModeOrder); i++) if (statusModeOrder[i].status == statusMode) return statusModeOrder[i].order; return 1000; diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index deb5de8227..33b94d6cf8 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -105,8 +105,8 @@ PMO_IntMenuItem MO_RecursiveWalkMenu(PMO_IntMenuItem parent, pfnWalkFunc func, v } /////////////////////////////////////////////////////////////////////////////// -//wparam=0 -//lparam=LPMEASUREITEMSTRUCT +//wparam = 0 +//lparam = LPMEASUREITEMSTRUCT int MO_MeasureMenuItem(LPMEASUREITEMSTRUCT mis) { // prevent win9x from ugly menus displaying when there is no icon @@ -132,8 +132,8 @@ int MO_MeasureMenuItem(LPMEASUREITEMSTRUCT mis) } /////////////////////////////////////////////////////////////////////////////// -//wparam=0 -//lparam=LPDRAWITEMSTRUCT +//wparam = 0 +//lparam = LPDRAWITEMSTRUCT int MO_DrawMenuItem(LPDRAWITEMSTRUCT dis) { if ( !bIsGenMenuInited) @@ -188,7 +188,7 @@ int MO_RemoveAllObjects() return 0; } -//wparam=MenuObjectHandle +//wparam = MenuObjectHandle INT_PTR MO_RemoveMenuObject(WPARAM wParam, LPARAM) { if ( !bIsGenMenuInited) @@ -204,8 +204,8 @@ INT_PTR MO_RemoveMenuObject(WPARAM wParam, LPARAM) return 0; } -//wparam=MenuObjectHandle -//lparam=vKey +//wparam = MenuObjectHandle +//lparam = vKey INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey) { if ( !bIsGenMenuInited) @@ -253,8 +253,8 @@ INT_PTR MO_GetProtoRootMenu(WPARAM wParam, LPARAM lParam) return NULL; } -//wparam=MenuItemHandle -//lparam=PMO_MenuItem +//wparam = MenuItemHandle +//lparam = PMO_MenuItem INT_PTR MO_GetMenuItem(WPARAM wParam, LPARAM lParam) { PMO_MenuItem mi = (PMO_MenuItem)lParam; @@ -323,7 +323,7 @@ int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmi) if (hIcon != NULL) { pimi->hIcolibItem = pmi->hIcolibItem; pimi->iconId = ImageList_ReplaceIcon(pimi->parent->m_hMenuIcons, pimi->iconId, hIcon); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); } else pimi->iconId = -1, pimi->hIcolibItem = NULL; } @@ -492,9 +492,9 @@ int MO_SetOptionsMenuObject(HANDLE handle, int setting, INT_PTR value) return res; } -//wparam=0; -//lparam=PMenuParam; -//result=MenuObjectHandle +//wparam = 0; +//lparam = PMenuParam; +//result = MenuObjectHandle INT_PTR MO_CreateNewMenuObject(WPARAM, LPARAM lParam) { PMenuParam pmp = (PMenuParam)lParam; @@ -514,8 +514,8 @@ INT_PTR MO_CreateNewMenuObject(WPARAM, LPARAM lParam) return p->id; } -//wparam=MenuItemHandle -//lparam=0 +//wparam = MenuItemHandle +//lparam = 0 static int FreeMenuItem(TMO_IntMenuItem* pimi, void*) { @@ -593,8 +593,8 @@ static int GetNextObjectMenuItemId() return NextObjectMenuItemId++; } -//wparam=MenuObjectHandle -//lparam=PMO_MenuItem +//wparam = MenuObjectHandle +//lparam = PMO_MenuItem //return MenuItemHandle PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) { @@ -632,7 +632,7 @@ PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) HICON hIcon = IcoLib_GetIconByHandle(pmi->hIcolibItem, false); p->iconId = ImageList_AddIcon(pmo->m_hMenuIcons, hIcon); p->hIcolibItem = pmi->hIcolibItem; - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); } else { HANDLE hIcolibItem = IcoLib_IsManaged(pmi->hIcon); @@ -660,8 +660,8 @@ PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi) return p; } -//wparam=MenuObjectHandle -//lparam=PMO_MenuItem +//wparam = MenuObjectHandle +//lparam = PMO_MenuItem int FindRoot(PMO_IntMenuItem pimi, void* param) { @@ -728,7 +728,7 @@ static int WhereToPlace(HMENU hMenu, PMO_MenuItem mi) MENUITEMINFO mii = { 0 }; mii.cbSize = MENUITEMINFO_V4_SIZE; mii.fMask = MIIM_SUBMENU | MIIM_DATA; - for (int i=GetMenuItemCount(hMenu)-1; i >= 0; i--) { + for (int i = GetMenuItemCount(hMenu)-1; i >= 0; i--) { GetMenuItemInfo(hMenu, i, TRUE, &mii); if (mii.fType != MFT_SEPARATOR) { PMO_IntMenuItem pimi = MO_GetIntMenuItem((HGENMENU)mii.dwItemData); @@ -1007,7 +1007,7 @@ static int MO_ReloadIcon(PMO_IntMenuItem pmi, void*) if (newIcon) ImageList_ReplaceIcon(pmi->parent->m_hMenuIcons, pmi->iconId, newIcon); - IconLib_ReleaseIcon(newIcon, 0); + IcoLib_ReleaseIcon(newIcon, 0); } return FALSE; @@ -1074,7 +1074,7 @@ static int MO_RegisterIcon(PMO_IntMenuItem pmi, void*) Safe_DestroyIcon(hIcon); if (hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)iconame)) { ImageList_ReplaceIcon(pmi->parent->m_hMenuIcons, pmi->iconId, hIcon); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); } } @@ -1183,7 +1183,7 @@ int UnitGenMenu() if (bIsGenMenuInited) { { mir_cslock lck(csMenuHook); MO_RemoveAllObjects(); - bIsGenMenuInited=false; + bIsGenMenuInited = false; } DeleteCriticalSection(&csMenuHook); diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index 4ec48d0e20..0e45e8efa0 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -144,9 +144,9 @@ static int BuildMenuObjectsTree(HWND hwndDlg) if (g_menus[i]->id == (int)hStatusMenuObject || !g_menus[i]->m_bUseUserDefinedItems) continue; - tvis.item.lParam = (LPARAM)g_menus[i]->id; + tvis.item.lParam = (LPARAM)g_menus[i]->id; tvis.item.pszText = Langpack_PcharToTchar(g_menus[i]->Name); - tvis.item.iImage = tvis.item.iSelectedImage = TRUE; + tvis.item.iImage = tvis.item.iSelectedImage = TRUE; TreeView_InsertItem(hTree, &tvis); mir_free(tvis.item.pszText); } @@ -156,8 +156,8 @@ static int BuildMenuObjectsTree(HWND hwndDlg) static int sortfunc(const void *a, const void *b) { lpMenuItemOptData *sd1, *sd2; - sd1=(lpMenuItemOptData *)a; - sd2=(lpMenuItemOptData *)b; + sd1 = (lpMenuItemOptData *)a; + sd2 = (lpMenuItemOptData *)b; if ((*sd1)->pos > (*sd2)->pos) return 1; @@ -186,10 +186,10 @@ static int InsertSeparator(HWND hwndDlg) PD = (MenuItemOptData*)mir_alloc(sizeof(MenuItemOptData)); ZeroMemory(PD, sizeof(MenuItemOptData)); - PD->id = -1; + PD->id = -1; PD->name = mir_tstrdup(STR_SEPARATOR); PD->show = TRUE; - PD->pos = ((MenuItemOptData *)tvi.lParam)->pos-1; + PD->pos = ((MenuItemOptData *)tvi.lParam)->pos-1; tvis.item.lParam = (LPARAM)(PD); tvis.item.pszText = PD->name; @@ -320,7 +320,7 @@ static int BuildTree(HWND hwndDlg, int MenuObjectId, BOOL bReread) HTREEITEM hti = (HTREEITEM)SendDlgItemMessage(hwndDlg, IDC_MENUITEMS, TVM_INSERTITEM, 0, (LPARAM)&tvis); if (first) { TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_MENUITEMS), hti); - first=FALSE; + first = FALSE; } lastpos = PDar[i]->pos; @@ -371,51 +371,51 @@ static HTREEITEM MoveItemAbove(HWND hTreeWnd, HTREEITEM hItem, HTREEITEM hInsert return NULL; if ( !TreeView_DeleteItem(hTreeWnd, hItem)) return NULL; - tvis.hParent=NULL; - tvis.hInsertAfter=hInsertAfter; + tvis.hParent = NULL; + tvis.hInsertAfter = hInsertAfter; return TreeView_InsertItem(hTreeWnd, &tvis); } return NULL; } -WNDPROC MyOldWindowProc=NULL; +WNDPROC MyOldWindowProc = NULL; LRESULT CALLBACK LBTNDOWNProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_LBUTTONDOWN && !(GetKeyState(VK_CONTROL)&0x8000)) { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(lParam); - hti.pt.y=(short)HIWORD(lParam); + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); // ClientToScreen(hwndDlg, &hti.pt); // ScreenToClient(GetDlgItem(hwndDlg, IDC_MENUITEMS), &hti.pt); TreeView_HitTest(hwnd, &hti); if (hti.flags&TVHT_ONITEMLABEL) { /// LabelClicked Set/unset selection TVITEM tvi; - HWND tvw=hwnd; - tvi.mask=TVIF_HANDLE|TVIF_PARAM; - tvi.hItem=hti.hItem; + HWND tvw = hwnd; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = hti.hItem; TreeView_GetItem(tvw, &tvi); if ( !((MenuItemOptData *)tvi.lParam)->isSelected) { /* is not Selected*/ // reset all selection except current HTREEITEM hit; - hit=TreeView_GetRoot(tvw); + hit = TreeView_GetRoot(tvw); if (hit) do { - TVITEM tvi={0}; - tvi.mask=TVIF_HANDLE|TVIF_PARAM; - tvi.hItem=hit; + TVITEM tvi = {0}; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = hit; TreeView_GetItem(tvw, &tvi); if (hti.hItem != hit) - ((MenuItemOptData *)tvi.lParam)->isSelected=0; + ((MenuItemOptData *)tvi.lParam)->isSelected = 0; else - ((MenuItemOptData *)tvi.lParam)->isSelected=1; + ((MenuItemOptData *)tvi.lParam)->isSelected = 1; TreeView_SetItem(tvw, &tvi); } - while (hit=TreeView_GetNextSibling(tvw, hit)); + while (hit = TreeView_GetNextSibling(tvw, hit)); } } } return CallWindowProc(MyOldWindowProc, hwnd, uMsg, wParam, lParam); @@ -429,7 +429,7 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - dat=(struct OrderData*)mir_alloc(sizeof(struct OrderData)); + dat = (struct OrderData*)mir_alloc(sizeof(struct OrderData)); SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MENUITEMS), GWLP_USERDATA, (LONG_PTR)dat); dat->dragging = 0; dat->iInitMenuValue = DBGetContactSettingByte(NULL, "CList", "MoveProtoMenus", TRUE); @@ -437,7 +437,7 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MENUITEMS), GWLP_WNDPROC, (LONG_PTR)&LBTNDOWNProc); { HIMAGELIST himlCheckBoxes; - himlCheckBoxes=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), + himlCheckBoxes = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 2, 2); ImageList_AddIcon_IconLibLoaded(himlCheckBoxes, SKINICON_OTHER_NOTICK); @@ -476,12 +476,12 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA HTREEITEM hti; MenuItemOptData *iod; - hti=TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_MENUITEMS)); + hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_MENUITEMS)); if (hti == NULL) break; - tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.hItem=hti; + tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.hItem = hti; TreeView_GetItem(GetDlgItem(hwndDlg, IDC_MENUITEMS), &tvi); iod = (MenuItemOptData *)tvi.lParam; @@ -557,33 +557,33 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch (hdr->code) { case NM_CUSTOMDRAW: { - int i= handleCustomDraw(GetDlgItem(hwndDlg, IDC_MENUITEMS), (LPNMTVCUSTOMDRAW) lParam); + int i = handleCustomDraw(GetDlgItem(hwndDlg, IDC_MENUITEMS), (LPNMTVCUSTOMDRAW) lParam); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, i); return TRUE; } case TVN_BEGINDRAGA: SetCapture(hwndDlg); - dat->dragging=1; - dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem; + dat->dragging = 1; + dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_MENUITEMS), dat->hDragItem); break; case NM_CLICK: { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); ScreenToClient(hdr->hwndFrom, &hti.pt); if (TreeView_HitTest(hdr->hwndFrom, &hti)) { if (hti.flags&TVHT_ONITEMICON) { TVITEM tvi; - tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.hItem=hti.hItem; + tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.hItem = hti.hItem; TreeView_GetItem(hdr->hwndFrom, &tvi); - tvi.iImage=tvi.iSelectedImage=!tvi.iImage; - ((MenuItemOptData *)tvi.lParam)->show=tvi.iImage; + tvi.iImage = tvi.iSelectedImage = !tvi.iImage; + ((MenuItemOptData *)tvi.lParam)->show = tvi.iImage; TreeView_SetItem(hdr->hwndFrom, &tvi); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -594,15 +594,15 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (hti.flags&TVHT_ONITEMLABEL) { /// LabelClicked Set/unset selection TVITEM tvi; - HWND tvw=hdr->hwndFrom; - tvi.mask=TVIF_HANDLE|TVIF_PARAM; - tvi.hItem=hti.hItem; + HWND tvw = hdr->hwndFrom; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = hti.hItem; TreeView_GetItem(tvw, &tvi); if (GetKeyState(VK_CONTROL)&0x8000) { if (((MenuItemOptData *)tvi.lParam)->isSelected) - ((MenuItemOptData *)tvi.lParam)->isSelected=0; + ((MenuItemOptData *)tvi.lParam)->isSelected = 0; else - ((MenuItemOptData *)tvi.lParam)->isSelected=1; //current selection order++. + ((MenuItemOptData *)tvi.lParam)->isSelected = 1; //current selection order++. TreeView_SetItem(tvw, &tvi); } else if (GetKeyState(VK_SHIFT)&0x8000) { @@ -611,21 +611,21 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA else { // reset all selection except current HTREEITEM hit; - hit=TreeView_GetRoot(tvw); + hit = TreeView_GetRoot(tvw); if (hit) do { - TVITEM tvi={0}; - tvi.mask=TVIF_HANDLE|TVIF_PARAM; - tvi.hItem=hit; + TVITEM tvi = {0}; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = hit; TreeView_GetItem(tvw, &tvi); if (hti.hItem != hit) - ((MenuItemOptData *)tvi.lParam)->isSelected=0; + ((MenuItemOptData *)tvi.lParam)->isSelected = 0; else - ((MenuItemOptData *)tvi.lParam)->isSelected=1; + ((MenuItemOptData *)tvi.lParam)->isSelected = 1; TreeView_SetItem(tvw, &tvi); } - while (hit=TreeView_GetNextSibling(tvw, hit)); + while (hit = TreeView_GetNextSibling(tvw, hit)); } } } break; } @@ -633,7 +633,7 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { LPNMTREEVIEW pn; pn = (LPNMTREEVIEW) lParam; - //((MenuItemOptData *)(pn->itemNew.lParam))->isSelected=1; + //((MenuItemOptData *)(pn->itemNew.lParam))->isSelected = 1; /*if (pn->action == NotKeyPressed) { remove all selection @@ -653,12 +653,12 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_GENMENU_DEFAULT), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_GENMENU_SET), FALSE); - hti=TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_MENUITEMS)); + hti = TreeView_GetSelection(GetDlgItem(hwndDlg, IDC_MENUITEMS)); if (hti == NULL) break; - tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.hItem=hti; + tvi.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.hItem = hti; TreeView_GetItem(GetDlgItem(hwndDlg, IDC_MENUITEMS), &tvi); if (tvi.lParam == 0) @@ -688,8 +688,8 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(lParam); - hti.pt.y=(short)HIWORD(lParam); + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(GetDlgItem(hwndDlg, IDC_MENUITEMS), &hti.pt); TreeView_HitTest(GetDlgItem(hwndDlg, IDC_MENUITEMS), &hti); @@ -714,53 +714,53 @@ static INT_PTR CALLBACK GenMenuOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break; TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_MENUITEMS), NULL, 0); - dat->dragging=0; + dat->dragging = 0; ReleaseCapture(); { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(lParam); - hti.pt.y=(short)HIWORD(lParam); + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(GetDlgItem(hwndDlg, IDC_MENUITEMS), &hti.pt); hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_MENUITEMS))/2; TreeView_HitTest(GetDlgItem(hwndDlg, IDC_MENUITEMS), &hti); - if (hti.flags&TVHT_ABOVE) hti.hItem=TVI_FIRST; + if (hti.flags&TVHT_ABOVE) hti.hItem = TVI_FIRST; if (dat->hDragItem == hti.hItem) break; - dat->hDragItem=NULL; + dat->hDragItem = NULL; if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) { HWND tvw; HTREEITEM * pSIT; - HTREEITEM FirstItem=NULL; + HTREEITEM FirstItem = NULL; UINT uITCnt, uSic; - tvw=GetDlgItem(hwndDlg, IDC_MENUITEMS); - uITCnt=TreeView_GetCount(tvw); - uSic=0; + tvw = GetDlgItem(hwndDlg, IDC_MENUITEMS); + uITCnt = TreeView_GetCount(tvw); + uSic = 0; if (uITCnt) { - pSIT=(HTREEITEM *)mir_alloc(sizeof(HTREEITEM)*uITCnt); + pSIT = (HTREEITEM *)mir_alloc(sizeof(HTREEITEM)*uITCnt); if (pSIT) { HTREEITEM hit; - hit=TreeView_GetRoot(tvw); + hit = TreeView_GetRoot(tvw); if (hit) do { - TVITEM tvi={0}; - tvi.mask=TVIF_HANDLE|TVIF_PARAM; - tvi.hItem=hit; + TVITEM tvi = {0}; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = hit; TreeView_GetItem(tvw, &tvi); if (((MenuItemOptData *)tvi.lParam)->isSelected) { - pSIT[uSic]=tvi.hItem; + pSIT[uSic] = tvi.hItem; uSic++; } - }while (hit=TreeView_GetNextSibling(tvw, hit)); + }while (hit = TreeView_GetNextSibling(tvw, hit)); // Proceed moving { UINT i; HTREEITEM insertAfter; - insertAfter=hti.hItem; + insertAfter = hti.hItem; for (i=0; inmcd.dwItemSpec; TCHAR buf[255]; TVITEM tvi = {0}; - int k=0; + int k = 0; tvi.mask = TVIF_HANDLE |TVIF_PARAM|TVIS_SELECTED|TVIF_TEXT|TVIF_IMAGE; - tvi.stateMask=TVIS_SELECTED; + tvi.stateMask = TVIS_SELECTED; tvi.hItem = hItem; - tvi.pszText=(LPTSTR)(&buf); - tvi.cchTextMax=254; + tvi.pszText = (LPTSTR)(&buf); + tvi.cchTextMax = 254; TreeView_GetItem(hWndTreeView, &tvi); if (((MenuItemOptData *)tvi.lParam)->isSelected) { pNMTVCD->clrTextBk = GetSysColor(COLOR_HIGHLIGHT); - pNMTVCD->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT); + pNMTVCD->clrText = GetSysColor(COLOR_HIGHLIGHTTEXT); } else { pNMTVCD->clrTextBk = GetSysColor(COLOR_WINDOW); - pNMTVCD->clrText = GetSysColor(COLOR_WINDOWTEXT); + pNMTVCD->clrText = GetSysColor(COLOR_WINDOWTEXT); } /* At this point, you can change the background colors for the item @@ -822,14 +822,14 @@ long handleCustomDraw(HWND hWndTreeView, LPNMTVCUSTOMDRAW pNMTVCD) HBRUSH br; SIZE sz; RECT rc; - k=1; + k = 1; GetTextExtentPoint32(pNMTVCD->nmcd.hdc, tvi.pszText, lstrlen(tvi.pszText), &sz); - if (sz.cx+3>pNMTVCD->nmcd.rc.right-pNMTVCD->nmcd.rc.left) rc=pNMTVCD->nmcd.rc; + if (sz.cx+3>pNMTVCD->nmcd.rc.right-pNMTVCD->nmcd.rc.left) rc = pNMTVCD->nmcd.rc; else SetRect(&rc, pNMTVCD->nmcd.rc.left, pNMTVCD->nmcd.rc.top, pNMTVCD->nmcd.rc.left+sz.cx+3, pNMTVCD->nmcd.rc.bottom); - br=CreateSolidBrush(pNMTVCD->clrTextBk); + br = CreateSolidBrush(pNMTVCD->clrTextBk); SetTextColor(pNMTVCD->nmcd.hdc, pNMTVCD->clrText); SetBkColor(pNMTVCD->nmcd.hdc, pNMTVCD->clrTextBk); FillRect(pNMTVCD->nmcd.hdc, &rc, br); @@ -848,7 +848,7 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM int GenMenuOptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize=sizeof(odp); + odp.cbSize = sizeof(odp); odp.hInstance = hInst; odp.pszGroup = LPGEN("Customize"); diff --git a/src/modules/clist/groups.cpp b/src/modules/clist/groups.cpp index 714ed0e223..c3a6403fe0 100644 --- a/src/modules/clist/groups.cpp +++ b/src/modules/clist/groups.cpp @@ -34,7 +34,7 @@ static int CountGroups(void) int i; char str[33]; - for (i = 0;; i++) { + for (i=0;; i++) { _itoa(i, str, 10); if (DBGetContactSetting(NULL, "CListGroups", str, &dbv)) break; @@ -49,7 +49,7 @@ static int GroupNameExists(const TCHAR *name, int skipGroup) DBVARIANT dbv; int i; - for (i = 0;; i++) { + for (i=0;; i++) { if (i == skipGroup) continue; _itoa(i, idstr, 10); @@ -226,7 +226,7 @@ static INT_PTR DeleteGroup(WPARAM wParam, LPARAM) int len; len = lstrlen(name); - for (i = 0;; i++) { + for (i=0;; i++) { _itoa(i, str, 10); if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv)) break; @@ -291,7 +291,7 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) int len, i; len = lstrlen(oldName); - for (i = 0;; i++) { + for (i=0;; i++) { if (i == groupId) continue; _itoa(i, idstr, 10); @@ -314,7 +314,7 @@ static int RenameGroupWithMove(int groupId, const TCHAR *szName, int move) pszLastBackslash = _tcsrchr(str, '\\'); if (pszLastBackslash != NULL) { *pszLastBackslash = '\0'; - for (i = 0;; i++) { + for (i=0;; i++) { _itoa(i, idstr, 10); if (DBGetContactSettingTString(NULL, "CListGroups", idstr, &dbv)) break; @@ -541,7 +541,7 @@ static INT_PTR BuildGroupMenu(WPARAM, LPARAM) int InitGroupServices(void) { - for (int i = 0;; i++) + for (int i=0;; i++) { char str[32]; _itoa(i, str, 10); diff --git a/src/modules/clist/keyboard.cpp b/src/modules/clist/keyboard.cpp index 2942f7137e..e580681e5c 100644 --- a/src/modules/clist/keyboard.cpp +++ b/src/modules/clist/keyboard.cpp @@ -32,7 +32,7 @@ static INT_PTR hkHideShow(WPARAM, LPARAM) /* INT_PTR hkSearch(WPARAM wParam, LPARAM lParam) { - DBVARIANT dbv={0}; + DBVARIANT dbv = {0}; if ( !DBGetContactSettingString(NULL, "CList", "SearchUrl", &dbv)) { CallService(MS_UTILS_OPENURL, DBGetContactSettingByte(NULL, "CList", "HKSearchNewWnd", 0), (LPARAM)dbv.pszVal); DBFreeVariant(&dbv); @@ -100,11 +100,11 @@ int InitClistHotKeys(void) shk.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, 'I'); Hotkey_Register(&shk); /* - shk.pszDescription="Search in site"; - shk.pszName="SearchInWeb"; - shk.pszSection="Main"; - shk.pszService="CLIST/HK/Search"; - shk.DefHotKey=846; + shk.pszDescription = "Search in site"; + shk.pszName = "SearchInWeb"; + shk.pszSection = "Main"; + shk.pszService = "CLIST/HK/Search"; + shk.DefHotKey = 846; Hotkey_Register(&shk); */ shk.ptszDescription = _T("Open Options Page"); @@ -129,25 +129,25 @@ int InitClistHotKeys(void) Hotkey_Register(&shk); /* - shk.pszDescription="Close Miranda"; - shk.pszName="CloseMiranda"; - shk.pszSection="Main"; - shk.pszService="CLIST/HK/CloseMiranda"; - shk.DefHotKey=0; + shk.pszDescription = "Close Miranda"; + shk.pszName = "CloseMiranda"; + shk.pszSection = "Main"; + shk.pszService = "CLIST/HK/CloseMiranda"; + shk.DefHotKey = 0; Hotkey_Register(&shk); - shk.pszDescription="Restore last status"; - shk.pszName="RestoreLastStatus"; - shk.pszSection="Status"; - shk.pszService="CLIST/HK/RestoreStatus"; - shk.DefHotKey=0; + shk.pszDescription = "Restore last status"; + shk.pszName = "RestoreLastStatus"; + shk.pszSection = "Status"; + shk.pszService = "CLIST/HK/RestoreStatus"; + shk.DefHotKey = 0; Hotkey_Register(&shk); - shk.pszDescription="Set All Offline"; - shk.pszName="AllOffline"; - shk.pszSection="Status"; - shk.pszService="CLIST/HK/AllOffline"; - shk.DefHotKey=0; + shk.pszDescription = "Set All Offline"; + shk.pszName = "AllOffline"; + shk.pszSection = "Status"; + shk.pszService = "CLIST/HK/AllOffline"; + shk.DefHotKey = 0; Hotkey_Register(&shk); */ return 0; diff --git a/src/modules/clist/movetogroup.cpp b/src/modules/clist/movetogroup.cpp index 2075fa3648..eaf4bc1906 100644 --- a/src/modules/clist/movetogroup.cpp +++ b/src/modules/clist/movetogroup.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h" HANDLE hOnCntMenuBuild; -HGENMENU hMoveToGroupItem=0, hPriorityItem = 0, hFloatingItem = 0; +HGENMENU hMoveToGroupItem = 0, hPriorityItem = 0, hFloatingItem = 0; LIST lphGroupsItems(5); @@ -56,23 +56,23 @@ static TCHAR* PrepareGroupName(TCHAR* str) d = p = (TCHAR*)mir_alloc(sizeof(TCHAR)*(2*_tcslen(str)+1)); while (*str) { if (*str == '&') - *d++ = '&'; - *d++ = *str++; + *d++='&'; + *d++=*str++; } - *d++ = 0; + *d++=0; return p; } static void AddGroupItem(HGENMENU hRoot, TCHAR* name, int pos, WPARAM param, bool checked) { CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.hParentMenu = hRoot; + mi.cbSize = sizeof(mi); + mi.hParentMenu = hRoot; mi.popupPosition = param; // param to pszService - only with CMIF_CHILDPOPUP !!!!!! - mi.position = pos; - mi.ptszName = PrepareGroupName(name); - mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; + mi.position = pos; + mi.ptszName = PrepareGroupName(name); + mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; if (checked) mi.flags |= CMIF_CHECKED; mi.pszService = MTG_MOVE; @@ -100,7 +100,7 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM) hMoveToGroupItem = Menu_AddContactMenuItem(&mi); } - for (i = 0; i < lphGroupsItems.getCount(); i++) + for (i=0; i < lphGroupsItems.getCount(); i++) CallService(MS_CLIST_REMOVECONTACTMENUITEM, (WPARAM)lphGroupsItems[i], 0); lphGroupsItems.destroy(); @@ -112,7 +112,7 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM) pos += 100000; // Separator - for (i = 0; ; ++i) + for (i=0; ; ++i) { char intname[20]; _itoa(i, intname, 10); @@ -127,7 +127,7 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM) mir_free(dbv.ptszVal); } - for (i = 0; i < groups.getCount(); ++i) + for (i=0; i < groups.getCount(); ++i) { bool checked = szContactGroup && !_tcscmp(szContactGroup, groups[i].name); AddGroupItem(hMoveToGroupItem, groups[i].name, ++pos, groups[i].position, checked); @@ -147,7 +147,7 @@ static INT_PTR MTG_DOMOVE(WPARAM wParam, LPARAM lParam) void MTG_OnmodulesLoad() { - hOnCntMenuBuild=HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnContactMenuBuild); + hOnCntMenuBuild = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnContactMenuBuild); CreateServiceFunction(MTG_MOVE, MTG_DOMOVE); } diff --git a/src/modules/clist/protocolorder.cpp b/src/modules/clist/protocolorder.cpp index 2eeb402f42..cebda085cb 100644 --- a/src/modules/clist/protocolorder.cpp +++ b/src/modules/clist/protocolorder.cpp @@ -64,7 +64,7 @@ bool CheckProtocolOrder(void) for (;;) { // Find account with this id - for (i = 0; i < accounts.getCount(); i++) + for (i=0; i < accounts.getCount(); i++) if (accounts[i]->iOrder == id) break; // Account with id not found @@ -72,7 +72,7 @@ bool CheckProtocolOrder(void) { // Check if this is skipped id, if it is decrement all other ids bool found = false; - for (i = 0; i < accounts.getCount(); i++) + for (i=0; i < accounts.getCount(); i++) { if (accounts[i]->iOrder < 1000000 && accounts[i]->iOrder > id) { @@ -90,7 +90,7 @@ bool CheckProtocolOrder(void) if (id < accounts.getCount()) { // Remove huge ids - for (i = 0; i < accounts.getCount(); i++) + for (i=0; i < accounts.getCount(); i++) { if (accounts[i]->iOrder >= 1000000) accounts[i]->iOrder = id++; @@ -101,7 +101,7 @@ bool CheckProtocolOrder(void) if (id < accounts.getCount()) { // Remove duplicate ids - for (i = 0; i < accounts.getCount(); i++) + for (i=0; i < accounts.getCount(); i++) { bool found = false; for (int j = 0; j < accounts.getCount(); j++) @@ -135,7 +135,7 @@ int FillTree(HWND hwnd) if (accounts.getCount() == 0) return FALSE; - for (i = 0; i < accounts.getCount(); i++) { + for (i=0; i < accounts.getCount(); i++) { int idx = cli.pfnGetAccountIndexByPos(i); if (idx == -1) continue; @@ -173,7 +173,7 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TranslateDialogDefault(hwndDlg); dat = (ProtocolOrderData*)mir_calloc(sizeof(ProtocolOrderData)); SetWindowLongPtr(hwndProtoOrder, GWLP_USERDATA, (LONG_PTR)dat); - dat->dragging=0; + dat->dragging = 0; SetWindowLongPtr(hwndProtoOrder, GWL_STYLE, GetWindowLongPtr(hwndProtoOrder, GWL_STYLE) | TVS_NOHSCROLL); { @@ -189,7 +189,7 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_COMMAND: if (LOWORD(wParam) == IDC_RESETPROTOCOLDATA && HIWORD(wParam) == BN_CLICKED) { - for (int i = 0; i < accounts.getCount(); i++) + for (int i=0; i < accounts.getCount(); i++) accounts[i]->iOrder = i; FillTree(hwndProtoOrder); @@ -244,16 +244,16 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case TVN_BEGINDRAGA: SetCapture(hwndDlg); - dat->dragging=1; - dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem; + dat->dragging = 1; + dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; TreeView_SelectItem(hwndProtoOrder, dat->hDragItem); break; case NM_CLICK: { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) { if (hti.flags & TVHT_ONITEMICON) { @@ -276,8 +276,8 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_MOUSEMOVE: if (dat->dragging) { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(lParam); - hti.pt.y=(short)HIWORD(lParam); + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(hwndProtoOrder, &hti.pt); TreeView_HitTest(hwndProtoOrder, &hti); @@ -333,12 +333,12 @@ INT_PTR CALLBACK ProtocolOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM //the pointed lParam will be freed inside TVN_DELETEITEM //so lets substitute it with 0 - lpOldData=(ProtocolData *)tvis.item.lParam; - tvis.item.lParam=0; + lpOldData = (ProtocolData *)tvis.item.lParam; + tvis.item.lParam = 0; TreeView_SetItem(hwndProtoOrder, &tvis.item); - tvis.item.lParam=(LPARAM)lpOldData; + tvis.item.lParam = (LPARAM)lpOldData; - //now current item contain lParam=0 we can delete it. the memory will be kept. + //now current item contain lParam = 0 we can delete it. the memory will be kept. TreeView_DeleteItem(hwndProtoOrder, dat->hDragItem); tvis.hParent = NULL; tvis.hInsertAfter = hti.hItem; diff --git a/src/modules/contacts/contacts.cpp b/src/modules/contacts/contacts.cpp index 096725972a..dbdd874fbb 100644 --- a/src/modules/contacts/contacts.cpp +++ b/src/modules/contacts/contacts.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h" #define NAMEORDERCOUNT 8 -static TCHAR* nameOrderDescr[ NAMEORDERCOUNT ] = +static TCHAR* nameOrderDescr[ NAMEORDERCOUNT ] = { _T("My custom name (not moveable)"), _T("Nick"), @@ -357,14 +357,14 @@ struct ContactOptionsData { static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) { struct ContactOptionsData *dat; - dat=(struct ContactOptionsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + dat = (struct ContactOptionsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); - dat=(struct ContactOptionsData*)mir_alloc(sizeof(struct ContactOptionsData)); + dat = (struct ContactOptionsData*)mir_alloc(sizeof(struct ContactOptionsData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->dragging=0; + dat->dragging = 0; SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_NAMEORDER), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_NAMEORDER), GWL_STYLE)|TVS_NOHSCROLL); { TVINSERTSTRUCT tvis; int i; @@ -408,8 +408,8 @@ static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPara if (notify->itemNew.lParam == 0 || notify->itemNew.lParam == SIZEOF(nameOrderDescr)-1) break; SetCapture(hwndDlg); - dat->dragging=1; - dat->hDragItem=((LPNMTREEVIEW)lParam)->itemNew.hItem; + dat->dragging = 1; + dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_NAMEORDER), dat->hDragItem); } break; @@ -418,8 +418,8 @@ static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPara case WM_MOUSEMOVE: if ( !dat->dragging) break; { TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(lParam); - hti.pt.y=(short)HIWORD(lParam); + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti.pt); TreeView_HitTest(GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti); @@ -438,33 +438,33 @@ static INT_PTR CALLBACK ContactOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPara case WM_LBUTTONUP: if ( !dat->dragging) break; TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_NAMEORDER), NULL, 0); - dat->dragging=0; + dat->dragging = 0; ReleaseCapture(); { TVHITTESTINFO hti; TVITEM tvi; - hti.pt.x=(short)LOWORD(lParam); - hti.pt.y=(short)HIWORD(lParam); + hti.pt.x = (short)LOWORD(lParam); + hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti.pt); hti.pt.y-=TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_NAMEORDER))/2; TreeView_HitTest(GetDlgItem(hwndDlg, IDC_NAMEORDER), &hti); if (dat->hDragItem == hti.hItem) break; - tvi.mask=TVIF_HANDLE|TVIF_PARAM; - tvi.hItem=hti.hItem; + tvi.mask = TVIF_HANDLE|TVIF_PARAM; + tvi.hItem = hti.hItem; TreeView_GetItem(GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvi); if (tvi.lParam == SIZEOF(nameOrderDescr)-1) break; if (hti.flags&(TVHT_ONITEM|TVHT_ONITEMRIGHT)) { TVINSERTSTRUCT tvis; TCHAR name[128]; - tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_PARAM; - tvis.item.stateMask=0xFFFFFFFF; - tvis.item.pszText=name; - tvis.item.cchTextMax=SIZEOF(name); - tvis.item.hItem=dat->hDragItem; + tvis.item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_PARAM; + tvis.item.stateMask = 0xFFFFFFFF; + tvis.item.pszText = name; + tvis.item.cchTextMax = SIZEOF(name); + tvis.item.hItem = dat->hDragItem; TreeView_GetItem(GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvis.item); TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_NAMEORDER), dat->hDragItem); - tvis.hParent=NULL; - tvis.hInsertAfter=hti.hItem; + tvis.hParent = NULL; + tvis.hInsertAfter = hti.hItem; TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_NAMEORDER), TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_NAMEORDER), &tvis)); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } @@ -495,7 +495,7 @@ static int ContactOptInit(WPARAM wParam, LPARAM) int LoadContactsModule(void) { for (BYTE i=0; i < NAMEORDERCOUNT; i++) - nameOrder[i]=i; + nameOrder[i] = i; DBVARIANT dbv; if ( !DBGetContactSetting(NULL, "Contact", "NameOrder", &dbv)) { diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index ec97fcaa9f..d9299c6c5d 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -66,7 +66,7 @@ bool IsInsideRootDir(TCHAR* profiledir, bool exact) } // returns 1 if the profile path was returned, without trailing slash -int getProfilePath(TCHAR * buf, size_t cch) +int getProfilePath(TCHAR *buf, size_t cch) { TCHAR profiledir[MAX_PATH]; GetPrivateProfileString(_T("Database"), _T("ProfileDir"), _T(""), profiledir, SIZEOF(profiledir), mirandabootini); @@ -114,7 +114,7 @@ bool shouldAutoCreate(TCHAR *szProfile) return _tcsicmp(ac, _T("yes")) == 0; } -static void getDefaultProfile(TCHAR * szProfile, size_t cch, TCHAR * profiledir) +static void getDefaultProfile(TCHAR *szProfile, size_t cch, TCHAR *profiledir) { TCHAR defaultProfile[MAX_PATH]; GetPrivateProfileString(_T("Database"), _T("DefaultProfile"), _T(""), defaultProfile, SIZEOF(defaultProfile), mirandabootini); @@ -131,12 +131,12 @@ static void getDefaultProfile(TCHAR * szProfile, size_t cch, TCHAR * profiledir) } // returns 1 if something that looks like a profile is there -static int getProfileCmdLineArgs(TCHAR * szProfile, size_t cch) +static int getProfileCmdLineArgs(TCHAR *szProfile, size_t cch) { TCHAR *szCmdLine = GetCommandLine(); TCHAR *szEndOfParam; TCHAR szThisParam[1024]; - int firstParam=1; + int firstParam = 1; while (szCmdLine[0]) { @@ -153,8 +153,8 @@ static int getProfileCmdLineArgs(TCHAR * szProfile, size_t cch) lstrcpyn(szThisParam, szCmdLine, min(SIZEOF(szThisParam), szEndOfParam - szCmdLine+1)); szCmdLine = szEndOfParam; } - while (*szCmdLine && *szCmdLine<=' ') szCmdLine++; - if (firstParam) { firstParam=0; continue; } //first param is executable name + while (*szCmdLine && *szCmdLine <= ' ') szCmdLine++; + if (firstParam) { firstParam = 0; continue; } //first param is executable name if (szThisParam[0] == '/' || szThisParam[0] == '-') continue; //no switches supported TCHAR* res = Utils_ReplaceVarsT(szThisParam); @@ -166,7 +166,7 @@ static int getProfileCmdLineArgs(TCHAR * szProfile, size_t cch) return 0; } -void getProfileCmdLine(TCHAR * szProfile, size_t cch, TCHAR * profiledir) +void getProfileCmdLine(TCHAR *szProfile, size_t cch, TCHAR *profiledir) { TCHAR buf[MAX_PATH]; if (getProfileCmdLineArgs(buf, SIZEOF(buf))) @@ -202,7 +202,7 @@ void getProfileCmdLine(TCHAR * szProfile, size_t cch, TCHAR * profiledir) } // move profile from profile subdir -static void moveProfileDirProfiles(TCHAR * profiledir, BOOL isRootDir = TRUE) +static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) { TCHAR pfd[MAX_PATH]; if (isRootDir) { @@ -217,19 +217,19 @@ static void moveProfileDirProfiles(TCHAR * profiledir, BOOL isRootDir = TRUE) HANDLE hFind = FindFirstFile(pfd, &ffd); if (hFind != INVALID_HANDLE_VALUE) { - TCHAR *c =_tcsrchr(pfd, '\\'); if (c) *c = 0; + TCHAR *c = _tcsrchr(pfd, '\\'); if (c) *c = 0; do { TCHAR path[MAX_PATH], path2[MAX_PATH]; TCHAR* profile = mir_tstrdup(ffd.cFileName); - TCHAR *c =_tcsrchr(profile, '.'); if (c) *c = 0; + TCHAR *c = _tcsrchr(profile, '.'); if (c) *c = 0; mir_sntprintf(path, SIZEOF(path), _T("%s\\%s"), pfd, ffd.cFileName); mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s"), profiledir, profile); CreateDirectoryTreeT(path2); mir_sntprintf(path2, SIZEOF(path2), _T("%s\\%s\\%s"), profiledir, profile, ffd.cFileName); if (_taccess(path2, 0) == 0) { - const TCHAR tszMoveMsg[] = + const TCHAR tszMoveMsg[] = _T("Miranda is trying upgrade your profile structure.\n") _T("It cannot move profile %s to the new location %s\n") _T("Because profile with this name already exist. Please resolve the issue manually."); @@ -240,7 +240,7 @@ static void moveProfileDirProfiles(TCHAR * profiledir, BOOL isRootDir = TRUE) } else if (MoveFile(path, path2) == 0) { - const TCHAR tszMoveMsg[] = + const TCHAR tszMoveMsg[] = _T("Miranda is trying upgrade your profile structure.\n") _T("It cannot move profile %s to the new location %s automatically\n") _T("Most likely due to insufficient privileges. Please move profile manually."); @@ -258,7 +258,7 @@ static void moveProfileDirProfiles(TCHAR * profiledir, BOOL isRootDir = TRUE) } // returns 1 if a single profile (full path) is found within the profile dir -static int getProfile1(TCHAR * szProfile, size_t cch, TCHAR * profiledir, BOOL * noProfiles) +static int getProfile1(TCHAR *szProfile, size_t cch, TCHAR *profiledir, BOOL * noProfiles) { unsigned int found = 0; @@ -307,7 +307,7 @@ static int getProfile1(TCHAR * szProfile, size_t cch, TCHAR * profiledir, BOOL * } // returns 1 if a default profile should be selected instead of showing the manager. -static int getProfileAutoRun(TCHAR * szProfile) +static int getProfileAutoRun(TCHAR *szProfile) { TCHAR Mgr[32]; GetPrivateProfileString(_T("Database"), _T("ShowProfileMgr"), _T(""), Mgr, SIZEOF(Mgr), mirandabootini); @@ -318,7 +318,7 @@ static int getProfileAutoRun(TCHAR * szProfile) } // returns 1 if a profile was selected -static int getProfile(TCHAR * szProfile, size_t cch) +static int getProfile(TCHAR *szProfile, size_t cch) { getProfilePath(g_profileDir, SIZEOF(g_profileDir)); if (IsInsideRootDir(g_profileDir, true)) @@ -371,12 +371,12 @@ char* makeFileName(const TCHAR* tszOriginalName) } // called by the UI, return 1 on success, use link to create profile, set error if any -int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg) +int makeDatabase(TCHAR *profile, DATABASELINK * link, HWND hwndDlg) { TCHAR buf[256]; - int err=0; + int err = 0; // check if the file already exists - TCHAR * file = _tcsrchr(profile, '\\'); + TCHAR *file = _tcsrchr(profile, '\\'); if (file) file++; if (_taccess(profile, 0) == 0) { // file already exists! @@ -475,7 +475,7 @@ static int FindDbPluginAutoCreate(const char*, DATABASELINK * dblink, LPARAM lPa } typedef struct { - TCHAR * profile; + TCHAR *profile; UINT msg; ATOM aPath; int found; @@ -485,7 +485,7 @@ static BOOL CALLBACK EnumMirandaWindows(HWND hwnd, LPARAM lParam) { TCHAR classname[256]; ENUMMIRANDAWINDOW * x = (ENUMMIRANDAWINDOW *)lParam; - DWORD_PTR res=0; + DWORD_PTR res = 0; if (GetClassName(hwnd, classname, SIZEOF(classname)) && lstrcmp(_T("Miranda"), classname) == 0) { if (SendMessageTimeout(hwnd, x->msg, (WPARAM)x->aPath, 0, SMTO_ABORTIFHUNG, 100, &res) && res) { x->found++; @@ -495,12 +495,12 @@ static BOOL CALLBACK EnumMirandaWindows(HWND hwnd, LPARAM lParam) return TRUE; } -static int FindMirandaForProfile(TCHAR * szProfile) +static int FindMirandaForProfile(TCHAR *szProfile) { - ENUMMIRANDAWINDOW x={0}; - x.profile=szProfile; - x.msg=RegisterWindowMessage(_T("Miranda::ProcessProfile")); - x.aPath=GlobalAddAtom(szProfile); + ENUMMIRANDAWINDOW x = {0}; + x.profile = szProfile; + x.msg = RegisterWindowMessage(_T("Miranda::ProcessProfile")); + x.aPath = GlobalAddAtom(szProfile); EnumWindows(EnumMirandaWindows, (LPARAM)&x); GlobalDeleteAtom(x.aPath); return x.found; @@ -525,9 +525,9 @@ int LoadDatabaseModule(void) dbe.lParam = (LPARAM)szProfile; if (_taccess(szProfile, 0) && shouldAutoCreate(szProfile)) - dbe.pfnEnumCallback=(int(*) (const char*, void*, LPARAM))FindDbPluginAutoCreate; + dbe.pfnEnumCallback = (int(*) (const char*, void*, LPARAM))FindDbPluginAutoCreate; else - dbe.pfnEnumCallback=(int(*) (const char*, void*, LPARAM))FindDbPluginForProfile; + dbe.pfnEnumCallback = (int(*) (const char*, void*, LPARAM))FindDbPluginForProfile; // find a driver to support the given profile bool retry; diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp index 70c1f965af..d8da15eac6 100644 --- a/src/modules/database/dbini.cpp +++ b/src/modules/database/dbini.cpp @@ -113,21 +113,21 @@ static INT_PTR CALLBACK WarnIniChangeDlgProc(HWND hwndDlg, UINT message, WPARAM SetDlgItemTextA(hwndDlg, IDC_SETTINGNAME, szSettingName); SetDlgItemTextA(hwndDlg, IDC_NEWVALUE, warnInfo->szValue); if (IsInSpaceSeparatedList(warnInfo->szSection, warnInfo->szSafeSections)) - pszSecurityInfo=LPGENT("This change is known to be safe."); + pszSecurityInfo = LPGENT("This change is known to be safe."); else if (IsInSpaceSeparatedList(warnInfo->szSection, warnInfo->szUnsafeSections)) - pszSecurityInfo=LPGENT("This change is known to be potentially hazardous."); + pszSecurityInfo = LPGENT("This change is known to be potentially hazardous."); else - pszSecurityInfo=LPGENT("This change is not known to be safe."); + pszSecurityInfo = LPGENT("This change is not known to be safe."); SetDlgItemText(hwndDlg, IDC_SECURITYINFO, TranslateTS(pszSecurityInfo)); return TRUE; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: - warnInfo->cancel=1; + warnInfo->cancel = 1; case IDYES: case IDNO: - warnInfo->warnNoMore=IsDlgButtonChecked(hwndDlg, IDC_WARNNOMORE); + warnInfo->warnNoMore = IsDlgButtonChecked(hwndDlg, IDC_WARNNOMORE); EndDialog(hwndDlg, LOWORD(wParam)); break; } @@ -154,10 +154,10 @@ static INT_PTR CALLBACK IniImportDoneDlgProc(HWND hwndDlg, UINT message, WPARAM EndDialog(hwndDlg, LOWORD(wParam)); break; case IDC_RECYCLE: - { SHFILEOPSTRUCT shfo={0}; - shfo.wFunc=FO_DELETE; - shfo.pFrom=szIniPath; - szIniPath[lstrlen(szIniPath)+1]='\0'; + { SHFILEOPSTRUCT shfo = {0}; + shfo.wFunc = FO_DELETE; + shfo.pFrom = szIniPath; + szIniPath[lstrlen(szIniPath)+1] = '\0'; shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; SHFileOperation(&shfo); } @@ -186,7 +186,7 @@ struct SettingsList int SettingsEnumProc(const char *szSetting, LPARAM lParam) { - SettingsList *newItem = (SettingsList *)mir_alloc(sizeof(SettingsList)); + SettingsList *newItem = (SettingsList *)mir_alloc(sizeof(SettingsList)); newItem->name = mir_strdup(szSetting); newItem->next = setting_items; setting_items = newItem; @@ -222,10 +222,10 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf break; int lineLength = lstrlenA(szLine); - while (lineLength && (BYTE)(szLine[lineLength-1])<=' ') - szLine[--lineLength]='\0'; + while (lineLength && (BYTE)(szLine[lineLength-1]) <= ' ') + szLine[--lineLength] = '\0'; - if (szLine[0] == ';' || szLine[0]<=' ') + if (szLine[0] == ';' || szLine[0] <= ' ') continue; if (szLine[0] == '[') { @@ -254,14 +254,14 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf warnThisSection = true; break; } - if (secFN) warnThisSection=0; + if (secFN) warnThisSection = 0; } if (szLine[1] == '?') { DBCONTACTENUMSETTINGS dbces; - dbces.pfnEnumProc=SettingsEnumProc; + dbces.pfnEnumProc = SettingsEnumProc; lstrcpynA(szSection, szLine+2, min(sizeof(szSection), (int)(szEnd-szLine-1))); - dbces.szModule=szSection; - dbces.ofsSettings=0; + dbces.szModule = szSection; + dbces.ofsSettings = 0; CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces); while (setting_items) { SettingsList *next = setting_items->next; @@ -282,7 +282,7 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf if (szSection[0] == '\0') continue; - char *szValue=strchr(szLine, '='); + char *szValue = strchr(szLine, '='); if (szValue == NULL) continue; @@ -291,20 +291,20 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf szValue++; { warnSettingChangeInfo_t warnInfo; - warnInfo.szIniPath=szIniPath; - warnInfo.szName=szName; - warnInfo.szSafeSections=szSafeSections; - warnInfo.szSection=szSection; - warnInfo.szUnsafeSections=szUnsafeSections; - warnInfo.szValue=szValue; - warnInfo.warnNoMore=0; - warnInfo.cancel=0; + warnInfo.szIniPath = szIniPath; + warnInfo.szName = szName; + warnInfo.szSafeSections = szSafeSections; + warnInfo.szSection = szSection; + warnInfo.szUnsafeSections = szUnsafeSections; + warnInfo.szValue = szValue; + warnInfo.warnNoMore = 0; + warnInfo.cancel = 0; if (warnThisSection && IDNO == DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WARNINICHANGE), NULL, WarnIniChangeDlgProc, (LPARAM)&warnInfo)) continue; if (warnInfo.cancel) break; if (warnInfo.warnNoMore) - warnThisSection=0; + warnThisSection = 0; } switch(szValue[0]) { @@ -334,13 +334,13 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf case 'g': case 'G': { char *pstr; - for (pstr=szValue+1;*pstr;pstr++) { + for (pstr = szValue+1;*pstr;pstr++) { if (*pstr == '\\') { switch(pstr[1]) { - case 'n': *pstr='\n'; break; - case 't': *pstr='\t'; break; - case 'r': *pstr='\r'; break; - default: *pstr=pstr[1]; break; + case 'n': *pstr = '\n'; break; + case 't': *pstr = '\t'; break; + case 'r': *pstr = '\r'; break; + default: *pstr = pstr[1]; break; } MoveMemory(pstr+1, pstr+2, lstrlenA(pstr+2)+1); } } } @@ -357,17 +357,17 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf char *pszValue, *pszEnd; DBCONTACTWRITESETTING cws; - buf=(PBYTE)mir_alloc(lstrlenA(szValue+1)); - for (len=0, pszValue=szValue+1;;len++) { - buf[len]=(BYTE)strtol(pszValue, &pszEnd, 0x10); + buf = (PBYTE)mir_alloc(lstrlenA(szValue+1)); + for (len = 0, pszValue = szValue+1;;len++) { + buf[len] = (BYTE)strtol(pszValue, &pszEnd, 0x10); if (pszValue == pszEnd) break; - pszValue=pszEnd; + pszValue = pszEnd; } - cws.szModule=szSection; - cws.szSetting=szName; - cws.value.type=DBVT_BLOB; - cws.value.pbVal=buf; - cws.value.cpbVal=len; + cws.szModule = szSection; + cws.szSetting = szName; + cws.value.type = DBVT_BLOB; + cws.value.pbVal = buf; + cws.value.cpbVal = len; CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)(HANDLE)NULL, (LPARAM)&cws); mir_free(buf); } @@ -432,7 +432,7 @@ static void DoAutoExec(void) mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName); if ( !lstrcmpi(szUse, _T("prompt")) && !secFN) { - int result=DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath); + int result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath); if (result == IDC_NOTOALL) break; if (result == IDCANCEL) continue; } @@ -447,11 +447,11 @@ static void DoAutoExec(void) if ( !lstrcmpi(szOnCompletion, _T("delete"))) DeleteFile(szIniPath); else if ( !lstrcmpi(szOnCompletion, _T("recycle"))) { - SHFILEOPSTRUCT shfo={0}; - shfo.wFunc=FO_DELETE; - shfo.pFrom=szIniPath; - szIniPath[lstrlen(szIniPath)+1]=0; - shfo.fFlags=FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; + SHFILEOPSTRUCT shfo = {0}; + shfo.wFunc = FO_DELETE; + shfo.pFrom = szIniPath; + szIniPath[lstrlen(szIniPath)+1] = 0; + shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; SHFileOperation(&shfo); } else if ( !lstrcmpi(szOnCompletion, _T("rename"))) { @@ -487,7 +487,7 @@ int InitIni(void) DoAutoExec(); PathToAbsoluteT(_T("."), szMirandaDir, NULL); - hIniChangeNotification=FindFirstChangeNotification(szMirandaDir, 0, FILE_NOTIFY_CHANGE_FILE_NAME); + hIniChangeNotification = FindFirstChangeNotification(szMirandaDir, 0, FILE_NOTIFY_CHANGE_FILE_NAME); if (hIniChangeNotification != INVALID_HANDLE_VALUE) { CreateServiceFunction("DB/Ini/CheckImportNow", CheckIniImportNow); CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hIniChangeNotification, (LPARAM)"DB/Ini/CheckImportNow"); diff --git a/src/modules/database/dbutils.cpp b/src/modules/database/dbutils.cpp index 54b352bb4d..1e62b160b4 100644 --- a/src/modules/database/dbutils.cpp +++ b/src/modules/database/dbutils.cpp @@ -45,7 +45,7 @@ static INT_PTR DbEventTypeRegister(WPARAM, LPARAM lParam) p->cbSize = DBEVENTTYPEDESCR_SIZE; p->module = mir_strdup(et->module); p->eventType = et->eventType; - p->descr = mir_strdup(et->descr); + p->descr = mir_strdup(et->descr); p->textService = NULL; p->iconService = NULL; p->eventIcon = NULL; @@ -132,7 +132,7 @@ static INT_PTR DbEventGetText(WPARAM wParam, LPARAM lParam) } else { size_t msglen = strlen((char*)dbei->pBlob) + 1, msglenW = 0; - if (msglen != dbei->cbBlob) { + if (msglen != dbei->cbBlob) { size_t i, count = ((dbei->cbBlob - msglen) / sizeof(WCHAR)); WCHAR* p = (WCHAR*)&dbei->pBlob[ msglen ]; for (i=0; i < count; i++) { @@ -231,7 +231,7 @@ static INT_PTR DbDeleteModule(WPARAM, LPARAM lParam) dbces.szModule = (char*)lParam; CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbces); - for (int i=vars.getCount()-1; i >= 0; i--) { + for (int i = vars.getCount()-1; i >= 0; i--) { DBDeleteContactSetting(NULL, (char*)lParam, vars[i]); mir_free(vars[i]); } diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp index 32e515efbe..558646e510 100644 --- a/src/modules/database/profilemanager.cpp +++ b/src/modules/database/profilemanager.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define WM_INPUTCHANGED (WM_USER + 0x3000) #define WM_FOCUSTEXTBOX (WM_USER + 0x3001) -typedef BOOL (__cdecl *ENUMPROFILECALLBACK) (TCHAR * fullpath, TCHAR * profile, LPARAM lParam); +typedef BOOL (__cdecl *ENUMPROFILECALLBACK) (TCHAR *fullpath, TCHAR *profile, LPARAM lParam); struct DetailsPageInit { int pageCount; @@ -76,7 +76,7 @@ static void ThemeDialogBackground(HWND hwnd) enableThemeDialogTexture(hwnd, ETDT_ENABLETAB); } -static int findProfiles(TCHAR * szProfileDir, ENUMPROFILECALLBACK callback, LPARAM lParam) +static int findProfiles(TCHAR *szProfileDir, ENUMPROFILECALLBACK callback, LPARAM lParam) { // find in Miranda IM profile subfolders HANDLE hFind = INVALID_HANDLE_VALUE; @@ -242,19 +242,19 @@ char* fullpath = makeFileName((TCHAR*)lParam); return DBPE_CONT; } -BOOL EnumProfilesForList(TCHAR * fullpath, TCHAR * profile, LPARAM lParam) +BOOL EnumProfilesForList(TCHAR *fullpath, TCHAR *profile, LPARAM lParam) { ProfileEnumData *ped = (ProfileEnumData*)lParam; HWND hwndList = GetDlgItem(ped->hwnd, IDC_PROFILELIST); TCHAR sizeBuf[64]; - int iItem=0; + int iItem = 0; struct _stat statbuf; bool bFileExists = false, bFileLocked = true; TCHAR* p = _tcsrchr(profile, '.'); _tcscpy(sizeBuf, _T("0 KB")); - if (p != NULL) *p=0; + if (p != NULL) *p = 0; LVITEM item = { 0 }; item.mask = LVIF_TEXT | LVIF_IMAGE; @@ -371,23 +371,23 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, // set columns col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = TranslateT("Profile"); - col.cx=122; + col.cx = 122; ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Driver"); - col.cx=100; + col.cx = 100; ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Size"); - col.cx=60; + col.cx = 60; ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Created"); - col.cx=145; + col.cx = 145; ListView_InsertColumn(hwndList, 3, &col); col.pszText = TranslateT("Modified"); - col.cx=145; + col.cx = 145; ListView_InsertColumn(hwndList, 4, &col); // icons @@ -445,13 +445,13 @@ static INT_PTR CALLBACK DlgProfileSelect(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_CONTEXTMENU: { LVHITTESTINFO lvht = {0}; - lvht.pt.x = GET_X_LPARAM(lParam); - lvht.pt.y = GET_Y_LPARAM(lParam); + lvht.pt.x = GET_X_LPARAM(lParam); + lvht.pt.y = GET_Y_LPARAM(lParam); ScreenToClient(hwndList, &lvht.pt); if (ListView_HitTest(hwndList, &lvht) < 0) break; - lvht.pt.x = GET_X_LPARAM(lParam); - lvht.pt.y = GET_Y_LPARAM(lParam); + lvht.pt.x = GET_X_LPARAM(lParam); + lvht.pt.y = GET_Y_LPARAM(lParam); HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1, TranslateT("Run")); @@ -600,7 +600,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, ShowWindow(GetDlgItem(hwndDlg, IDC_SM_LABEL), FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_SM_COMBO), FALSE); } else { - int i = 0; + int i=0; LRESULT index; HWND hwndCombo = GetDlgItem(hwndDlg, IDC_SM_COMBO); index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)_T("")); @@ -628,7 +628,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, break; case PSM_CHANGED: - dat->opd[dat->currentPage].changed=1; + dat->opd[dat->currentPage].changed = 1; return TRUE; case PSM_FORCECHANGED: @@ -671,13 +671,13 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, if (dat->currentPage != -1) { if (dat->opd[dat->currentPage].hwnd == NULL) { PSHNOTIFY pshn; - dat->opd[dat->currentPage].hwnd=CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst, dat->opd[dat->currentPage].pTemplate, hwndDlg, dat->opd[dat->currentPage].dlgProc, (LPARAM)dat->prof); + dat->opd[dat->currentPage].hwnd = CreateDialogIndirectParam(dat->opd[dat->currentPage].hInst, dat->opd[dat->currentPage].pTemplate, hwndDlg, dat->opd[dat->currentPage].dlgProc, (LPARAM)dat->prof); ThemeDialogBackground(dat->opd[dat->currentPage].hwnd); SetWindowPos(dat->opd[dat->currentPage].hwnd, HWND_TOP, dat->rcDisplay.left, dat->rcDisplay.top, 0, 0, SWP_NOSIZE); - pshn.hdr.code=PSN_INFOCHANGED; - pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd; - pshn.hdr.idFrom=0; - pshn.lParam=(LPARAM)0; + pshn.hdr.code = PSN_INFOCHANGED; + pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)0; SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); } ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); @@ -693,12 +693,12 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, case IDCANCEL: { int i; PSHNOTIFY pshn; - pshn.hdr.idFrom=0; - pshn.lParam=0; - pshn.hdr.code=PSN_RESET; + pshn.hdr.idFrom = 0; + pshn.lParam = 0; + pshn.hdr.code = PSN_RESET; for (i=0;ipageCount;i++) { if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; - pshn.hdr.hwndFrom=dat->opd[i].hwnd; + pshn.hdr.hwndFrom = dat->opd[i].hwnd; SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); } EndDialog(hwndDlg, 0); @@ -716,8 +716,8 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, { int i; PSHNOTIFY pshn; - pshn.hdr.idFrom=0; - pshn.lParam=(LPARAM)0; + pshn.hdr.idFrom = 0; + pshn.lParam = (LPARAM)0; if (dat->currentPage != -1) { pshn.hdr.code = PSN_KILLACTIVE; pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; @@ -725,7 +725,7 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam, break; } - pshn.hdr.code=PSN_APPLY; + pshn.hdr.code = PSN_APPLY; for (i=0; i < dat->pageCount; i++) { if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; @@ -776,15 +776,15 @@ static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE opi->odp = (OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1)); { OPTIONSDIALOGPAGE* p = opi->odp + opi->pageCount++; - p->cbSize = sizeof(OPTIONSDIALOGPAGE); - p->hInstance = odp->hInstance; - p->pfnDlgProc = odp->pfnDlgProc; - p->position = odp->position; - p->ptszTitle = Langpack_PcharToTchar(odp->pszTitle); - p->pszGroup = NULL; + p->cbSize = sizeof(OPTIONSDIALOGPAGE); + p->hInstance = odp->hInstance; + p->pfnDlgProc = odp->pfnDlgProc; + p->position = odp->position; + p->ptszTitle = Langpack_PcharToTchar(odp->pszTitle); + p->pszGroup = NULL; p->groupPosition = odp->groupPosition; - p->hGroupIcon = odp->hGroupIcon; - p->hIcon = odp->hIcon; + p->hGroupIcon = odp->hGroupIcon; + p->hIcon = odp->hIcon; if ((DWORD_PTR)odp->pszTemplate & 0xFFFF0000) p->pszTemplate = mir_strdup(odp->pszTemplate); else @@ -796,34 +796,34 @@ static int AddProfileManagerPage(struct DetailsPageInit * opi, OPTIONSDIALOGPAGE int getProfileManager(PROFILEMANAGERDATA * pd) { DetailsPageInit opi; - opi.pageCount=0; - opi.odp=NULL; + opi.pageCount = 0; + opi.odp = NULL; { OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.pszTitle = LPGEN("My Profiles"); - odp.pfnDlgProc = DlgProfileSelect; + odp.cbSize = sizeof(odp); + odp.pszTitle = LPGEN("My Profiles"); + odp.pfnDlgProc = DlgProfileSelect; odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROFILE_SELECTION); - odp.hInstance = hInst; + odp.hInstance = hInst; AddProfileManagerPage(&opi, &odp); - odp.pszTitle = LPGEN("New Profile"); + odp.pszTitle = LPGEN("New Profile"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROFILE_NEW); - odp.pfnDlgProc = DlgProfileNew; + odp.pfnDlgProc = DlgProfileNew; AddProfileManagerPage(&opi, &odp); } PROPSHEETHEADER psh = { 0 }; - psh.dwSize = sizeof(psh); - psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW; + psh.dwSize = sizeof(psh); + psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW; psh.hwndParent = NULL; - psh.nPages = opi.pageCount; + psh.nPages = opi.pageCount; psh.pStartPage = 0; - psh.ppsp = (PROPSHEETPAGE*)opi.odp; + psh.ppsp = (PROPSHEETPAGE*)opi.odp; DlgProfData prof; - prof.pd = pd; + prof.pd = pd; prof.psh = &psh; int rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PROFILEMANAGER), NULL, DlgProfileManager, (LPARAM)&prof); diff --git a/src/modules/database/profilemanager.h b/src/modules/database/profilemanager.h index 9d4e7821e1..416403f057 100644 --- a/src/modules/database/profilemanager.h +++ b/src/modules/database/profilemanager.h @@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ typedef struct { - TCHAR * szProfile; // in/out - TCHAR * szProfileDir; // in/out + TCHAR *szProfile; // in/out + TCHAR *szProfileDir; // in/out BOOL noProfiles; // in BOOL newProfile; // out DATABASELINK * dblink; // out @@ -32,10 +32,10 @@ typedef struct { int InitUtils(void); char* makeFileName(const TCHAR* tszOriginalName); -int makeDatabase(TCHAR * profile, DATABASELINK * link, HWND hwndDlg); +int makeDatabase(TCHAR *profile, DATABASELINK * link, HWND hwndDlg); int getProfileManager(PROFILEMANAGERDATA * pd); -int getProfilePath(TCHAR * buf, size_t cch); -int isValidProfileName(const TCHAR * name); +int getProfilePath(TCHAR *buf, size_t cch); +int isValidProfileName(const TCHAR *name); bool fileExist(TCHAR* fname); bool shouldAutoCreate(TCHAR *szProfile); diff --git a/src/modules/findadd/findadd.cpp b/src/modules/findadd/findadd.cpp index 297b418067..da55c76cff 100644 --- a/src/modules/findadd/findadd.cpp +++ b/src/modules/findadd/findadd.cpp @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define HM_SEARCHACK (WM_USER+10) #define M_SETGROUPVISIBILITIES (WM_USER+11) -static HWND hwndFindAdd=NULL; +static HWND hwndFindAdd = NULL; static HANDLE hHookModulesLoaded = 0; static HANDLE hMainMenuItem = NULL; static int OnSystemModulesLoaded(WPARAM wParam, LPARAM lParam); @@ -38,12 +38,12 @@ static int FindAddDlgResizer(HWND, LPARAM lParam, UTILRESIZECONTROL *urc) static int y, nextY, oldTop; struct FindAddDlgData *dat; - dat=(struct FindAddDlgData*)lParam; + dat = (struct FindAddDlgData*)lParam; switch(urc->wId) { case IDC_RESULTS: return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; case IDOK: - dat->minDlgHeight=nextY+urc->rcItem.bottom-urc->rcItem.top; + dat->minDlgHeight = nextY+urc->rcItem.bottom-urc->rcItem.top; return RD_ANCHORX_LEFT|RD_ANCHORY_BOTTOM; case IDC_ADD: case IDC_MOREOPTIONS: @@ -51,35 +51,35 @@ static int FindAddDlgResizer(HWND, LPARAM lParam, UTILRESIZECONTROL *urc) case IDC_STATUSBAR: return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; case IDC_PROTOIDGROUP: //the resize is always processed in template order - nextY=y=urc->rcItem.top; - if (dat->showProtoId) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + nextY = y = urc->rcItem.top; + if (dat->showProtoId) nextY = y+urc->rcItem.bottom-urc->rcItem.top+7; break; case IDC_EMAILGROUP: - oldTop=urc->rcItem.top; - y=nextY; - if (dat->showEmail) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + oldTop = urc->rcItem.top; + y = nextY; + if (dat->showEmail) nextY = y+urc->rcItem.bottom-urc->rcItem.top+7; OffsetRect(&urc->rcItem, 0, y-oldTop); return RD_ANCHORX_LEFT|RD_ANCHORY_CUSTOM; case IDC_NAMEGROUP: - oldTop=urc->rcItem.top; - y=nextY; - if (dat->showName) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + oldTop = urc->rcItem.top; + y = nextY; + if (dat->showName) nextY = y+urc->rcItem.bottom-urc->rcItem.top+7; OffsetRect(&urc->rcItem, 0, y-oldTop); return RD_ANCHORX_LEFT|RD_ANCHORY_CUSTOM; case IDC_ADVANCEDGROUP: - oldTop=urc->rcItem.top; - y=nextY; - if (dat->showAdvanced) nextY=y+urc->rcItem.bottom-urc->rcItem.top+7; + oldTop = urc->rcItem.top; + y = nextY; + if (dat->showAdvanced) nextY = y+urc->rcItem.bottom-urc->rcItem.top+7; OffsetRect(&urc->rcItem, 0, y-oldTop); return RD_ANCHORX_LEFT|RD_ANCHORY_CUSTOM; case IDC_TINYEXTENDEDGROUP: - oldTop=urc->rcItem.top; - y=nextY; + oldTop = urc->rcItem.top; + y = nextY; if (dat->showTiny) { - int height= urc->dlgNewSize.cy-y-(urc->dlgOriginalSize.cy-urc->rcItem.bottom); - nextY=y+200; //min height for custom dialog - urc->rcItem.top=urc->rcItem.bottom-height; + int height = urc->dlgNewSize.cy-y-(urc->dlgOriginalSize.cy-urc->rcItem.bottom); + nextY = y+200; //min height for custom dialog + urc->rcItem.top = urc->rcItem.bottom-height; } return RD_ANCHORX_LEFT|RD_ANCHORY_BOTTOM; case IDC_BYEMAIL: @@ -112,25 +112,25 @@ static void RenderThrobber(HDC hdc, RECT *rcItem, int *throbbing, int *pivot) int x, width, height, height2; InflateRect(rcItem, -1, 0); - width=rcItem->right-rcItem->left; - height=rcItem->bottom-rcItem->top; - height2=height/2; + width = rcItem->right-rcItem->left; + height = rcItem->bottom-rcItem->top; + height2 = height/2; if (*throbbing) { /* create memdc */ - hMemDC=CreateCompatibleDC(0); - hBitmap=(HBITMAP)SelectObject(hMemDC, CreateCompatibleBitmap(hdc, width, height)); + hMemDC = CreateCompatibleDC(0); + hBitmap = (HBITMAP)SelectObject(hMemDC, CreateCompatibleBitmap(hdc, width, height)); /* flush it */ - rc.left=rc.top=0; - rc.right=width; - rc.bottom=height; - hBr=GetSysColorBrush(COLOR_BTNFACE); + rc.left = rc.top = 0; + rc.right = width; + rc.bottom = height; + hBr = GetSysColorBrush(COLOR_BTNFACE); FillRect(hMemDC, &rc, hBr); DeleteObject(hBr); /* set up the pen */ - hPen=(HPEN)SelectObject(hMemDC, CreatePen(PS_SOLID, 4, GetSysColor(COLOR_BTNSHADOW))); + hPen = (HPEN)SelectObject(hMemDC, CreatePen(PS_SOLID, 4, GetSysColor(COLOR_BTNSHADOW))); /* draw everything before the pivot */ - x=*pivot; + x = *pivot; while (x>(-height)) { MoveToEx(hMemDC, x+height2, 0, NULL); LineTo(hMemDC, x-height2, height); @@ -148,11 +148,11 @@ static void RenderThrobber(HDC hdc, RECT *rcItem, int *throbbing, int *pivot) /* move the pivot */ *pivot+=2; /* reset the pivot point if it gets past the rect */ - if (*pivot>width) *pivot=0; + if (*pivot>width) *pivot = 0; /* put back the old pen and delete the new one */ DeleteObject(SelectObject(hMemDC, hPen)); /* cap the top and bottom */ - hPen=(HPEN)SelectObject(hMemDC, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNFACE))); + hPen = (HPEN)SelectObject(hMemDC, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNFACE))); MoveToEx(hMemDC, 0, 0, NULL); LineTo(hMemDC, width, 0); MoveToEx(hMemDC, 0, height-1, NULL); @@ -162,39 +162,39 @@ static void RenderThrobber(HDC hdc, RECT *rcItem, int *throbbing, int *pivot) /* paint to screen */ BitBlt(hdc, rcItem->left, rcItem->top, width, height, hMemDC, 0, 0, SRCCOPY); /* select back in the old bitmap and delete the created one, as well as freeing the mem dc. */ - hBitmap=(HBITMAP)SelectObject(hMemDC, hBitmap); + hBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); DeleteObject(hBitmap); DeleteDC(hMemDC); } else { /* just flush the DC */ - hBr=GetSysColorBrush(COLOR_BTNFACE); + hBr = GetSysColorBrush(COLOR_BTNFACE); FillRect(hdc, rcItem, hBr); DeleteObject(hBr); } } static void StartThrobber(HWND hwndDlg, struct FindAddDlgData *dat) { - dat->throbbing=1; + dat->throbbing = 1; SetTimer(hwndDlg, TIMERID_THROBBER, 25, NULL); } static void StopThrobber(HWND hwndDlg, struct FindAddDlgData *dat) { KillTimer(hwndDlg, TIMERID_THROBBER); - dat->throbbing=0; - dat->pivot=0; + dat->throbbing = 0; + dat->pivot = 0; InvalidateRect(GetDlgItem(hwndDlg, IDC_STATUSBAR), NULL, FALSE); } static void ShowAdvancedSearchDlg(HWND hwndDlg, struct FindAddDlgData *dat) { - char *szProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); + char *szProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); if (szProto == NULL) return; if (dat->hwndAdvSearch == NULL) { RECT rc; - dat->hwndAdvSearch=(HWND)CallProtoServiceInt(NULL,szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)hwndDlg); + dat->hwndAdvSearch = (HWND)CallProtoServiceInt(NULL,szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)hwndDlg); GetWindowRect(GetDlgItem(hwndDlg, IDC_RESULTS), &rc); SetWindowPos(dat->hwndAdvSearch, 0, rc.left, rc.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); } @@ -210,11 +210,11 @@ static void ReposTinySearchDlg(HWND hwndDlg, struct FindAddDlgData *dat) if (dat->hwndTinySearch != NULL) { RECT rc; RECT clientRect; - POINT pt={0, 0}; + POINT pt = {0, 0}; GetWindowRect(GetDlgItem(hwndDlg, IDC_TINYEXTENDEDGROUP), &rc); GetWindowRect(dat->hwndTinySearch, &clientRect); - pt.x=rc.left; - pt.y=rc.top; + pt.x = rc.left; + pt.y = rc.top; ScreenToClient(hwndDlg, &pt); SetWindowPos(dat->hwndTinySearch, 0, pt.x+5, pt.y+15, rc.right-rc.left-10, rc.bottom-rc.top-30, SWP_NOZORDER); //SetWindowPos(GetDlgItem(hwndDlg, IDC_TINYEXTENDEDGROUP), 0, 0, 0, rc.right-rc.left, clientRect.bottom-clientRect.top+20, SWP_NOMOVE|SWP_NOZORDER); @@ -222,10 +222,10 @@ static void ReposTinySearchDlg(HWND hwndDlg, struct FindAddDlgData *dat) static void ShowTinySearchDlg(HWND hwndDlg, struct FindAddDlgData *dat) { - char *szProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); + char *szProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); if (szProto == NULL) return; if (dat->hwndTinySearch == NULL) { - dat->hwndTinySearch=(HWND)CallProtoServiceInt(NULL,szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)/*GetDlgItem(*/hwndDlg/*, IDC_TINYEXTENDEDGROUP)*/); + dat->hwndTinySearch = (HWND)CallProtoServiceInt(NULL,szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)/*GetDlgItem(*/hwndDlg/*, IDC_TINYEXTENDEDGROUP)*/); if (dat->hwndTinySearch) ReposTinySearchDlg(hwndDlg, dat); else @@ -252,7 +252,7 @@ void EnableResultButtons(HWND hwndDlg, int enable) static void CheckSearchTypeRadioButton(HWND hwndDlg, int idControl) { int i; - static const int controls[]={IDC_BYPROTOID, IDC_BYEMAIL, IDC_BYNAME, IDC_BYADVANCED, IDC_BYCUSTOM}; + static const int controls[] = {IDC_BYPROTOID, IDC_BYEMAIL, IDC_BYNAME, IDC_BYADVANCED, IDC_BYCUSTOM}; for (i=0; i < SIZEOF(controls); i++) CheckDlgButton(hwndDlg, controls[i], idControl == controls[i]?BST_CHECKED:BST_UNCHECKED); } @@ -286,13 +286,13 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP TranslateDialogDefault(hwndDlg); Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_FINDUSER); - dat=(struct FindAddDlgData*)mir_calloc(sizeof(struct FindAddDlgData)); + dat = (struct FindAddDlgData*)mir_calloc(sizeof(struct FindAddDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->notSearchedYet=1; - dat->iLastColumnSortIndex=1; - dat->bSortAscending=1; - dat->hBmpSortUp=(HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_SORTCOLUP), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); - dat->hBmpSortDown=(HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_SORTCOLDOWN), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); + dat->notSearchedYet = 1; + dat->iLastColumnSortIndex = 1; + dat->bSortAscending = 1; + dat->hBmpSortUp = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_SORTCOLUP), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); + dat->hBmpSortDown = (HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_SORTCOLDOWN), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS); SendDlgItemMessage(hwndDlg, IDC_MOREOPTIONS, BUTTONSETARROW, 1, 0); ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP); @@ -305,10 +305,10 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP lvc.pszText = TranslateT("Results"); lvc.cx = rc.right-1; ListView_InsertColumn(hwndList, 0, &lvc); - lvi.mask=LVIF_TEXT; - lvi.iItem=0; - lvi.iSubItem=0; - lvi.pszText=TranslateT("There are no results to display."); + lvi.mask = LVIF_TEXT; + lvi.iItem = 0; + lvi.iSubItem = 0; + lvi.pszText = TranslateT("There are no results to display."); ListView_InsertItem(hwndList, &lvi); } @@ -317,15 +317,15 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP SIZE textSize; HDC hdc; - hdc=GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR)); + hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR)); SelectObject(hdc, (HFONT)SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0)); GetTextExtentPoint32(hdc, TranslateT("Searching"), lstrlen(TranslateT("Searching")), &textSize); - partWidth[0]=textSize.cx; + partWidth[0] = textSize.cx; GetTextExtentPoint32(hdc, _T("01234567890123456789"), 20, &textSize); partWidth[0]+=textSize.cx; ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc); - partWidth[1]=partWidth[0]+150; - partWidth[2]=-1; + partWidth[1] = partWidth[0]+150; + partWidth[2] = -1; SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, SIZEOF(partWidth), (LPARAM)partWidth); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1|SBT_OWNERDRAW, 0); SetStatusBarSearchInfo(GetDlgItem(hwndDlg, IDC_STATUSBAR), dat); @@ -333,7 +333,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP { TCHAR *szProto = NULL; int index = 0; - DBVARIANT dbv={0}; + DBVARIANT dbv = {0}; HDC hdc; SIZE textSize; RECT rect; @@ -342,41 +342,41 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP if ( !DBGetContactSettingTString(NULL, "FindAdd", "LastSearched", &dbv)) szProto = dbv.ptszVal; - for (i=0, netProtoCount=0; i < accounts.getCount(); i++) { + for (i=0, netProtoCount = 0; i < accounts.getCount(); i++) { if ( !Proto_IsAccountEnabled(accounts[i])) continue; DWORD caps = (DWORD)CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (caps & PF1_BASICSEARCH || caps & PF1_EXTSEARCH || caps & PF1_SEARCHBYEMAIL || caps & PF1_SEARCHBYNAME) netProtoCount++; } - dat->himlComboIcons=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK, netProtoCount+1, netProtoCount+1); + dat->himlComboIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK, netProtoCount+1, netProtoCount+1); SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CBEM_SETIMAGELIST, 0, (LPARAM)dat->himlComboIcons); - cbei.mask=CBEIF_IMAGE|CBEIF_SELECTEDIMAGE|CBEIF_TEXT|CBEIF_LPARAM; - cbei.iItem=0; - hdc=GetDC(hwndDlg); + cbei.mask = CBEIF_IMAGE|CBEIF_SELECTEDIMAGE|CBEIF_TEXT|CBEIF_LPARAM; + cbei.iItem = 0; + hdc = GetDC(hwndDlg); SelectObject(hdc, (HFONT)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, WM_GETFONT, 0, 0)); if (netProtoCount>1) { - cbei.pszText=TranslateT("All Networks"); + cbei.pszText = TranslateT("All Networks"); GetTextExtentPoint32(hdc, cbei.pszText, lstrlen(cbei.pszText), &textSize); if (textSize.cx>cbwidth) cbwidth = textSize.cx; - cbei.iImage=cbei.iSelectedImage=ImageList_AddIcon_IconLibLoaded(dat->himlComboIcons, SKINICON_OTHER_SEARCHALL); - cbei.lParam=0; + cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon_IconLibLoaded(dat->himlComboIcons, SKINICON_OTHER_SEARCHALL); + cbei.lParam = 0; SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CBEM_INSERTITEM, 0, (LPARAM)&cbei); cbei.iItem++; } for (i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; if ( !Proto_IsAccountEnabled(pa)) continue; - DWORD caps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + DWORD caps = (DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if ( !(caps&PF1_BASICSEARCH) && !(caps&PF1_EXTSEARCH) && !(caps&PF1_SEARCHBYEMAIL) && !(caps&PF1_SEARCHBYNAME)) continue; cbei.pszText = pa->tszAccountName; GetTextExtentPoint32(hdc, cbei.pszText, lstrlen(cbei.pszText), &textSize); if (textSize.cx>cbwidth) cbwidth = textSize.cx; - hIcon=(HICON)CallProtoServiceInt(NULL,pa->szModuleName, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); - cbei.iImage=cbei.iSelectedImage=ImageList_AddIcon(dat->himlComboIcons, hIcon); + hIcon = (HICON)CallProtoServiceInt(NULL,pa->szModuleName, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); + cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon(dat->himlComboIcons, hIcon); DestroyIcon(hIcon); - cbei.lParam=(LPARAM)pa->szModuleName; + cbei.lParam = (LPARAM)pa->szModuleName; SendDlgItemMessageA(hwndDlg, IDC_PROTOLIST, CBEM_INSERTITEM, 0, (LPARAM)&cbei); if (szProto && cbei.pszText && !lstrcmp(szProto, pa->tszAccountName)) index = cbei.iItem; @@ -395,13 +395,13 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; } case WM_SIZE: - { UTILRESIZEDIALOG urd={0}; - urd.cbSize=sizeof(urd); - urd.hwndDlg=hwndDlg; - urd.hInstance=hInst; - urd.lpTemplate=MAKEINTRESOURCEA(IDD_FINDADD); - urd.lParam=(LPARAM)dat; - urd.pfnResizer=FindAddDlgResizer; + { UTILRESIZEDIALOG urd = {0}; + urd.cbSize = sizeof(urd); + urd.hwndDlg = hwndDlg; + urd.hInstance = hInst; + urd.lpTemplate = MAKEINTRESOURCEA(IDD_FINDADD); + urd.lParam = (LPARAM)dat; + urd.pfnResizer = FindAddDlgResizer; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); ReposTinySearchDlg(hwndDlg, dat); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_SIZE, 0, 0); @@ -421,17 +421,17 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } break; case WM_GETMINMAXINFO: - { MINMAXINFO *mmi=(MINMAXINFO*)lParam; + { MINMAXINFO *mmi = (MINMAXINFO*)lParam; RECT rc, rc2; GetWindowRect(hwndList, &rc); GetWindowRect(hwndDlg, &rc2); - mmi->ptMinTrackSize.x=rc.left-rc2.left+10+GetSystemMetrics(SM_CXFRAME); + mmi->ptMinTrackSize.x = rc.left-rc2.left+10+GetSystemMetrics(SM_CXFRAME); GetClientRect(GetDlgItem(hwndDlg, IDC_MOREOPTIONS), &rc); mmi->ptMinTrackSize.x+=rc.right+5; GetClientRect(GetDlgItem(hwndDlg, IDC_ADD), &rc); mmi->ptMinTrackSize.x+=rc.right+5; GetClientRect(GetDlgItem(hwndDlg, IDC_STATUSBAR), &rc); - mmi->ptMinTrackSize.y=dat->minDlgHeight+20+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYFRAME); + mmi->ptMinTrackSize.y = dat->minDlgHeight+20+GetSystemMetrics(SM_CYCAPTION)+2*GetSystemMetrics(SM_CYFRAME); GetClientRect(GetDlgItem(hwndDlg, IDC_STATUSBAR), &rc); mmi->ptMinTrackSize.y+=rc.bottom; return 0; @@ -445,29 +445,29 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP int checkmarkVisible; dat->showAdvanced = dat->showEmail = dat->showName = dat->showProtoId = dat->showTiny = 0; - szProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); + szProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); if (szProto == (char *)CB_ERR) break; if (szProto == NULL) { for (i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; if ( !Proto_IsAccountEnabled(pa)) continue; - protoCaps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); - if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1; - if (protoCaps&PF1_SEARCHBYNAME) dat->showName=1; + protoCaps = (DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail = 1; + if (protoCaps&PF1_SEARCHBYNAME) dat->showName = 1; } } else { - protoCaps=(DWORD)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0); - if (protoCaps&PF1_BASICSEARCH) dat->showProtoId=1; - if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1; - if (protoCaps&PF1_SEARCHBYNAME) dat->showName=1; - if (protoCaps&PF1_EXTSEARCH && !(protoCaps&PF1_EXTSEARCHUI)) dat->showTiny=1; - if (protoCaps&PF1_EXTSEARCHUI) dat->showAdvanced=1; - if (protoCaps&PF1_USERIDISEMAIL && dat->showProtoId) {dat->showProtoId=0; dat->showEmail=1;} + protoCaps = (DWORD)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0); + if (protoCaps&PF1_BASICSEARCH) dat->showProtoId = 1; + if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail = 1; + if (protoCaps&PF1_SEARCHBYNAME) dat->showName = 1; + if (protoCaps&PF1_EXTSEARCH && !(protoCaps&PF1_EXTSEARCHUI)) dat->showTiny = 1; + if (protoCaps&PF1_EXTSEARCHUI) dat->showAdvanced = 1; + if (protoCaps&PF1_USERIDISEMAIL && dat->showProtoId) {dat->showProtoId = 0; dat->showEmail = 1;} if (dat->showProtoId) { char *szUniqueId; - szUniqueId=(char*)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); + szUniqueId = (char*)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0); if (szUniqueId) { #if defined(_UNICODE) TCHAR* p = mir_a2u(szUniqueId); @@ -488,7 +488,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP else { if (dat->hwndTinySearch) { DestroyWindow(dat->hwndTinySearch); - dat->hwndTinySearch=NULL; + dat->hwndTinySearch = NULL; } } #define en(id, t) ShowWindow(GetDlgItem(hwndDlg, IDC_##id), dat->show##t?SW_SHOW:SW_HIDE) @@ -502,7 +502,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP en(BYCUSTOM, Tiny); en(TINYEXTENDEDGROUP, Tiny); #undef en - checkmarkVisible=(dat->showAdvanced && IsDlgButtonChecked(hwndDlg, IDC_BYADVANCED)) || + checkmarkVisible = (dat->showAdvanced && IsDlgButtonChecked(hwndDlg, IDC_BYADVANCED)) || (dat->showEmail && IsDlgButtonChecked(hwndDlg, IDC_BYEMAIL)) || (dat->showTiny && IsDlgButtonChecked(hwndDlg, IDC_BYCUSTOM)) || (dat->showName && IsDlgButtonChecked(hwndDlg, IDC_BYNAME)) || @@ -530,13 +530,13 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_GETBORDERS, 0, (LPARAM)borders); SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_GETRECT, 1, (LPARAM)&rc); InflateRect(&rc, -borders[2]/2, -borders[1]/2); - hdc=GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR)); + hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR)); RenderThrobber(hdc, &rc, &dat->throbbing, &dat->pivot); ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc); } break; case WM_DRAWITEM: - { DRAWITEMSTRUCT *dis=(DRAWITEMSTRUCT*)lParam; + { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam; if (dis->CtlID == IDC_STATUSBAR && dis->itemID == 1) { RenderThrobber(dis->hDC, &dis->rcItem, &dat->throbbing, &dat->pivot); return TRUE; @@ -547,29 +547,29 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (wParam == IDC_RESULTS) { switch(((LPNMHDR)lParam)->code) { case LVN_ITEMCHANGED: - { int count=ListView_GetSelectedCount(hwndList); - if (dat->notSearchedYet) count=0; + { int count = ListView_GetSelectedCount(hwndList); + if (dat->notSearchedYet) count = 0; EnableResultButtons(hwndDlg, count); break; } case LVN_COLUMNCLICK: { - LPNMLISTVIEW nmlv=(LPNMLISTVIEW)lParam; + LPNMLISTVIEW nmlv = (LPNMLISTVIEW)lParam; HDITEM hdi; - hdi.mask=HDI_BITMAP|HDI_FORMAT; - hdi.fmt=HDF_LEFT|HDF_STRING; + hdi.mask = HDI_BITMAP|HDI_FORMAT; + hdi.fmt = HDF_LEFT|HDF_STRING; Header_SetItem(ListView_GetHeader(hwndList), dat->iLastColumnSortIndex, &hdi); if (nmlv->iSubItem != dat->iLastColumnSortIndex) { - dat->bSortAscending=TRUE; - dat->iLastColumnSortIndex=nmlv->iSubItem; + dat->bSortAscending = TRUE; + dat->iLastColumnSortIndex = nmlv->iSubItem; } - else dat->bSortAscending=!dat->bSortAscending; + else dat->bSortAscending = !dat->bSortAscending; - hdi.fmt=HDF_LEFT|HDF_BITMAP|HDF_STRING|HDF_BITMAP_ON_RIGHT; - hdi.hbm=dat->bSortAscending?dat->hBmpSortDown:dat->hBmpSortUp; + hdi.fmt = HDF_LEFT|HDF_BITMAP|HDF_STRING|HDF_BITMAP_ON_RIGHT; + hdi.hbm = dat->bSortAscending?dat->hBmpSortDown:dat->hBmpSortUp; Header_SetItem(ListView_GetHeader(hwndList), dat->iLastColumnSortIndex, &hdi); ListView_SortItemsEx(hwndList, SearchResultsCompareFunc, (LPARAM)hwndDlg); @@ -585,11 +585,11 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP HideAdvancedSearchDlg(hwndDlg, dat); if (dat->hwndAdvSearch) { DestroyWindow(dat->hwndAdvSearch); - dat->hwndAdvSearch=NULL; + dat->hwndAdvSearch = NULL; } if (dat->hwndTinySearch) { DestroyWindow(dat->hwndTinySearch); - dat->hwndTinySearch=NULL; + dat->hwndTinySearch = NULL; } SendMessage(hwndDlg, M_SETGROUPVISIBILITIES, 0, 0); } @@ -640,17 +640,17 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP HideAdvancedSearchDlg(hwndDlg, dat); if (dat->searchCount) { //cancel search SetDlgItemText(hwndDlg, IDOK, TranslateT("&Search")); - if (dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook=NULL;} - if (dat->search) {mir_free(dat->search); dat->search=NULL;} - dat->searchCount=0; + if (dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook = NULL;} + if (dat->search) {mir_free(dat->search); dat->search = NULL;} + dat->searchCount = 0; StopThrobber(hwndDlg, dat); SetStatusBarSearchInfo(GetDlgItem(hwndDlg, IDC_STATUSBAR), dat); break; } - char *szProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); - if (dat->search) {mir_free(dat->search); dat->search=NULL;} - dat->searchCount=0; - dat->hResultHook=HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_SEARCHACK); + char *szProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); + if (dat->search) {mir_free(dat->search); dat->search = NULL;} + dat->searchCount = 0; + dat->hResultHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_SEARCHACK); if (IsDlgButtonChecked(hwndDlg, IDC_BYCUSTOM)) { BeginSearch(hwndDlg, dat, szProto, PS_SEARCHBYADVANCED, PF1_EXTSEARCHUI, dat->hwndTinySearch); @@ -695,11 +695,11 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } if (dat->searchCount == 0) { - if (dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook=NULL;} + if (dat->hResultHook) {UnhookEvent(dat->hResultHook); dat->hResultHook = NULL;} break; } - dat->notSearchedYet=0; + dat->notSearchedYet = 0; FreeSearchResults(hwndList); CreateResultsColumns(hwndList, dat, szProto); @@ -761,8 +761,8 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP { POINT pt; LVHITTESTINFO lvhti; - pt.x=(short)LOWORD(lParam); pt.y=(short)HIWORD(lParam); - lvhti.pt=pt; + pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); + lvhti.pt = pt; ScreenToClient(hwndDlg, &pt); switch(GetDlgCtrlID(ChildWindowFromPoint(hwndDlg, pt))) { case IDC_RESULTS: @@ -775,7 +775,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; } case HM_SEARCHACK: - { ACKDATA *ack=(ACKDATA*)lParam; + { ACKDATA *ack = (ACKDATA*)lParam; int i; if (ack->type != ACKTYPE_SEARCH) break; @@ -787,9 +787,9 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP memmove(dat->search+i, dat->search+i+1, sizeof(struct ProtoSearchInfo)*(dat->searchCount-i)); if (dat->searchCount == 0) { mir_free(dat->search); - dat->search=NULL; + dat->search = NULL; UnhookEvent(dat->hResultHook); - dat->hResultHook=NULL; + dat->hResultHook = NULL; SetDlgItemText(hwndDlg, IDOK, TranslateT("&Search")); StopThrobber(hwndDlg, dat); } @@ -799,14 +799,14 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP else if (ack->result == ACKRESULT_SEARCHRESULT && ack->lParam) { PROTOSEARCHRESULT *psr; - CUSTOMSEARCHRESULTS * csr=(CUSTOMSEARCHRESULTS*)ack->lParam; - dat->bFlexSearchResult=TRUE; - psr=&(csr->psr); + CUSTOMSEARCHRESULTS * csr = (CUSTOMSEARCHRESULTS*)ack->lParam; + dat->bFlexSearchResult = TRUE; + psr = &(csr->psr); // check if this is column names data (psr->cbSize == 0) if (psr->cbSize == 0) { // blob contain info about columns int iColumn; - LVCOLUMN lvc={0}; + LVCOLUMN lvc = {0}; //firstly remove all exist items FreeSearchResults(hwndList); @@ -814,10 +814,10 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP //secondly remove all columns while (ListView_DeleteColumn(hwndList, 1)); //will delete fist column till it possible //now will add columns and captions; - lvc.mask=LVCF_TEXT; - for (iColumn=0; iColumnnFieldCount; iColumn++) + lvc.mask = LVCF_TEXT; + for (iColumn = 0; iColumnnFieldCount; iColumn++) { - lvc.pszText=TranslateTS(csr->pszFields[iColumn]); + lvc.pszText = TranslateTS(csr->pszFields[iColumn]); ListView_InsertColumn (hwndList, iColumn+1, &lvc); } // Column inserting Done @@ -857,7 +857,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP lvi.lParam = (LPARAM)lsr; for (i = SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCOUNT, 0, 0); i--;) { - szComboProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, i, 0); + szComboProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, i, 0); if (szComboProto == NULL) continue; if ( !lstrcmpA(szComboProto, ack->szModule)) { @@ -868,7 +868,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP } } i = ListView_InsertItem(hwndList, &lvi); - for (col=0; colnFieldCount; col++) { + for (col = 0; colnFieldCount; col++) { SetListItemText(hwndList, i, col+1 , csr->pszFields[col]); } ListView_SortItemsEx(hwndList, SearchResultsCompareFunc, (LPARAM)hwndDlg); @@ -879,15 +879,15 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; } else if (ack->result == ACKRESULT_DATA) { - LVITEM lvi={0}; + LVITEM lvi = {0}; int i, col; - PROTOSEARCHRESULT *psr=(PROTOSEARCHRESULT*)ack->lParam; + PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)ack->lParam; struct ListSearchResult *lsr; char *szComboProto; - COMBOBOXEXITEM cbei={0}; - dat->bFlexSearchResult=FALSE; - lsr=(struct ListSearchResult*)mir_alloc(offsetof(struct ListSearchResult, psr)+psr->cbSize); - lsr->szProto=ack->szModule; + COMBOBOXEXITEM cbei = {0}; + dat->bFlexSearchResult = FALSE; + lsr = (struct ListSearchResult*)mir_alloc(offsetof(struct ListSearchResult, psr)+psr->cbSize); + lsr->szProto = ack->szModule; CopyMemory(&lsr->psr, psr, psr->cbSize); lsr->psr.nick = psr->flags & PSR_UNICODE ? mir_u2t((wchar_t*)psr->nick) : mir_a2t((char*)psr->nick); @@ -898,21 +898,21 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP lsr->psr.flags = psr->flags & ~PSR_UNICODE | PSR_TCHAR; lvi.mask = LVIF_PARAM|LVIF_IMAGE; - lvi.lParam=(LPARAM)lsr; + lvi.lParam = (LPARAM)lsr; for (i = SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCOUNT, 0, 0); i--;) { - szComboProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, i, 0); + szComboProto = (char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, i, 0); if (szComboProto == NULL) continue; if ( !lstrcmpA(szComboProto, ack->szModule)) { - cbei.mask=CBEIF_IMAGE; - cbei.iItem=i; + cbei.mask = CBEIF_IMAGE; + cbei.iItem = i; SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CBEM_GETITEM, 0, (LPARAM)&cbei); - lvi.iImage=cbei.iImage; + lvi.iImage = cbei.iImage; break; } } - i=ListView_InsertItem(hwndList, &lvi); - col=1; + i = ListView_InsertItem(hwndList, &lvi); + col = 1; SetListItemText(hwndList, i, col++, lsr->psr.id); SetListItemText(hwndList, i, col++, lsr->psr.nick); SetListItemText(hwndList, i, col++, lsr->psr.firstName); @@ -930,7 +930,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP TCHAR *szProto; int len = SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETLBTEXTLEN, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0); szProto = (TCHAR*)alloca(sizeof(TCHAR)*(len+1)); - *szProto='\0'; + *szProto = '\0'; SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETLBTEXT, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), (LPARAM)szProto); DBWriteContactSettingTString(NULL, "FindAdd", "LastSearched", szProto?szProto:_T("")); } @@ -941,11 +941,11 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP mir_free(dat->search); if (dat->hwndAdvSearch) { DestroyWindow(dat->hwndAdvSearch); - dat->hwndAdvSearch=NULL; + dat->hwndAdvSearch = NULL; } if (dat->hwndTinySearch) { DestroyWindow(dat->hwndTinySearch); - dat->hwndTinySearch=NULL; + dat->hwndTinySearch = NULL; } DeleteObject(dat->hBmpSortDown); DeleteObject(dat->hBmpSortUp); @@ -974,15 +974,15 @@ static INT_PTR FindAddCommand(WPARAM, LPARAM) // One alternative would be to only create the service if we have network // protocols loaded but that would delay the creation until MODULE_LOADED and // that is not good either... - for (i=0, netProtoCount=0; i < accounts.getCount(); i++) { + for (i=0, netProtoCount = 0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; if ( !Proto_IsAccountEnabled(pa)) continue; - int protoCaps=CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + int protoCaps = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (protoCaps&PF1_BASICSEARCH || protoCaps&PF1_SEARCHBYEMAIL || protoCaps&PF1_SEARCHBYNAME || protoCaps&PF1_EXTSEARCHUI) netProtoCount++; } if (netProtoCount > 0) - hwndFindAdd=CreateDialog(hInst, MAKEINTRESOURCE(IDD_FINDADD), NULL, DlgProcFindAdd); + hwndFindAdd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FINDADD), NULL, DlgProcFindAdd); } return 0; } @@ -1003,11 +1003,11 @@ int LoadFindAddModule(void) HookEvent(ME_SYSTEM_PRESHUTDOWN, FindAddPreShutdown); CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.position = 500020000; - mi.flags = CMIF_ICONFROMICOLIB; + mi.cbSize = sizeof(mi); + mi.position = 500020000; + mi.flags = CMIF_ICONFROMICOLIB; mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_FINDUSER); - mi.pszName = LPGEN("&Find/Add Contacts..."); + mi.pszName = LPGEN("&Find/Add Contacts..."); mi.pszService = MS_FINDADD_FINDADD; hMainMenuItem = Menu_AddMainMenuItem(&mi); return 0; @@ -1018,7 +1018,7 @@ static int OnSystemModulesLoaded(WPARAM, LPARAM) int netProtoCount, i; // Make sure we have some networks to search on. - for (i=0, netProtoCount=0; i < accounts.getCount(); i++) { + for (i=0, netProtoCount = 0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; int protoCaps = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if (protoCaps & (PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_EXTSEARCHUI)) diff --git a/src/modules/findadd/searchresults.cpp b/src/modules/findadd/searchresults.cpp index e579c9888b..6addad0725 100644 --- a/src/modules/findadd/searchresults.cpp +++ b/src/modules/findadd/searchresults.cpp @@ -41,8 +41,8 @@ void SaveColumnSizes(HWND hwndResults) int i; struct FindAddDlgData *dat; - dat=(struct FindAddDlgData*)GetWindowLongPtr(GetParent(hwndResults), GWLP_USERDATA); - columnCount=Header_GetItemCount(ListView_GetHeader(hwndResults)); + dat = (struct FindAddDlgData*)GetWindowLongPtr(GetParent(hwndResults), GWLP_USERDATA); + columnCount = Header_GetItemCount(ListView_GetHeader(hwndResults)); if (columnCount != NUM_COLUMNID) return; ListView_GetColumnOrderArray(hwndResults, columnCount, columnOrder); for (i=0; i < NUM_COLUMNID; i++) { @@ -57,7 +57,7 @@ void SaveColumnSizes(HWND hwndResults) } static const TCHAR *szColumnNames[] = { NULL, NULL, _T("Nick"), _T("First Name"), _T("Last Name"), _T("E-mail") }; -static int defaultColumnSizes[]={0, 90, 100, 100, 100, 2000}; +static int defaultColumnSizes[] = {0, 90, 100, 100, 100, 2000}; void LoadColumnSizes(HWND hwndResults, const char *szProto) { HDITEM hdi; @@ -129,18 +129,18 @@ static LPARAM ListView_GetItemLParam(HWND hwndList, int idx) int CALLBACK SearchResultsCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { - struct FindAddDlgData *dat=(struct FindAddDlgData*)GetWindowLongPtr((HWND) lParamSort, GWLP_USERDATA); + struct FindAddDlgData *dat = (struct FindAddDlgData*)GetWindowLongPtr((HWND) lParamSort, GWLP_USERDATA); int sortMultiplier; int sortCol; struct ListSearchResult *lsr1, *lsr2; - HWND hList=GetDlgItem((HWND) lParamSort, IDC_RESULTS); + HWND hList = GetDlgItem((HWND) lParamSort, IDC_RESULTS); - sortMultiplier=dat->bSortAscending?1:-1; - sortCol=dat->iLastColumnSortIndex; + sortMultiplier = dat->bSortAscending?1:-1; + sortCol = dat->iLastColumnSortIndex; if ( !dat->bFlexSearchResult) { - lsr1=(struct ListSearchResult*)ListView_GetItemLParam(hList, (int)lParam1); - lsr2=(struct ListSearchResult*)ListView_GetItemLParam(hList, (int)lParam2); + lsr1 = (struct ListSearchResult*)ListView_GetItemLParam(hList, (int)lParam1); + lsr2 = (struct ListSearchResult*)ListView_GetItemLParam(hList, (int)lParam2); if (lsr1 == NULL || lsr2 == NULL) return 0; switch(sortCol) @@ -174,10 +174,10 @@ void FreeSearchResults(HWND hwndResults) { LV_ITEM lvi; struct ListSearchResult *lsr; - for (lvi.iItem=ListView_GetItemCount(hwndResults)-1;lvi.iItem>=0;lvi.iItem--) { - lvi.mask=LVIF_PARAM; + for (lvi.iItem = ListView_GetItemCount(hwndResults)-1;lvi.iItem>=0;lvi.iItem--) { + lvi.mask = LVIF_PARAM; ListView_GetItem(hwndResults, &lvi); - lsr=(struct ListSearchResult*)lvi.lParam; + lsr = (struct ListSearchResult*)lvi.lParam; if (lsr == NULL) continue; mir_free(lsr->psr.id); mir_free(lsr->psr.email); @@ -214,7 +214,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha for (int i=0; i < accounts.getCount();i++) { PROTOACCOUNT* pa = accounts[i]; if ( !Proto_IsAccountEnabled(pa)) continue; - DWORD caps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); + DWORD caps = (DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0); if ( !(caps&requiredCapability)) continue; dat->search[dat->searchCount].hProcess = (HANDLE)CallProtoServiceInt(NULL,pa->szModuleName, szSearchService, 0, (LPARAM)pvSearchParams); dat->search[dat->searchCount].szProto = pa->szModuleName; @@ -226,23 +226,23 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha if (dat->searchCount == 0) { forkthread(BeginSearchFailed, 0, NULL); mir_free(dat->search); - dat->search=NULL; + dat->search = NULL; return 1; } } } else { - dat->search=(struct ProtoSearchInfo*)mir_alloc(sizeof(struct ProtoSearchInfo)); - dat->searchCount=1; - dat->search[0].hProcess=(HANDLE)CallProtoServiceInt(NULL,szProto, szSearchService, 0, (LPARAM)pvSearchParams); - dat->search[0].szProto=szProto; + dat->search = (struct ProtoSearchInfo*)mir_alloc(sizeof(struct ProtoSearchInfo)); + dat->searchCount = 1; + dat->search[0].hProcess = (HANDLE)CallProtoServiceInt(NULL,szProto, szSearchService, 0, (LPARAM)pvSearchParams); + dat->search[0].szProto = szProto; if (dat->search[0].hProcess == NULL) { //infuriatingly vague error message. fixme. PROTOACCOUNT* pa = Proto_GetAccount(szProto); forkthread(BeginSearchFailed, 0, mir_tstrdup(pa->tszAccountName)); mir_free(dat->search); - dat->search=NULL; - dat->searchCount=0; + dat->search = NULL; + dat->searchCount = 0; return 1; } } @@ -277,20 +277,20 @@ struct ProtoResultsSummary { }; void SetStatusBarResultInfo(HWND hwndDlg) { - HWND hwndStatus=GetDlgItem(hwndDlg, IDC_STATUSBAR); - HWND hwndResults=GetDlgItem(hwndDlg, IDC_RESULTS); + HWND hwndStatus = GetDlgItem(hwndDlg, IDC_STATUSBAR); + HWND hwndResults = GetDlgItem(hwndDlg, IDC_RESULTS); LV_ITEM lvi; struct ListSearchResult *lsr; - struct ProtoResultsSummary *subtotal=NULL; - int subtotalCount=0; + struct ProtoResultsSummary *subtotal = NULL; + int subtotalCount = 0; int i, total; TCHAR str[256]; - total=ListView_GetItemCount(hwndResults); - for (lvi.iItem=total-1;lvi.iItem>=0;lvi.iItem--) { - lvi.mask=LVIF_PARAM; + total = ListView_GetItemCount(hwndResults); + for (lvi.iItem = total-1;lvi.iItem>=0;lvi.iItem--) { + lvi.mask = LVIF_PARAM; ListView_GetItem(hwndResults, &lvi); - lsr=(struct ListSearchResult*)lvi.lParam; + lsr = (struct ListSearchResult*)lvi.lParam; if (lsr == NULL) continue; for (i=0;iszProto) { @@ -299,9 +299,9 @@ void SetStatusBarResultInfo(HWND hwndDlg) } } if (i == subtotalCount) { - subtotal=(struct ProtoResultsSummary*)mir_realloc(subtotal, sizeof(struct ProtoResultsSummary)*(subtotalCount+1)); - subtotal[subtotalCount].szProto=lsr->szProto; - subtotal[subtotalCount++].count=1; + subtotal = (struct ProtoResultsSummary*)mir_realloc(subtotal, sizeof(struct ProtoResultsSummary)*(subtotalCount+1)); + subtotal[subtotalCount].szProto = lsr->szProto; + subtotal[subtotalCount++].count = 1; } } if (total != 0) { @@ -348,40 +348,40 @@ void ShowMoreOptionsMenu(HWND hwndDlg, int x, int y) int commandId; struct ListSearchResult *lsr; - dat=(struct FindAddDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + dat = (struct FindAddDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); { LVITEM lvi; if (ListView_GetSelectedCount(GetDlgItem(hwndDlg, IDC_RESULTS)) != 1) return; - lvi.mask=LVIF_PARAM; - lvi.iItem=ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_RESULTS), -1, LVNI_ALL|LVNI_SELECTED); + lvi.mask = LVIF_PARAM; + lvi.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_RESULTS), -1, LVNI_ALL|LVNI_SELECTED); ListView_GetItem(GetDlgItem(hwndDlg, IDC_RESULTS), &lvi); - lsr=(struct ListSearchResult*)lvi.lParam; + lsr = (struct ListSearchResult*)lvi.lParam; } - hMenu=LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); - hPopupMenu=GetSubMenu(hMenu, 4); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + hPopupMenu = GetSubMenu(hMenu, 4); TranslateMenu(hPopupMenu); - commandId=TrackPopupMenu(hPopupMenu, TPM_RIGHTBUTTON|TPM_RETURNCMD, x, y, 0, hwndDlg, NULL); + commandId = TrackPopupMenu(hPopupMenu, TPM_RIGHTBUTTON|TPM_RETURNCMD, x, y, 0, hwndDlg, NULL); switch(commandId) { case IDC_ADD: { ADDCONTACTSTRUCT acs; - acs.handle=NULL; - acs.handleType=HANDLE_SEARCHRESULT; - acs.szProto=lsr->szProto; - acs.psr=&lsr->psr; + acs.handle = NULL; + acs.handleType = HANDLE_SEARCHRESULT; + acs.szProto = lsr->szProto; + acs.psr = &lsr->psr; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); break; } case IDC_DETAILS: { HANDLE hContact; - hContact=(HANDLE)CallProtoServiceInt(NULL,lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr); + hContact = (HANDLE)CallProtoServiceInt(NULL,lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr); CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); break; } case IDC_SENDMESSAGE: { HANDLE hContact; - hContact=(HANDLE)CallProtoServiceInt(NULL,lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr); + hContact = (HANDLE)CallProtoServiceInt(NULL,lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr); CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)(const char*)NULL); break; } diff --git a/src/modules/fonts/FontOptions.cpp b/src/modules/fonts/FontOptions.cpp index bb3961369e..0ed3aa6911 100644 --- a/src/modules/fonts/FontOptions.cpp +++ b/src/modules/fonts/FontOptions.cpp @@ -102,13 +102,13 @@ int __inline DrawTextWithEffect(HDC hdc, LPCTSTR lpchText, int cchText, RECT * l return DrawText (hdc, lpchText, cchText, lprc, dwDTFormat); // else - params.cbSize = sizeof(DrawTextWithEffectParam); - params.hdc = hdc; - params.lpchText = lpchText; - params.cchText = cchText; - params.lprc = lprc; - params.dwDTFormat = dwDTFormat; - params.pEffect = pEffect; + params.cbSize = sizeof(DrawTextWithEffectParam); + params.hdc = hdc; + params.lpchText = lpchText; + params.cchText = cchText; + params.lprc = lprc; + params.dwDTFormat = dwDTFormat; + params.pEffect = pEffect; return CallService(MS_DRAW_TEXT_WITH_EFFECT, (WPARAM)¶ms, 0); } @@ -149,7 +149,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, strcpy(buff, "SETTINGS:\r\n"); WriteLine(fhand, buff); - for (i = 0; i < flist.getCount(); i++) { + for (i=0; i < flist.getCount(); i++) { FontInternal& F = flist[i]; mir_snprintf(buff, SIZEOF(buff), "\r\n[%s]", F.dbSettingsGroup); @@ -159,16 +159,16 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, } if (F.flags & FIDF_APPENDNAME) - mir_snprintf(buff, SIZEOF(buff), "%sName=s", F.prefix); + mir_snprintf(buff, SIZEOF(buff), "%sName = s", F.prefix); else - mir_snprintf(buff, SIZEOF(buff), "%s=s", F.prefix); + mir_snprintf(buff, SIZEOF(buff), "%s = s", F.prefix); WideCharToMultiByte(code_page, 0, F.value.szFace, -1, abuff, 1024, 0, 0); - abuff[1023]=0; + abuff[1023] = 0; strcat(buff, abuff); WriteLine(fhand, buff); - mir_snprintf(buff, SIZEOF(buff), "%sSize=b", F.prefix); + mir_snprintf(buff, SIZEOF(buff), "%sSize = b", F.prefix); if (F.flags & FIDF_SAVEACTUALHEIGHT) { HDC hdc; SIZE size; @@ -195,17 +195,17 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, WriteLine(fhand, buff); - mir_snprintf(buff, SIZEOF(buff), "%sSty=b%d", F.prefix, (BYTE)F.value.style); + mir_snprintf(buff, SIZEOF(buff), "%sSty = b%d", F.prefix, (BYTE)F.value.style); WriteLine(fhand, buff); - mir_snprintf(buff, SIZEOF(buff), "%sSet=b%d", F.prefix, (BYTE)F.value.charset); + mir_snprintf(buff, SIZEOF(buff), "%sSet = b%d", F.prefix, (BYTE)F.value.charset); WriteLine(fhand, buff); - mir_snprintf(buff, SIZEOF(buff), "%sCol=d%d", F.prefix, (DWORD)F.value.colour); + mir_snprintf(buff, SIZEOF(buff), "%sCol = d%d", F.prefix, (DWORD)F.value.colour); WriteLine(fhand, buff); if (F.flags & FIDF_NOAS) { - mir_snprintf(buff, SIZEOF(buff), "%sAs=w%d", F.prefix, (WORD)0x00FF); + mir_snprintf(buff, SIZEOF(buff), "%sAs = w%d", F.prefix, (WORD)0x00FF); WriteLine(fhand, buff); } - mir_snprintf(buff, SIZEOF(buff), "%sFlags=w%d", F.prefix, (WORD)F.flags); + mir_snprintf(buff, SIZEOF(buff), "%sFlags = w%d", F.prefix, (WORD)F.flags); WriteLine(fhand, buff); } @@ -218,7 +218,7 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, strcpy(header, buff); WriteLine(fhand, buff); } - mir_snprintf(buff, SIZEOF(buff), "%s=d%d", C.setting, (DWORD)C.value); + mir_snprintf(buff, SIZEOF(buff), "%s = d%d", C.setting, (DWORD)C.value); WriteLine(fhand, buff); } @@ -231,11 +231,11 @@ BOOL ExportSettings(HWND hwndDlg, TCHAR *filename, OBJLIST& flist, strcpy(header, buff); WriteLine(fhand, buff); } - mir_snprintf(buff, SIZEOF(buff), "%sEffect=b%d", E.setting, E.value.effectIndex); + mir_snprintf(buff, SIZEOF(buff), "%sEffect = b%d", E.setting, E.value.effectIndex); WriteLine(fhand, buff); - mir_snprintf(buff, SIZEOF(buff), "%sEffectCol1=d%d", E.setting, E.value.baseColour); + mir_snprintf(buff, SIZEOF(buff), "%sEffectCol1 = d%d", E.setting, E.value.baseColour); WriteLine(fhand, buff); - mir_snprintf(buff, SIZEOF(buff), "%sEffectCol2=d%d", E.setting, E.value.secondaryColour); + mir_snprintf(buff, SIZEOF(buff), "%sEffectCol2 = d%d", E.setting, E.value.secondaryColour); WriteLine(fhand, buff); } @@ -287,7 +287,7 @@ static BOOL sttFsuiBindColourIdToFonts(HWND hwndList, const TCHAR *name, const T for (i = SendMessage(hwndList, LB_GETCOUNT, 0, 0); i--;) { FSUIListItemData *itemData = (FSUIListItemData *)SendMessage(hwndList, LB_GETITEMDATA, i, 0); - if (itemData && itemData->font_id >= 0) { + if (itemData && itemData->font_id >= 0) { FontInternal& F = font_id_list_w2[itemData->font_id]; if (name && !_tcscmp(F.name, name)) { @@ -310,7 +310,7 @@ static BOOL sttFsuiBindEffectIdToFonts(HWND hwndList, const TCHAR *name, int eff for (i = SendMessage(hwndList, LB_GETCOUNT, 0, 0); i--;) { FSUIListItemData *itemData = (FSUIListItemData *)SendMessage(hwndList, LB_GETITEMDATA, i, 0); - if (itemData && itemData->font_id >= 0) { + if (itemData && itemData->font_id >= 0) { FontInternal& F = font_id_list_w2[itemData->font_id]; if (name && !_tcscmp(F.name, name)) { @@ -487,7 +487,7 @@ static INT_PTR CALLBACK ChooseEffectDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wPar } int cnt = SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_GETCOUNT, 0, 0); - for (i = 0; i < cnt; i++) { + for (i=0; i < cnt; i++) { if (SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_GETITEMDATA, i, 0) == pEffect->effectIndex) { SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_SETCURSEL, i, 0); break; @@ -507,9 +507,9 @@ static INT_PTR CALLBACK ChooseEffectDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wPar case IDOK: { int i = SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_GETCURSEL, 0, 0); - pEffect->effectIndex=(BYTE)SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_GETITEMDATA, i, 0); - pEffect->baseColour=SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR1, CPM_GETCOLOUR, 0, 0)|((~(BYTE)SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR_SPIN1, UDM_GETPOS, 0, 0))<<24); - pEffect->secondaryColour=SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR2, CPM_GETCOLOUR, 0, 0)|((~(BYTE)SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR_SPIN2, UDM_GETPOS, 0, 0))<<24);; + pEffect->effectIndex = (BYTE)SendDlgItemMessage(hwndDlg, IDC_EFFECT_COMBO, CB_GETITEMDATA, i, 0); + pEffect->baseColour = SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR1, CPM_GETCOLOUR, 0, 0)|((~(BYTE)SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR_SPIN1, UDM_GETPOS, 0, 0))<<24); + pEffect->secondaryColour = SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR2, CPM_GETCOLOUR, 0, 0)|((~(BYTE)SendDlgItemMessage(hwndDlg, IDC_EFFECT_COLOUR_SPIN2, UDM_GETPOS, 0, 0))<<24);; } EndDialog(hwndDlg, IDOK); return TRUE; @@ -599,14 +599,14 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, effect_id_list_w2 = effect_id_list; effect_id_list_w3 = effect_id_list; - for (i = 0; i < font_id_list_w2.getCount(); i++) { + for (i=0; i < font_id_list_w2.getCount(); i++) { FontInternal& F = font_id_list_w2[i]; // sync settings with database UpdateFontSettings(&F, &F.value); sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), F.group, F.hLangpack); } - for (i = 0; i < colour_id_list_w2.getCount(); i++) { + for (i=0; i < colour_id_list_w2.getCount(); i++) { ColourInternal& C = colour_id_list_w2[i]; // sync settings with database @@ -614,7 +614,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), C.group, C.hLangpack); } - for (i = 0; i < effect_id_list_w2.getCount(); i++) { + for (i=0; i < effect_id_list_w2.getCount(); i++) { EffectInternal& E = effect_id_list_w2[i]; // sync settings with database @@ -927,7 +927,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, if (selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELCOUNT, (WPARAM)0, (LPARAM)0)) { int *selItems = (int *)mir_alloc(font_id_list_w2.getCount() * sizeof(int)); SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)selCount, (LPARAM)selItems); - for (i = 0; i < selCount; ++i) { + for (i=0; i < selCount; ++i) { FSUIListItemData *itemData = (FSUIListItemData *)SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[i], 0); if (IsBadReadPtr(itemData, sizeof(FSUIListItemData))) continue; // prevent possible problems with corrupted itemData @@ -1017,7 +1017,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, else cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; if (ChooseFont(&cf)) { - for (i = 0; i < selCount; ++i) { + for (i=0; i < selCount; ++i) { FSUIListItemData *itemData = (FSUIListItemData *)SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[i], 0); if (itemData->font_id < 0) continue; @@ -1075,7 +1075,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, if (selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELCOUNT, 0, 0)) { int *selItems = (int *)mir_alloc(selCount * sizeof(int)); SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)selCount, (LPARAM) selItems); - for (int i = 0; i < selCount; i++) { + for (int i=0; i < selCount; i++) { FSUIListItemData *itemData = (FSUIListItemData *)SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[i], 0); if (itemData->font_id < 0) continue; font_id_list_w2[itemData->font_id].value.colour = SendDlgItemMessage(hwndDlg, IDC_FONTCOLOUR, CPM_GETCOLOUR, 0, 0); @@ -1090,7 +1090,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, if (selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELCOUNT, 0, 0)) { int *selItems = (int *)mir_alloc(selCount * sizeof(int)); SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)selCount, (LPARAM) selItems); - for (i = 0; i < selCount; i++) { + for (i=0; i < selCount; i++) { FSUIListItemData *itemData = (FSUIListItemData *)SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[i], 0); if (itemData->colour_id < 0) continue; colour_id_list_w2[itemData->colour_id].value = SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_GETCOLOUR, 0, 0); @@ -1110,7 +1110,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, if (font_id_list_w2.getCount() && (selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELCOUNT, (WPARAM)0, (LPARAM)0))) { int *selItems = (int *)mir_alloc(font_id_list_w2.getCount() * sizeof(int)); SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELITEMS, (WPARAM)selCount, (LPARAM)selItems); - for (i = 0; i < selCount; ++i) { + for (i=0; i < selCount; ++i) { FSUIListItemData *itemData = (FSUIListItemData *)SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETITEMDATA, selItems[i], 0); if (IsBadReadPtr(itemData, sizeof(FSUIListItemData))) continue; // prevent possible problems with corrupted itemData @@ -1274,7 +1274,7 @@ int OptInit(WPARAM wParam, LPARAM) static FontInternal *sttFindFont(OBJLIST &fonts, char *module, char *prefix) { - for (int i = 0; i < fonts.getCount(); i++) + for (int i=0; i < fonts.getCount(); i++) { FontInternal& F = fonts[i]; if ( !lstrcmpA(F.dbSettingsGroup, module) && !lstrcmpA(F.prefix, prefix)) @@ -1418,7 +1418,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND, UINT, WPARAM, LPARAM); int FontsModernOptInit(WPARAM wParam, LPARAM lParam) { - static int iBoldControls[] = + static int iBoldControls[] = { IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, MODERNOPT_CTRL_LAST diff --git a/src/modules/fonts/services.cpp b/src/modules/fonts/services.cpp index f4804c839a..5a7c9696ab 100644 --- a/src/modules/fonts/services.cpp +++ b/src/modules/fonts/services.cpp @@ -237,7 +237,7 @@ void UpdateFontSettings(FontIDW* font_id, FontSettingsT* fontsettings) colour = GetColorFromDefault(font_id->deffontsettings.colour); } - fontsettings->style = + fontsettings->style = (lf.lfWeight == FW_NORMAL ? 0 : DBFONTF_BOLD) | (lf.lfItalic ? DBFONTF_ITALIC : 0) | (lf.lfUnderline ? DBFONTF_UNDERLINE : 0) | (lf.lfStrikeOut ? DBFONTF_STRIKEOUT : 0); fontsettings->size = (char)lf.lfHeight; @@ -288,7 +288,7 @@ static int sttRegisterFontWorker(FontIDW* font_id, int hLangpack) if (font_id->cbSize != sizeof(FontIDW) && font_id->cbSize != FontIDW_OLDSIZE) return -1; - for (int i = 0; i < font_id_list.getCount(); i++) { + for (int i=0; i < font_id_list.getCount(); i++) { FontInternal& F = font_id_list[i]; if ( !lstrcmp(F.group, font_id->group) && !lstrcmp(F.name, font_id->name) && !(F.flags & FIDF_ALLOWREREGISTER)) return 1; @@ -335,7 +335,7 @@ static INT_PTR sttGetFontWorker(FontIDW* font_id, LOGFONT* lf) { COLORREF colour; - for (int i = 0; i < font_id_list.getCount(); i++) { + for (int i=0; i < font_id_list.getCount(); i++) { FontInternal& F = font_id_list[i]; if ( !_tcsncmp(F.name, font_id->name, SIZEOF(F.name)) && !_tcsncmp(F.group, font_id->group, SIZEOF(F.group))) { if (GetFontSettingFromDB(F.dbSettingsGroup, F.prefix, lf, &colour, F.flags) && (F.flags & FIDF_DEFAULTVALID)) { @@ -372,7 +372,7 @@ INT_PTR GetFont(WPARAM wParam, LPARAM lParam) void KillModuleFonts(int hLangpack) { - for (int i=font_id_list.getCount()-1; i >= 0; i--) + for (int i = font_id_list.getCount()-1; i >= 0; i--) if ( font_id_list[i].hLangpack == hLangpack) font_id_list.remove(i); } @@ -390,7 +390,7 @@ static INT_PTR sttRegisterColourWorker(ColourIDW* colour_id, int hLangpack) if (colour_id->cbSize != sizeof(ColourIDW)) return -1; - for (int i = 0; i < colour_id_list.getCount(); i++) { + for (int i=0; i < colour_id_list.getCount(); i++) { ColourInternal& C = colour_id_list[i]; if ( !_tcscmp(C.group, colour_id->group) && !_tcscmp(C.name, colour_id->name)) return 1; @@ -422,7 +422,7 @@ INT_PTR RegisterColour(WPARAM wParam, LPARAM lParam) static INT_PTR sttGetColourWorker(ColourIDW* colour_id) { - for (int i = 0; i < colour_id_list.getCount(); i++) { + for (int i=0; i < colour_id_list.getCount(); i++) { ColourInternal& C = colour_id_list[i]; if ( !_tcscmp(C.group, colour_id->group) && !_tcscmp(C.name, colour_id->name)) return DBGetContactSettingDword(NULL, C.dbSettingsGroup, C.setting, GetColorFromDefault(C.defcolour)); @@ -447,7 +447,7 @@ INT_PTR GetColour(WPARAM wParam, LPARAM) void KillModuleColours(int hLangpack) { - for (int i=colour_id_list.getCount()-1; i >= 0; i--) + for (int i = colour_id_list.getCount()-1; i >= 0; i--) if (colour_id_list[i].hLangpack == hLangpack) colour_id_list.remove(i); } @@ -476,7 +476,7 @@ static INT_PTR sttRegisterEffectWorker(EffectIDW* effect_id, int hLangpack) if (effect_id->cbSize != sizeof(EffectIDW)) return -1; - for (int i = 0; i < effect_id_list.getCount(); i++) { + for (int i=0; i < effect_id_list.getCount(); i++) { EffectInternal& E = effect_id_list[i]; if ( !_tcscmp(E.group, effect_id->group) && !_tcscmp(E.name, effect_id->name)) return 1; @@ -508,14 +508,14 @@ INT_PTR RegisterEffect(WPARAM wParam, LPARAM lParam) static INT_PTR sttGetEffectWorker(EffectIDW* effect_id, FONTEFFECT* effect) { - for (int i = 0; i < effect_id_list.getCount(); i++) { + for (int i=0; i < effect_id_list.getCount(); i++) { EffectInternal& E = effect_id_list[i]; if ( !_tcsncmp(E.name, effect_id->name, SIZEOF(E.name)) && !_tcsncmp(E.group, effect_id->group, SIZEOF(E.group))) { FONTEFFECT temp; UpdateEffectSettings(effect_id, &temp); effect->effectIndex = temp.effectIndex; - effect->baseColour = temp.baseColour; + effect->baseColour = temp.baseColour; effect->secondaryColour = temp.secondaryColour; return TRUE; } } @@ -539,7 +539,7 @@ INT_PTR GetEffect(WPARAM wParam, LPARAM lParam) void KillModuleEffects(int hLangpack) { - for (int i=effect_id_list.getCount()-1; i >= 0; i--) + for (int i = effect_id_list.getCount()-1; i >= 0; i--) if (effect_id_list[i].hLangpack == hLangpack) effect_id_list.remove(i); } diff --git a/src/modules/help/about.cpp b/src/modules/help/about.cpp index 93f869466a..b01e139a01 100644 --- a/src/modules/help/about.cpp +++ b/src/modules/help/about.cpp @@ -37,8 +37,8 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar PVOID pVerInfo; GetModuleFileName(NULL, filename, SIZEOF(filename)); - verInfoSize=GetFileVersionInfoSize(filename, &unused); - pVerInfo=mir_alloc(verInfoSize); + verInfoSize = GetFileVersionInfoSize(filename, &unused); + pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo); VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\LegalCopyright"), (LPVOID*)&productCopyright, &blockSize); SetDlgItemText(hwndDlg, IDC_DEVS, productCopyright); @@ -67,10 +67,10 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar } ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE); { - HRSRC hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT")); - DWORD ResSize = SizeofResource(hInst, hResInfo); - HGLOBAL hRes = LoadResource(hInst, hResInfo); - char* pszMsg = (char*)LockResource(hRes); + HRSRC hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT")); + DWORD ResSize = SizeofResource(hInst, hResInfo); + HGLOBAL hRes = LoadResource(hInst, hResInfo); + char* pszMsg = (char*)LockResource(hRes); if (pszMsg) { char* pszMsgt = (char*)alloca(ResSize + 1); @@ -134,7 +134,7 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar case WM_DESTROY: Window_FreeIcon_IcoLib(hwndDlg); { - HFONT hFont=(HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); + HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_GETFONT, 0, 0); SendDlgItemMessage(hwndDlg, IDC_VERSION, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0), 0); DeleteObject(hFont); } diff --git a/src/modules/help/help.cpp b/src/modules/help/help.cpp index a1984ca32e..30c25ff87c 100644 --- a/src/modules/help/help.cpp +++ b/src/modules/help/help.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -HWND hAboutDlg=NULL; +HWND hAboutDlg = NULL; static HANDLE hBugEvent = NULL; static INT_PTR AboutCommand(WPARAM wParam, LPARAM) @@ -34,7 +34,7 @@ static INT_PTR AboutCommand(WPARAM wParam, LPARAM) SetFocus(hAboutDlg); return 0; } - hAboutDlg=CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout); + hAboutDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout); return 0; } @@ -68,7 +68,7 @@ static INT_PTR BugCommand(WPARAM, LPARAM) int ShutdownHelpModule(WPARAM, LPARAM) { if (IsWindow(hAboutDlg)) DestroyWindow(hAboutDlg); - hAboutDlg=NULL; + hAboutDlg = NULL; return 0; } diff --git a/src/modules/history/history.cpp b/src/modules/history/history.cpp index 403ffecd79..c4d56a858a 100644 --- a/src/modules/history/history.cpp +++ b/src/modules/history/history.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK DlgProcHistoryFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static HANDLE hWindowList=0; +static HANDLE hWindowList = 0; static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM) { @@ -70,7 +70,7 @@ int LoadHistoryModule(void) Menu_AddContactMenuItem(&mi); CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, UserHistoryCommand); - hWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); HookEvent(ME_DB_CONTACT_DELETED, HistoryContactDelete); HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdownHistoryModule); return 0; @@ -194,21 +194,21 @@ static void FillHistoryThread(void* param) THistoryThread *hInfo = (THistoryThread*)param; SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); - i=CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hInfo->hContact, 0); + i = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hInfo->hContact, 0); SendDlgItemMessage(hInfo->hwnd, IDC_LIST, LB_INITSTORAGE, i, i*40); ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - oldBlobSize=0; - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hInfo->hContact, 0); + dbei.cbSize = sizeof(dbei); + oldBlobSize = 0; + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hInfo->hContact, 0); hwndList = GetDlgItem(hInfo->hwnd, IDC_LIST); while (hDbEvent != NULL) { if ( !IsWindow(hInfo->hwnd)) break; - newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); if (newBlobSize>oldBlobSize) { - dbei.pBlob=(PBYTE)mir_realloc(dbei.pBlob, newBlobSize); - oldBlobSize=newBlobSize; + dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); + oldBlobSize = newBlobSize; } dbei.cbBlob = oldBlobSize; CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); @@ -219,7 +219,7 @@ static void FillHistoryThread(void* param) i = SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)eventText); SendMessage(hwndList, LB_SETITEMDATA, i, (LPARAM)hDbEvent); } - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hDbEvent, 0); } mir_free(dbei.pBlob); @@ -249,7 +249,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP { HANDLE hContact; - hContact=(HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); @@ -284,18 +284,18 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP return TRUE; case WM_GETMINMAXINFO: - ((MINMAXINFO*)lParam)->ptMinTrackSize.x=300; - ((MINMAXINFO*)lParam)->ptMinTrackSize.y=230; + ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 300; + ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 230; case WM_SIZE: { - UTILRESIZEDIALOG urd={0}; - urd.cbSize=sizeof(urd); - urd.hwndDlg=hwndDlg; - urd.hInstance=hInst; - urd.lpTemplate=MAKEINTRESOURCEA(IDD_HISTORY); - urd.lParam=(LPARAM)NULL; - urd.pfnResizer=HistoryDlgResizer; + UTILRESIZEDIALOG urd = {0}; + urd.cbSize = sizeof(urd); + urd.hwndDlg = hwndDlg; + urd.hInstance = hInst; + urd.lpTemplate = MAKEINTRESOURCEA(IDD_HISTORY); + urd.lParam = (LPARAM)NULL; + urd.pfnResizer = HistoryDlgResizer; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); return TRUE; } @@ -330,17 +330,17 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP HANDLE hDbEvent; DBEVENTINFO dbei; int sel; - sel=SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); + sel = SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETCURSEL, 0, 0); if (sel == LB_ERR) { EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), FALSE); break; } EnableWindow(GetDlgItem(hwndDlg, IDC_DELETEHISTORY), TRUE); contactName = cli.pfnGetContactDisplayName(hContact, 0); - hDbEvent=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); + hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, sel, 0); ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); if ((int)dbei.cbBlob != -1) { - dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0) { GetObjectDescription(&dbei, str, SIZEOF(str)); @@ -364,11 +364,11 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (index == LB_ERR) break; - hDbEventStart=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); + hDbEventStart = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, index, 0); ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - dbei.pBlob=NULL; - oldBlobSize=0; + dbei.cbSize = sizeof(dbei); + dbei.pBlob = NULL; + oldBlobSize = 0; for (;;) { hDbEvent = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, LB_GETITEMDATA, ++index, 0); if (hDbEvent == (HANDLE)LB_ERR) { @@ -376,12 +376,12 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP continue; } if (hDbEvent == hDbEventStart) break; - newBlobSize=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); + newBlobSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); if (newBlobSize>oldBlobSize) { - dbei.pBlob=(PBYTE)mir_realloc(dbei.pBlob, newBlobSize); - oldBlobSize=newBlobSize; + dbei.pBlob = (PBYTE)mir_realloc(dbei.pBlob, newBlobSize); + oldBlobSize = newBlobSize; } - dbei.cbBlob=oldBlobSize; + dbei.cbBlob = oldBlobSize; CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); GetObjectDescription(&dbei, str, SIZEOF(str)); if (str[0]) { diff --git a/src/modules/icolib/extracticon.cpp b/src/modules/icolib/extracticon.cpp index 6a9b3a2ccc..6a53f767cc 100644 --- a/src/modules/icolib/extracticon.cpp +++ b/src/modules/icolib/extracticon.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #undef _ASSERT #endif #define _ASSERT(n) -// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcestructures/newheader.asp +// http://msdn.microsoft.com/library/default.asp?url = /library/en-us/winui/winui/windowsuserinterface/resources/introductiontoresources/resourcereference/resourcestructures/newheader.asp typedef struct { WORD Reserved; @@ -53,7 +53,7 @@ void* _RelativeVirtualAddresstoPtr(IMAGE_DOS_HEADER* pDosHeader, DWORD rva) IMAGE_SECTION_HEADER* pSection = IMAGE_FIRST_SECTION(pPE); int i; - for (i = 0; i < pPE->FileHeader.NumberOfSections; i++) { + for (i=0; i < pPE->FileHeader.NumberOfSections; i++) { IMAGE_SECTION_HEADER* cSection = &pSection[i]; DWORD size = cSection->Misc.VirtualSize ? cSection->Misc.VirtualSize : cSection->SizeOfRawData; @@ -103,7 +103,7 @@ IMAGE_RESOURCE_DIRECTORY_ENTRY* _FindResourceBase(void* prt, int resType, int* p count = pDir->NumberOfIdEntries + pDir->NumberOfNamedEntries; pRes = (IMAGE_RESOURCE_DIRECTORY_ENTRY*)(pDir+1); - for (i = 0; i < count; i++) + for (i=0; i < count; i++) if (pRes[i].Name == (DWORD)resType) break; if (i == count) return NULL; @@ -111,7 +111,7 @@ IMAGE_RESOURCE_DIRECTORY_ENTRY* _FindResourceBase(void* prt, int resType, int* p pDir = (IMAGE_RESOURCE_DIRECTORY*)((LPBYTE)prt + (pRes[i].OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)); - count = pDir->NumberOfIdEntries + pDir->NumberOfNamedEntries; + count = pDir->NumberOfIdEntries + pDir->NumberOfNamedEntries; *pCount = count; pRes = (IMAGE_RESOURCE_DIRECTORY_ENTRY*)(pDir+1); diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp index 62ab6b15cf..b838e7def6 100644 --- a/src/modules/icolib/skin2icons.cpp +++ b/src/modules/icolib/skin2icons.cpp @@ -364,7 +364,7 @@ IconSourceItem* CreateStaticIconSourceItem(int cxIcon, int cyIcon) TCHAR sourceName[ MAX_PATH ]; IconSourceFile key = { sourceName }; - int i = 0; + int i=0; do { // find new unique name mir_sntprintf(sourceName, SIZEOF(sourceName), _T("*StaticIcon_%d"), ++i); } while (iconSourceFileList.getIndex(&key) != -1); @@ -594,7 +594,7 @@ void KillModuleIcons(int hLangpack) return; mir_cslock lck(csIconList); - for (int i=iconList.getCount()-1; i >= 0; i--) { + for (int i = iconList.getCount()-1; i >= 0; i--) { IconItem *item = iconList[i]; if ( item->hLangpack == hLangpack) { IcoLib_FreeIcon(item); @@ -821,15 +821,15 @@ int LoadIcoLibModule(void) hIconBlank = LoadIconEx(NULL, MAKEINTRESOURCE(IDI_BLANK), 0); InitializeCriticalSection(&csIconList); - hIcoLib_AddNewIcon = CreateServiceFunction("Skin2/Icons/AddIcon", sttIcoLib_AddNewIcon); - hIcoLib_RemoveIcon = CreateServiceFunction(MS_SKIN2_REMOVEICON, IcoLib_RemoveIcon); - hIcoLib_GetIcon = CreateServiceFunction(MS_SKIN2_GETICON, sttIcoLib_GetIcon); + hIcoLib_AddNewIcon = CreateServiceFunction("Skin2/Icons/AddIcon", sttIcoLib_AddNewIcon); + hIcoLib_RemoveIcon = CreateServiceFunction(MS_SKIN2_REMOVEICON, IcoLib_RemoveIcon); + hIcoLib_GetIcon = CreateServiceFunction(MS_SKIN2_GETICON, sttIcoLib_GetIcon); hIcoLib_GetIconHandle = CreateServiceFunction(MS_SKIN2_GETICONHANDLE, sttIcoLib_GetIconHandle); - hIcoLib_GetIcon2 = CreateServiceFunction(MS_SKIN2_GETICONBYHANDLE, sttIcoLib_GetIconByHandle); - hIcoLib_IsManaged = CreateServiceFunction(MS_SKIN2_ISMANAGEDICON, sttIcoLib_IsManaged); - hIcoLib_AddRef = CreateServiceFunction(MS_SKIN2_ADDREFICON, IcoLib_AddRef); - hIcoLib_ReleaseIcon = CreateServiceFunction(MS_SKIN2_RELEASEICON, sttIcoLib_ReleaseIcon); - hIcoLib_ReleaseIcon = CreateServiceFunction(MS_SKIN2_RELEASEICONBIG, sttIcoLib_ReleaseIconBig); + hIcoLib_GetIcon2 = CreateServiceFunction(MS_SKIN2_GETICONBYHANDLE, sttIcoLib_GetIconByHandle); + hIcoLib_IsManaged = CreateServiceFunction(MS_SKIN2_ISMANAGEDICON, sttIcoLib_IsManaged); + hIcoLib_AddRef = CreateServiceFunction(MS_SKIN2_ADDREFICON, IcoLib_AddRef); + hIcoLib_ReleaseIcon = CreateServiceFunction(MS_SKIN2_RELEASEICON, sttIcoLib_ReleaseIcon); + hIcoLib_ReleaseIcon = CreateServiceFunction(MS_SKIN2_RELEASEICONBIG, sttIcoLib_ReleaseIconBig); hIcons2ChangedEvent = CreateHookableEvent(ME_SKIN2_ICONSCHANGED); hIconsChangedEvent = CreateHookableEvent(ME_SKIN_ICONSCHANGED); diff --git a/src/modules/icolib/skin2opts.cpp b/src/modules/icolib/skin2opts.cpp index 97529762e3..d9bcdaf8d9 100644 --- a/src/modules/icolib/skin2opts.cpp +++ b/src/modules/icolib/skin2opts.cpp @@ -227,7 +227,7 @@ void UndoSubItemChanges(HWND htv, HTREEITEM hItem, int cmd) static void OpenIconsPage() { - CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=35"); + CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action = display&id = 35"); } static int OpenPopupMenu(HWND hwndDlg) @@ -259,7 +259,7 @@ static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll) else lstrcat(filter, _T(" (*.dll)")); - pfilter=filter+lstrlen(filter)+1; + pfilter = filter+lstrlen(filter)+1; if (bAll) lstrcpy(pfilter, _T("*.DLL;*.ICL;*.EXE;*.ICO")); else @@ -271,7 +271,7 @@ static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll) pfilter += lstrlen(pfilter) + 1; lstrcpy(pfilter, _T("*")); pfilter += lstrlen(pfilter) + 1; - *pfilter='\0'; + *pfilter = '\0'; ofn.lpstrFilter = filter; ofn.lpstrDefExt = _T("dll"); @@ -444,7 +444,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lvi.iSubItem = 0; lvi.iItem = 0; int count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR); - for (int i = 0; i < count; lvi.iItem++, i++) { + for (int i=0; i < count; lvi.iItem++, i++) { mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i+1); lvi.pszText = caption; @@ -486,7 +486,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_MOUSEMOVE: if (dragging) { LVHITTESTINFO lvhti; - int onItem=0; + int onItem = 0; HWND hwndOver; RECT rc; POINT ptDrag; @@ -542,7 +542,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, SIZEOF(fullPath)); CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)fullPath, (LPARAM)filename); - lvi.mask=LVIF_PARAM; + lvi.mask = LVIF_PARAM; lvi.iItem = dragItem; lvi.iSubItem = 0; ListView_GetItem(hPreview, &lvi); mir_sntprintf(path, MAX_PATH, _T("%s,%d"), filename, (int)lvi.lParam); @@ -1019,7 +1019,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return FALSE; } -static UINT iconsExpertOnlyControls[]={IDC_IMPORT}; +static UINT iconsExpertOnlyControls[] = {IDC_IMPORT}; int SkinOptionsInit(WPARAM wParam, LPARAM) { diff --git a/src/modules/idle/idle.cpp b/src/modules/idle/idle.cpp index dfd2fdf628..fdd842ef79 100644 --- a/src/modules/idle/idle.cpp +++ b/src/modules/idle/idle.cpp @@ -187,7 +187,7 @@ static void IdleObject_ReadSettings(IdleObject * obj) static void IdleObject_Create(IdleObject * obj) { ZeroMemory(obj, sizeof(IdleObject)); - obj->hTimer=SetTimer(NULL, 0, 2000, IdleTimer); + obj->hTimer = SetTimer(NULL, 0, 2000, IdleTimer); IdleObject_ReadSettings(obj); } @@ -210,7 +210,7 @@ static int IdleObject_IsUserIdle(IdleObject * obj) if (MyGetLastInputInfo != NULL) { LASTINPUTINFO ii; ZeroMemory(&ii, sizeof(ii)); - ii.cbSize=sizeof(ii); + ii.cbSize = sizeof(ii); if (MyGetLastInputInfo(&ii)) return GetTickCount() - ii.dwTime > (obj->minutes * 60 * 1000); } @@ -218,8 +218,8 @@ static int IdleObject_IsUserIdle(IdleObject * obj) POINT pt; GetCursorPos(&pt); if (pt.x != obj->mousepos.x || pt.y != obj->mousepos.y) { - obj->mousepos=pt; - obj->mouseidle=0; + obj->mousepos = pt; + obj->mouseidle = 0; } else obj->mouseidle += 2; @@ -424,7 +424,7 @@ static INT_PTR CALLBACK IdleOptsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L { int min; if ((HWND)lParam != GetFocus() || HIWORD(wParam) != EN_CHANGE) return FALSE; - min=GetDlgItemInt(hwndDlg, IDC_IDLE1STTIME, NULL, FALSE); + min = GetDlgItemInt(hwndDlg, IDC_IDLE1STTIME, NULL, FALSE); if (min == 0 && GetWindowTextLength(GetDlgItem(hwndDlg, IDC_IDLE1STTIME))) SendDlgItemMessage(hwndDlg, IDC_IDLESPIN, UDM_SETPOS, 0, MAKELONG((short) 1, 0)); break; @@ -478,7 +478,7 @@ static INT_PTR IdleGetInfo(WPARAM, LPARAM lParam) static int IdleModernOptInit(WPARAM wParam, LPARAM) { - static const int iBoldControls[] = + static const int iBoldControls[] = { IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, MODERNOPT_CTRL_LAST @@ -505,8 +505,8 @@ int LoadIdleModule(void) bModuleInitialized = TRUE; bIsWTSApiPresent = InitWTSAPI(); - MyGetLastInputInfo=(BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); - hIdleEvent=CreateHookableEvent(ME_IDLE_CHANGED); + MyGetLastInputInfo = (BOOL (WINAPI *)(LASTINPUTINFO*))GetProcAddress(GetModuleHandleA("user32"), "GetLastInputInfo"); + hIdleEvent = CreateHookableEvent(ME_IDLE_CHANGED); IdleObject_Create(&gIdleObject); CreateServiceFunction(MS_IDLE_GETIDLEINFO, IdleGetInfo); HookEvent(ME_OPT_INITIALISE, IdleOptInit); @@ -520,5 +520,5 @@ void UnloadIdleModule() IdleObject_Destroy(&gIdleObject); DestroyHookableEvent(hIdleEvent); - hIdleEvent=NULL; + hIdleEvent = NULL; } diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp index b5b88343d0..21f1207386 100644 --- a/src/modules/ignore/ignore.cpp +++ b/src/modules/ignore/ignore.cpp @@ -24,19 +24,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IGNOREEVENT_MAX 7 -static const DWORD ignoreIdToPf1[IGNOREEVENT_MAX]={PF1_IMRECV, PF1_URLRECV, PF1_FILERECV, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; -static const DWORD ignoreIdToPf4[IGNOREEVENT_MAX]={0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, PF4_SUPPORTTYPING}; +static const DWORD ignoreIdToPf1[IGNOREEVENT_MAX] = {PF1_IMRECV, PF1_URLRECV, PF1_FILERECV, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; +static const DWORD ignoreIdToPf4[IGNOREEVENT_MAX] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, PF4_SUPPORTTYPING}; static DWORD GetMask(HANDLE hContact) { - DWORD mask=DBGetContactSettingDword(hContact, "Ignore", "Mask1", (DWORD)(-1)); + DWORD mask = DBGetContactSettingDword(hContact, "Ignore", "Mask1", (DWORD)(-1)); if (mask == (DWORD)(-1)) { - if (hContact == NULL) mask=0; + if (hContact == NULL) mask = 0; else { if (DBGetContactSettingByte(hContact, "CList", "Hidden", 0) || DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) - mask=DBGetContactSettingDword(NULL, "Ignore", "Mask1", 0); + mask = DBGetContactSettingDword(NULL, "Ignore", "Mask1", 0); else - mask=DBGetContactSettingDword(NULL, "Ignore", "Default1", 0); + mask = DBGetContactSettingDword(NULL, "Ignore", "Default1", 0); } } return mask; @@ -45,32 +45,32 @@ static DWORD GetMask(HANDLE hContact) static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount) { int typeOfFirst; - int iconOn[IGNOREEVENT_MAX]={1, 1, 1, 1, 1, 1, 1}; - int childCount[IGNOREEVENT_MAX]={0, 0, 0, 0, 0, 0, 0}, i; + int iconOn[IGNOREEVENT_MAX] = {1, 1, 1, 1, 1, 1, 1}; + int childCount[IGNOREEVENT_MAX] = {0, 0, 0, 0, 0, 0, 0}, i; int iImage; HANDLE hItem, hChildItem; - typeOfFirst=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); + typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); //check groups - if (typeOfFirst == CLCIT_GROUP) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); while (hItem) { - hChildItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount); for (i=0; i < SIZEOF(iconOn); i++) - if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i]=0; - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); + if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0; + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } //check contacts - if (typeOfFirst == CLCIT_CONTACT) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { for (i=0; i < SIZEOF(iconOn); i++) { - iImage=SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); - if (iconOn[i] && iImage == 0) iconOn[i]=0; + iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); + if (iconOn[i] && iImage == 0) iconOn[i] = 0; if (iImage != 0xFF) childCount[i]++; } - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } //set icons for (i=0; i < SIZEOF(iconOn); i++) { @@ -86,22 +86,22 @@ static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int int typeOfFirst, iOldIcon; HANDLE hItem, hChildItem; - typeOfFirst=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); + typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); //check groups - if (typeOfFirst == CLCIT_GROUP) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); while (hItem) { - hChildItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetAllChildIcons(hwndList, hChildItem, iColumn, iImage); - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } //check contacts - if (typeOfFirst == CLCIT_CONTACT) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { - iOldIcon=SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); + iOldIcon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); if (iOldIcon != 0xFF && iOldIcon != iImage) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } } @@ -115,7 +115,7 @@ static void ResetListOptions(HWND hwndList) SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0); SendMessage(hwndList, CLM_SETINDENT, 10, 0); SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, 1, 0); - for (i=0;i<=FONTID_MAX;i++) + for (i=0;i <= FONTID_MAX;i++) SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT)); } @@ -123,7 +123,7 @@ static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int { int itemType; - itemType=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0); + itemType = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0); if (itemType == CLCIT_CONTACT) { int oldiImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); if (oldiImage != 0xFF && oldiImage != iImage) @@ -134,7 +134,7 @@ static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int else SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); //hItemUnknown } else if (itemType == CLCIT_GROUP) { - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hItem) SetAllChildIcons(hwndList, hItem, iColumn, iImage); } } @@ -144,7 +144,7 @@ static void InitialiseItem(HWND hwndList, HANDLE hContact, HANDLE hItem, DWORD p DWORD mask; int i; - mask=GetMask(hContact); + mask = GetMask(hContact); for (i=0;iiColumn == -1) break; - hItem=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); + hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y)); if (hItem == NULL) break; if ( !(hitFlags&CLCHT_ONITEMEXTRA)) break; if (nm->iColumn == IGNOREEVENT_MAX) { //ignore all - for (iImage=0;iImageiColumn == IGNOREEVENT_MAX+1) { //ignore none - for (iImage=0;iImageiColumn, 0)); - if (iImage == 0) iImage=nm->iColumn+3; - else if (iImage != 0xFF) iImage=0; + iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); + if (iImage == 0) iImage = nm->iColumn+3; + else if (iImage != 0xFF) iImage = 0; SetIconsForColumn(GetDlgItem(hwndDlg, IDC_LIST), hItem, hItemAll, nm->iColumn, iImage); } SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL); @@ -305,15 +305,15 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM case PSN_APPLY: { HANDLE hContact, hItem; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); do { - hItem=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); + hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); if (hItem) SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), hContact, hItem, "Mask1"); if (SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) DBDeleteContactSetting(hContact, "CList", "Hidden"); else DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); - } while (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); + } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemAll, "Default1"); SaveItemMask(GetDlgItem(hwndDlg, IDC_LIST), NULL, hItemUnknown, "Mask1"); return TRUE; @@ -331,7 +331,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM HIMAGELIST hIml; for (i=0; i < SIZEOF(hIcons); i++) DestroyIcon(hIcons[i]); - hIml=(HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); + hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); ImageList_Destroy(hIml); break; } @@ -339,7 +339,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM return FALSE; } -static UINT expertOnlyControls[]={IDC_STCHECKMARKS}; +static UINT expertOnlyControls[] = {IDC_STCHECKMARKS}; static int IgnoreOptInitialise(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; @@ -359,16 +359,16 @@ static int IgnoreOptInitialise(WPARAM wParam, LPARAM) static INT_PTR IsIgnored(WPARAM wParam, LPARAM lParam) { - DWORD mask=GetMask((HANDLE)wParam); + DWORD mask = GetMask((HANDLE)wParam); if (lParam<1 || lParam>IGNOREEVENT_MAX) return 1; return (mask>>(lParam-1))&1; } static INT_PTR Ignore(WPARAM wParam, LPARAM lParam) { - DWORD mask=GetMask((HANDLE)wParam); + DWORD mask = GetMask((HANDLE)wParam); if ((lParam<1 || lParam>IGNOREEVENT_MAX) && lParam != IGNOREEVENT_ALL) return 1; - if (lParam == IGNOREEVENT_ALL) mask=(1<IGNOREEVENT_MAX) && lParam != IGNOREEVENT_ALL) return 1; - if (lParam == IGNOREEVENT_ALL) mask=0; + if (lParam == IGNOREEVENT_ALL) mask = 0; else mask&=~(1<<(lParam-1)); DBWriteContactSettingDword((HANDLE)wParam, "Ignore", "Mask1", mask); return 0; @@ -416,11 +416,11 @@ static INT_PTR IgnoreRecvAuth(WPARAM wParam, LPARAM lParam) static int IgnoreAddedNotify(WPARAM, LPARAM lParam) { - DBEVENTINFO *dbei=(DBEVENTINFO*)lParam; + DBEVENTINFO *dbei = (DBEVENTINFO*)lParam; if (dbei && dbei->eventType == EVENTTYPE_ADDED && dbei->pBlob != NULL) { HANDLE hContact; - hContact=*((PHANDLE)(dbei->pBlob+sizeof(DWORD))); + hContact = *((PHANDLE)(dbei->pBlob+sizeof(DWORD))); if (CallService(MS_DB_CONTACT_IS, (WPARAM)hContact, 0) && IsIgnored((WPARAM)hContact, IGNOREEVENT_YOUWEREADDED)) return 1; } @@ -429,7 +429,7 @@ static int IgnoreAddedNotify(WPARAM, LPARAM lParam) static int IgnoreModernOptInit(WPARAM wParam, LPARAM) { - static int iBoldControls[] = + static int iBoldControls[] = { IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, MODERNOPT_CTRL_LAST @@ -453,16 +453,16 @@ static int IgnoreModernOptInit(WPARAM wParam, LPARAM) int LoadIgnoreModule(void) { PROTOCOLDESCRIPTOR pd = { 0 }; - pd.cbSize=sizeof(pd); - pd.szName="Ignore"; - pd.type=PROTOTYPE_IGNORE; + pd.cbSize = sizeof(pd); + pd.szName = "Ignore"; + pd.type = PROTOTYPE_IGNORE; CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { if ( !CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)"Ignore")) CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)"Ignore"); - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } CreateServiceFunction("Ignore"PSR_MESSAGE, IgnoreRecvMessage); diff --git a/src/modules/json/JSONChildren.cpp b/src/modules/json/JSONChildren.cpp index 371c19880a..f55f0fa676 100644 --- a/src/modules/json/JSONChildren.cpp +++ b/src/modules/json/JSONChildren.cpp @@ -1,28 +1,28 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + #include "JSONChildren.h" #include "JSONNode.h" diff --git a/src/modules/json/JSONDebug.cpp b/src/modules/json/JSONDebug.cpp index 7e13c11a85..990a594679 100644 --- a/src/modules/json/JSONDebug.cpp +++ b/src/modules/json/JSONDebug.cpp @@ -1,30 +1,30 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - -#include "libJSON.h" -#include "m_json.h" +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + +#include "libJSON.h" +#include "m_json.h" #ifdef JSON_DEBUG diff --git a/src/modules/json/JSONIterators.cpp b/src/modules/json/JSONIterators.cpp index edb8ff7618..716be5f8e1 100644 --- a/src/modules/json/JSONIterators.cpp +++ b/src/modules/json/JSONIterators.cpp @@ -1,28 +1,28 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + #include "JSONNode.h" #ifdef JSON_ITERATORS @@ -119,7 +119,7 @@ JSONNode::json_iterator JSONNode::insertFFF(json_iterator pos, JSONNode ** const json_auto mem(num); JSONNode ** runner = mem.ptr; for (JSONNode ** po = _start; po < _end; ++po){ - *runner++ = newJSONNode(*(*po) JSON_MUTEX_COPY2); + *runner++=newJSONNode(*(*po) JSON_MUTEX_COPY2); } internal -> Children.insert(json_iterator_ptr(pos), mem.ptr, num); return pos; @@ -213,7 +213,7 @@ JSONNode::json_iterator JSONNode::insertFFF(json_iterator pos, JSONNode ** const json_auto mem(num); JSONNode ** runner = mem.ptr; for (JSONNode ** po = _start; po > _end; --po){ - *runner++ = newJSONNode(*(*po) JSON_MUTEX_COPY2); + *runner++=newJSONNode(*(*po) JSON_MUTEX_COPY2); } internal -> Children.insert(pos.it, mem.ptr, num); return pos; @@ -229,7 +229,7 @@ JSONNode::json_iterator JSONNode::insertFFF(json_iterator pos, JSONNode ** const json_auto mem(num); JSONNode ** runner = mem.ptr; for (JSONNode ** po = _start; po > _end; --po){ - *runner++ = newJSONNode(*(*po) JSON_MUTEX_COPY2); + *runner++=newJSONNode(*(*po) JSON_MUTEX_COPY2); } internal -> Children.insert(++pos.it, mem.ptr, num); return pos - num + 1; diff --git a/src/modules/json/JSONMemory.cpp b/src/modules/json/JSONMemory.cpp index 08b6d7fd70..4c2c851022 100644 --- a/src/modules/json/JSONMemory.cpp +++ b/src/modules/json/JSONMemory.cpp @@ -1,28 +1,28 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + #include "JSONMemory.h" #include "JSONNode.h" diff --git a/src/modules/json/JSONMemory.h b/src/modules/json/JSONMemory.h index c04c45eff5..899d73b6fc 100644 --- a/src/modules/json/JSONMemory.h +++ b/src/modules/json/JSONMemory.h @@ -119,7 +119,7 @@ class json_auto { T * ptr; private: json_auto(const json_auto &); - json_auto & operator =(const json_auto &); + json_auto & operator = (const json_auto &); }; //Clears a string, if required, frees the memory diff --git a/src/modules/json/JSONNode.cpp b/src/modules/json/JSONNode.cpp index 8d2a046f69..8e4ca34678 100644 --- a/src/modules/json/JSONNode.cpp +++ b/src/modules/json/JSONNode.cpp @@ -1,28 +1,28 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + #include "JSONNode.h" #ifdef JSON_UNIT_TEST @@ -158,7 +158,7 @@ void JSONNode::merge(JSONNode &) { #ifdef JSON_REF_COUNT va_list args; va_start(args, num); - for(unsigned int i = 0; i < num; ++i){ + for(unsigned int i=0; i < num; ++i){ merge(va_arg(args, JSONNode*)); } va_end(args); diff --git a/src/modules/json/JSONNode.h b/src/modules/json/JSONNode.h index 36ebcd6145..3552f9f73c 100644 --- a/src/modules/json/JSONNode.h +++ b/src/modules/json/JSONNode.h @@ -158,7 +158,7 @@ public: JSONNode JSON_PTR_LIB pop_back_nocase(const json_string & name_t); #endif - DECLARE_FOR_ALL_TYPES(JSONNode & operator =) + DECLARE_FOR_ALL_TYPES(JSONNode & operator = ) JSONNode & operator = (const JSONNode &); DECLARE_FOR_ALL_TYPES_CONST(bool operator ==) @@ -253,7 +253,7 @@ public: inline bool operator >= (const const_iterator & other) const { return it >= other.it; } inline bool operator < (const const_iterator & other) const { return it < other.it; } inline bool operator <= (const const_iterator & other) const { return it <= other.it; } - inline const_iterator & operator =(const const_iterator & orig){ it = orig.it; return *this; } + inline const_iterator & operator = (const const_iterator & orig){ it = orig.it; return *this; } const_iterator (const const_iterator & orig) : it(orig.it) {} private: JSONNode ** it; diff --git a/src/modules/json/JSONWorker.cpp b/src/modules/json/JSONWorker.cpp index 25589a8d2f..488089345f 100644 --- a/src/modules/json/JSONWorker.cpp +++ b/src/modules/json/JSONWorker.cpp @@ -143,12 +143,12 @@ size_t JSONWorker::FindNextRelevant(json_char ch, const json_string & value_t, c } #ifdef JSON_COMMENTS - #define COMMENT_DELIMITER() *runner++ = '\5' + #define COMMENT_DELIMITER() *runner++='\5' #define AND_RUNNER ,runner inline void SingleLineComment(const json_char * & p, json_char * & runner){ COMMENT_DELIMITER(); while((*(++p)) && (*p != JSON_TEXT('\n'))) { - *runner++ = *p; + *runner++=*p; } COMMENT_DELIMITER(); } @@ -183,7 +183,7 @@ inline void SingleLineComment(const json_char * & p){ COMMENT_DELIMITER(); while ((*(++p) != JSON_TEXT('*')) || (*(p + 1) != JSON_TEXT('/'))) { JSON_ASSERT_SAFE(*p, JSON_TEXT("Null terminator inside of a multiline quote"), COMMENT_DELIMITER(); goto endofloop;); - *runner++ = *p; + *runner++=*p; } ++p; COMMENT_DELIMITER(); @@ -195,16 +195,16 @@ inline void SingleLineComment(const json_char * & p){ SingleLineComment(p AND_RUNNER); break; case JSON_TEXT('\"'): //a quote - *runner++ = JSON_TEXT('\"'); + *runner++=JSON_TEXT('\"'); while(*(++p) != JSON_TEXT('\"')) { //find the end of the quotation, as white space is preserved within it JSON_ASSERT_SAFE(*p, JSON_TEXT("Null terminator inside of a quotation"), goto endofloop;); switch(*p){ case JSON_TEXT('\\'): - *runner++ = JSON_TEXT('\\'); - *runner++ = (*++p == JSON_TEXT('\"')) ? JSON_TEXT('\1') : *p; //an escaped quote will reak havoc will all of my searching functions, so change it into an illegal character in JSON for convertion later on + *runner++=JSON_TEXT('\\'); + *runner++=(*++p == JSON_TEXT('\"')) ? JSON_TEXT('\1') : *p; //an escaped quote will reak havoc will all of my searching functions, so change it into an illegal character in JSON for convertion later on break; default: - *runner++ = *p; + *runner++=*p; break; } } @@ -212,7 +212,7 @@ inline void SingleLineComment(const json_char * & p){ default: JSON_ASSERT_SAFE((json_uchar)*p >= 32, JSON_TEXT("Invalid JSON character detected (lo)"), goto endofloop;); JSON_ASSERT_SAFE((json_uchar)*p <= 126, JSON_TEXT("Invalid JSON character detected (hi)"), goto endofloop;); - *runner++ = *p; + *runner++=*p; break; } ++p; @@ -333,8 +333,8 @@ json_char* JSONWorker::UTF8_2(const json_char * & pos){ ++pos; json_uchar temp = Hex(pos) << 8; ++pos; - *szU8Buffer= temp | Hex(pos); - szU8Buffer[1]=0; + *szU8Buffer = temp | Hex(pos); + szU8Buffer[1] = 0; return szU8Buffer; #else union { @@ -343,20 +343,20 @@ json_char* JSONWorker::UTF8_2(const json_char * & pos){ }; pos++; strncpy(szU8Buffer+5,pos,4); - szU8Buffer[9]=0; - uChar=strtoul(szU8Buffer+5,NULL,16); + szU8Buffer[9] = 0; + uChar = strtoul(szU8Buffer+5,NULL,16); if (uChar<0x80) { - szU8Buffer[0]=uChar; - szU8Buffer[1]=0; + szU8Buffer[0] = uChar; + szU8Buffer[1] = 0; } else if (uChar<0x7ff) { - szU8Buffer[0]=0xc0+(uByte[1]<<2)+(uByte[0]>>6); - szU8Buffer[1]=0x80+(uByte[0]&0x3f); - szU8Buffer[2]=0; + szU8Buffer[0] = 0xc0+(uByte[1]<<2)+(uByte[0]>>6); + szU8Buffer[1] = 0x80+(uByte[0]&0x3f); + szU8Buffer[2] = 0; } else { - szU8Buffer[0]=0xe0+(uByte[1]>>4); - szU8Buffer[1]=0x80+((uByte[1]&0x0f)<<2)+(uByte[0]>>6); - szU8Buffer[2]=0x80+(uByte[0]&0x3f); - szU8Buffer[3]=0; + szU8Buffer[0] = 0xe0+(uByte[1]>>4); + szU8Buffer[1] = 0x80+((uByte[1]&0x0f)<<2)+(uByte[0]>>6); + szU8Buffer[2] = 0x80+(uByte[0]&0x3f); + szU8Buffer[3] = 0; } pos += 3; diff --git a/src/modules/json/JSONWriter.cpp b/src/modules/json/JSONWriter.cpp index ae95773f6d..550a03dadd 100644 --- a/src/modules/json/JSONWriter.cpp +++ b/src/modules/json/JSONWriter.cpp @@ -41,7 +41,7 @@ const static json_string WRITER_EMPTY; if (amount == 0xFFFFFFFF) return WRITER_EMPTY; json_string result; result.reserve(amount); - for(unsigned int i = 0; i < amount; ++i){ + for(unsigned int i=0; i < amount; ++i){ result += INDENT; } return result; @@ -75,7 +75,7 @@ json_string internalJSONNode::WriteChildren(unsigned int indent){ } //else it's not formatted, leave the indentation strings empty const size_t size_minus_one = Children.size() - 1; - size_t i = 0; + size_t i=0; json_foreach(Children, it){ res += indent_plus_one + (*it) -> internal -> Write(indent, type() == JSON_ARRAY); if (i < size_minus_one) res += JSON_TEXT(","); //the last one does not get a comma, but all of the others do diff --git a/src/modules/json/JSON_Base64.cpp b/src/modules/json/JSON_Base64.cpp index 4759b112bb..07147afadc 100644 --- a/src/modules/json/JSON_Base64.cpp +++ b/src/modules/json/JSON_Base64.cpp @@ -1,28 +1,28 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "..\..\core\commonheaders.h" - +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + #include "JSON_Base64.h" #include "JSONDefs.h" @@ -42,7 +42,7 @@ json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes result.reserve((size_t)(((float)bytes) * 1.37f) + 4); //do all of the ones that are 3 byte aligned - for (size_t i = 0; i < aligned; ++i){ + for (size_t i=0; i < aligned; ++i){ result += chars64[(binary[0] & 0xFC) >> 2]; result += chars64[((binary[0] & 0x03) << 4) + ((binary[1] & 0xF0) >> 4)]; result += chars64[((binary[1] & 0x0F) << 2) + ((binary[2] & 0xC0) >> 6)]; @@ -53,7 +53,7 @@ json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes if (misaligned){ //copy the rest into a temporary buffer unsigned char temp[3]; - for (unsigned int i = 0; i < misaligned; ++i){ + for (unsigned int i=0; i < misaligned; ++i){ temp[i] = *binary++; } for (unsigned int i = (unsigned int)misaligned; i < 3; ++i){ @@ -67,7 +67,7 @@ json_string JSONBase64::json_encode64(const unsigned char * binary, size_t bytes result += chars64[((temp[1] & 0x0F) << 2) + ((temp[2] & 0xC0) >> 6)]; result += JSON_TEXT('='); } else { - result += JSON_TEXT("=="); + result += JSON_TEXT(" = = "); } } JSON_ASSERT((size_t)(((float)bytes) * 1.37f) + 4 >= result.length(), JSON_TEXT("Didn't reserve enough space for a one-time go")); @@ -110,7 +110,7 @@ std::string JSONBase64::json_decode64(const json_string & encoded){ result.reserve((size_t)((float)length / 1.37) + 1); //first do the ones that can not have any padding - for (unsigned int i = 0; i < aligned; ++i){ + for (unsigned int i=0; i < aligned; ++i){ const json_char second = toBinary(runner[1]); const json_char third = toBinary(runner[2]); result += (toBinary(runner[0]) << 2) + ((second & 0x30) >> 4); diff --git a/src/modules/json/NumberToString.h b/src/modules/json/NumberToString.h index a5e93d4302..35c6c98d0a 100644 --- a/src/modules/json/NumberToString.h +++ b/src/modules/json/NumberToString.h @@ -41,7 +41,7 @@ public: //create the string do { - *runner-- = (json_char)(value % 10) + JSON_TEXT('0'); + *runner--=(json_char)(value % 10) + JSON_TEXT('0'); } while(value /= 10); //if it's negative, add the negation @@ -66,7 +66,7 @@ public: //create the string do { - *runner-- = (json_char)(value % 10) + JSON_TEXT('0'); + *runner--=(json_char)(value % 10) + JSON_TEXT('0'); } while(value /= 10); json_string res = runner + 1; diff --git a/src/modules/json/json.cpp b/src/modules/json/json.cpp index ee71ee4ef7..4b3e35d926 100644 --- a/src/modules/json/json.cpp +++ b/src/modules/json/json.cpp @@ -31,12 +31,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR GetInterface(WPARAM wParam, LPARAM lParam) { - LPJSONSERVICEINTERFACE lpJSI=(LPJSONSERVICEINTERFACE)wParam; + LPJSONSERVICEINTERFACE lpJSI = (LPJSONSERVICEINTERFACE)wParam; memset(lpJSI,0,sizeof(JSONSERVICEINTERFACE)); -#define SETJSI(x) lpJSI->##x=json_##x +#define SETJSI(x) lpJSI->##x = json_##x SETJSI(free); - lpJSI->delete_=json_delete; + lpJSI->delete_ = json_delete; #ifdef JSON_MEMORY_MANAGE SETJSI(free_all); SETJSI(delete_all); @@ -50,7 +50,7 @@ INT_PTR GetInterface(WPARAM wParam, LPARAM lParam) SETJSI(new_i); SETJSI(new_f); SETJSI(new_b); - lpJSI->new_=json_new; + lpJSI->new_ = json_new; SETJSI(copy); SETJSI(duplicate); SETJSI(set_a); diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index bd72a8374b..670a882d90 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -28,7 +28,7 @@ static BOOL bModuleInitialized = FALSE; HANDLE hConnectionHeaderMutex, hConnectionOpenMutex; DWORD g_LastConnectionTick; int connectionTimeout; -HANDLE hSendEvent=NULL, hRecvEvent=NULL; +HANDLE hSendEvent = NULL, hRecvEvent = NULL; typedef BOOL (WINAPI *tGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD); @@ -53,9 +53,9 @@ void NetlibFreeUserSettingsStruct(NETLIBUSERSETTINGS *settings) void NetlibInitializeNestedCS(struct NetlibNestedCriticalSection *nlncs) { - nlncs->dwOwningThreadId= 0; - nlncs->lockCount=0; - nlncs->hMutex=CreateMutex(NULL, FALSE, NULL); + nlncs->dwOwningThreadId = 0; + nlncs->lockCount = 0; + nlncs->hMutex = CreateMutex(NULL, FALSE, NULL); } void NetlibDeleteNestedCS(struct NetlibNestedCriticalSection *nlncs) @@ -66,7 +66,7 @@ void NetlibDeleteNestedCS(struct NetlibNestedCriticalSection *nlncs) int NetlibEnterNestedCS(struct NetlibConnection *nlc, int which) { struct NetlibNestedCriticalSection *nlncs; - DWORD dwCurrentThreadId=GetCurrentThreadId(); + DWORD dwCurrentThreadId = GetCurrentThreadId(); WaitForSingleObject(hConnectionHeaderMutex, INFINITE); if (nlc == NULL || nlc->handleType != NLH_CONNECTION) { @@ -84,8 +84,8 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc, int which) ResetEvent(nlc->hOkToCloseEvent); ReleaseMutex(hConnectionHeaderMutex); WaitForSingleObject(nlncs->hMutex, INFINITE); - nlncs->dwOwningThreadId=dwCurrentThreadId; - nlncs->lockCount=1; + nlncs->dwOwningThreadId = dwCurrentThreadId; + nlncs->lockCount = 1; if (InterlockedDecrement(&nlc->dontCloseNow) == 0) SetEvent(nlc->hOkToCloseEvent); return 1; @@ -94,7 +94,7 @@ int NetlibEnterNestedCS(struct NetlibConnection *nlc, int which) void NetlibLeaveNestedCS(struct NetlibNestedCriticalSection *nlncs) { if (--nlncs->lockCount == 0) { - nlncs->dwOwningThreadId=0; + nlncs->dwOwningThreadId = 0; ReleaseMutex(nlncs->hMutex); } } @@ -120,7 +120,7 @@ static char *GetNetlibUserSettingString(const char *szUserModule, const char *sz else { char *szRet; if (decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal); - szRet=mir_strdup(dbv.pszVal); + szRet = mir_strdup(dbv.pszVal); DBFreeVariant(&dbv); if (szRet == NULL) SetLastError(ERROR_OUTOFMEMORY); return szRet; @@ -129,7 +129,7 @@ static char *GetNetlibUserSettingString(const char *szUserModule, const char *sz static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam) { - NETLIBUSER *nlu=(NETLIBUSER*)lParam; + NETLIBUSER *nlu = (NETLIBUSER*)lParam; if (nlu == NULL || nlu->cbSize != sizeof(NETLIBUSER) || nlu->szSettingsModule == NULL || ( !(nlu->flags&NUF_NOOPTIONS) && nlu->szDescriptiveName == NULL) || (nlu->flags&NUF_HTTPGATEWAY && (nlu->pfnHttpGatewayInit == NULL))) { @@ -155,42 +155,42 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam) if (nlu->szDescriptiveName) { thisUser->user.ptszDescriptiveName = (thisUser->user.flags&NUF_UNICODE ? mir_u2t((WCHAR*)nlu->ptszDescriptiveName) : mir_a2t(nlu->szDescriptiveName)); } - if ((thisUser->user.szSettingsModule=mir_strdup(nlu->szSettingsModule)) == NULL + if ((thisUser->user.szSettingsModule = mir_strdup(nlu->szSettingsModule)) == NULL || (nlu->szDescriptiveName && thisUser->user.ptszDescriptiveName == NULL) - || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent=mir_strdup(nlu->szHttpGatewayUserAgent)) == NULL)) + || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent = mir_strdup(nlu->szHttpGatewayUserAgent)) == NULL)) { mir_free(thisUser); SetLastError(ERROR_OUTOFMEMORY); return 0; } if (nlu->szHttpGatewayHello) - thisUser->user.szHttpGatewayHello=mir_strdup(nlu->szHttpGatewayHello); + thisUser->user.szHttpGatewayHello = mir_strdup(nlu->szHttpGatewayHello); else - thisUser->user.szHttpGatewayHello=NULL; + thisUser->user.szHttpGatewayHello = NULL; - thisUser->settings.cbSize=sizeof(NETLIBUSERSETTINGS); - thisUser->settings.useProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxy", 0); - thisUser->settings.proxyType=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyType", PROXYTYPE_SOCKS5); + thisUser->settings.cbSize = sizeof(NETLIBUSERSETTINGS); + thisUser->settings.useProxy = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxy", 0); + thisUser->settings.proxyType = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyType", PROXYTYPE_SOCKS5); if (thisUser->user.flags&NUF_NOHTTPSOPTION && thisUser->settings.proxyType == PROXYTYPE_HTTPS) - thisUser->settings.proxyType=PROXYTYPE_HTTP; + thisUser->settings.proxyType = PROXYTYPE_HTTP; if ( !(thisUser->user.flags&(NUF_HTTPCONNS|NUF_HTTPGATEWAY)) && thisUser->settings.proxyType == PROXYTYPE_HTTP) { - thisUser->settings.useProxy=0; - thisUser->settings.proxyType=PROXYTYPE_SOCKS5; + thisUser->settings.useProxy = 0; + thisUser->settings.proxyType = PROXYTYPE_SOCKS5; } - thisUser->settings.szProxyServer=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyServer", 0); - thisUser->settings.wProxyPort=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyPort", 1080); - thisUser->settings.useProxyAuth=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxyAuth", 0); - thisUser->settings.szProxyAuthUser=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthUser", 0); - thisUser->settings.szProxyAuthPassword=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthPassword", 1); - thisUser->settings.dnsThroughProxy=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLDnsThroughProxy", 1); - thisUser->settings.specifyIncomingPorts=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyIncomingPorts", 0); - thisUser->settings.szIncomingPorts=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLIncomingPorts", 0); - thisUser->settings.specifyOutgoingPorts=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyOutgoingPorts", 0); - thisUser->settings.szOutgoingPorts=GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLOutgoingPorts", 0); - thisUser->settings.enableUPnP=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLEnableUPnP", 1); //default to on - thisUser->settings.validateSSL=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLValidateSSL", 0); - - thisUser->toLog=GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLlog", 1); + thisUser->settings.szProxyServer = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyServer", 0); + thisUser->settings.wProxyPort = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyPort", 1080); + thisUser->settings.useProxyAuth = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxyAuth", 0); + thisUser->settings.szProxyAuthUser = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthUser", 0); + thisUser->settings.szProxyAuthPassword = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthPassword", 1); + thisUser->settings.dnsThroughProxy = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLDnsThroughProxy", 1); + thisUser->settings.specifyIncomingPorts = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyIncomingPorts", 0); + thisUser->settings.szIncomingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLIncomingPorts", 0); + thisUser->settings.specifyOutgoingPorts = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyOutgoingPorts", 0); + thisUser->settings.szOutgoingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLOutgoingPorts", 0); + thisUser->settings.enableUPnP = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLEnableUPnP", 1); //default to on + thisUser->settings.validateSSL = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLValidateSSL", 0); + + thisUser->toLog = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLlog", 1); mir_cslock lck(csNetlibUser); netlibUser.insert(thisUser); @@ -199,21 +199,21 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam) static INT_PTR NetlibGetUserSettings(WPARAM wParam, LPARAM lParam) { - NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam; - struct NetlibUser *nlu=(struct NetlibUser*)wParam; + NETLIBUSERSETTINGS *nlus = (NETLIBUSERSETTINGS*)lParam; + struct NetlibUser *nlu = (struct NetlibUser*)wParam; if (GetNetlibHandleType(nlu) != NLH_USER || nlus == NULL || nlus->cbSize != sizeof(NETLIBUSERSETTINGS)) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } - *nlus=nlu->settings; + *nlus = nlu->settings; return 1; } static INT_PTR NetlibSetUserSettings(WPARAM wParam, LPARAM lParam) { - NETLIBUSERSETTINGS *nlus=(NETLIBUSERSETTINGS*)lParam; - struct NetlibUser *nlu=(struct NetlibUser*)wParam; + NETLIBUSERSETTINGS *nlus = (NETLIBUSERSETTINGS*)lParam; + struct NetlibUser *nlu = (struct NetlibUser*)wParam; if (GetNetlibHandleType(nlu) != NLH_USER || nlus == NULL || nlus->cbSize != sizeof(NETLIBUSERSETTINGS)) { SetLastError(ERROR_INVALID_PARAMETER); @@ -244,7 +244,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) { case NLH_USER: { - struct NetlibUser *nlu=(struct NetlibUser*)wParam; + struct NetlibUser *nlu = (struct NetlibUser*)wParam; { mir_cslock lck(csNetlibUser); int i = netlibUser.getIndex(nlu); @@ -261,7 +261,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) break; } case NLH_CONNECTION: - { struct NetlibConnection *nlc=(struct NetlibConnection*)wParam; + { struct NetlibConnection *nlc = (struct NetlibConnection*)wParam; HANDLE waitHandles[4]; DWORD waitResult; @@ -280,17 +280,17 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) } ReleaseMutex(hConnectionHeaderMutex); - waitHandles[0]=hConnectionHeaderMutex; - waitHandles[1]=nlc->hOkToCloseEvent; - waitHandles[2]=nlc->ncsRecv.hMutex; - waitHandles[3]=nlc->ncsSend.hMutex; - waitResult=WaitForMultipleObjects(SIZEOF(waitHandles), waitHandles, TRUE, INFINITE); + waitHandles[0] = hConnectionHeaderMutex; + waitHandles[1] = nlc->hOkToCloseEvent; + waitHandles[2] = nlc->ncsRecv.hMutex; + waitHandles[3] = nlc->ncsSend.hMutex; + waitResult = WaitForMultipleObjects(SIZEOF(waitHandles), waitHandles, TRUE, INFINITE); if (waitResult= WAIT_OBJECT_0 + SIZEOF(waitHandles)) { ReleaseMutex(hConnectionHeaderMutex); SetLastError(ERROR_INVALID_PARAMETER); //already been closed return 0; } - nlc->handleType=0; + nlc->handleType = 0; mir_free(nlc->nlhpi.szHttpPostUrl); mir_free(nlc->nlhpi.szHttpGetUrl); mir_free(nlc->dataBuffer); @@ -308,7 +308,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM) case NLH_BOUNDPORT: return NetlibFreeBoundPort((struct NetlibBoundPort*)wParam); case NLH_PACKETRECVER: - { struct NetlibPacketRecver *nlpr=(struct NetlibPacketRecver*)wParam; + { struct NetlibPacketRecver *nlpr = (struct NetlibPacketRecver*)wParam; mir_free(nlpr->packetRecver.buffer); break; } @@ -406,10 +406,10 @@ INT_PTR NetlibShutdown(WPARAM wParam, LPARAM) return 0; } -static const char szHexDigits[]="0123456789ABCDEF"; +static const char szHexDigits[] = "0123456789ABCDEF"; INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam) { - unsigned char *szOutput, *szInput=(unsigned char*)lParam; + unsigned char *szOutput, *szInput = (unsigned char*)lParam; unsigned char *pszIn, *pszOut; int outputLen; @@ -417,19 +417,19 @@ INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam) SetLastError(ERROR_INVALID_PARAMETER); return (INT_PTR)(char*)NULL; } - for (outputLen=0, pszIn=szInput;*pszIn;pszIn++) { + for (outputLen = 0, pszIn = szInput;*pszIn;pszIn++) { if ((48 <= *pszIn && *pszIn <= 57) || //0-9 (65 <= *pszIn && *pszIn <= 90) || //ABC...XYZ (97 <= *pszIn && *pszIn <= 122) || //abc...xyz *pszIn == '-' || *pszIn == '_' || *pszIn == '.' || *pszIn == ' ') outputLen++; else outputLen+=3; } - szOutput=(unsigned char*)HeapAlloc(GetProcessHeap(), 0, outputLen+1); + szOutput = (unsigned char*)HeapAlloc(GetProcessHeap(), 0, outputLen+1); if (szOutput == NULL) { SetLastError(ERROR_OUTOFMEMORY); return (INT_PTR)(unsigned char*)NULL; } - for (pszOut=szOutput, pszIn=szInput;*pszIn;pszIn++) { + for (pszOut = szOutput, pszIn = szInput;*pszIn;pszIn++) { if ((48 <= *pszIn && *pszIn <= 57) || (65 <= *pszIn && *pszIn <= 90) || (97 <= *pszIn && *pszIn <= 122) || @@ -441,14 +441,14 @@ INT_PTR NetlibHttpUrlEncode(WPARAM, LPARAM lParam) *pszOut++=szHexDigits[*pszIn&0xF]; } } - *pszOut='\0'; + *pszOut = '\0'; return (INT_PTR)szOutput; } -static const char base64chars[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam) { - NETLIBBASE64 *nlb64=(NETLIBBASE64*)lParam; + NETLIBBASE64 *nlb64 = (NETLIBBASE64*)lParam; int iIn; char *pszOut; PBYTE pbIn; @@ -461,35 +461,35 @@ INT_PTR NetlibBase64Encode(WPARAM, LPARAM lParam) SetLastError(ERROR_BUFFER_OVERFLOW); return 0; } - nlb64->cchEncoded=Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded); - for (iIn=0, pbIn=nlb64->pbDecoded, pszOut=nlb64->pszEncoded;iIncbDecoded;iIn+=3, pbIn+=3, pszOut+=4) { - pszOut[0]=base64chars[pbIn[0]>>2]; + nlb64->cchEncoded = Netlib_GetBase64EncodedBufferSize(nlb64->cbDecoded); + for (iIn = 0, pbIn = nlb64->pbDecoded, pszOut = nlb64->pszEncoded;iIncbDecoded;iIn+=3, pbIn+=3, pszOut+=4) { + pszOut[0] = base64chars[pbIn[0]>>2]; if (nlb64->cbDecoded-iIn == 1) { - pszOut[1]=base64chars[(pbIn[0]&3)<<4]; - pszOut[2]='='; - pszOut[3]='='; + pszOut[1] = base64chars[(pbIn[0]&3)<<4]; + pszOut[2] = '='; + pszOut[3] = '='; pszOut+=4; break; } - pszOut[1]=base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)]; + pszOut[1] = base64chars[((pbIn[0]&3)<<4)|(pbIn[1]>>4)]; if (nlb64->cbDecoded-iIn == 2) { - pszOut[2]=base64chars[(pbIn[1]&0xF)<<2]; - pszOut[3]='='; + pszOut[2] = base64chars[(pbIn[1]&0xF)<<2]; + pszOut[3] = '='; pszOut+=4; break; } - pszOut[2]=base64chars[((pbIn[1]&0xF)<<2)|(pbIn[2]>>6)]; - pszOut[3]=base64chars[pbIn[2]&0x3F]; + pszOut[2] = base64chars[((pbIn[1]&0xF)<<2)|(pbIn[2]>>6)]; + pszOut[3] = base64chars[pbIn[2]&0x3F]; } - pszOut[0]='\0'; + pszOut[0] = '\0'; return 1; } static BYTE Base64CharToInt(char c) { - if (c>='A' && c<='Z') return c-'A'; - if (c>='a' && c<='z') return c-'a'+26; - if (c>='0' && c<='9') return c-'0'+52; + if (c>='A' && c <= 'Z') return c-'A'; + if (c>='a' && c <= 'z') return c-'a'+26; + if (c>='0' && c <= '9') return c-'0'+52; if (c == '+') return 62; if (c == '/') return 63; if (c == '=') return 64; @@ -498,7 +498,7 @@ static BYTE Base64CharToInt(char c) INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam) { - NETLIBBASE64 *nlb64=(NETLIBBASE64*)lParam; + NETLIBBASE64 *nlb64 = (NETLIBBASE64*)lParam; char *pszIn; PBYTE pbOut; BYTE b1, b2, b3, b4; @@ -516,21 +516,21 @@ INT_PTR NetlibBase64Decode(WPARAM, LPARAM lParam) SetLastError(ERROR_BUFFER_OVERFLOW); return 0; } - nlb64->cbDecoded=Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded); - for (iIn=0, pszIn=nlb64->pszEncoded, pbOut=nlb64->pbDecoded;iIncchEncoded;iIn+=4, pszIn+=4, pbOut+=3) { - b1=Base64CharToInt(pszIn[0]); - b2=Base64CharToInt(pszIn[1]); - b3=Base64CharToInt(pszIn[2]); - b4=Base64CharToInt(pszIn[3]); + nlb64->cbDecoded = Netlib_GetBase64DecodedBufferSize(nlb64->cchEncoded); + for (iIn = 0, pszIn = nlb64->pszEncoded, pbOut = nlb64->pbDecoded;iIncchEncoded;iIn+=4, pszIn+=4, pbOut+=3) { + b1 = Base64CharToInt(pszIn[0]); + b2 = Base64CharToInt(pszIn[1]); + b3 = Base64CharToInt(pszIn[2]); + b4 = Base64CharToInt(pszIn[3]); if (b1 == 255 || b1 == 64 || b2 == 255 || b2 == 64 || b3 == 255 || b4 == 255) { SetLastError(ERROR_INVALID_DATA); return 0; } - pbOut[0]=(b1<<2)|(b2>>4); + pbOut[0] = (b1<<2)|(b2>>4); if (b3 == 64) {nlb64->cbDecoded-=2; break;} - pbOut[1]=(b2<<4)|(b3>>2); + pbOut[1] = (b2<<4)|(b3>>2); if (b4 == 64) {nlb64->cbDecoded--; break;} - pbOut[2]=b4|(b3<<6); + pbOut[2] = b4|(b3<<6); } return 1; } @@ -574,7 +574,7 @@ int LoadNetlibModule(void) HookEvent(ME_OPT_INITIALISE, NetlibOptInitialise); InitializeCriticalSection(&csNetlibUser); - hConnectionHeaderMutex=CreateMutex(NULL, FALSE, NULL); + hConnectionHeaderMutex = CreateMutex(NULL, FALSE, NULL); NetlibLogInit(); connectionTimeout = 0; diff --git a/src/modules/netlib/netlib.h b/src/modules/netlib/netlib.h index f152eafe10..f20d123fee 100644 --- a/src/modules/netlib/netlib.h +++ b/src/modules/netlib/netlib.h @@ -210,10 +210,10 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge static __inline INT_PTR NLSend(struct NetlibConnection *nlc, const char *buf, int len, int flags) { - NETLIBBUFFER nlb={(char*)buf, len, flags}; + NETLIBBUFFER nlb = {(char*)buf, len, flags}; return NetlibSend((WPARAM)nlc, (LPARAM)&nlb); } static __inline INT_PTR NLRecv(struct NetlibConnection *nlc, char *buf, int len, int flags) { - NETLIBBUFFER nlb={buf, len, flags}; + NETLIBBUFFER nlb = {buf, len, flags}; return NetlibRecv((WPARAM)nlc, (LPARAM)&nlb); } diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp index 37c3e88e22..e0428bf687 100644 --- a/src/modules/netlib/netlibautoproxy.cpp +++ b/src/modules/netlib/netlibautoproxy.cpp @@ -325,7 +325,7 @@ char* NetlibGetIeProxy(char *szUrl) if (bEnabled) { - for (int i = 0; i < proxyBypass.getCount(); ++i) + for (int i=0; i < proxyBypass.getCount(); ++i) { if (strcmp(proxyBypass[i], "") == 0) { @@ -399,9 +399,9 @@ void NetlibLoadIeProxy(void) if (szProxyEnd) *szProxyEnd = 0; int ind = -1; - if (strncmp(szProxy, "http=", 5) == 0) { ind = 0; szProxy += 5; } - else if (strncmp(szProxy, "https=", 6) == 0) { ind = 1; szProxy += 6; } - else if (strncmp(szProxy, "socks=", 6) == 0) { ind = 2; szProxy += 6; } + if (strncmp(szProxy, "http = ", 5) == 0) { ind = 0; szProxy += 5; } + else if (strncmp(szProxy, "https = ", 6) == 0) { ind = 1; szProxy += 6; } + else if (strncmp(szProxy, "socks = ", 6) == 0) { ind = 2; szProxy += 6; } else if (strchr(szProxy, '=')) ind = -2; if (ind != -2) @@ -447,10 +447,10 @@ void NetlibUnloadIeProxy(void) { int i; - for (i = 0; i < 3; ++i) + for (i=0; i < 3; ++i) mir_free(szProxyHost[i]); - for (i = 0; i < proxyBypass.getCount(); ++i) + for (i=0; i < proxyBypass.getCount(); ++i) mir_free(proxyBypass[i]); proxyBypass.destroy(); diff --git a/src/modules/netlib/netlibbind.cpp b/src/modules/netlib/netlibbind.cpp index 582358b619..7bb862f284 100644 --- a/src/modules/netlib/netlibbind.cpp +++ b/src/modules/netlib/netlibbind.cpp @@ -43,13 +43,13 @@ bool BindSocketToPort(const char *szPorts, SOCKET s, SOCKET s6, int* portn) *portn = num % *portn; } - bool before=false; + bool before = false; while (true) { const char *psz; char *pszEnd; int portMin, portMax, port, portnum = 0; - for (psz=szPorts;*psz;) { + for (psz = szPorts;*psz;) { while (*psz == ' ' || *psz == ',') psz++; portMin = strtol(psz, &pszEnd, 0); if (pszEnd == psz) diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp index 7296b339bd..8a87d330d0 100644 --- a/src/modules/netlib/netlibhttp.cpp +++ b/src/modules/netlib/netlibhttp.cpp @@ -138,7 +138,7 @@ static int RecvWithTimeoutTime(struct NetlibConnection *nlc, unsigned dwTimeoutT static char* NetlibHttpFindHeader(NETLIBHTTPREQUEST *nlhrReply, const char *hdr) { - for (int i = 0; i < nlhrReply->headersCount; i++) + for (int i=0; i < nlhrReply->headersCount; i++) { if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0) { @@ -154,7 +154,7 @@ static char* NetlibHttpFindAuthHeader(NETLIBHTTPREQUEST *nlhrReply, const char * char *szNegoHdr = NULL; char *szNtlmHdr = NULL; - for (int i = 0; i < nlhrReply->headersCount; i++) + for (int i=0; i < nlhrReply->headersCount; i++) { if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0) { @@ -423,12 +423,12 @@ static int SendHttpRequestAndData(struct NetlibConnection *nlc, struct Resizable INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) { - struct NetlibConnection *nlc=(struct NetlibConnection*)wParam; - NETLIBHTTPREQUEST *nlhr=(NETLIBHTTPREQUEST*)lParam; + struct NetlibConnection *nlc = (struct NetlibConnection*)wParam; + NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam; NETLIBHTTPREQUEST *nlhrReply = NULL; HttpSecurityContext httpSecurity; - struct ResizableCharBuffer httpRequest={0}; + struct ResizableCharBuffer httpRequest = {0}; const char *pszRequest, *pszUrl, *pszFullUrl; char *szHost = NULL, *szNewUrl = NULL; char *pszProxyAuthHdr = NULL, *pszAuthHdr = NULL; @@ -531,7 +531,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) if (phost) { phost += 3; - size_t len = phost - pszUrl; + size_t len = phost - pszUrl; memcpy(szNewUrl, pszUrl, len); szNewUrl[len] = 0; } @@ -806,7 +806,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) INT_PTR NetlibHttpFreeRequestStruct(WPARAM, LPARAM lParam) { - NETLIBHTTPREQUEST *nlhr=(NETLIBHTTPREQUEST*)lParam; + NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam; if (nlhr == NULL || nlhr->cbSize != sizeof(NETLIBHTTPREQUEST) || nlhr->requestType != REQUEST_RESPONSE) { @@ -950,7 +950,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam) INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) { - NetlibUser *nlu = (NetlibUser*)wParam; + NetlibUser *nlu = (NetlibUser*)wParam; NETLIBHTTPREQUEST *nlhr = (NETLIBHTTPREQUEST*)lParam, *nlhrReply; DWORD dflags, hflags; @@ -989,10 +989,10 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) nlhrSend.headers[nlhrSend.headersCount].szValue = szUserAgent; ++nlhrSend.headersCount; CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(szMirandaVer), (LPARAM)szMirandaVer); - pspace=strchr(szMirandaVer, ' '); + pspace = strchr(szMirandaVer, ' '); if (pspace) { - *pspace++ = '\0'; + *pspace++='\0'; mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s (%s)", szMirandaVer, pspace); } else @@ -1099,8 +1099,7 @@ char* gzip_decode(char *gzip_data, int *len_ptr, int window) gzip_len = gzip_err == Z_STREAM_END ? zstr.total_out : -1; - if (gzip_len <= 0) - { + if (gzip_len <= 0) { mir_free(output_data); output_data = NULL; } diff --git a/src/modules/netlib/netlibhttpproxy.cpp b/src/modules/netlib/netlibhttpproxy.cpp index 77a70a1dce..7c1ddd53c9 100644 --- a/src/modules/netlib/netlibhttpproxy.cpp +++ b/src/modules/netlib/netlibhttpproxy.cpp @@ -81,7 +81,7 @@ static bool NetlibHttpGatewaySend(struct NetlibConnection *nlc, RequestType reqT { case reqHelloGet: nlhrSend.requestType = REQUEST_GET; - nlhrSend.szUrl=nlc->nlu->user.szHttpGatewayHello; + nlhrSend.szUrl = nlc->nlu->user.szHttpGatewayHello; break; case reqOldGet: @@ -136,13 +136,13 @@ static bool NetlibHttpGatewaySend(struct NetlibConnection *nlc, RequestType reqT nlhrSend.headersCount = 3; nlhrSend.headers = (NETLIBHTTPHEADER*)alloca(sizeof(NETLIBHTTPHEADER) * nlhrSend.headersCount); - nlhrSend.headers[0].szName = "User-Agent"; + nlhrSend.headers[0].szName = "User-Agent"; nlhrSend.headers[0].szValue = nlc->nlu->user.szHttpGatewayUserAgent; - nlhrSend.headers[1].szName = "Cache-Control"; + nlhrSend.headers[1].szName = "Cache-Control"; nlhrSend.headers[1].szValue = "no-cache, no-store "; - nlhrSend.headers[2].szName = "Pragma"; + nlhrSend.headers[2].szName = "Pragma"; nlhrSend.headers[2].szValue = "no-cache"; -// nlhrSend.headers[3].szName = "Accept-Encoding"; +// nlhrSend.headers[3].szName = "Accept-Encoding"; // nlhrSend.headers[3].szValue = "deflate, gzip"; return NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) != SOCKET_ERROR; @@ -179,19 +179,19 @@ static bool NetlibHttpGatewayOscarPost(NetlibConnection *nlc, const char *buf, i NETLIBHTTPREQUEST *nlhrReply = NULL; NetlibConnection nlcSend = {0}; - nlcSend.handleType = NLH_CONNECTION; - nlcSend.nlu = nlc->nlu; - nlcSend.nlhpi = nlc->nlhpi; - nlcSend.s = nlc->s2; + nlcSend.handleType = NLH_CONNECTION; + nlcSend.nlu = nlc->nlu; + nlcSend.nlhpi = nlc->nlhpi; + nlcSend.s = nlc->s2; nlcSend.usingHttpGateway = nlc->usingHttpGateway; - nlcSend.szProxyServer = nlc->szProxyServer; - nlcSend.wProxyPort = nlc->wProxyPort; - nlcSend.proxyType = nlc->proxyType; + nlcSend.szProxyServer = nlc->szProxyServer; + nlcSend.wProxyPort = nlc->wProxyPort; + nlcSend.proxyType = nlc->proxyType; if ( !NetlibReconnect(&nlcSend)) return false; nlc->s2 = nlcSend.s; - nlcSend.hOkToCloseEvent = CreateEvent(NULL, TRUE, TRUE, NULL); + nlcSend.hOkToCloseEvent = CreateEvent(NULL, TRUE, TRUE, NULL); NetlibInitializeNestedCS(&nlcSend.ncsRecv); NetlibInitializeNestedCS(&nlcSend.ncsSend); @@ -404,7 +404,7 @@ int NetlibInitHttpConnection(struct NetlibConnection *nlc, struct NetlibUser *nl { NETLIBHTTPREQUEST *nlhrReply = NULL; - nlc->nlhpi.firstGetSequence = 1; + nlc->nlhpi.firstGetSequence = 1; nlc->nlhpi.firstPostSequence = 1; if (nlu->user.szHttpGatewayHello != NULL) @@ -449,8 +449,8 @@ int NetlibInitHttpConnection(struct NetlibConnection *nlc, struct NetlibUser *nl INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam) { - NETLIBHTTPPROXYINFO *nlhpi=(NETLIBHTTPPROXYINFO*)lParam; - struct NetlibConnection *nlc=(struct NetlibConnection*)wParam; + NETLIBHTTPPROXYINFO *nlhpi = (NETLIBHTTPPROXYINFO*)lParam; + struct NetlibConnection *nlc = (struct NetlibConnection*)wParam; if (GetNetlibHandleType(nlc) != NLH_CONNECTION || nlhpi == NULL || nlhpi->cbSize < (sizeof(NETLIBHTTPPROXYINFO) - sizeof(int)) || @@ -467,7 +467,7 @@ INT_PTR NetlibHttpGatewaySetInfo(WPARAM wParam, LPARAM lParam) memcpy(&nlc->nlhpi, nlhpi, min(nlhpi->cbSize, sizeof(*nlhpi))); if (nlc->nlhpi.combinePackets == 0) nlc->nlhpi.combinePackets = 1; - nlc->nlhpi.szHttpGetUrl = mir_strdup(nlc->nlhpi.szHttpGetUrl); + nlc->nlhpi.szHttpGetUrl = mir_strdup(nlc->nlhpi.szHttpGetUrl); nlc->nlhpi.szHttpPostUrl = mir_strdup(nlc->nlhpi.szHttpPostUrl); return 1; @@ -485,7 +485,7 @@ INT_PTR NetlibHttpSetSticky(WPARAM wParam, LPARAM lParam) INT_PTR NetlibHttpSetPollingTimeout(WPARAM wParam, LPARAM lParam) { int oldTimeout; - struct NetlibConnection *nlc=(struct NetlibConnection*)wParam; + struct NetlibConnection *nlc = (struct NetlibConnection*)wParam; if (GetNetlibHandleType(nlc) != NLH_CONNECTION) return -1; oldTimeout = nlc->pollingTimeout; nlc->pollingTimeout = lParam; diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp index 2e9f7a4365..ff352b5b55 100644 --- a/src/modules/netlib/netliblog.cpp +++ b/src/modules/netlib/netliblog.cpp @@ -57,7 +57,7 @@ static __int64 mirandaStartTime, perfCounterFreq; static int bIsActive = TRUE; static HANDLE hLogEvent = NULL; -static const TCHAR* szTimeFormats[] = +static const TCHAR* szTimeFormats[] = { _T("No times"), _T("Standard hh:mm:ss times"), @@ -69,7 +69,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa { switch(message) { case WM_INITDIALOG: - logOptions.hwndOpts=hwndDlg; + logOptions.hwndOpts = hwndDlg; TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_DUMPRECV, logOptions.dumpRecv?BST_CHECKED:BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_DUMPSENT, logOptions.dumpSent?BST_CHECKED:BST_UNCHECKED); @@ -102,21 +102,21 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa SetWindowLongPtr(hwndFilter, GWL_STYLE, GetWindowLongPtr(hwndFilter, GWL_STYLE) | (TVS_NOHSCROLL | TVS_CHECKBOXES)); - tvis.hParent=NULL; - tvis.hInsertAfter=TVI_SORT; - tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - tvis.item.stateMask=TVIS_STATEIMAGEMASK; + tvis.hParent = NULL; + tvis.hInsertAfter = TVI_SORT; + tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE; + tvis.item.stateMask = TVIS_STATEIMAGEMASK; - for (i = 0; i < netlibUser.getCount(); ++i) + for (i=0; i < netlibUser.getCount(); ++i) { - tvis.item.pszText=netlibUser[i]->user.ptszDescriptiveName; - tvis.item.lParam=i; - tvis.item.state=INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1); + tvis.item.pszText = netlibUser[i]->user.ptszDescriptiveName; + tvis.item.lParam = i; + tvis.item.state = INDEXTOSTATEIMAGEMASK((netlibUser[i]->toLog) ? 2 : 1); TreeView_InsertItem(hwndFilter, &tvis); } - tvis.item.lParam=-1; - tvis.item.pszText=TranslateT("(Miranda Core Logging)"); - tvis.item.state=INDEXTOSTATEIMAGEMASK((logOptions.toLog) ? 2 : 1); + tvis.item.lParam = -1; + tvis.item.pszText = TranslateT("(Miranda Core Logging)"); + tvis.item.state = INDEXTOSTATEIMAGEMASK((logOptions.toLog) ? 2 : 1); TreeView_InsertItem(hwndFilter, &tvis); } return TRUE; @@ -154,29 +154,29 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa case IDC_FILENAMEBROWSE: case IDC_RUNATSTARTBROWSE: { TCHAR str[MAX_PATH+2]; - OPENFILENAME ofn={0}; + OPENFILENAME ofn = {0}; TCHAR filter[512], *pfilter; GetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str, SIZEOF(str)); - ofn.lStructSize=OPENFILENAME_SIZE_VERSION_400; - ofn.hwndOwner=hwndDlg; - ofn.Flags=OFN_HIDEREADONLY | OFN_DONTADDTORECENT; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.hwndOwner = hwndDlg; + ofn.Flags = OFN_HIDEREADONLY | OFN_DONTADDTORECENT; if (LOWORD(wParam) == IDC_FILENAMEBROWSE) { - ofn.lpstrTitle=TranslateT("Select where log file will be created"); + ofn.lpstrTitle = TranslateT("Select where log file will be created"); } else { ofn.Flags|=OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST; - ofn.lpstrTitle=TranslateT("Select program to be run"); + ofn.lpstrTitle = TranslateT("Select program to be run"); } _tcscpy(filter, TranslateT("All Files")); _tcscat(filter, _T(" (*)")); - pfilter=filter+lstrlen(filter)+1; + pfilter = filter+lstrlen(filter)+1; _tcscpy(pfilter, _T("*")); - pfilter=pfilter+lstrlen(pfilter)+1; - *pfilter='\0'; - ofn.lpstrFilter=filter; - ofn.lpstrFile=str; - ofn.nMaxFile=SIZEOF(str)-2; - ofn.nMaxFileTitle=MAX_PATH; + pfilter = pfilter+lstrlen(pfilter)+1; + *pfilter = '\0'; + ofn.lpstrFilter = filter; + ofn.lpstrFile = str; + ofn.nMaxFile = SIZEOF(str)-2; + ofn.nMaxFileTitle = MAX_PATH; if (LOWORD(wParam) == IDC_FILENAMEBROWSE) { if ( !GetSaveFileName(&ofn)) return 1; } else { @@ -184,7 +184,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa } if (LOWORD(wParam) == IDC_RUNATSTARTBROWSE && _tcschr(str, ' ') != NULL) { MoveMemory(str+1, str, SIZEOF(str)-2); - str[0]='"'; + str[0] = '"'; lstrcat(str, _T("\"")); } SetWindowText(GetWindow((HWND)lParam, GW_HWNDPREV), str); @@ -192,10 +192,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa } case IDC_RUNNOW: { TCHAR str[MAX_PATH+1]; - STARTUPINFO si={0}; + STARTUPINFO si = {0}; PROCESS_INFORMATION pi; GetDlgItemText(hwndDlg, IDC_RUNATSTART, str, MAX_PATH); - si.cb=sizeof(si); + si.cb = sizeof(si); if (str[0]) CreateProcess(NULL, str, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); } break; @@ -220,24 +220,24 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa GetWindowText(GetDlgItem(hwndDlg, IDC_PATH), str, MAX_PATH); logOptions.szFile = mir_tstrdup(str); - logOptions.dumpRecv=IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV); - logOptions.dumpSent=IsDlgButtonChecked(hwndDlg, IDC_DUMPSENT); - logOptions.dumpProxy=IsDlgButtonChecked(hwndDlg, IDC_DUMPPROXY); - logOptions.dumpSsl=IsDlgButtonChecked(hwndDlg, IDC_DUMPSSL); - logOptions.textDumps=IsDlgButtonChecked(hwndDlg, IDC_TEXTDUMPS); - logOptions.autoDetectText=IsDlgButtonChecked(hwndDlg, IDC_AUTODETECTTEXT); - logOptions.timeFormat=SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_GETCURSEL, 0, 0); - logOptions.showUser=IsDlgButtonChecked(hwndDlg, IDC_SHOWNAMES); - logOptions.toOutputDebugString=IsDlgButtonChecked(hwndDlg, IDC_TOOUTPUTDEBUGSTRING); - logOptions.toFile=IsDlgButtonChecked(hwndDlg, IDC_TOFILE); + logOptions.dumpRecv = IsDlgButtonChecked(hwndDlg, IDC_DUMPRECV); + logOptions.dumpSent = IsDlgButtonChecked(hwndDlg, IDC_DUMPSENT); + logOptions.dumpProxy = IsDlgButtonChecked(hwndDlg, IDC_DUMPPROXY); + logOptions.dumpSsl = IsDlgButtonChecked(hwndDlg, IDC_DUMPSSL); + logOptions.textDumps = IsDlgButtonChecked(hwndDlg, IDC_TEXTDUMPS); + logOptions.autoDetectText = IsDlgButtonChecked(hwndDlg, IDC_AUTODETECTTEXT); + logOptions.timeFormat = SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_GETCURSEL, 0, 0); + logOptions.showUser = IsDlgButtonChecked(hwndDlg, IDC_SHOWNAMES); + logOptions.toOutputDebugString = IsDlgButtonChecked(hwndDlg, IDC_TOOUTPUTDEBUGSTRING); + logOptions.toFile = IsDlgButtonChecked(hwndDlg, IDC_TOFILE); } { HWND hwndFilter = GetDlgItem(logOptions.hwndOpts, IDC_FILTER); - TVITEM tvi={0}; + TVITEM tvi = {0}; BOOL checked; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_STATE|TVIF_TEXT; - tvi.hItem=TreeView_GetRoot(hwndFilter); + tvi.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_STATE|TVIF_TEXT; + tvi.hItem = TreeView_GetRoot(hwndFilter); while (tvi.hItem) { @@ -256,7 +256,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa DBWriteContactSettingDword(NULL, netlibUser[tvi.lParam]->user.szSettingsModule, "NLlog", checked); } - tvi.hItem=TreeView_GetNextSibling(hwndFilter, tvi.hItem); + tvi.hItem = TreeView_GetNextSibling(hwndFilter, tvi.hItem); } } @@ -288,7 +288,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa break; case WM_DESTROY: ImageList_Destroy(TreeView_GetImageList(GetDlgItem(hwndDlg, IDC_FILTER), TVSIL_STATE)); - logOptions.hwndOpts=NULL; + logOptions.hwndOpts = NULL; break; } return FALSE; @@ -297,7 +297,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa void NetlibLogShowOptions(void) { if (logOptions.hwndOpts == NULL) - logOptions.hwndOpts=CreateDialog(hInst, MAKEINTRESOURCE(IDD_NETLIBLOGOPTS), NULL, LogOptionsDlgProc); + logOptions.hwndOpts = CreateDialog(hInst, MAKEINTRESOURCE(IDD_NETLIBLOGOPTS), NULL, LogOptionsDlgProc); SetForegroundWindow(logOptions.hwndOpts); } @@ -365,7 +365,7 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam) (logOptions.showUser && logOptions.timeFormat) ? " " : "", logOptions.showUser ? nlu->user.szSettingsModule : ""); else - szHead[0]=0; + szHead[0] = 0; if (logOptions.toOutputDebugString) { if (szHead[0]) @@ -428,7 +428,7 @@ void NetlibLogf(NetlibUser* nlu, const char *fmt, ...) void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent, int flags) { - int isText=1; + int isText = 1; char szTitleLine[128]; char *szBuf; int titleLineLen; @@ -474,7 +474,7 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent, if (logOptions.autoDetectText) { int i; - for (i = 0; i=0x80) { @@ -526,17 +526,17 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent, lstrcpyA(pszBuf, " "); pszBuf += 3; } - *pszBuf++ = ' '; + *pszBuf++=' '; } for (col = 0; col < colsInLine; col++) - *pszBuf++ = buf[line+col]<' '?'.':(char)buf[line+col]; + *pszBuf++=buf[line+col]<' '?'.':(char)buf[line+col]; - if (len-line<=16) + if (len-line <= 16) break; - *pszBuf++ = '\r'; // End each line with a break - *pszBuf++ = '\n'; // End each line with a break + *pszBuf++='\r'; // End each line with a break + *pszBuf++='\n'; // End each line with a break } *pszBuf = '\0'; } diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp index 15623461c6..1f23c7e197 100644 --- a/src/modules/netlib/netlibopenconn.cpp +++ b/src/modules/netlib/netlibopenconn.cpp @@ -59,7 +59,7 @@ int WaitUntilReadable(SOCKET s, DWORD dwTimeout, bool check) if (s == INVALID_SOCKET) return SOCKET_ERROR; - tv.tv_sec = dwTimeout / 1000; + tv.tv_sec = dwTimeout / 1000; tv.tv_usec = (dwTimeout % 1000) * 1000; FD_ZERO(&readfd); @@ -160,9 +160,9 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli //rfc1928 BYTE buf[258]; - buf[0]=5; //yep, socks5 - buf[1]=1; //one auth method - buf[2]=nlu->settings.useProxyAuth?2:0; + buf[0] = 5; //yep, socks5 + buf[1] = 1; //one auth method + buf[2] = nlu->settings.useProxyAuth?2:0; if (NLSend(nlc, (char*)buf, 3, MSG_DUMPPROXY) == SOCKET_ERROR) { NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); return 0; @@ -183,13 +183,13 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli int nUserLen, nPassLen; PBYTE pAuthBuf; - nUserLen=lstrlenA(nlu->settings.szProxyAuthUser); - nPassLen=lstrlenA(nlu->settings.szProxyAuthPassword); - pAuthBuf=(PBYTE)mir_alloc(3+nUserLen+nPassLen); - pAuthBuf[0]=1; //auth version - pAuthBuf[1]=nUserLen; + nUserLen = lstrlenA(nlu->settings.szProxyAuthUser); + nPassLen = lstrlenA(nlu->settings.szProxyAuthPassword); + pAuthBuf = (PBYTE)mir_alloc(3+nUserLen+nPassLen); + pAuthBuf[0] = 1; //auth version + pAuthBuf[1] = nUserLen; memcpy(pAuthBuf+2, nlu->settings.szProxyAuthUser, nUserLen); - pAuthBuf[2+nUserLen]=nPassLen; + pAuthBuf[2+nUserLen] = nPassLen; memcpy(pAuthBuf+3+nUserLen, nlu->settings.szProxyAuthPassword, nPassLen); if (NLSend(nlc, (char*)pAuthBuf, 3+nUserLen+nPassLen, MSG_DUMPPROXY) == SOCKET_ERROR) { NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); @@ -225,20 +225,20 @@ static int NetlibInitSocks5Connection(struct NetlibConnection *nlc, struct Netli return 0; nHostLen = 4; } - pInit=(PBYTE)mir_alloc(6+nHostLen); - pInit[0]=5; //SOCKS5 - pInit[1]= nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP - pInit[2]=0; //reserved + pInit = (PBYTE)mir_alloc(6+nHostLen); + pInit[0] = 5; //SOCKS5 + pInit[1] = nloc->flags & NLOCF_UDP ? 3 : 1; //connect or UDP + pInit[2] = 0; //reserved if (hostIP == INADDR_NONE) { //DNS lookup through proxy - pInit[3]=3; - pInit[4]=nHostLen-1; + pInit[3] = 3; + pInit[4] = nHostLen-1; memcpy(pInit+5, nloc->szHost, nHostLen-1); } else { - pInit[3]=1; - *(PDWORD)(pInit+4)=hostIP; + pInit[3] = 1; + *(PDWORD)(pInit+4) = hostIP; } - *(PWORD)(pInit+4+nHostLen)=htons(nloc->wPort); + *(PWORD)(pInit+4+nHostLen) = htons(nloc->wPort); if (NLSend(nlc, (char*)pInit, 6+nHostLen, MSG_DUMPPROXY) == SOCKET_ERROR) { NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "NLSend", GetLastError()); mir_free(pInit); @@ -345,7 +345,7 @@ static bool NetlibInitHttpsConnection(struct NetlibConnection *nlc, struct Netli static void FreePartiallyInitedConnection(struct NetlibConnection *nlc) { - DWORD dwOriginalLastError=GetLastError(); + DWORD dwOriginalLastError = GetLastError(); if (nlc->s != INVALID_SOCKET) closesocket(nlc->s); mir_free(nlc->nlhpi.szHttpPostUrl); diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp index a8dc2b77b0..86fc34a6b5 100644 --- a/src/modules/netlib/netlibopts.cpp +++ b/src/modules/netlib/netlibopts.cpp @@ -32,7 +32,7 @@ struct NetlibTempSettings static LIST tempSettings(5); -static const UINT outgoingConnectionsControls[] = +static const UINT outgoingConnectionsControls[] = { IDC_STATIC12, IDC_USEPROXY, @@ -45,28 +45,28 @@ static const UINT outgoingConnectionsControls[] = IDC_PORTSRANGEO, IDC_STATIC54, IDC_VALIDATESSL}; -static const UINT useProxyControls[]={ +static const UINT useProxyControls[] = { IDC_STATIC21, IDC_PROXYTYPE, IDC_STATIC22, IDC_PROXYHOST, IDC_STATIC23, IDC_PROXYPORT, IDC_STOFTENPORT, IDC_PROXYAUTH, IDC_STATIC31, IDC_PROXYUSER, IDC_STATIC32, IDC_PROXYPASS, IDC_PROXYDNS}; -static const UINT specifyOPortsControls[]={ +static const UINT specifyOPortsControls[] = { IDC_PORTSRANGEO, IDC_STATIC54 }; -static const UINT incomingConnectionsControls[]={ +static const UINT incomingConnectionsControls[] = { IDC_STATIC43, IDC_SPECIFYPORTS, IDC_PORTSRANGE, IDC_STATIC52, IDC_ENABLEUPNP}; -static const UINT specifyPortsControls[]={ +static const UINT specifyPortsControls[] = { IDC_PORTSRANGE, IDC_STATIC52}; -static const TCHAR* szProxyTypes[]={_T(""), _T("SOCKS4"), _T("SOCKS5"), _T("HTTP"), _T("HTTPS"), _T("Internet Explorer")}; -static const WORD oftenProxyPorts[]={1080, 1080, 1080, 8080, 8080, 8080}; +static const TCHAR* szProxyTypes[] = {_T(""), _T("SOCKS4"), _T("SOCKS5"), _T("HTTP"), _T("HTTPS"), _T("Internet Explorer")}; +static const WORD oftenProxyPorts[] = {1080, 1080, 1080, 8080, 8080, 8080}; #define M_REFRESHALL (WM_USER+100) #define M_REFRESHENABLING (WM_USER+101) @@ -93,68 +93,68 @@ static void AddProxyTypeItem(HWND hwndDlg, int type, int selectType) static void CopySettingsStruct(NETLIBUSERSETTINGS *dest, NETLIBUSERSETTINGS *source) { - *dest=*source; - if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts); - if (dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts); - if (dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword); - if (dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser); - if (dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer); + *dest = *source; + if (dest->szIncomingPorts) dest->szIncomingPorts = mir_strdup(dest->szIncomingPorts); + if (dest->szOutgoingPorts) dest->szOutgoingPorts = mir_strdup(dest->szOutgoingPorts); + if (dest->szProxyAuthPassword) dest->szProxyAuthPassword = mir_strdup(dest->szProxyAuthPassword); + if (dest->szProxyAuthUser) dest->szProxyAuthUser = mir_strdup(dest->szProxyAuthUser); + if (dest->szProxyServer) dest->szProxyServer = mir_strdup(dest->szProxyServer); } static void CombineSettingsStrings(char **dest, char **source) { - if (*dest != NULL && (*source == NULL || lstrcmpiA(*dest, *source))) {mir_free(*dest); *dest=NULL;} + if (*dest != NULL && (*source == NULL || lstrcmpiA(*dest, *source))) {mir_free(*dest); *dest = NULL;} } static void CombineSettingsStructs(NETLIBUSERSETTINGS *dest, DWORD *destFlags, NETLIBUSERSETTINGS *source, DWORD sourceFlags) { if (sourceFlags&NUF_OUTGOING) { if (*destFlags&NUF_OUTGOING) { - if (dest->validateSSL != source->validateSSL) dest->validateSSL=2; - if (dest->useProxy != source->useProxy) dest->useProxy=2; - if (dest->proxyType != source->proxyType) dest->proxyType=0; + if (dest->validateSSL != source->validateSSL) dest->validateSSL = 2; + if (dest->useProxy != source->useProxy) dest->useProxy = 2; + if (dest->proxyType != source->proxyType) dest->proxyType = 0; CombineSettingsStrings(&dest->szProxyServer, &source->szProxyServer); - if (dest->wProxyPort != source->wProxyPort) dest->wProxyPort=0; - if (dest->useProxyAuth != source->useProxyAuth) dest->useProxyAuth=2; + if (dest->wProxyPort != source->wProxyPort) dest->wProxyPort = 0; + if (dest->useProxyAuth != source->useProxyAuth) dest->useProxyAuth = 2; CombineSettingsStrings(&dest->szProxyAuthUser, &source->szProxyAuthUser); CombineSettingsStrings(&dest->szProxyAuthPassword, &source->szProxyAuthPassword); - if (dest->dnsThroughProxy != source->dnsThroughProxy) dest->dnsThroughProxy=2; - if (dest->specifyOutgoingPorts != source->specifyOutgoingPorts) dest->specifyOutgoingPorts=2; + if (dest->dnsThroughProxy != source->dnsThroughProxy) dest->dnsThroughProxy = 2; + if (dest->specifyOutgoingPorts != source->specifyOutgoingPorts) dest->specifyOutgoingPorts = 2; CombineSettingsStrings(&dest->szOutgoingPorts, &source->szOutgoingPorts); } else { - dest->validateSSL=source->validateSSL; - dest->useProxy=source->useProxy; - dest->proxyType=source->proxyType; - dest->szProxyServer=source->szProxyServer; - if (dest->szProxyServer) dest->szProxyServer=mir_strdup(dest->szProxyServer); - dest->wProxyPort=source->wProxyPort; - dest->useProxyAuth=source->useProxyAuth; - dest->szProxyAuthUser=source->szProxyAuthUser; - if (dest->szProxyAuthUser) dest->szProxyAuthUser=mir_strdup(dest->szProxyAuthUser); - dest->szProxyAuthPassword=source->szProxyAuthPassword; - if (dest->szProxyAuthPassword) dest->szProxyAuthPassword=mir_strdup(dest->szProxyAuthPassword); - dest->dnsThroughProxy=source->dnsThroughProxy; - dest->specifyOutgoingPorts=source->specifyOutgoingPorts; - dest->szOutgoingPorts=source->szOutgoingPorts; - if (dest->szOutgoingPorts) dest->szOutgoingPorts=mir_strdup(dest->szOutgoingPorts); + dest->validateSSL = source->validateSSL; + dest->useProxy = source->useProxy; + dest->proxyType = source->proxyType; + dest->szProxyServer = source->szProxyServer; + if (dest->szProxyServer) dest->szProxyServer = mir_strdup(dest->szProxyServer); + dest->wProxyPort = source->wProxyPort; + dest->useProxyAuth = source->useProxyAuth; + dest->szProxyAuthUser = source->szProxyAuthUser; + if (dest->szProxyAuthUser) dest->szProxyAuthUser = mir_strdup(dest->szProxyAuthUser); + dest->szProxyAuthPassword = source->szProxyAuthPassword; + if (dest->szProxyAuthPassword) dest->szProxyAuthPassword = mir_strdup(dest->szProxyAuthPassword); + dest->dnsThroughProxy = source->dnsThroughProxy; + dest->specifyOutgoingPorts = source->specifyOutgoingPorts; + dest->szOutgoingPorts = source->szOutgoingPorts; + if (dest->szOutgoingPorts) dest->szOutgoingPorts = mir_strdup(dest->szOutgoingPorts); } } if (sourceFlags&NUF_INCOMING) { if (*destFlags&NUF_INCOMING) { - if (dest->enableUPnP != source->enableUPnP) dest->enableUPnP=2; - if (dest->specifyIncomingPorts != source->specifyIncomingPorts) dest->specifyIncomingPorts=2; + if (dest->enableUPnP != source->enableUPnP) dest->enableUPnP = 2; + if (dest->specifyIncomingPorts != source->specifyIncomingPorts) dest->specifyIncomingPorts = 2; CombineSettingsStrings(&dest->szIncomingPorts, &source->szIncomingPorts); } else { - dest->enableUPnP=source->enableUPnP; - dest->specifyIncomingPorts=source->specifyIncomingPorts; - dest->szIncomingPorts=source->szIncomingPorts; - if (dest->szIncomingPorts) dest->szIncomingPorts=mir_strdup(dest->szIncomingPorts); + dest->enableUPnP = source->enableUPnP; + dest->specifyIncomingPorts = source->specifyIncomingPorts; + dest->szIncomingPorts = source->szIncomingPorts; + if (dest->szIncomingPorts) dest->szIncomingPorts = mir_strdup(dest->szIncomingPorts); } } if ((*destFlags&NUF_NOHTTPSOPTION) != (sourceFlags&NUF_NOHTTPSOPTION)) - *destFlags=(*destFlags|sourceFlags)&~NUF_NOHTTPSOPTION; + *destFlags = (*destFlags|sourceFlags)&~NUF_NOHTTPSOPTION; else *destFlags|=sourceFlags; } @@ -167,26 +167,26 @@ static void ChangeSettingIntByCheckbox(HWND hwndDlg, UINT ctrlId, int iUser, int if ( !(tempSettings[i]->flags & NUF_NOOPTIONS)) *(int*)(((PBYTE)&tempSettings[i]->settings) + memberOffset) = newValue; } - else *(int*)(((PBYTE)&tempSettings[iUser]->settings) + memberOffset)=newValue; + else *(int*)(((PBYTE)&tempSettings[iUser]->settings) + memberOffset) = newValue; SendMessage(hwndDlg, M_REFRESHENABLING, 0, 0); } static void ChangeSettingStringByEdit(HWND hwndDlg, UINT ctrlId, int iUser, int memberOffset) { - int newValueLen=GetWindowTextLength(GetDlgItem(hwndDlg, ctrlId)); - char *szNewValue=(char*)mir_alloc(newValueLen+1); + int newValueLen = GetWindowTextLength(GetDlgItem(hwndDlg, ctrlId)); + char *szNewValue = (char*)mir_alloc(newValueLen+1); GetDlgItemTextA(hwndDlg, ctrlId, szNewValue, newValueLen+1); if (iUser == -1) { for (int i=0; iflags & NUF_NOOPTIONS)) { - char **ppszNew=(char**)(((PBYTE)&tempSettings[i]->settings)+memberOffset); + char **ppszNew = (char**)(((PBYTE)&tempSettings[i]->settings)+memberOffset); mir_free(*ppszNew); *ppszNew = mir_strdup(szNewValue); } mir_free(szNewValue); } else { - char **ppszNew=(char**)(((PBYTE)&tempSettings[iUser]->settings)+memberOffset); + char **ppszNew = (char**)(((PBYTE)&tempSettings[iUser]->settings)+memberOffset); mir_free(*ppszNew); *ppszNew = szNewValue; } @@ -240,13 +240,13 @@ void NetlibSaveUserSettingsStruct(const char *szSettingsModule, NETLIBUSERSETTIN continue; CombineSettingsStructs(&combinedSettings, &flags, &thisUser->settings, thisUser->user.flags); } - if (combinedSettings.validateSSL == 2) combinedSettings.validateSSL=0; - if (combinedSettings.useProxy == 2) combinedSettings.useProxy=0; - if (combinedSettings.proxyType == 0) combinedSettings.proxyType=PROXYTYPE_SOCKS5; - if (combinedSettings.useProxyAuth == 2) combinedSettings.useProxyAuth=0; - if (combinedSettings.dnsThroughProxy == 2) combinedSettings.dnsThroughProxy=1; - if (combinedSettings.enableUPnP == 2) combinedSettings.enableUPnP=1; - if (combinedSettings.specifyIncomingPorts == 2) combinedSettings.specifyIncomingPorts=0; + if (combinedSettings.validateSSL == 2) combinedSettings.validateSSL = 0; + if (combinedSettings.useProxy == 2) combinedSettings.useProxy = 0; + if (combinedSettings.proxyType == 0) combinedSettings.proxyType = PROXYTYPE_SOCKS5; + if (combinedSettings.useProxyAuth == 2) combinedSettings.useProxyAuth = 0; + if (combinedSettings.dnsThroughProxy == 2) combinedSettings.dnsThroughProxy = 1; + if (combinedSettings.enableUPnP == 2) combinedSettings.enableUPnP = 1; + if (combinedSettings.specifyIncomingPorts == 2) combinedSettings.specifyIncomingPorts = 0; WriteSettingsStructToDb("Netlib", &combinedSettings, flags); NetlibFreeUserSettingsStruct(&combinedSettings); } @@ -289,8 +289,8 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, DWORD flags = 0; if (iUser == -1) { - settings.cbSize=sizeof(settings); - for (int i = 0; i < tempSettings.getCount(); ++i) { + settings.cbSize = sizeof(settings); + for (int i=0; i < tempSettings.getCount(); ++i) { if (tempSettings[i]->flags & NUF_NOOPTIONS) continue; CombineSettingsStructs(&settings, &flags, &tempSettings[i]->settings, tempSettings[i]->flags); } @@ -344,24 +344,24 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, int enableAuth = 0, enableUser = 0, enablePass = 0, enableServer = 1; EnableMultipleControls(hwndDlg, useProxyControls, SIZEOF(useProxyControls), TRUE); if (selectedProxyType == 0) { - for (int i = 0; i < tempSettings.getCount(); ++i) { + for (int i=0; i < tempSettings.getCount(); ++i) { if ( !tempSettings[i]->settings.useProxy || tempSettings[i]->flags & NUF_NOOPTIONS || !(tempSettings[i]->flags & NUF_OUTGOING)) continue; - if (tempSettings[i]->settings.proxyType == PROXYTYPE_SOCKS4) enableUser=1; + if (tempSettings[i]->settings.proxyType == PROXYTYPE_SOCKS4) enableUser = 1; else { enableAuth = 1; if (tempSettings[i]->settings.useProxyAuth) - enableUser=enablePass=1; + enableUser = enablePass = 1; } } } else { - if (selectedProxyType == PROXYTYPE_SOCKS4) enableUser=1; + if (selectedProxyType == PROXYTYPE_SOCKS4) enableUser = 1; else { - if (selectedProxyType == PROXYTYPE_IE) enableServer=0; - enableAuth=1; + if (selectedProxyType == PROXYTYPE_IE) enableServer = 0; + enableAuth = 1; if (IsDlgButtonChecked(hwndDlg, IDC_PROXYAUTH) != BST_UNCHECKED) enableUser = enablePass = 1; } @@ -397,7 +397,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, int newValue = SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROXYTYPE, CB_GETCURSEL, 0, 0), 0); if (iUser == -1) { if (newValue == 0) return 0; - for (int i = 0; i < tempSettings.getCount(); ++i) { + for (int i=0; i < tempSettings.getCount(); ++i) { if (tempSettings[i]->flags & NUF_NOOPTIONS) continue; if (newValue == PROXYTYPE_HTTP && !(tempSettings[i]->flags & (NUF_HTTPCONNS|NUF_HTTPGATEWAY))) tempSettings[i]->settings.proxyType = PROXYTYPE_HTTPS; @@ -444,7 +444,7 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { int newValue = GetDlgItemInt(hwndDlg, LOWORD(wParam), NULL, FALSE); if (iUser == -1) { - for (int i = 0; i < tempSettings.getCount(); ++i) + for (int i=0; i < tempSettings.getCount(); ++i) if ( !(tempSettings[i]->flags & NUF_NOOPTIONS)) tempSettings[i]->settings.wProxyPort = newValue; } @@ -498,13 +498,13 @@ static INT_PTR CALLBACK DlgProcNetlibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, return FALSE; } -static UINT expertOnlyControls[]={IDC_LOGOPTIONS}; +static UINT expertOnlyControls[] = {IDC_LOGOPTIONS}; int NetlibOptInitialise(WPARAM wParam, LPARAM) { int optionsCount = 0; { mir_cslock lck(csNetlibUser); - for (int i = 0; i < netlibUser.getCount(); ++i) + for (int i=0; i < netlibUser.getCount(); ++i) if ( !(netlibUser[i]->user.flags & NUF_NOOPTIONS)) ++optionsCount; } diff --git a/src/modules/netlib/netlibpktrecver.cpp b/src/modules/netlib/netlibpktrecver.cpp index d2b40559b3..4e887b1177 100644 --- a/src/modules/netlib/netlibpktrecver.cpp +++ b/src/modules/netlib/netlibpktrecver.cpp @@ -25,32 +25,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR NetlibPacketRecverCreate(WPARAM wParam, LPARAM lParam) { - struct NetlibConnection *nlc=(struct NetlibConnection*)wParam; + struct NetlibConnection *nlc = (struct NetlibConnection*)wParam; struct NetlibPacketRecver *nlpr; if (GetNetlibHandleType(nlc) != NLH_CONNECTION || lParam == 0) { SetLastError(ERROR_INVALID_PARAMETER); return (INT_PTR)(struct NetlibPacketRecver*)NULL; } - nlpr=(struct NetlibPacketRecver*)mir_calloc(sizeof(struct NetlibPacketRecver)); + nlpr = (struct NetlibPacketRecver*)mir_calloc(sizeof(struct NetlibPacketRecver)); if (nlpr == NULL) { SetLastError(ERROR_OUTOFMEMORY); return (INT_PTR)(struct NetlibPacketRecver*)NULL; } - nlpr->handleType=NLH_PACKETRECVER; - nlpr->nlc=nlc; - nlpr->packetRecver.cbSize=sizeof(nlpr->packetRecver); - nlpr->packetRecver.bufferSize=lParam; - nlpr->packetRecver.buffer=(PBYTE)mir_alloc(nlpr->packetRecver.bufferSize); - nlpr->packetRecver.bytesUsed=0; - nlpr->packetRecver.bytesAvailable=0; + nlpr->handleType = NLH_PACKETRECVER; + nlpr->nlc = nlc; + nlpr->packetRecver.cbSize = sizeof(nlpr->packetRecver); + nlpr->packetRecver.bufferSize = lParam; + nlpr->packetRecver.buffer = (PBYTE)mir_alloc(nlpr->packetRecver.bufferSize); + nlpr->packetRecver.bytesUsed = 0; + nlpr->packetRecver.bytesAvailable = 0; return (INT_PTR)nlpr; } INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) { - struct NetlibPacketRecver *nlpr=(struct NetlibPacketRecver*)wParam; - NETLIBPACKETRECVER *nlprParam=(NETLIBPACKETRECVER*)lParam; + struct NetlibPacketRecver *nlpr = (struct NetlibPacketRecver*)wParam; + NETLIBPACKETRECVER *nlprParam = (NETLIBPACKETRECVER*)lParam; INT_PTR recvResult; if (GetNetlibHandleType(nlpr) != NLH_PACKETRECVER || nlprParam == NULL || nlprParam->cbSize != sizeof(NETLIBPACKETRECVER) || nlprParam->bytesUsed>nlpr->packetRecver.bytesAvailable) { @@ -61,10 +61,10 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) SetLastError(ERROR_TIMEOUT); return SOCKET_ERROR; } - nlpr->packetRecver.dwTimeout=nlprParam->dwTimeout; + nlpr->packetRecver.dwTimeout = nlprParam->dwTimeout; if (nlprParam->bytesUsed == 0) { if (nlpr->packetRecver.bytesAvailable == nlpr->packetRecver.bufferSize) { - nlpr->packetRecver.bytesAvailable=0; + nlpr->packetRecver.bytesAvailable = 0; NetlibLogf(nlpr->nlc->nlu, "Packet recver: packet overflowed buffer, ditching"); } } @@ -74,12 +74,12 @@ INT_PTR NetlibPacketRecverGetMore(WPARAM wParam, LPARAM lParam) } if (nlprParam->dwTimeout != INFINITE) { if ( !si.pending(nlpr->nlc->hSsl) && WaitUntilReadable(nlpr->nlc->s, nlprParam->dwTimeout) <= 0) { - *nlprParam=nlpr->packetRecver; + *nlprParam = nlpr->packetRecver; return SOCKET_ERROR; } } - recvResult=NLRecv(nlpr->nlc, (char*)nlpr->packetRecver.buffer+nlpr->packetRecver.bytesAvailable, nlpr->packetRecver.bufferSize-nlpr->packetRecver.bytesAvailable, 0); + recvResult = NLRecv(nlpr->nlc, (char*)nlpr->packetRecver.buffer+nlpr->packetRecver.bytesAvailable, nlpr->packetRecver.bufferSize-nlpr->packetRecver.bytesAvailable, 0); if (recvResult>0) nlpr->packetRecver.bytesAvailable+=recvResult; - *nlprParam=nlpr->packetRecver; + *nlprParam = nlpr->packetRecver; return recvResult; } diff --git a/src/modules/netlib/netlibsecurity.cpp b/src/modules/netlib/netlibsecurity.cpp index 9ff92944e3..c95b4fd7ab 100644 --- a/src/modules/netlib/netlibsecurity.cpp +++ b/src/modules/netlib/netlibsecurity.cpp @@ -241,12 +241,12 @@ char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chls } unsigned i, ressz = 0; - for (i = 0; i < outBuffersDesc.cBuffers; i++) + for (i=0; i < outBuffersDesc.cBuffers; i++) ressz += outBuffersDesc.pBuffers[i].cbBuffer; unsigned char *response = (unsigned char*)alloca(ressz), *p = response; - for (i = 0; i < outBuffersDesc.cBuffers; i++) + for (i=0; i < outBuffersDesc.cBuffers; i++) { memcpy(p, outBuffersDesc.pBuffers[i].pvBuffer, outBuffersDesc.pBuffers[i].cbBuffer); p += outBuffersDesc.pBuffers[i].cbBuffer; @@ -430,7 +430,7 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, char *szAuth = (char*)alloca(authLen); nlb64.cbDecoded = mir_snprintf(szAuth, authLen, "%s:%s", szLogin, szPassw); - nlb64.pbDecoded=(PBYTE)szAuth; + nlb64.pbDecoded = (PBYTE)szAuth; complete = true; mir_free(szPassw); diff --git a/src/modules/netlib/netlibsock.cpp b/src/modules/netlib/netlibsock.cpp index badc1fe0ca..ac0435564e 100644 --- a/src/modules/netlib/netlibsock.cpp +++ b/src/modules/netlib/netlibsock.cpp @@ -106,7 +106,7 @@ static int ConnectionListToSocketList(HANDLE *hConns, fd_set *fd, int& pending) int i; FD_ZERO(fd); - for (i = 0; hConns[i] && hConns[i] != INVALID_HANDLE_VALUE && i < FD_SETSIZE; i++) + for (i=0; hConns[i] && hConns[i] != INVALID_HANDLE_VALUE && i < FD_SETSIZE; i++) { nlcCheck = (NetlibConnection*)hConns[i]; if (nlcCheck->handleType != NLH_CONNECTION && nlcCheck->handleType != NLH_BOUNDPORT) @@ -131,8 +131,8 @@ INT_PTR NetlibSelect(WPARAM, LPARAM lParam) } TIMEVAL tv; - tv.tv_sec=nls->dwTimeout/1000; - tv.tv_usec=(nls->dwTimeout%1000)*1000; + tv.tv_sec = nls->dwTimeout/1000; + tv.tv_usec = (nls->dwTimeout%1000)*1000; int pending = 0; fd_set readfd, writefd, exceptfd; @@ -305,7 +305,7 @@ static NETLIBIPLIST* GetMyIpv6(unsigned flags) NETLIBIPLIST *addr = (NETLIBIPLIST*)mir_calloc(n * 64 + 4); addr->cbNum = n; - unsigned i = 0; + unsigned i=0; for (ai = air; ai; ai = ai->ai_next) { SOCKADDR_INET_M* iaddr = (SOCKADDR_INET_M*)ai->ai_addr; @@ -336,7 +336,7 @@ static NETLIBIPLIST* GetMyIpv4(void) NETLIBIPLIST *addr = (NETLIBIPLIST*)mir_calloc(n * 64 + 4); addr->cbNum = n; - for (unsigned i = 0; i < n; ++i) + for (unsigned i=0; i < n; ++i) strcpy(addr->szIp[i], inet_ntoa(*(PIN_ADDR)he->h_addr_list[i])); return addr; diff --git a/src/modules/netlib/netlibssl.cpp b/src/modules/netlib/netlibssl.cpp index 77c6bec8c9..a1910f3ca6 100644 --- a/src/modules/netlib/netlibssl.cpp +++ b/src/modules/netlib/netlibssl.cpp @@ -119,7 +119,7 @@ static bool AcquireCredentials(void) ZeroMemory(&SchannelCred, sizeof(SchannelCred)); - SchannelCred.dwVersion = SCHANNEL_CRED_VERSION; + SchannelCred.dwVersion = SCHANNEL_CRED_VERSION; SchannelCred.grbitEnabledProtocols = SP_PROT_SSL3TLS1_CLIENTS /*| 0xA00 TLS1.1 & 1.2*/; SchannelCred.dwFlags |= SCH_CRED_NO_DEFAULT_CREDS | SCH_CRED_MANUAL_CRED_VALIDATION; @@ -235,7 +235,7 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF ChainPara.cbSize = sizeof(ChainPara); ChainPara.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR; - ChainPara.RequestedUsage.Usage.cUsageIdentifier = SIZEOF(rgszUsages); + ChainPara.RequestedUsage.Usage.cUsageIdentifier = SIZEOF(rgszUsages); ChainPara.RequestedUsage.Usage.rgpszUsageIdentifier = rgszUsages; if ( !fnCertGetCertificateChain(NULL, pServerCert, NULL, pServerCert->hCertStore, @@ -245,12 +245,12 @@ static bool VerifyCertificate(SslHandle *ssl, PCSTR pszServerName, DWORD dwCertF goto cleanup; } - polHttps.cbStruct = sizeof(HTTPSPolicyCallbackData); - polHttps.dwAuthType = AUTHTYPE_SERVER; - polHttps.fdwChecks = dwCertFlags; - polHttps.pwszServerName = pwszServerName; + polHttps.cbStruct = sizeof(HTTPSPolicyCallbackData); + polHttps.dwAuthType = AUTHTYPE_SERVER; + polHttps.fdwChecks = dwCertFlags; + polHttps.pwszServerName = pwszServerName; - PolicyPara.cbSize = sizeof(PolicyPara); + PolicyPara.cbSize = sizeof(PolicyPara); PolicyPara.pvExtraPolicyPara = &polHttps; PolicyStatus.cbSize = sizeof(PolicyStatus); @@ -361,29 +361,29 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead) // of this. Leftover data (if any) will be placed in buffer 1 and // given a buffer type of SECBUFFER_EXTRA. - InBuffers[0].pvBuffer = ssl->pbIoBuffer; - InBuffers[0].cbBuffer = ssl->cbIoBuffer; + InBuffers[0].pvBuffer = ssl->pbIoBuffer; + InBuffers[0].cbBuffer = ssl->cbIoBuffer; InBuffers[0].BufferType = SECBUFFER_TOKEN; - InBuffers[1].pvBuffer = NULL; - InBuffers[1].cbBuffer = 0; + InBuffers[1].pvBuffer = NULL; + InBuffers[1].cbBuffer = 0; InBuffers[1].BufferType = SECBUFFER_EMPTY; - InBuffer.cBuffers = 2; - InBuffer.pBuffers = InBuffers; - InBuffer.ulVersion = SECBUFFER_VERSION; + InBuffer.cBuffers = 2; + InBuffer.pBuffers = InBuffers; + InBuffer.ulVersion = SECBUFFER_VERSION; // Set up the output buffers. These are initialized to NULL // so as to make it less likely we'll attempt to free random // garbage later. - OutBuffers[0].pvBuffer = NULL; - OutBuffers[0].BufferType= SECBUFFER_TOKEN; - OutBuffers[0].cbBuffer = 0; + OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].BufferType = SECBUFFER_TOKEN; + OutBuffers[0].cbBuffer = 0; - OutBuffer.cBuffers = 1; - OutBuffer.pBuffers = OutBuffers; - OutBuffer.ulVersion = SECBUFFER_VERSION; + OutBuffer.cBuffers = 1; + OutBuffer.pBuffers = OutBuffers; + OutBuffer.ulVersion = SECBUFFER_VERSION; scRet = g_pSSPI->InitializeSecurityContextA( &hCreds, @@ -509,9 +509,9 @@ static bool ClientConnect(SslHandle *ssl, const char *host) // Initiate a ClientHello message and generate a token. - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = NULL; OutBuffers[0].BufferType = SECBUFFER_TOKEN; - OutBuffers[0].cbBuffer = 0; + OutBuffers[0].cbBuffer = 0; OutBuffer.cBuffers = 1; OutBuffer.pBuffers = OutBuffers; @@ -600,12 +600,12 @@ void NetlibSslShutdown(SslHandle *ssl) dwType = SCHANNEL_SHUTDOWN; - OutBuffers[0].pvBuffer = &dwType; + OutBuffers[0].pvBuffer = &dwType; OutBuffers[0].BufferType = SECBUFFER_TOKEN; - OutBuffers[0].cbBuffer = sizeof(dwType); + OutBuffers[0].cbBuffer = sizeof(dwType); - OutBuffer.cBuffers = 1; - OutBuffer.pBuffers = OutBuffers; + OutBuffer.cBuffers = 1; + OutBuffer.pBuffers = OutBuffers; OutBuffer.ulVersion = SECBUFFER_VERSION; scRet = g_pSSPI->ApplyControlToken(&ssl->hContext, &OutBuffer); @@ -622,12 +622,12 @@ void NetlibSslShutdown(SslHandle *ssl) ISC_REQ_ALLOCATE_MEMORY | ISC_REQ_STREAM; - OutBuffers[0].pvBuffer = NULL; + OutBuffers[0].pvBuffer = NULL; OutBuffers[0].BufferType = SECBUFFER_TOKEN; - OutBuffers[0].cbBuffer = 0; + OutBuffers[0].cbBuffer = 0; - OutBuffer.cBuffers = 1; - OutBuffer.pBuffers = OutBuffers; + OutBuffer.cBuffers = 1; + OutBuffer.pBuffers = OutBuffers; OutBuffer.ulVersion = SECBUFFER_VERSION; scRet = g_pSSPI->InitializeSecurityContextA( @@ -760,17 +760,17 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) } // Attempt to decrypt the received data. - Buffers[0].pvBuffer = ssl->pbIoBuffer; - Buffers[0].cbBuffer = ssl->cbIoBuffer; - Buffers[0].BufferType = SECBUFFER_DATA; + Buffers[0].pvBuffer = ssl->pbIoBuffer; + Buffers[0].cbBuffer = ssl->cbIoBuffer; + Buffers[0].BufferType = SECBUFFER_DATA; - Buffers[1].BufferType = SECBUFFER_EMPTY; - Buffers[2].BufferType = SECBUFFER_EMPTY; - Buffers[3].BufferType = SECBUFFER_EMPTY; + Buffers[1].BufferType = SECBUFFER_EMPTY; + Buffers[2].BufferType = SECBUFFER_EMPTY; + Buffers[3].BufferType = SECBUFFER_EMPTY; - Message.ulVersion = SECBUFFER_VERSION; - Message.cBuffers = 4; - Message.pBuffers = Buffers; + Message.ulVersion = SECBUFFER_VERSION; + Message.cBuffers = 4; + Message.pBuffers = Buffers; if (g_pSSPI->DecryptMessage != NULL && g_pSSPI->DecryptMessage != PVOID(0x80000000)) scRet = g_pSSPI->DecryptMessage(&ssl->hContext, &Message, 0, NULL); @@ -791,7 +791,7 @@ int NetlibSslRead(SslHandle *ssl, char *buf, int num, int peek) } // Locate data and (optional) extra buffers. - pDataBuffer = NULL; + pDataBuffer = NULL; pExtraBuffer = NULL; for (i = 1; i < 4; i++) { @@ -900,23 +900,23 @@ int NetlibSslWrite(SslHandle *ssl, const char *buf, int num) cbMessage = min(Sizes.cbMaximumMessage, (DWORD)num - sendOff); CopyMemory(pbMessage, buf+sendOff, cbMessage); - Buffers[0].pvBuffer = pbDataBuffer; - Buffers[0].cbBuffer = Sizes.cbHeader; - Buffers[0].BufferType = SECBUFFER_STREAM_HEADER; + Buffers[0].pvBuffer = pbDataBuffer; + Buffers[0].cbBuffer = Sizes.cbHeader; + Buffers[0].BufferType = SECBUFFER_STREAM_HEADER; - Buffers[1].pvBuffer = pbMessage; - Buffers[1].cbBuffer = cbMessage; - Buffers[1].BufferType = SECBUFFER_DATA; + Buffers[1].pvBuffer = pbMessage; + Buffers[1].cbBuffer = cbMessage; + Buffers[1].BufferType = SECBUFFER_DATA; - Buffers[2].pvBuffer = pbMessage + cbMessage; - Buffers[2].cbBuffer = Sizes.cbTrailer; - Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER; + Buffers[2].pvBuffer = pbMessage + cbMessage; + Buffers[2].cbBuffer = Sizes.cbTrailer; + Buffers[2].BufferType = SECBUFFER_STREAM_TRAILER; - Buffers[3].BufferType = SECBUFFER_EMPTY; + Buffers[3].BufferType = SECBUFFER_EMPTY; - Message.ulVersion = SECBUFFER_VERSION; - Message.cBuffers = 4; - Message.pBuffers = Buffers; + Message.ulVersion = SECBUFFER_VERSION; + Message.cBuffers = 4; + Message.pBuffers = Buffers; if (g_pSSPI->EncryptMessage != NULL) scRet = g_pSSPI->EncryptMessage(&ssl->hContext, 0, &Message, 0); @@ -953,12 +953,12 @@ static INT_PTR GetSslApi(WPARAM, LPARAM lParam) if (si->cbSize != sizeof(SSL_API)) return FALSE; - si->connect = (HSSL (__cdecl *)(SOCKET, const char *, int))NetlibSslConnect; - si->pending = (BOOL (__cdecl *)(HSSL))NetlibSslPending; - si->read = (int (__cdecl *)(HSSL, char *, int, int))NetlibSslRead; - si->write = (int (__cdecl *)(HSSL, const char *, int))NetlibSslWrite; + si->connect = (HSSL (__cdecl *)(SOCKET, const char *, int))NetlibSslConnect; + si->pending = (BOOL (__cdecl *)(HSSL))NetlibSslPending; + si->read = (int (__cdecl *)(HSSL, char *, int, int))NetlibSslRead; + si->write = (int (__cdecl *)(HSSL, const char *, int))NetlibSslWrite; si->shutdown = (void (__cdecl *)(HSSL))NetlibSslShutdown; - si->sfree = (void (__cdecl *)(HSSL))NetlibSslFree; + si->sfree = (void (__cdecl *)(HSSL))NetlibSslFree; return TRUE; } diff --git a/src/modules/netlib/netlibupnp.cpp b/src/modules/netlib/netlibupnp.cpp index 8bec975111..b75953d280 100644 --- a/src/modules/netlib/netlibupnp.cpp +++ b/src/modules/netlib/netlibupnp.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "..\..\core\commonheaders.h" #include "netlib.h" -static const char search_request_msg[] = +static const char search_request_msg[] = "M-SEARCH * HTTP/1.1\r\n" "HOST: 239.255.255.250:1900\r\n" "MAN: \"ssdp:discover\"\r\n" @@ -31,55 +31,55 @@ static const char search_request_msg[] = "ST: urn:schemas-upnp-org:service:%s\r\n" "\r\n"; -static const char xml_get_hdr[] = +static const char xml_get_hdr[] = "GET %s HTTP/1.1\r\n" "HOST: %s:%u\r\n" "ACCEPT-LANGUAGE: *\r\n\r\n"; -static const char soap_post_hdr[] = +static const char soap_post_hdr[] = "POST %s HTTP/1.1\r\n" "HOST: %s:%u\r\n" "CONTENT-LENGTH: %u\r\n" - "CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n" + "CONTENT-TYPE: text/xml; charset = \"utf-8\"\r\n" "SOAPACTION: \"%s#%s\"\r\n\r\n" "%s"; -static const char soap_post_hdr_m[] = +static const char soap_post_hdr_m[] = "M-POST %s URL HTTP/1.1\r\n" "HOST: %s:%u\r\n" "CONTENT-LENGTH: %u\r\n" - "CONTENT-TYPE: text/xml; charset=\"utf-8\"\r\n" - "MAN: \"http://schemas.xmlsoap.org/soap/envelope/\"; ns=01\r\n" + "CONTENT-TYPE: text/xml; charset = \"utf-8\"\r\n" + "MAN: \"http://schemas.xmlsoap.org/soap/envelope/\"; ns = 01\r\n" "01-SOAPACTION: \"%s#%s\"\r\n\r\n" "%s"; -static const char search_device[] = +static const char search_device[] = "%s"; -static const char soap_action[] = - "\r\n" +static const char soap_action[] = + "\r\n" "\r\n" + " xmlns:s = \"http://schemas.xmlsoap.org/soap/envelope/\"\r\n" + " s:encodingStyle = \"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" " \r\n" - " \r\n" + " \r\n" "%s" " \r\n" " \r\n" "\r\n"; -static const char soap_query[] = +static const char soap_query[] = "\r\n" + " xmlns:s = \"http://schemas.xmlsoap.org/soap/envelope/\"\r\n" + " s:encodingStyle = \"http://schemas.xmlsoap.org/soap/encoding/\">\r\n" " \r\n" - " \r\n" + " \r\n" " %s\r\n" " \r\n" " \r\n" "\r\n"; -static const char add_port_mapping[] = +static const char add_port_mapping[] = " \r\n" " %i\r\n" " %s\r\n" @@ -89,12 +89,12 @@ static const char add_port_mapping[] = " Miranda\r\n" " 0\r\n"; -static const char delete_port_mapping[] = +static const char delete_port_mapping[] = " \r\n" " %i\r\n" " %s\r\n"; -static const char get_port_mapping[] = +static const char get_port_mapping[] = " %i\r\n"; static bool gatewayFound; @@ -249,7 +249,7 @@ static int httpTransact(char* szUrl, char* szResult, int resSize, char* szAction const char* szPostHdr = soap_post_hdr; char* szData = (char*)mir_alloc(4096); - char* szReq = NULL; + char* szReq = NULL; parseURL(szUrl, szHost, &sPort, szPath); @@ -678,7 +678,7 @@ static void discoverUPnP(void) } txtParseParam(buf, NULL, "ST:", "\n", szDev, sizeof(szDev)); - txtParseParam(buf, "max-age", "=", "\n", age, sizeof(age)); + txtParseParam(buf, "max-age", " = ", "\n", age, sizeof(age)); expireTime = atoi(lrtrimp(age)); lrtrim(szDev); @@ -784,7 +784,7 @@ void NetlibUPnPDeletePortMapping(WORD extport, char* proto) mir_snprintf(szData, 4096, delete_port_mapping, extport, proto); httpTransact(szCtlUrl, szData, 4096, "DeletePortMapping", ControlAction); - for (i = 0; i < numports; ++i) + for (i=0; i < numports; ++i) if (portList[i] == extport && --numports > 0) memmove(&portList[i], &portList[i+1], (numports - i) * sizeof(WORD)); @@ -802,7 +802,7 @@ void NetlibUPnPCleanup(void*) { int incoming = 0; mir_cslock lck(csNetlibUser); - for (int i = 0; i < netlibUser.getCount(); ++i) + for (int i=0; i < netlibUser.getCount(); ++i) if (netlibUser[i]->user.flags & NUF_INCOMING) { incoming = 1; break; @@ -851,7 +851,7 @@ void NetlibUPnPCleanup(void*) if (j >= SIZEOF(ports)) break; - for (k=0; krgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; - dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; - dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; + dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; + dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; + dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; cl = GetSysColor(COLOR_HIGHLIGHT); - dat->rgbSelTop.rgbRed = (dat->rgbSelBottom.rgbRed = GetRValue(cl)) * .75; - dat->rgbSelTop.rgbGreen = (dat->rgbSelBottom.rgbGreen = GetGValue(cl)) * .75; - dat->rgbSelTop.rgbBlue = (dat->rgbSelBottom.rgbBlue = GetBValue(cl)) * .75; + dat->rgbSelTop.rgbRed = (dat->rgbSelBottom.rgbRed = GetRValue(cl)) * .75; + dat->rgbSelTop.rgbGreen = (dat->rgbSelBottom.rgbGreen = GetGValue(cl)) * .75; + dat->rgbSelTop.rgbBlue = (dat->rgbSelBottom.rgbBlue = GetBValue(cl)) * .75; - dat->rgbHotTop.rgbRed = (dat->rgbSelTop.rgbRed + 255) / 2; - dat->rgbHotTop.rgbGreen = (dat->rgbSelTop.rgbGreen + 255) / 2; - dat->rgbHotTop.rgbBlue = (dat->rgbSelTop.rgbBlue + 255) / 2; + dat->rgbHotTop.rgbRed = (dat->rgbSelTop.rgbRed + 255) / 2; + dat->rgbHotTop.rgbGreen = (dat->rgbSelTop.rgbGreen + 255) / 2; + dat->rgbHotTop.rgbBlue = (dat->rgbSelTop.rgbBlue + 255) / 2; - dat->rgbHotBottom.rgbRed = (dat->rgbSelBottom.rgbRed + 255) / 2; - dat->rgbHotBottom.rgbGreen = (dat->rgbSelBottom.rgbGreen + 255) / 2; - dat->rgbHotBottom.rgbBlue = (dat->rgbSelBottom.rgbBlue + 255) / 2; + dat->rgbHotBottom.rgbRed = (dat->rgbSelBottom.rgbRed + 255) / 2; + dat->rgbHotBottom.rgbGreen = (dat->rgbSelBottom.rgbGreen + 255) / 2; + dat->rgbHotBottom.rgbBlue = (dat->rgbSelBottom.rgbBlue + 255) / 2; - dat->clBackground = GetSysColor(COLOR_3DFACE); - dat->clText = GetSysColor(COLOR_WINDOWTEXT); - dat->clSelText = GetSysColor(COLOR_HIGHLIGHTTEXT); - dat->clSelBorder = RGB(dat->rgbSelTop.rgbRed, dat->rgbSelTop.rgbGreen, dat->rgbSelTop.rgbBlue); - dat->clHotBorder = RGB(dat->rgbHotTop.rgbRed, dat->rgbHotTop.rgbGreen, dat->rgbHotTop.rgbBlue); + dat->clBackground = GetSysColor(COLOR_3DFACE); + dat->clText = GetSysColor(COLOR_WINDOWTEXT); + dat->clSelText = GetSysColor(COLOR_HIGHLIGHTTEXT); + dat->clSelBorder = RGB(dat->rgbSelTop.rgbRed, dat->rgbSelTop.rgbGreen, dat->rgbSelTop.rgbBlue); + dat->clHotBorder = RGB(dat->rgbHotTop.rgbRed, dat->rgbHotTop.rgbGreen, dat->rgbHotTop.rgbBlue); if ( !dat->hFont) dat->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); } static void MDescButton_FillRect(HDC hdc, int x, int y, int width, int height, COLORREF cl) { - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, cl); + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, cl); RECT rc; SetRect(&rc, x, y, x+width, y+height); ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, 0); @@ -124,11 +124,11 @@ static void MDescButton_FillRect(HDC hdc, int x, int y, int width, int height, C static void MDescButton_DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1) { - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, 0); + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, 0); RECT rc; SetRect(&rc, x, 0, x+width, 0); - for (int i=y+height; --i >= y;) { + for (int i = y+height; --i >= y;) { COLORREF color = RGB( ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, ((height-i-1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height, @@ -150,17 +150,17 @@ static LRESULT MDescButton_OnPaint(HWND hwndDlg, MDescButtonCtrl *dat, UINT msg RECT temprc; HFONT hfntSave; - HDC hdc=BeginPaint(hwndDlg, &ps); - HDC tempDC=CreateCompatibleDC(hdc); + HDC hdc = BeginPaint(hwndDlg, &ps); + HDC tempDC = CreateCompatibleDC(hdc); SIZE titleSize = {0}; - hBmp=CreateCompatibleBitmap(hdc, dat->width, dat->height); - hOldBmp=(HBITMAP)SelectObject(tempDC, hBmp); + hBmp = CreateCompatibleBitmap(hdc, dat->width, dat->height); + hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp); - temprc.left=0; - temprc.right=dat->width; - temprc.top=0; + temprc.left = 0; + temprc.right = dat->width; + temprc.top = 0; //Draw background if (dat->bMouseInside || (GetFocus() == hwndDlg)) { @@ -223,7 +223,7 @@ static LRESULT MDescButton_OnPaint(HWND hwndDlg, MDescButtonCtrl *dat, UINT msg static LRESULT CALLBACK MDescButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - MDescButtonCtrl *dat = (MDescButtonCtrl *)GetWindowLongPtr(hwndDlg, 0); + MDescButtonCtrl *dat = (MDescButtonCtrl *)GetWindowLongPtr(hwndDlg, 0); switch(msg) { case WM_NCCREATE: dat = (MDescButtonCtrl*)mir_alloc(sizeof(MDescButtonCtrl)); @@ -241,8 +241,8 @@ static LRESULT CALLBACK MDescButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wPara case WM_SIZE: GetClientRect(hwndDlg, &dat->rc); - dat->width=dat->rc.right-dat->rc.left; - dat->height=dat->rc.bottom-dat->rc.top; + dat->width = dat->rc.right-dat->rc.left; + dat->height = dat->rc.bottom-dat->rc.top; return TRUE; case WM_THEMECHANGED: diff --git a/src/modules/options/filter.cpp b/src/modules/options/filter.cpp index 8b72f4e67d..4a332b2259 100644 --- a/src/modules/options/filter.cpp +++ b/src/modules/options/filter.cpp @@ -94,7 +94,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) if (lstrcmpi(szClass, _T("listbox")) == 0) { if (GetWindowStyle(hWndDlg) & LBS_HASSTRINGS) { int count = ListBox_GetCount(hWndDlg); - for (int i = 0; i < count; i++) { + for (int i=0; i < count; i++) { title[0] = 0; //safety int res = ListBox_GetText(hWndDlg, i, title); if (res != LB_ERR) { @@ -106,7 +106,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) else { if (lstrcmpi(szClass, _T("SysListView32")) == 0) { int count = ListView_GetItemCount(hWndDlg); - for (int i = 0; i < count; i++) { + for (int i=0; i < count; i++) { title[0] = 0; //safety ListView_GetItemText(hWndDlg, i, 0, title, SIZEOF(title)); @@ -117,7 +117,7 @@ void AddDialogString(HWND hWndDlg, const PageHash key) if (lstrcmpi(szClass, _T("combobox")) == 0) { if (GetWindowStyle(hWndDlg) & CBS_HASSTRINGS) { int count = ComboBox_GetCount(hWndDlg); - for (int i = 0; i < count; i++) { + for (int i=0; i < count; i++) { title[0] = 0; //safety int res = ComboBox_GetLBText(hWndDlg, i, title); if (res != CB_ERR) { @@ -134,7 +134,7 @@ static BOOL CALLBACK GetDialogStringsCallback(HWND hWnd, LPARAM lParam) return TRUE; } -void GetDialogStrings(int enableKeywordFiltering, const PageHash key, TCHAR *pluginName, HWND hWnd, TCHAR * group, TCHAR * title, TCHAR * tab, TCHAR * name) +void GetDialogStrings(int enableKeywordFiltering, const PageHash key, TCHAR *pluginName, HWND hWnd, TCHAR *group, TCHAR *title, TCHAR *tab, TCHAR *name) { AddFilterString(key, pluginName); //add the plugin name as keyword if (group) AddFilterString(key, group); diff --git a/src/modules/options/filter.h b/src/modules/options/filter.h index 6bf38d17d5..39c16698f2 100644 --- a/src/modules/options/filter.h +++ b/src/modules/options/filter.h @@ -34,9 +34,9 @@ typedef DWORD PageHash; void AddFilterString(const PageHash key, const TCHAR *data); BOOL ContainsFilterString(const PageHash key, TCHAR *data); void ClearFilterStrings(); -void GetDialogStrings(int enableKeywordFiltering, const PageHash key, TCHAR *pluginName, HWND hWnd, TCHAR * group, TCHAR * title, TCHAR * tab, TCHAR * name); +void GetDialogStrings(int enableKeywordFiltering, const PageHash key, TCHAR *pluginName, HWND hWnd, TCHAR *group, TCHAR *title, TCHAR *tab, TCHAR *name); -_inline TCHAR * _tcslwr_locale(TCHAR * buf) +_inline TCHAR *_tcslwr_locale(TCHAR *buf) { LCMapString(Langpack_GetDefaultLocale() , LCMAP_LOWERCASE, buf, (int)_tcslen(buf), buf, (int)_tcslen(buf)); return buf; @@ -55,24 +55,24 @@ public: { for (int j = 0; j < _pageKeyWords.getCount(); j++) { - TCHAR * data = _pageKeyWords[j]; + TCHAR *data = _pageKeyWords[j]; mir_free(data); } _pageKeyWords.destroy(); }; - void AddKeyWord(TCHAR * ptKeyWord) + void AddKeyWord(TCHAR *ptKeyWord) { - TCHAR * plwrWord = _tcslwr_locale(mir_tstrdup(ptKeyWord)); + TCHAR *plwrWord = _tcslwr_locale(mir_tstrdup(ptKeyWord)); if (_pageKeyWords.getIndex(plwrWord) == -1) _pageKeyWords.insert(plwrWord); else mir_free(plwrWord); }; - BOOL ContainsString(TCHAR * data) + BOOL ContainsString(TCHAR *data) { - for (int i = 0; i < _pageKeyWords.getCount(); i++) + for (int i=0; i < _pageKeyWords.getCount(); i++) if (_tcsstr(_pageKeyWords[i], data)) return TRUE; return FALSE; diff --git a/src/modules/options/headerbar.cpp b/src/modules/options/headerbar.cpp index 44a729089d..ad06f75f98 100644 --- a/src/modules/options/headerbar.cpp +++ b/src/modules/options/headerbar.cpp @@ -81,13 +81,13 @@ int LoadHeaderbarModule() WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); - wc.cbSize = sizeof(wc); - wc.lpszClassName = _T("MHeaderbarCtrl"); //MIRANDAHEADERBARCLASS; - wc.lpfnWndProc = MHeaderbarWndProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(MHeaderbarCtrl*); - wc.hbrBackground = 0; //GetStockObject(WHITE_BRUSH); - wc.style = CS_GLOBALCLASS|CS_SAVEBITS; + wc.cbSize = sizeof(wc); + wc.lpszClassName = _T("MHeaderbarCtrl"); //MIRANDAHEADERBARCLASS; + wc.lpfnWndProc = MHeaderbarWndProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(MHeaderbarCtrl*); + wc.hbrBackground = 0; //GetStockObject(WHITE_BRUSH); + wc.style = CS_GLOBALCLASS|CS_SAVEBITS; RegisterClassEx(&wc); return 0; } @@ -97,19 +97,19 @@ static void MHeaderbar_SetupColors(MHeaderbarCtrl *dat) COLORREF cl; cl = GetSysColor(COLOR_WINDOW); - dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; - dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; - dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; + dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; + dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; + dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; - dat->clText = GetSysColor(COLOR_WINDOWTEXT); + dat->clText = GetSysColor(COLOR_WINDOWTEXT); if ( !dat->hFont) dat->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); } static void MHeaderbar_FillRect(HDC hdc, int x, int y, int width, int height, COLORREF cl) { - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, cl); + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, cl); RECT rc; SetRect(&rc, x, y, x+width, y+height); ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, 0); @@ -122,11 +122,11 @@ static void MHeaderbar_DrawGradient(HDC hdc, int x, int y, int width, int height { int i; - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, 0); + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, 0); RECT rc; SetRect(&rc, x, 0, x+width, 0); - for (i=y+height; --i >= y;) + for (i = y+height; --i >= y;) { COLORREF color = RGB( ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, @@ -153,10 +153,10 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, GetWindowText(hwndDlg, szTitle, titleLength); TCHAR *szSubTitle = _tcschr(szTitle, _T('\n')); - if (szSubTitle) *szSubTitle++ = 0; + if (szSubTitle) *szSubTitle++=0; - HDC hdc=BeginPaint(hwndDlg, &ps); - HDC tempDC=CreateCompatibleDC(hdc); + HDC hdc = BeginPaint(hwndDlg, &ps); + HDC tempDC = CreateCompatibleDC(hdc); BITMAPINFO bmi; bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -167,14 +167,14 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, bmi.bmiHeader.biCompression = BI_RGB; hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, NULL, NULL, 0); - hOldBmp=(HBITMAP)SelectObject(tempDC, hBmp); + hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp); if (IsAeroMode()) { RECT temprc; - temprc.left=0; - temprc.right=mit->width; - temprc.top=0; - temprc.bottom=mit->width; + temprc.left = 0; + temprc.right = mit->width; + temprc.top = 0; + temprc.bottom = mit->width; FillRect(tempDC, &temprc, (HBRUSH)GetStockObject(BLACK_BRUSH)); MARGINS margins = {0, 0, mit->height, 0}; @@ -213,10 +213,10 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, } RECT textRect; - textRect.left=50; - textRect.right=mit->width; - textRect.top=2 + iTopSpace; - textRect.bottom=GetSystemMetrics(SM_CYICON)-2 + iTopSpace; + textRect.left = 50; + textRect.right = mit->width; + textRect.top = 2 + iTopSpace; + textRect.bottom = GetSystemMetrics(SM_CYICON)-2 + iTopSpace; if (IsAeroMode()) { DTTOPTS dto = {0}; @@ -225,7 +225,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, dto.iGlowSize = 10; HANDLE hTheme = openThemeData(hwndDlg, L"Window"); - textRect.left=50; + textRect.left = 50; SelectObject(tempDC, hFntBold); wchar_t *szTitleW = mir_t2u(szTitle); @@ -233,7 +233,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, mir_free(szTitleW); if (szSubTitle) { - textRect.left=66; + textRect.left = 66; SelectObject(tempDC, hFont); wchar_t *szSubTitleW = mir_t2u(szSubTitle); @@ -243,12 +243,12 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, closeThemeData(hTheme); } else { - textRect.left=50; + textRect.left = 50; SelectObject(tempDC, hFntBold); DrawText(tempDC, szTitle, -1, &textRect, DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS); if (szSubTitle) { - textRect.left=66; + textRect.left = 66; SelectObject(tempDC, hFont); DrawText(tempDC, szSubTitle, -1, &textRect, DT_BOTTOM|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX|DT_NOCLIP|DT_END_ELLIPSIS); } } @@ -261,13 +261,13 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, if (mit->nControlsToRedraw) { RECT temprc; - temprc.left=0; - temprc.right=mit->width; - temprc.top=0; - temprc.bottom=mit->width; + temprc.left = 0; + temprc.right = mit->width; + temprc.top = 0; + temprc.bottom = mit->width; HRGN hRgn = CreateRectRgnIndirect(&temprc); - for (int i = 0; i < mit->nControlsToRedraw; ++i) + for (int i=0; i < mit->nControlsToRedraw; ++i) { GetWindowRect(mit->controlsToRedraw[i], &temprc); MapWindowPoints(NULL, hwndDlg, (LPPOINT)&temprc, 2); @@ -294,7 +294,7 @@ static LRESULT MHeaderbar_OnPaint(HWND hwndDlg, MHeaderbarCtrl *mit, UINT msg, static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - MHeaderbarCtrl* itc = (MHeaderbarCtrl *)GetWindowLongPtr(hwndDlg, 0); + MHeaderbarCtrl* itc = (MHeaderbarCtrl *)GetWindowLongPtr(hwndDlg, 0); switch(msg) { case WM_NCCREATE: itc = new MHeaderbarCtrl; //(MHeaderbarCtrl*)mir_alloc(sizeof(MHeaderbarCtrl)); @@ -333,8 +333,8 @@ static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam case WM_SIZE: GetClientRect(hwndDlg, &itc->rc); - itc->width=itc->rc.right-itc->rc.left; - itc->height=itc->rc.bottom-itc->rc.top; + itc->width = itc->rc.right-itc->rc.left; + itc->height = itc->rc.bottom-itc->rc.top; return TRUE; case WM_THEMECHANGED: diff --git a/src/modules/options/iconheader.cpp b/src/modules/options/iconheader.cpp index e3f27c8289..afaf893d04 100644 --- a/src/modules/options/iconheader.cpp +++ b/src/modules/options/iconheader.cpp @@ -91,7 +91,7 @@ typedef void (*ItemDestuctor)(void*); static void MITListDestructor(void * adr) { - MIcoTab * mit=(MIcoTab *)adr; + MIcoTab * mit = (MIcoTab *)adr; mir_free(mit->tcsName); if (mit->hIcon && !(mit->flag&MITCF_SHAREDICON)) DestroyIcon(mit->hIcon); @@ -109,14 +109,14 @@ int LoadIcoTabsModule() WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); - wc.cbSize = sizeof(wc); - wc.lpszClassName = MIRANDAICOTABCLASS; - wc.lpfnWndProc = MIcoTabWndProc; -// wc.hCursor = LoadCursor(NULL, IDC_HAND); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.cbWndExtra = sizeof(MIcoTabCtrl*); - wc.hbrBackground = 0; //GetStockObject(WHITE_BRUSH); - wc.style = CS_GLOBALCLASS/*|CS_SAVEBITS*/; + wc.cbSize = sizeof(wc); + wc.lpszClassName = MIRANDAICOTABCLASS; + wc.lpfnWndProc = MIcoTabWndProc; +// wc.hCursor = LoadCursor(NULL, IDC_HAND); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.cbWndExtra = sizeof(MIcoTabCtrl*); + wc.hbrBackground = 0; //GetStockObject(WHITE_BRUSH); + wc.style = CS_GLOBALCLASS/*|CS_SAVEBITS*/; RegisterClassEx(&wc); return 0; } @@ -126,35 +126,35 @@ static void MIcoTab_SetupColors(MIcoTabCtrl *dat) COLORREF cl; cl = GetSysColor(COLOR_WINDOW); - dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; - dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; - dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; + dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; + dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; + dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; cl = GetSysColor(COLOR_HIGHLIGHT); - dat->rgbSelTop.rgbRed = (dat->rgbSelBottom.rgbRed = GetRValue(cl)) * .75; - dat->rgbSelTop.rgbGreen = (dat->rgbSelBottom.rgbGreen = GetGValue(cl)) * .75; - dat->rgbSelTop.rgbBlue = (dat->rgbSelBottom.rgbBlue = GetBValue(cl)) * .75; + dat->rgbSelTop.rgbRed = (dat->rgbSelBottom.rgbRed = GetRValue(cl)) * .75; + dat->rgbSelTop.rgbGreen = (dat->rgbSelBottom.rgbGreen = GetGValue(cl)) * .75; + dat->rgbSelTop.rgbBlue = (dat->rgbSelBottom.rgbBlue = GetBValue(cl)) * .75; - dat->rgbHotTop.rgbRed = (dat->rgbSelTop.rgbRed + 255) / 2; - dat->rgbHotTop.rgbGreen = (dat->rgbSelTop.rgbGreen + 255) / 2; - dat->rgbHotTop.rgbBlue = (dat->rgbSelTop.rgbBlue + 255) / 2; + dat->rgbHotTop.rgbRed = (dat->rgbSelTop.rgbRed + 255) / 2; + dat->rgbHotTop.rgbGreen = (dat->rgbSelTop.rgbGreen + 255) / 2; + dat->rgbHotTop.rgbBlue = (dat->rgbSelTop.rgbBlue + 255) / 2; - dat->rgbHotBottom.rgbRed = (dat->rgbSelBottom.rgbRed + 255) / 2; - dat->rgbHotBottom.rgbGreen = (dat->rgbSelBottom.rgbGreen + 255) / 2; - dat->rgbHotBottom.rgbBlue = (dat->rgbSelBottom.rgbBlue + 255) / 2; + dat->rgbHotBottom.rgbRed = (dat->rgbSelBottom.rgbRed + 255) / 2; + dat->rgbHotBottom.rgbGreen = (dat->rgbSelBottom.rgbGreen + 255) / 2; + dat->rgbHotBottom.rgbBlue = (dat->rgbSelBottom.rgbBlue + 255) / 2; - dat->clText = GetSysColor(COLOR_WINDOWTEXT); - dat->clSelText = GetSysColor(COLOR_HIGHLIGHTTEXT); - dat->clSelBorder = RGB(dat->rgbSelTop.rgbRed, dat->rgbSelTop.rgbGreen, dat->rgbSelTop.rgbBlue); - dat->clHotBorder = RGB(dat->rgbHotTop.rgbRed, dat->rgbHotTop.rgbGreen, dat->rgbHotTop.rgbBlue); + dat->clText = GetSysColor(COLOR_WINDOWTEXT); + dat->clSelText = GetSysColor(COLOR_HIGHLIGHTTEXT); + dat->clSelBorder = RGB(dat->rgbSelTop.rgbRed, dat->rgbSelTop.rgbGreen, dat->rgbSelTop.rgbBlue); + dat->clHotBorder = RGB(dat->rgbHotTop.rgbRed, dat->rgbHotTop.rgbGreen, dat->rgbHotTop.rgbBlue); if ( !dat->hFont) dat->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); } static void MIcoTab_FillRect(HDC hdc, int x, int y, int width, int height, COLORREF cl) { - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, cl); + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, cl); RECT rc; SetRect(&rc, x, y, x+width, y+height); ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, 0); @@ -165,11 +165,11 @@ static void MIcoTab_FillRect(HDC hdc, int x, int y, int width, int height, COLOR static void MIcoTab_DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1) { - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, 0); + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, 0); RECT rc; SetRect(&rc, x, 0, x+width, 0); - for (int i=y+height; --i >= y;) { + for (int i = y+height; --i >= y;) { COLORREF color = RGB( ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, ((height-i-1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height, @@ -187,9 +187,9 @@ static void MIcoTab_DrawGradient(HDC hdc, int x, int y, int width, int height, R static void MIcoTab_DrawItem(HWND hwnd, HDC hdc, MIcoTabCtrl *dat, MIcoTab *tab, int i) { int iTopSpace = IsAeroMode() ? 0 : ITC_BORDER_SIZE; - int itemX = ITC_BORDER_SIZE + dat->itemWidth * i; - int iconTop = iTopSpace + 5; - int textTop = iconTop + 32 + 3; + int itemX = ITC_BORDER_SIZE + dat->itemWidth * i; + int iconTop = iTopSpace + 5; + int textTop = iconTop + 32 + 3; HFONT hFntSave = NULL; @@ -240,10 +240,10 @@ static void MIcoTab_DrawItem(HWND hwnd, HDC hdc, MIcoTabCtrl *dat, MIcoTab *tab, else SetTextColor(hdc, dat->clText); RECT textRect; - textRect.left=itemX; - textRect.right=itemX+dat->itemWidth; - textRect.top=textTop; - textRect.bottom=iconTop+dat->itemHeight; + textRect.left = itemX; + textRect.right = itemX+dat->itemWidth; + textRect.top = textTop; + textRect.bottom = iconTop+dat->itemHeight; DrawIcon(hdc, itemX+dat->itemWidth/2-16, iconTop, tab->hIcon); if (IsVSMode()) { @@ -270,8 +270,8 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM RECT temprc; int i; - HDC hdc=BeginPaint(hwndDlg, &ps); - HDC tempDC=CreateCompatibleDC(hdc); + HDC hdc = BeginPaint(hwndDlg, &ps); + HDC tempDC = CreateCompatibleDC(hdc); HFONT hFont = 0; @@ -284,13 +284,13 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM bmi.bmiHeader.biCompression = BI_RGB; hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, NULL, NULL, 0); - hOldBmp=(HBITMAP)SelectObject(tempDC, hBmp); + hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp); if (IsAeroMode()) { - temprc.left=0; - temprc.right=mit->width; - temprc.top=0; - temprc.bottom=mit->width; + temprc.left = 0; + temprc.right = mit->width; + temprc.top = 0; + temprc.bottom = mit->width; FillRect(tempDC, &temprc, (HBRUSH)GetStockObject(BLACK_BRUSH)); } else { @@ -329,13 +329,13 @@ static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit, UINT msg, WPARAM static LRESULT CALLBACK MIcoTabWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - MIcoTabCtrl* itc = (MIcoTabCtrl *)GetWindowLongPtr(hwndDlg, 0); + MIcoTabCtrl* itc = (MIcoTabCtrl *)GetWindowLongPtr(hwndDlg, 0); switch(msg) { case WM_NCCREATE: itc = new MIcoTabCtrl; //(MIcoTabCtrl*)mir_alloc(sizeof(MIcoTabCtrl)); if (itc == NULL) return FALSE; - itc->nSelectedIdx=-1; - itc->nHotIdx=-1; + itc->nSelectedIdx = -1; + itc->nHotIdx = -1; itc->bMouseInside = FALSE; SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)itc); MIcoTab_SetupColors(itc); @@ -354,12 +354,12 @@ static LRESULT CALLBACK MIcoTabWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_SIZE: GetClientRect(hwndDlg, &itc->rc); - itc->width=itc->rc.right-itc->rc.left; - itc->height=itc->rc.bottom-itc->rc.top; + itc->width = itc->rc.right-itc->rc.left; + itc->height = itc->rc.bottom-itc->rc.top; if (itc->pList.getCount()) { - itc->itemWidth=(itc->width-2*ITC_BORDER_SIZE)/itc->pList.getCount(); - itc->itemHeight=itc->height-2*ITC_BORDER_SIZE-2; + itc->itemWidth = (itc->width-2*ITC_BORDER_SIZE)/itc->pList.getCount(); + itc->itemHeight = itc->height-2*ITC_BORDER_SIZE-2; } else itc->itemWidth = itc->itemHeight = 0; return TRUE; @@ -473,41 +473,41 @@ static LRESULT CALLBACK MIcoTabWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L break; case ITCM_SETBACKGROUND: - itc->hBkgBmp=(HBITMAP)lParam; + itc->hBkgBmp = (HBITMAP)lParam; if ( !itc->hBkgDC) itc->hBkgDC = CreateCompatibleDC(NULL); itc->hBkgOldBmp = (HBITMAP)SelectObject(itc->hBkgDC, itc->hBkgBmp); { BITMAPINFO bmp; GetObject(itc->hBkgBmp, sizeof(bmp), &bmp); - itc->BkgSize.cx=bmp.bmiHeader.biWidth; - itc->BkgSize.cy=bmp.bmiHeader.biHeight; + itc->BkgSize.cx = bmp.bmiHeader.biWidth; + itc->BkgSize.cy = bmp.bmiHeader.biHeight; } return TRUE; case ITCM_ADDITEM: { - MIcoTab* pMit=(MIcoTab *)wParam; + MIcoTab* pMit = (MIcoTab *)wParam; if ( !pMit) return FALSE; - MIcoTab* pListMit=(MIcoTab *)mir_calloc(sizeof(MIcoTab)); - pListMit->flag=pMit->flag; - pListMit->data=pMit->data; + MIcoTab* pListMit = (MIcoTab *)mir_calloc(sizeof(MIcoTab)); + pListMit->flag = pMit->flag; + pListMit->data = pMit->data; if (pMit->flag & MITCF_UNICODE) - pListMit->tcsName=mir_u2t(pMit->lpwzName); + pListMit->tcsName = mir_u2t(pMit->lpwzName); else - pListMit->tcsName=mir_a2t(pMit->lpzName); + pListMit->tcsName = mir_a2t(pMit->lpzName); if (pMit->hIcon) { if (pListMit->flag&MITCF_SHAREDICON) - pListMit->hIcon=pMit->hIcon; + pListMit->hIcon = pMit->hIcon; else - pListMit->hIcon=CopyIcon(pMit->hIcon); + pListMit->hIcon = CopyIcon(pMit->hIcon); } itc->pList.insert(pListMit); - itc->itemWidth=(itc->width-2*ITC_BORDER_SIZE)/itc->pList.getCount(); - itc->itemHeight=itc->height-2*ITC_BORDER_SIZE-2; + itc->itemWidth = (itc->width-2*ITC_BORDER_SIZE)/itc->pList.getCount(); + itc->itemHeight = itc->height-2*ITC_BORDER_SIZE-2; RedrawWindow(hwndDlg, NULL, NULL, RDW_INVALIDATE); return TRUE; diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp index e049105253..4a4f79688b 100644 --- a/src/modules/options/options.cpp +++ b/src/modules/options/options.cpp @@ -254,7 +254,7 @@ static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWnd DWORD key = GetPluginPageHash(page); //get the plugin page hash - TCHAR * PluginFullName = NULL; + TCHAR *PluginFullName = NULL; char * temp = GetPluginNameByInstance(page->hInst); if (temp) PluginFullName = mir_a2t(temp); GetDialogStrings(enableKeywordFiltering, key, GetPluginName(page->hInst, pluginName, SIZEOF(pluginName)), hWnd, page->ptszGroup, page->ptszTitle, page->ptszTab, PluginFullName); @@ -309,10 +309,10 @@ static LRESULT CALLBACK OptionsFilterSubclassProc(HWND hWnd, UINT message, WPARA RECT rc2; getThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &rc, &rc2); - rc2.top = 2 * rc.top - rc2.top; - rc2.left = 2 * rc.left - rc2.left; + rc2.top = 2 * rc.top - rc2.top; + rc2.left = 2 * rc.left - rc2.left; rc2.bottom = 2 * rc.bottom - rc2.bottom; - rc2.right = 2 * rc.right - rc2.right; + rc2.right = 2 * rc.right - rc2.right; drawThemeBackground(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &rc2, &rc); HFONT hFont = (HFONT) SendMessage(hWnd, WM_GETFONT, 0, 0); @@ -365,7 +365,7 @@ static BOOL IsAeroMode() static void FreeOptionsData(OptionsPageInit* popi) { - for (int i = 0; i < popi->pageCount; i++) { + for (int i=0; i < popi->pageCount; i++) { mir_free((char*)popi->odp[i].pszTitle); mir_free(popi->odp[i].pszGroup); mir_free(popi->odp[i].pszTab); @@ -412,7 +412,7 @@ static void AeroPaintControl(HWND hwnd, HDC hdc, WNDPROC OldWndProc, UINT msg = // Fix alpha channel GdiFlush(); - for (int i = 0; i < rc.right*rc.bottom; ++i, pBits += 4) + for (int i=0; i < rc.right*rc.bottom; ++i, pBits += 4) if ( !pBits[3]) pBits[3] = 255; //Copy to output @@ -499,8 +499,8 @@ static void FillFilterCombo(int enableKeywordFiltering, HWND hDlg, OptionsDlgDat index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, (WPARAM)0, (LPARAM)TranslateTS(CORE_MODULES_FILTER)); SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)hInst); TCHAR* tszModuleName = (TCHAR*)alloca(MAX_PATH*sizeof(TCHAR)); - for (int i = 0; i < dat->arOpd.getCount(); i++) { - TCHAR * dllName = NULL; + for (int i=0; i < dat->arOpd.getCount(); i++) { + TCHAR *dllName = NULL; int j; HINSTANCE inst = dat->arOpd[i]->hInst; @@ -736,7 +736,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L else lastTab = Langpack_PcharToTchar(ood->pszTab); OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp; - for (size_t i = 0; i < psh->nPages; i++, odp++) { + for (size_t i=0; i < psh->nPages; i++, odp++) { OptionsPageData* opd = (OptionsPageData*)mir_calloc(sizeof(OptionsPageData)); if ( !LoadOptionsPage(odp, opd)) { mir_free(opd); @@ -832,7 +832,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L tvis.hInsertAfter = TVI_SORT; tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED; - for (int i = 0; i < dat->arOpd.getCount(); i++) { + for (int i=0; i < dat->arOpd.getCount(); i++) { static TCHAR *fullTitle = NULL; mir_free(fullTitle); fullTitle = NULL; if ( !CheckPageShow(hdlg, dat, i)) @@ -841,7 +841,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L OptionsPageData* opd = dat->arOpd[i]; TCHAR* ptszGroup = TranslateTH(opd->hLangpack, opd->ptszGroup); TCHAR* ptszTitle = TranslateTH(opd->hLangpack, opd->ptszTitle); - TCHAR* ptszTab = TranslateTH(opd->hLangpack, opd->ptszTab); + TCHAR* ptszTab = TranslateTH(opd->hLangpack, opd->ptszTab); tvis.hParent = NULL; if (FilterInst != NULL) { @@ -1051,7 +1051,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L h = p->expertHeight; } else { - for (int i = 0; i < p->nExpertOnlyControls; i++) + for (int i=0; i < p->nExpertOnlyControls; i++) ShowWindow(GetDlgItem(p->hwnd, p->expertOnlyControls[i]), SW_HIDE); w = p->simpleWidth; h = p->simpleHeight; @@ -1081,7 +1081,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L TCITEM tie; tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tie.iImage = -1; - for (int i = 0; i < dat->arOpd.getCount(); i++) { + for (int i=0; i < dat->arOpd.getCount(); i++) { if ( !CheckPageShow(hdlg, dat, i)) continue; @@ -1124,13 +1124,13 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L parentPageRect = &dat->rcTab; pageHeight = min(pageHeight, parentPageRect->bottom - parentPageRect->top); - pageWidth = min(pageWidth, parentPageRect->right - parentPageRect->left); + pageWidth = min(pageWidth, parentPageRect->right - parentPageRect->left); int newOffsetX = (parentPageRect->right - parentPageRect->left - pageWidth) >> 1; int newOffsetY = p->insideTab ? 0 : (parentPageRect->bottom - parentPageRect->top - pageHeight) >> 1; struct MoveChildParam mcp; - mcp.hDlg = p->hwnd; + mcp.hDlg = p->hwnd; mcp.offset.x = newOffsetX - p->offsetX; mcp.offset.y = newOffsetY - p->offsetY; @@ -1194,7 +1194,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L pshn.lParam = expert; pshn.hdr.code = PSN_EXPERTCHANGED; - for (int i = 0; i arOpd.getCount(); i++) { + for (int i=0; i arOpd.getCount(); i++) { OptionsPageData *opd = dat->arOpd[i]; if (opd->hwnd == NULL) continue; if ( !CheckPageShow(hdlg, dat, i)) continue; @@ -1273,7 +1273,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L pshn.hdr.idFrom = 0; pshn.lParam = 0; pshn.hdr.code = PSN_RESET; - for (int i = 0;iarOpd.getCount();i++) { + for (int i=0;iarOpd.getCount();i++) { if (dat->arOpd[i]->hwnd == NULL || !dat->arOpd[i]->changed) continue; pshn.hdr.hwndFrom = dat->arOpd[i]->hwnd; @@ -1302,7 +1302,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L } pshn.hdr.code = PSN_APPLY; - for (int i = 0;iarOpd.getCount();i++) { + for (int i=0;iarOpd.getCount();i++) { if (dat->arOpd[i]->hwnd == NULL || !dat->arOpd[i]->changed) continue; dat->arOpd[i]->changed = 0; pshn.hdr.hwndFrom = dat->arOpd[i]->hwnd; @@ -1351,7 +1351,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L } Utils_SaveWindowPosition(hdlg, NULL, "Options", ""); { - for (int i = 0; i < dat->arOpd.getCount(); i++) + for (int i=0; i < dat->arOpd.getCount(); i++) FreeOptionsPageData(dat->arOpd[i]); } diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 237d2140b3..a07f371e42 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -37,7 +37,7 @@ struct PluginUUIDList { MUUID uuid; DWORD maxVersion; } -static const pluginBannedList[] = +static const pluginBannedList[] = { {{0x7f65393b, 0x7771, 0x4f3f, { 0xa9, 0xeb, 0x5d, 0xba, 0xf2, 0xb3, 0x61, 0xf1 }}, MAX_MIR_VER}, // png2dib {{0xe00f1643, 0x263c, 0x4599, { 0xb8, 0x4b, 0x05, 0x3e, 0x5c, 0x51, 0x1d, 0x28 }}, MAX_MIR_VER}, // loadavatars (unicode) @@ -46,22 +46,22 @@ static const pluginBannedList[] = MuuidReplacement pluginDefault[] = { - { MIID_UIUSERINFO, NULL }, // 0 - { MIID_SRURL, NULL }, // 1 - { MIID_SREMAIL, NULL }, // 2 - { MIID_SRAUTH, NULL }, // 3 - { MIID_SRFILE, NULL }, // 4 - { MIID_UIHELP, NULL }, // 5 - { MIID_UIHISTORY, NULL }, // 6 - { MIID_IDLE, NULL }, // 7 - { MIID_AUTOAWAY, NULL }, // 8 - { MIID_USERONLINE, NULL }, // 9 - { MIID_UPDATENOTIFY, NULL }, // 10 - - { MIID_CLIST, NULL }, // 11 - { MIID_CHAT, NULL }, // 12 - { MIID_SRMM, NULL }, // 13 - { MIID_DATABASE, NULL }, // 14 + { MIID_UIUSERINFO, _T("stduserinfo"), NULL }, // 0 + { MIID_SRURL, _T("stdurl"), NULL }, // 1 + { MIID_SREMAIL, _T("stdemail"), NULL }, // 2 + { MIID_SRAUTH, _T("stdauth"), NULL }, // 3 + { MIID_SRFILE, _T("stdfile"), NULL }, // 4 + { MIID_UIHELP, _T("stdhelp"), NULL }, // 5 + { MIID_UIHISTORY, _T("stduihist"), NULL }, // 6 + { MIID_IDLE, _T("stdidle"), NULL }, // 7 + { MIID_AUTOAWAY, _T("stdautoaway"), NULL }, // 8 + { MIID_USERONLINE, _T("stduseronline"), NULL }, // 9 + { MIID_UPDATENOTIFY, _T("stdupdate"), NULL }, // 10 + + { MIID_CLIST, NULL, NULL }, // 11 + { MIID_CHAT, NULL, NULL }, // 12 + { MIID_SRMM, NULL, NULL }, // 13 + { MIID_DATABASE, NULL, NULL }, // 14 }; static BOOL bModuleInitialized = FALSE; @@ -86,7 +86,7 @@ char* GetPluginNameByInstance(HINSTANCE hInstance) if (pluginList.getCount() == 0) return NULL; - for (int i = 0; i < pluginList.getCount(); i++) { + for (int i=0; i < pluginList.getCount(); i++) { pluginEntry* pe = pluginList[i]; if (pe->bpi.pluginInfo && pe->bpi.hInst == hInstance) return pe->bpi.pluginInfo->shortName; @@ -164,14 +164,14 @@ static int isPluginBanned(MUUID u1, DWORD dwVersion) * storage */ -static const TCHAR* modulesToSkip[] = +static const TCHAR* modulesToSkip[] = { _T("autoloadavatars.dll"), _T("multiwindow.dll"), _T("fontservice.dll"), _T("icolib.dll"), _T("historyeditor.dll") }; // The following plugins will be checked for a valid MUUID or they will not be loaded -static const TCHAR* expiredModulesToSkip[] = +static const TCHAR* expiredModulesToSkip[] = { _T("scriver.dll"), _T("nconvers.dll"), _T("tabsrmm.dll"), _T("nhistory.dll"), _T("historypp.dll"), _T("help.dll"), _T("loadavatars.dll"), _T("tabsrmm_unicode.dll"), @@ -207,7 +207,7 @@ int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int ch // fontservice plugin is built into the core now TCHAR* p = _tcsrchr(plugin, '\\'); if (p != NULL && ++p) { - for (int i = 0; i < SIZEOF(modulesToSkip); i++) + for (int i=0; i < SIZEOF(modulesToSkip); i++) if (lstrcmpi(p, modulesToSkip[i]) == 0) return 0; } @@ -294,6 +294,11 @@ void Plugin_Uninit(pluginEntry* p, bool bDynamic) KillModuleHotkeys(hLangpack); KillModuleSounds(hLangpack); } + + // release default plugin + for (int i=0; i < SIZEOF(pluginDefault); i++) + if (pluginDefault[i].pImpl == p) + pluginDefault[i].pImpl = NULL; } FreeLibrary(p->bpi.hInst); @@ -303,10 +308,24 @@ void Plugin_Uninit(pluginEntry* p, bool bDynamic) pluginList.remove(p); } +int Plugin_UnloadDyn(pluginEntry* p) +{ + if (CallPluginEventHook(p->bpi.hInst, hOkToExitEvent, 0, 0) != 0) + return FALSE; + + NotifyEventHooks(hevUnloadModule, (WPARAM)p->bpi.InfoEx, (LPARAM)p->bpi.hInst); + + CallPluginEventHook(p->bpi.hInst, hPreShutdownEvent, 0, 0); + CallPluginEventHook(p->bpi.hInst, hShutdownEvent, 0, 0); + + Plugin_Uninit(p, true); + return TRUE; +} + // returns true if the given file is .dll exactly static int valid_library_name(TCHAR *name) { - TCHAR * dot = _tcsrchr(name, '.'); + TCHAR *dot = _tcsrchr(name, '.'); if (dot != NULL && lstrcmpi(dot + 1, _T("dll")) == 0) if (dot[4] == 0) return 1; @@ -315,21 +334,21 @@ static int valid_library_name(TCHAR *name) } // returns true if the given file matches dbx_*.dll, which is used to LoadLibrary() -static int validguess_db_name(TCHAR * name) +static int validguess_db_name(TCHAR *name) { int rc = 0; // this is ONLY SAFE because name -> ffd.cFileName == MAX_PATH TCHAR x = name[4]; - name[4]=0; + name[4] = 0; rc = lstrcmpi(name, _T("dbx_")) == 0 || lstrcmpi(name, _T("dbrw")) == 0; name[4] = x; return rc; } // returns true if the given file matches clist_*.dll -static int validguess_clist_name(TCHAR * name) +static int validguess_clist_name(TCHAR *name) { - int rc=0; + int rc = 0; // argh evil TCHAR x = name[6]; name[6] = 0; @@ -339,12 +358,12 @@ static int validguess_clist_name(TCHAR * name) } // returns true if the given file matches svc_*.dll -static int validguess_servicemode_name(TCHAR * name) +static int validguess_servicemode_name(TCHAR *name) { int rc = 0; // argh evil TCHAR x = name[4]; - name[4]=0; + name[4] = 0; rc = lstrcmpi(name, _T("svc_")) == 0; name[4] = x; return rc; @@ -401,15 +420,17 @@ static INT_PTR PluginsEnum(WPARAM, LPARAM lParam) return pluginListDb != NULL ? 1 : -1; } -pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path) +pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path) { BASIC_PLUGIN_INFO bpi; pluginEntry* p = (pluginEntry*)HeapAlloc(hPluginListHeap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, sizeof(pluginEntry)); _tcsncpy(p->pluginname, tszFileName, SIZEOF(p->pluginname)); + + TCHAR buf[MAX_PATH]; + mir_sntprintf(buf, SIZEOF(buf), _T("%s\\%s\\%s"), path, dir, tszFileName); + // plugin name suggests its a db module, load it right now if ( validguess_db_name(tszFileName)) { - TCHAR buf[MAX_PATH]; - mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, tszFileName); if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_DB)) { // db plugin is valid p->pclass |= (PCLASS_DB | PCLASS_BASICAPI); @@ -425,13 +446,11 @@ pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path) } else if ( validguess_clist_name(tszFileName)) { // keep a note of this plugin for later - if (pluginListUI != NULL) p->nextclass=pluginListUI; - pluginListUI=p; + if (pluginListUI != NULL) p->nextclass = pluginListUI; + pluginListUI = p; p->pclass |= PCLASS_CLIST; } else if ( validguess_servicemode_name(tszFileName)) { - TCHAR buf[MAX_PATH]; - mir_sntprintf(buf, SIZEOF(buf), _T("%s\\Plugins\\%s"), path, tszFileName); if (checkAPI(buf, &bpi, mirandaVersion, CHECKAPI_NONE)) { p->pclass |= (PCLASS_OK | PCLASS_BASICAPI); p->bpi = bpi; @@ -455,7 +474,7 @@ pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path) // called in the first pass to create pluginEntry* structures and validate database plugins static BOOL scanPluginsDir(WIN32_FIND_DATA *fd, TCHAR *path, WPARAM, LPARAM) { - pluginEntry* p = OpenPlugin(fd->cFileName, path); + pluginEntry* p = OpenPlugin(fd->cFileName, _T("Plugins"), path); if ( !(p->pclass & PCLASS_FAILED)) { if (pluginList_freeimg == NULL && lstrcmpi(fd->cFileName, _T("advaimg.dll")) == 0) pluginList_freeimg = p; @@ -492,7 +511,7 @@ int isPluginOnWhiteList(const TCHAR* pluginname) return rc == 0; } -bool TryLoadPlugin(pluginEntry *p, bool bDynamic) +bool TryLoadPlugin(pluginEntry *p, TCHAR* dir, bool bDynamic) { TCHAR exe[MAX_PATH]; GetModuleFileName(NULL, exe, SIZEOF(exe)); @@ -505,7 +524,7 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) return false; BASIC_PLUGIN_INFO bpi; - mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), p->pluginname); + mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\%s\\%s"), dir, p->pluginname); if ( !checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE)) p->pclass |= PCLASS_FAILED; else { @@ -517,8 +536,12 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) for (int i=0; !equalUUID(miid_last, piface[i]); i++) { int idx = getDefaultPluginIdx( piface[i] ); if (idx != -1 && pluginDefault[idx].pImpl) { - SetPluginOnWhiteList(p->pluginname, 0); - return false; + if ( !bDynamic) { + SetPluginOnWhiteList(p->pluginname, 0); + return false; + } + Plugin_UnloadDyn(pluginDefault[idx].pImpl); + pluginDefault[idx].pImpl = NULL; } } } @@ -545,7 +568,32 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic) return true; } -static pluginEntry* getCListModule(TCHAR * exe, TCHAR * slice, int useWhiteList) +bool LoadCorePlugin(MuuidReplacement& mr) +{ + TCHAR exe[MAX_PATH], tszPlugName[MAX_PATH]; + GetModuleFileName(NULL, exe, SIZEOF(exe)); + TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0; + + mir_sntprintf(tszPlugName, SIZEOF(tszPlugName), _T("%s.dll"), mr.stdplugname); + pluginEntry* pPlug = OpenPlugin(tszPlugName, _T("Core"), exe); + if (pPlug->pclass & PCLASS_FAILED) { +LBL_Error: + Plugin_Uninit(pPlug, true); + return FALSE; + } + + if ( !TryLoadPlugin(pPlug, _T("Core"), true)) + goto LBL_Error; + + if (CallPluginEventHook(pPlug->bpi.hInst, hModulesLoadedEvent, 0, 0) != 0) + goto LBL_Error; + + mr.pImpl = pPlug; + NotifyEventHooks(hevLoadModule, (WPARAM)pPlug->bpi.InfoEx, (LPARAM)pPlug->bpi.hInst); + return TRUE; +} + +static pluginEntry* getCListModule(TCHAR *exe, TCHAR *slice, int useWhiteList) { for (pluginEntry *p = pluginListUI; p != NULL; p = p->nextclass) { mir_sntprintf(slice, &exe[MAX_PATH] - slice, _T("\\Plugins\\%s"), p->pluginname); @@ -589,7 +637,7 @@ int UnloadPlugin(TCHAR* buf, int bufLen) char **GetServiceModePluginsList(void) { - int i = 0; + int i=0; char **list = NULL; pluginEntry * p = pluginListSM; while (p != NULL) { @@ -599,7 +647,7 @@ char **GetServiceModePluginsList(void) if (i) { list = (char**)mir_calloc((i + 1) * sizeof(char*)); p = pluginListSM; - i = 0; + i=0; while (p != NULL) { list[i++] = p->bpi.pluginInfo->shortName; p = p->nextclass; @@ -615,7 +663,7 @@ void SetServiceModePlugin(int idx) int LoadServiceModePlugin(void) { - int i = 0; + int i=0; pluginEntry* p = pluginListSM; if (serviceModeIdx < 0) @@ -671,7 +719,7 @@ int LoadNewPluginsModule(void) if (slice) *slice = 0; // remember some useful options - askAboutIgnoredPlugins=(UINT) GetPrivateProfileInt(_T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini); + askAboutIgnoredPlugins = (UINT) GetPrivateProfileInt(_T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini); // if Crash Dumper is present, load it to provide Crash Reports if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname)) @@ -718,7 +766,7 @@ int LoadNewPluginsModule(void) for (i=0; i < pluginList.getCount(); i++) { p = pluginList[i]; - if ( !TryLoadPlugin(p, false)) { + if ( !TryLoadPlugin(p, _T("Plugins"), false)) { Plugin_Uninit(p); i--; } @@ -788,7 +836,7 @@ void UnloadNewPluginsModule(void) } if (hPluginListHeap) HeapDestroy(hPluginListHeap); - hPluginListHeap=0; + hPluginListHeap = 0; pluginList.destroy(); UninitIni(); diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp index 69034567f3..b8384ae593 100644 --- a/src/modules/plugins/pluginopts.cpp +++ b/src/modules/plugins/pluginopts.cpp @@ -29,8 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define IS_DATABASE (1 << 14) extern MUUID miid_clist, miid_database; -extern HANDLE hShutdownEvent, hPreShutdownEvent; -static HANDLE hevLoadModule, hevUnloadModule; +HANDLE hevLoadModule, hevUnloadModule; ///////////////////////////////////////////////////////////////////////////////////////// // Plugins options page dialog @@ -165,14 +164,14 @@ static int LoadPluginDynamically(PluginListItemData* dat) GetModuleFileName(NULL, exe, SIZEOF(exe)); TCHAR *p = _tcsrchr(exe, '\\'); if (p) *p = 0; - pluginEntry* pPlug = OpenPlugin(dat->fileName, exe); + pluginEntry* pPlug = OpenPlugin(dat->fileName, _T("Plugins"), exe); if (pPlug->pclass & PCLASS_FAILED) { LBL_Error: Plugin_Uninit(pPlug, true); return FALSE; } - if ( !TryLoadPlugin(pPlug, true)) + if ( !TryLoadPlugin(pPlug, _T("Plugins"), true)) goto LBL_Error; if (CallPluginEventHook(pPlug->bpi.hInst, hModulesLoadedEvent, 0, 0) != 0) @@ -192,17 +191,8 @@ static int UnloadPluginDynamically(PluginListItemData* dat) if (idx == -1) return FALSE; - pluginEntry* pPlug = pluginList[idx]; - if (CallPluginEventHook(pPlug->bpi.hInst, hOkToExitEvent, 0, 0) != 0) - return FALSE; - - NotifyEventHooks(hevUnloadModule, (WPARAM)pPlug->bpi.InfoEx, (LPARAM)pPlug->bpi.hInst); - - CallPluginEventHook(pPlug->bpi.hInst, hPreShutdownEvent, 0, 0); - CallPluginEventHook(pPlug->bpi.hInst, hShutdownEvent, 0, 0); - - dat->hInst = NULL; - Plugin_Uninit(pPlug, true); + if ( Plugin_UnloadDyn(pluginList[idx])) + dat->hInst = NULL; return TRUE; } @@ -319,7 +309,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar } // if enabling and replaces, find all other replaces and toggle off if ((hdr->uNewState & 0x2000) && dat->flags != 0) { - for (int iRow=0; iRow != -1;) { + for (int iRow = 0; iRow != -1;) { if (iRow != hdr->iItem) { LVITEM dt; dt.mask = LVIF_PARAM; @@ -375,7 +365,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar if (hdr->hdr.code == PSN_APPLY) { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); TCHAR buf[1024]; - for (int iRow=0; iRow != -1;) { + for (int iRow = 0; iRow != -1;) { ListView_GetItemText(hwndList, iRow, 2, buf, SIZEOF(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); @@ -397,7 +387,7 @@ INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar break; } case IDC_GETMOREPLUGINS: - CallService(MS_UTILS_OPENURL, 0, (LPARAM) "http://addons.miranda-im.org/index.php?action=display&id=1"); + CallService(MS_UTILS_OPENURL, 0, (LPARAM) "http://addons.miranda-im.org/index.php?action = display&id = 1"); break; } } break; diff --git a/src/modules/plugins/plugins.h b/src/modules/plugins/plugins.h index 7a3a082f3e..85922fcae8 100644 --- a/src/modules/plugins/plugins.h +++ b/src/modules/plugins/plugins.h @@ -30,7 +30,7 @@ struct BASIC_PLUGIN_INFO Miranda_Plugin_Interfaces Interfaces; Database_Plugin_Info DbInfo; CList_Initialise clistlink; - PLUGININFOEX * pluginInfo; // must be freed if hInst == NULL then its a copy + PLUGININFOEX * pluginInfo; // must be freed if hInst = = NULL then its a copy DATABASELINK * dblink; // only valid during module being in memory }; @@ -66,17 +66,23 @@ int getDefaultPluginIdx(const MUUID& muuid); bool hasMuuid(const BASIC_PLUGIN_INFO&, const MUUID&); int equalUUID(const MUUID& u1, const MUUID& u2); int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI); -pluginEntry* OpenPlugin(TCHAR* tszFileName, TCHAR* path); -bool TryLoadPlugin(pluginEntry *p, bool bDynamic); -void Plugin_Uninit(pluginEntry* p, bool bDynamic=false); -typedef BOOL (*SCAN_PLUGINS_CALLBACK) (WIN32_FIND_DATA * fd, TCHAR * path, WPARAM wParam, LPARAM lParam); +pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path); + +bool TryLoadPlugin(pluginEntry *p, TCHAR *dir, bool bDynamic); +void Plugin_Uninit(pluginEntry* p, bool bDynamic = false); +int Plugin_UnloadDyn(pluginEntry* p); + +typedef BOOL (*SCAN_PLUGINS_CALLBACK) (WIN32_FIND_DATA * fd, TCHAR *path, WPARAM wParam, LPARAM lParam); void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam); struct MuuidReplacement { MUUID uuid; // default interface plugin + TCHAR* stdplugname; pluginEntry* pImpl; // replacement plugin }; extern MuuidReplacement pluginDefault[]; + +bool LoadCorePlugin( MuuidReplacement& ); diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp index 4846d84b87..3fd5aeee6b 100644 --- a/src/modules/protocols/protoaccs.cpp +++ b/src/modules/protocols/protoaccs.cpp @@ -225,7 +225,7 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) { int count = 0; - for (int i = 0; i < accounts.getCount(); i++) { + for (int i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; if ( !pa->ppro || !Proto_IsAccountEnabled(pa)) continue; @@ -247,7 +247,7 @@ static int InitializeStaticAccounts(WPARAM, LPARAM) static int UninitializeStaticAccounts(WPARAM, LPARAM) { - for (int i = 0; i < accounts.getCount(); i++) { + for (int i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; if ( !pa->ppro || !Proto_IsAccountEnabled(pa)) continue; @@ -264,7 +264,7 @@ int LoadAccountsModule(void) bModuleInitialized = TRUE; - for (i = 0; i < accounts.getCount(); i++) { + for (i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[i]; pa->bDynDisabled = !Proto_IsProtocolLoaded(pa->szProtoName); if (pa->ppro) @@ -604,7 +604,7 @@ void UnloadAccountsModule() if ( !bModuleInitialized) return; - for (i=accounts.getCount()-1; i >= 0; i--) { + for (i = accounts.getCount()-1; i >= 0; i--) { PROTOACCOUNT* pa = accounts[ i ]; UnloadAccount(pa, false, false); accounts.remove(i); @@ -617,7 +617,7 @@ void UnloadAccountsModule() void BuildProtoMenus() { - for (int i = 0; i < accounts.getCount(); i++) { + for (int i=0; i < accounts.getCount(); i++) { PROTOACCOUNT* pa = accounts[ i ]; if (cli.pfnGetProtocolVisibility(pa->szModuleName) == 0) continue; diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp index 05d39b07e4..74145d3970 100644 --- a/src/modules/protocols/protochains.cpp +++ b/src/modules/protocols/protochains.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam) //note that this is ChainSend() too, due to a quirk of function definitions { - CCSDATA *ccs=(CCSDATA*)lParam; + CCSDATA *ccs = (CCSDATA*)lParam; int i; char str[10]; DBVARIANT dbv; @@ -70,7 +70,7 @@ INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam) static INT_PTR CallRecvChain(WPARAM wParam, LPARAM lParam) { - CCSDATA *ccs=(CCSDATA*)lParam; + CCSDATA *ccs = (CCSDATA*)lParam; int i; INT_PTR ret; char str[10]; @@ -217,7 +217,7 @@ static INT_PTR Proto_AddToContact(WPARAM wParam, LPARAM lParam) if (pd->type > pdCompare->type) break; } //put the new module at position i - lastProto=mir_strdup((char*)lParam); + lastProto = mir_strdup((char*)lParam); for (;;i++) { _itoa(i, str, 10); if (DBGetContactSettingString((HANDLE)wParam, "_Filter", str, &dbv)) { @@ -227,7 +227,7 @@ static INT_PTR Proto_AddToContact(WPARAM wParam, LPARAM lParam) } DBWriteContactSettingString((HANDLE)wParam, "_Filter", str, lastProto); mir_free(lastProto); - lastProto=dbv.pszVal; + lastProto = dbv.pszVal; } } return 0; diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp index 991ebdfe08..8a12239c48 100644 --- a/src/modules/protocols/protocols.cpp +++ b/src/modules/protocols/protocols.cpp @@ -329,7 +329,7 @@ char** __fastcall Proto_FilesMatrixA(wchar_t **files) while (files[ count++ ]); char** filesA = (char**)mir_alloc(count * sizeof(char*)); - for (int i = 0; i < count; ++i) + for (int i=0; i < count; ++i) filesA[ i ] = mir_u2a(files[ i ]); return filesA; @@ -343,7 +343,7 @@ static wchar_t** __fastcall Proto_FilesMatrixU(char **files) while (files[ count++ ]); wchar_t** filesU = (wchar_t**)mir_alloc(count * sizeof(wchar_t*)); - for (int i = 0; i < count; ++i) + for (int i=0; i < count; ++i) filesU[ i ] = mir_a2u(files[ i ]); return filesU; @@ -419,12 +419,12 @@ INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *s return (INT_PTR)ppi->AddToList(wParam, (PROTOSEARCHRESULT*)lParam); else { PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam; - PROTOSEARCHRESULT *psra =(PROTOSEARCHRESULT*)mir_alloc(psr->cbSize); + PROTOSEARCHRESULT *psra = (PROTOSEARCHRESULT*)mir_alloc(psr->cbSize); memcpy(psra, psr, psr->cbSize); - psra->nick = (PROTOCHAR*)mir_u2a(psr->nick); + psra->nick = (PROTOCHAR*)mir_u2a(psr->nick); psra->firstName = (PROTOCHAR*)mir_u2a(psr->firstName); - psra->lastName = (PROTOCHAR*)mir_u2a(psr->lastName); - psra->email = (PROTOCHAR*)mir_u2a(psr->email); + psra->lastName = (PROTOCHAR*)mir_u2a(psr->lastName); + psra->email = (PROTOCHAR*)mir_u2a(psr->email); INT_PTR res = (INT_PTR)ppi->AddToList(wParam, psra); @@ -595,12 +595,12 @@ INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *s if ( !strcmp(szService, PS_ADDTOLIST)) { PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam; if ( !(psr->flags & PSR_UNICODE)) { - PROTOSEARCHRESULT *psra =(PROTOSEARCHRESULT*)mir_alloc(psr->cbSize); + PROTOSEARCHRESULT *psra = (PROTOSEARCHRESULT*)mir_alloc(psr->cbSize); memcpy(psra, psr, psr->cbSize); - psra->nick = (PROTOCHAR*)mir_u2a(psr->nick); + psra->nick = (PROTOCHAR*)mir_u2a(psr->nick); psra->firstName = (PROTOCHAR*)mir_u2a(psr->firstName); - psra->lastName = (PROTOCHAR*)mir_u2a(psr->lastName); - psra->email = (PROTOCHAR*)mir_u2a(psr->email); + psra->lastName = (PROTOCHAR*)mir_u2a(psr->lastName); + psra->email = (PROTOCHAR*)mir_u2a(psr->email); INT_PTR res = MyCallProtoService(szModule, szService, wParam, (LPARAM)psra); @@ -668,7 +668,7 @@ INT_PTR CallContactService(HANDLE hContact, const char *szProtoService, WPARAM w PROTOACCOUNT* pa; CCSDATA ccs = { hContact, szProtoService, wParam, lParam }; - for (i = 0;; i++) { + for (i=0;; i++) { char str[10]; _itoa(i, str, 10); if (DBGetContactSettingString(hContact, "_Filter", str, &dbv)) diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp index 007e827388..2de8275453 100644 --- a/src/modules/protocols/protoopts.cpp +++ b/src/modules/protocols/protoopts.cpp @@ -124,7 +124,7 @@ static INT_PTR CALLBACK AccFormDlgProc(HWND hwndDlg, UINT message, WPARAM wParam GetDlgItemTextA(hwndDlg, IDC_ACCINTERNALNAME, buf, SIZEOF(buf)); rtrim(buf); if (buf[0]) { - for (int i = 0; i < accounts.getCount(); ++i) + for (int i=0; i < accounts.getCount(); ++i) if (_stricmp(buf, accounts[i]->szModuleName) == 0) return FALSE; } } @@ -587,7 +587,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM hIcon = LoadSkinnedIcon(tmp); DrawIconEx(lps->hDC, lps->rcItem.left, lps->rcItem.top, hIcon, cxIcon, cyIcon, 0, hbrBack, DI_NORMAL); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); lps->rcItem.left += cxIcon + 2; @@ -662,7 +662,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM dat->iSelected = -1; SendMessage(hList, LB_RESETCONTENT, 0, 0); - for (i = 0; i < accounts.getCount(); ++i) { + for (i=0; i < accounts.getCount(); ++i) { int iItem = SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)accounts[i]->tszAccountName); SendMessage(hList, LB_SETITEMDATA, iItem, (LPARAM)accounts[i]); @@ -670,7 +670,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM ListBox_SetCurSel(hList, iItem); } - dat->iSelected = ListBox_GetCurSel(hList); // -1 if error => nothing selected in our case + dat->iSelected = ListBox_GetCurSel(hList); // -1 if error = > nothing selected in our case if (dat->iSelected >= 0) sttSelectItem(dat, hList, dat->iSelected); else if (acc && acc->hwndAccMgrUI) @@ -696,7 +696,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM } } else { - // menu was activated with mouse => find item under cursor & set focus to our control. + // menu was activated with mouse = > find item under cursor & set focus to our control. POINT ptItem = pt; ScreenToClient(hwndList, &ptItem); iItem = (short)LOWORD(SendMessage(hwndList, LB_ITEMFROMPOINT, 0, MAKELPARAM(ptItem.x, ptItem.y))); @@ -969,7 +969,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM int i; PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_APPLY; - for (i = 0; i < accounts.getCount(); ++i) { + for (i=0; i < accounts.getCount(); ++i) { if (accounts[i]->hwndAccMgrUI && accounts[i]->bAccMgrUIChanged) { pshn.hdr.hwndFrom = accounts[i]->hwndAccMgrUI; SendMessage(accounts[i]->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn); @@ -982,7 +982,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM int i; PSHNOTIFY pshn = {0}; pshn.hdr.code = PSN_RESET; - for (i = 0; i < accounts.getCount(); ++i) { + for (i=0; i < accounts.getCount(); ++i) { if (accounts[i]->hwndAccMgrUI && accounts[i]->bAccMgrUIChanged) { pshn.hdr.hwndFrom = accounts[i]->hwndAccMgrUI; SendMessage(accounts[i]->hwndAccMgrUI, WM_NOTIFY, 0, (LPARAM)&pshn); @@ -996,7 +996,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM break; case WM_DESTROY: { - for (int i = 0; i < accounts.getCount(); ++i) { + for (int i=0; i < accounts.getCount(); ++i) { accounts[i]->bAccMgrUIChanged = FALSE; if (accounts[i]->hwndAccMgrUI) { DestroyWindow(accounts[i]->hwndAccMgrUI); diff --git a/src/modules/skin/hotkey_opts.cpp b/src/modules/skin/hotkey_opts.cpp index 6bebcdc273..f23e777604 100644 --- a/src/modules/skin/hotkey_opts.cpp +++ b/src/modules/skin/hotkey_opts.cpp @@ -331,7 +331,7 @@ static void sttOptionsSaveItem(THotkeyItem *item) DBWriteContactSettingByte(NULL, DBMODULENAME "Types", item->pszName, (BYTE)item->type); item->nSubHotkeys = 0; - for (i = 0; i < hotkeys.getCount(); i++) { + for (i=0; i < hotkeys.getCount(); i++) { THotkeyItem *subItem = hotkeys[i]; if (subItem->rootHotkey == item) { subItem->Hotkey = subItem->OptHotkey; @@ -351,10 +351,10 @@ static void sttOptionsSaveItem(THotkeyItem *item) static void sttBuildHotkeyList(HWND hwndList) { - int i, nItems=0; + int i, nItems = 0; ListView_DeleteAllItems(hwndList); - for (i = 0; i < hotkeys.getCount(); i++) { + for (i=0; i < hotkeys.getCount(); i++) { LVITEM lvi = {0}; THotkeyItem *item = hotkeys[i]; @@ -469,7 +469,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, lvc.cx = GetSystemMetrics(SM_CXSMICON); ListView_InsertColumn(hwndHotkey, COL_ADDREMOVE, &lvc); - for (int i = 0; i < hotkeys.getCount(); i++) { + for (int i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; item->OptChanged = FALSE; @@ -728,7 +728,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, UnregisterHotkeys(); - for (i = 0; i < hotkeys.getCount(); i++) { + for (i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; if (item->OptNew && item->OptDeleted || item->rootHotkey && !item->OptHotkey || @@ -744,7 +744,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LVITEM lvi = {0}; int count = ListView_GetItemCount(hwndHotkey); - for (i = 0; i < hotkeys.getCount(); i++) + for (i=0; i < hotkeys.getCount(); i++) sttOptionsSaveItem(hotkeys[i]); lvi.mask = LVIF_IMAGE; @@ -886,7 +886,7 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, else if (param->uNewState>>12 == 2) { int i, nItems = ListView_GetItemCount(lpnmhdr->hwndFrom); initialized = FALSE; - for (i = 0; i < hotkeys.getCount(); ++i) { + for (i=0; i < hotkeys.getCount(); ++i) { LVITEM lvi = {0}; THotkeyItem *item = hotkeys[i]; diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp index bf939d5716..05297f92b3 100644 --- a/src/modules/skin/hotkeys.cpp +++ b/src/modules/skin/hotkeys.cpp @@ -51,7 +51,7 @@ static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam); WORD GetHotkeyValue(INT_PTR idHotkey) { - for (int i = 0; i < hotkeys.getCount(); i++) + for (int i=0; i < hotkeys.getCount(); i++) if (hotkeys[i]->idHotkey == idHotkey) return hotkeys[i]->Enabled ? hotkeys[i]->Hotkey : 0; @@ -71,7 +71,7 @@ static void sttWordToModAndVk(WORD w, BYTE *mod, BYTE *vk) static LRESULT CALLBACK sttHotkeyHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_HOTKEY) { - for (int i = 0; i < hotkeys.getCount(); i++) { + for (int i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; if (item->type != HKT_GLOBAL || !item->Enabled) continue; @@ -91,7 +91,7 @@ static LRESULT CALLBACK sttHotkeyHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam) { if (code == HC_ACTION && !(HIWORD(lParam) & KF_UP)) { - BYTE mod=0, vk=wParam; + BYTE mod = 0, vk = wParam; if (vk) { if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL; @@ -99,7 +99,7 @@ static LRESULT CALLBACK sttKeyboardProc(int code, WPARAM wParam, LPARAM lParam) if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT; if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN; - for (int i = 0; i < hotkeys.getCount(); i++) { + for (int i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; BYTE hkMod, hkVk; if (item->type != HKT_LOCAL) continue; @@ -194,7 +194,7 @@ static INT_PTR svcHotkeyRegister(WPARAM wParam, LPARAM lParam) int count, i; mir_snprintf(buf, SIZEOF(buf), "%s$count", item->pszName); count = (int)DBGetContactSettingDword(NULL, DBMODULENAME, buf, -1); - for (i = 0; i < count; i++) { + for (i=0; i < count; i++) { mir_snprintf(buf, SIZEOF(buf), "%s$%d", item->pszName, i); if ( !DBGetContactSettingWord(NULL, DBMODULENAME, buf, 0)) continue; @@ -220,14 +220,14 @@ static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam) mir_snprintf(pszNamePrefix, SIZEOF(pszNamePrefix), "%s$", pszName); cbNamePrefix = strlen(pszNamePrefix); - for (i = 0; i < hotkeys.getCount(); ++i) + for (i=0; i < hotkeys.getCount(); ++i) { char *pszCurrentName = hotkeys[i]->rootHotkey ? hotkeys[i]->rootHotkey->pszName : hotkeys[i]->pszName; if ( !pszCurrentName) continue; - hotkeys[i]->UnregisterHotkey = + hotkeys[i]->UnregisterHotkey = !lstrcmpA(pszCurrentName, pszName) || !strncmp(pszCurrentName, pszNamePrefix, cbNamePrefix); } @@ -235,7 +235,7 @@ static INT_PTR svcHotkeyUnregister(WPARAM, LPARAM lParam) if (g_hwndHkOptions) SendMessage(g_hwndHkOptions, WM_HOTKEYUNREGISTERED, 0, 0); - for (i = 0; i < hotkeys.getCount(); ++i) + for (i=0; i < hotkeys.getCount(); ++i) if (hotkeys[i]->UnregisterHotkey) { FreeHotkey(hotkeys[i]); List_Remove((SortedList *)&hotkeys, i); @@ -252,7 +252,7 @@ static INT_PTR svcHotkeyCheck(WPARAM wParam, LPARAM lParam) if ((msg->message == WM_KEYDOWN) || (msg->message == WM_SYSKEYDOWN)) { int i; - BYTE mod=0, vk=msg->wParam; + BYTE mod = 0, vk = msg->wParam; if (vk) { if (GetAsyncKeyState(VK_CONTROL)) mod |= MOD_CONTROL; @@ -260,7 +260,7 @@ static INT_PTR svcHotkeyCheck(WPARAM wParam, LPARAM lParam) if (GetAsyncKeyState(VK_SHIFT)) mod |= MOD_SHIFT; if (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN)) mod |= MOD_WIN; - for (i = 0; i < hotkeys.getCount(); i++) { + for (i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; BYTE hkMod, hkVk; if ((item->type != HKT_MANUAL) || lstrcmp(pszSection, item->ptszSection)) continue; @@ -290,7 +290,7 @@ void FreeHotkey(THotkeyItem *item) void RegisterHotkeys() { - for (int i = 0; i < hotkeys.getCount(); i++) { + for (int i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; UnregisterHotKey(g_hwndHotkeyHost, item->idHotkey); if (item->type != HKT_GLOBAL) continue; @@ -302,7 +302,7 @@ void RegisterHotkeys() void KillModuleHotkeys(int hLangpack) { - for (int i=hotkeys.getCount()-1; i >= 0; i--) { + for (int i = hotkeys.getCount()-1; i >= 0; i--) { THotkeyItem *item = hotkeys[i]; if (item->hLangpack == hLangpack) { FreeHotkey(item); @@ -313,7 +313,7 @@ void KillModuleHotkeys(int hLangpack) void UnregisterHotkeys() { - for (int i = 0; i < hotkeys.getCount(); i++) { + for (int i=0; i < hotkeys.getCount(); i++) { THotkeyItem *item = hotkeys[i]; if (item->type == HKT_GLOBAL && item->Enabled) UnregisterHotKey(g_hwndHotkeyHost, item->idHotkey); @@ -369,7 +369,7 @@ int LoadSkinHotkeys(void) HookEvent(ME_SYSTEM_MODULESLOADED, sttModulesLoaded); - for (int i = 0; i < SIZEOF(oldSettings); i++) { + for (int i=0; i < SIZEOF(oldSettings); i++) { char szSetting[ 100 ]; mir_snprintf(szSetting, SIZEOF(szSetting), "HK%s", oldSettings[i]); @@ -398,7 +398,7 @@ void UnloadSkinHotkeys(void) UnhookWindowsHookEx(hhkKeyboard); UnregisterHotkeys(); DestroyWindow(g_hwndHotkeyHost); - for (int i = 0; i < hotkeys.getCount(); i++) + for (int i=0; i < hotkeys.getCount(); i++) FreeHotkey(hotkeys[i]); hotkeys.destroy(); } diff --git a/src/modules/skin/skinicons.cpp b/src/modules/skin/skinicons.cpp index 509135ae20..796b2033f4 100644 --- a/src/modules/skin/skinicons.cpp +++ b/src/modules/skin/skinicons.cpp @@ -32,7 +32,7 @@ struct StandardIconDescription const char* section; }; -static const struct StandardIconDescription mainIcons[] = +static const struct StandardIconDescription mainIcons[] = { { SKINICON_OTHER_MIRANDA, LPGEN("Miranda IM"), -IDI_MIRANDA }, { SKINICON_EVENT_MESSAGE, LPGEN("Message"), -IDI_RECVMSG }, @@ -85,7 +85,7 @@ static const struct StandardIconDescription mainIcons[] = HANDLE hMainIcons[SIZEOF(mainIcons)]; -static const struct StandardIconDescription statusIcons[] = +static const struct StandardIconDescription statusIcons[] = { { ID_STATUS_OFFLINE, LPGEN("Offline"), -IDI_OFFLINE, 0xFFFFFFFF }, { ID_STATUS_ONLINE, LPGEN("Online"), -IDI_ONLINE, PF2_ONLINE }, @@ -101,9 +101,9 @@ static const struct StandardIconDescription statusIcons[] = HANDLE hStatusIcons[SIZEOF(statusIcons)]; -const char* mainIconsFmt = "core_main_"; +const char* mainIconsFmt = "core_main_"; const char* statusIconsFmt = "core_status_"; -const char* protoIconsFmt = LPGEN("%s Icons"); +const char* protoIconsFmt = LPGEN("%s Icons"); #define PROTOCOLS_PREFIX "Status Icons/" #define GLOBAL_PROTO_NAME "*" @@ -135,7 +135,7 @@ HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared) { HICON hResIcon = bShared ? LoadSmallIcon(hInstance, lpIconName) : LoadSmallIconShared(hInstance, lpIconName); if ( !hResIcon) { //Icon not found in hInstance lets try to load it from core - HINSTANCE hCoreInstance=hInst; + HINSTANCE hCoreInstance = hInst; if (hCoreInstance != hInstance) hResIcon = bShared ? LoadSmallIcon(hCoreInstance, lpIconName) : LoadSmallIconShared(hCoreInstance, lpIconName); } @@ -144,7 +144,7 @@ HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared) int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource) { - HICON hTempIcon=LoadIconEx(hInst, szResource, 0); + HICON hTempIcon = LoadIconEx(hInst, szResource, 0); int res = ImageList_AddIcon(hIml, hTempIcon); Safe_DestroyIcon(hTempIcon); return res; @@ -154,7 +154,7 @@ int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId) { HICON hIcon = LoadSkinIcon(iconId); int res = ImageList_AddIcon(hIml, hIcon); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); return res; } @@ -162,7 +162,7 @@ int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char* szProto, i { HICON hIcon = LoadSkinProtoIcon(szProto, iconId); int res = ImageList_AddIcon(hIml, hIcon); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); return res; } @@ -177,7 +177,7 @@ int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInst int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon) { int res = ImageList_ReplaceIcon(hIml, nIndex, hIcon); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); return res; } @@ -195,8 +195,8 @@ void Window_SetProtoIcon_IcoLib(HWND hWnd, const char* szProto, int iconId) void Window_FreeIcon_IcoLib(HWND hWnd) { - IconLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0), NULL); - IconLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0), NULL); + IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_BIG, 0), NULL); + IcoLib_ReleaseIcon((HICON)SendMessage(hWnd, WM_SETICON, ICON_SMALL, 0), NULL); } void Button_SetIcon_IcoLib(HWND hwndDlg, int itemId, int iconId, const char* tooltip) @@ -210,7 +210,7 @@ void Button_SetIcon_IcoLib(HWND hwndDlg, int itemId, int iconId, const char* too void Button_FreeIcon_IcoLib(HWND hwndDlg, int itemId) { HICON hIcon = (HICON)SendDlgItemMessage(hwndDlg, itemId, BM_SETIMAGE, IMAGE_ICON, 0); - IconLib_ReleaseIcon(hIcon, 0); + IcoLib_ReleaseIcon(hIcon, 0); } // @@ -229,7 +229,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) return IcoLib_GetIcon(iconName, big); } - for (i = 0; i < SIZEOF(statusIcons); i++) { + for (i=0; i < SIZEOF(statusIcons); i++) { if (statusIcons[i].id == status) { statusIndx = i; break; @@ -335,7 +335,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) HANDLE GetSkinIconHandle(int idx) { int i; - for (i = 0; i < SIZEOF(mainIcons); i++) + for (i=0; i < SIZEOF(mainIcons); i++) if (idx == mainIcons[i].id) return hMainIcons[i]; @@ -365,7 +365,7 @@ static void convertOneProtocol(char* moduleName, char* iconName) char* pm = moduleName + strlen(moduleName); char* pi = iconName + strlen(iconName); - for (int i = 0; i < SIZEOF(statusIcons); i++) { + for (int i=0; i < SIZEOF(statusIcons); i++) { _itoa(statusIcons[i].id, pm, 10); DBVARIANT dbv; @@ -416,7 +416,7 @@ int LoadSkinIcons(void) // // Perform "1st-time running import" - for (i = 0; i < SIZEOF(mainIcons); i++) { + for (i=0; i < SIZEOF(mainIcons); i++) { _itoa(mainIcons[i].id, moduleName, 10); if (DBGetContactSettingTString(NULL, "Icons", moduleName, &dbv)) break; @@ -465,7 +465,7 @@ int LoadSkinIcons(void) // // Add main icons to list // - for (i = 0; i < SIZEOF(mainIcons); i++) { + for (i=0; i < SIZEOF(mainIcons); i++) { mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, i); sid.pszSection = mainIcons[i].section == NULL ? "Main Icons" : (char*)mainIcons[i].section; sid.pszDescription = (char*)mainIcons[i].description; @@ -479,7 +479,7 @@ int LoadSkinIcons(void) // // Asterisk is used, to avoid conflict with proto-plugins // 'coz users can't rename it to name with '*' - for (i = 0; i < SIZEOF(statusIcons); i++) { + for (i=0; i < SIZEOF(statusIcons); i++) { mir_snprintf(iconName, SIZEOF(iconName), "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i); sid.pszName = iconName; sid.pszDescription = (char*)statusIcons[i].description; diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp index 05422ffef6..448ff26358 100644 --- a/src/modules/skin/sounds.cpp +++ b/src/modules/skin/sounds.cpp @@ -53,7 +53,7 @@ static OBJLIST arSounds(10, CompareSounds); void KillModuleSounds(int hLangpack) { - for (int i=arSounds.getCount()-1; i >= 0; i--) { + for (int i = arSounds.getCount()-1; i >= 0; i--) { SoundItem& p = arSounds[i]; if (p.hLangpack == hLangpack) { p.clear(); @@ -192,7 +192,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (tvi.lParam == -1) TreeView_SetItemState(hwndTree, tvi.hItem, INDEXTOSTATEIMAGEMASK(0), TVIS_STATEIMAGEMASK); - tvi.hItem=TreeView_GetNextSibling(hwndTree, tvi.hItem); + tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem); } } ShowWindow(hwndTree, SW_SHOW); @@ -316,7 +316,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetDlgItemText(hwndDlg, IDC_LOCATION, strFull); } if (LOWORD(wParam) == IDC_GETMORE) { - CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=5"); + CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action = display&id = 5"); break; } if (LOWORD(wParam) == IDC_LOCATION) @@ -355,7 +355,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM tvic.hItem = TreeView_GetNextSibling(hwndTree, tvic.hItem); } } - tvi.hItem=TreeView_GetNextSibling(hwndTree, tvi.hItem); + tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem); } return TRUE; } @@ -419,7 +419,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return FALSE; } -static UINT iconsExpertOnlyControls[]={IDC_IMPORT}; +static UINT iconsExpertOnlyControls[] = {IDC_IMPORT}; static int SkinOptionsInit(WPARAM wParam, LPARAM) { diff --git a/src/modules/srauth/auth.cpp b/src/modules/srauth/auth.cpp index 61dedc06be..1baadfaced 100644 --- a/src/modules/srauth/auth.cpp +++ b/src/modules/srauth/auth.cpp @@ -61,7 +61,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam) HANDLE hContact = *(PHANDLE)(dbei.pBlob + sizeof(DWORD)); - CLISTEVENT cli ={0}; + CLISTEVENT cli = {0}; cli.cbSize = sizeof(cli); cli.hContact = hContact; cli.ptszTooltip = szTooltip; diff --git a/src/modules/srauth/authdialogs.cpp b/src/modules/srauth/authdialogs.cpp index 7a19f54642..ae75865ab4 100644 --- a/src/modules/srauth/authdialogs.cpp +++ b/src/modules/srauth/authdialogs.cpp @@ -42,15 +42,15 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); + dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); DWORD uin = *(PDWORD)dbei.pBlob; HANDLE hContact = *(HANDLE*)(dbei.pBlob + sizeof(DWORD)); - char* nick = (char *)(dbei.pBlob + sizeof(DWORD) + sizeof(HANDLE)); - char* first = nick + strlen(nick) + 1; - char* last = first + strlen(first) + 1; - char* email = last + strlen(last) + 1; + char* nick = (char *)(dbei.pBlob + sizeof(DWORD) + sizeof(HANDLE)); + char* first = nick + strlen(nick) + 1; + char* last = first + strlen(first) + 1; + char* email = last + strlen(last) + 1; SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); @@ -173,16 +173,16 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP //blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) dbei.cbSize = sizeof(dbei); dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0); - dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); + dbei.pBlob = (PBYTE)alloca(dbei.cbBlob); CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); uin = *(PDWORD)dbei.pBlob; hContact = *(HANDLE*)(dbei.pBlob + sizeof(DWORD)); - nick = (char *)(dbei.pBlob + sizeof(DWORD) + sizeof(HANDLE)); - first = nick + strlen(nick) + 1; - last = first + strlen(first) + 1; - email = last + strlen(last) + 1; - reason = email + strlen(email) + 1; + nick = (char *)(dbei.pBlob + sizeof(DWORD) + sizeof(HANDLE)); + first = nick + strlen(nick) + 1; + last = first + strlen(first) + 1; + email = last + strlen(last) + 1; + reason = email + strlen(email) + 1; SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0)); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0)); @@ -195,7 +195,7 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR* emailT = dbei.flags & DBEF_UTF ? Utf8DecodeT(email) : mir_a2t(email); TCHAR* reasonT = dbei.flags & DBEF_UTF ? Utf8DecodeT(reason) : mir_a2t(reason); - TCHAR name[128] =_T(""); + TCHAR name[128] = _T(""); int off = 0; if (firstT[0] && lastT[0]) off = mir_sntprintf(name, SIZEOF(name), _T("%s %s"), firstT, lastT); diff --git a/src/modules/srawaymsg/awaymsg.cpp b/src/modules/srawaymsg/awaymsg.cpp index 82ea8f2121..e9d80789e3 100644 --- a/src/modules/srawaymsg/awaymsg.cpp +++ b/src/modules/srawaymsg/awaymsg.cpp @@ -121,7 +121,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM) { HWND hwnd; - if (hwnd=WindowList_Find(hWindowList, (HANDLE)wParam)) { + if (hwnd = WindowList_Find(hWindowList, (HANDLE)wParam)) { SetForegroundWindow(hwnd); SetFocus(hwnd); } @@ -135,7 +135,7 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM) TCHAR str[128]; char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); ZeroMemory(&clmi, sizeof(clmi)); clmi.cbSize = sizeof(clmi); clmi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN | CMIF_TCHAR; @@ -153,7 +153,7 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM) } } } } CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hAwayMsgMenuItem, (LPARAM)&clmi); - IconLib_ReleaseIcon(clmi.hIcon, 0); + IcoLib_ReleaseIcon(clmi.hIcon, 0); return 0; } @@ -170,10 +170,10 @@ int LoadAwayMsgModule(void) hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetMessageCommand); - mi.cbSize = sizeof(mi); - mi.position = -2000005000; - mi.flags = CMIF_NOTOFFLINE; - mi.pszName = LPGEN("Re&ad Status Message"); + mi.cbSize = sizeof(mi); + mi.position = -2000005000; + mi.flags = CMIF_NOTOFFLINE; + mi.pszName = LPGEN("Re&ad Status Message"); mi.pszService = MS_AWAYMSG_SHOWAWAYMSG; hAwayMsgMenuItem = Menu_AddContactMenuItem(&mi); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, AwayMsgPreBuildMenu); diff --git a/src/modules/srawaymsg/sendmsg.cpp b/src/modules/srawaymsg/sendmsg.cpp index 843b43f64f..56649c5297 100644 --- a/src/modules/srawaymsg/sendmsg.cpp +++ b/src/modules/srawaymsg/sendmsg.cpp @@ -377,7 +377,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam HWND hLst = GetDlgItem(hwndDlg, IDC_LST_STATUS); - dat=(struct AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + dat = (struct AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: @@ -386,7 +386,7 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->oldPage = -1; - for (int i = 0; i < SIZEOF(statusModes); i++) + for (int i=0; i < SIZEOF(statusModes); i++) { int j; if ( !(protoModeMsgFlags & Proto_Status2Flag(statusModes[i]))) @@ -562,7 +562,7 @@ static int AwayMsgSendModernOptInit(WPARAM wParam, LPARAM) if (protoModeMsgFlags == 0) return 0; - static const int iBoldControls[] = + static const int iBoldControls[] = { IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, MODERNOPT_CTRL_LAST diff --git a/src/modules/sremail/email.cpp b/src/modules/sremail/email.cpp index 0f7ca69020..3782f132ed 100644 --- a/src/modules/sremail/email.cpp +++ b/src/modules/sremail/email.cpp @@ -37,14 +37,14 @@ static INT_PTR SendEMailCommand(WPARAM wParam, LPARAM lParam) char *szUrl; char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (szProto == NULL || DBGetContactSettingString((HANDLE)wParam, szProto, "e-mail", &dbv)) { if (DBGetContactSettingString((HANDLE)wParam, "UserInfo", "Mye-mail0", &dbv)) { MessageBox((HWND)lParam, TranslateT("User has not registered an e-mail address"), TranslateT("Send e-mail"), MB_OK); return 1; } } - szUrl=(char*)mir_alloc(lstrlenA(dbv.pszVal)+8); + szUrl = (char*)mir_alloc(lstrlenA(dbv.pszVal)+8); lstrcpyA(szUrl, "mailto:"); lstrcatA(szUrl, dbv.pszVal); mir_free(dbv.pszVal); diff --git a/src/modules/srfile/file.cpp b/src/modules/srfile/file.cpp index b398294c8d..4e1db5c651 100644 --- a/src/modules/srfile/file.cpp +++ b/src/modules/srfile/file.cpp @@ -31,8 +31,8 @@ static HANDLE hSRFileMenuItem; static INT_PTR SendFileCommand(WPARAM wParam, LPARAM) { struct FileSendData fsd; - fsd.hContact=(HANDLE)wParam; - fsd.ppFiles=NULL; + fsd.hContact = (HANDLE)wParam; + fsd.ppFiles = NULL; CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); return 0; } @@ -40,7 +40,7 @@ static INT_PTR SendFileCommand(WPARAM wParam, LPARAM) static INT_PTR SendSpecificFiles(WPARAM wParam, LPARAM lParam) { FileSendData fsd; - fsd.hContact=(HANDLE)wParam; + fsd.hContact = (HANDLE)wParam; char** ppFiles = (char**)lParam; int count = 0; @@ -53,7 +53,7 @@ static INT_PTR SendSpecificFiles(WPARAM wParam, LPARAM lParam) fsd.ppFiles[ count ] = NULL; CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); - for (int j=0; j < count; j++) + for (int j = 0; j < count; j++) mir_free((void*)fsd.ppFiles[j]); return 0; } @@ -61,8 +61,8 @@ static INT_PTR SendSpecificFiles(WPARAM wParam, LPARAM lParam) static INT_PTR SendSpecificFilesT(WPARAM wParam, LPARAM lParam) { FileSendData fsd; - fsd.hContact=(HANDLE)wParam; - fsd.ppFiles=(const TCHAR**)lParam; + fsd.hContact = (HANDLE)wParam; + fsd.ppFiles = (const TCHAR**)lParam; CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd); return 0; } @@ -85,7 +85,7 @@ static INT_PTR RecvFileCommand(WPARAM, LPARAM lParam) void PushFileEvent(HANDLE hContact, HANDLE hdbe, LPARAM lParam) { - CLISTEVENT cle={0}; + CLISTEVENT cle = {0}; cle.cbSize = sizeof(cle); cle.hContact = hContact; cle.hDbEvent = hdbe; @@ -110,7 +110,7 @@ static int FileEventAdded(WPARAM wParam, LPARAM lParam) { DWORD dwSignature; - DBEVENTINFO dbei={0}; + DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); dbei.cbBlob = sizeof(DWORD); dbei.pBlob = (PBYTE)&dwSignature; @@ -125,7 +125,7 @@ static int FileEventAdded(WPARAM wParam, LPARAM lParam) int SRFile_GetRegValue(HKEY hKeyBase, const TCHAR *szSubKey, const TCHAR *szValue, TCHAR *szOutput, int cbOutput) { HKEY hKey; - DWORD cbOut=cbOutput; + DWORD cbOut = cbOutput; if (RegOpenKeyEx(hKeyBase, szSubKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) return 0; @@ -142,13 +142,13 @@ int SRFile_GetRegValue(HKEY hKeyBase, const TCHAR *szSubKey, const TCHAR *szValu void GetSensiblyFormattedSize(__int64 size, TCHAR *szOut, int cchOut, int unitsOverride, int appendUnits, int *unitsUsed) { if ( !unitsOverride) { - if (size<1000) unitsOverride=UNITS_BYTES; - else if (size<100*1024) unitsOverride=UNITS_KBPOINT1; - else if (size<1024*1024) unitsOverride=UNITS_KBPOINT0; - else if (size<1024*1024*1024) unitsOverride=UNITS_MBPOINT2; - else unitsOverride=UNITS_GBPOINT3; + if (size<1000) unitsOverride = UNITS_BYTES; + else if (size<100*1024) unitsOverride = UNITS_KBPOINT1; + else if (size<1024*1024) unitsOverride = UNITS_KBPOINT0; + else if (size<1024*1024*1024) unitsOverride = UNITS_MBPOINT2; + else unitsOverride = UNITS_GBPOINT3; } - if (unitsUsed) *unitsUsed=unitsOverride; + if (unitsUsed) *unitsUsed = unitsOverride; switch(unitsOverride) { case UNITS_BYTES: mir_sntprintf(szOut, cchOut, _T("%u%s%s"), (int)size, appendUnits?_T(" "):_T(""), appendUnits?TranslateT("bytes"):_T("")); break; case UNITS_KBPOINT1: mir_sntprintf(szOut, cchOut, _T("%.1lf%s"), size/1024.0, appendUnits?_T(" KB"):_T("")); break; @@ -190,7 +190,7 @@ void FreeProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *fts) void CopyProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANSFERSTATUS *src) { - *dest=*src; + *dest = *src; if (src->tszCurrentFile) dest->tszCurrentFile = PFTS_StringToTchar(src->flags, src->tszCurrentFile); if (src->ptszFiles) { dest->ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*)*src->totalFiles); @@ -258,21 +258,21 @@ void UpdateProtoFileTransferStatus(PROTOFILETRANSFERSTATUS *dest, PROTOFILETRANS static void RemoveUnreadFileEvents(void) { - DBEVENTINFO dbei={0}; + DBEVENTINFO dbei = {0}; HANDLE hDbEvent, hContact; - dbei.cbSize=sizeof(dbei); - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + dbei.cbSize = sizeof(dbei); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact) { - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); while (hDbEvent) { - dbei.cbBlob=0; + dbei.cbBlob = 0; CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); if ( !(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_FILE) CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)hDbEvent); - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0); + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0); } - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } } diff --git a/src/modules/srfile/file.h b/src/modules/srfile/file.h index b152812467..d814e99ab4 100644 --- a/src/modules/srfile/file.h +++ b/src/modules/srfile/file.h @@ -66,11 +66,11 @@ struct FileDlgData { }; //file.c -#define UNITS_BYTES 1 // 0<=size<1000: "%d bytes" -#define UNITS_KBPOINT1 2 // 1000<=size<100*1024: "%.1f KB" -#define UNITS_KBPOINT0 3 // 100*1024<=size<1024*1024: "%d KB" -#define UNITS_MBPOINT2 4 // 1024*1024<=size: "%.2f MB" -#define UNITS_GBPOINT3 5 // 1024*1024*1024<=size: "%.3f GB" +#define UNITS_BYTES 1 // 0 <= size<1000: "%d bytes" +#define UNITS_KBPOINT1 2 // 1000 <= size<100*1024: "%.1f KB" +#define UNITS_KBPOINT0 3 // 100*1024 <= size<1024*1024: "%d KB" +#define UNITS_MBPOINT2 4 // 1024*1024 <= size: "%.2f MB" +#define UNITS_GBPOINT3 5 // 1024*1024*1024 <= size: "%.3f GB" void GetSensiblyFormattedSize(__int64 size, TCHAR *szOut, int cchOut, int unitsOverride, int appendUnits, int *unitsUsed); void FreeFilesMatrix(TCHAR ***files); //loving that triple indirection diff --git a/src/modules/srfile/fileexistsdlg.cpp b/src/modules/srfile/fileexistsdlg.cpp index 70ad5613b0..3388b692fb 100644 --- a/src/modules/srfile/fileexistsdlg.cpp +++ b/src/modules/srfile/fileexistsdlg.cpp @@ -33,9 +33,9 @@ static void SetControlToUnixTime(HWND hwndDlg, UINT idCtrl, time_t unixTime) SYSTEMTIME st; char szTime[64], szDate[64], szOutput[128]; - liFiletime.QuadPart=(BIGI(11644473600)+(__int64)unixTime)*10000000; - filetime.dwHighDateTime=liFiletime.HighPart; - filetime.dwLowDateTime=liFiletime.LowPart; + liFiletime.QuadPart = (BIGI(11644473600)+(__int64)unixTime)*10000000; + filetime.dwHighDateTime = liFiletime.HighPart; + filetime.dwLowDateTime = liFiletime.LowPart; FileTimeToSystemTime(&filetime, &st); GetTimeFormatA(LOCALE_USER_DEFAULT, 0, &st, NULL, szTime, SIZEOF(szTime)); GetDateFormatA(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate)); @@ -61,41 +61,41 @@ static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd, ITEMIDLIST *pidl, *pidlNext, *pidlFilename; IShellFolder *pFileFolder; - for (pidl=pCurrentIdl;;) { - pidlNext=(ITEMIDLIST*)((PBYTE)pidl+pidl->mkid.cb); + for (pidl = pCurrentIdl;;) { + pidlNext = (ITEMIDLIST*)((PBYTE)pidl+pidl->mkid.cb); if (pidlNext->mkid.cb == 0) { pidlFilename = (ITEMIDLIST*)CoTaskMemAlloc(pidl->mkid.cb+sizeof(pidl->mkid.cb)); CopyMemory(pidlFilename, pidl, pidl->mkid.cb+sizeof(pidl->mkid.cb)); - pidl->mkid.cb=0; + pidl->mkid.cb = 0; break; } - pidl=pidlNext; + pidl = pidlNext; } if (pDesktopFolder->BindToObject(pCurrentIdl, NULL, IID_IShellFolder, (void**)&pFileFolder) == NOERROR) { IContextMenu *pContextMenu; if (pFileFolder->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidlFilename, IID_IContextMenu, NULL, (void**)&pContextMenu) == NOERROR) { switch(cmd) { case C_PROPERTIES: - { CMINVOKECOMMANDINFO ici={0}; - ici.cbSize=sizeof(ici); - ici.hwnd=hwnd; - ici.lpVerb="properties"; - ici.nShow=SW_SHOW; + { CMINVOKECOMMANDINFO ici = {0}; + ici.cbSize = sizeof(ici); + ici.hwnd = hwnd; + ici.lpVerb = "properties"; + ici.nShow = SW_SHOW; pContextMenu->InvokeCommand(&ici); break; } case C_CONTEXTMENU: { HMENU hMenu; - hMenu=CreatePopupMenu(); + hMenu = CreatePopupMenu(); if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT)&0x8000?CMF_EXTENDEDVERBS:0)|CMF_NORMAL))) { int cmd; - cmd=TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL); + cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL); if (cmd) { - CMINVOKECOMMANDINFO ici={0}; - ici.cbSize=sizeof(ici); - ici.hwnd=hwnd; - ici.lpVerb=MAKEINTRESOURCEA(cmd-1000); - ici.nShow=SW_SHOW; + CMINVOKECOMMANDINFO ici = {0}; + ici.cbSize = sizeof(ici); + ici.hwnd = hwnd; + ici.lpVerb = MAKEINTRESOURCEA(cmd-1000); + ici.nShow = SW_SHOW; pContextMenu->InvokeCommand(&ici); } } @@ -126,7 +126,7 @@ static LRESULT CALLBACK IconCtrlSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break; case WM_RBUTTONUP: { POINT pt; - pt.x=(short)LOWORD(lParam); pt.y=(short)HIWORD(lParam); + pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); ClientToScreen(hwnd, &pt); DoAnnoyingShellCommand(hwnd, pft->tszCurrentFile, C_CONTEXTMENU, &pt); return 0; @@ -159,7 +159,7 @@ void __cdecl LoadIconsAndTypesThread(void* param) lstrcpyn(szExtension, pszExtension+1, SIZEOF(szExtension)); else { pszExtension = _T("."); - szExtension[0]='\0'; + szExtension[0] = '\0'; } CharUpper(szExtension); if (fileInfo.szTypeName[0] == '\0') @@ -167,7 +167,7 @@ void __cdecl LoadIconsAndTypesThread(void* param) SetDlgItemText(info->hwndDlg, IDC_EXISTINGTYPE, fileInfo.szTypeName); SetDlgItemText(info->hwndDlg, IDC_NEWTYPE, fileInfo.szTypeName); SendDlgItemMessage(info->hwndDlg, IDC_EXISTINGICON, STM_SETICON, (WPARAM)fileInfo.hIcon, 0); - szIconFile[0]='\0'; + szIconFile[0] = '\0'; if ( !lstrcmp(szExtension, _T("EXE"))) SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("2"), szIconFile, SIZEOF(szIconFile)); else { @@ -177,12 +177,12 @@ void __cdecl LoadIconsAndTypesThread(void* param) if (SRFile_GetRegValue(HKEY_CLASSES_ROOT, szTypeName, NULL, szIconFile, SIZEOF(szIconFile))) { if (_tcsstr(szIconFile, _T("%1"))) SRFile_GetRegValue(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Icons"), _T("0"), szIconFile, SIZEOF(szIconFile)); - else szIconFile[0]='\0'; + else szIconFile[0] = '\0'; } } } if (szIconFile[0]) { TCHAR *pszComma = _tcsrchr(szIconFile, ','); - int iconIndex = (pszComma == NULL) ? 0 :_ttoi(pszComma+1); *pszComma='\0'; + int iconIndex = (pszComma == NULL) ? 0 :_ttoi(pszComma+1); *pszComma = '\0'; HICON hIcon = ExtractIcon(hInst, szIconFile, iconIndex); if (hIcon) fileInfo.hIcon = hIcon; @@ -197,7 +197,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { PROTOFILETRANSFERSTATUS *fts; - fts=(PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + fts = (PROTOFILETRANSFERSTATUS*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch(msg) { case WM_INITDIALOG: { @@ -210,7 +210,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetPropA(hwndDlg, "Miranda.ParentWnd", dat->hwndParent); TranslateDialogDefault(hwndDlg); - fts=(PROTOFILETRANSFERSTATUS*)mir_alloc(sizeof(PROTOFILETRANSFERSTATUS)); + fts = (PROTOFILETRANSFERSTATUS*)mir_alloc(sizeof(PROTOFILETRANSFERSTATUS)); CopyProtoFileTransferStatus(fts, dat->fts); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fts); SetDlgItemText(hwndDlg, IDC_FILENAME, fts->tszCurrentFile); @@ -218,20 +218,20 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM GetSensiblyFormattedSize(fts->currentFileSize, szSize, SIZEOF(szSize), 0, 1, NULL); SetDlgItemText(hwndDlg, IDC_NEWSIZE, szSize); - pfnIconWindowProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EXISTINGICON), GWLP_WNDPROC, (LONG_PTR)IconCtrlSubclassProc); + pfnIconWindowProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EXISTINGICON), GWLP_WNDPROC, (LONG_PTR)IconCtrlSubclassProc); - hwndFocus=GetDlgItem(hwndDlg, IDC_RESUME); + hwndFocus = GetDlgItem(hwndDlg, IDC_RESUME); if (_tstati64(fts->tszCurrentFile, &statbuf) == 0) { SetControlToUnixTime(hwndDlg, IDC_EXISTINGDATE, statbuf.st_mtime); GetSensiblyFormattedSize(statbuf.st_size, szSize, SIZEOF(szSize), 0, 1, NULL); SetDlgItemText(hwndDlg, IDC_EXISTINGSIZE, szSize); if (statbuf.st_size>(int)fts->currentFileSize) { EnableWindow(GetDlgItem(hwndDlg, IDC_RESUME), FALSE); - hwndFocus=GetDlgItem(hwndDlg, IDC_OVERWRITE); + hwndFocus = GetDlgItem(hwndDlg, IDC_OVERWRITE); } } loadiconsstartinfo *lisi = (loadiconsstartinfo*)mir_alloc(sizeof(loadiconsstartinfo)); - lisi->hwndDlg=hwndDlg; + lisi->hwndDlg = hwndDlg; lisi->szFilename = mir_tstrdup(fts->tszCurrentFile); //can be a little slow, so why not? forkthread(LoadIconsAndTypesThread, 0, lisi); @@ -241,7 +241,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } case WM_COMMAND: { - PROTOFILERESUME pfr={0}; + PROTOFILERESUME pfr = {0}; switch(LOWORD(wParam)) { case IDC_OPENFILE: ShellExecute(hwndDlg, NULL, fts->tszCurrentFile, NULL, NULL, SW_SHOW); @@ -261,16 +261,16 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM DoAnnoyingShellCommand(hwndDlg, fts->tszCurrentFile, C_PROPERTIES, NULL); return FALSE; case IDC_RESUME: - pfr.action=FILERESUME_RESUME; + pfr.action = FILERESUME_RESUME; break; case IDC_RESUMEALL: - pfr.action=FILERESUME_RESUMEALL; + pfr.action = FILERESUME_RESUMEALL; break; case IDC_OVERWRITE: - pfr.action=FILERESUME_OVERWRITE; + pfr.action = FILERESUME_OVERWRITE; break; case IDC_OVERWRITEALL: - pfr.action=FILERESUME_OVERWRITEALL; + pfr.action = FILERESUME_OVERWRITEALL; break; case IDC_AUTORENAME: @@ -279,7 +279,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case IDC_SAVEAS: { - OPENFILENAME ofn={0}; + OPENFILENAME ofn = {0}; TCHAR filter[512], *pfilter; TCHAR str[MAX_PATH]; @@ -292,7 +292,7 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM pfilter = filter + _tcslen(filter) + 1; _tcscpy(pfilter, _T("*")); pfilter = pfilter + _tcslen(pfilter) + 1; - *pfilter='\0'; + *pfilter = '\0'; ofn.lpstrFilter = filter; ofn.lpstrFile = str; ofn.nMaxFile = SIZEOF(str); @@ -305,16 +305,16 @@ INT_PTR CALLBACK DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break; } case IDC_SKIP: - pfr.action=FILERESUME_SKIP; + pfr.action = FILERESUME_SKIP; break; case IDCANCEL: - pfr.action=FILERESUME_CANCEL; + pfr.action = FILERESUME_CANCEL; break; default: return FALSE; } { PROTOFILERESUME *pfrCopy; - pfrCopy=(PROTOFILERESUME*)mir_alloc(sizeof(pfr)); + pfrCopy = (PROTOFILERESUME*)mir_alloc(sizeof(pfr)); CopyMemory(pfrCopy, &pfr, sizeof(pfr)); PostMessage((HWND)GetPropA(hwndDlg, "Miranda.ParentWnd"), M_FILEEXISTSDLGREPLY, (WPARAM)mir_tstrdup(fts->tszCurrentFile), (LPARAM)pfrCopy); DestroyWindow(hwndDlg); diff --git a/src/modules/srfile/fileopts.cpp b/src/modules/srfile/fileopts.cpp index b8c8c0133a..2aec9fa5a1 100644 --- a/src/modules/srfile/fileopts.cpp +++ b/src/modules/srfile/fileopts.cpp @@ -35,17 +35,17 @@ struct virusscannerinfo { const TCHAR *szCommandLine; }; -static const struct virusscannerinfo virusScanners[]={ +static const struct virusscannerinfo virusScanners[] = { {_T("Network Associates/McAfee VirusScan"), _T("SOFTWARE\\McAfee\\VirusScan"), _T("Scan32EXE"), _T("\"%s\" %%f /nosplash /comp /autoscan /autoexit /noboot")}, {_T("Dr Solomon's VirusScan (Network Associates)"), _T("SOFTWARE\\Network Associates\\TVD\\VirusScan\\AVConsol\\General"), _T("szScannerExe"), _T("\"%s\" %%f /uinone /noboot /comp /prompt /autoexit")}, {_T("Norton AntiVirus"), _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Navw32.exe"), NULL, _T("\"%s\" %%f /b- /m- /s+ /noresults")}, - {_T("Computer Associates/Inoculate IT"), _T("Software\\Antivirus"), _T("ImageFilename"), _T("\"%s\" %%f /display=progress /exit")}, - {_T("Computer Associates eTrust"), _T("SOFTWARE\\ComputerAssociates\\Anti-Virus\\Resident"), _T("VetPath"), _T("\"%s\" %%f /display=progress /exit")}, + {_T("Computer Associates/Inoculate IT"), _T("Software\\Antivirus"), _T("ImageFilename"), _T("\"%s\" %%f /display = progress /exit")}, + {_T("Computer Associates eTrust"), _T("SOFTWARE\\ComputerAssociates\\Anti-Virus\\Resident"), _T("VetPath"), _T("\"%s\" %%f /display = progress /exit")}, {_T("Kaspersky Anti-Virus"), _T("SOFTWARE\\KasperskyLab\\Components\\101"), _T("EXEName"), _T("\"%s\" /S /Q %%f")}, {_T("Kaspersky Anti-Virus"), _T("SOFTWARE\\KasperskyLab\\SetupFolders"), _T("KAV8"), _T("\"%savp.exe\" SCAN %%f")}, {_T("Kaspersky Anti-Virus"), _T("SOFTWARE\\KasperskyLab\\SetupFolders"), _T("KAV9"), _T("\"%savp.exe\" SCAN %%f")}, - {_T("AntiVir PersonalEdition Classic"), _T("SOFTWARE\\Avira\\AntiVir PersonalEdition Classic"), _T("Path"), _T("\"%savscan.exe\" /GUIMODE=2 /PATH=\"%%f\"")}, - {_T("ESET NOD32 Antivirus"), _T("SOFTWARE\\ESET\\ESET Security\\CurrentVersion\\Info"), _T("InstallDir"), _T("\"%secls.exe\" /log-all /aind /no-boots /adware /sfx /unsafe /unwanted /heur /adv-heur /action=clean \"%%f\"")}, + {_T("AntiVir PersonalEdition Classic"), _T("SOFTWARE\\Avira\\AntiVir PersonalEdition Classic"), _T("Path"), _T("\"%savscan.exe\" /GUIMODE = 2 /PATH = \"%%f\"")}, + {_T("ESET NOD32 Antivirus"), _T("SOFTWARE\\ESET\\ESET Security\\CurrentVersion\\Info"), _T("InstallDir"), _T("\"%secls.exe\" /log-all /aind /no-boots /adware /sfx /unsafe /unwanted /heur /adv-heur /action = clean \"%%f\"")}, }; #define M_UPDATEENABLING (WM_USER+100) @@ -86,7 +86,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L int i, iItem; for (i=0; i < SIZEOF(virusScanners); i++) { if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[i].szExeRegPath, virusScanners[i].szExeRegValue, szScanExe, SIZEOF(szScanExe))) { - iItem=SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); + iItem = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_ADDSTRING, 0, (LPARAM)virusScanners[i].szProductName); SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_SETITEMDATA, iItem, i); } } @@ -118,7 +118,7 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L return TRUE; } case M_UPDATEENABLING: - { int on=!IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER); + { int on = !IsDlgButtonChecked(hwndDlg, IDC_NOSCANNER); EnableWindow(GetDlgItem(hwndDlg, IDC_ST_CMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINE), on); EnableWindow(GetDlgItem(hwndDlg, IDC_SCANCMDLINEBROWSE), on); @@ -129,9 +129,9 @@ static INT_PTR CALLBACK DlgProcFileOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L case M_SCANCMDLINESELCHANGE: { TCHAR str[512]; TCHAR szScanExe[MAX_PATH]; - int iScanner=SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); + int iScanner = SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCANCMDLINE, CB_GETCURSEL, 0, 0), 0); if (iScanner >= SIZEOF(virusScanners) || iScanner<0) break; - str[0]='\0'; + str[0] = '\0'; if (SRFile_GetRegValue(HKEY_LOCAL_MACHINE, virusScanners[iScanner].szExeRegPath, virusScanners[iScanner].szExeRegValue, szScanExe, SIZEOF(szScanExe))) mir_sntprintf(str, SIZEOF(str), virusScanners[iScanner].szCommandLine, szScanExe); SetDlgItemText(hwndDlg, IDC_SCANCMDLINE, str); diff --git a/src/modules/srfile/filerecvdlg.cpp b/src/modules/srfile/filerecvdlg.cpp index 7249291b6d..93ba691266 100644 --- a/src/modules/srfile/filerecvdlg.cpp +++ b/src/modules/srfile/filerecvdlg.cpp @@ -37,10 +37,10 @@ static void GetLowestExistingDirName(const TCHAR *szTestDir, TCHAR *szExistingDi TCHAR *pszLastBackslash; lstrcpyn(szExistingDir, szTestDir, cchExistingDir); - while ((dwAttributes=GetFileAttributes(szExistingDir)) != INVALID_FILE_ATTRIBUTES && !(dwAttributes&FILE_ATTRIBUTE_DIRECTORY)) { - pszLastBackslash=_tcsrchr(szExistingDir, '\\'); - if (pszLastBackslash == NULL) {*szExistingDir='\0'; break;} - *pszLastBackslash='\0'; + while ((dwAttributes = GetFileAttributes(szExistingDir)) != INVALID_FILE_ATTRIBUTES && !(dwAttributes&FILE_ATTRIBUTE_DIRECTORY)) { + pszLastBackslash = _tcsrchr(szExistingDir, '\\'); + if (pszLastBackslash == NULL) {*szExistingDir = '\0'; break;} + *pszLastBackslash = '\0'; } if (szExistingDir[0] == '\0') GetCurrentDirectory(cchExistingDir, szExistingDir); } @@ -50,7 +50,7 @@ void RemoveInvalidFilenameChars(TCHAR *tszString) { size_t i; if (tszString) { - for (i=_tcscspn(tszString, InvalidFilenameChars); tszString[i]; i+=_tcscspn(tszString+i+1, InvalidFilenameChars)+1) + for (i = _tcscspn(tszString, InvalidFilenameChars); tszString[i]; i+=_tcscspn(tszString+i+1, InvalidFilenameChars)+1) if (tszString[i] >= 0) tszString[i] = _T('_'); } @@ -61,7 +61,7 @@ void RemoveInvalidPathChars(TCHAR *tszString) { size_t i; if (tszString) { - for (i=_tcscspn(tszString, InvalidPathChars); tszString[i]; i+=_tcscspn(tszString+i+1, InvalidPathChars)+1) + for (i = _tcscspn(tszString, InvalidPathChars); tszString[i]; i+=_tcscspn(tszString+i+1, InvalidPathChars)+1) if (tszString[i] >= 0) tszString[i] = _T('_'); } @@ -84,17 +84,17 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p int BrowseForFolder(HWND hwnd, TCHAR *szPath) { - BROWSEINFO bi={0}; + BROWSEINFO bi = {0}; LPITEMIDLIST pidlResult; - bi.hwndOwner=hwnd; - bi.pszDisplayName=szPath; - bi.lpszTitle=TranslateT("Select Folder"); - bi.ulFlags=BIF_NEWDIALOGSTYLE|BIF_EDITBOX|BIF_RETURNONLYFSDIRS; // Use this combo instead of BIF_USENEWUI - bi.lpfn=BrowseCallbackProc; - bi.lParam=(LPARAM)szPath; + bi.hwndOwner = hwnd; + bi.pszDisplayName = szPath; + bi.lpszTitle = TranslateT("Select Folder"); + bi.ulFlags = BIF_NEWDIALOGSTYLE|BIF_EDITBOX|BIF_RETURNONLYFSDIRS; // Use this combo instead of BIF_USENEWUI + bi.lpfn = BrowseCallbackProc; + bi.lParam = (LPARAM)szPath; - pidlResult=SHBrowseForFolder(&bi); + pidlResult = SHBrowseForFolder(&bi); if (pidlResult) { SHGetPathFromIDList(pidlResult, szPath); lstrcat(szPath, _T("\\")); @@ -103,7 +103,7 @@ int BrowseForFolder(HWND hwnd, TCHAR *szPath) return pidlResult != NULL; } -static REPLACEVARSARRAY sttVarsToReplace[] = +static REPLACEVARSARRAY sttVarsToReplace[] = { { (TCHAR*)"///", (TCHAR*)"//" }, { (TCHAR*)"//", (TCHAR*)"/" }, @@ -149,13 +149,13 @@ void GetContactReceivedFilesDir(HANDLE hContact, TCHAR *szDir, int cchDir, BOOL if (hContact) { REPLACEVARSDATA dat = { 0 }; REPLACEVARSARRAY rvaVarsToReplace[4]; - rvaVarsToReplace[0].lptzKey = _T("nick"); + rvaVarsToReplace[0].lptzKey = _T("nick"); rvaVarsToReplace[0].lptzValue = mir_tstrdup((TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)); - rvaVarsToReplace[1].lptzKey = _T("userid"); + rvaVarsToReplace[1].lptzKey = _T("userid"); rvaVarsToReplace[1].lptzValue = GetContactID(hContact); - rvaVarsToReplace[2].lptzKey = _T("proto"); + rvaVarsToReplace[2].lptzKey = _T("proto"); rvaVarsToReplace[2].lptzValue = mir_a2t((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); - rvaVarsToReplace[3].lptzKey = NULL; + rvaVarsToReplace[3].lptzKey = NULL; rvaVarsToReplace[3].lptzValue = NULL; for (int i=0; i < (SIZEOF(rvaVarsToReplace)-1);i++) RemoveInvalidFilenameChars(rvaVarsToReplace[i].lptzValue); @@ -204,7 +204,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { struct FileDlgData *dat; - dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + dat = (struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCHAR *contactName; @@ -213,7 +213,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TranslateDialogDefault(hwndDlg); - dat=(struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); + dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = cle->hContact; dat->hDbEvent = cle->hDbEvent; @@ -250,13 +250,13 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent); { - DBEVENTINFO dbei={0}; + DBEVENTINFO dbei = {0}; TCHAR datetimestr[64]; char buf[540]; - dbei.cbSize=sizeof(dbei); - dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0); - dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0); + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei); dat->fs = cle->lParam ? (HANDLE)cle->lParam : (HANDLE)*(PDWORD)dbei.pBlob; lstrcpynA(buf, (char*)dbei.pBlob+4, min(dbei.cbBlob+1, SIZEOF(buf))); @@ -322,15 +322,15 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); case WM_DRAWITEM: - { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; + { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { HICON hIcon; - hIcon=(HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); + hIcon = (HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); DestroyIcon(hIcon); @@ -363,7 +363,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l char idstr[32]; int i; DBVARIANT dbv; - for (i=MAX_MRU_DIRS-2;i>=0;i--) { + for (i = MAX_MRU_DIRS-2;i>=0;i--) { mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i); if (DBGetContactSettingTString(NULL, "SRFile", idstr, &dbv)) continue; mir_snprintf(idstr, SIZEOF(idstr), "MruDir%d", i+1); @@ -393,16 +393,16 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDCANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILEDENYT, (WPARAM)dat->fs, (LPARAM)TranslateT("Cancelled")); - dat->fs=NULL; /* the protocol will free the handle */ + dat->fs = NULL; /* the protocol will free the handle */ DestroyWindow(hwndDlg); break; case IDC_ADD: - { ADDCONTACTSTRUCT acs={0}; + { ADDCONTACTSTRUCT acs = {0}; - acs.handle=dat->hContact; - acs.handleType=HANDLE_CONTACT; - acs.szProto=""; + acs.handle = dat->hContact; + acs.handleType = HANDLE_CONTACT; + acs.szProto = ""; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); @@ -411,7 +411,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_USERMENU: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); diff --git a/src/modules/srfile/filesenddlg.cpp b/src/modules/srfile/filesenddlg.cpp index 92875ddbdb..7614d38a4e 100644 --- a/src/modules/srfile/filesenddlg.cpp +++ b/src/modules/srfile/filesenddlg.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void SetFileListAndSizeControls(HWND hwndDlg, struct FileDlgData *dat) { - int fileCount=0, dirCount=0, totalSize=0, i; + int fileCount = 0, dirCount = 0, totalSize = 0, i; struct _stat statbuf; TCHAR str[64]; @@ -145,7 +145,7 @@ void __cdecl ChooseFilesThread(void* param) else { OPENFILENAME ofn = {0}; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - ofn.hwndOwner = hwndDlg; + ofn.hwndOwner = hwndDlg; lstrcpy(filter, TranslateT("All Files")); lstrcat(filter, _T(" (*)")); pfilter = filter + lstrlen(filter)+1; @@ -193,23 +193,23 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { struct FileDlgData *dat; - dat=(struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + dat = (struct FileDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { - struct FileSendData *fsd=(struct FileSendData*)lParam; + struct FileSendData *fsd = (struct FileSendData*)lParam; - dat=(struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); + dat = (struct FileDlgData*)mir_calloc(sizeof(struct FileDlgData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->hContact=fsd->hContact; - dat->send=1; - dat->hPreshutdownEvent=HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); - dat->fs=NULL; - dat->dwTicks=GetTickCount(); + dat->hContact = fsd->hContact; + dat->send = 1; + dat->hPreshutdownEvent = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, M_PRESHUTDOWN); + dat->fs = NULL; + dat->dwTicks = GetTickCount(); TranslateDialogDefault(hwndDlg); EnumChildWindows(hwndDlg, ClipSiblingsChildEnumProc, 0); - OldSendEditProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); + OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MSG), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_FILE); Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details")); @@ -220,11 +220,11 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (fsd->ppFiles != NULL && fsd->ppFiles[0] != NULL) { int totalCount, i; - for (totalCount=0;fsd->ppFiles[totalCount];totalCount++); + for (totalCount = 0;fsd->ppFiles[totalCount];totalCount++); dat->files = (TCHAR**)mir_alloc(sizeof(TCHAR*)*(totalCount+1)); // Leaks for (i=0;ifiles[i] = mir_tstrdup(fsd->ppFiles[i]); - dat->files[totalCount]=NULL; + dat->files[totalCount] = NULL; SetFileListAndSizeControls(hwndDlg, dat); } { @@ -232,7 +232,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TCHAR* contactName = cli.pfnGetContactDisplayName(dat->hContact, 0); SetDlgItemText(hwndDlg, IDC_TO, contactName); - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { CONTACTINFO ci; int hasName = 0; @@ -264,7 +264,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (fsd->ppFiles == NULL) { EnableWindow(hwndDlg, FALSE); - dat->closeIfFileChooseCancelled=1; + dat->closeIfFileChooseCancelled = 1; PostMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_CHOOSE, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDC_CHOOSE)); } return TRUE; @@ -275,11 +275,11 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case WM_DRAWITEM: { - LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { HICON hIcon = (HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); if (hIcon) { @@ -327,7 +327,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_USERMENU: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp index 99eed2c3d9..3648e2306e 100644 --- a/src/modules/srfile/filexferdlg.cpp +++ b/src/modules/srfile/filexferdlg.cpp @@ -86,8 +86,8 @@ void FillSendData(FileDlgData* dat, DBEVENTINFO& dbei) dbei.flags |= DBEF_UTF; dbei.cbBlob = sizeof(DWORD) + lstrlenA(szFileNames)+lstrlenA(szMsg)+2; - dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); - *(PDWORD)dbei.pBlob=0; + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); + *(PDWORD)dbei.pBlob = 0; lstrcpyA((char*)dbei.pBlob+sizeof(DWORD), szFileNames); lstrcpyA((char*)dbei.pBlob+sizeof(DWORD)+lstrlenA(szFileNames)+1, szMsg); @@ -98,7 +98,7 @@ void FillSendData(FileDlgData* dat, DBEVENTINFO& dbei) static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) { PROCESS_INFORMATION pi; - STARTUPINFO si={0}; + STARTUPINFO si = {0}; DBVARIANT dbv; TCHAR szCmdLine[768]; @@ -107,7 +107,7 @@ static void __cdecl RunVirusScannerThread(struct virusscanthreadstartinfo *info) if (dbv.ptszVal[0]) { TCHAR *pszReplace; - si.cb=sizeof(si); + si.cb = sizeof(si); pszReplace = _tcsstr(dbv.ptszVal, _T("%f")); if (pszReplace) { @@ -163,7 +163,7 @@ static void SetFilenameControls(HWND hwndDlg, struct FileDlgData *dat, PROTOFILE lstrcpyn(msg, cli.pfnGetContactDisplayName(fts->hContact, 0), SIZEOF(msg)); HICON hIcon = LoadSkinIcon(SKINICON_OTHER_DOWNARROW); dat->hIcon = CopyIcon(hIcon); - IconLib_ReleaseIcon(hIcon, NULL); + IcoLib_ReleaseIcon(hIcon, NULL); } mir_free(fnbuf); @@ -239,38 +239,38 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR TranslateDialogDefault(hwndDlg); dat = (FileDlgData*)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->hNotifyEvent=HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_RECVEVENT); + dat->hNotifyEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_RECVEVENT); dat->transferStatus.currentFileNumber = -1; if (dat->send) { - dat->fs=(HANDLE)CallContactService(dat->hContact, PSS_FILET, (WPARAM)dat->szMsg, (LPARAM)dat->files); + dat->fs = (HANDLE)CallContactService(dat->hContact, PSS_FILET, (WPARAM)dat->szMsg, (LPARAM)dat->files); SetFtStatus(hwndDlg, LPGENT("Request sent, waiting for acceptance..."), FTS_TEXT); SetOpenFileButtonStyle(GetDlgItem(hwndDlg, IDC_OPENFILE), 1); - dat->waitingForAcceptance=1; + dat->waitingForAcceptance = 1; // hide "open" button since it may cause potential access violations... ShowWindow(GetDlgItem(hwndDlg, IDC_OPENFILE), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_OPENFOLDER), SW_HIDE); } else { //recv CreateDirectoryTreeT(dat->szSavePath); - dat->fs=(HANDLE)CallContactService(dat->hContact, PSS_FILEALLOWT, (WPARAM)dat->fs, (LPARAM)dat->szSavePath); + dat->fs = (HANDLE)CallContactService(dat->hContact, PSS_FILEALLOWT, (WPARAM)dat->fs, (LPARAM)dat->szSavePath); dat->transferStatus.tszWorkingDir = mir_tstrdup(dat->szSavePath); - if (DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) dat->resumeBehaviour=FILERESUME_ASK; - else dat->resumeBehaviour=DBGetContactSettingByte(NULL, "SRFile", "IfExists", FILERESUME_ASK); + if (DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) dat->resumeBehaviour = FILERESUME_ASK; + else dat->resumeBehaviour = DBGetContactSettingByte(NULL, "SRFile", "IfExists", FILERESUME_ASK); SetFtStatus(hwndDlg, LPGENT("Waiting for connection..."), FTS_TEXT); } { /* check we actually got an fs handle back from the protocol */ if ( !dat->fs) { SetFtStatus(hwndDlg, LPGENT("Unable to initiate transfer."), FTS_TEXT); - dat->waitingForAcceptance=0; + dat->waitingForAcceptance = 0; } } { LOGFONT lf; HFONT hFont; - hFont=(HFONT)SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_GETFONT, 0, 0); + hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_GETFONT, 0, 0); GetObject(hFont, sizeof(lf), &lf); - lf.lfWeight=FW_BOLD; - hFont=CreateFontIndirect(&lf); + lf.lfWeight = FW_BOLD; + hFont = CreateFontIndirect(&lf); SendDlgItemMessage(hwndDlg, IDC_CONTACTNAME, WM_SETFONT, (WPARAM)hFont, 0); } @@ -301,7 +301,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return TRUE; case WM_TIMER: MoveMemory(dat->bytesRecvedHistory+1, dat->bytesRecvedHistory, sizeof(dat->bytesRecvedHistory)-sizeof(dat->bytesRecvedHistory[0])); - dat->bytesRecvedHistory[0]=dat->transferStatus.totalProgress; + dat->bytesRecvedHistory[0] = dat->transferStatus.totalProgress; if (dat->bytesRecvedHistorySize < SIZEOF(dat->bytesRecvedHistory)) dat->bytesRecvedHistorySize++; @@ -320,7 +320,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime)); } if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) { - li.QuadPart=BIGI(10000000)*(dat->transferStatus.totalBytes-dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]); + li.QuadPart = BIGI(10000000)*(dat->transferStatus.totalBytes-dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]); ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart; FileTimeToSystemTime(&ft, &st); GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime)); @@ -359,7 +359,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_CONTACT: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); @@ -400,7 +400,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR else files = dat->files; else - files=dat->files; + files = dat->files; hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1, TranslateT("Open folder")); @@ -417,7 +417,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR limit = dat->transferStatus.currentFileNumber; // Loop over all transfered files and add them to the menu - for (i = 0; i < limit; i++) { + for (i=0; i < limit; i++) { pszFilename = _tcsrchr(files[i], '\\'); if (pszFilename == NULL) pszFilename = files[i]; @@ -429,10 +429,10 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR pszNewFileName = (TCHAR*)mir_alloc(cbFileNameLen*2*sizeof(TCHAR)); TCHAR *p = pszNewFileName; - for (size_t pszlen=0; pszlen < cbFileNameLen; pszlen++) { - *p++ = pszFilename[pszlen]; + for (size_t pszlen = 0; pszlen < cbFileNameLen; pszlen++) { + *p++=pszFilename[pszlen]; if (pszFilename[pszlen] == '&') - *p++ = '&'; + *p++='&'; } *p = '\0'; AppendMenu(hMenu, MF_STRING, i+10, pszNewFileName); @@ -467,33 +467,33 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } break; case M_FILEEXISTSDLGREPLY: - { PROTOFILERESUME *pfr=(PROTOFILERESUME*)lParam; - TCHAR *szOriginalFilename=(TCHAR*)wParam; - char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + { PROTOFILERESUME *pfr = (PROTOFILERESUME*)lParam; + TCHAR *szOriginalFilename = (TCHAR*)wParam; + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); EnableWindow(hwndDlg, TRUE); switch(pfr->action) { case FILERESUME_CANCEL: if (dat->fs) CallContactService(dat->hContact, PSS_FILECANCEL, (WPARAM)dat->fs, 0); - dat->fs=NULL; + dat->fs = NULL; mir_free(szOriginalFilename); if (pfr->szFilename) mir_free((char*)pfr->szFilename); mir_free(pfr); return 0; case FILERESUME_RESUMEALL: case FILERESUME_OVERWRITEALL: - dat->resumeBehaviour=pfr->action; + dat->resumeBehaviour = pfr->action; pfr->action&=~FILERESUMEF_ALL; break; case FILERESUME_RENAMEALL: - pfr->action=FILERESUME_RENAME; + pfr->action = FILERESUME_RENAME; { TCHAR *pszExtension, *pszFilename; int i; - if ((pszFilename = _tcsrchr(szOriginalFilename, '\\')) == NULL) pszFilename=szOriginalFilename; - if ((pszExtension = _tcsrchr(pszFilename+1, '.')) == NULL) pszExtension=pszFilename+lstrlen(pszFilename); + if ((pszFilename = _tcsrchr(szOriginalFilename, '\\')) == NULL) pszFilename = szOriginalFilename; + if ((pszExtension = _tcsrchr(pszFilename+1, '.')) == NULL) pszExtension = pszFilename+lstrlen(pszFilename); if (pfr->szFilename) mir_free((TCHAR*)pfr->szFilename); pfr->szFilename = (TCHAR*)mir_alloc(sizeof(TCHAR)*((pszExtension-szOriginalFilename)+21+lstrlen(pszExtension))); - for (i=1;;i++) { + for (i = 1;;i++) { _stprintf((TCHAR*)pfr->szFilename, _T("%.*s (%u)%s"), pszExtension-szOriginalFilename, szOriginalFilename, i, pszExtension); if (_taccess(pfr->szFilename, 0) != 0) break; @@ -508,14 +508,14 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; } case HM_RECVEVENT: - { ACKDATA *ack=(ACKDATA*)lParam; + { ACKDATA *ack = (ACKDATA*)lParam; if (ack->hProcess != dat->fs) break; /* icq abuses this sometimes */ if (ack->hContact != dat->hContact) break; if (ack->type != ACKTYPE_FILE) break; if (dat->waitingForAcceptance) { SetTimer(hwndDlg, 1, 1000, NULL); - dat->waitingForAcceptance=0; + dat->waitingForAcceptance = 0; } switch(ack->result) { case ACKRESULT_SENTREQUEST: SetFtStatus(hwndDlg, LPGENT("Decision sent"), FTS_TEXT); break; @@ -534,7 +534,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR PostMessage(hwndDlg, M_VIRUSSCANDONE, dat->transferStatus.currentFileNumber, 0); else { virusscanthreadstartinfo *vstsi; - vstsi=(struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); + vstsi = (struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); vstsi->hwndReply = hwndDlg; vstsi->szFile = mir_tstrdup(dat->files[dat->transferStatus.currentFileNumber]); vstsi->returnCode = dat->transferStatus.currentFileNumber; @@ -561,7 +561,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } else { PROTOFILERESUME *pfr; - pfr=(PROTOFILERESUME*)mir_alloc(sizeof(PROTOFILERESUME)); + pfr = (PROTOFILERESUME*)mir_alloc(sizeof(PROTOFILERESUME)); pfr->action = dat->resumeBehaviour; pfr->szFilename = NULL; PostMessage(hwndDlg, M_FILEEXISTSDLGREPLY, (WPARAM)mir_tstrdup(fts->tszCurrentFile), (LPARAM)pfr); @@ -571,12 +571,12 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } case ACKRESULT_DATA: { - PROTOFILETRANSFERSTATUS *fts=(PROTOFILETRANSFERSTATUS*)ack->lParam; + PROTOFILETRANSFERSTATUS *fts = (PROTOFILETRANSFERSTATUS*)ack->lParam; TCHAR str[64], str2[64], szSizeDone[32], szSizeTotal[32];//, *contactName; int units; if (dat->fileVirusScanned == NULL) - dat->fileVirusScanned=(int*)mir_calloc(sizeof(int) * fts->totalFiles); + dat->fileVirusScanned = (int*)mir_calloc(sizeof(int) * fts->totalFiles); // This needs to be here - otherwise we get holes in the files array if ( !dat->send) { @@ -632,31 +632,31 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close")); if (dat->hNotifyEvent) UnhookEvent(dat->hNotifyEvent); - dat->hNotifyEvent=NULL; + dat->hNotifyEvent = NULL; if (ack->result == ACKRESULT_DENIED) { - dat->fs=NULL; /* protocol will free structure */ + dat->fs = NULL; /* protocol will free structure */ SkinPlaySound("FileDenied"); SetFtStatus(hwndDlg, LPGENT("File transfer denied"), FTS_TEXT); } else if (ack->result == ACKRESULT_FAILED) { - dat->fs=NULL; /* protocol will free structure */ + dat->fs = NULL; /* protocol will free structure */ SkinPlaySound("FileFailed"); SetFtStatus(hwndDlg, LPGENT("File transfer failed"), FTS_TEXT); } else { SkinPlaySound("FileDone"); if (dat->send) { - dat->fs=NULL; /* protocol will free structure */ + dat->fs = NULL; /* protocol will free structure */ SetFtStatus(hwndDlg, LPGENT("Transfer completed."), FTS_TEXT); - DBEVENTINFO dbei={0}; + DBEVENTINFO dbei = {0}; FillSendData(dat, dbei); CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei); if (dbei.pBlob) mir_free(dbei.pBlob); - dat->files=NULL; //protocol library frees this + dat->files = NULL; //protocol library frees this } else { SetFtStatus(hwndDlg, @@ -665,17 +665,17 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR LPGENT("Transfer completed, open folder."), FTS_OPEN); - int useScanner=DBGetContactSettingByte(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE); + int useScanner = DBGetContactSettingByte(NULL, "SRFile", "UseScanner", VIRUSSCAN_DISABLE); if (useScanner != VIRUSSCAN_DISABLE) { struct virusscanthreadstartinfo *vstsi; - vstsi=(struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); - vstsi->hwndReply=hwndDlg; + vstsi = (struct virusscanthreadstartinfo*)mir_alloc(sizeof(struct virusscanthreadstartinfo)); + vstsi->hwndReply = hwndDlg; if (useScanner == VIRUSSCAN_DURINGDL) { - vstsi->returnCode=dat->transferStatus.currentFileNumber; + vstsi->returnCode = dat->transferStatus.currentFileNumber; if (GetFileAttributes(dat->files[dat->transferStatus.currentFileNumber])&FILE_ATTRIBUTE_DIRECTORY) { PostMessage(hwndDlg, M_VIRUSSCANDONE, vstsi->returnCode, 0); mir_free(vstsi); - vstsi=NULL; + vstsi = NULL; } else vstsi->szFile = mir_tstrdup(dat->files[dat->transferStatus.currentFileNumber]); } @@ -687,9 +687,9 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (vstsi) forkthread((void (*)(void*))RunVirusScannerThread, 0, vstsi); } - else dat->fs=NULL; /* protocol will free structure */ + else dat->fs = NULL; /* protocol will free structure */ - dat->transferStatus.currentFileNumber=dat->transferStatus.totalFiles; + dat->transferStatus.currentFileNumber = dat->transferStatus.totalFiles; } // else dat->send } // else ack->result @@ -701,29 +701,29 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } // switch ack->result } break; // case HM_RECVEVENT case M_VIRUSSCANDONE: - { int done=1, i; + { int done = 1, i; if ((int)wParam == -1) { - for (i=0;itransferStatus.totalFiles;i++) dat->fileVirusScanned[i]=1; + for (i=0;itransferStatus.totalFiles;i++) dat->fileVirusScanned[i] = 1; } else { - dat->fileVirusScanned[wParam]=1; - for (i=0;itransferStatus.totalFiles;i++) if ( !dat->fileVirusScanned[i]) {done=0; break;} + dat->fileVirusScanned[wParam] = 1; + for (i=0;itransferStatus.totalFiles;i++) if ( !dat->fileVirusScanned[i]) {done = 0; break;} } if (done) { - dat->fs=NULL; /* protocol will free structure */ + dat->fs = NULL; /* protocol will free structure */ SetFtStatus(hwndDlg, LPGENT("Transfer and virus scan complete"), FTS_TEXT); } break; } case WM_SIZE: { - UTILRESIZEDIALOG urd={0}; - urd.cbSize=sizeof(urd); - urd.hwndDlg=hwndDlg; - urd.hInstance=hInst; - urd.lpTemplate=MAKEINTRESOURCEA(IDD_FILETRANSFERINFO); - urd.pfnResizer=FileTransferDlgResizer; + UTILRESIZEDIALOG urd = {0}; + urd.cbSize = sizeof(urd); + urd.hwndDlg = hwndDlg; + urd.hInstance = hInst; + urd.lpTemplate = MAKEINTRESOURCEA(IDD_FILETRANSFERINFO); + urd.pfnResizer = FileTransferDlgResizer; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); RedrawWindow(GetDlgItem(hwndDlg, IDC_ALLTRANSFERRED), NULL, NULL, RDW_INVALIDATE|RDW_NOERASE); diff --git a/src/modules/srfile/ftmanager.cpp b/src/modules/srfile/ftmanager.cpp index 7e0dcfc9cc..567e038fc6 100644 --- a/src/modules/srfile/ftmanager.cpp +++ b/src/modules/srfile/ftmanager.cpp @@ -78,7 +78,7 @@ static void LayoutTransfers(HWND hwnd, struct TFtPageData *dat) hdwp = BeginDeferWindowPos(dat->wnds->realCount); top -= dat->scrollPos; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) { int height = dat->wnds->items[i]->rc.bottom - dat->wnds->items[i]->rc.top; hdwp = DeferWindowPos(hdwp, dat->wnds->items[i]->hwnd, NULL, 0, top, rc.right, height, SWP_NOZORDER); @@ -138,7 +138,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_FT_RESIZE: { int i; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) if (dat->wnds->items[i]->hwnd == (HWND)lParam) { GetWindowRect(dat->wnds->items[i]->hwnd, &dat->wnds->items[i]->rc); @@ -151,7 +151,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_FT_REMOVE: { int i; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) if (dat->wnds->items[i]->hwnd == (HWND)lParam) { mir_free(dat->wnds->items[i]); @@ -165,7 +165,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_FT_COMPLETED: { //wParam: { ACKRESULT_SUCCESS | ACKRESULT_FAILED | ACKRESULT_DENIED } dat->runningCount--; - int i = 0; + int i=0; while (i < dat->wnds->realCount) { // no error when canceling (WM_FT_REMOVE is send first, check if hwnd is still registered) @@ -187,7 +187,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_FT_CLEANUP: { int i; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) SendMessage(dat->wnds->items[i]->hwnd, WM_FT_CLEANUP, wParam, lParam); break; } @@ -205,7 +205,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA { int i, nScrollLines = 0; SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, (void*)&nScrollLines, 0); - for (i = 0; i < (nScrollLines + 1) / 2; i++) + for (i=0; i < (nScrollLines + 1) / 2; i++) SendMessage(hwnd, WM_VSCROLL, (zDelta < 0) ? SB_LINEDOWN : SB_LINEUP, 0); } @@ -250,7 +250,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case M_PRESHUTDOWN: { int i; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) PostMessage(dat->wnds->items[i]->hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, BN_CLICKED), 0); break; } @@ -258,7 +258,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_DESTROY: { int i; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) mir_free(dat->wnds->items[i]); List_Destroy((SortedList *)dat->wnds); mir_free(dat->wnds); @@ -270,7 +270,7 @@ static INT_PTR CALLBACK FtMgrPageDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPA { int i; TFtProgressData * prg = (TFtProgressData *)wParam; - for (i = 0; i < dat->wnds->realCount; ++i) + for (i=0; i < dat->wnds->realCount; ++i) { struct FileDlgData *trdat = (struct FileDlgData *)GetWindowLongPtr(dat->wnds->items[i]->hwnd, GWLP_USERDATA); if (trdat->transferStatus.totalBytes && trdat->fs && !trdat->send && (trdat->transferStatus.totalBytes == trdat->transferStatus.totalProgress)) @@ -327,7 +327,7 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM // Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); SAVEWINDOWPOS swp; - swp.hwnd=hwnd; swp.hContact=NULL; swp.szModule="SRFile"; swp.szNamePrefix="FtMgrDlg_"; + swp.hwnd = hwnd; swp.hContact = NULL; swp.szModule = "SRFile"; swp.szNamePrefix = "FtMgrDlg_"; CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp); // Fall through to setup initial placement diff --git a/src/modules/srurl/url.cpp b/src/modules/srurl/url.cpp index fe790330c0..ba1b025296 100644 --- a/src/modules/srurl/url.cpp +++ b/src/modules/srurl/url.cpp @@ -45,21 +45,21 @@ static int UrlEventAdded(WPARAM wParam, LPARAM lParam) TCHAR szTooltip[256]; ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - dbei.cbBlob=0; + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = 0; CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei); if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_URL) return 0; SkinPlaySound("RecvUrl"); ZeroMemory(&cle, sizeof(cle)); - cle.cbSize=sizeof(cle); + cle.cbSize = sizeof(cle); cle.flags = CLEF_TCHAR; - cle.hContact=(HANDLE)wParam; - cle.hDbEvent=(HANDLE)lParam; + cle.hContact = (HANDLE)wParam; + cle.hDbEvent = (HANDLE)lParam; cle.hIcon = LoadSkinIcon(SKINICON_EVENT_URL); - cle.pszService="SRUrl/ReadUrl"; + cle.pszService = "SRUrl/ReadUrl"; mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("URL from %s"), cli.pfnGetContactDisplayName((HANDLE)wParam, 0)); - cle.ptszTooltip=szTooltip; + cle.ptszTooltip = szTooltip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); return 0; } @@ -72,42 +72,42 @@ static INT_PTR SendUrlCommand(WPARAM wParam, LPARAM) static void RestoreUnreadUrlAlerts(void) { - CLISTEVENT cle={0}; - DBEVENTINFO dbei={0}; + CLISTEVENT cle = {0}; + DBEVENTINFO dbei = {0}; TCHAR toolTip[256]; HANDLE hDbEvent, hContact; - dbei.cbSize=sizeof(dbei); - cle.cbSize=sizeof(cle); + dbei.cbSize = sizeof(dbei); + cle.cbSize = sizeof(cle); cle.hIcon = LoadSkinIcon(SKINICON_EVENT_URL); - cle.pszService="SRUrl/ReadUrl"; + cle.pszService = "SRUrl/ReadUrl"; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact) { - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); while (hDbEvent) { - dbei.cbBlob=0; + dbei.cbBlob = 0; CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); if ( !(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_URL) { - cle.hContact=hContact; - cle.hDbEvent=hDbEvent; + cle.hContact = hContact; + cle.hDbEvent = hDbEvent; cle.flags = CLEF_TCHAR; mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("URL from %s"), cli.pfnGetContactDisplayName(hContact, 0)); - cle.ptszTooltip=toolTip; + cle.ptszTooltip = toolTip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } - hDbEvent=(HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0); + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0); } - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } } static int ContactSettingChanged(WPARAM wParam, LPARAM lParam) { - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (lstrcmpA(cws->szModule, "CList") && (szProto == NULL || lstrcmpA(cws->szModule, szProto))) return 0; WindowList_Broadcast(hUrlWindowList, DM_UPDATETITLE, 0, 0); return 0; @@ -168,7 +168,7 @@ int UrlContactDeleted(WPARAM wParam, LPARAM) int LoadSendRecvUrlModule(void) { - hUrlWindowList=(HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + hUrlWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); HookEvent(ME_SYSTEM_MODULESLOADED, SRUrlModulesLoaded); HookEvent(ME_DB_EVENT_ADDED, UrlEventAdded); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SRUrlPreBuildMenu); diff --git a/src/modules/srurl/urldialogs.cpp b/src/modules/srurl/urldialogs.cpp index 6fb5e7f33a..1198b70bef 100644 --- a/src/modules/srurl/urldialogs.cpp +++ b/src/modules/srurl/urldialogs.cpp @@ -89,7 +89,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View User's History")); Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu")); - dat=(struct UrlRcvData*)mir_alloc(sizeof(struct UrlRcvData)); + dat = (struct UrlRcvData*)mir_alloc(sizeof(struct UrlRcvData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->hContact = ((CLISTEVENT*)lParam)->hContact; @@ -102,9 +102,9 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP TCHAR msg[128]; ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - dbei.cbBlob=CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0); - dbei.pBlob=(PBYTE)mir_alloc(dbei.cbBlob); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0); + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei); SetDlgItemTextA(hwndDlg, IDC_URL, (char*)dbei.pBlob); SetDlgItemTextA(hwndDlg, IDC_MSG, (char*)dbei.pBlob+lstrlenA((char*)dbei.pBlob)+1); @@ -137,11 +137,11 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_DRAWITEM: { - LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); if (szProto) { HICON hIcon; @@ -166,8 +166,8 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP RECT rc; char url[256]; - hMenu=LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); - hSubMenu=GetSubMenu(hMenu, 6); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); GetWindowRect((HWND)lParam, &rc); GetDlgItemTextA(hwndDlg, IDC_URL, url, SIZEOF(url)); @@ -182,7 +182,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP { HGLOBAL hData; if ( !OpenClipboard(hwndDlg)) break; EmptyClipboard(); - hData=GlobalAlloc(GMEM_MOVEABLE, lstrlenA(url)+1); + hData = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(url)+1); lstrcpyA((char*)GlobalLock(hData), url); GlobalUnlock(hData); SetClipboardData(CF_TEXT, hData); @@ -197,7 +197,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case IDC_USERMENU: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); @@ -214,11 +214,11 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case IDC_ADD: { - ADDCONTACTSTRUCT acs={0}; + ADDCONTACTSTRUCT acs = {0}; - acs.handle=dat->hContact; - acs.handleType=HANDLE_CONTACT; - acs.szProto=0; + acs.handle = dat->hContact; + acs.handleType = HANDLE_CONTACT; + acs.szProto = 0; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); } if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) { @@ -260,8 +260,8 @@ static LRESULT DdeMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) switch(msg) { case WM_DDE_ACK: - ddeAcked=1; - hwndDde=(HWND)wParam; + ddeAcked = 1; + hwndDde = (HWND)wParam; break; case WM_DDE_DATA: @@ -288,20 +288,20 @@ static HGLOBAL DoDdeRequest(const char *szItemName, HWND hwndDlg) DWORD timeoutTick, thisTick; MSG msg; - hSzItemName=GlobalAddAtomA(szItemName); + hSzItemName = GlobalAddAtomA(szItemName); if ( !PostMessage(hwndDde, WM_DDE_REQUEST, (WPARAM)hwndDlg, MAKELPARAM(CF_TEXT, hSzItemName))) { GlobalDeleteAtom(hSzItemName); return NULL; } - timeoutTick=GetTickCount()+5000; - ddeData=0; ddeAcked=0; + timeoutTick = GetTickCount()+5000; + ddeData = 0; ddeAcked = 0; do { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (ddeData || ddeAcked) break; - thisTick=GetTickCount(); + thisTick = GetTickCount(); if (thisTick>timeoutTick) break; } while (MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutTick-thisTick, QS_ALLINPUT) == WAIT_OBJECT_0); @@ -317,7 +317,7 @@ static HGLOBAL DoDdeRequest(const char *szItemName, HWND hwndDlg) static void FreeDdeRequestData(HGLOBAL hData) { DDEDATA *data; - data=(DDEDATA*)GlobalLock(hData); + data = (DDEDATA*)GlobalLock(hData); if (data->fRelease) { GlobalUnlock(hData); GlobalFree(hData); @@ -331,36 +331,36 @@ static void AddBrowserPageToCombo(char *url, HWND hwndCombo) if (url[0] != '"') return; url++; - title=strchr(url, '"'); + title = strchr(url, '"'); if (title == NULL) return; - *title='\0'; title++; + *title = '\0'; title++; if (*title) { title+=2; - frame=strchr(title, '"'); + frame = strchr(title, '"'); if (frame == NULL) return; - *frame='\0'; frame++; + *frame = '\0'; frame++; if (*frame) { frame+=2; - end=strchr(frame, '"'); + end = strchr(frame, '"'); if (end == NULL) return; - *end='\0'; + *end = '\0'; } - else frame=NULL; + else frame = NULL; } - else title=frame=NULL; + else title = frame = NULL; if (frame == NULL || *frame == 0) { char *szItemData; int i; char szExistingUrl[1024]; - for (i=SendMessage(hwndCombo, CB_GETCOUNT, 0, 0)-1;i>=0;i--) { + for (i = SendMessage(hwndCombo, CB_GETCOUNT, 0, 0)-1;i>=0;i--) { if (SendMessage(hwndCombo, CB_GETLBTEXTLEN, i, 0) >= SIZEOF(szExistingUrl)) continue; SendMessageA(hwndCombo, CB_GETLBTEXT, i, (LPARAM)szExistingUrl); if ( !lstrcmpA(szExistingUrl, url)) return; } - i=SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LPARAM)url); - szItemData=mir_strdup(title); + i = SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LPARAM)url); + szItemData = mir_strdup(title); SendMessage(hwndCombo, CB_SETITEMDATA, i, (LPARAM)szItemData); } } @@ -376,34 +376,34 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW DDEDATA *data; int dataLength; - hSzBrowser=GlobalAddAtomA(szBrowser); + hSzBrowser = GlobalAddAtomA(szBrowser); - hSzTopic=GlobalAddAtomA("WWW_ListWindows"); - ddeAcked=0; + hSzTopic = GlobalAddAtomA("WWW_ListWindows"); + ddeAcked = 0; if ( !SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDlg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, (PDWORD_PTR)&dwResult) || !ddeAcked) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; } - hData=DoDdeRequest("WWW_ListWindows", hwndDlg); + hData = DoDdeRequest("WWW_ListWindows", hwndDlg); if (hData == NULL) { GlobalDeleteAtom(hSzTopic); GlobalDeleteAtom(hSzBrowser); return; } - dataLength=GlobalSize(hData)-offsetof(DDEDATA, Value); - data=(DDEDATA*)GlobalLock(hData); - windowCount=dataLength/sizeof(DWORD); - windowId=(PDWORD)mir_alloc(sizeof(DWORD)*windowCount); + dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); + data = (DDEDATA*)GlobalLock(hData); + windowCount = dataLength/sizeof(DWORD); + windowId = (PDWORD)mir_alloc(sizeof(DWORD)*windowCount); memcpy(windowId, data->Value, windowCount*sizeof(DWORD)); GlobalUnlock(hData); FreeDdeRequestData(hData); PostMessage(hwndDde, WM_DDE_TERMINATE, (WPARAM)hwndDlg, 0); GlobalDeleteAtom(hSzTopic); - hSzTopic=GlobalAddAtomA("WWW_GetWindowInfo"); - ddeAcked=0; + hSzTopic = GlobalAddAtomA("WWW_GetWindowInfo"); + ddeAcked = 0; if ( !SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDlg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, (PDWORD_PTR)&dwResult) || !ddeAcked) { GlobalDeleteAtom(hSzTopic); @@ -415,11 +415,11 @@ static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HW if (windowId[i] == 0) break; { char str[16]; mir_snprintf(str, SIZEOF(str), "%d", windowId[i]); - hData=DoDdeRequest(str, hwndDlg); + hData = DoDdeRequest(str, hwndDlg); } if (hData != NULL) { - dataLength=GlobalSize(hData)-offsetof(DDEDATA, Value); - data=(DDEDATA*)GlobalLock(hData); + dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); + data = (DDEDATA*)GlobalLock(hData); AddBrowserPageToCombo((char*)data->Value, hwndCombo); GlobalUnlock(hData); FreeDdeRequestData(hData); @@ -471,12 +471,12 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu")); SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0); - dat=(struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData)); + dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData)); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->hContact=(HANDLE)lParam; - dat->hAckEvent=NULL; - dat->hSendId=NULL; - dat->sendBuffer=NULL; + dat->hContact = (HANDLE)lParam; + dat->hAckEvent = NULL; + dat->hSendId = NULL; + dat->sendBuffer = NULL; WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); { @@ -489,8 +489,8 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE); Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send"); - OldSendEditProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); - OldSendEditProc=(WNDPROC)SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); + OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); + OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); // From message dlg if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) @@ -545,22 +545,22 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP char *body, *url; int bodySize, urlSize; - urlSize=GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1; - url=(char*)mir_alloc(urlSize); + urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1; + url = (char*)mir_alloc(urlSize); GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize); if (url[0] == 0) { mir_free(url); break; } - bodySize=GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1; - body=(char*)mir_alloc(bodySize); + bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1; + body = (char*)mir_alloc(bodySize); GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize); - dat->sendBuffer=(char*)mir_realloc(dat->sendBuffer, lstrlenA(url)+lstrlenA(body)+2); + dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, lstrlenA(url)+lstrlenA(body)+2); lstrcpyA(dat->sendBuffer, url); lstrcpyA(dat->sendBuffer+lstrlenA(url)+1, body); - dat->hAckEvent=HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); - dat->hSendId=(HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer); + dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); + dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer); mir_free(url); mir_free(body); @@ -580,10 +580,10 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (HIWORD(wParam) == CBN_SELCHANGE) { int i, urlSize; char *title; - i=SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0); - title=(char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0); + i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0); + title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0); SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title); - urlSize=SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0); + urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0); EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); } else if (HIWORD(wParam) == CBN_EDITCHANGE) { @@ -593,7 +593,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case IDC_USERMENU: { RECT rc; - HMENU hMenu=(HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); @@ -606,11 +606,11 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); break; case IDC_ADD: - { ADDCONTACTSTRUCT acs={0}; + { ADDCONTACTSTRUCT acs = {0}; - acs.handle=dat->hContact; - acs.handleType=HANDLE_CONTACT; - acs.szProto=0; + acs.handle = dat->hContact; + acs.handleType = HANDLE_CONTACT; + acs.szProto = 0; CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); } if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) { @@ -620,20 +620,20 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } break; case HM_EVENTSENT: - { ACKDATA *ack=(ACKDATA*)lParam; + { ACKDATA *ack = (ACKDATA*)lParam; DBEVENTINFO dbei; if (ack->hProcess != dat->hSendId) break; if (ack->hContact != dat->hContact) break; if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; ZeroMemory(&dbei, sizeof(dbei)); - dbei.cbSize=sizeof(dbei); - dbei.eventType=EVENTTYPE_URL; - dbei.flags=DBEF_SENT; - dbei.szModule=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); - dbei.timestamp=time(NULL); - dbei.cbBlob=(DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2); - dbei.pBlob=(PBYTE)dat->sendBuffer; + dbei.cbSize = sizeof(dbei); + dbei.eventType = EVENTTYPE_URL; + dbei.flags = DBEF_SENT; + dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + dbei.timestamp = time(NULL); + dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2); + dbei.pBlob = (PBYTE)dat->sendBuffer; CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei); KillTimer(hwndDlg, 0); DestroyWindow(hwndDlg); @@ -654,7 +654,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP mir_free(dat); Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send"); { int i; - for (i=SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--) + for (i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--) mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0)); } break; diff --git a/src/modules/updatenotify/updatenotify.cpp b/src/modules/updatenotify/updatenotify.cpp index 184f46a42b..a223076062 100644 --- a/src/modules/updatenotify/updatenotify.cpp +++ b/src/modules/updatenotify/updatenotify.cpp @@ -79,7 +79,7 @@ static int UpdateNotifyModulesLoaded(WPARAM, LPARAM) { ZeroMemory(&nlu, sizeof(nlu)); nlu.cbSize = sizeof(nlu); - nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS; + nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS; nlu.szSettingsModule = UN_MOD; nlu.szDescriptiveName = Translate("Update notification"); hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); diff --git a/src/modules/userinfo/contactinfo.cpp b/src/modules/userinfo/contactinfo.cpp deleted file mode 100644 index 64c84cf221..0000000000 --- a/src/modules/userinfo/contactinfo.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#include "..\..\core\commonheaders.h" - -static HFONT hEmailFont=NULL; -static HCURSOR hHandCursor=NULL; - -static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (*(char*)lParam) SetWindowText(hwndDlg, TranslateT("Edit E-Mail Address")); - TranslateDialogDefault(hwndDlg); - SetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)lParam); - EnableWindow(GetDlgItem(hwndDlg, IDOK), *(char*)lParam); - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDOK: - GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256); - //fall through - case IDCANCEL: - EndDialog(hwndDlg, wParam); - case IDC_EMAIL: - if (HIWORD(wParam) == EN_CHANGE) - EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EMAIL))); - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int noRecursion=0; - - switch(msg) { - case WM_INITDIALOG: - { char *szText=(char*)lParam; - int i, item, countryCount; - struct CountryListEntry *countries; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (szText[0]) SetWindowText(hwndDlg, TranslateT("Edit Phone Number")); - TranslateDialogDefault(hwndDlg); - if (lstrlenA(szText)>4 && !lstrcmpA(szText+lstrlenA(szText)-4, " SMS")) { - CheckDlgButton(hwndDlg, IDC_SMS, BST_CHECKED); - szText[lstrlenA(szText)-4]='\0'; - } - EnableWindow(GetDlgItem(hwndDlg, IDOK), szText[0]); - SendDlgItemMessage(hwndDlg, IDC_AREA, EM_LIMITTEXT, 31, 0); - SendDlgItemMessage(hwndDlg, IDC_NUMBER, EM_LIMITTEXT, 63, 0); - CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries); - for (i=0;i 4) - isValid = 0; - else { - for (i = SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0)-1; i >= 0; i--) - if (country == SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, i, 0)) { - SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, i, 0); - break; - } - if (i < 0) - isValid = 0; - } - } - if (isValid) { - pArea = pText+strcspn(pText, "0123456789"); - pText = pArea+strspn(pArea, "0123456789"); - if (*pText) { - *pText='\0'; - pNumber = pText+1+strcspn(pText+1, "0123456789"); - SetDlgItemTextA(hwndDlg, IDC_NUMBER, pNumber); - } - SetDlgItemTextA(hwndDlg, IDC_AREA, pArea); - } - if ( !isValid) { - SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, -1, 0); - SetDlgItemTextA(hwndDlg, IDC_AREA, ""); - SetDlgItemTextA(hwndDlg, IDC_NUMBER, ""); - } - } - noRecursion=0; - EnableWindow(GetDlgItem(hwndDlg, IDOK), GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PHONE))); - break; - } - break; - } - return FALSE; -} - -static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) -{ - RECT rc; - HWND hwndEmails; - TCHAR szText[256]; - HDC hdc; - SIZE textSize; - LVHITTESTINFO hti; - - hwndEmails=GetDlgItem(hwndDlg, IDC_EMAILS); - GetCursorPos(&hti.pt); - ScreenToClient(hwndEmails, &hti.pt); - GetClientRect(hwndEmails, &rc); - if ( !PtInRect(&rc, hti.pt)) return 0; - if (ListView_SubItemHitTest(hwndEmails, &hti) == -1) return 0; - if (hti.iSubItem != 1) return 0; - if ( !(hti.flags&LVHT_ONITEMLABEL)) return 0; - ListView_GetSubItemRect(hwndEmails, hti.iItem, 1, LVIR_LABEL, &rc); - szText[0] = 0; - ListView_GetItemText(hwndEmails, hti.iItem, 1, szText, SIZEOF(szText)); - hdc=GetDC(hwndEmails); - SelectObject(hdc, hEmailFont); - GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textSize); - ReleaseDC(hwndEmails, hdc); - if (hti.pt.x4 && !lstrcmpA(dbv.pszVal+lstrlenA(dbv.pszVal)-4, " SMS")) { - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); - dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0'; - } - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - DBFreeVariant(&dbv); - lvi.iItem++; - } - if ( !DBGetContactSettingTString(hContact, szProto, "CompanyPhone", &dbv)) { - lvi.pszText=TranslateT("Work Phone"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - DBFreeVariant(&dbv); - lvi.iItem++; - } - if ( !DBGetContactSettingTString(hContact, szProto, "CompanyFax", &dbv)) { - lvi.pszText=TranslateT("Work Fax"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - DBFreeVariant(&dbv); - lvi.iItem++; - } - lvi.iSubItem=0; - for (i=0;;i++) { - lvi.lParam=i; - mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d", i); - if (DBGetContactSettingTString(hContact, "UserInfo", idstr, &dbv)) - break; - lvi.pszText=idstr2; - mir_sntprintf(idstr2, SIZEOF(idstr2), TranslateT("Custom %d"), i+1); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - if (lstrlen(dbv.ptszVal)>4 && !lstrcmp(dbv.ptszVal+lstrlen(dbv.ptszVal)-4, _T(" SMS"))) { - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y")); - dbv.ptszVal[lstrlen(dbv.ptszVal)-4]='\0'; - } - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal); - DBFreeVariant(&dbv); - lvi.iItem++; - } - lvi.mask=LVIF_PARAM; - lvi.lParam=(LPARAM)(-2); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - } - break; - } - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_INFOCHANGED: - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - break; - } - break; - case IDC_EMAILS: - case IDC_PHONES: - switch (((LPNMHDR)lParam)->code) { - case NM_CUSTOMDRAW: - { NMLVCUSTOMDRAW *nm=(NMLVCUSTOMDRAW*)lParam; - switch(nm->nmcd.dwDrawStage) { - case CDDS_PREPAINT: - case CDDS_ITEMPREPAINT: - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW); - return TRUE; - case CDDS_SUBITEM|CDDS_ITEMPREPAINT: - { - RECT rc; - ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc); - if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) { - HFONT hoFont; - TCHAR szText[256] = {0}; - ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); - hoFont=(HFONT)SelectObject(nm->nmcd.hdc, hEmailFont); - SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255)); - DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); - SelectObject(nm->nmcd.hdc, hoFont); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); - return TRUE; - } - - HICON hIcon = NULL; - if (nm->nmcd.lItemlParam == (LPARAM)(-2) && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES)) - hIcon = LoadSkinIcon(SKINICON_OTHER_ADDCONTACT); - else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != (LPARAM)(-1) && nm->nmcd.lItemlParam != (LPARAM)(-2)) { - static int iconResources[3]={SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE}; - if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) { - TCHAR szText[2]; - ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, SIZEOF(szText)); - if (szText[0]) hIcon = LoadSkinIcon(SKINICON_OTHER_SMS); - } - else hIcon = LoadSkinIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]); - } - else break; - DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); - IconLib_ReleaseIcon(hIcon, 0); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); - return TRUE; - } - } - break; - } - case NM_CLICK: - { NMLISTVIEW *nm=(NMLISTVIEW*)lParam; - LVITEM lvi; - TCHAR szEmail[256]; - HANDLE hContact=(HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - char *szIdTemplate=nm->hdr.idFrom == IDC_PHONES?"MyPhone%d":"Mye-mail%d"; - LVHITTESTINFO hti; - - if (IsOverEmail(hwndDlg, szEmail, SIZEOF(szEmail))) { - TCHAR szExec[264]; - mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); - ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); - break; - } - if (nm->iSubItem<2) break; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(nm->hdr.hwndFrom, &hti.pt); - if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break; - lvi.mask=LVIF_PARAM; - lvi.iItem=hti.iItem; - lvi.iSubItem=0; - ListView_GetItem(nm->hdr.hwndFrom, &lvi); - if (lvi.lParam == (LPARAM)(-1)) break; - if (lvi.lParam == (LPARAM)(-2)) { - if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { - //add - char szNewData[256]="", idstr[33]; - int i; - DBVARIANT dbv; - if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData)) - break; - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); - if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break; - DBFreeVariant(&dbv); - } - DBWriteContactSettingString(hContact, "UserInfo", idstr, szNewData); - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - } - } - else { - if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) { - //delete - int i; - char idstr[33]; - DBVARIANT dbv; - for (i=lvi.lParam;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i+1); - if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break; - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); - DBWriteContactSettingString(hContact, "UserInfo", idstr, dbv.pszVal); - DBFreeVariant(&dbv); - } - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i); - DBDeleteContactSetting(hContact, "UserInfo", idstr); - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - } - else if (hti.iSubItem-2 == (nm->hdr.idFrom == IDC_PHONES)) { - //edit - char szText[256], idstr[33]; - DBVARIANT dbv; - mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, lvi.lParam); - if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break; - lstrcpynA(szText, dbv.pszVal, SIZEOF(szText)); - DBFreeVariant(&dbv); - if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText)) - break; - DBWriteContactSettingString(hContact, "UserInfo", idstr, szText); - SendMessage(hwndDlg, M_REMAKELISTS, 0, 0); - } - } - break; - } - } - break; - } - break; - case WM_SETCURSOR: - if (LOWORD(lParam) != HTCLIENT) break; - if (GetForegroundWindow() == GetParent(hwndDlg)) { - POINT pt; - GetCursorPos(&pt); - ScreenToClient(hwndDlg, &pt); -// SetFocus(ChildWindowFromPoint(hwndDlg, pt)); //ugly hack because listviews ignore their first click - } - if (IsOverEmail(hwndDlg, NULL, 0)) { - SetCursor(hHandCursor); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); - return TRUE; - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - } - break; - } - return FALSE; -} diff --git a/src/modules/userinfo/stdinfo.cpp b/src/modules/userinfo/stdinfo.cpp deleted file mode 100644 index 42f2b3241d..0000000000 --- a/src/modules/userinfo/stdinfo.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#include "..\..\core\commonheaders.h" - -INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - -#define SVS_NORMAL 0 -#define SVS_GENDER 1 -#define SVS_ZEROISUNSPEC 2 -#define SVS_IP 3 -#define SVS_COUNTRY 4 -#define SVS_MONTH 5 -#define SVS_SIGNED 6 -#define SVS_TIMEZONE 7 - -static int Proto_GetContactInfoSetting(HANDLE hContact, const char *szProto, const char *szModule, const char *szSetting, DBVARIANT *dbv, const int nType) -{ - DBCONTACTGETSETTING cgs={szModule, szSetting, dbv}; - dbv->type=(BYTE)nType; - - return CallProtoServiceInt(NULL,szProto, PS_GETINFOSETTING, (WPARAM)hContact, (LPARAM)&cgs); -} - -static void Proto_FreeInfoVariant(DBVARIANT *dbv) -{ - switch (dbv->type) { - case DBVT_ASCIIZ: - case DBVT_UTF8: - case DBVT_WCHAR: - { - mir_free(dbv->pszVal); - dbv->pszVal=0; - break; - } - case DBVT_BLOB: - { - mir_free(dbv->pbVal); - dbv->pbVal=0; - break; - } - } - dbv->type=0; -} - -static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule, char *szSetting, int special) -{ - DBVARIANT dbv = { 0 }; - char str[80], *pstr = NULL; - TCHAR* ptstr = NULL; - int unspecified=0; - char* szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - bool proto_service = szProto && (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC); - - dbv.type=DBVT_DELETED; - if (szModule == NULL) unspecified=1; - else if (proto_service) unspecified=Proto_GetContactInfoSetting(hContact, szProto, szModule, szSetting, &dbv, 0); - else unspecified=DBGetContactSettingW(hContact, szModule, szSetting, &dbv); - if ( !unspecified) { - switch(dbv.type) { - case DBVT_BYTE: - if (special == SVS_GENDER) { - if (dbv.cVal == 'M') ptstr=TranslateT("Male"); - else if (dbv.cVal == 'F') ptstr=TranslateT("Female"); - else unspecified=1; - } - else if (special == SVS_MONTH) { - if (dbv.bVal>0 && dbv.bVal<=12) { - pstr=str; - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1-1+dbv.bVal, str, SIZEOF(str)); - } - else unspecified=1; - } - else if (special == SVS_TIMEZONE) { - if (dbv.cVal == -100) unspecified=1; - else { - pstr=str; - mir_snprintf(str, SIZEOF(str), dbv.cVal?"UTC%+d:%02d":"UTC", -dbv.cVal/2, (dbv.cVal&1)*30); - } - } - else { - unspecified=(special == SVS_ZEROISUNSPEC && dbv.bVal == 0); - pstr=_itoa(special == SVS_SIGNED?dbv.cVal:dbv.bVal, str, 10); - } - break; - case DBVT_WORD: - if (special == SVS_COUNTRY) { - WORD wSave = dbv.wVal; - if (wSave == (WORD)-1) { - char szSettingName[100]; - mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sName", szSetting); - if ( !DBGetContactSettingTString(hContact, szModule, szSettingName, &dbv)) { - ptstr = dbv.ptszVal; - unspecified = false; - break; - } - } - - pstr = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0)); - unspecified=pstr == NULL; - } - else { - unspecified=(special == SVS_ZEROISUNSPEC && dbv.wVal == 0); - pstr=_itoa(special == SVS_SIGNED?dbv.sVal:dbv.wVal, str, 10); - } - break; - case DBVT_DWORD: - unspecified=(special == SVS_ZEROISUNSPEC && dbv.dVal == 0); - if (special == SVS_IP) { - struct in_addr ia; - ia.S_un.S_addr=htonl(dbv.dVal); - pstr=inet_ntoa(ia); - if (dbv.dVal == 0) unspecified=1; - } - else pstr=_itoa(special == SVS_SIGNED?dbv.lVal:dbv.dVal, str, 10); - break; - case DBVT_ASCIIZ: - unspecified=(special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); - pstr=dbv.pszVal; - break; - case DBVT_UTF8: - unspecified=(special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); - if ( !unspecified) - { WCHAR* wszStr; - Utf8Decode(dbv.pszVal, &wszStr); - SetDlgItemTextW(hwndDlg, idCtrl, TranslateTS(wszStr)); - mir_free(wszStr); - goto LBL_Exit; - } - - pstr=dbv.pszVal; - Utf8Decode(dbv.pszVal, NULL); - break; - default: pstr=str; lstrcpyA(str, "???"); break; - } } - - if (unspecified) - SetDlgItemText(hwndDlg, idCtrl, TranslateT("")); - else if (ptstr != NULL) - SetDlgItemText(hwndDlg, idCtrl, ptstr); - else - SetDlgItemTextA(hwndDlg, idCtrl, pstr); - - -LBL_Exit: - - EnableWindow(GetDlgItem(hwndDlg, idCtrl), !unspecified); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - DBFreeVariant(&dbv); -} - -static INT_PTR CALLBACK SummaryDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) - { char *szProto; - HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) break; - SetValue(hwndDlg, IDC_NICK, hContact, szProto, "Nick", 0); - SetValue(hwndDlg, IDC_FIRSTNAME, hContact, szProto, "FirstName", 0); - SetValue(hwndDlg, IDC_LASTNAME, hContact, szProto, "LastName", 0); - SetValue(hwndDlg, IDC_EMAIL, hContact, szProto, "e-mail", 0); - SetValue(hwndDlg, IDC_AGE, hContact, szProto, "Age", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_GENDER, hContact, szProto, "Gender", SVS_GENDER); - SetValue(hwndDlg, IDC_DOBDAY, hContact, szProto, "BirthDay", 0); - SetValue(hwndDlg, IDC_DOBMONTH, hContact, szProto, "BirthMonth", SVS_MONTH); - SetValue(hwndDlg, IDC_DOBYEAR, hContact, szProto, "BirthYear", 0); - SetValue(hwndDlg, IDC_MARITAL, hContact, szProto, "MaritalStatus", 0); - } } - break; - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case IDC_EMAIL: - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EMAIL))) { - TCHAR szExec[264], szEmail[256]; - GetDlgItemText(hwndDlg, IDC_EMAIL, szEmail, SIZEOF(szEmail)); - mir_sntprintf(szExec, SIZEOF(szExec), _T("mailto:%s"), szEmail); - ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW); - } - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK LocationDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - TranslateDialogDefault(hwndDlg); - SetTimer(hwndDlg, 1, 1000, NULL); - - tmi.prepareList((HANDLE)lParam, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); - SendMessage(hwndDlg, WM_TIMER, 0, 0); - break; - - case WM_TIMER: - { - HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - if (hContact != NULL) - { - TCHAR szTime[80]; - - if (tmi.printDateTimeByContact(hContact, _T("s"), szTime, SIZEOF(szTime), TZF_KNOWNONLY)) - { - EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), FALSE); - SetDlgItemText(hwndDlg, IDC_LOCALTIME, TranslateT("")); - } - else - { - EnableWindow(GetDlgItem(hwndDlg, IDC_LOCALTIME), TRUE); - SetDlgItemText(hwndDlg, IDC_LOCALTIME, szTime); - } - } - break; - } - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) - { char *szProto; - HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) break; - SetValue(hwndDlg, IDC_STREET, hContact, szProto, "Street", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_CITY, hContact, szProto, "City", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_STATE, hContact, szProto, "State", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "ZIP", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "Country", SVS_COUNTRY); - SetValue(hwndDlg, IDC_LANGUAGE1, hContact, szProto, "Language1", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_LANGUAGE2, hContact, szProto, "Language2", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_LANGUAGE3, hContact, szProto, "Language3", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_TIMEZONE, hContact, szProto, "Timezone", SVS_TIMEZONE); - } - } - break; - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case IDC_TIMEZONESELECT: - if (HIWORD(wParam) == CBN_SELCHANGE) { - HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - tmi.storeListResults(hContact, GetDlgItem(hwndDlg, IDC_TIMEZONESELECT), TZF_PLF_CB); - } - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK WorkDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - break; - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) - { char *szProto; - HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) break; - SetValue(hwndDlg, IDC_COMPANY, hContact, szProto, "Company", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_DEPARTMENT, hContact, szProto, "CompanyDepartment", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_POSITION, hContact, szProto, "CompanyPosition", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_STREET, hContact, szProto, "CompanyStreet", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_CITY, hContact, szProto, "CompanyCity", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_STATE, hContact, szProto, "CompanyState", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_ZIP, hContact, szProto, "CompanyZIP", SVS_ZEROISUNSPEC); - SetValue(hwndDlg, IDC_COUNTRY, hContact, szProto, "CompanyCountry", SVS_COUNTRY); - SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "CompanyHomepage", SVS_ZEROISUNSPEC); - } } - break; - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case IDC_WEBPAGE: - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { - char szPage[256]; - GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); - CallService(MS_UTILS_OPENURL, 1, (LPARAM)szPage); - } - break; - } - break; - } - return FALSE; -} - -// Resizes all columns in a listview (report style) -// to make all text visible -void ResizeColumns(HWND hwndLV) -{ - int nCol = 0; LVCOLUMN lvCol; - lvCol.mask = LVCF_WIDTH; - while (ListView_GetColumn(hwndLV, nCol++, &lvCol)) - ListView_SetColumnWidth(hwndLV, nCol-1, LVSCW_AUTOSIZE); -} - -static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { LVCOLUMN lvc; - RECT rc; - GetClientRect(GetDlgItem(hwndDlg, IDC_PAST), &rc); - rc.right-=GetSystemMetrics(SM_CXVSCROLL); - lvc.mask=LVCF_WIDTH; - lvc.cx=rc.right/3; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 0, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 0, &lvc); - lvc.cx=rc.right-rc.right/3; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 1, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 1, &lvc); - } - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PAST), LVS_EX_LABELTIP, LVS_EX_LABELTIP); - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_INTERESTS), LVS_EX_LABELTIP, LVS_EX_LABELTIP); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED) - { LVITEM lvi; - int i; - char idstr[33]; - DBVARIANT dbv, dbvText; - HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - - if (hContact != NULL) { - char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) break; - bool proto_service = (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC; - SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC); - - //past - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PAST)); - lvi.mask=LVIF_TEXT; - lvi.iSubItem=0; - lvi.iItem=0; - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), "Past%d", i); - if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || - ( !proto_service && DBGetContactSettingTString(hContact, szProto, idstr, &dbv))) - break; - mir_snprintf(idstr, SIZEOF(idstr), "Past%dText", i); - if (DBGetContactSettingTString(hContact, szProto, idstr, &dbvText)) - {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} - lvi.pszText=dbv.ptszVal; - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); - DBFreeVariant(&dbvText); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - DBFreeVariant(&dbv); - lvi.iItem++; - } - - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%d", i); - if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || - ( !proto_service && DBGetContactSettingTString(hContact, szProto, idstr, &dbv))) - break; - mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%dText", i); - if (DBGetContactSettingTString(hContact, szProto, idstr, &dbvText)) - {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} - lvi.pszText=dbv.ptszVal; - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal); - DBFreeVariant(&dbvText); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - DBFreeVariant(&dbv); - lvi.iItem++; - } - - ResizeColumns(GetDlgItem(hwndDlg, IDC_PAST)); - - //interests - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_INTERESTS)); - lvi.mask=LVIF_TEXT; - lvi.iSubItem=0; - lvi.iItem=0; - for (i=0;;i++) { - mir_snprintf(idstr, SIZEOF(idstr), "Interest%dCat", i); - if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) || - ( !proto_service && DBGetContactSettingTString(hContact, szProto, idstr, &dbv))) - break; - mir_snprintf(idstr, SIZEOF(idstr), "Interest%dText", i); - if (DBGetContactSettingTString(hContact, szProto, idstr, &dbvText)) - {if (proto_service) Proto_FreeInfoVariant(&dbv); else DBFreeVariant(&dbv); break;} - lvi.pszText=dbv.ptszVal; - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_INTERESTS), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_INTERESTS), lvi.iItem, 1, dbvText.ptszVal); - DBFreeVariant(&dbvText); - if (proto_service) - Proto_FreeInfoVariant(&dbv); - else - DBFreeVariant(&dbv); - lvi.iItem++; - } - ResizeColumns(GetDlgItem(hwndDlg, IDC_INTERESTS)); - } } - break; - } - break; - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case IDC_WEBPAGE: - if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) { - char szPage[256]; - GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage)); - CallService(MS_UTILS_OPENURL, 1, (LPARAM)szPage); - } - break; - } - break; - } - return FALSE; -} - -static INT_PTR CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { DBVARIANT dbv; - HFONT hFont; - LOGFONT lf; - HDC hDC = GetDC(hwndDlg); - lf.lfHeight = -MulDiv(10, GetDeviceCaps(hDC, LOGPIXELSY), 72); - ReleaseDC(hwndDlg, hDC); - lf.lfWidth = 0; - lf.lfEscapement = 0; - lf.lfOrientation = 0; - lf.lfWeight = FW_NORMAL; - lf.lfItalic = 0; - lf.lfUnderline = 0; - lf.lfStrikeOut = 0; - lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - lstrcpy(lf.lfFaceName, _T("Courier New")); - lf.lfCharSet = DEFAULT_CHARSET; -// hFont = (HFONT) GetStockObject(ANSI_FIXED_FONT); - hFont = CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0)); - - if ( !DBGetContactSettingString((HANDLE)lParam, "UserInfo", "MyNotes", &dbv)) { - SetDlgItemTextA(hwndDlg, IDC_MYNOTES, dbv.pszVal); - DBFreeVariant(&dbv); - } - } - SendDlgItemMessage(hwndDlg, IDC_MYNOTES, EM_LIMITTEXT, 2048, 0); - break; - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_INFOCHANGED: - { char *szProto; - HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - if (hContact != NULL) { - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) break; - SetValue(hwndDlg, IDC_ABOUT, hContact, szProto, "About", 0); - } - break; - } - case PSN_APPLY: - { HANDLE hContact=(HANDLE)((LPPSHNOTIFY)lParam)->lParam; - if (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MYNOTES))) { - char text[2048]; - GetDlgItemTextA(hwndDlg, IDC_MYNOTES, text, SIZEOF(text)); - DBWriteContactSettingString(hContact, "UserInfo", "MyNotes", text); - } - else DBDeleteContactSetting(hContact, "UserInfo", "MyNotes"); - break; - } - } - break; - } - break; - case WM_COMMAND: - if (wParam == MAKEWPARAM(IDC_MYNOTES, EN_CHANGE)) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - else if (LOWORD(wParam) == IDCANCEL) - SendMessage(GetParent(hwndDlg), msg, wParam, lParam); - break; - case WM_DESTROY: - { - HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_ABOUT, WM_GETFONT, 0, 0); - DeleteObject(hFont); - } - break; - } - return FALSE; -} - -int DetailsInit(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp; - - if ((HANDLE)lParam == NULL) - return 0; - - if (CallService(MS_PROTO_GETCONTACTBASEPROTO, lParam, 0) == 0) - return 0; - - odp.cbSize = sizeof(odp); - odp.hIcon = NULL; - odp.hInstance = hInst; - odp.flags = 0; - - odp.pfnDlgProc = SummaryDlgProc; - odp.position = -2100000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SUMMARY); - odp.pszTitle = LPGEN("Summary"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = ContactDlgProc; - odp.position = -1800000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_CONTACT); - odp.pszTitle = LPGEN("Contact"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = LocationDlgProc; - odp.position = -1500000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_LOCATION); - odp.pszTitle = LPGEN("Location"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = WorkDlgProc; - odp.position = -1200000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_WORK); - odp.pszTitle = LPGEN("Work"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = BackgroundDlgProc; - odp.position = -900000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_BACKGROUND); - odp.pszTitle = LPGEN("Background info"); - UserInfo_AddPage(wParam, &odp); - - odp.pfnDlgProc = NotesDlgProc; - odp.position = 0; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_NOTES); - odp.pszTitle = LPGEN("Notes"); - UserInfo_AddPage(wParam, &odp); - return 0; -} diff --git a/src/modules/userinfo/userinfo.cpp b/src/modules/userinfo/userinfo.cpp deleted file mode 100644 index 237c1bdee5..0000000000 --- a/src/modules/userinfo/userinfo.cpp +++ /dev/null @@ -1,634 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ -#include "..\..\core\commonheaders.h" -#define UPDATEANIMFRAMES 20 - -int DetailsInit(WPARAM wParam, LPARAM lParam); -static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static HANDLE hWindowList=NULL; -static HANDLE hDetailsInitEvent; - -struct DetailsPageInit { - int pageCount; - OPTIONSDIALOGPAGE *odp; -}; - -struct DetailsPageData { - DLGTEMPLATE *pTemplate; - HINSTANCE hInst; - DLGPROC dlgProc; - LPARAM dlgParam; - HWND hwnd; - HTREEITEM hItem; - int changed; - TCHAR *ptszTitle, *ptszTab; -}; - -struct DetailsData { - HANDLE hContact; - HANDLE hProtoAckEvent; - HINSTANCE hInstIcmp; - HFONT hBoldFont; - int pageCount; - int currentPage; - struct DetailsPageData *opd; - RECT rcDisplay, rcDisplayTab; - int updateAnimFrame; - TCHAR szUpdating[64]; - int *infosUpdated; -}; - -static int PageSortProc(OPTIONSDIALOGPAGE *item1, OPTIONSDIALOGPAGE *item2) -{ - int res; - if ( !lstrcmp(item1->ptszTitle, TranslateT("Summary"))) return -1; - if ( !lstrcmp(item2->ptszTitle, TranslateT("Summary"))) return 1; - if (res = lstrcmp(item1->ptszTitle, item2->ptszTitle)) return res; - if (item1->ptszTab && !item2->ptszTab) return -1; - if ( !item1->ptszTab && item2->ptszTab) return 1; - if ( !item1->ptszTab && !item2->ptszTab) return 0; - if (item1->ptszTab && !lstrcmp(item1->ptszTab, TranslateT("General"))) return -1; - if (item2->ptszTab && !lstrcmp(item2->ptszTab, TranslateT("General"))) return 1; - return lstrcmp(item1->ptszTab, item2->ptszTab); -} - -static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM) -{ - HWND hwnd; - PROPSHEETHEADER psh; - struct DetailsPageInit opi; - int i; - - if (hwnd=WindowList_Find(hWindowList, (HANDLE)wParam)) { - SetForegroundWindow(hwnd); - SetFocus(hwnd); - return 0; - } - - opi.pageCount=0; - opi.odp=NULL; - NotifyEventHooks(hDetailsInitEvent, (WPARAM)&opi, wParam); - if (opi.pageCount == 0) return 0; - qsort(opi.odp, opi.pageCount, sizeof(OPTIONSDIALOGPAGE), (int (*)(const void*, const void*))PageSortProc); - - ZeroMemory(&psh, sizeof(psh)); - psh.dwSize = sizeof(psh); - psh.dwFlags = PSH_PROPSHEETPAGE|PSH_NOAPPLYNOW; - psh.hwndParent = NULL; - psh.nPages = opi.pageCount; - psh.pStartPage = 0; - psh.pszCaption = (TCHAR*)wParam; //more abuses of structure: this is hContact - psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell - - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh); - for (i=0;icbSize != sizeof(OPTIONSDIALOGPAGE) && odp->cbSize != OPTIONPAGE_OLD_SIZE) - return 1; - - opi->odp=(OPTIONSDIALOGPAGE*)mir_realloc(opi->odp, sizeof(OPTIONSDIALOGPAGE)*(opi->pageCount+1)); - dst = opi->odp + opi->pageCount; - dst->cbSize = sizeof(OPTIONSDIALOGPAGE); - dst->hInstance = odp->hInstance; - dst->pfnDlgProc = odp->pfnDlgProc; - dst->position = odp->position; - if ((DWORD_PTR)odp->pszTemplate&0xFFFF0000) dst->pszTemplate = mir_strdup(odp->pszTemplate); - else dst->pszTemplate = odp->pszTemplate; - - - if (odp->flags & ODPF_UNICODE) - { - dst->ptszTitle = (odp->ptszTitle == 0) ? NULL : mir_wstrdup(odp->ptszTitle); - dst->ptszTab = ( !(odp->flags & ODPF_USERINFOTAB) || !odp->ptszTab) ? NULL : mir_wstrdup(odp->ptszTab); - } - else - - { - if (odp->flags & ODPF_DONTTRANSLATE) - dst->ptszTitle = (odp->pszTitle == 0) ? NULL : mir_a2t(odp->pszTitle); - else - dst->ptszTitle = (odp->pszTitle == 0) ? NULL : Langpack_PcharToTchar(odp->pszTitle); - dst->ptszTab = ( !(odp->flags & ODPF_USERINFOTAB) || !odp->pszTab) ? NULL : Langpack_PcharToTchar(odp->pszTab); - } - - dst->pszGroup = NULL; - dst->groupPosition = odp->groupPosition; - dst->hGroupIcon = odp->hGroupIcon; - dst->hIcon = odp->hIcon; - if (odp->cbSize == sizeof(OPTIONSDIALOGPAGE)) - dst->dwInitParam = odp->dwInitParam; - opi->pageCount++; - return 0; -} - -static void ThemeDialogBackground(HWND hwnd) -{ - if (enableThemeDialogTexture) - enableThemeDialogTexture(hwnd, ETDT_ENABLETAB); -} - -static void CreateDetailsTabs(HWND hwndDlg, struct DetailsData* dat, struct DetailsPageData* ppg) -{ - HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); - int i, sel=0, pages=0; - TCITEM tie; - tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; - tie.iImage = -1; - TabCtrl_DeleteAllItems(hwndTab); - for (i=0; i < dat->pageCount; i++) { - if ( !dat->opd[i].ptszTab || lstrcmp(dat->opd[i].ptszTitle, ppg->ptszTitle)) continue; - - tie.pszText = TranslateTS(dat->opd[i].ptszTab); - tie.lParam = i; - TabCtrl_InsertItem(hwndTab, pages, &tie); - if ( !lstrcmp(dat->opd[i].ptszTab, ppg->ptszTab)) - sel = pages; - pages++; - } - TabCtrl_SetCurSel(hwndTab, sel); - - LONG style = GetWindowLongPtr(hwndTab, GWL_STYLE); - SetWindowLongPtr(hwndTab, GWL_STYLE, pages > 1 ? style | WS_TABSTOP : style & ~WS_TABSTOP); -} - -static void CreateDetailsPageWindow(HWND hwndDlg, struct DetailsData* dat, struct DetailsPageData* ppg) -{ - RECT *rc = ppg->ptszTab ? &dat->rcDisplayTab : &dat->rcDisplay; - ppg->hwnd=CreateDialogIndirectParam(ppg->hInst, ppg->pTemplate, hwndDlg, ppg->dlgProc, (LPARAM)dat->hContact); - ThemeDialogBackground(ppg->hwnd); - SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); - SetWindowPos(ppg->hwnd, HWND_TOP, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, 0); - { - PSHNOTIFY pshn; - pshn.hdr.code = PSN_PARAMCHANGED; - pshn.hdr.hwndFrom = ppg->hwnd; - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)ppg->dlgParam; - SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - - pshn.hdr.code=PSN_INFOCHANGED; - pshn.hdr.hwndFrom=ppg->hwnd; - pshn.hdr.idFrom=0; - pshn.lParam=(LPARAM)dat->hContact; - SendMessage(ppg->hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - } -} - -static int UserInfoContactDelete(WPARAM wParam, LPARAM) -{ - HWND hwnd; - hwnd=WindowList_Find(hWindowList, (HANDLE)wParam); - if (hwnd != NULL) DestroyWindow(hwnd); - return 0; -} - -#define HM_PROTOACK (WM_USER+10) -#define M_CHECKONLINE (WM_USER+11) -static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - struct DetailsData *dat =(struct DetailsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - Window_SetIcon_IcoLib(hwndDlg, SKINICON_OTHER_USERDETAILS); - { - PROPSHEETHEADER *psh = (PROPSHEETHEADER*)lParam; - dat = (DetailsData*)mir_calloc(sizeof(DetailsData)); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->hContact = (HANDLE)psh->pszCaption; - dat->hProtoAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_PROTOACK); - WindowList_Add(hWindowList, hwndDlg, dat->hContact); - { - TCHAR *name, oldTitle[256], newTitle[256]; - if (dat->hContact == NULL) - name = TranslateT("Owner"); - else - name = cli.pfnGetContactDisplayName(dat->hContact, 0); - - GetWindowText(hwndDlg, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); - SetWindowText(hwndDlg, newTitle); - - GetDlgItemText(hwndDlg, IDC_HEADERBAR, oldTitle, SIZEOF(oldTitle)); - mir_sntprintf(newTitle, SIZEOF(newTitle), oldTitle, name); - SetDlgItemText(hwndDlg, IDC_HEADERBAR, newTitle); - } - { LOGFONT lf; - HFONT hNormalFont=(HFONT)SendDlgItemMessage(hwndDlg, IDC_NAME, WM_GETFONT, 0, 0); - GetObject(hNormalFont, sizeof(lf), &lf); - lf.lfWeight=FW_BOLD; - dat->hBoldFont=CreateFontIndirect(&lf); - SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, (WPARAM)dat->hBoldFont, 0); - } - { OPTIONSDIALOGPAGE *odp; - int i; - TVINSERTSTRUCT tvis; - DBVARIANT dbv; - - HWND hwndTree = GetDlgItem(hwndDlg, IDC_PAGETREE); - - dat->currentPage = 0; - if (DBGetContactSettingTString(NULL, "UserInfo", "LastTab", &dbv)) - dbv.type = DBVT_DELETED; - dat->pageCount = psh->nPages; - dat->opd = (DetailsPageData*)mir_calloc(sizeof(DetailsPageData) * dat->pageCount); - odp = (OPTIONSDIALOGPAGE*)psh->ppsp; - - for (i=0; i < dat->pageCount; i++) { - dat->opd[i].pTemplate = (LPDLGTEMPLATE)LockResource(LoadResource(odp[i].hInstance, - FindResourceA(odp[i].hInstance, odp[i].pszTemplate, MAKEINTRESOURCEA(5)))); - dat->opd[i].dlgProc = odp[i].pfnDlgProc; - dat->opd[i].dlgParam = odp[i].dwInitParam; - dat->opd[i].hInst = odp[i].hInstance; - - dat->opd[i].ptszTitle = odp[i].ptszTitle; - dat->opd[i].ptszTab = odp[i].ptszTab; - - if (i && dat->opd[i].ptszTab && !lstrcmp(dat->opd[i-1].ptszTitle, dat->opd[i].ptszTitle)) { - dat->opd[i].hItem = dat->opd[i-1].hItem; - continue; - } - - tvis.hParent = NULL; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_PARAM; - tvis.item.lParam = (LPARAM) i; - if (odp[i].flags & ODPF_DONTTRANSLATE) - tvis.item.pszText = mir_tstrdup(odp[i].ptszTitle); - else - tvis.item.pszText = TranslateTS(odp[i].ptszTitle); - if (dbv.type != DBVT_DELETED && !lstrcmp(tvis.item.pszText, dbv.ptszVal)) - dat->currentPage = i; - dat->opd[i].hItem = TreeView_InsertItem(hwndTree, &tvis); - } - DBFreeVariant(&dbv); - } - - { - HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); - - TCITEM tci; - tci.mask = TCIF_TEXT | TCIF_IMAGE; - tci.iImage = -1; - tci.pszText = _T("X"); - TabCtrl_InsertItem(hwndTab, 0, &tci); - - GetWindowRect(hwndTab, &dat->rcDisplayTab); - TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplayTab); - { POINT pt={0, 0}; - ClientToScreen(hwndDlg, &pt); - OffsetRect(&dat->rcDisplayTab, -pt.x, -pt.y); - } - - TabCtrl_DeleteAllItems(hwndTab); - - GetWindowRect(hwndTab, &dat->rcDisplay); - TabCtrl_AdjustRect(hwndTab, FALSE, &dat->rcDisplay); - { POINT pt={0, 0}; - ClientToScreen(hwndDlg, &pt); - OffsetRect(&dat->rcDisplay, -pt.x, -pt.y); - } } - - TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_PAGETREE), dat->opd[dat->currentPage].hItem); - - dat->updateAnimFrame = 0; - GetDlgItemText(hwndDlg, IDC_UPDATING, dat->szUpdating, SIZEOF(dat->szUpdating)); - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - if ( !CallContactService(dat->hContact, PSS_GETINFO, SGIF_ONOPEN, 0)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - SetTimer(hwndDlg, 1, 100, NULL); - } else - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); - - SetFocus(GetDlgItem(hwndDlg, IDC_PAGETREE)); - - return TRUE; - } - case WM_TIMER: - { - TCHAR str[128]; - mir_sntprintf(str, SIZEOF(str), _T("%.*s%s%.*s"), dat->updateAnimFrame%10, _T("........."), dat->szUpdating, dat->updateAnimFrame%10, _T(".........")); - SetDlgItemText(hwndDlg, IDC_UPDATING, str); - if (++dat->updateAnimFrame == UPDATEANIMFRAMES) dat->updateAnimFrame=0; - break; - } - case WM_CTLCOLORSTATIC: - switch (GetDlgCtrlID((HWND)lParam)) { - case IDC_WHITERECT: - SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); - return (INT_PTR)GetSysColorBrush(COLOR_WINDOW); - case IDC_UPDATING: - { - COLORREF textCol, bgCol, newCol; - int ratio; - textCol=GetSysColor(COLOR_BTNTEXT); - bgCol=GetSysColor(COLOR_3DFACE); - ratio=abs(UPDATEANIMFRAMES/2-dat->updateAnimFrame)*510/UPDATEANIMFRAMES; - newCol=RGB(GetRValue(bgCol)+(GetRValue(textCol)-GetRValue(bgCol))*ratio/256, - GetGValue(bgCol)+(GetGValue(textCol)-GetGValue(bgCol))*ratio/256, - GetBValue(bgCol)+(GetBValue(textCol)-GetBValue(bgCol))*ratio/256); - SetTextColor((HDC)wParam, newCol); - SetBkColor((HDC)wParam, GetSysColor(COLOR_3DFACE)); - return (INT_PTR)GetSysColorBrush(COLOR_3DFACE); - } - default: - SetBkMode((HDC)wParam, TRANSPARENT); - return (INT_PTR)GetStockObject(NULL_BRUSH); - } - break; - - case PSM_CHANGED: - dat->opd[dat->currentPage].changed=1; - return TRUE; - - case PSM_FORCECHANGED: - { - int i; - PSHNOTIFY pshn; - pshn.hdr.code=PSN_INFOCHANGED; - pshn.hdr.idFrom=0; - pshn.lParam=(LPARAM)dat->hContact; - for (i=0;ipageCount;i++) { - pshn.hdr.hwndFrom=dat->opd[i].hwnd; - if (dat->opd[i].hwnd != NULL) - SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - } - break; - } - case M_CHECKONLINE: - { - char *szProto; - if (dat->hContact != NULL) { - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); - if (szProto == NULL) {EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); break;} - if (CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0)hContact == NULL && ack->type == ACKTYPE_STATUS) { - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - break; - } - if (ack->hContact != dat->hContact) break; - if (ack->type != ACKTYPE_GETINFO) break; - SendMessage(hwndDlg, PSM_FORCECHANGED, 0, 0); - /* if they're not gonna send any more ACK's don't let that mean we should crash */ - if ( !ack->hProcess && !ack->lParam) { - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); - KillTimer(hwndDlg, 1); - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - break; - } //if - if (dat->infosUpdated == NULL) dat->infosUpdated=(int*)mir_calloc(sizeof(int)*(INT_PTR)ack->hProcess); - if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED) dat->infosUpdated[ack->lParam]=1; - for (i=0;i<(int)ack->hProcess;i++) - if (dat->infosUpdated[i] == 0) break; - if (i == (int)ack->hProcess) { - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_HIDE); - KillTimer(hwndDlg, 1); - SendMessage(hwndDlg, M_CHECKONLINE, 0, 0); - } } - break; - - case WM_NOTIFY: - switch(wParam) { - case IDC_TABS: - case IDC_PAGETREE: - switch(((LPNMHDR)lParam)->code) - { - case TCN_SELCHANGING: - case TVN_SELCHANGING: - if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) - { - PSHNOTIFY pshn; - pshn.hdr.code = PSN_KILLACTIVE; - pshn.hdr.hwndFrom = dat->opd[dat->currentPage].hwnd; - pshn.hdr.idFrom = 0; - pshn.lParam = (LPARAM)dat->hContact; - if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) - { - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE); - return TRUE; - } - } - break; - - case TCN_SELCHANGE: - if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) - { - HWND hwndTab = GetDlgItem(hwndDlg, IDC_TABS); - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); - - TCITEM tie; - TVITEM tvi; - - tie.mask = TCIF_PARAM; - TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tie); - dat->currentPage = tie.lParam; - - tvi.hItem = TreeView_GetNextItem(GetDlgItem(hwndDlg, IDC_PAGETREE), NULL, TVGN_CARET); - tvi.mask = TVIF_PARAM; - tvi.lParam = dat->currentPage; - TreeView_SetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); - - if (dat->currentPage != -1) - { - if (dat->opd[dat->currentPage].hwnd == NULL) - CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); - } - } - break; - - case TVN_SELCHANGED: - if (dat->currentPage != -1 && dat->opd[dat->currentPage].hwnd != NULL) - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); - - { - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam; - TVITEM tvi = pnmtv->itemNew; - dat->currentPage = tvi.lParam; - - if (dat->currentPage != -1) - { - CreateDetailsTabs(hwndDlg, dat, &dat->opd[dat->currentPage]); - if (dat->opd[dat->currentPage].hwnd == NULL) - CreateDetailsPageWindow(hwndDlg, dat, &dat->opd[dat->currentPage]); - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOWNA); - - } - } - break; - } - break; - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDCANCEL: - { - int i; - PSHNOTIFY pshn; - pshn.hdr.idFrom=0; - pshn.lParam=(LPARAM)dat->hContact; - pshn.hdr.code=PSN_RESET; - for (i=0;ipageCount;i++) { - if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; - pshn.hdr.hwndFrom=dat->opd[i].hwnd; - SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn); - } - DestroyWindow(hwndDlg); - break; - } - case IDOK: - { - int i; - PSHNOTIFY pshn; - pshn.hdr.idFrom=0; - pshn.lParam=(LPARAM)dat->hContact; - if (dat->currentPage != -1) { - pshn.hdr.code=PSN_KILLACTIVE; - pshn.hdr.hwndFrom=dat->opd[dat->currentPage].hwnd; - if (SendMessage(dat->opd[dat->currentPage].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn)) - break; - } - - pshn.hdr.code=PSN_APPLY; - for (i=0;ipageCount;i++) { - if (dat->opd[i].hwnd == NULL || !dat->opd[i].changed) continue; - pshn.hdr.hwndFrom=dat->opd[i].hwnd; - if (SendMessage(dat->opd[i].hwnd, WM_NOTIFY, 0, (LPARAM)&pshn) == PSNRET_INVALID_NOCHANGEPAGE) { - TreeView_Select(GetDlgItem(hwndDlg, IDC_PAGETREE), dat->opd[i].hItem, TVGN_CARET); - if (dat->currentPage != -1) ShowWindow(dat->opd[dat->currentPage].hwnd, SW_HIDE); - dat->currentPage=i; - ShowWindow(dat->opd[dat->currentPage].hwnd, SW_SHOW); - return 0; - } - } - DestroyWindow(hwndDlg); - break; - } - case IDC_UPDATE: - if (dat->infosUpdated != NULL) {mir_free(dat->infosUpdated); dat->infosUpdated=NULL;} - if (dat->hContact != NULL) { - if ( !CallContactService(dat->hContact, PSS_GETINFO, 0, 0)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); - ShowWindow(GetDlgItem(hwndDlg, IDC_UPDATING), SW_SHOW); - SetTimer(hwndDlg, 1, 100, NULL); - } - } - break; - } - break; - - case WM_CLOSE: - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, BN_CLICKED), (LPARAM)GetDlgItem(hwndDlg, IDOK)); - break; - - case WM_DESTROY: - { - TCHAR name[128]; - TVITEM tvi; - tvi.mask = TVIF_TEXT; - tvi.hItem = dat->opd[dat->currentPage].hItem; - tvi.pszText=name; - tvi.cchTextMax=SIZEOF(name); - TreeView_GetItem(GetDlgItem(hwndDlg, IDC_PAGETREE), &tvi); - DBWriteContactSettingTString(NULL, "UserInfo", "LastTab", name); - } - Window_FreeIcon_IcoLib(hwndDlg); - SendDlgItemMessage(hwndDlg, IDC_NAME, WM_SETFONT, SendDlgItemMessage(hwndDlg, IDC_WHITERECT, WM_GETFONT, 0, 0), 0); - DeleteObject(dat->hBoldFont); - WindowList_Remove(hWindowList, hwndDlg); - UnhookEvent(dat->hProtoAckEvent); - { int i; - for (i=0;ipageCount;i++) - { - if (dat->opd[i].hwnd != NULL) DestroyWindow(dat->opd[i].hwnd); - mir_free(dat->opd[i].ptszTitle); - mir_free(dat->opd[i].ptszTab); - } - } - mir_free(dat->infosUpdated); - mir_free(dat->opd); - mir_free(dat); - break; - } - return FALSE; -} - -int ShutdownUserInfo(WPARAM, LPARAM) -{ - WindowList_BroadcastAsync(hWindowList, WM_DESTROY, 0, 0); - return 0; -} - -int LoadUserInfoModule(void) -{ - CLISTMENUITEM mi = { 0 }; - - CreateServiceFunction(MS_USERINFO_SHOWDIALOG, ShowDetailsDialogCommand); - hDetailsInitEvent=CreateHookableEvent(ME_USERINFO_INITIALISE); - HookEvent(ME_USERINFO_INITIALISE, DetailsInit); - HookEvent(ME_DB_CONTACT_DELETED, UserInfoContactDelete); - HookEvent(ME_SYSTEM_PRESHUTDOWN, ShutdownUserInfo); - CreateServiceFunction("UserInfo/AddPage", AddDetailsPage); - - mi.cbSize = sizeof(mi); - mi.flags = CMIF_ICONFROMICOLIB; - mi.position = 1000050000; - mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_USERDETAILS); - mi.pszName = LPGEN("User &Details"); - mi.pszService = MS_USERINFO_SHOWDIALOG; - Menu_AddContactMenuItem(&mi); - - mi.position = 500050000; - mi.pszName = LPGEN("View/Change My &Details..."); - Menu_AddMainMenuItem(&mi); - - hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); - return 0; -} diff --git a/src/modules/useronline/useronline.cpp b/src/modules/useronline/useronline.cpp index 3097db834a..e6f5148f50 100644 --- a/src/modules/useronline/useronline.cpp +++ b/src/modules/useronline/useronline.cpp @@ -22,16 +22,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "..\..\core\commonheaders.h" -static int uniqueEventId=0; +static int uniqueEventId = 0; static int UserOnlineSettingChanged(WPARAM wParam, LPARAM lParam) { - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; int newStatus, oldStatus; if ((HANDLE)wParam == NULL || strcmp(cws->szSetting, "Status")) return 0; - newStatus=cws->value.wVal; - oldStatus=DBGetContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); + newStatus = cws->value.wVal; + oldStatus = DBGetContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); DBWriteContactSettingWord((HANDLE)wParam, "UserOnline", "OldStatus", (WORD)newStatus); if (CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_USERONLINE)) return 0; if (DBGetContactSettingByte((HANDLE)wParam, "CList", "Hidden", 0)) return 0; @@ -54,16 +54,16 @@ static int UserOnlineSettingChanged(WPARAM wParam, LPARAM lParam) TCHAR tooltip[256]; ZeroMemory(&cle, sizeof(cle)); - cle.cbSize=sizeof(cle); - cle.flags=CLEF_ONLYAFEW | CLEF_TCHAR; - cle.hContact=(HANDLE)wParam; - cle.hDbEvent=(HANDLE)(uniqueEventId++); + cle.cbSize = sizeof(cle); + cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; + cle.hContact = (HANDLE)wParam; + cle.hDbEvent = (HANDLE)(uniqueEventId++); cle.hIcon = LoadSkinIcon(SKINICON_OTHER_USERONLINE, false); - cle.pszService="UserOnline/Description"; + cle.pszService = "UserOnline/Description"; mir_sntprintf(tooltip, SIZEOF(tooltip), TranslateT("%s is Online"), cli.pfnGetContactDisplayName((HANDLE)wParam, 0)); - cle.ptszTooltip=tooltip; + cle.ptszTooltip = tooltip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); - IconLib_ReleaseIcon(cle.hIcon, 0); + IcoLib_ReleaseIcon(cle.hIcon, 0); DBWriteContactSettingDword(cle.hContact, "UserOnline", "LastEvent", (DWORD)cle.hDbEvent); SkinPlaySound("UserOnline"); } diff --git a/src/modules/utils/bmpfilter.cpp b/src/modules/utils/bmpfilter.cpp index 46db86baaf..442c75996a 100644 --- a/src/modules/utils/bmpfilter.cpp +++ b/src/modules/utils/bmpfilter.cpp @@ -106,12 +106,12 @@ static INT_PTR sttBitmapLoader(const TCHAR* ptszFileName) GetObject(hBmp, sizeof(bmpInfo), &bmpInfo); //need to copy bitmap so we can free the IPicture - hdc=GetDC(NULL); - hdcMem1=CreateCompatibleDC(hdc); - hdcMem2=CreateCompatibleDC(hdc); - hOldBitmap=(HBITMAP)SelectObject(hdcMem1, hBmp); - hBmpCopy=CreateCompatibleBitmap(hdcMem1, bmpInfo.bmWidth, bmpInfo.bmHeight); - hOldBitmap2=(HBITMAP)SelectObject(hdcMem2, hBmpCopy); + hdc = GetDC(NULL); + hdcMem1 = CreateCompatibleDC(hdc); + hdcMem2 = CreateCompatibleDC(hdc); + hOldBitmap = (HBITMAP)SelectObject(hdcMem1, hBmp); + hBmpCopy = CreateCompatibleBitmap(hdcMem1, bmpInfo.bmWidth, bmpInfo.bmHeight); + hOldBitmap2 = (HBITMAP)SelectObject(hdcMem2, hBmpCopy); BitBlt(hdcMem2, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, hdcMem1, 0, 0, SRCCOPY); SelectObject(hdcMem1, hOldBitmap); SelectObject(hdcMem2, hOldBitmap2); @@ -138,91 +138,91 @@ static INT_PTR BmpFilterLoadBitmapW(WPARAM, LPARAM lParam) static INT_PTR BmpFilterGetStrings(WPARAM wParam, LPARAM lParam) { - int bytesLeft=wParam; - char *filter=(char*)lParam, *pfilter; + int bytesLeft = wParam; + char *filter = (char*)lParam, *pfilter; lstrcpynA(filter, Translate("All Bitmaps"), bytesLeft); bytesLeft-=lstrlenA(filter); strncat(filter, " (*.bmp;*.jpg;*.gif;*.png)", bytesLeft); - pfilter=filter+lstrlenA(filter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter = filter+lstrlenA(filter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, "*.BMP;*.RLE;*.JPG;*.JPEG;*.GIF;*.PNG", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, Translate("Windows Bitmaps"), bytesLeft); bytesLeft-=lstrlenA(pfilter); strncat(pfilter, " (*.bmp;*.rle)", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, "*.BMP;*.RLE", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, Translate("JPEG Bitmaps"), bytesLeft); bytesLeft-=lstrlenA(pfilter); strncat(pfilter, " (*.jpg;*.jpeg)", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, "*.JPG;*.JPEG", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, Translate("GIF Bitmaps"), bytesLeft); bytesLeft-=lstrlenA(pfilter); strncat(pfilter, " (*.gif)", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, "*.GIF", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, Translate("PNG Bitmaps"), bytesLeft); bytesLeft-=lstrlenA(pfilter); strncat(pfilter, " (*.png)", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, "*.PNG", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, Translate("All Files"), bytesLeft); bytesLeft-=lstrlenA(pfilter); strncat(pfilter, " (*)", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpynA(pfilter, "*", bytesLeft); - pfilter+=lstrlenA(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlenA(pfilter)+1; bytesLeft = wParam-(pfilter-filter); - if (bytesLeft) *pfilter='\0'; + if (bytesLeft) *pfilter = '\0'; return 0; } static INT_PTR BmpFilterGetStringsW(WPARAM wParam, LPARAM lParam) { - int bytesLeft=wParam; - TCHAR *filter=(TCHAR*)lParam, *pfilter; + int bytesLeft = wParam; + TCHAR *filter = (TCHAR*)lParam, *pfilter; lstrcpyn(filter, TranslateT("All Bitmaps"), bytesLeft); bytesLeft-=lstrlen(filter); _tcsncat(filter, _T(" (*.bmp;*.jpg;*.gif;*.png)"), bytesLeft); - pfilter=filter+lstrlen(filter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter = filter+lstrlen(filter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, _T("*.BMP;*.RLE;*.JPG;*.JPEG;*.GIF;*.PNG"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, TranslateT("Windows Bitmaps"), bytesLeft); bytesLeft-=lstrlen(pfilter); _tcsncat(pfilter, _T(" (*.bmp;*.rle)"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, _T("*.BMP;*.RLE"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, TranslateT("JPEG Bitmaps"), bytesLeft); bytesLeft-=lstrlen(pfilter); _tcsncat(pfilter, _T(" (*.jpg;*.jpeg)"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, _T("*.JPG;*.JPEG"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, TranslateT("GIF Bitmaps"), bytesLeft); bytesLeft-=lstrlen(pfilter); _tcsncat(pfilter, _T(" (*.gif)"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, _T("*.GIF"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, TranslateT("PNG Bitmaps"), bytesLeft); bytesLeft-=lstrlen(pfilter); _tcsncat(pfilter, _T(" (*.png)"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, _T("*.PNG"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, TranslateT("All Files"), bytesLeft); bytesLeft-=lstrlen(pfilter); _tcsncat(pfilter, _T(" (*)"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); lstrcpyn(pfilter, _T("*"), bytesLeft); - pfilter+=lstrlen(pfilter)+1; bytesLeft=wParam-(pfilter-filter); + pfilter+=lstrlen(pfilter)+1; bytesLeft = wParam-(pfilter-filter); - if (bytesLeft) *pfilter='\0'; + if (bytesLeft) *pfilter = '\0'; return 0; } diff --git a/src/modules/utils/colourpicker.cpp b/src/modules/utils/colourpicker.cpp index dd31bf7155..badfcb712e 100644 --- a/src/modules/utils/colourpicker.cpp +++ b/src/modules/utils/colourpicker.cpp @@ -42,15 +42,15 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wPar return GetWindowLongPtr(hwnd, 0); case WM_LBUTTONUP: { - CHOOSECOLOR cc={0}; - COLORREF custColours[16]={0}; - custColours[0]=GetWindowLongPtr(hwnd, sizeof(COLORREF)); - cc.lStructSize=sizeof(CHOOSECOLOR); - cc.hwndOwner=hwnd; - cc.hInstance=(HWND)hInst; - cc.rgbResult=GetWindowLongPtr(hwnd, 0); - cc.lpCustColors=custColours; - cc.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT; + CHOOSECOLOR cc = {0}; + COLORREF custColours[16] = {0}; + custColours[0] = GetWindowLongPtr(hwnd, sizeof(COLORREF)); + cc.lStructSize = sizeof(CHOOSECOLOR); + cc.hwndOwner = hwnd; + cc.hInstance = (HWND)hInst; + cc.rgbResult = GetWindowLongPtr(hwnd, 0); + cc.lpCustColors = custColours; + cc.Flags = CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT; if (ChooseColor(&cc)) { SetWindowLongPtr(hwnd, 0, cc.rgbResult); SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), CPN_COLOURCHANGED), (LPARAM)hwnd); @@ -68,14 +68,14 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wPar RECT rc; HBRUSH hBrush; - hdc1=BeginPaint(hwnd, &ps); + hdc1 = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rc); DrawEdge(hdc1, &rc, EDGE_ETCHED, BF_RECT); InflateRect(&rc, -2, -2); if (IsWindowEnabled(hwnd)) - hBrush=CreateSolidBrush(GetWindowLongPtr(hwnd, 0)); + hBrush = CreateSolidBrush(GetWindowLongPtr(hwnd, 0)); else - hBrush=CreateHatchBrush(HS_BDIAGONAL, GetSysColor(COLOR_GRAYTEXT)); + hBrush = CreateHatchBrush(HS_BDIAGONAL, GetSysColor(COLOR_GRAYTEXT)); SetBkColor(hdc1, GetSysColor(COLOR_BTNFACE)); FillRect(hdc1, &rc, hBrush); DeleteObject(hBrush); @@ -92,16 +92,16 @@ int InitColourPicker(void) { WNDCLASS wcl; - wcl.lpfnWndProc=ColourPickerWndProc; - wcl.cbClsExtra=0; - wcl.cbWndExtra=sizeof(COLORREF)*2; - wcl.hInstance=hInst; - wcl.hCursor=NULL; - wcl.lpszClassName=WNDCLASS_COLOURPICKER; - wcl.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1); - wcl.hIcon=NULL; - wcl.lpszMenuName=NULL; - wcl.style=CS_HREDRAW|CS_VREDRAW|CS_GLOBALCLASS; + wcl.lpfnWndProc = ColourPickerWndProc; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = sizeof(COLORREF)*2; + wcl.hInstance = hInst; + wcl.hCursor = NULL; + wcl.lpszClassName = WNDCLASS_COLOURPICKER; + wcl.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); + wcl.hIcon = NULL; + wcl.lpszMenuName = NULL; + wcl.style = CS_HREDRAW|CS_VREDRAW|CS_GLOBALCLASS; RegisterClass(&wcl); return 0; } diff --git a/src/modules/utils/hyperlink.cpp b/src/modules/utils/hyperlink.cpp index ae372a9017..dceff9dd11 100644 --- a/src/modules/utils/hyperlink.cpp +++ b/src/modules/utils/hyperlink.cpp @@ -39,21 +39,21 @@ struct HyperlinkWndData { static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - struct HyperlinkWndData *dat=(struct HyperlinkWndData*)GetWindowLongPtr(hwnd, 0); + struct HyperlinkWndData *dat = (struct HyperlinkWndData*)GetWindowLongPtr(hwnd, 0); switch(msg) { case WM_NCCREATE: - dat=(struct HyperlinkWndData*)mir_calloc(sizeof(struct HyperlinkWndData)); + dat = (struct HyperlinkWndData*)mir_calloc(sizeof(struct HyperlinkWndData)); if (dat == NULL) return FALSE; /* fail creation */ SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat); /* always succeeds */ /* fall thru */ case WM_SYSCOLORCHANGE: if ( !(dat->flags&HLKF_HASENABLECOLOR)) { - if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL) dat->enableColor=RGB(0, 0, 255); - else dat->enableColor=GetSysColor(COLOR_HOTLIGHT); + if (GetSysColorBrush(COLOR_HOTLIGHT) == NULL) dat->enableColor = RGB(0, 0, 255); + else dat->enableColor = GetSysColor(COLOR_HOTLIGHT); dat->focusColor = RGB(GetRValue(dat->enableColor) / 2, GetGValue(dat->enableColor) / 2, GetBValue(dat->enableColor) / 2); } if ( !(dat->flags&HLKF_HASDISABLECOLOR)) - dat->disableColor=GetSysColor(COLOR_GRAYTEXT); + dat->disableColor = GetSysColor(COLOR_GRAYTEXT); break; case WM_SETFOCUS: @@ -109,15 +109,15 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA { LOGFONT lf; HFONT hFont; if ((HFONT)wParam == NULL) { /* use default system color */ - dat->hEnableFont=dat->hDisableFont=NULL; + dat->hEnableFont = dat->hDisableFont = NULL; return 0; } if (GetObject((HFONT)wParam, sizeof(lf), &lf)) { - lf.lfUnderline=1; - hFont=CreateFontIndirect(&lf); + lf.lfUnderline = 1; + hFont = CreateFontIndirect(&lf); if (hFont != NULL) { - dat->hEnableFont=hFont; - dat->hDisableFont=(HFONT)wParam; + dat->hEnableFont = hFont; + dat->hDisableFont = (HFONT)wParam; if (LOWORD(lParam)) SendMessage(hwnd, HLK_INVALIDATE, 0, 0); SendMessage(hwnd, HLK_MEASURETEXT, 0, 0); } @@ -132,15 +132,15 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA POINT pt; HWND hwndParent; if ( !GetWindowRect(hwnd, &rcWnd)) break; - pt.x=rcWnd.left; - pt.y=rcWnd.top; - hwndParent=GetParent(hwnd); - if (hwndParent == NULL) hwndParent=hwnd; + pt.x = rcWnd.left; + pt.y = rcWnd.top; + hwndParent = GetParent(hwnd); + if (hwndParent == NULL) hwndParent = hwnd; if ( !ScreenToClient(hwndParent, &pt)) break; - rcWnd.right=pt.x+(rcWnd.right-rcWnd.left); - rcWnd.bottom=pt.y+(rcWnd.bottom-rcWnd.top); - rcWnd.left=pt.x; - rcWnd.top=pt.y; + rcWnd.right = pt.x+(rcWnd.right-rcWnd.left); + rcWnd.bottom = pt.y+(rcWnd.bottom-rcWnd.top); + rcWnd.left = pt.x; + rcWnd.top = pt.y; InvalidateRect(hwndParent, &rcWnd, TRUE); return 0; } @@ -150,7 +150,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case HLK_MEASURETEXT: { TCHAR szText[256]; if ( !GetWindowText(hwnd, szText, SIZEOF(szText))) return 0; - lParam=(LPARAM)szText; + lParam = (LPARAM)szText; /* fall thru */ case WM_SETTEXT: { HFONT hPrevFont = NULL; @@ -158,21 +158,21 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA RECT rc; HDC hdc; LONG style; - BOOL fMeasured=FALSE; - hdc=GetDC(hwnd); + BOOL fMeasured = FALSE; + hdc = GetDC(hwnd); if (hdc == NULL) return 0; /* text change failed */ - if (dat->hEnableFont != NULL) hPrevFont=(HFONT)SelectObject(hdc, dat->hEnableFont); + if (dat->hEnableFont != NULL) hPrevFont = (HFONT)SelectObject(hdc, dat->hEnableFont); if (dat->hEnableFont == NULL || hPrevFont != NULL) /* select failed? */ if (GetTextExtentPoint32(hdc, (TCHAR*)lParam, lstrlen((TCHAR*)lParam), &textSize)) if (GetClientRect(hwnd, &rc)) { - dat->rcText.top=0; - dat->rcText.bottom=dat->rcText.top+textSize.cy; - style=GetWindowLongPtr(hwnd, GWL_STYLE); - if (style&SS_CENTER) dat->rcText.left=(rc.right-textSize.cx)/2; - else if (style&SS_RIGHT) dat->rcText.left=rc.right-textSize.cx; - else dat->rcText.left=0; - dat->rcText.right=dat->rcText.left+textSize.cx; - fMeasured=TRUE; + dat->rcText.top = 0; + dat->rcText.bottom = dat->rcText.top+textSize.cy; + style = GetWindowLongPtr(hwnd, GWL_STYLE); + if (style&SS_CENTER) dat->rcText.left = (rc.right-textSize.cx)/2; + else if (style&SS_RIGHT) dat->rcText.left = rc.right-textSize.cx; + else dat->rcText.left = 0; + dat->rcText.right = dat->rcText.left+textSize.cx; + fMeasured = TRUE; } if (dat->hEnableFont != NULL && hPrevFont != NULL) SelectObject(hdc, hPrevFont); ReleaseDC(hwnd, hdc); @@ -186,23 +186,23 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA if ( !GetCursorPos(&pt)) return FALSE; if ( !ScreenToClient(hwnd, &pt)) return FALSE; if (PtInRect(&dat->rcText, pt)) { - hCursor=(HCURSOR)GetClassLongPtr(hwnd, GCLP_HCURSOR); - if (hCursor == NULL) hCursor=LoadCursor(NULL, IDC_HAND); /* Win2000+ */ + hCursor = (HCURSOR)GetClassLongPtr(hwnd, GCLP_HCURSOR); + if (hCursor == NULL) hCursor = LoadCursor(NULL, IDC_HAND); /* Win2000+ */ } - else hCursor=LoadCursor(NULL, IDC_ARROW); + else hCursor = LoadCursor(NULL, IDC_ARROW); SetCursor(hCursor); return TRUE; } case HLK_SETENABLECOLOUR: - { COLORREF prevColor=dat->enableColor; - dat->enableColor=(COLORREF)wParam; + { COLORREF prevColor = dat->enableColor; + dat->enableColor = (COLORREF)wParam; dat->focusColor = RGB(GetRValue(dat->enableColor) / 2, GetGValue(dat->enableColor) / 2, GetBValue(dat->enableColor) / 2); dat->flags|=HLKF_HASENABLECOLOR; return (LRESULT)prevColor; } case HLK_SETDISABLECOLOUR: - { COLORREF prevColor=dat->disableColor; - dat->disableColor=(COLORREF)wParam; + { COLORREF prevColor = dat->disableColor; + dat->disableColor = (COLORREF)wParam; dat->flags|=HLKF_HASDISABLECOLOR; return (LRESULT)prevColor; } @@ -217,14 +217,14 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA PAINTSTRUCT ps; HDC hdc; - hdc=BeginPaint(hwnd, &ps); + hdc = BeginPaint(hwnd, &ps); if (hdc != NULL) { if (IsWindowEnabled(hwnd)) { - hPrevFont=(HFONT)SelectObject(hdc, dat->hEnableFont); + hPrevFont = (HFONT)SelectObject(hdc, dat->hEnableFont); textColor = (GetFocus() == hwnd) ? dat->focusColor : dat->enableColor; } else { - hPrevFont=(HFONT)SelectObject(hdc, dat->hDisableFont); - textColor=dat->disableColor; + hPrevFont = (HFONT)SelectObject(hdc, dat->hDisableFont); + textColor = dat->disableColor; } if (GetClientRect(hwnd, &rc) && GetWindowText(hwnd, szText, SIZEOF(szText))) { if (drawThemeParentBackground && IsWinVerXPPlus()) @@ -238,7 +238,7 @@ static LRESULT CALLBACK HyperlinkWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA } SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, textColor); - alignFlag=(GetWindowLongPtr(hwnd, GWL_STYLE)&(SS_CENTER|SS_RIGHT|SS_LEFT)); + alignFlag = (GetWindowLongPtr(hwnd, GWL_STYLE)&(SS_CENTER|SS_RIGHT|SS_LEFT)); DrawText(hdc, szText, -1, &rc, alignFlag|DT_NOPREFIX|DT_SINGLELINE|DT_TOP); } if (hPrevFont != NULL) SelectObject(hdc, hPrevFont); @@ -258,17 +258,17 @@ int InitHyperlink(void) { WNDCLASS wcl; - wcl.lpfnWndProc=HyperlinkWndProc; - wcl.cbClsExtra=0; - wcl.cbWndExtra=sizeof(struct HyperlinkWndData*); - wcl.hInstance=hInst; - if (IsWinVer2000Plus()) wcl.hCursor=NULL; - else wcl.hCursor=LoadCursor(wcl.hInstance, MAKEINTRESOURCE(IDC_HYPERLINKHAND)); - wcl.lpszClassName=WNDCLASS_HYPERLINK; - wcl.hbrBackground=NULL; - wcl.hIcon=NULL; - wcl.lpszMenuName=NULL; - wcl.style=CS_HREDRAW|CS_VREDRAW|CS_GLOBALCLASS|CS_PARENTDC; + wcl.lpfnWndProc = HyperlinkWndProc; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = sizeof(struct HyperlinkWndData*); + wcl.hInstance = hInst; + if (IsWinVer2000Plus()) wcl.hCursor = NULL; + else wcl.hCursor = LoadCursor(wcl.hInstance, MAKEINTRESOURCE(IDC_HYPERLINKHAND)); + wcl.lpszClassName = WNDCLASS_HYPERLINK; + wcl.hbrBackground = NULL; + wcl.hIcon = NULL; + wcl.lpszMenuName = NULL; + wcl.style = CS_HREDRAW|CS_VREDRAW|CS_GLOBALCLASS|CS_PARENTDC; RegisterClass(&wcl); /* automatically unregistered on exit */ return 0; } diff --git a/src/modules/utils/imgconv.cpp b/src/modules/utils/imgconv.cpp index d4d72f066e..216167316b 100644 --- a/src/modules/utils/imgconv.cpp +++ b/src/modules/utils/imgconv.cpp @@ -53,7 +53,7 @@ void ConvertToPARGB32(HDC hdc, ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cx if (*pargbMask++) { // transparent pixel - *pargb++ = 0; + *pargb++=0; } else { diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp index bf875f9d74..7ce014725d 100644 --- a/src/modules/utils/path.cpp +++ b/src/modules/utils/path.cpp @@ -361,7 +361,7 @@ XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) if (*p == '%') { if (varStart) { if (p == varStart) - *q++ = '%'; + *q++='%'; else if (XCHAR *value = GetVariableFromArray(data->variables, varStart, p-varStart, data->hContact, &bFree)) { _xcscpy(q, value); q += _xcslen(value); @@ -377,7 +377,7 @@ XCHAR *ReplaceVariables(XCHAR *str, REPLACEVARSDATA *data) else varStart = p+1; } else if ( !varStart) - *q++ = *p; + *q++=*p; } *q = 0; diff --git a/src/modules/utils/resizer.cpp b/src/modules/utils/resizer.cpp index a443fef0ae..0f9b0b418f 100644 --- a/src/modules/utils/resizer.cpp +++ b/src/modules/utils/resizer.cpp @@ -48,7 +48,7 @@ typedef struct { INT_PTR ResizeDialog(WPARAM, LPARAM lParam) { - UTILRESIZEDIALOG *urd=(UTILRESIZEDIALOG*)lParam; + UTILRESIZEDIALOG *urd = (UTILRESIZEDIALOG*)lParam; HDWP hDwp; int i; DLGITEMTEMPLATE *pItem = NULL; @@ -62,14 +62,14 @@ INT_PTR ResizeDialog(WPARAM, LPARAM lParam) int extendedDlg, itemCount; if (urd == NULL || urd->cbSize != sizeof(UTILRESIZEDIALOG)) return 1; - pTemplate=(DLGTEMPLATE*)LockResource(LoadResource(urd->hInstance, FindResourceA(urd->hInstance, urd->lpTemplate, MAKEINTRESOURCEA(5)))); - pTemplateEx=(START_OF_DLGTEMPLATEEX*)pTemplate; - extendedDlg=pTemplateEx->signature == 0xFFFF; + pTemplate = (DLGTEMPLATE*)LockResource(LoadResource(urd->hInstance, FindResourceA(urd->hInstance, urd->lpTemplate, MAKEINTRESOURCEA(5)))); + pTemplateEx = (START_OF_DLGTEMPLATEEX*)pTemplate; + extendedDlg = pTemplateEx->signature == 0xFFFF; if (extendedDlg && pTemplateEx->dlgVer != 1) return 1; - if (extendedDlg) pWord=(PWORD)(pTemplateEx+1); - else pWord=(PWORD)(pTemplate+1); + if (extendedDlg) pWord = (PWORD)(pTemplateEx+1); + else pWord = (PWORD)(pTemplate+1); if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //menu if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //class while (*pWord++); //title @@ -86,36 +86,36 @@ INT_PTR ResizeDialog(WPARAM, LPARAM lParam) } } - urc.cbSize=sizeof(UTILRESIZECONTROL); - rc.left=0; rc.top=0; - if (extendedDlg) {rc.right=pTemplateEx->cx; rc.bottom=pTemplateEx->cy;} - else {rc.right=pTemplate->cx; rc.bottom=pTemplate->cy;} + urc.cbSize = sizeof(UTILRESIZECONTROL); + rc.left = 0; rc.top = 0; + if (extendedDlg) {rc.right = pTemplateEx->cx; rc.bottom = pTemplateEx->cy;} + else {rc.right = pTemplate->cx; rc.bottom = pTemplate->cy;} MapDialogRect(urd->hwndDlg, &rc); - urc.dlgOriginalSize.cx=rc.right; urc.dlgOriginalSize.cy=rc.bottom; + urc.dlgOriginalSize.cx = rc.right; urc.dlgOriginalSize.cy = rc.bottom; GetClientRect(urd->hwndDlg, &rc); - urc.dlgNewSize.cx=rc.right; urc.dlgNewSize.cy=rc.bottom; + urc.dlgNewSize.cx = rc.right; urc.dlgNewSize.cy = rc.bottom; - if (extendedDlg) itemCount=pTemplateEx->cDlgItems; - else itemCount=pTemplate->cdit; - hDwp=BeginDeferWindowPos(itemCount); + if (extendedDlg) itemCount = pTemplateEx->cDlgItems; + else itemCount = pTemplate->cdit; + hDwp = BeginDeferWindowPos(itemCount); for (i=0;iid; - urc.rcItem.left=pItemEx->x; urc.rcItem.top=pItemEx->y; - urc.rcItem.right=urc.rcItem.left+pItemEx->cx; urc.rcItem.bottom=urc.rcItem.top+pItemEx->cy; + urc.wId = pItemEx->id; + urc.rcItem.left = pItemEx->x; urc.rcItem.top = pItemEx->y; + urc.rcItem.right = urc.rcItem.left+pItemEx->cx; urc.rcItem.bottom = urc.rcItem.top+pItemEx->cy; } else { - pItem=(DLGITEMTEMPLATE*)pWord; - pWord=(PWORD)(pItem+1); + pItem = (DLGITEMTEMPLATE*)pWord; + pWord = (PWORD)(pItem+1); - urc.wId=pItem->id; - urc.rcItem.left=pItem->x; urc.rcItem.top=pItem->y; - urc.rcItem.right=urc.rcItem.left+pItem->cx; urc.rcItem.bottom=urc.rcItem.top+pItem->cy; + urc.wId = pItem->id; + urc.rcItem.left = pItem->x; urc.rcItem.top = pItem->y; + urc.rcItem.right = urc.rcItem.left+pItem->cx; urc.rcItem.bottom = urc.rcItem.top+pItem->cy; } if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //menu if (*pWord == 0xFFFF) pWord+=2; else while (*pWord++); //class @@ -124,7 +124,7 @@ INT_PTR ResizeDialog(WPARAM, LPARAM lParam) if (urc.wId == 65535) continue; //using this breaks the dwp, so just ignore it MapDialogRect(urd->hwndDlg, &urc.rcItem); - procResult=(urd->pfnResizer)(urd->hwndDlg, urd->lParam, &urc); + procResult = (urd->pfnResizer)(urd->hwndDlg, urd->lParam, &urc); if (procResult&RD_ANCHORX_RIGHT) { urc.rcItem.left+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; diff --git a/src/modules/utils/timeutils.cpp b/src/modules/utils/timeutils.cpp index 5e921566d5..205457e76d 100644 --- a/src/modules/utils/timeutils.cpp +++ b/src/modules/utils/timeutils.cpp @@ -84,7 +84,7 @@ void FormatTime(const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, int default: if (destCharsLeft--) - *pDest++ = *pFormat; + *pDest++=*pFormat; continue; } diff --git a/src/modules/utils/timezones.cpp b/src/modules/utils/timezones.cpp index bf83dfeb75..f22b18829c 100644 --- a/src/modules/utils/timezones.cpp +++ b/src/modules/utils/timezones.cpp @@ -341,10 +341,10 @@ typedef struct UINT addStr, getSel, setSel, getData, setData; } ListMessages; -static const ListMessages lbMessages = +static const ListMessages lbMessages = { LB_ADDSTRING, LB_GETCURSEL, LB_SETCURSEL, LB_GETITEMDATA, LB_SETITEMDATA }; -static const ListMessages cbMessages = +static const ListMessages cbMessages = { CB_ADDSTRING, CB_GETCURSEL, CB_SETCURSEL, CB_GETITEMDATA, CB_SETITEMDATA }; static const ListMessages *GetListMessages(HWND hWnd, DWORD dwFlags) @@ -382,7 +382,7 @@ static int timeapiSelectListItem(HANDLE hContact, HWND hWnd, DWORD dwFlags) if ( !DBGetContactSettingTString(hContact, "UserInfo", "TzName", &dbv)) { unsigned hash = mir_hashstrT(dbv.ptszVal); - for (int i = 0; i < g_timezonesBias.getCount(); ++i) + for (int i=0; i < g_timezonesBias.getCount(); ++i) { if (hash == g_timezonesBias[i]->hash) { @@ -409,7 +409,7 @@ static int timeapiPrepareList(HANDLE hContact, HWND hWnd, DWORD dwFlags) SendMessage(hWnd, lstMsg->addStr, 0, (LPARAM)TranslateT("")); - for (int i = 0; i < g_timezonesBias.getCount(); ++i) + for (int i=0; i < g_timezonesBias.getCount(); ++i) { MIM_TIMEZONE *tz = g_timezonesBias[i]; @@ -451,21 +451,21 @@ static INT_PTR GetTimeApi(WPARAM, LPARAM lParam) if (tmi->cbSize != sizeof(TIME_API)) return FALSE; - tmi->createByName = timeapiGetInfoByName; - tmi->createByContact = timeapiGetInfoByContact; - tmi->storeByContact = timeapiSetInfoByContact; + tmi->createByName = timeapiGetInfoByName; + tmi->createByContact = timeapiGetInfoByContact; + tmi->storeByContact = timeapiSetInfoByContact; - tmi->printDateTime = timeapiPrintDateTime; - tmi->printTimeStamp = timeapiPrintTimeStamp; + tmi->printDateTime = timeapiPrintDateTime; + tmi->printTimeStamp = timeapiPrintTimeStamp; - tmi->prepareList = timeapiPrepareList; - tmi->selectListItem = timeapiSelectListItem; - tmi->storeListResults = timeapiStoreListResult; + tmi->prepareList = timeapiPrepareList; + tmi->selectListItem = timeapiSelectListItem; + tmi->storeListResults = timeapiStoreListResult; - tmi->getTimeZoneTime = timeapiGetTimeZoneTime; - tmi->timeStampToTimeZoneTimeStamp = timeapiTimeStampToTimeZoneTimeStamp; - tmi->getTzi = timeapiGetTzi; - tmi->getTzName = timeapiGetTzName; + tmi->getTimeZoneTime = timeapiGetTimeZoneTime; + tmi->timeStampToTimeZoneTimeStamp = timeapiTimeStampToTimeZoneTimeStamp; + tmi->getTzi = timeapiGetTzi; + tmi->getTzName = timeapiGetTzName; return TRUE; } @@ -537,7 +537,7 @@ extern "C" __declspec(dllexport) void RecalculateTime(void) found = true; } - for (int i = 0; i < g_timezones.getCount(); ++i) + for (int i=0; i < g_timezones.getCount(); ++i) { MIM_TIMEZONE &tz = g_timezones[i]; if (tz.offset != INT_MIN) tz.offset = INT_MIN; diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp index 4af0230071..64941a9b85 100644 --- a/src/modules/utils/utils.cpp +++ b/src/modules/utils/utils.cpp @@ -39,7 +39,7 @@ void UninitTimeZones(void); static BOOL bModuleInitialized = FALSE; -static struct CountryListEntry countries[]={ +static struct CountryListEntry countries[] = { {0 , "Unspecified"}, {9999, "Other"}, {0xFFFF, "Unknown"}, @@ -310,7 +310,7 @@ static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM) static INT_PTR GetCountryList(WPARAM wParam, LPARAM lParam) { *(int*)wParam = SIZEOF(countries); - *(struct CountryListEntry**)lParam=countries; + *(struct CountryListEntry**)lParam = countries; return 0; } @@ -318,11 +318,11 @@ static INT_PTR GetCountryList(WPARAM wParam, LPARAM lParam) static INT_PTR SaveWindowPosition(WPARAM, LPARAM lParam) { - SAVEWINDOWPOS *swp=(SAVEWINDOWPOS*)lParam; + SAVEWINDOWPOS *swp = (SAVEWINDOWPOS*)lParam; WINDOWPLACEMENT wp; char szSettingName[64]; - wp.length=sizeof(wp); + wp.length = sizeof(wp); GetWindowPlacement(swp->hwnd, &wp); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", swp->szNamePrefix); DBWriteContactSettingDword(swp->hContact, swp->szModule, szSettingName, wp.rcNormalPosition.left); @@ -377,30 +377,30 @@ static INT_PTR AssertInsideScreen(WPARAM wParam, LPARAM lParam) static INT_PTR RestoreWindowPosition(WPARAM wParam, LPARAM lParam) { - SAVEWINDOWPOS *swp=(SAVEWINDOWPOS*)lParam; + SAVEWINDOWPOS *swp = (SAVEWINDOWPOS*)lParam; WINDOWPLACEMENT wp; char szSettingName[64]; int x, y; - wp.length=sizeof(wp); + wp.length = sizeof(wp); GetWindowPlacement(swp->hwnd, &wp); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", swp->szNamePrefix); - x=DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); + x = DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", swp->szNamePrefix); - y=(int)DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); + y = (int)DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); if (x == -1) return 1; if (wParam&RWPF_NOSIZE) { OffsetRect(&wp.rcNormalPosition, x-wp.rcNormalPosition.left, y-wp.rcNormalPosition.top); } else { - wp.rcNormalPosition.left=x; - wp.rcNormalPosition.top=y; + wp.rcNormalPosition.left = x; + wp.rcNormalPosition.top = y; mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", swp->szNamePrefix); - wp.rcNormalPosition.right=wp.rcNormalPosition.left+DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); + wp.rcNormalPosition.right = wp.rcNormalPosition.left+DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", swp->szNamePrefix); - wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); + wp.rcNormalPosition.bottom = wp.rcNormalPosition.top+DBGetContactSettingDword(swp->hContact, swp->szModule, szSettingName, -1); } - wp.flags=0; + wp.flags = 0; if (wParam & RWPF_HIDDEN) wp.showCmd = SW_HIDE; if (wParam & RWPF_NOACTIVATE) diff --git a/src/modules/utils/windowlist.cpp b/src/modules/utils/windowlist.cpp index f1ccff236b..7230ab4a23 100644 --- a/src/modules/utils/windowlist.cpp +++ b/src/modules/utils/windowlist.cpp @@ -22,9 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "..\..\core\commonheaders.h" -static WINDOWLISTENTRY *windowList=NULL; -static int windowListCount=0; -static int nextWindowListId=1; +static WINDOWLISTENTRY *windowList = NULL; +static int windowListCount = 0; +static int nextWindowListId = 1; static INT_PTR AllocWindowList(WPARAM, LPARAM) { @@ -33,8 +33,8 @@ static INT_PTR AllocWindowList(WPARAM, LPARAM) static INT_PTR AddToWindowList(WPARAM, LPARAM lParam) { - windowList=(WINDOWLISTENTRY*)mir_realloc(windowList, sizeof(WINDOWLISTENTRY)*(windowListCount+1)); - windowList[windowListCount++]=*(WINDOWLISTENTRY*)lParam; + windowList = (WINDOWLISTENTRY*)mir_realloc(windowList, sizeof(WINDOWLISTENTRY)*(windowListCount+1)); + windowList[windowListCount++] = *(WINDOWLISTENTRY*)lParam; return 0; } @@ -62,7 +62,7 @@ static INT_PTR FindInWindowList(WPARAM wParam, LPARAM lParam) static INT_PTR BroadcastToWindowList(WPARAM wParam, LPARAM lParam) { int i; - MSG *msg=(MSG*)lParam; + MSG *msg = (MSG*)lParam; for (i=0;imessage, msg->wParam, msg->lParam); @@ -72,7 +72,7 @@ static INT_PTR BroadcastToWindowList(WPARAM wParam, LPARAM lParam) static INT_PTR BroadcastToWindowListAsync(WPARAM wParam, LPARAM lParam) { int i; - MSG *msg=(MSG*)lParam; + MSG *msg = (MSG*)lParam; for (i=0;imessage, msg->wParam, msg->lParam); @@ -96,6 +96,6 @@ void FreeWindowList(void) mir_free(windowList); windowList = NULL; } - windowListCount=0; - nextWindowListId=1; + windowListCount = 0; + nextWindowListId = 1; } diff --git a/src/modules/visibility/visibility.cpp b/src/modules/visibility/visibility.cpp index b7e67a2cd4..0de68fe01a 100644 --- a/src/modules/visibility/visibility.cpp +++ b/src/modules/visibility/visibility.cpp @@ -25,32 +25,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount) { int typeOfFirst; - int iconOn[2]={1, 1}; - int childCount[2]={0, 0}, i; + int iconOn[2] = {1, 1}; + int childCount[2] = {0, 0}, i; int iImage; HANDLE hItem, hChildItem; - typeOfFirst=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); + typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); //check groups - if (typeOfFirst == CLCIT_GROUP) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); while (hItem) { - hChildItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount); for (i=0; i < SIZEOF(iconOn); i++) - if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i]=0; - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); + if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0; + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } //check contacts - if (typeOfFirst == CLCIT_CONTACT) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { for (i=0; i < SIZEOF(iconOn); i++) { - iImage=SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); - if (iconOn[i] && iImage == 0) iconOn[i]=0; + iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i); + if (iconOn[i] && iImage == 0) iconOn[i] = 0; if (iImage != 0xFF) childCount[i]++; } - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } //set icons for (i=0; i < SIZEOF(iconOn); i++) { @@ -64,22 +64,22 @@ static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int int typeOfFirst, iOldIcon; HANDLE hItem, hChildItem; - typeOfFirst=SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); + typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0); //check groups - if (typeOfFirst == CLCIT_GROUP) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem); while (hItem) { - hChildItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); + hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem); if (hChildItem) SetAllChildIcons(hwndList, hChildItem, iColumn, iImage); - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem); } //check contacts - if (typeOfFirst == CLCIT_CONTACT) hItem=hFirstItem; - else hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); + if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem; + else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem); while (hItem) { - iOldIcon=SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); + iOldIcon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn); if (iOldIcon != 0xFF && iOldIcon != iImage) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); - hItem=(HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); + hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem); } } @@ -92,7 +92,7 @@ static void ResetListOptions(HWND hwndList) SendMessage(hwndList, CLM_SETGREYOUTFLAGS, 0, 0); SendMessage(hwndList, CLM_SETLEFTMARGIN, 2, 0); SendMessage(hwndList, CLM_SETINDENT, 10, 0); - for (i=0;i<=FONTID_MAX;i++) + for (i=0;i <= FONTID_MAX;i++) SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT)); SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE)|CLS_SHOWHIDDEN); } @@ -104,15 +104,15 @@ static void SetAllContactIcons(HWND hwndList) DWORD flags; WORD status; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); do { - hItem=(HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); + hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); if (hItem) { - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (szProto == NULL) {flags=0; status=0;} + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto == NULL) {flags = 0; status = 0;} else { - flags=CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0); - status=DBGetContactSettingWord(hContact, szProto, "ApparentMode", 0); + flags = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0); + status = DBGetContactSettingWord(hContact, szProto, "ApparentMode", 0); } if (flags&PF1_INVISLIST) { if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, 0)) == 0xFF) @@ -123,7 +123,7 @@ static void SetAllContactIcons(HWND hwndList) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, status == ID_STATUS_OFFLINE?2:0)); } } - } while (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); + } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); } static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) @@ -136,25 +136,25 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); { HIMAGELIST hIml; - hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK, 3, 3); + hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK, 3, 3); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_SMALLDOT); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_STATUS_INVISIBLE); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_STATUS_OFFLINE); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); - hVisibleIcon=ImageList_GetIcon(hIml, 1, ILD_NORMAL); + hVisibleIcon = ImageList_GetIcon(hIml, 1, ILD_NORMAL); SendDlgItemMessage(hwndDlg, IDC_VISIBLEICON, STM_SETICON, (WPARAM)hVisibleIcon, 0); - hInvisibleIcon=ImageList_GetIcon(hIml, 2, ILD_NORMAL); + hInvisibleIcon = ImageList_GetIcon(hIml, 2, ILD_NORMAL); SendDlgItemMessage(hwndDlg, IDC_INVISIBLEICON, STM_SETICON, (WPARAM)hInvisibleIcon, 0); } ResetListOptions(GetDlgItem(hwndDlg, IDC_LIST)); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRACOLUMNS, 2, 0); - { CLCINFOITEM cii={0}; - cii.cbSize=sizeof(cii); - cii.flags=CLCIIF_GROUPFONT; - cii.pszText=TranslateT("** All contacts **"); - hItemAll=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); + { CLCINFOITEM cii = {0}; + cii.cbSize = sizeof(cii); + cii.flags = CLCIIF_GROUPFONT; + cii.pszText = TranslateT("** All contacts **"); + hItemAll = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); } SetAllContactIcons(GetDlgItem(hwndDlg, IDC_LIST)); @@ -180,7 +180,7 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP break; case NM_CLICK: { HANDLE hItem; - NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam; + NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam; DWORD hitFlags; int iImage; int itemType; @@ -196,10 +196,10 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP // It was not a visbility icon if ( !(hitFlags & CLCHT_ONITEMEXTRA)) break; - // Get image in clicked column (0=none, 1=visible, 2=invisible) + // Get image in clicked column (0 = none, 1 = visible, 2 = invisible) iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0)); if (iImage == 0) - iImage=nm->iColumn + 1; + iImage = nm->iColumn + 1; else if (iImage == 1 || iImage == 2) iImage = 0; @@ -242,22 +242,22 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP { HANDLE hContact, hItem; int set, i, iImage; - hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); do { - hItem=(HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); + hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0); if (hItem) { - set=0; + set = 0; for (i=0;i<2;i++) { - iImage=SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0)); + iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0)); if (iImage == i+1) { CallContactService(hContact, PSS_SETAPPARENTMODE, iImage == 1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE, 0); - set=1; + set = 1; break; } } if ( !set) CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0); } - } while (hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); + } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)); return TRUE; } } @@ -267,7 +267,7 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP case WM_DESTROY: DestroyIcon(hVisibleIcon); DestroyIcon(hInvisibleIcon); - { HIMAGELIST hIml=(HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); + { HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); ImageList_Destroy(hIml); } break; diff --git a/src/modules/xml/xmlApi.cpp b/src/modules/xml/xmlApi.cpp index dc6387b80a..6d2a09390f 100644 --- a/src/modules/xml/xmlApi.cpp +++ b/src/modules/xml/xmlApi.cpp @@ -376,66 +376,66 @@ static INT_PTR GetXmlApi(WPARAM, LPARAM lParam) if (xi->cbSize != XML_API_SIZEOF_V1 && xi->cbSize != sizeof(XML_API)) return FALSE; - xi->createNode = xmlapiCreateNode; - xi->destroyNode = xmlapiDestroyNode; + xi->createNode = xmlapiCreateNode; + xi->destroyNode = xmlapiDestroyNode; - xi->parseString = xmlapiParseString; - xi->toString = xmlapiToString; - xi->freeMem = xmlapiFree; + xi->parseString = xmlapiParseString; + xi->toString = xmlapiToString; + xi->freeMem = xmlapiFree; - xi->addChild = xmlapiAddChild; - xi->addChild2 = xmlapiAddChild2; - xi->copyNode = xmlapiCopyNode; - xi->getChild = xmlapiGetChild; + xi->addChild = xmlapiAddChild; + xi->addChild2 = xmlapiAddChild2; + xi->copyNode = xmlapiCopyNode; + xi->getChild = xmlapiGetChild; xi->getChildByAttrValue = xmlapiGetChildByAttrValue; - xi->getChildCount = xmlapiGetChildCount; - xi->getFirstChild = xmlapiGetFirstChild; - xi->getNthChild = xmlapiGetNthChild; - xi->getNextChild = xmlapiGetNextChild; - xi->getNextNode = xmlapiGetNextNode; - xi->getChildByPath = xmlapiGetChildByPath; - xi->getName = xmlapiGetName; - xi->getParent = xmlapiGetParent; - xi->getText = xmlapiGetText; - xi->setText = xmlapiSetText; - - xi->getAttr = xmlapiGetAttr; - xi->getAttrCount = xmlapiGetAttrCount; - xi->getAttrName = xmlapiGetAttrName; - xi->getAttrValue = xmlapiGetAttrValue; - xi->addAttr = xmlapiAddAttr; - xi->addAttrInt = xmlapiAddAttrInt; + xi->getChildCount = xmlapiGetChildCount; + xi->getFirstChild = xmlapiGetFirstChild; + xi->getNthChild = xmlapiGetNthChild; + xi->getNextChild = xmlapiGetNextChild; + xi->getNextNode = xmlapiGetNextNode; + xi->getChildByPath = xmlapiGetChildByPath; + xi->getName = xmlapiGetName; + xi->getParent = xmlapiGetParent; + xi->getText = xmlapiGetText; + xi->setText = xmlapiSetText; + + xi->getAttr = xmlapiGetAttr; + xi->getAttrCount = xmlapiGetAttrCount; + xi->getAttrName = xmlapiGetAttrName; + xi->getAttrValue = xmlapiGetAttrValue; + xi->addAttr = xmlapiAddAttr; + xi->addAttrInt = xmlapiAddAttrInt; if (xi->cbSize > XML_API_SIZEOF_V1) { - xi->isDeclaration = xmlapiIsDeclaration; + xi->isDeclaration = xmlapiIsDeclaration; xi->toStringWithFormatting = xmlapiToStringWithFormatting; - xi->deepCopy = xmlapiDeepCopy; - xi->setAttrByIndex = xmlapiSetAttrByIndex; - xi->setAttrByName = xmlapiSetAttrByName; - xi->addChildEx = xmlapiAddChildEx; - xi->addChildEx2 = xmlapiAddChildEx2; - xi->getTextCount = xmlapiGetTextCount; - xi->getTextByIndex = xmlapiGetTextByIndex; - xi->addText = xmlapiAddText; - xi->setTextByIndex = xmlapiSetTextByIndex; - xi->getClearCount = xmlapiGetClearCount; - xi->getClear = xmlapiGetClear; - xi->addClear = xmlapiAddClear; - xi->setClear = xmlapiSetClear; - xi->getElementCount = xmlapiGetElementCount; - xi->getElement = xmlapiGetElement; - - xi->deleteNodeContent = xmlapiDeleteNodeContent; - xi->deleteAttrByIndex = xmlapiDeleteAttrByIndex; - xi->deleteAttrByName = xmlapiDeleteAttrByName; - xi->deleteText = xmlapiDeleteText; - xi->deleteClear = xmlapiDeleteClear; + xi->deepCopy = xmlapiDeepCopy; + xi->setAttrByIndex = xmlapiSetAttrByIndex; + xi->setAttrByName = xmlapiSetAttrByName; + xi->addChildEx = xmlapiAddChildEx; + xi->addChildEx2 = xmlapiAddChildEx2; + xi->getTextCount = xmlapiGetTextCount; + xi->getTextByIndex = xmlapiGetTextByIndex; + xi->addText = xmlapiAddText; + xi->setTextByIndex = xmlapiSetTextByIndex; + xi->getClearCount = xmlapiGetClearCount; + xi->getClear = xmlapiGetClear; + xi->addClear = xmlapiAddClear; + xi->setClear = xmlapiSetClear; + xi->getElementCount = xmlapiGetElementCount; + xi->getElement = xmlapiGetElement; + + xi->deleteNodeContent = xmlapiDeleteNodeContent; + xi->deleteAttrByIndex = xmlapiDeleteAttrByIndex; + xi->deleteAttrByName = xmlapiDeleteAttrByName; + xi->deleteText = xmlapiDeleteText; + xi->deleteClear = xmlapiDeleteClear; xi->positionOfChildByIndex = xmlapiPositionOfChildByIndex; - xi->positionOfChildByNode = xmlapiPositionOfChildByNode; - xi->positionOfChildByName = xmlapiPositionOfChildByName; - xi->positionOfText = xmlapiPositionOfText; - xi->positionOfClear = xmlapiPositionOfClear; + xi->positionOfChildByNode = xmlapiPositionOfChildByNode; + xi->positionOfChildByName = xmlapiPositionOfChildByName; + xi->positionOfText = xmlapiPositionOfText; + xi->positionOfClear = xmlapiPositionOfClear; } return TRUE; } diff --git a/src/modules/xml/xmlParser.cpp b/src/modules/xml/xmlParser.cpp index 32c81c88c8..a473c9b194 100644 --- a/src/modules/xml/xmlParser.cpp +++ b/src/modules/xml/xmlParser.cpp @@ -19,19 +19,19 @@ * * If you add "#define APPROXIMATE_PARSING" on the first line of this file * the parser will see the following XML-stream: -* -* -* +* +* +* * as equivalent to the following XML-stream: -* -* -* +* +* +* * This can be useful for badly-formed XML-streams but prevent the use * of the following XML-stream (problem is: tags at contiguous levels * have the same names): -* -* -* +* +* +* * * * @@ -43,7 +43,7 @@ * available on windows 9x/NT/2000/XP/Vista only. * * Copyright (c) 2002, Business-Insight -* Business-Insight +* Business-Insight * All rights reserved. * See the file "AFPL-license.txt" about the licensing terms * @@ -62,8 +62,8 @@ XMLCSTR XMLNode::getVersion() { return _CXML("v2.43"); } void freeXMLString(XMLSTR t) {if(t)free(t);} -static XMLNode::XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8; -static char guessWideCharChars=1, dropWhiteSpace=1, removeCommentsInMiddleOfText=1; +static XMLNode::XMLCharEncoding characterEncoding = XMLNode::char_encoding_UTF8; +static char guessWideCharChars = 1, dropWhiteSpace = 1, removeCommentsInMiddleOfText = 1; inline int mmin(const int t1, const int t2) { return t1 < t2 ? t1 : t2; } @@ -75,7 +75,7 @@ inline int mmin(const int t1, const int t2) { return t1 < t2 ? t1 : t2; } // The "0) { if (*ss == _CXML('&')) { if (ss[1] == _CXML('#')) { - ss+=2; j=0; + ss+=2; j = 0; if ((*ss == _CXML('X')) || (*ss == _CXML('x'))) { ss++; while (*ss != _CXML(';')) { - if ((*ss>=_CXML('0'))&&(*ss<=_CXML('9'))) j=(j<<4)+*ss-_CXML('0'); - else if ((*ss>=_CXML('A'))&&(*ss<=_CXML('F'))) j=(j<<4)+*ss-_CXML('A')+10; - else if ((*ss>=_CXML('a'))&&(*ss<=_CXML('f'))) j=(j<<4)+*ss-_CXML('a')+10; - else { free((void*)s); pXML->error=eXMLErrorUnknownCharacterEntity;return NULL;} + if ((*ss>=_CXML('0'))&&(*ss <= _CXML('9'))) j = (j<<4)+*ss-_CXML('0'); + else if ((*ss>=_CXML('A'))&&(*ss <= _CXML('F'))) j = (j<<4)+*ss-_CXML('A')+10; + else if ((*ss>=_CXML('a'))&&(*ss <= _CXML('f'))) j = (j<<4)+*ss-_CXML('a')+10; + else { free((void*)s); pXML->error = eXMLErrorUnknownCharacterEntity;return NULL;} ss++; } } else { while (*ss != _CXML(';')) { - if ((*ss>=_CXML('0'))&&(*ss<=_CXML('9'))) j=(j*10)+*ss-_CXML('0'); - else { free((void*)s); pXML->error=eXMLErrorUnknownCharacterEntity;return NULL;} + if ((*ss>=_CXML('0'))&&(*ss <= _CXML('9'))) j = (j*10)+*ss-_CXML('0'); + else { free((void*)s); pXML->error = eXMLErrorUnknownCharacterEntity;return NULL;} ss++; } } #ifndef _XMLWIDECHAR - if (j>255) { free((void*)s); pXML->error=eXMLErrorCharacterCodeAbove255;return NULL;} + if (j>255) { free((void*)s); pXML->error = eXMLErrorCharacterCodeAbove255;return NULL;} #endif - (*d++)=(XMLCHAR)j; ss++; + (*d++) = (XMLCHAR)j; ss++; } else { - entity=XMLEntities; + entity = XMLEntities; do { - if (xstrnicmp(ss, entity->s, entity->l) == 0) { *(d++)=entity->c; ss+=entity->l; break; } + if (xstrnicmp(ss, entity->s, entity->l) == 0) { *(d++) = entity->c; ss+=entity->l; break; } entity++; } while (entity->s); } } else { #ifdef _XMLWIDECHAR - *(d++)=*(ss++); + *(d++) = *(ss++); #else switch(XML_ByteTable[(unsigned char)*ss]) { - case 4: *(d++)=*(ss++); ll--; - case 3: *(d++)=*(ss++); ll--; - case 2: *(d++)=*(ss++); ll--; - case 1: *(d++)=*(ss++); + case 4: *(d++) = *(ss++); ll--; + case 3: *(d++) = *(ss++); ll--; + case 2: *(d++) = *(ss++); ll--; + case 1: *(d++) = *(ss++); } #endif } } - *d=0; + *d = 0; #ifndef _XMLWIDECHAR if (characterEncoding != XMLNode::char_encoding_legacy) @@ -863,7 +863,7 @@ XMLSTR fromXMLString(XMLCSTR s, int lo, XML *pXML) return (XMLSTR)s; } -#define XML_isSPACECHAR(ch) ((ch == _CXML('\n')) || (ch == _CXML(' ')) || (ch == _CXML('\t')) || (ch == _CXML('\r'))) +#define XML_isSPACECHAR(ch) ((ch == _CXML('\n')) || (ch == _CXML(' ')) || (ch == _CXML('\t')) || (ch == _CXML('\r'))) // private: char myTagCompare(XMLCSTR cclose, XMLCSTR copen) @@ -872,9 +872,9 @@ char myTagCompare(XMLCSTR cclose, XMLCSTR copen) // return 1 if different { if ( !cclose) return 1; - int l=(int)xstrlen(cclose); + int l = (int)xstrlen(cclose); if (xstrnicmp(cclose, copen, l) != 0) return 1; - const XMLCHAR c=copen[l]; + const XMLCHAR c = copen[l]; if (XML_isSPACECHAR(c) || (c == _CXML('/')) || (c == _CXML('<')) || @@ -902,11 +902,11 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT NextToken result; XMLCHAR ch; XMLCHAR chTemp; - int indexStart, nFoundMatch, nIsText=FALSE; - result.pClr=NULL; // prevent warning + int indexStart, nFoundMatch, nIsText = FALSE; + result.pClr = NULL; // prevent warning // Find next non-white space character - do { indexStart=pXML->nIndex; ch=getNextChar(pXML); } while XML_isSPACECHAR(ch); + do { indexStart = pXML->nIndex; ch = getNextChar(pXML); } while XML_isSPACECHAR(ch); if (ch) { @@ -936,8 +936,8 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT // If we failed to find a matching quote if (nFoundMatch == FALSE) { - pXML->nIndex=indexStart+1; - nIsText=TRUE; + pXML->nIndex = indexStart+1; + nIsText = TRUE; break; } @@ -962,14 +962,14 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT { // First check whether the token is in the clear tag list (meaning it // does not need formatting). - ALLXMLClearTag *ctag=XMLClearTags; + ALLXMLClearTag *ctag = XMLClearTags; do { if ( !xstrncmp(ctag->lpszOpen, result.pStr, ctag->openTagLen)) { - result.pClr=ctag; + result.pClr = ctag; pXML->nIndex+=ctag->openTagLen-1; - *pType=eTokenClear; + *pType = eTokenClear; return result; } ctag++; @@ -1042,7 +1042,7 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT { // If we find a slash then this maybe text or a short hand end tag // Peek at the next character to see it we have short hand end tag - ch=pXML->lpXML[pXML->nIndex]; + ch = pXML->lpXML[pXML->nIndex]; // If we found a short hand end tag then we need to exit the loop if (ch == _CXML('>')) { pXML->nIndex--; break; } @@ -1058,7 +1058,7 @@ static NextToken GetNextToken(XML *pXML, int *pcbToken, enum XMLTokenTypeTag *pT // If we failed to obtain a valid character *pcbToken = 0; *pType = eTokenError; - result.pStr=NULL; + result.pStr = NULL; } return result; @@ -1068,19 +1068,19 @@ XMLCSTR XMLNode::updateName_WOSD(XMLSTR lpszName) { if ( !d) { free(lpszName); return NULL; } if (d->lpszName&&(lpszName != d->lpszName)) free((void*)d->lpszName); - d->lpszName=lpszName; + d->lpszName = lpszName; return lpszName; } // private: -XMLNode::XMLNode(struct XMLNodeDataTag *p) { d=p; (p->ref_count)++; } +XMLNode::XMLNode(struct XMLNodeDataTag *p) { d = p; (p->ref_count)++; } XMLNode::XMLNode(XMLNodeData *pParent, XMLSTR lpszName, char isDeclaration) { - d=(XMLNodeData*)malloc(sizeof(XMLNodeData)); - d->ref_count=1; + d = (XMLNodeData*)malloc(sizeof(XMLNodeData)); + d->ref_count = 1; - d->lpszName=NULL; - d->nChild= 0; + d->lpszName = NULL; + d->nChild = 0; d->nText = 0; d->nClear = 0; d->nAttribute = 0; @@ -1088,13 +1088,13 @@ XMLNode::XMLNode(XMLNodeData *pParent, XMLSTR lpszName, char isDeclaration) d->isDeclaration = isDeclaration; d->pParent = pParent; - d->pChild= NULL; - d->pText= NULL; - d->pClear= NULL; - d->pAttribute= NULL; - d->pOrder= NULL; + d->pChild = NULL; + d->pText = NULL; + d->pClear = NULL; + d->pAttribute = NULL; + d->pOrder = NULL; - d->pInnerText= NULL; + d->pInnerText = NULL; updateName_WOSD(lpszName); @@ -1118,7 +1118,7 @@ static inline void myFree(void *p) { if (p) free(p); } static inline void *myRealloc(void *p, int newsize, int memInc, int sizeofElem) { if (p == NULL) { if (memInc) return malloc(memInc*sizeofElem); return malloc(sizeofElem); } - if ((memInc == 0) || ((newsize%memInc) == 0)) p=realloc(p, (newsize+memInc)*sizeofElem); + if ((memInc == 0) || ((newsize%memInc) == 0)) p = realloc(p, (newsize+memInc)*sizeofElem); // if ( !p) // { // printf("XMLParser Error: Not enough memory! Aborting...\n"); exit(220); @@ -1130,19 +1130,19 @@ static inline void *myRealloc(void *p, int newsize, int memInc, int sizeofElem) XMLElementPosition XMLNode::findPosition(XMLNodeData *d, int index, XMLElementType xxtype) { if (index<0) return -1; - int i=0, j=(int)((index<<2)+xxtype), *o=d->pOrder; while (o[i] != j) i++; return i; + int i=0, j = (int)((index<<2)+xxtype), *o = d->pOrder; while (o[i] != j) i++; return i; } // private: // update "order" information when deleting a content of a XMLNode int XMLNode::removeOrderElement(XMLNodeData *d, XMLElementType t, int index) { - int n=d->nChild+d->nText+d->nClear, *o=d->pOrder, i=findPosition(d, index, t); + int n = d->nChild+d->nText+d->nClear, *o = d->pOrder, i = findPosition(d, index, t); memmove(o+i, o+i+1, (n-i)*sizeof(int)); for (;ipOrder=(int)realloc(d->pOrder, n*sizeof(int)); + // d->pOrder = (int)realloc(d->pOrder, n*sizeof(int)); // but we skip reallocation because it's too time consuming. // Anyway, at the end, it will be free'd completely at once. return i; @@ -1152,23 +1152,23 @@ void *XMLNode::addToOrder(int memoryIncrease, int *_pos, int nc, void *p, int si { // in: *_pos is the position inside d->pOrder ("-1" means "EndOf") // out: *_pos is the index inside p - p=myRealloc(p, (nc+1), memoryIncrease, size); - int n=d->nChild+d->nText+d->nClear; - d->pOrder=(int*)myRealloc(d->pOrder, n+1, memoryIncrease*3, sizeof(int)); - int pos=*_pos, *o=d->pOrder; + p = myRealloc(p, (nc+1), memoryIncrease, size); + int n = d->nChild+d->nText+d->nClear; + d->pOrder = (int*)myRealloc(d->pOrder, n+1, memoryIncrease*3, sizeof(int)); + int pos = *_pos, *o = d->pOrder; - if ((pos<0) || (pos>=n)) { *_pos=nc; o[n]=(int)((nc<<2)+xtype); return p; } + if ((pos<0) || (pos>=n)) { *_pos = nc; o[n] = (int)((nc<<2)+xtype); return p; } - int i=pos; + int i = pos; memmove(o+i+1, o+i, (n-i)*sizeof(int)); while ((pos>2; + *_pos = pos = o[pos]>>2; memmove(((char*)p)+(pos+1)*size, ((char*)p)+pos*size, (nc-pos)*size); return p; @@ -1178,9 +1178,9 @@ void *XMLNode::addToOrder(int memoryIncrease, int *_pos, int nc, void *p, int si XMLNode XMLNode::addChild_priv(int memoryIncrease, XMLSTR lpszName, char isDeclaration, int pos) { if ( !lpszName) return emptyXMLNode; - d->pChild=(XMLNode*)addToOrder(memoryIncrease, &pos, d->nChild, d->pChild, sizeof(XMLNode), eNodeChild); - d->pChild[pos].d=NULL; - d->pChild[pos]=XMLNode(d, lpszName, isDeclaration); + d->pChild = (XMLNode*)addToOrder(memoryIncrease, &pos, d->nChild, d->pChild, sizeof(XMLNode), eNodeChild); + d->pChild[pos].d = NULL; + d->pChild[pos] = XMLNode(d, lpszName, isDeclaration); d->nChild++; return d->pChild[pos]; } @@ -1190,9 +1190,9 @@ XMLAttribute *XMLNode::addAttribute_priv(int memoryIncrease, XMLSTR lpszName, XM { if ( !lpszName) return &emptyXMLAttribute; if ( !d) { myFree(lpszName); myFree(lpszValuev); return &emptyXMLAttribute; } - int nc=d->nAttribute; - d->pAttribute=(XMLAttribute*)myRealloc(d->pAttribute, (nc+1), memoryIncrease, sizeof(XMLAttribute)); - XMLAttribute *pAttr=d->pAttribute+nc; + int nc = d->nAttribute; + d->pAttribute = (XMLAttribute*)myRealloc(d->pAttribute, (nc+1), memoryIncrease, sizeof(XMLAttribute)); + XMLAttribute *pAttr = d->pAttribute+nc; pAttr->lpszName = lpszName; pAttr->lpszValue = lpszValuev; d->nAttribute++; @@ -1211,8 +1211,8 @@ XMLCSTR XMLNode::addText_priv(int memoryIncrease, XMLSTR lpszValue, int pos) if ( !lpszValue) return NULL; if ( !d) { myFree(lpszValue); return NULL; } invalidateInnerText(); - d->pText=(XMLCSTR*)addToOrder(memoryIncrease, &pos, d->nText, d->pText, sizeof(XMLSTR), eNodeText); - d->pText[pos]=lpszValue; + d->pText = (XMLCSTR*)addToOrder(memoryIncrease, &pos, d->nText, d->pText, sizeof(XMLSTR), eNodeText); + d->pText[pos] = lpszValue; d->nText++; return lpszValue; } @@ -1223,11 +1223,11 @@ XMLClear *XMLNode::addClear_priv(int memoryIncrease, XMLSTR lpszValue, XMLCSTR l if ( !lpszValue) return &emptyXMLClear; if ( !d) { myFree(lpszValue); return &emptyXMLClear; } invalidateInnerText(); - d->pClear=(XMLClear *)addToOrder(memoryIncrease, &pos, d->nClear, d->pClear, sizeof(XMLClear), eNodeClear); - XMLClear *pNewClear=d->pClear+pos; + d->pClear = (XMLClear *)addToOrder(memoryIncrease, &pos, d->nClear, d->pClear, sizeof(XMLClear), eNodeClear); + XMLClear *pNewClear = d->pClear+pos; pNewClear->lpszValue = lpszValue; - if ( !lpszOpen) lpszOpen=XMLClearTags->lpszOpen; - if ( !lpszClose) lpszClose=XMLClearTags->lpszClose; + if ( !lpszOpen) lpszOpen = XMLClearTags->lpszOpen; + if ( !lpszClose) lpszClose = XMLClearTags->lpszClose; pNewClear->lpszOpenTag = lpszOpen; pNewClear->lpszCloseTag = lpszClose; d->nClear++; @@ -1238,29 +1238,29 @@ XMLClear *XMLNode::addClear_priv(int memoryIncrease, XMLSTR lpszValue, XMLCSTR l // Parse a clear (unformatted) type node. char XMLNode::parseClearTag(void *px, void *_pClear) { - XML *pXML=(XML *)px; - ALLXMLClearTag pClear=*((ALLXMLClearTag*)_pClear); - int cbTemp=0; - XMLCSTR lpszTemp=NULL; - XMLCSTR lpXML=&pXML->lpXML[pXML->nIndex]; - static XMLCSTR docTypeEnd=_CXML("]>"); + XML *pXML = (XML *)px; + ALLXMLClearTag pClear = *((ALLXMLClearTag*)_pClear); + int cbTemp = 0; + XMLCSTR lpszTemp = NULL; + XMLCSTR lpXML = &pXML->lpXML[pXML->nIndex]; + static XMLCSTR docTypeEnd = _CXML("]>"); // Find the closing tag // Seems the ')) { lpszTemp=pCh; break; } + if (*pCh == _CXML('<')) { pClear.lpszClose = docTypeEnd; lpszTemp = xstrstr(lpXML, docTypeEnd); break; } + else if (*pCh == _CXML('>')) { lpszTemp = pCh; break; } #ifdef _XMLWIDECHAR pCh++; #else pCh+=XML_ByteTable[(unsigned char)(*pCh)]; #endif } - } else lpszTemp=xstrstr(lpXML, pClear.lpszClose); + } else lpszTemp = xstrstr(lpXML, pClear.lpszClose); if (lpszTemp) { @@ -1281,41 +1281,41 @@ char XMLNode::parseClearTag(void *px, void *_pClear) void XMLNode::exactMemory(XMLNodeData *d) { - if (d->pOrder) d->pOrder=(int*)realloc(d->pOrder, (d->nChild+d->nText+d->nClear)*sizeof(int)); - if (d->pChild) d->pChild=(XMLNode*)realloc(d->pChild, d->nChild*sizeof(XMLNode)); - if (d->pAttribute) d->pAttribute=(XMLAttribute*)realloc(d->pAttribute, d->nAttribute*sizeof(XMLAttribute)); - if (d->pText) d->pText=(XMLCSTR*)realloc(d->pText, d->nText*sizeof(XMLSTR)); - if (d->pClear) d->pClear=(XMLClear *)realloc(d->pClear, d->nClear*sizeof(XMLClear)); + if (d->pOrder) d->pOrder = (int*)realloc(d->pOrder, (d->nChild+d->nText+d->nClear)*sizeof(int)); + if (d->pChild) d->pChild = (XMLNode*)realloc(d->pChild, d->nChild*sizeof(XMLNode)); + if (d->pAttribute) d->pAttribute = (XMLAttribute*)realloc(d->pAttribute, d->nAttribute*sizeof(XMLAttribute)); + if (d->pText) d->pText = (XMLCSTR*)realloc(d->pText, d->nText*sizeof(XMLSTR)); + if (d->pClear) d->pClear = (XMLClear *)realloc(d->pClear, d->nClear*sizeof(XMLClear)); } char XMLNode::maybeAddTxT(void *pa, XMLCSTR tokenPStr) { - XML *pXML=(XML *)pa; - XMLCSTR lpszText=pXML->lpszText; + XML *pXML = (XML *)pa; + XMLCSTR lpszText = pXML->lpszText; if ( !lpszText) return 0; if (dropWhiteSpace) while (XML_isSPACECHAR(*lpszText)&&(lpszText != tokenPStr)) lpszText++; int cbText = (int)(tokenPStr - lpszText); - if ( !cbText) { pXML->lpszText=NULL; return 0; } + if ( !cbText) { pXML->lpszText = NULL; return 0; } if (dropWhiteSpace) { cbText--; while ((cbText)&&XML_isSPACECHAR(lpszText[cbText])) cbText--; cbText++; } - if ( !cbText) { pXML->lpszText=NULL; return 0; } - XMLSTR lpt=fromXMLString(lpszText, cbText, pXML); + if ( !cbText) { pXML->lpszText = NULL; return 0; } + XMLSTR lpt = fromXMLString(lpszText, cbText, pXML); if ( !lpt) return 1; - pXML->lpszText=NULL; + pXML->lpszText = NULL; if (removeCommentsInMiddleOfText && d->nText && d->nClear) { // if the previous insertion was a comment () AND // if the previous previous insertion was a text then, delete the comment and append the text - int n=d->nChild+d->nText+d->nClear-1, *o=d->pOrder; + int n = d->nChild+d->nText+d->nClear-1, *o = d->pOrder; if (((o[n]&3) == eNodeClear)&&((o[n-1]&3) == eNodeText)) { - int i=o[n]>>2; + int i = o[n]>>2; if (d->pClear[i].lpszOpenTag == XMLClearTags[2].lpszOpen) { deleteClear(i); - i=o[n-1]>>2; - n=xstrlen(d->pText[i]); - int n2=xstrlen(lpt)+1; - d->pText[i]=(XMLSTR)realloc((void*)d->pText[i], (n+n2)*sizeof(XMLCHAR)); + i = o[n-1]>>2; + n = xstrlen(d->pText[i]); + int n2 = xstrlen(lpt)+1; + d->pText[i] = (XMLSTR)realloc((void*)d->pText[i], (n+n2)*sizeof(XMLCHAR)); if ( !d->pText[i]) return 1; memcpy((void*)(d->pText[i]+n), lpt, n2*sizeof(XMLCHAR)); free(lpt); @@ -1330,12 +1330,12 @@ char XMLNode::maybeAddTxT(void *pa, XMLCSTR tokenPStr) // Recursively parse an XML element. int XMLNode::ParseXMLElement(void *pa) { - XML *pXML=(XML *)pa; + XML *pXML = (XML *)pa; int cbToken; enum XMLTokenTypeTag xtype; NextToken token; - XMLCSTR lpszTemp=NULL; - int cbTemp=0; + XMLCSTR lpszTemp = NULL; + int cbTemp = 0; char nDeclaration; XMLNode pNew; enum XMLStatus status; // inside or outside a tag @@ -1443,7 +1443,7 @@ int XMLNode::ParseXMLElement(void *pa) // have an unmatched end tag if ( !d->lpszName) { - pXML->error=eXMLErrorUnmatchedEndTag; + pXML->error = eXMLErrorUnmatchedEndTag; return FALSE; } @@ -1512,7 +1512,7 @@ int XMLNode::ParseXMLElement(void *pa) pXML->error = eXMLErrorMissingEndTagName; return FALSE; } - pXML->lpszText=pXML->lpXML+pXML->nIndex; + pXML->lpszText = pXML->lpXML+pXML->nIndex; // We need to return to the previous caller. If the name // of the tag cannot be found we need to keep returning to @@ -1522,15 +1522,15 @@ int XMLNode::ParseXMLElement(void *pa) #ifdef STRICT_PARSING { LBL_Error: - pXML->error=eXMLErrorUnmatchedEndTag; - pXML->nIndexMissigEndTag=pXML->nIndex; + pXML->error = eXMLErrorUnmatchedEndTag; + pXML->nIndexMissigEndTag = pXML->nIndex; return FALSE; } #else { LBL_Error: - pXML->error=eXMLErrorMissingEndTag; - pXML->nIndexMissigEndTag=pXML->nIndex; + pXML->error = eXMLErrorMissingEndTag; + pXML->nIndexMissigEndTag = pXML->nIndex; pXML->lpEndTag = lpszTemp; pXML->cbEndTag = cbTemp; } @@ -1554,7 +1554,7 @@ LBL_Error: // If we have node text then add this to the element if (maybeAddTxT(pXML, token.pStr)) return FALSE; if (parseClearTag(pXML, token.pClr)) return FALSE; - pXML->lpszText=pXML->lpXML+pXML->nIndex; + pXML->lpszText = pXML->lpXML+pXML->nIndex; break; default: @@ -1590,14 +1590,14 @@ LBL_Error: case eTokenCloseTag: // We are now outside the tag status = eOutsideTag; - pXML->lpszText=pXML->lpXML+pXML->nIndex; + pXML->lpszText = pXML->lpXML+pXML->nIndex; break; // If we found a short hand '/>' closing tag then we can // return to the caller case eTokenShortHandClose: exactMemory(d); - pXML->lpszText=pXML->lpXML+pXML->nIndex; + pXML->lpszText = pXML->lpXML+pXML->nIndex; return TRUE; // Errors... @@ -1635,7 +1635,7 @@ LBL_Error: case eTokenCloseTag: // If we are a declaration element 'lpszText=pXML->lpXML+pXML->nIndex; + pXML->lpszText = pXML->lpXML+pXML->nIndex; if (d->isDeclaration && (lpszTemp[cbTemp-1]) == _CXML('?')) @@ -1662,7 +1662,7 @@ LBL_Error: break; // If we found the equals token... - // Eg. 'Attribute =' + // Eg. 'Attribute = ' case eTokenEquals: // Indicate that we next need to search for the value // for the attribute @@ -1703,10 +1703,10 @@ LBL_Error: { // Add the valued attribute to the list if (xtype == eTokenQuotedText) { token.pStr++; cbToken-=2; } - XMLSTR attrVal=(XMLSTR)token.pStr; + XMLSTR attrVal = (XMLSTR)token.pStr; if (attrVal) { - attrVal=fromXMLString(attrVal, cbToken, pXML); + attrVal = fromXMLString(attrVal, cbToken, pXML); if ( !attrVal) return FALSE; } addAttribute_priv(MEMORYINCREASE, stringDup(lpszTemp, cbTemp), attrVal); @@ -1721,7 +1721,7 @@ LBL_Error: case eTokenTagEnd: /* 'Attr = ' */ case eTokenShortHandClose: /* "Attr = />" */ - case eTokenEquals: /* 'Attr = =' */ + case eTokenEquals: /* 'Attr = = ' */ case eTokenDeclaration: /* 'Attr = error = eXMLErrorUnexpectedToken; @@ -1738,11 +1738,11 @@ LBL_Error: if (( !d->isDeclaration)&&(d->pParent)) { #ifdef STRICT_PARSING - pXML->error=eXMLErrorUnmatchedEndTag; + pXML->error = eXMLErrorUnmatchedEndTag; #else - pXML->error=eXMLErrorMissingEndTag; + pXML->error = eXMLErrorMissingEndTag; #endif - pXML->nIndexMissigEndTag=pXML->nIndex; + pXML->nIndexMissigEndTag = pXML->nIndex; } maybeAddTxT(pXML, pXML->lpXML+pXML->nIndex); return FALSE; @@ -1757,7 +1757,7 @@ static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto, XMLResults *pResults) assert(lpXML); assert(pResults); - struct XML xml={ lpXML, lpXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0, TRUE }; + struct XML xml = { lpXML, lpXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0, TRUE }; pResults->nLine = 1; pResults->nColumn = 1; @@ -1768,7 +1768,7 @@ static void CountLinesAndColumns(XMLCSTR lpXML, int nUpto, XMLResults *pResults) else { pResults->nLine++; - pResults->nColumn=1; + pResults->nColumn = 1; } } } @@ -1780,37 +1780,37 @@ XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag, XMLResults *pResults) { if (pResults) { - pResults->error=eXMLErrorNoElements; - pResults->nLine=0; - pResults->nColumn=0; + pResults->error = eXMLErrorNoElements; + pResults->nLine = 0; + pResults->nColumn = 0; } return emptyXMLNode; } XMLNode xnode(NULL, NULL, FALSE); - struct XML xml={ lpszXML, lpszXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0, TRUE }; + struct XML xml = { lpszXML, lpszXML, 0, 0, eXMLErrorNone, NULL, 0, NULL, 0, TRUE }; // Create header element xnode.ParseXMLElement(&xml); enum XMLError error = xml.error; - if ( !xnode.nChildNode()) error=eXMLErrorNoXMLTagFound; - if ((xnode.nChildNode() == 1)&&(xnode.nElement() == 1)) xnode=xnode.getChildNode(); // skip the empty node + if ( !xnode.nChildNode()) error = eXMLErrorNoXMLTagFound; + if ((xnode.nChildNode() == 1)&&(xnode.nElement() == 1)) xnode = xnode.getChildNode(); // skip the empty node // If no error occurred if ((error == eXMLErrorNone) || (error == eXMLErrorMissingEndTag) || (error == eXMLErrorNoXMLTagFound)) { - XMLCSTR name=xnode.getName(); + XMLCSTR name = xnode.getName(); if (tag&&(*tag)&&(( !name) || (xstricmp(name, tag)))) { - xnode=xnode.getChildNode(tag); + xnode = xnode.getChildNode(tag); if (xnode.isEmpty()) { if (pResults) { - pResults->error=eXMLErrorFirstTagNotFound; - pResults->nLine=0; - pResults->nColumn=0; - pResults->nChars=xml.nIndex; + pResults->error = eXMLErrorFirstTagNotFound; + pResults->nLine = 0; + pResults->nColumn = 0; + pResults->nChars = xml.nIndex; } return emptyXMLNode; } @@ -1830,7 +1830,7 @@ XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag, XMLResults *pResults) // If we have an error if (error != eXMLErrorNone) { - if (error == eXMLErrorMissingEndTag) xml.nIndex=xml.nIndexMissigEndTag; + if (error == eXMLErrorMissingEndTag) xml.nIndex = xml.nIndexMissigEndTag; // Find which line and column it starts on. CountLinesAndColumns(xml.lpXML, xml.nIndex, pResults); } @@ -1842,69 +1842,69 @@ XMLNode XMLNode::parseString(XMLCSTR lpszXML, XMLCSTR tag, XMLResults *pResults) XMLNode XMLNode::parseFile(XMLCSTR filename, XMLCSTR tag, XMLResults *pResults) { - if (pResults) { pResults->nLine=0; pResults->nColumn=0; } - FILE *f=xfopen(filename, _CXML("rb")); - if (f == NULL) { if (pResults) pResults->error=eXMLErrorFileNotFound; return emptyXMLNode; } + if (pResults) { pResults->nLine = 0; pResults->nColumn = 0; } + FILE *f = xfopen(filename, _CXML("rb")); + if (f == NULL) { if (pResults) pResults->error = eXMLErrorFileNotFound; return emptyXMLNode; } fseek(f, 0, SEEK_END); - int l=(int)ftell(f), headerSz=0; - if ( !l) { if (pResults) pResults->error=eXMLErrorEmpty; fclose(f); return emptyXMLNode; } + int l = (int)ftell(f), headerSz = 0; + if ( !l) { if (pResults) pResults->error = eXMLErrorEmpty; fclose(f); return emptyXMLNode; } fseek(f, 0, SEEK_SET); - unsigned char *buf=(unsigned char*)malloc(l+4); - l=(int)fread(buf, 1, l, f); + unsigned char *buf = (unsigned char*)malloc(l+4); + l = (int)fread(buf, 1, l, f); fclose(f); - buf[l]=0;buf[l+1]=0;buf[l+2]=0;buf[l+3]=0; + buf[l] = 0;buf[l+1] = 0;buf[l+2] = 0;buf[l+3] = 0; #ifdef _XMLWIDECHAR if (guessWideCharChars) { if ( !myIsTextWideChar(buf, l)) { - XMLNode::XMLCharEncoding ce=XMLNode::char_encoding_legacy; - if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) { headerSz=3; ce=XMLNode::char_encoding_UTF8; } - XMLSTR b2=myMultiByteToWideChar((const char*)(buf+headerSz), ce); + XMLNode::XMLCharEncoding ce = XMLNode::char_encoding_legacy; + if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) { headerSz = 3; ce = XMLNode::char_encoding_UTF8; } + XMLSTR b2 = myMultiByteToWideChar((const char*)(buf+headerSz), ce); if ( !b2) { // todo: unable to convert } - free(buf); buf=(unsigned char*)b2; headerSz=0; + free(buf); buf = (unsigned char*)b2; headerSz = 0; } else { - if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz=2; - if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz=2; + if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz = 2; + if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz = 2; } } else { - if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz=2; - if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz=2; - if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) headerSz=3; + if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz = 2; + if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz = 2; + if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) headerSz = 3; } #else if (guessWideCharChars) { if (myIsTextWideChar(buf, l)) { - if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz=2; - if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz=2; - char *b2=myWideCharToMultiByte((const wchar_t*)(buf+headerSz)); - free(buf); buf=(unsigned char*)b2; headerSz=0; + if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz = 2; + if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz = 2; + char *b2 = myWideCharToMultiByte((const wchar_t*)(buf+headerSz)); + free(buf); buf = (unsigned char*)b2; headerSz = 0; } else { - if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) headerSz=3; + if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) headerSz = 3; } } else { - if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz=2; - if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz=2; - if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) headerSz=3; + if ((buf[0] == 0xef)&&(buf[1] == 0xff)) headerSz = 2; + if ((buf[0] == 0xff)&&(buf[1] == 0xfe)) headerSz = 2; + if ((buf[0] == 0xef)&&(buf[1] == 0xbb)&&(buf[2] == 0xbf)) headerSz = 3; } #endif - if ( !buf) { if (pResults) pResults->error=eXMLErrorCharConversionError; return emptyXMLNode; } - XMLNode x=parseString((XMLSTR)(buf+headerSz), tag, pResults); + if ( !buf) { if (pResults) pResults->error = eXMLErrorCharConversionError; return emptyXMLNode; } + XMLNode x = parseString((XMLSTR)(buf+headerSz), tag, pResults); free(buf); return x; } -static inline void charmemset(XMLSTR dest, XMLCHAR c, int l) { while (l--) *(dest++)=c; } +static inline void charmemset(XMLSTR dest, XMLCHAR c, int l) { while (l--) *(dest++) = c; } // private: // Creates an user friendly XML string from a given element with // appropriate white space and carriage returns. @@ -1914,12 +1914,12 @@ static inline void charmemset(XMLSTR dest, XMLCHAR c, int l) { while (l--) *(des int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nFormat) { int nResult = 0; - int cb=nFormat<0?0:nFormat; + int cb = nFormat<0?0:nFormat; int cbElement; - int nChildFormat=-1; - int nElementI=pEntry->nChild+pEntry->nText+pEntry->nClear; + int nChildFormat = -1; + int nElementI = pEntry->nChild+pEntry->nText+pEntry->nClear; int i, j; - if ((nFormat>=0)&&(nElementI == 1)&&(pEntry->nText == 1)&&( !pEntry->isDeclaration)) nFormat=-2; + if ((nFormat>=0)&&(nElementI == 1)&&(pEntry->nText == 1)&&( !pEntry->isDeclaration)) nFormat = -2; assert(pEntry); @@ -1935,11 +1935,11 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma { if (cb) charmemset(lpszMarker, INDENTCHAR, cb); nResult = cb; - lpszMarker[nResult++]=_CXML('<'); - if (pEntry->isDeclaration) lpszMarker[nResult++]=_CXML('?'); + lpszMarker[nResult++] = _CXML('<'); + if (pEntry->isDeclaration) lpszMarker[nResult++] = _CXML('?'); xstrcpy(&lpszMarker[nResult], pEntry->lpszName); nResult+=cbElement; - lpszMarker[nResult++]=_CXML(' '); + lpszMarker[nResult++] = _CXML(' '); } else { @@ -1948,7 +1948,7 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma } // Enumerate attributes and add them to the string - XMLAttribute *pAttr=pEntry->pAttribute; + XMLAttribute *pAttr = pEntry->pAttribute; for (i=0; inAttribute; i++) { // "Attrib @@ -1957,16 +1957,16 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma { if (lpszMarker) xstrcpy(&lpszMarker[nResult], pAttr->lpszName); nResult += cb; - // "Attrib=Value " + // "Attrib = Value " if (pAttr->lpszValue) { - cb=(int)ToXMLStringTool::lengthXMLString(pAttr->lpszValue); + cb = (int)ToXMLStringTool::lengthXMLString(pAttr->lpszValue); if (lpszMarker) { - lpszMarker[nResult]=_CXML('='); - lpszMarker[nResult+1]=_CXML('"'); + lpszMarker[nResult] = _CXML('='); + lpszMarker[nResult+1] = _CXML('"'); if (cb) ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult+2], pAttr->lpszValue); - lpszMarker[nResult+cb+2]=_CXML('"'); + lpszMarker[nResult+cb+2] = _CXML('"'); } nResult+=cb+3; } @@ -1980,23 +1980,23 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma { if (lpszMarker) { - lpszMarker[nResult-1]=_CXML('?'); - lpszMarker[nResult]=_CXML('>'); + lpszMarker[nResult-1] = _CXML('?'); + lpszMarker[nResult] = _CXML('>'); } nResult++; if (nFormat != -1) { - if (lpszMarker) lpszMarker[nResult]=_CXML('\n'); + if (lpszMarker) lpszMarker[nResult] = _CXML('\n'); nResult++; } } else // If there are child nodes we need to terminate the start tag if (nElementI) { - if (lpszMarker) lpszMarker[nResult-1]=_CXML('>'); + if (lpszMarker) lpszMarker[nResult-1] = _CXML('>'); if (nFormat>=0) { - if (lpszMarker) lpszMarker[nResult]=_CXML('\n'); + if (lpszMarker) lpszMarker[nResult] = _CXML('\n'); nResult++; } } else nResult--; @@ -2006,21 +2006,21 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma // determine the number of spaces used for prefixes. if (nFormat != -1) { - if (cbElement&&( !pEntry->isDeclaration)) nChildFormat=nFormat+1; - else nChildFormat=nFormat; + if (cbElement&&( !pEntry->isDeclaration)) nChildFormat = nFormat+1; + else nChildFormat = nFormat; } // Enumerate through remaining children for (i=0; ipOrder[i]; + j = pEntry->pOrder[i]; switch((XMLElementType)(j&3)) { // Text nodes case eNodeText: { // "Text" - XMLCSTR pChild=pEntry->pText[j>>2]; + XMLCSTR pChild = pEntry->pText[j>>2]; cb = (int)ToXMLStringTool::lengthXMLString(pChild); if (cb) { @@ -2030,7 +2030,7 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma { charmemset(&lpszMarker[nResult], INDENTCHAR, nFormat+1); ToXMLStringTool::toXMLUnSafe(&lpszMarker[nResult+nFormat+1], pChild); - lpszMarker[nResult+nFormat+1+cb]=_CXML('\n'); + lpszMarker[nResult+nFormat+1+cb] = _CXML('\n'); } nResult+=cb+nFormat+2; } else @@ -2045,7 +2045,7 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma // Clear type nodes case eNodeClear: { - XMLClear *pChild=pEntry->pClear+(j>>2); + XMLClear *pChild = pEntry->pClear+(j>>2); // "OpenTag" cb = (int)LENSTR(pChild->lpszOpenTag); if (cb) @@ -2116,16 +2116,16 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma nResult+=nFormat; } - lpszMarker[nResult]=_CXML('<'); lpszMarker[nResult+1]=_CXML('/'); + lpszMarker[nResult] = _CXML('<'); lpszMarker[nResult+1] = _CXML('/'); nResult += 2; xstrcpy(&lpszMarker[nResult], pEntry->lpszName); nResult += cbElement; - lpszMarker[nResult]=_CXML('>'); + lpszMarker[nResult] = _CXML('>'); if (nFormat == -1) nResult++; else { - lpszMarker[nResult+1]=_CXML('\n'); + lpszMarker[nResult+1] = _CXML('\n'); nResult+=2; } } else @@ -2141,8 +2141,8 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma // "/>\0" if (lpszMarker) { - lpszMarker[nResult]=_CXML('/'); lpszMarker[nResult+1]=_CXML('>'); - if (nFormat != -1) lpszMarker[nResult+2]=_CXML('\n'); + lpszMarker[nResult] = _CXML('/'); lpszMarker[nResult+1] = _CXML('>'); + if (nFormat != -1) lpszMarker[nResult+2] = _CXML('\n'); } nResult += nFormat == -1 ? 2 : 3; } @@ -2164,32 +2164,32 @@ int XMLNode::CreateXMLStringR(XMLNodeData *pEntry, XMLSTR lpszMarker, int nForma // this with free(). XMLSTR XMLNode::createXMLString(int nFormat, int *pnSize) const { - if ( !d) { if (pnSize) *pnSize=0; return NULL; } + if ( !d) { if (pnSize) *pnSize = 0; return NULL; } XMLSTR lpszResult = NULL; int cbStr; // Recursively Calculate the size of the XML string - if ( !dropWhiteSpace) nFormat=0; + if ( !dropWhiteSpace) nFormat = 0; nFormat = nFormat ? 0 : -1; cbStr = CreateXMLStringR(d, 0, nFormat); // Alllocate memory for the XML string + the NULL terminator and // create the recursively XML string. - lpszResult=(XMLSTR)malloc((cbStr+1)*sizeof(XMLCHAR)); + lpszResult = (XMLSTR)malloc((cbStr+1)*sizeof(XMLCHAR)); CreateXMLStringR(d, lpszResult, nFormat); - lpszResult[cbStr]=_CXML('\0'); + lpszResult[cbStr] = _CXML('\0'); if (pnSize) *pnSize = cbStr; return lpszResult; } int XMLNode::detachFromParent(XMLNodeData *d) { - XMLNode *pa=d->pParent->pChild; + XMLNode *pa = d->pParent->pChild; int i=0; while (((void*)(pa[i].d)) != ((void*)d)) i++; d->pParent->nChild--; if (d->pParent->nChild) memmove(pa+i, pa+i+1, (d->pParent->nChild-i)*sizeof(XMLNode)); - else { free(pa); d->pParent->pChild=NULL; } + else { free(pa); d->pParent->pChild = NULL; } return removeOrderElement(d->pParent, eNodeChild, i); } @@ -2202,12 +2202,12 @@ XMLNode::~XMLNode() void XMLNode::deleteNodeContent() { if ( !d) return; - if (d->pParent) { detachFromParent(d); d->pParent=NULL; d->ref_count--; } + if (d->pParent) { detachFromParent(d); d->pParent = NULL; d->ref_count--; } emptyTheNode(1); } void XMLNode::emptyTheNode(char force) { - XMLNodeData *dd=d; // warning: must stay this way! + XMLNodeData *dd = d; // warning: must stay this way! if ((dd->ref_count == 0) || force) { if (d->pParent) detachFromParent(d); @@ -2215,8 +2215,8 @@ void XMLNode::emptyTheNode(char force) XMLNode *pc; for (i=0; inChild; i++) { - pc=dd->pChild+i; - pc->d->pParent=NULL; + pc = dd->pChild+i; + pc->d->pParent = NULL; pc->d->ref_count--; pc->emptyTheNode(force); } @@ -2237,30 +2237,30 @@ void XMLNode::emptyTheNode(char force) myFree((void*)dd->lpszNS); else myFree((void*)dd->lpszName); - dd->nChild=0; dd->nText=0; dd->nClear=0; dd->nAttribute=0; - dd->pChild=NULL; dd->pText=NULL; dd->pClear=NULL; dd->pAttribute=NULL; - dd->pOrder=NULL; dd->pInnerText=NULL; dd->lpszNS=dd->lpszName=NULL; dd->pParent=NULL; + dd->nChild = 0; dd->nText = 0; dd->nClear = 0; dd->nAttribute = 0; + dd->pChild = NULL; dd->pText = NULL; dd->pClear = NULL; dd->pAttribute = NULL; + dd->pOrder = NULL; dd->pInnerText = NULL; dd->lpszNS = dd->lpszName = NULL; dd->pParent = NULL; } if (dd->ref_count == 0) { free(dd); - d=NULL; + d = NULL; } } void XMLNode::invalidateInnerText() { if ( !d) return; myFree(d->pInnerText); - d->pInnerText= NULL; + d->pInnerText = NULL; } -XMLNode& XMLNode::operator=(const XMLNode& A) +XMLNode& XMLNode::operator = (const XMLNode& A) { // shallow copy if (this != &A) { if (d) { d->ref_count--; emptyTheNode(0); } - d=A.d; + d = A.d; if (d) (d->ref_count) ++; } return *this; @@ -2269,7 +2269,7 @@ XMLNode& XMLNode::operator=(const XMLNode& A) XMLNode::XMLNode(const XMLNode &A) { // shallow copy - d=A.d; + d = A.d; if (d) (d->ref_count)++; } @@ -2277,47 +2277,47 @@ XMLNode XMLNode::deepCopy() const { if ( !d) return XMLNode::emptyXMLNode; XMLNode x(NULL, stringDup(d->lpszName), d->isDeclaration); - XMLNodeData *p=x.d; - int n=d->nAttribute; + XMLNodeData *p = x.d; + int n = d->nAttribute; if (n) { - p->nAttribute=n; p->pAttribute=(XMLAttribute*)malloc(n*sizeof(XMLAttribute)); + p->nAttribute = n; p->pAttribute = (XMLAttribute*)malloc(n*sizeof(XMLAttribute)); while (n--) { - p->pAttribute[n].lpszName=stringDup(d->pAttribute[n].lpszName); - p->pAttribute[n].lpszValue=stringDup(d->pAttribute[n].lpszValue); + p->pAttribute[n].lpszName = stringDup(d->pAttribute[n].lpszName); + p->pAttribute[n].lpszValue = stringDup(d->pAttribute[n].lpszValue); } } if (d->pOrder) { - n=(d->nChild+d->nText+d->nClear)*sizeof(int); p->pOrder=(int*)malloc(n); memcpy(p->pOrder, d->pOrder, n); + n = (d->nChild+d->nText+d->nClear)*sizeof(int); p->pOrder = (int*)malloc(n); memcpy(p->pOrder, d->pOrder, n); } - n=d->nText; + n = d->nText; if (n) { - p->nText=n; p->pText=(XMLCSTR*)malloc(n*sizeof(XMLCSTR)); - while (n--) p->pText[n]=stringDup(d->pText[n]); + p->nText = n; p->pText = (XMLCSTR*)malloc(n*sizeof(XMLCSTR)); + while (n--) p->pText[n] = stringDup(d->pText[n]); } - n=d->nClear; + n = d->nClear; if (n) { - p->nClear=n; p->pClear=(XMLClear*)malloc(n*sizeof(XMLClear)); + p->nClear = n; p->pClear = (XMLClear*)malloc(n*sizeof(XMLClear)); while (n--) { - p->pClear[n].lpszCloseTag=d->pClear[n].lpszCloseTag; - p->pClear[n].lpszOpenTag=d->pClear[n].lpszOpenTag; - p->pClear[n].lpszValue=stringDup(d->pClear[n].lpszValue); + p->pClear[n].lpszCloseTag = d->pClear[n].lpszCloseTag; + p->pClear[n].lpszOpenTag = d->pClear[n].lpszOpenTag; + p->pClear[n].lpszValue = stringDup(d->pClear[n].lpszValue); } } - n=d->nChild; + n = d->nChild; if (n) { - p->nChild=n; p->pChild=(XMLNode*)malloc(n*sizeof(XMLNode)); + p->nChild = n; p->pChild = (XMLNode*)malloc(n*sizeof(XMLNode)); while (n--) { - p->pChild[n].d=NULL; - p->pChild[n]=d->pChild[n].deepCopy(); - p->pChild[n].d->pParent=p; + p->pChild[n].d = NULL; + p->pChild[n] = d->pChild[n].deepCopy(); + p->pChild[n].d->pParent = p; } } return x; @@ -2325,12 +2325,12 @@ XMLNode XMLNode::deepCopy() const XMLNode XMLNode::addChild(XMLNode childNode, int pos) { - XMLNodeData *dc=childNode.d; + XMLNodeData *dc = childNode.d; if (( !dc) || ( !d)) return childNode; if ( !dc->lpszName) { // this is a root node: todo: correct fix - int j=pos; + int j = pos; while (dc->nChild) { addChild(dc->pChild[0], j); @@ -2338,12 +2338,12 @@ XMLNode XMLNode::addChild(XMLNode childNode, int pos) } return childNode; } - if (dc->pParent) { if ((detachFromParent(dc)<=pos)&&(dc->pParent == d)) pos--; } else dc->ref_count++; - dc->pParent=d; - // int nc=d->nChild; - // d->pChild=(XMLNode*)myRealloc(d->pChild, (nc+1), memoryIncrease, sizeof(XMLNode)); - d->pChild=(XMLNode*)addToOrder(0, &pos, d->nChild, d->pChild, sizeof(XMLNode), eNodeChild); - d->pChild[pos].d=dc; + if (dc->pParent) { if ((detachFromParent(dc) <= pos)&&(dc->pParent == d)) pos--; } else dc->ref_count++; + dc->pParent = d; + // int nc = d->nChild; + // d->pChild = (XMLNode*)myRealloc(d->pChild, (nc+1), memoryIncrease, sizeof(XMLNode)); + d->pChild = (XMLNode*)addToOrder(0, &pos, d->nChild, d->pChild, sizeof(XMLNode), eNodeChild); + d->pChild[pos].d = dc; d->nChild++; return childNode; } @@ -2352,16 +2352,16 @@ void XMLNode::deleteAttribute(int i) { if (( !d) || (i<0) || (i>=d->nAttribute)) return; d->nAttribute--; - XMLAttribute *p=d->pAttribute+i; + XMLAttribute *p = d->pAttribute+i; free((void*)p->lpszName); if (p->lpszValue) free((void*)p->lpszValue); - if (d->nAttribute) memmove(p, p+1, (d->nAttribute-i)*sizeof(XMLAttribute)); else { free(p); d->pAttribute=NULL; } + if (d->nAttribute) memmove(p, p+1, (d->nAttribute-i)*sizeof(XMLAttribute)); else { free(p); d->pAttribute = NULL; } } void XMLNode::deleteAttribute(XMLAttribute *a) { if (a) deleteAttribute(a->lpszName); } void XMLNode::deleteAttribute(XMLCSTR lpszName) { - int j=0; + int j = 0; getAttribute(lpszName, &j); if (j) deleteAttribute(j-1); } @@ -2374,10 +2374,10 @@ XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewN if (lpszNewName) return addAttribute_WOSD(lpszNewName, lpszNewValue); return NULL; } - XMLAttribute *p=d->pAttribute+i; + XMLAttribute *p = d->pAttribute+i; if (p->lpszValue&&p->lpszValue != lpszNewValue) free((void*)p->lpszValue); - p->lpszValue=lpszNewValue; - if (lpszNewName&&p->lpszName != lpszNewName) { free((void*)p->lpszName); p->lpszName=lpszNewName; }; + p->lpszValue = lpszNewValue; + if (lpszNewName&&p->lpszName != lpszNewName) { free((void*)p->lpszName); p->lpszName = lpszNewName; }; return p; } @@ -2389,7 +2389,7 @@ XMLAttribute *XMLNode::updateAttribute_WOSD(XMLAttribute *newAttribute, XMLAttri XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName) { - int j=0; + int j = 0; getAttribute(lpszOldName, &j); if (j) return updateAttribute_WOSD(lpszNewValue, lpszNewName, j-1); else @@ -2402,9 +2402,9 @@ XMLAttribute *XMLNode::updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewN int XMLNode::indexText(XMLCSTR lpszValue) const { if ( !d) return -1; - int i, l=d->nText; + int i, l = d->nText; if ( !lpszValue) { if (l) return 0; return -1; } - XMLCSTR *p=d->pText; + XMLCSTR *p = d->pText; for (i=0; i=d->nText)) return; invalidateInnerText(); d->nText--; - XMLCSTR *p=d->pText+i; + XMLCSTR *p = d->pText+i; free((void*)*p); - if (d->nText) memmove(p, p+1, (d->nText-i)*sizeof(XMLCSTR)); else { free(p); d->pText=NULL; } + if (d->nText) memmove(p, p+1, (d->nText-i)*sizeof(XMLCSTR)); else { free(p); d->pText = NULL; } removeOrderElement(d, eNodeText, i); } @@ -2427,15 +2427,15 @@ XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, int i) if ( !d) { if (lpszNewValue) free(lpszNewValue); return NULL; } if (i>=d->nText) return addText_WOSD(lpszNewValue); invalidateInnerText(); - XMLCSTR *p=d->pText+i; - if (*p != lpszNewValue) { free((void*)*p); *p=lpszNewValue; } + XMLCSTR *p = d->pText+i; + if (*p != lpszNewValue) { free((void*)*p); *p = lpszNewValue; } return lpszNewValue; } XMLCSTR XMLNode::updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue) { if ( !d) { if (lpszNewValue) free(lpszNewValue); return NULL; } - int i=indexText(lpszOldValue); + int i = indexText(lpszOldValue); if (i>=0) return updateText_WOSD(lpszNewValue, i); return addText_WOSD(lpszNewValue); } @@ -2445,18 +2445,18 @@ void XMLNode::deleteClear(int i) if (( !d) || (i<0) || (i>=d->nClear)) return; invalidateInnerText(); d->nClear--; - XMLClear *p=d->pClear+i; + XMLClear *p = d->pClear+i; free((void*)p->lpszValue); - if (d->nClear) memmove(p, p+1, (d->nClear-i)*sizeof(XMLClear)); else { free(p); d->pClear=NULL; } + if (d->nClear) memmove(p, p+1, (d->nClear-i)*sizeof(XMLClear)); else { free(p); d->pClear = NULL; } removeOrderElement(d, eNodeClear, i); } int XMLNode::indexClear(XMLCSTR lpszValue) const { if ( !d) return -1; - int i, l=d->nClear; + int i, l = d->nClear; if ( !lpszValue) { if (l) return 0; return -1; } - XMLClear *p=d->pClear; + XMLClear *p = d->pClear; for (i=0; i=d->nClear) return addClear_WOSD(lpszNewContent); invalidateInnerText(); - XMLClear *p=d->pClear+i; - if (lpszNewContent != p->lpszValue) { free((void*)p->lpszValue); p->lpszValue=lpszNewContent; } + XMLClear *p = d->pClear+i; + if (lpszNewContent != p->lpszValue) { free((void*)p->lpszValue); p->lpszValue = lpszNewContent; } return p; } XMLClear *XMLNode::updateClear_WOSD(XMLSTR lpszNewContent, XMLCSTR lpszOldValue) { if ( !d) { if (lpszNewContent) free(lpszNewContent); return NULL; } - int i=indexClear(lpszOldValue); + int i = indexClear(lpszOldValue); if (i>=0) return updateClear_WOSD(lpszNewContent, i); return addClear_WOSD(lpszNewContent); } @@ -2491,8 +2491,8 @@ XMLClear *XMLNode::updateClear_WOSD(XMLClear *newP, XMLClear *oldP) int XMLNode::nChildNode(XMLCSTR name) const { if ( !d) return 0; - int i, j=0, n=d->nChild; - XMLNode *pc=d->pChild; + int i, j = 0, n = d->nChild; + XMLNode *pc = d->pChild; for (i=0; id->lpszName, name) == 0) j++; @@ -2504,14 +2504,14 @@ int XMLNode::nChildNode(XMLCSTR name) const XMLNode XMLNode::getChildNode(XMLCSTR name, int *j) const { if ( !d) return emptyXMLNode; - int i=0, n=d->nChild; - if (j) i=*j; - XMLNode *pc=d->pChild+i; + int i=0, n = d->nChild; + if (j) i = *j; + XMLNode *pc = d->pChild+i; for (; id->lpszName, name)) { - if (j) *j=i+1; + if (j) *j = i+1; return *pc; } pc++; @@ -2528,7 +2528,7 @@ XMLNode XMLNode::getChildNode(XMLCSTR name, int j) const while (j-->0) getChildNode(name, &i); return getChildNode(name, &i); } - int i=d->nChild; + int i = d->nChild; while (i--) if ( !xstricmp(name, d->pChild[i].d->lpszName)) break; if (i<0) return emptyXMLNode; return getChildNode(i); @@ -2537,9 +2537,9 @@ XMLNode XMLNode::getChildNode(XMLCSTR name, int j) const XMLNode XMLNode::getNextNode() const { if ( !d) return emptyXMLNode; - XMLNodeDataTag *par=d->pParent; + XMLNodeDataTag *par = d->pParent; if ( !par) return emptyXMLNode; - int i, n=par->nChild; + int i, n = par->nChild; for (i=0; ipChild[i].d == d) break; @@ -2549,8 +2549,8 @@ XMLNode XMLNode::getNextNode() const XMLNode XMLNode::getChildNodeByPath(XMLCSTR _path, char createMissing, XMLCHAR sep) { - XMLSTR path=stringDup(_path); - XMLNode x=getChildNodeByPathNonConst(path, createMissing, sep); + XMLSTR path = stringDup(_path); + XMLNode x = getChildNodeByPathNonConst(path, createMissing, sep); if (path) free(path); return x; } @@ -2558,47 +2558,47 @@ XMLNode XMLNode::getChildNodeByPath(XMLCSTR _path, char createMissing, XMLCHAR s XMLNode XMLNode::getChildNodeByPathNonConst(XMLSTR path, char createIfMissing, XMLCHAR sep) { if (( !path) || ( !(*path))) return *this; - XMLNode xn, xbase=*this; - XMLCHAR *tend1, sepString[2]; sepString[0]=sep; sepString[1]=0; - tend1=xstrstr(path, sepString); + XMLNode xn, xbase = *this; + XMLCHAR *tend1, sepString[2]; sepString[0] = sep; sepString[1] = 0; + tend1 = xstrstr(path, sepString); while (tend1) { - *tend1=0; - xn=xbase.getChildNode(path); + *tend1 = 0; + xn = xbase.getChildNode(path); if (xn.isEmpty()) { - if (createIfMissing) xn=xbase.addChild(path); - else { *tend1=sep; return XMLNode::emptyXMLNode; } + if (createIfMissing) xn = xbase.addChild(path); + else { *tend1 = sep; return XMLNode::emptyXMLNode; } } - *tend1=sep; - xbase=xn; - path=tend1+1; - tend1=xstrstr(path, sepString); + *tend1 = sep; + xbase = xn; + path = tend1+1; + tend1 = xstrstr(path, sepString); } - xn=xbase.getChildNode(path); - if (xn.isEmpty()&&createIfMissing) xn=xbase.addChild(path); + xn = xbase.getChildNode(path); + if (xn.isEmpty()&&createIfMissing) xn = xbase.addChild(path); return xn; } -XMLElementPosition XMLNode::positionOfText (int i) const { if (i>=d->nText) i=d->nText-1; return findPosition(d, i, eNodeText); } -XMLElementPosition XMLNode::positionOfClear (int i) const { if (i>=d->nClear) i=d->nClear-1; return findPosition(d, i, eNodeClear); } -XMLElementPosition XMLNode::positionOfChildNode(int i) const { if (i>=d->nChild) i=d->nChild-1; return findPosition(d, i, eNodeChild); } +XMLElementPosition XMLNode::positionOfText (int i) const { if (i>=d->nText) i = d->nText-1; return findPosition(d, i, eNodeText); } +XMLElementPosition XMLNode::positionOfClear (int i) const { if (i>=d->nClear) i = d->nClear-1; return findPosition(d, i, eNodeClear); } +XMLElementPosition XMLNode::positionOfChildNode(int i) const { if (i>=d->nChild) i = d->nChild-1; return findPosition(d, i, eNodeChild); } XMLElementPosition XMLNode::positionOfText (XMLCSTR lpszValue) const { return positionOfText (indexText (lpszValue)); } XMLElementPosition XMLNode::positionOfClear(XMLCSTR lpszValue) const { return positionOfClear(indexClear(lpszValue)); } XMLElementPosition XMLNode::positionOfClear(XMLClear *a) const { if (a) return positionOfClear(a->lpszValue); return positionOfClear(); } XMLElementPosition XMLNode::positionOfChildNode(XMLNode x) const { if (( !d) || ( !x.d)) return -1; - XMLNodeData *dd=x.d; - XMLNode *pc=d->pChild; - int i=d->nChild; + XMLNodeData *dd = x.d; + XMLNode *pc = d->pChild; + int i = d->nChild; while (i--) if (pc[i].d == dd) return findPosition(d, i, eNodeChild); return -1; } XMLElementPosition XMLNode::positionOfChildNode(XMLCSTR name, int count) const { if ( !name) return positionOfChildNode(count); - int j=0; + int j = 0; do { getChildNode(name, &j); if (j<0) return -1; } while (count--); return findPosition(d, j-1, eNodeChild); } @@ -2606,25 +2606,25 @@ XMLElementPosition XMLNode::positionOfChildNode(XMLCSTR name, int count) const XMLNode XMLNode::getChildNodeWithAttribute(XMLCSTR name, XMLCSTR attributeName, XMLCSTR attributeValue, int *k) const { int i=0, j; - if (k) i=*k; + if (k) i = *k; XMLNode x; XMLCSTR t; do { - x=getChildNode(name, &i); + x = getChildNode(name, &i); if ( !x.isEmpty()) { if (attributeValue) { - j=0; + j = 0; do { - t=x.getAttribute(attributeName, &j); - if (t&&(xstricmp(attributeValue, t) == 0)) { if (k) *k=i; return x; } + t = x.getAttribute(attributeName, &j); + if (t&&(xstricmp(attributeValue, t) == 0)) { if (k) *k = i; return x; } } while (t); } else { - if (x.isAttributeSet(attributeName)) { if (k) *k=i; return x; } + if (x.isAttributeSet(attributeName)) { if (k) *k = i; return x; } } } } while ( !x.isEmpty()); @@ -2635,14 +2635,14 @@ XMLNode XMLNode::getChildNodeWithAttribute(XMLCSTR name, XMLCSTR attributeName, XMLCSTR XMLNode::getAttribute(XMLCSTR lpszAttrib, int *j) const { if ( !d) return NULL; - int i=0, n=d->nAttribute; - if (j) i=*j; - XMLAttribute *pAttr=d->pAttribute+i; + int i=0, n = d->nAttribute; + if (j) i = *j; + XMLAttribute *pAttr = d->pAttribute+i; for (; ilpszName, lpszAttrib) == 0) { - if (j) *j=i+1; + if (j) *j = i+1; return pAttr->lpszValue; } pAttr++; @@ -2653,8 +2653,8 @@ XMLCSTR XMLNode::getAttribute(XMLCSTR lpszAttrib, int *j) const char XMLNode::isAttributeSet(XMLCSTR lpszAttrib) const { if ( !d) return FALSE; - int i, n=d->nAttribute; - XMLAttribute *pAttr=d->pAttribute; + int i, n = d->nAttribute; + XMLAttribute *pAttr = d->pAttribute; for (i=0; ilpszName, lpszAttrib) == 0) @@ -2677,20 +2677,20 @@ XMLCSTR XMLNode::getAttribute(XMLCSTR name, int j) const XMLNodeContents XMLNode::enumContents(int i) const { XMLNodeContents c; - if ( !d) { c.etype=eNodeNULL; return c; } + if ( !d) { c.etype = eNodeNULL; return c; } if (inAttribute) { - c.etype=eNodeAttribute; - c.attrib=d->pAttribute[i]; + c.etype = eNodeAttribute; + c.attrib = d->pAttribute[i]; return c; } i-=d->nAttribute; - c.etype=(XMLElementType)(d->pOrder[i]&3); - i=(d->pOrder[i])>>2; + c.etype = (XMLElementType)(d->pOrder[i]&3); + i = (d->pOrder[i])>>2; switch (c.etype) { case eNodeChild: c.child = d->pChild[i]; break; - case eNodeText: c.text = d->pText[i]; break; + case eNodeText: c.text = d->pText[i]; break; case eNodeClear: c.clear = d->pClear[i]; break; default: break; } @@ -2705,7 +2705,7 @@ XMLCSTR XMLNode::getInnerText() const int count = nElement(); int i, length = 1; - for (i = 0; i < count; ++i) + for (i=0; i < count; ++i) { XMLNodeContents c = enumContents(i); switch (c.etype) @@ -2720,7 +2720,7 @@ XMLCSTR XMLNode::getInnerText() const } XMLCHAR *buf = (XMLCHAR *)malloc(sizeof(XMLCHAR) * length); XMLCHAR *pos = buf; - for (i = 0; i < count; ++i) + for (i=0; i < count; ++i) { XMLNodeContents c = enumContents(i); switch (c.etype) @@ -2793,18 +2793,18 @@ XMLClear *XMLNode::updateClear(XMLClear *newP, XMLClear *oldP) char XMLNode::setGlobalOptions(XMLCharEncoding _characterEncoding, char _guessWideCharChars, char _dropWhiteSpace, char _removeCommentsInMiddleOfText) { - guessWideCharChars=_guessWideCharChars; dropWhiteSpace=_dropWhiteSpace; removeCommentsInMiddleOfText=_removeCommentsInMiddleOfText; + guessWideCharChars = _guessWideCharChars; dropWhiteSpace = _dropWhiteSpace; removeCommentsInMiddleOfText = _removeCommentsInMiddleOfText; #ifdef _XMLWIDECHAR - if (_characterEncoding) characterEncoding=_characterEncoding; + if (_characterEncoding) characterEncoding = _characterEncoding; #else switch(_characterEncoding) { - case char_encoding_UTF8: characterEncoding=_characterEncoding; XML_ByteTable=XML_utf8ByteTable; break; - case char_encoding_legacy: characterEncoding=_characterEncoding; XML_ByteTable=XML_legacyByteTable; break; - case char_encoding_ShiftJIS: characterEncoding=_characterEncoding; XML_ByteTable=XML_sjisByteTable; break; - case char_encoding_GB2312: characterEncoding=_characterEncoding; XML_ByteTable=XML_gb2312ByteTable; break; + case char_encoding_UTF8: characterEncoding = _characterEncoding; XML_ByteTable = XML_utf8ByteTable; break; + case char_encoding_legacy: characterEncoding = _characterEncoding; XML_ByteTable = XML_legacyByteTable; break; + case char_encoding_ShiftJIS: characterEncoding = _characterEncoding; XML_ByteTable = XML_sjisByteTable; break; + case char_encoding_GB2312: characterEncoding = _characterEncoding; XML_ByteTable = XML_gb2312ByteTable; break; case char_encoding_Big5: - case char_encoding_GBK: characterEncoding=_characterEncoding; XML_ByteTable=XML_gbk_big5_ByteTable; break; + case char_encoding_GBK: characterEncoding = _characterEncoding; XML_ByteTable = XML_gbk_big5_ByteTable; break; default: return 1; } #endif @@ -2818,29 +2818,29 @@ XMLNode::XMLCharEncoding XMLNode::guessCharEncoding(void *buf, int l, char useXM #else if (l<25) return (XMLCharEncoding)0; if (guessWideCharChars&&(myIsTextWideChar(buf, l))) return (XMLCharEncoding)0; - unsigned char *b=(unsigned char*)buf; + unsigned char *b = (unsigned char*)buf; if ((b[0] == 0xef)&&(b[1] == 0xbb)&&(b[2] == 0xbf)) return char_encoding_UTF8; // Match utf-8 model ? - XMLCharEncoding bestGuess=char_encoding_UTF8; + XMLCharEncoding bestGuess = char_encoding_UTF8; int i=0; while (i>18 ]; + *(curr++) = base64EncodeTable[(j>>12)&0x3f]; + *(curr++) = base64EncodeTable[(j>> 6)&0x3f]; + *(curr++) = base64EncodeTable[(j)&0x3f]; + if (formatted) { if ( !k) { *(curr++) = _CXML('\n'); k = 18; } k--; } } - eLen=inlen-eLen*3; // 0 - 2. + eLen = inlen-eLen*3; // 0 - 2. if (eLen == 1) { - *(curr++)=base64EncodeTable[ inbuf[0]>>2 ]; - *(curr++)=base64EncodeTable[(inbuf[0]<<4)&0x3F]; - *(curr++)=base64Fillchar; - *(curr++)=base64Fillchar; + *(curr++) = base64EncodeTable[ inbuf[0]>>2 ]; + *(curr++) = base64EncodeTable[(inbuf[0]<<4)&0x3F]; + *(curr++) = base64Fillchar; + *(curr++) = base64Fillchar; } else if (eLen == 2) { - j=(inbuf[0]<<8)|inbuf[1]; - *(curr++)=base64EncodeTable[ j>>10 ]; - *(curr++)=base64EncodeTable[(j>> 4)&0x3f]; - *(curr++)=base64EncodeTable[(j<< 2)&0x3f]; - *(curr++)=base64Fillchar; + j = (inbuf[0]<<8)|inbuf[1]; + *(curr++) = base64EncodeTable[ j>>10 ]; + *(curr++) = base64EncodeTable[(j>> 4)&0x3f]; + *(curr++) = base64EncodeTable[(j<< 2)&0x3f]; + *(curr++) = base64Fillchar; } - *(curr++)=0; + *(curr++) = 0; return (XMLSTR)buf; } unsigned int XMLParserBase64Tool::decodeSize(XMLCSTR data, XMLError *xe) { if ( !data) return 0; - if (xe) *xe=eXMLErrorNone; - int size=0; + if (xe) *xe = eXMLErrorNone; + int size = 0; unsigned char c; //skip any extra characters (e.g. newlines or spaces) while (*data) { #ifdef _XMLWIDECHAR - if (*data>255) { if (xe) *xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; } + if (*data>255) { if (xe) *xe = eXMLErrorBase64DecodeIllegalCharacter; return 0; } #endif - c=base64DecodeTable[(unsigned char)(*data)]; + c = base64DecodeTable[(unsigned char)(*data)]; if (c<97) size++; - else if (c == 98) { if (xe) *xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; } + else if (c == 98) { if (xe) *xe = eXMLErrorBase64DecodeIllegalCharacter; return 0; } data++; } - if (xe&&(size%4 != 0)) *xe=eXMLErrorBase64DataSizeIsNotMultipleOf4; + if (xe&&(size%4 != 0)) *xe = eXMLErrorBase64DataSizeIsNotMultipleOf4; if (size == 0) return 0; do { data--; size--; } while (*data == base64Fillchar); size++; return (unsigned int)((size*3)/4); @@ -2961,8 +2961,8 @@ unsigned int XMLParserBase64Tool::decodeSize(XMLCSTR data, XMLError *xe) unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int len, XMLError *xe) { if ( !data) return 0; - if (xe) *xe=eXMLErrorNone; - int i=0, p=0; + if (xe) *xe = eXMLErrorNone; + int i=0, p = 0; unsigned char d, c; for (;;) { @@ -2970,14 +2970,14 @@ unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int #ifdef _XMLWIDECHAR #define BASE64DECODE_READ_NEXT_CHAR(c) \ do { \ - if (data[i]>255) { c=98; break; } \ - c=base64DecodeTable[(unsigned char)data[i++]]; \ + if (data[i]>255) { c = 98; break; } \ + c = base64DecodeTable[(unsigned char)data[i++]]; \ }while (c == 97); \ - if(c == 98) { if(xe)*xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; } + if(c == 98) { if(xe)*xe = eXMLErrorBase64DecodeIllegalCharacter; return 0; } #else #define BASE64DECODE_READ_NEXT_CHAR(c) \ - do { c=base64DecodeTable[(unsigned char)data[i++]]; }while (c == 97); \ - if(c == 98) { if(xe)*xe=eXMLErrorBase64DecodeIllegalCharacter; return 0; } + do { c = base64DecodeTable[(unsigned char)data[i++]]; }while (c == 97); \ + if(c == 98) { if(xe)*xe = eXMLErrorBase64DecodeIllegalCharacter; return 0; } #endif BASE64DECODE_READ_NEXT_CHAR(c) @@ -2985,52 +2985,52 @@ unsigned char XMLParserBase64Tool::decode(XMLCSTR data, unsigned char *buf, int if (c == 96) { if (p == (int)len) return 2; - if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; + if (xe) *xe = eXMLErrorBase64DecodeTruncatedData; return 1; } BASE64DECODE_READ_NEXT_CHAR(d) - if ((d == 99) || (d == 96)) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } - if (p == (int)len) { if (xe) *xe=eXMLErrorBase64DecodeBufferTooSmall; return 0; } - buf[p++]=(unsigned char)((c<<2)|((d>>4)&0x3)); + if ((d == 99) || (d == 96)) { if (xe) *xe = eXMLErrorBase64DecodeTruncatedData; return 1; } + if (p == (int)len) { if (xe) *xe = eXMLErrorBase64DecodeBufferTooSmall; return 0; } + buf[p++] = (unsigned char)((c<<2)|((d>>4)&0x3)); BASE64DECODE_READ_NEXT_CHAR(c) - if (c == 99) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } + if (c == 99) { if (xe) *xe = eXMLErrorBase64DecodeTruncatedData; return 1; } if (p == (int)len) { if (c == 96) return 2; - if (xe) *xe=eXMLErrorBase64DecodeBufferTooSmall; + if (xe) *xe = eXMLErrorBase64DecodeBufferTooSmall; return 0; } - if (c == 96) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } - buf[p++]=(unsigned char)(((d<<4)&0xf0)|((c>>2)&0xf)); + if (c == 96) { if (xe) *xe = eXMLErrorBase64DecodeTruncatedData; return 1; } + buf[p++] = (unsigned char)(((d<<4)&0xf0)|((c>>2)&0xf)); BASE64DECODE_READ_NEXT_CHAR(d) - if (d == 99) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } + if (d == 99) { if (xe) *xe = eXMLErrorBase64DecodeTruncatedData; return 1; } if (p == (int)len) { if (d == 96) return 2; - if (xe) *xe=eXMLErrorBase64DecodeBufferTooSmall; + if (xe) *xe = eXMLErrorBase64DecodeBufferTooSmall; return 0; } - if (d == 96) { if (xe) *xe=eXMLErrorBase64DecodeTruncatedData; return 1; } - buf[p++]=(unsigned char)(((c<<6)&0xc0)|d); + if (d == 96) { if (xe) *xe = eXMLErrorBase64DecodeTruncatedData; return 1; } + buf[p++] = (unsigned char)(((c<<6)&0xc0)|d); } } #undef BASE64DECODE_READ_NEXT_CHAR void XMLParserBase64Tool::alloc(int newsize) { - if (( !buf)&&(newsize)) { buf=malloc(newsize); buflen=newsize; return; } - if (newsize>buflen) { buf=realloc(buf, newsize); buflen=newsize; } + if (( !buf)&&(newsize)) { buf = malloc(newsize); buflen = newsize; return; } + if (newsize>buflen) { buf = realloc(buf, newsize); buflen = newsize; } } unsigned char *XMLParserBase64Tool::decode(XMLCSTR data, int *outlen, XMLError *xe) { - if (xe) *xe=eXMLErrorNone; - if ( !data) { *outlen=0; return (unsigned char*)""; } - unsigned int len=decodeSize(data, xe); - if (outlen) *outlen=len; + if (xe) *xe = eXMLErrorNone; + if ( !data) { *outlen = 0; return (unsigned char*)""; } + unsigned int len = decodeSize(data, xe); + if (outlen) *outlen = len; if ( !len) return NULL; alloc(len+1); if( !decode(data, (unsigned char*)buf, len, xe)) { return NULL; } diff --git a/src/modules/xml/xmlParser.h b/src/modules/xml/xmlParser.h index a166801d7c..3b91c62e5c 100644 --- a/src/modules/xml/xmlParser.h +++ b/src/modules/xml/xmlParser.h @@ -10,21 +10,21 @@ * @author Frank Vanden Berghen * * Copyright (c) 2002, Business-Insight - * Business-Insight + * Business-Insight * All rights reserved. - * See the file AFPL-license.txt about the licensing terms + * See the file AFPL-license.txt about the licensing terms * * \section tutorial First Tutorial - * You can follow a simple Tutorial to know the basics... + * You can follow a simple Tutorial to know the basics... * * \section usage General usage: How to include the XMLParser library inside your project. * - * The library is composed of two files: xmlParser.cpp and - * xmlParser.h. These are the ONLY 2 files that you need when + * The library is composed of two files: xmlParser.cpp and + * xmlParser.h. These are the ONLY 2 files that you need when * using the library inside your own projects. * * All the functions of the library are documented inside the comments of the file - * xmlParser.h. These comments can be transformed in + * xmlParser.h. These comments can be transformed in * full-fledged HTML documentation using the DOXYGEN software: simply type: "doxygen doxy.cfg" * * By default, the XMLParser library uses (char*) for string representation.To use the (wchar_t*) @@ -35,11 +35,11 @@ * \section example Advanced Tutorial and Many Examples of usage. * * Some very small introductory examples are described inside the Tutorial file - * xmlParser.html + * xmlParser.html * - * Some additional small examples are also inside the file xmlTest.cpp + * Some additional small examples are also inside the file xmlTest.cpp * (for the "char*" version of the library) and inside the file - * xmlTestUnicode.cpp (for the "wchar_t*" + * xmlTestUnicode.cpp (for the "wchar_t*" * version of the library). If you have a question, please review these additionnal examples * before sending an e-mail to the author. * @@ -68,10 +68,10 @@ * the XMLParser Library allows me to have lightening XML parsing speed even in debug! * Other than that, the DLL version is useless: In the release version of my tool, * I always use the normal, ".cpp"-based, XMLParser Library (I simply include the - * xmlParser.cpp and - * xmlParser.h files into the project). + * xmlParser.cpp and + * xmlParser.h files into the project). * - * The file XMLNodeAutoexp.txt contains some + * The file XMLNodeAutoexp.txt contains some * "tweaks" that improve substancially the display of the content of the XMLNode objects * inside the Visual Studio Debugger. Believe me, once you have seen inside the debugger * the "smooth" display of the XMLNode objects, you cannot live without it anymore! @@ -182,11 +182,11 @@ typedef enum XMLError /// Enumeration used to manage type of data. Use in conjunction with structure XMLNodeContents typedef enum XMLElementType { - eNodeChild=0, - eNodeAttribute=1, - eNodeText=2, - eNodeClear=3, - eNodeNULL=4 + eNodeChild = 0, + eNodeAttribute = 1, + eNodeText = 2, + eNodeClear = 3, + eNodeNULL = 4 } XMLElementType; /// Structure used to obtain error details if the parse fails. @@ -242,7 +242,7 @@ public: * @{ */ /// Parse an XML string and return the root of a XMLNode tree representing the string. - static XMLNode parseString (XMLCSTR lpXMLString, XMLCSTR tag=NULL, XMLResults *pResults=NULL); + static XMLNode parseString (XMLCSTR lpXMLString, XMLCSTR tag = NULL, XMLResults *pResults = NULL); /**< The "parseString" function parse an XML string and return the root of a XMLNode tree. The "opposite" of this function is * the function "createXMLString" that re-creates an XML string from an XMLNode tree. If the XML document is corrupted, the * "parseString" method will initialize the "pResults" variable with some information that can be used to trace the error. @@ -255,7 +255,7 @@ public: */ /// Parse an XML file and return the root of a XMLNode tree representing the file. - static XMLNode parseFile (XMLCSTR filename, XMLCSTR tag=NULL, XMLResults *pResults=NULL); + static XMLNode parseFile (XMLCSTR filename, XMLCSTR tag = NULL, XMLResults *pResults = NULL); /**< The "parseFile" function parse an XML file and return the root of a XMLNode tree. The "opposite" of this function is * the function "writeToFile" that re-creates an XML file from an XMLNode tree. If the XML document is corrupted, the * "parseFile" method will initialize the "pResults" variable with some information that can be used to trace the error. @@ -268,7 +268,7 @@ public: */ /// Parse an XML file and return the root of a XMLNode tree representing the file. A very crude error checking is made. An attempt to guess the Char Encoding used in the file is made. - static XMLNode openFileHelper(XMLCSTR filename, XMLCSTR tag=NULL); + static XMLNode openFileHelper(XMLCSTR filename, XMLCSTR tag = NULL); /**< The "openFileHelper" function reports to the screen all the warnings and errors that occurred during parsing of the XML file. * This function also tries to guess char Encoding (UTF-8, ASCII or SHIT-JIS) based on the first 200 bytes of the file. Since each * application has its own way to report and deal with errors, you should rather use the "parseFile" function to parse XML files @@ -289,7 +289,7 @@ public: static XMLCSTR getError(XMLError error); ///< this gives you a user-friendly explanation of the parsing error /// Create an XML string starting from the current XMLNode. - XMLSTR createXMLString(int nFormat=1, int *pnSize=NULL) const; + XMLSTR createXMLString(int nFormat = 1, int *pnSize = NULL) const; /**< The returned string should be free'd using the "freeXMLString" function. * * If nFormat == 0, no formatting is required otherwise this returns an user friendly XML string from a given element @@ -297,12 +297,12 @@ public: /// Save the content of an xmlNode inside a file XMLError writeToFile(XMLCSTR filename, - const char *encoding=NULL, - char nFormat=1) const; + const char *encoding = NULL, + char nFormat = 1) const; /**< If nFormat == 0, no formatting is required otherwise this returns an user friendly XML string from a given element with appropriate white spaces and carriage returns. * If the global parameter "characterEncoding == encoding_UTF8", then the "encoding" parameter is ignored and always set to "utf-8". * If the global parameter "characterEncoding == encoding_ShiftJIS", then the "encoding" parameter is ignored and always set to "SHIFT-JIS". - * If "_XMLWIDECHAR=1", then the "encoding" parameter is ignored and always set to "utf-16". + * If "_XMLWIDECHAR = 1", then the "encoding" parameter is ignored and always set to "utf-16". * If no "encoding" parameter is given the "ISO-8859-1" encoding is used. */ /** @} */ @@ -316,16 +316,16 @@ public: XMLNode getParentNode() const; ///< return the parent node XMLNode getChildNode(int i=0) const; ///< return ith child node XMLNode getChildNode(XMLCSTR name, int i) const; ///< return ith child node with specific name (return an empty node if failing). If i == -1, this returns the last XMLNode with the given name. - XMLNode getChildNode(XMLCSTR name, int *i=NULL) const; ///< return next child node with specific name (return an empty node if failing) + XMLNode getChildNode(XMLCSTR name, int *i = NULL) const; ///< return next child node with specific name (return an empty node if failing) XMLNode getChildNodeWithAttribute(XMLCSTR tagName, XMLCSTR attributeName, - XMLCSTR attributeValue=NULL, - int *i=NULL) const; ///< return child node with specific name/attribute (return an empty node if failing) - XMLNode getChildNodeByPath(XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/'); + XMLCSTR attributeValue = NULL, + int *i = NULL) const; ///< return child node with specific name/attribute (return an empty node if failing) + XMLNode getChildNodeByPath(XMLSTR path, char createNodeIfMissing = 0, XMLCHAR sep = '/'); ///< return the first child node with specific path. WARNING: the value of the parameter "path" is destroyed! - XMLNode getChildNodeByPath(XMLCSTR path, char createNodeIfMissing=0, XMLCHAR sep='/'); + XMLNode getChildNodeByPath(XMLCSTR path, char createNodeIfMissing = 0, XMLCHAR sep = '/'); ///< return the first child node with specific path - XMLNode getChildNodeByPathNonConst(XMLSTR path, char createNodeIfMissing=0, XMLCHAR sep='/'); + XMLNode getChildNodeByPathNonConst(XMLSTR path, char createNodeIfMissing = 0, XMLCHAR sep = '/'); ///< return the first child node with specific path. XMLNode getNextNode() const; @@ -336,7 +336,7 @@ public: XMLCSTR getAttributeValue(int i=0) const; ///< return ith attribute value char isAttributeSet(XMLCSTR name) const; ///< test if an attribute with a specific name is given XMLCSTR getAttribute(XMLCSTR name, int i) const; ///< return ith attribute content with specific name (return a NULL if failing) - XMLCSTR getAttribute(XMLCSTR name, int *i=NULL) const; ///< return next attribute content with specific name (return a NULL if failing) + XMLCSTR getAttribute(XMLCSTR name, int *i = NULL) const; ///< return next attribute content with specific name (return a NULL if failing) int nAttribute() const; ///< nbr of attribute XMLClear getClear(int i=0) const; ///< return ith clear field (comments) int nClear() const; ///< nbr of clear field @@ -350,7 +350,7 @@ public: ~XMLNode(); XMLNode(const XMLNode &A); ///< to allow shallow/fast copy: - XMLNode& operator=(const XMLNode& A); ///< to allow shallow/fast copy: + XMLNode& operator = (const XMLNode& A); ///< to allow shallow/fast copy: XMLNode(): d(NULL) {}; static XMLNode emptyXMLNode; @@ -367,8 +367,8 @@ public: * @ingroup XMLParserGeneral * The functions in this group allows you to create from scratch (or update) a XMLNode structure. Start by creating your top * node with the "createXMLTopNode" function and then add new nodes with the "addChild" function. The parameter 'pos' gives - * the position where the childNode, the text or the XMLClearTag will be inserted. The default value (pos=-1) inserts at the - * end. The value (pos=0) insert at the beginning (Insertion at the beginning is slower than at the end).
+ * the position where the childNode, the text or the XMLClearTag will be inserted. The default value (pos = -1) inserts at the + * end. The value (pos = 0) insert at the beginning (Insertion at the beginning is slower than at the end).
* * REMARK: 0 <= pos < nChild()+nText()+nClear()
*/ @@ -376,12 +376,12 @@ public: /** @defgroup creation Creating from scratch a XMLNode structure * @ingroup xmlModify * @{ */ - static XMLNode createXMLTopNode(XMLCSTR lpszName, char isDeclaration=FALSE); ///< Create the top node of an XMLNode structure - XMLNode addChild(XMLCSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1); ///< Add a new child node - XMLNode addChild(XMLNode nodeToAdd, XMLElementPosition pos=-1); ///< If the "nodeToAdd" has some parents, it will be detached from it's parents before being attached to the current XMLNode + static XMLNode createXMLTopNode(XMLCSTR lpszName, char isDeclaration = FALSE); ///< Create the top node of an XMLNode structure + XMLNode addChild(XMLCSTR lpszName, char isDeclaration = FALSE, XMLElementPosition pos = -1); ///< Add a new child node + XMLNode addChild(XMLNode nodeToAdd, XMLElementPosition pos = -1); ///< If the "nodeToAdd" has some parents, it will be detached from it's parents before being attached to the current XMLNode XMLAttribute *addAttribute(XMLCSTR lpszName, XMLCSTR lpszValuev); ///< Add a new attribute - XMLCSTR addText(XMLCSTR lpszValue, XMLElementPosition pos=-1); ///< Add a new text content - XMLClear *addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1); + XMLCSTR addText(XMLCSTR lpszValue, XMLElementPosition pos = -1); ///< Add a new text content + XMLClear *addClear(XMLCSTR lpszValue, XMLCSTR lpszOpen = NULL, XMLCSTR lpszClose = NULL, XMLElementPosition pos = -1); /**< Add a new clear tag * @param lpszOpen default value "" @@ -395,8 +395,8 @@ public: */ XMLCSTR updateName(XMLCSTR lpszName); ///< change node's name XMLAttribute *updateAttribute(XMLAttribute *newAttribute, XMLAttribute *oldAttribute); ///< if the attribute to update is missing, a new one will be added - XMLAttribute *updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName=NULL, int i=0); ///< if the attribute to update is missing, a new one will be added - XMLAttribute *updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName);///< set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added + XMLAttribute *updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName = NULL, int i=0); ///< if the attribute to update is missing, a new one will be added + XMLAttribute *updateAttribute(XMLCSTR lpszNewValue, XMLCSTR lpszNewName, XMLCSTR lpszOldName);///< set lpszNewName = NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added XMLCSTR updateText(XMLCSTR lpszNewValue, int i=0); ///< if the text to update is missing, a new one will be added XMLCSTR updateText(XMLCSTR lpszNewValue, XMLCSTR lpszOldValue); ///< if the text to update is missing, a new one will be added XMLClear *updateClear(XMLCSTR lpszNewContent, int i=0); ///< if the clearTag to update is missing, a new one will be added @@ -440,27 +440,27 @@ public: * \endcode * Typically, you will never do: * \code - * char *b=(char*)malloc(...); + * char *b = (char*)malloc(...); * xNode.addText(b); * free(b); * \endcode * ... but rather: * \code - * char *b=(char*)malloc(...); + * char *b = (char*)malloc(...); * xNode.addText_WOSD(b); * \endcode * ('free(b)' is performed by the XMLNode class) * @{ */ - static XMLNode createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration=FALSE); ///< Create the top node of an XMLNode structure - XMLNode addChild_WOSD(XMLSTR lpszName, char isDeclaration=FALSE, XMLElementPosition pos=-1); ///< Add a new child node + static XMLNode createXMLTopNode_WOSD(XMLSTR lpszName, char isDeclaration = FALSE); ///< Create the top node of an XMLNode structure + XMLNode addChild_WOSD(XMLSTR lpszName, char isDeclaration = FALSE, XMLElementPosition pos = -1); ///< Add a new child node XMLAttribute *addAttribute_WOSD(XMLSTR lpszName, XMLSTR lpszValue); ///< Add a new attribute - XMLCSTR addText_WOSD(XMLSTR lpszValue, XMLElementPosition pos=-1); ///< Add a new text content - XMLClear *addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen=NULL, XMLCSTR lpszClose=NULL, XMLElementPosition pos=-1); ///< Add a new clear Tag + XMLCSTR addText_WOSD(XMLSTR lpszValue, XMLElementPosition pos = -1); ///< Add a new text content + XMLClear *addClear_WOSD(XMLSTR lpszValue, XMLCSTR lpszOpen = NULL, XMLCSTR lpszClose = NULL, XMLElementPosition pos = -1); ///< Add a new clear Tag XMLCSTR updateName_WOSD(XMLSTR lpszName); ///< change node's name XMLAttribute *updateAttribute_WOSD(XMLAttribute *newAttribute, XMLAttribute *oldAttribute); ///< if the attribute to update is missing, a new one will be added - XMLAttribute *updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName=NULL, int i=0); ///< if the attribute to update is missing, a new one will be added - XMLAttribute *updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName); ///< set lpszNewName=NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added + XMLAttribute *updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName = NULL, int i=0); ///< if the attribute to update is missing, a new one will be added + XMLAttribute *updateAttribute_WOSD(XMLSTR lpszNewValue, XMLSTR lpszNewName, XMLCSTR lpszOldName); ///< set lpszNewName = NULL if you don't want to change the name of the attribute if the attribute to update is missing, a new one will be added XMLCSTR updateText_WOSD(XMLSTR lpszNewValue, int i=0); ///< if the text to update is missing, a new one will be added XMLCSTR updateText_WOSD(XMLSTR lpszNewValue, XMLCSTR lpszOldValue); ///< if the text to update is missing, a new one will be added XMLClear *updateClear_WOSD(XMLSTR lpszNewContent, int i=0); ///< if the clearTag to update is missing, a new one will be added @@ -487,30 +487,30 @@ public: /// Enumeration for XML character encoding. typedef enum XMLCharEncoding { - char_encoding_error=0, - char_encoding_UTF8=1, - char_encoding_legacy=2, - char_encoding_ShiftJIS=3, - char_encoding_GB2312=4, - char_encoding_Big5=5, - char_encoding_GBK=6 // this is actually the same as Big5 + char_encoding_error = 0, + char_encoding_UTF8 = 1, + char_encoding_legacy = 2, + char_encoding_ShiftJIS = 3, + char_encoding_GB2312 = 4, + char_encoding_Big5 = 5, + char_encoding_GBK = 6 // this is actually the same as Big5 } XMLCharEncoding; /** \addtogroup conversions * @{ */ /// Sets the global options for the conversions - static char setGlobalOptions(XMLCharEncoding characterEncoding=XMLNode::char_encoding_UTF8, char guessWideCharChars=1, - char dropWhiteSpace=1, char removeCommentsInMiddleOfText=1); + static char setGlobalOptions(XMLCharEncoding characterEncoding = XMLNode::char_encoding_UTF8, char guessWideCharChars = 1, + char dropWhiteSpace = 1, char removeCommentsInMiddleOfText = 1); /**< The "setGlobalOptions" function allows you to change four global parameters that affect string & file * parsing. First of all, you most-probably will never have to change these 3 global parameters. * - * @param guessWideCharChars If "guessWideCharChars"=1 and if this library is compiled in WideChar mode, then the + * @param guessWideCharChars If "guessWideCharChars" = 1 and if this library is compiled in WideChar mode, then the * XMLNode::parseFile and XMLNode::openFileHelper functions will test if the file contains ASCII * characters. If this is the case, then the file will be loaded and converted in memory to * WideChar before being parsed. If 0, no conversion will be performed. * - * @param guessWideCharChars If "guessWideCharChars"=1 and if this library is compiled in ASCII/UTF8/char* mode, then the + * @param guessWideCharChars If "guessWideCharChars" = 1 and if this library is compiled in ASCII/UTF8/char* mode, then the * XMLNode::parseFile and XMLNode::openFileHelper functions will test if the file contains WideChar * characters. If this is the case, then the file will be loaded and converted in memory to * ASCII/UTF8/char* before being parsed. If 0, no conversion will be performed. @@ -525,14 +525,14 @@ public: * complexity of the user's code for parsing. So, 99% of the time, it's better to drop * the "empty" text fields. However The XML specification indicates that no white spaces * should be lost when parsing the file. So to be perfectly XML-compliant, you should set - * dropWhiteSpace=0. A note of caution: if you set "dropWhiteSpace=0", the parser will be + * dropWhiteSpace = 0. A note of caution: if you set "dropWhiteSpace = 0", the parser will be * slower and your code will be more complex. * * @param removeCommentsInMiddleOfText To explain this parameter, let's consider this code: * \code - * XMLNode x=XMLNode::parseString("foobarchu", "a"); + * XMLNode x = XMLNode::parseString("foobarchu", "a"); * \endcode - * If removeCommentsInMiddleOfText=0, then we will have: + * If removeCommentsInMiddleOfText = 0, then we will have: * \code * x.getText(0) -> "foo" * x.getText(1) -> "bar" @@ -540,7 +540,7 @@ public: * x.getClear(0) --> "" * x.getClear(1) --> "" * \endcode - * If removeCommentsInMiddleOfText=1, then we will have: + * If removeCommentsInMiddleOfText = 1, then we will have: * \code * x.getText(0) -> "foobar" * x.getText(1) -> "chu" @@ -549,11 +549,11 @@ public: * * \return "0" when there are no errors. If you try to set an unrecognized encoding then the return value will be "1" to signal an error. * - * \note Sometime, it's useful to set "guessWideCharChars=0" to disable any conversion + * \note Sometime, it's useful to set "guessWideCharChars = 0" to disable any conversion * because the test to detect the file-type (ASCII/UTF8/char* or WideChar) may fail (rarely). */ /// Guess the character encoding of the string (ascii, utf8 or shift-JIS) - static XMLCharEncoding guessCharEncoding(void *buffer, int bufLen, char useXMLEncodingAttribute=1); + static XMLCharEncoding guessCharEncoding(void *buffer, int bufLen, char useXMLEncodingAttribute = 1); /**< The "guessCharEncoding" function try to guess the character encoding. You most-probably will never * have to use this function. It then returns the appropriate value of the global parameter * "characterEncoding" described in the XMLNode::setGlobalOptions. The guess is based on the content of a buffer of length @@ -571,14 +571,14 @@ private: typedef struct XMLNodeDataTag // to allow shallow copy and "intelligent/smart" pointers (automatic delete): { - XMLCSTR lpszName; // Element name (=NULL if root) + XMLCSTR lpszName; // Element name ( = NULL if root) XMLCSTR lpszNS; // Namespace int nChild, // Number of child nodes nText, // Number of text fields nClear, // Number of Clear fields (comments) nAttribute; // Number of attributes char isDeclaration; // Whether node is an XML declaration - '' - struct XMLNodeDataTag *pParent; // Pointer to parent element (=NULL if root) + struct XMLNodeDataTag *pParent; // Pointer to parent element ( = NULL if root) XMLNode *pChild; // Array of child nodes XMLCSTR *pText; // Array of text fields XMLClear *pClear; // Array of clear fields @@ -625,7 +625,7 @@ typedef struct XMLNodeContents * @ingroup xmlModify * @{ */ /// Duplicate (copy in a new allocated buffer) the source string. -XMLDLLENTRY XMLSTR stringDup(XMLCSTR source, int cbData=-1); +XMLDLLENTRY XMLSTR stringDup(XMLCSTR source, int cbData = -1); /**< This is * a very handy function when used with all the "XMLNode::*_WOSD" functions (\link xmlWOSD \endlink). * @param cbData If != 0 then cbData is the number of chars to duplicate. New strings allocated with @@ -644,12 +644,12 @@ XMLDLLENTRY void freeXMLString(XMLSTR t); // {free(t);} * delete them without any trouble. * * @{ */ -XMLDLLENTRY char xmltob(XMLCSTR xmlString, char defautValue=0); -XMLDLLENTRY int xmltoi(XMLCSTR xmlString, int defautValue=0); -XMLDLLENTRY long xmltol(XMLCSTR xmlString, long defautValue=0); -XMLDLLENTRY double xmltof(XMLCSTR xmlString, double defautValue=.0); -XMLDLLENTRY XMLCSTR xmltoa(XMLCSTR xmlString, XMLCSTR defautValue=_CXML("")); -XMLDLLENTRY XMLCHAR xmltoc(XMLCSTR xmlString, const XMLCHAR defautValue=_CXML('\0')); +XMLDLLENTRY char xmltob(XMLCSTR xmlString, char defautValue = 0); +XMLDLLENTRY int xmltoi(XMLCSTR xmlString, int defautValue = 0); +XMLDLLENTRY long xmltol(XMLCSTR xmlString, long defautValue = 0); +XMLDLLENTRY double xmltof(XMLCSTR xmlString, double defautValue = .0); +XMLDLLENTRY XMLCSTR xmltoa(XMLCSTR xmlString, XMLCSTR defautValue = _CXML("")); +XMLDLLENTRY XMLCHAR xmltoc(XMLCSTR xmlString, const XMLCHAR defautValue = _CXML('\0')); /** @} */ /** @defgroup ToXMLStringTool Helper class to create XML files using "printf", "fprintf", "cout", ... functions. @@ -706,31 +706,31 @@ public: void freeBuffer();///< Call this function when you have finished using this object to release memory used by the internal buffer. /** - * @param formatted If "formatted"=true, some space will be reserved for a carriage-return every 72 chars. */ - static int encodeLength(int inBufLen, char formatted=0); ///< return the length of the base64 string that encodes a data buffer of size inBufLen bytes. + * @param formatted If "formatted" = true, some space will be reserved for a carriage-return every 72 chars. */ + static int encodeLength(int inBufLen, char formatted = 0); ///< return the length of the base64 string that encodes a data buffer of size inBufLen bytes. /** * The "base64Encode" function returns a string containing the base64 encoding of "inByteLen" bytes * from "inByteBuf". If "formatted" parameter is true, then there will be a carriage-return every 72 chars. * The string will be free'd when the XMLParserBase64Tool object is deleted. * All returned strings are sharing the same memory space. */ - XMLSTR encode(unsigned char *inByteBuf, unsigned int inByteLen, char formatted=0); ///< returns a pointer to an internal buffer containing the base64 string containing the binary data encoded from "inByteBuf" + XMLSTR encode(unsigned char *inByteBuf, unsigned int inByteLen, char formatted = 0); ///< returns a pointer to an internal buffer containing the base64 string containing the binary data encoded from "inByteBuf" /// returns the number of bytes which will be decoded from "inString". - static unsigned int decodeSize(XMLCSTR inString, XMLError *xe=NULL); + static unsigned int decodeSize(XMLCSTR inString, XMLError *xe = NULL); /** * The "decode" function returns a pointer to a buffer containing the binary data decoded from "inString" * The output buffer will be free'd when the XMLParserBase64Tool object is deleted. * All output buffer are sharing the same memory space. * @param inString If "instring" is malformed, NULL will be returned */ - unsigned char* decode(XMLCSTR inString, int *outByteLen=NULL, XMLError *xe=NULL); ///< returns a pointer to an internal buffer containing the binary data decoded from "inString" + unsigned char* decode(XMLCSTR inString, int *outByteLen = NULL, XMLError *xe = NULL); ///< returns a pointer to an internal buffer containing the binary data decoded from "inString" /** * decodes data from "inString" to "outByteBuf". You need to provide the size (in byte) of "outByteBuf" * in "inMaxByteOutBuflen". If "outByteBuf" is not large enough or if data is malformed, then "FALSE" * will be returned; otherwise "TRUE". */ - static unsigned char decode(XMLCSTR inString, unsigned char *outByteBuf, int inMaxByteOutBuflen, XMLError *xe=NULL); ///< deprecated. + static unsigned char decode(XMLCSTR inString, unsigned char *outByteBuf, int inMaxByteOutBuflen, XMLError *xe = NULL); ///< deprecated. private: void *buf; diff --git a/src/resource.rc b/src/resource.rc index 36ad9de944..7e0ae1b3c2 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -236,161 +236,6 @@ BEGIN EDITTEXT IDC_MSG,5,5,177,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL END -IDD_DETAILS DIALOGEX 0, 0, 318, 210 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "%s: User Details" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - CONTROL "%s\nView personal user details and more",IDC_HEADERBAR, - "MHeaderbarCtrl",0x0,0,0,318,25 - CONTROL "",IDC_PAGETREE,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_NOTOOLTIPS | TVS_TRACKSELECT | TVS_FULLROWSELECT | TVS_NONEVENHEIGHT | WS_HSCROLL | WS_TABSTOP,3,30,76,176,WS_EX_STATICEDGE - CONTROL "Tab1",IDC_TABS,"SysTabControl32",TCS_HOTTRACK | TCS_MULTILINE | WS_TABSTOP,85,29,228,158 - PUSHBUTTON "Update Now",IDC_UPDATE,85,191,55,14,WS_DISABLED - CTEXT "Updating",IDC_UPDATING,145,194,113,8,SS_NOPREFIX | SS_CENTERIMAGE - DEFPUSHBUTTON "OK",IDOK,263,191,50,14 -END - -IDD_INFO_SUMMARY DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Nickname:",IDC_STATIC,5,5,46,8 - EDITTEXT IDC_NICK,51,5,166,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "First name:",IDC_STATIC,5,18,46,8 - EDITTEXT IDC_FIRSTNAME,51,18,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Gender:",IDC_STATIC,126,18,44,8 - EDITTEXT IDC_GENDER,170,18,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Last name:",IDC_STATIC,5,31,46,8 - EDITTEXT IDC_LASTNAME,51,31,74,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Age:",IDC_STATIC,126,31,44,8 - EDITTEXT IDC_AGE,170,31,47,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "E-mail:",IDC_STATIC,5,44,46,8 - CONTROL "",IDC_EMAIL,"Hyperlink",WS_TABSTOP,51,44,166,8 - LTEXT "Date of birth:",IDC_STATIC,5,58,59,8 - EDITTEXT IDC_DOBDAY,66,58,8,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_DOBMONTH,76,58,16,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_DOBYEAR,94,58,20,8,ES_RIGHT | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Marital status:",IDC_STATIC,5,71,76,8 - EDITTEXT IDC_MARITAL,83,71,87,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER -END - -IDD_INFO_CONTACT DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "E-mail:",IDC_STATIC,5,5,212,8 - CONTROL "List1",IDC_EMAILS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,14,212,50 - LTEXT "Phone:",IDC_STATIC,5,68,212,8 - CONTROL "List1",IDC_PHONES,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,77,212,50 -END - -IDD_INFO_BACKGROUND DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Web page:",IDC_STATIC,5,5,44,8 - CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,49,5,168,8 - LTEXT "Past background:",IDC_STATIC,5,18,212,8 - CONTROL "List1",IDC_PAST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,27,212,44 - LTEXT "Interests:",IDC_STATIC,5,74,212,8 - CONTROL "List1",IDC_INTERESTS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,5,83,212,44 -END - -IDD_INFO_NOTES DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "About:",IDC_STATIC,5,5,212,8 - EDITTEXT IDC_ABOUT,5,13,212,45,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL - LTEXT "My notes:",IDC_STATIC,5,61,212,8 - EDITTEXT IDC_MYNOTES,5,69,212,58,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL -END - -IDD_INFO_LOCATION DIALOGEX 0, 0, 222, 147 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Street:",IDC_STATIC,5,5,51,8 - EDITTEXT IDC_STREET,56,5,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "City:",IDC_STATIC,5,22,51,8 - EDITTEXT IDC_CITY,56,22,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "State:",IDC_STATIC,5,33,51,8 - EDITTEXT IDC_STATE,56,33,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Postal code:",IDC_STATIC,5,44,51,8 - EDITTEXT IDC_ZIP,56,44,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Country:",IDC_STATIC,5,55,51,8 - EDITTEXT IDC_COUNTRY,56,55,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Spoken languages:",IDC_STATIC,5,70,51,16 - EDITTEXT IDC_LANGUAGE1,56,70,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_LANGUAGE2,56,78,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - EDITTEXT IDC_LANGUAGE3,56,86,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Timezone:",IDC_STATIC,5,97,51,8 - EDITTEXT IDC_TIMEZONE,56,97,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Local time:",IDC_STATIC,5,108,51,8 - EDITTEXT IDC_LOCALTIME,56,108,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - COMBOBOX IDC_TIMEZONESELECT,4,132,214,46,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Set custom time zone",IDC_STATIC,5,121,212,8 -END - -IDD_INFO_WORK DIALOGEX 0, 0, 222, 132 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Company:",IDC_STATIC,5,5,51,8 - EDITTEXT IDC_COMPANY,56,5,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Department:",IDC_STATIC,5,17,51,8 - EDITTEXT IDC_DEPARTMENT,56,17,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Position:",IDC_STATIC,5,28,51,8 - EDITTEXT IDC_POSITION,56,28,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Street:",IDC_STATIC,5,48,51,8 - EDITTEXT IDC_STREET,56,48,161,16,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "City:",IDC_STATIC,5,65,51,8 - EDITTEXT IDC_CITY,56,65,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "State:",IDC_STATIC,5,76,51,8 - EDITTEXT IDC_STATE,56,76,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Postal code:",IDC_STATIC,5,87,51,8 - EDITTEXT IDC_ZIP,56,87,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Country:",IDC_STATIC,5,98,51,8 - EDITTEXT IDC_COUNTRY,56,98,161,8,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER - LTEXT "Website:",IDC_STATIC,5,109,51,8 - CONTROL "",IDC_WEBPAGE,"Hyperlink",WS_TABSTOP,57,109,160,8 -END - -IDD_ADDEMAIL DIALOGEX 0, 0, 187, 42 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Add E-Mail Address" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_EMAIL,5,5,177,12,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,36,23,50,14 - PUSHBUTTON "Cancel",IDCANCEL,102,23,50,14 -END - -IDD_ADDPHONE DIALOGEX 0, 0, 210, 91 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Add Phone Number" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Enter country, area code and phone number:",IDC_STATIC,5,5,200,8 - COMBOBOX IDC_COUNTRY,21,15,66,120,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_AREA,91,15,36,12,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_NUMBER,131,15,74,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "Or enter a full international number:",IDC_STATIC,5,30,200,8 - EDITTEXT IDC_PHONE,21,40,184,12,ES_AUTOHSCROLL - CONTROL "Phone can receive SMS text messages",IDC_SMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,56,200,10 - DEFPUSHBUTTON "OK",IDOK,47,72,50,14 - PUSHBUTTON "Cancel",IDCANCEL,113,72,50,14 -END - IDD_INSTALLINI DIALOGEX 0, 0, 213, 103 STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT @@ -1422,82 +1267,6 @@ BEGIN HORZGUIDE, 62 END - IDD_INFO_CONTACT, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - END - - IDD_INFO_BACKGROUND, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - VERTGUIDE, 49 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - END - - IDD_INFO_NOTES, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - END - - IDD_INFO_LOCATION, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - VERTGUIDE, 56 - TOPMARGIN, 5 - BOTTOMMARGIN, 142 - HORZGUIDE, 22 - HORZGUIDE, 33 - HORZGUIDE, 45 - HORZGUIDE, 56 - HORZGUIDE, 70 - HORZGUIDE, 95 - HORZGUIDE, 106 - END - - IDD_INFO_WORK, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 217 - VERTGUIDE, 56 - VERTGUIDE, 126 - VERTGUIDE, 170 - TOPMARGIN, 5 - BOTTOMMARGIN, 127 - HORZGUIDE, 16 - HORZGUIDE, 27 - HORZGUIDE, 44 - HORZGUIDE, 61 - HORZGUIDE, 72 - HORZGUIDE, 83 - HORZGUIDE, 94 - HORZGUIDE, 105 - END - - IDD_ADDEMAIL, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 182 - TOPMARGIN, 5 - BOTTOMMARGIN, 37 - END - - IDD_ADDPHONE, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 205 - TOPMARGIN, 5 - BOTTOMMARGIN, 86 - END - IDD_INSTALLINI, DIALOG BEGIN LEFTMARGIN, 5 @@ -1836,12 +1605,12 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include \r\n" "#include \r\n" @@ -1849,7 +1618,7 @@ BEGIN "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -2034,4 +1803,3 @@ IDB_SORTCOLDOWN BITMAP "res/arrow_sort_column_down.bmp" ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED - -- cgit v1.2.3