From 2ebb53adcd4663ac2f1da74972b7b21d53b0ce53 Mon Sep 17 00:00:00 2001 From: "george.hazan" Date: Thu, 26 May 2011 20:18:42 +0000 Subject: patch for dbeditorpp: C++ support, other improvements git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@122 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- dbeditorpp/Version.h | 28 + dbeditorpp/addeditsettingsdlg.cpp | 50 +- dbeditorpp/copymodule.cpp | 32 +- dbeditorpp/dbeditorpp.vcproj | 227 +++++-- dbeditorpp/dbeditorpp_10.vcxproj | 249 ++++++-- dbeditorpp/dbeditorpp_10.vcxproj.filters | 148 +++++ dbeditorpp/dbeditorpp_8.vcproj | 604 ++++++++++++++++++ dbeditorpp/dbeditorpp_9.vcproj | 1005 ++++++++++++++++++++++++++++++ dbeditorpp/deletemodule.cpp | 6 +- dbeditorpp/exportimport.cpp | 384 +++++++----- dbeditorpp/findwindow.cpp | 96 +-- dbeditorpp/headers.h | 106 ++-- dbeditorpp/icons.cpp | 20 +- dbeditorpp/knownmodules.cpp | 20 +- dbeditorpp/main.cpp | 326 ++-------- dbeditorpp/main_window.cpp | 67 +- dbeditorpp/modsettingenum.cpp | 12 +- dbeditorpp/modules.cpp | 6 +- dbeditorpp/moduletree.cpp | 88 +-- dbeditorpp/options.cpp | 17 +- dbeditorpp/resource.rc | 201 ++---- dbeditorpp/settinglist.cpp | 227 ++++--- dbeditorpp/watchedvars.cpp | 57 +- 23 files changed, 2918 insertions(+), 1058 deletions(-) create mode 100644 dbeditorpp/Version.h create mode 100644 dbeditorpp/dbeditorpp_10.vcxproj.filters create mode 100644 dbeditorpp/dbeditorpp_8.vcproj create mode 100644 dbeditorpp/dbeditorpp_9.vcproj diff --git a/dbeditorpp/Version.h b/dbeditorpp/Version.h new file mode 100644 index 0000000..9ce8b18 --- /dev/null +++ b/dbeditorpp/Version.h @@ -0,0 +1,28 @@ +#define __MAJOR_VERSION 3 +#define __MINOR_VERSION 2 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + +#ifdef _UNICODE +#if defined(WIN64) || defined(_WIN64) + #define __PLUGIN_NAME "Database Editor++ (Unicode x64)" +#else + #define __PLUGIN_NAME "Database Editor++ (Unicode)" +#endif +#else + #define __PLUGIN_NAME "Database Editor++" +#endif +#define __INTERNAL_NAME "DBEditor" +#define __FILENAME "Svc_dbepp.dll" +#define __DESCRIPTION "Advanced Database Editor." +#define __AUTHOR "Bio, Jonathan Gordon" +#define __AUTHOREMAIL "bio@msx.ru, jdgordy@gmail.com" +#define __AUTHORWEB "http://addons.miranda-im.org/details.php?action=viewfile&id=2957" +#define __COPYRIGHT "© 2003-2011 Bio, Jonathan Gordon" diff --git a/dbeditorpp/addeditsettingsdlg.cpp b/dbeditorpp/addeditsettingsdlg.cpp index c0bfb7c..6c21fe4 100644 --- a/dbeditorpp/addeditsettingsdlg.cpp +++ b/dbeditorpp/addeditsettingsdlg.cpp @@ -56,8 +56,8 @@ BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // case DBVT_ASCIIZ: if (toType == 4) // convert to UNICODE { - int len = strlen(dbv.pszVal)+1; - WCHAR *wc = _alloca(len*sizeof(WCHAR)); + int len = (int)strlen(dbv.pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); Result = !DBWriteContactSettingWString(hContact, module, setting, wc); } @@ -74,9 +74,9 @@ BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // case DBVT_UTF8: if (toType == 3 && UOS) // convert to ANSI { - int len = strlen(dbv.pszVal)+1; - char *sz = _alloca(len*3); - WCHAR *wc = _alloca(len*sizeof(WCHAR)); + int len = (int)strlen(dbv.pszVal) + 1; + char *sz = (char*)_alloca(len*3); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); Result = !DBWriteContactSettingString(hContact, module, setting, sz); @@ -108,14 +108,14 @@ int saveAsType(HWND hwnd) } -BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { char tmp[32]; - SetWindowLong(hwnd,GWL_USERDATA,(LPARAM)lParam); + SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lParam); switch (((struct DBsetting*)lParam)->dbv.type) { case DBVT_BYTE: @@ -159,7 +159,7 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar char text[32]; SetWindowText(hwnd, Translate("Edit DWORD value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - mir_snprintf(text, 32, "%X", ((struct DBsetting*)lParam)->dbv.dVal); + mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); } CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); @@ -207,10 +207,10 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); if (UOS) { - int length = strlen(tmp)+1; - WCHAR *wc = _alloca(length*sizeof(WCHAR)); + int length = (int)strlen(tmp) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); - _SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); + SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); } else { // convert from UTF8 @@ -243,7 +243,7 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar for(j=0; jdbv.type == DBVT_UTF8 && UOS) - _SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); + SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); else GetWindowText(GetDlgItem(hwnd, valueID), value, valueLength+1); } @@ -425,10 +425,10 @@ BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } // fall through case IDCANCEL: { - struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLong(hwnd,GWL_USERDATA); - safe_free(dbsetting->module); - safe_free(dbsetting->setting); - safe_free(dbsetting); + struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + mir_free(dbsetting->module); + mir_free(dbsetting->setting); + mir_free(dbsetting); DestroyWindow(hwnd); } break; @@ -443,16 +443,16 @@ void editSetting(HANDLE hContact, char* module, char* setting) DBVARIANT dbv = {0}; // freed in the dialog if (!GetSetting(hContact,module, setting, &dbv)) { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets free()ed in the window proc dbsetting->dbv = dbv; // freed in the dialog dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(setting); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(setting); if (dbv.type == DBVT_UTF8 && UOS) - _CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd2mainWindow,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); else - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd2mainWindow,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); } } \ No newline at end of file diff --git a/dbeditorpp/copymodule.cpp b/dbeditorpp/copymodule.cpp index a58be3c..25489a7 100644 --- a/dbeditorpp/copymodule.cpp +++ b/dbeditorpp/copymodule.cpp @@ -41,9 +41,9 @@ void copyModule(char* module, HANDLE hContactFrom, HANDLE hContactTo) FreeModuleSettingLL(&msll); } -BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - ModuleAndContact *mac = (ModuleAndContact *)GetWindowLong(hwnd,GWL_USERDATA); + ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd,GWLP_USERDATA); if (msg == WM_INITDIALOG) { int index, loaded; @@ -52,7 +52,7 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) while (hContact) { - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) loaded = IsProtocolLoaded(szProto); else loaded = 0; @@ -81,9 +81,9 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (protoW) { if (Order) - mir_snwprintf(nick, SIZEOF(nick),L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); else - mir_snwprintf(nick, SIZEOF(nick),L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); } else wcscpy(nick, nick_unknownW); @@ -96,8 +96,8 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); } - index = _SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); - _SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); + index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); + SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); } else { @@ -108,9 +108,9 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (szProto[0]) { if (Order) - mir_snprintf(nick, sizeof(nick),"(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); + mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); else - mir_snprintf(nick, sizeof(nick),"%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); + mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); } else strcpy(nick, nick_unknown); @@ -118,9 +118,9 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) else { if (Order) - mir_snprintf(nick, sizeof(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); + mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); else - mir_snprintf(nick, sizeof(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); } index = SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); @@ -134,7 +134,7 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)0); SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETCURSEL, index, 0); - SetWindowLong(hwnd,GWL_USERDATA,lParam); + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); TranslateDialogDefault(hwnd); } else @@ -167,14 +167,14 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SetCursor(LoadCursor(NULL,IDC_ARROW)); } - safe_free(mac); + mir_free(mac); refreshTree(1); DestroyWindow(hwnd); } break; case IDCANCEL: { - safe_free(mac); + mir_free(mac); DestroyWindow(hwnd); } break; @@ -186,12 +186,12 @@ BOOL CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) void copyModuleMenuItem(char* module, HANDLE hContact) { HWND hwnd; - ModuleAndContact *mac = (ModuleAndContact *)calloc(sizeof(ModuleAndContact),1); + ModuleAndContact *mac = (ModuleAndContact *)mir_calloc(sizeof(ModuleAndContact)); mac->hContact = hContact; strncpy(mac->module, module, 255); if (UOS) - hwnd = _CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); + hwnd = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); else hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); } \ No newline at end of file diff --git a/dbeditorpp/dbeditorpp.vcproj b/dbeditorpp/dbeditorpp.vcproj index d6406dd..028f1c3 100644 --- a/dbeditorpp/dbeditorpp.vcproj +++ b/dbeditorpp/dbeditorpp.vcproj @@ -11,10 +11,84 @@ Name="Win32"/> + + + + + + + + + + + + + + + + DebugInformationFormat="4"/> + ImportLibrary="$(IntDir)/$(TargetName).lib" + TargetMachine="1"/> + TypeLibraryName=".\Debug/dbeditorpp.tlb" + HeaderFileName=""/> + Culture="3081"/> + DebugInformationFormat="3"/> + ImportLibrary="$(IntDir)/$(TargetName).lib" + TargetMachine="1"/> + TypeLibraryName=".\Release/dbeditorpp.tlb" + HeaderFileName=""/> + Culture="3081"/> + + + + + + + + + + + + + + + + + Debug Unicode + Win32 + + + Debug Unicode + x64 + Debug Win32 + + Debug + x64 + + + Release Unicode + Win32 + + + Release Unicode + x64 + Release Win32 + + Release + x64 + - Svc_dbepp + dbeditorpp {9C6040B8-1173-40FA-A3DB-DE044CCD8250} - Svc_dbepp + dbeditorpp_8 + + DynamicLibrary + false + MultiByte + true + + + DynamicLibrary + false + MultiByte + DynamicLibrary false MultiByte + true DynamicLibrary false MultiByte + + Application + + + Application + + + Application + + + Application + + + + + + + - - + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - ../../../Files/Debug/Plugins\ - $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ - $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ - AllRules.ruleset - - - AllRules.ruleset - - - D:\Sources\miranda9_trunk\miranda\include;D:\Sources\externalapi;$(IncludePath) + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + true + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + true + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + true + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + true + svc_dbepp + svc_dbepp + svc_dbepp + svc_dbepp @@ -61,27 +131,30 @@ Disabled - ../../include;../ExternalAPI;../../ExternalAPI + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug - - + Use + headers.h Level3 + true EditAndContinue - Default + 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) + 0x0409 /MACHINE:I386 %(AdditionalOptions) + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + true true false $(IntDir)$(TargetName).lib - MachineX86 @@ -97,26 +170,108 @@ OnlyExplicitInline Size true - ../../include;../ExternalAPI;../../ExternalAPI - WIN32;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) true + MultiThreadedDLL true - - + Use + headers.h + AssemblyAndSourceCode Level3 + true + 4996;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + /MACHINE:I386 %(AdditionalOptions) + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + true + type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) + true + true + true + UseLinkTimeCodeGeneration + false + + + $(IntDir)$(TargetName).lib + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/dbeditorpp.tlb + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + headers.h + Level3 + true + EditAndContinue + 4996;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + /MACHINE:I386 %(AdditionalOptions) + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + true + true + false + + + $(IntDir)$(TargetName).lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/dbeditorpp.tlb + + + Full + OnlyExplicitInline + Size + true + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) + true + MultiThreadedDLL + true + Use + headers.h + AssemblyAndSourceCode + Level3 + true ProgramDatabase - Default 4996;%(DisableSpecificWarnings) - MultiThreaded NDEBUG;%(PreprocessorDefinitions) + 0x0409 /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + type=%27Win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 processorArchitecture=%27X86%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27;%(AdditionalManifestDependencies) + true true true UseLinkTimeCodeGeneration @@ -124,26 +279,30 @@ $(IntDir)$(TargetName).lib - MachineX86 - - - - - - - - - - - - - - - - + + + + + Create + Create + Create + Create + + + + + + + + + + + + + diff --git a/dbeditorpp/dbeditorpp_10.vcxproj.filters b/dbeditorpp/dbeditorpp_10.vcxproj.filters new file mode 100644 index 0000000..a1a9d91 --- /dev/null +++ b/dbeditorpp/dbeditorpp_10.vcxproj.filters @@ -0,0 +1,148 @@ +п»ї + + + + {bc4414ca-bfab-4385-a016-6239272b67ab} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {8ba4deb9-307a-4c99-9c87-2243a0ef802e} + + + {b1b3b1b6-9fe0-435d-b8ab-1715cc5e7430} + + + {adcc58df-dacb-48fe-a36b-59f8221cb71e} + h;hpp;hxx;hm;inl + + + {fb09bf3d-d973-466d-b87b-0b785885753b} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\ModSetting Enuming + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + + + Source Files\ModSetting Enuming + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/dbeditorpp/dbeditorpp_8.vcproj b/dbeditorpp/dbeditorpp_8.vcproj new file mode 100644 index 0000000..a1f678c --- /dev/null +++ b/dbeditorpp/dbeditorpp_8.vcproj @@ -0,0 +1,604 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbeditorpp/dbeditorpp_9.vcproj b/dbeditorpp/dbeditorpp_9.vcproj new file mode 100644 index 0000000..7eb7740 --- /dev/null +++ b/dbeditorpp/dbeditorpp_9.vcproj @@ -0,0 +1,1005 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dbeditorpp/deletemodule.cpp b/dbeditorpp/deletemodule.cpp index 566a0cf..a0eddf7 100644 --- a/dbeditorpp/deletemodule.cpp +++ b/dbeditorpp/deletemodule.cpp @@ -13,7 +13,7 @@ int deleteModule(char* module, HANDLE hContact, int fromMenu) if (!fromMenu) { - mir_snprintf(msg, 1024, Translate("Are you sure you want to delete module \"%s\"?"), module); + mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete module \"%s\"?"), module); if (DBGetContactSettingByte(NULL,modname, "WarnOnDelete",1)) { if (MessageBox(0,msg, Translate("Confirm Module Deletion"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) @@ -79,7 +79,7 @@ void __cdecl PopulateModuleDropListThreadFunc(LPVOID di) working = 2; } -BOOL CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -142,7 +142,7 @@ BOOL CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa void deleteModuleGui() { if (!hwnd2Delete) - hwnd2Delete = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_COPY_MOD),hwnd2mainWindow,DeleteModuleDlgProc, (LPARAM)0); + hwnd2Delete = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, DeleteModuleDlgProc, (LPARAM)0); else SetForegroundWindow(hwnd2Delete); } \ No newline at end of file diff --git a/dbeditorpp/exportimport.cpp b/dbeditorpp/exportimport.cpp index b398b77..20442a1 100644 --- a/dbeditorpp/exportimport.cpp +++ b/dbeditorpp/exportimport.cpp @@ -1,11 +1,14 @@ #include "headers.h" +int Mode; +HWND hwnd2importWindow; + int Openfile(char *outputFile, const char *module) { OPENFILENAME ofn = {0}; char filename[MAX_PATH] = ""; - char *filter = "INI Files\0*.ini\0All Files\0*.*\0"; - int r; + char filter[MAX_PATH]; + mir_snprintf(filter, SIZEOF(filter), "%s%c*.ini%c%s%c*.*%c", Translate("INI Files"), 0, 0, Translate("All Files"), 0, 0); char *title = Translate("Export to file"); if (module) @@ -38,24 +41,56 @@ int Openfile(char *outputFile, const char *module) ofn.nMaxFile = MAX_PATH; ofn.lpstrDefExt = "ini"; - r = GetSaveFileName(&ofn); - if (!r) + if (!GetSaveFileName(&ofn)) return 0; lstrcpy(outputFile,filename); return 1; } +char* StrReplace (char* Search, char* Replace, char* Resource) +{ + int i = 0; + int SearchLen = (int)_tcslen(Search); + char* Work = mir_tstrdup(Replace); + int ReplaceLen = (int)_tcslen(Work); + + char* Pointer = _tcsstr(Resource, Search); + + while (Pointer != NULL) + { + int PointerLen = (int)_tcslen(Pointer); + int ResourceLen = (int)_tcslen(Resource); + + char* NewText = (char*)mir_calloc((ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); + + _tcsncpy(NewText, Resource, ResourceLen - PointerLen); + _tcscat(NewText, Work); + _tcscat(NewText, Pointer + SearchLen); + + Resource = (char*)mir_realloc(Resource, (ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); + + for (i = 0; i < (ResourceLen - SearchLen + ReplaceLen); i++) + Resource[i] = NewText[i]; + Resource[i] = 0; + mir_free(NewText); + + Pointer = _tcsstr(Resource + (ResourceLen - PointerLen + ReplaceLen), Search); + } + mir_free(Work); + + return Resource; +} + void exportModule(HANDLE hContact, char* module, FILE* file) { char tmp[32]; ModuleSettingLL settinglist; struct ModSetLinkLinkItem *setting; - if (IsModuleEmpty(hContact,module)) return; EnumSettings(hContact,module,&settinglist); // print the module header.. - fprintf(file, "[%s]\n", module); + fprintf(file, "\n[%s]", module); setting = settinglist.first; while(setting) { @@ -65,69 +100,60 @@ void exportModule(HANDLE hContact, char* module, FILE* file) switch (dbv.type) { case DBVT_BYTE: - fprintf(file, "%s=b%s\n", setting->name, itoa(dbv.bVal,tmp,10)); + fprintf(file, "\n%s=b%s", setting->name, itoa(dbv.bVal,tmp,10)); + DBFreeVariant(&dbv); break; case DBVT_WORD: - fprintf(file, "%s=w%s\n", setting->name, itoa(dbv.wVal,tmp,10)); + fprintf(file, "\n%s=w%s", setting->name, itoa(dbv.wVal,tmp,10)); + DBFreeVariant(&dbv); break; case DBVT_DWORD: - fprintf(file, "%s=d%s\n", setting->name, itoa(dbv.dVal,tmp,10)); + fprintf(file, "\n%s=d%s", setting->name, itoa(dbv.dVal,tmp,10)); + DBFreeVariant(&dbv); break; case DBVT_ASCIIZ: - fprintf(file, "%s=s%s\n", setting->name, dbv.pszVal); - break; case DBVT_UTF8: - fprintf(file, "%s=u%s\n", setting->name, dbv.pszVal); - /*{ - //convert \r to STX and \n to ETX - char *end = strchr(dbv.pszVal, '\r'); - while (end) // convert \r to STX - { - *end = 2; - end = strchr(end+1, '\r'); - } - end = strchr(dbv.pszVal, '\n'); - while (end) // convert \n to ETX - { - *end = 3; - end = strchr(end+1, '\n'); - } - - if (dbv.type == DBVT_UTF8) - fprintf(file, "%s=u%s\n", setting->name, dbv.pszVal); - else - fprintf(file, "%s=s%s\n", setting->name, dbv.pszVal); - }*/ - break; + if (strchr(dbv.pszVal, '\r')) + { + char *end = StrReplace("\\", "\\\\", dbv.pszVal); + end = StrReplace("\r", "\\r", end); + end = StrReplace("\n", "\\n", end); + fprintf(file, "\n%s=g%s", setting->name, end); + break; + } + if (dbv.type == DBVT_UTF8) + fprintf(file, "\n%s=u%s", setting->name, dbv.pszVal); + else + fprintf(file, "\n%s=s%s", setting->name, dbv.pszVal); + DBFreeVariant(&dbv); + break; case DBVT_BLOB: { int j; char *data = NULL; - if (!(data = (char*)malloc( 3*(dbv.cpbVal+1)) )) + if (!(data = (char*)mir_alloc( 3*(dbv.cpbVal+1)*sizeof(char)) )) break; data[0] = '\0'; for (j=0; jname , data); - safe_free(data); + fprintf(file,"\n%s=n%s",setting->name , data); + mir_free(data); } + DBFreeVariant(&dbv); break; } } - DBFreeVariant(&dbv); setting = (struct ModSetLinkLinkItem *)setting->next; } - fprintf(file, "\n"); FreeModuleSettingLL(&settinglist); - } -static char *NickFromHContact(HANDLE hContact) +char *NickFromHContact(HANDLE hContact) { static char nick[512] = ""; @@ -136,7 +162,7 @@ static char *NickFromHContact(HANDLE hContact) char szProto[256]; int loaded = 0; - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) loaded = IsProtocolLoaded(szProto); if (!szProto[0] || !loaded) @@ -145,13 +171,13 @@ static char *NickFromHContact(HANDLE hContact) if (szProto[0]) { - if (GetValue(hContact,szProto,"Nick",name,sizeof(name))) - mir_snprintf(nick, sizeof(nick),"%s (%s)", name, szProto); + if (GetValue(hContact,szProto,"Nick",name,SIZEOF(name))) + mir_snprintf(nick, SIZEOF(nick),"%s (%s)", name, szProto); else - mir_snprintf(nick, sizeof(nick),"(UNKNOWN) (%s)", szProto); + mir_snprintf(nick, SIZEOF(nick),"(UNKNOWN) (%s)", szProto); } else - mir_snprintf(nick, sizeof(nick),"(UNKNOWN)"); + mir_snprintf(nick, SIZEOF(nick),"(UNKNOWN)"); } else { @@ -161,11 +187,11 @@ static char *NickFromHContact(HANDLE hContact) uid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); if ((int)uid!=CALLSERVICE_NOTFOUND && uid) { - GetValue(hContact, szProto, uid, szUID, sizeof(szUID)); - mir_snprintf(nick, sizeof(nick), "%s *(%s)*<%s>*{%s}*", (char*)GetContactName(hContact,szProto,0), szProto, uid, szUID); + GetValue(hContact, szProto, uid, szUID, SIZEOF(szUID)); + mir_snprintf(nick, SIZEOF(nick), "%s *(%s)*<%s>*{%s}*", (char*)GetContactName(hContact,szProto,0), szProto, uid, szUID); } else - mir_snprintf(nick, sizeof(nick), "%s (%s)", (char*)GetContactName(hContact,szProto,0), szProto); + mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact,szProto,0), szProto); } } @@ -197,15 +223,20 @@ void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. if (module == NULL) { - fprintf(file, "SETTINGS:\n\n"); + fprintf(file, "SETTINGS:\n"); mod = modlist.first; - while(mod) // null contact first + while(mod) { + if (IsModuleEmpty(hContact, mod->name)) + { + mod = (struct ModSetLinkLinkItem *)mod->next; + continue; + } exportModule(hContact, mod->name, file); mod = (struct ModSetLinkLinkItem *)mod->next; + if (mod) + fprintf(file, "\n"); } - fprintf(file, "\n"); - } else { @@ -224,7 +255,7 @@ void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. char szProto[256]; int loaded = 0; - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) loaded = IsProtocolLoaded(szProto); if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) @@ -234,23 +265,28 @@ void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. } } - fprintf(file, "CONTACT: %s\n\n", NickFromHContact(hContact)); + fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); if (module == NULL) // export all modules { mod = modlist.first; while(mod) { + if (IsModuleEmpty(hContact, mod->name)) + { + mod = (struct ModSetLinkLinkItem *)mod->next; + continue; + } exportModule(hContact, mod->name, file); mod = (struct ModSetLinkLinkItem *)mod->next; + if (mod) + fprintf(file, "\n"); } } else // export module { exportModule(hContact, module, file); } - - fprintf(file, "\n"); hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); } } @@ -260,28 +296,33 @@ void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. if (!module) // exporting every module { if (hContact) - fprintf(file, "CONTACT: %s\n\n", NickFromHContact(hContact)); + fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); else - fprintf(file, "SETTINGS:\n\n"); + fprintf(file, "SETTINGS:\n"); mod = modlist.first; while(mod) { + if (IsModuleEmpty(hContact, mod->name)) + { + mod = (struct ModSetLinkLinkItem *)mod->next; + continue; + } exportModule(hContact, mod->name, file); mod = (struct ModSetLinkLinkItem *)mod->next; + if (mod) + fprintf(file, "\n"); } } else { if (hContact) - fprintf(file, "FROM CONTACT: %s\n\n", NickFromHContact(hContact)); + fprintf(file, "FROM CONTACT: %s\n", NickFromHContact(hContact)); else - fprintf(file, "SETTINGS:\n\n"); + fprintf(file, "SETTINGS:\n"); exportModule(hContact, module, file); } - - fprintf(file, "\n"); } fclose(file); @@ -289,7 +330,6 @@ void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. } FreeModuleSettingLL(&modlist); - } @@ -306,7 +346,7 @@ HANDLE CheckNewContact(char *myProto, char *uid, char *myName) { if (!mir_strcmp(szProto, myProto)) { - if (GetValue(hContact, szProto, uid, szName, sizeof(szName)) && + if (GetValue(hContact, szProto, uid, szName, SIZEOF(szName)) && !mir_strcmp(szName, myName)) { //char msg[1024]; @@ -325,6 +365,42 @@ HANDLE CheckNewContact(char *myProto, char *uid, char *myName) } +TCHAR* __stdcall rtrim(TCHAR *string) +{ + TCHAR* p = string + _tcslen(string) - 1; + + while (p >= string) { + if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') + break; + + *p-- = 0; + } + return string; +} + +HANDLE Clist_GroupExists(WCHAR *tszGroup) +{ + unsigned int i = 0; + WCHAR* _t = 0; + char str[10]; + INT_PTR result = 0; + DBVARIANT dbv = {0}; + int match; + + do { + _itoa(i, str, 10); + result = DBGetContactSettingTString(0, "CListGroups", str, &dbv); + if(!result) { + match = (!lstrcmpW(tszGroup, (LPCWSTR)&dbv.ptszVal[1]) && (lstrlenW(tszGroup) == lstrlenW((LPCWSTR)&dbv.ptszVal[1]))); + DBFreeVariant(&dbv); + if(match) + return((HANDLE)(i + 1)); + } + i++; + } + while(result == 0); + return(0); +} void importSettings(HANDLE hContact, char *importstring ) { @@ -337,33 +413,24 @@ void importSettings(HANDLE hContact, char *importstring ) while (importstring != NULL) { i=0; - if (importstring[i] == '\n') + rtrim(importstring); + if (importstring[i] == '\0') { importstring = strtok(NULL, "\n"); continue; } else if (!strncmp(&importstring[i],"SETTINGS:",strlen("SETTINGS:"))) { - hContact = 0; -/* - end = strstr(&importstring[i], "\n"); - if (end) - { - i = end - &importstring[i]; - } -*/ + importstring = strtok(NULL, "\n"); + continue; } else if (!strncmp(&importstring[i],"CONTACT:", strlen("CONTACT:"))) { - int len, add = 1; - hContact = INVALID_HANDLE_VALUE; - //end = strstr(&importstring[i], "\n"); - - i = i + strlen("CONTACT:"); - len = strlen(&importstring[i]); + i = i + (int)strlen("CONTACT:"); + len = (int)strlen(&importstring[i]); if (len > 10) { @@ -373,21 +440,21 @@ void importSettings(HANDLE hContact, char *importstring ) p1 = strrchr(&importstring[i], '>*{'); p2 = strrchr(&importstring[i], '}*'); - if (p1 && p2 && p1+3 < p2 && p2-p1 < sizeof(szUID)) + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szUID)) { strncpy(szUID, p1+1, p2-p1-2); p1 = strrchr(&importstring[i], ')*<'); p2 = strrchr(&importstring[i], '>*{'); - if (p1 && p2 && p1+3 < p2 && p2-p1 < sizeof(uid)) + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(uid)) { strncpy(uid, p1+1, p2-p1-3); p1 = strrchr(&importstring[i], ' *('); p2 = strrchr(&importstring[i], ')*<'); - if (p1 && p2 && p1+3 < p2 && p2-p1 < sizeof(szProto)) + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szProto)) { char *protouid; strncpy(szProto, p1+1, p2-p1-3); @@ -408,16 +475,9 @@ void importSettings(HANDLE hContact, char *importstring ) if (hContact == INVALID_HANDLE_VALUE) { HANDLE temp = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); - if (temp) hContact = temp; } -/* - if (end) - { - i = end - &importstring[i]; - } -*/ } else if (importstring[i] == '[' && !strchr(&importstring[i+1],'=') )// get the module { @@ -427,8 +487,7 @@ void importSettings(HANDLE hContact, char *importstring ) } } else if (importstring[i] == '-' && importstring[i+1] == '[' && - !strchr(&importstring[i+2],'=') && - hContact != INVALID_HANDLE_VALUE)// get the module + !strchr(&importstring[i+2],'='))// get the module { if (end = strpbrk(&importstring[i+2], "]")) { if ((end+1) != '\0') *end = '\0'; @@ -436,8 +495,7 @@ void importSettings(HANDLE hContact, char *importstring ) deleteModule(module, hContact, 1); } } - else if (strstr(&importstring[i], "=") && module[0] && - hContact != INVALID_HANDLE_VALUE) // get the setting + else if (strstr(&importstring[i], "=") && module[0]) // get the setting { if (end = strpbrk(&importstring[i+1], "=")) { if ((end+1) != '\0') *end = '\0'; @@ -445,6 +503,22 @@ void importSettings(HANDLE hContact, char *importstring ) // get the type type = *(end+1); + if (lstrcmp(module, "CList") == 0 && lstrcmp(setting, "Group") == 0) + { + WCHAR* GroupName = mir_a2u(end+2); + if (!GroupName) + continue; + HANDLE GroupHandle = Clist_GroupExists(GroupName); + if(GroupHandle == 0) { + GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)GroupName); + + if(GroupHandle) { + CallService(MS_CLUI_GROUPADDED, (WPARAM)GroupHandle, 0); + CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)GroupHandle, 1); + } + } + mir_free(GroupName); + } switch (type) { case 'b': @@ -463,35 +537,25 @@ void importSettings(HANDLE hContact, char *importstring ) DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); break; case 's': - case 'u': + case 'S': DBWriteContactSettingString(hContact,module, setting, (end+2)); break; - case 'S': + case 'g': + case 'G': + { char *pstr; + for(pstr=end+2;*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; + } + MoveMemory(pstr+1,pstr+2,lstrlenA(pstr+2)+1); + } } } + case 'u': case 'U': DBWriteContactSettingStringUtf(hContact,module, setting, (end+2)); - /*{ - char *string; - string = (end+2); - end = strchr(string, '\r'); - if (end) // remove \r - *end = 0; - end = strchr(string, 2); - while (end) // convert STX back to \r - { - *end = '\r'; - end = strchr(++end, 2); - } - end = strchr(string, 3); - while (end) // convert ETX back to \n - { - *end = '\n'; - end = strchr(++end, 3); - } - if (type == 'u' || type == 'U') - DBWriteContactSettingStringUtf(hContact,module, setting, string); - else - DBWriteContactSettingString(hContact,module, setting, string); - }*/ break; case 'l': case 'L': @@ -499,26 +563,22 @@ void importSettings(HANDLE hContact, char *importstring ) break; case 'n': case 'N': - WriteBlobFromString(hContact,module,setting,(end+2),strlen((end+2))); + WriteBlobFromString(hContact, module, setting, (end+2), (int)strlen((end+2))); break; } } } importstring = strtok(NULL, "\n"); } - SetCursor(LoadCursor(NULL,IDC_ARROW)); } - -#define crlf_string "\x02\x03\0" - -BOOL CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_INITDIALOG) { hwnd2importWindow = hwnd; - SetWindowLong(hwnd,GWL_USERDATA,lParam); + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); TranslateDialogDefault(hwnd); SendDlgItemMessage(hwnd, IDC_TEXT, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)*0x7FFFFFFF, 0); } @@ -530,12 +590,12 @@ BOOL CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_CRLF: { int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); - char *string = _alloca(length+4); + char *string = (char*)_alloca(length+3); int Pos = 2; if (length) { - int Range = SendDlgItemMessageA(hwnd,IDC_TEXT,EM_GETSEL,0,0); + int Range = SendDlgItemMessage(hwnd,IDC_TEXT,EM_GETSEL,0,0); int Min = LOWORD(Range); int Max = HIWORD(Range); @@ -543,35 +603,35 @@ BOOL CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) GetDlgItemText(hwnd, IDC_TEXT, string, length+1); if (Min == -1) - memcpy(string, crlf_string, 3); + memcpy(string, crlf_string, SIZEOF(crlf_string)); else if (Max == -1 || Max >= length) - memcpy(&string[Min], crlf_string, 3); + memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); else if (Max-Min > 2) { - memcpy(&string[Min], crlf_string, 2); + memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); memmove(&string[Min+2], &string[Max], length - Max + 1); } else { memmove(&string[Min+2], &string[Max], length - Max + 1); - memcpy(&string[Min], crlf_string, 2); + memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); } if (Min) Pos += Min; } else - memcpy(string, crlf_string, 3); + memcpy(string, crlf_string, SIZEOF(crlf_string)); SetDlgItemText(hwnd, IDC_TEXT, string); - SendDlgItemMessageA(hwnd,IDC_TEXT,EM_SETSEL,Pos,Pos); + SendDlgItemMessage(hwnd,IDC_TEXT,EM_SETSEL,Pos,Pos); SetFocus(GetDlgItem(hwnd, IDC_TEXT)); } break; case IDOK: { - HANDLE hContact = (HANDLE)GetWindowLong(hwnd,GWL_USERDATA); + HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA); int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); char *string; if (length) @@ -598,52 +658,59 @@ void ImportSettingsMenuItem(HANDLE hContact) if (hwnd2importWindow) DestroyWindow(hwnd2importWindow); - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_IMPORT), 0,ImportDlgProc, (LPARAM)hContact); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_IMPORT), 0, ImportDlgProc, (LPARAM)hContact); } int Openfile2Import(char *outputFiles) { OPENFILENAME ofn = {0}; - char *filter = "INI Files\0*.ini\0All Files\0*.*\0"; + char filter[MAX_PATH]; + mir_snprintf(filter, SIZEOF(filter), "%s%c*.ini%c%s%c*.*%c", Translate("INI Files"), 0, 0, Translate("All Files"), 0, 0); char *title = Translate("Import from files"); - ofn.lStructSize = sizeof(ofn); - ofn.lpstrFile = outputFiles; + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.lpstrFilter = filter; + ofn.hwndOwner = 0; + ofn.lpstrFile = outputFiles; + ofn.nMaxFile = MAX_PATH; + ofn.nMaxFileTitle = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; ofn.lpstrTitle = title; - ofn.nMaxFile = MAX_PATH*10; - if (!GetOpenFileName(&ofn)) return 0; - return ofn.nFileOffset; + return 1; +} + +BOOL Exists(LPCTSTR strName) +{ + return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES; } -void ImportSettingsFromFileMenuItem(HANDLE hContact) +void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath) { char szFileNames[MAX_PATH*10] = {0}; char szPath[MAX_PATH] = ""; char szFile[MAX_PATH]; - DWORD offset = Openfile2Import(szFileNames); int index = 0; HANDLE hFile, hMap; PBYTE pFile = NULL; - - if (offset) + if (lstrcmp(FilePath, "") == 0) + Openfile2Import(szFileNames); + else + { + if(Exists(FilePath)) + lstrcpy(szFileNames, FilePath); + else + lstrcpy(szFileNames, ""); + } + if (!lstrcmp(szFileNames, "") == 0) { - if (strlen(szFileNames) < offset) - { - index += offset; - strncpy(szPath, szFileNames, offset); - strcat(szPath, "\\"); - } - while(szFileNames[index]) { strcpy(szFile, szPath); strcat(szFile, &szFileNames[index]); - index += strlen(&szFileNames[index])+1; + index += (int)strlen(&szFileNames[index])+1; hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) @@ -653,10 +720,10 @@ void ImportSettingsFromFileMenuItem(HANDLE hContact) hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); if (hMap) { - pFile = MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0 ,0); + pFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0 ,0); if (pFile) { - importSettings(hContact, pFile); + importSettings(hContact, (char*)pFile); UnmapViewOfFile(pFile); } CloseHandle(hMap); @@ -669,8 +736,7 @@ void ImportSettingsFromFileMenuItem(HANDLE hContact) break; } - - refreshTree(1); + if (lstrcmp(FilePath, "") == 0) + refreshTree(1); } - } diff --git a/dbeditorpp/findwindow.cpp b/dbeditorpp/findwindow.cpp index fc478ee..b9957cd 100644 --- a/dbeditorpp/findwindow.cpp +++ b/dbeditorpp/findwindow.cpp @@ -53,12 +53,12 @@ void freeItems(HWND hwnd) ii = (ItemInfo*)SendMessage(hwnd,LB_GETITEMDATA,i,0); if ((LRESULT)ii != LB_ERR) - safe_free(ii); + mir_free(ii); } } -BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -71,22 +71,22 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara CheckDlgButton(hwnd,IDC_SETTINGVALUE,1); CheckDlgButton(hwnd,IDC_FOUND,1); SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); - SetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA, 0); - SetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA, 0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA, 0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA, 0); } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: - SetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA, 1); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA, 1); case IDC_SEARCH: { - if (GetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA)) // stop the search + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA)) // stop the search { - SetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA,0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,0); } else { @@ -95,10 +95,10 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara char text[256]; char replace[256]=""; - if (!GetDlgItemText(hwnd,IDC_TEXT,text,sizeof(text))) break; + if (!GetDlgItemText(hwnd,IDC_TEXT,text,SIZEOF(text))) break; - if (GetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA) && - !GetDlgItemText(hwnd,IDC_REPLACE,replace,sizeof(replace)) && + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA) && + !GetDlgItemText(hwnd,IDC_REPLACE,replace,SIZEOF(replace)) && !IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) break; @@ -107,7 +107,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara !IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE) ) break; - fi = (FindInfo*)calloc(sizeof(FindInfo),1); + fi = (FindInfo*)mir_calloc(sizeof(FindInfo)); if (!fi) break; fi->hwnd = GetDlgItem(hwnd,IDC_LIST); @@ -117,7 +117,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME)?FW_SETNAME:0)| (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE)?FW_SETVAL:0); - if (GetWindowLong(GetDlgItem(hwnd,IDC_REPLACE),GWL_USERDATA)) + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA)) { if (IsDlgButtonChecked(hwnd,IDC_FOUND)) fi->mode = RW_FOUND; @@ -134,7 +134,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) fi->mode |= RW_FULL; - fi->replace = strdup(replace); + fi->replace = mir_tstrdup(replace); SetWindowText(GetDlgItem(hwnd,IDOK),Translate("Stop")); EnableWindow(GetDlgItem(hwnd,IDC_SEARCH),0); @@ -148,10 +148,10 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara EnableWindow(GetDlgItem(hwnd,IDOK),0); } - fi->text = strdup(text); + fi->text = mir_tstrdup(text); SendDlgItemMessage(hwnd,IDC_LIST,LB_RESETCONTENT,0,0); - SetWindowLong(GetDlgItem(hwnd,IDC_SEARCH),GWL_USERDATA,1); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,1); EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); forkthread(FindSettings,0,fi); @@ -201,7 +201,7 @@ BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting,const char* value,int type) { - ItemInfo *ii = (ItemInfo*)calloc(sizeof(ItemInfo),1); + ItemInfo *ii = (ItemInfo*)mir_calloc(sizeof(ItemInfo)); int index; char text[256] = ""; int result = 0; @@ -224,20 +224,20 @@ void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting { case FW_MODULE: ii->type = FW_MODULE; - mir_snprintf(text,256,Translate("%s Module \"%s\" in contact \"%s\""),mode,module,name); + mir_snprintf(text, SIZEOF(text), Translate("%s Module \"%s\" in contact \"%s\""), mode, module, name); break; case FW_SETTINGNAME: mir_strncpy(ii->setting,setting,256); ii->type = FW_SETTINGNAME; - if (GetValue(hContact,module,setting, szValue, sizeof(szValue))) - mir_snprintf(text,256,Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""),mode,setting,module,name,szValue); + if (GetValue(hContact,module,setting, szValue, SIZEOF(szValue))) + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""), mode, setting, module, name, szValue); else - mir_snprintf(text,256,Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""),mode,setting,module,name); + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, setting, module, name); break; case FW_SETTINGVALUE: mir_strncpy(ii->setting,setting,256); ii->type = FW_SETTINGVALUE; - mir_snprintf(text,256,Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""),mode,value,setting,module,name); + mir_snprintf(text, SIZEOF(text), Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, value, setting, module, name); break; } @@ -245,7 +245,7 @@ void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting if (type & FW_DELETED) { SendMessage(hwnd,LB_SETITEMDATA,index,0); - safe_free(ii); + mir_free(ii); } else { @@ -260,19 +260,19 @@ char *multiReplace(const char* value, const char *find, const char *replace, int { char *head, *temp, *string; - int len = strlen(find); - int replen = strlen(replace); + int len = (int)strlen(find); + int replen = (int)strlen(replace); - if (head = (cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... + if (head = (char*)(cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... { string = (char*)value; - temp = (char*)malloc(1); + temp = (char*)mir_alloc(1*sizeof(char)); temp[0] = '\0'; while (head) { - temp = (char*)realloc(temp, strlen(temp) + strlen(string) + replen + 1); - if (!temp) _strdup(value); + temp = (char*)mir_realloc(temp, strlen(temp) + strlen(string) + replen + 1); + if (!temp) mir_tstrdup(value); strncat(temp, string, (head - string)); string = head + len; @@ -285,7 +285,7 @@ char *multiReplace(const char* value, const char *find, const char *replace, int return temp; } - return _strdup(value); + return mir_tstrdup(value); } @@ -354,7 +354,7 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set { ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); DBDeleteContactSetting(hContact,module,setting); - safe_free(myreplace); + mir_free(myreplace); return 1; } @@ -364,7 +364,7 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set ItemFound(hwnd,hContact,module,setting,myreplace?myreplace:(char*)replace,FW_SETTINGVALUE|FW_REPLACED); } - safe_free(myreplace); + mir_free(myreplace); return count; } @@ -391,7 +391,7 @@ int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *s { ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); DBDeleteContactSetting(hContact,module,setting); - safe_free(myreplace); + mir_free(myreplace); return 1; } @@ -417,7 +417,7 @@ int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *s else DBFreeVariant(&dbv2); - safe_free(myreplace); + mir_free(myreplace); return count; } @@ -445,7 +445,7 @@ int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *fi ItemFound(hwnd,hContact,module,NULL,NULL,FW_MODULE|FW_DELETED); deleteModule((char*)module, hContact, 1); replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, NULL); - safe_free(myreplace); + mir_free(myreplace); return 1; } @@ -498,7 +498,7 @@ int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *fi count++; } - safe_free(myreplace); + mir_free(myreplace); return count; } @@ -547,7 +547,7 @@ void __cdecl FindSettings(LPVOID di) freeItems(hwnd); if (!text) return; - if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); safe_free(di); return;} + if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); mir_free(di); return;} SendMessage(GetDlgItem(GetParent(hwnd),IDC_SBAR),SB_SETTEXT,0,(LPARAM)Translate("Searching...")); @@ -555,7 +555,7 @@ void __cdecl FindSettings(LPVOID di) isNumber = sscanf(text,"%d",&settingValue); - while (GetWindowLong(GetDlgItem(prnthwnd,IDC_SEARCH),GWL_USERDATA)) + while (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA)) { if (!hContact) { @@ -580,8 +580,8 @@ void __cdecl FindSettings(LPVOID di) if (!EnumSettings(hContact,module->name,&SettingList)) { msg(Translate("Error Loading Setting List"),modFullname); - safe_free(text); - safe_free(di); + mir_free(text); + mir_free(di); FreeModuleSettingLL(&ModuleList); return; } @@ -692,20 +692,20 @@ void __cdecl FindSettings(LPVOID di) if (mode) { if (!replace[0]) - _snprintf(szTmp,sizeof(szTmp),Translate("Finished. %d items were found, %d items were deleted."),foundCount, replaceCount); + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were deleted."), foundCount, replaceCount); else - _snprintf(szTmp,sizeof(szTmp),Translate("Finished. %d items were found, %d items were replaced."),foundCount, replaceCount); + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were replaced."), foundCount, replaceCount); } else - _snprintf(szTmp,sizeof(szTmp),Translate("Finished. %d items were found."),foundCount); + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); SendMessage(GetDlgItem(prnthwnd,IDC_SBAR),SB_SETTEXT,0,(LPARAM)szTmp); - SetWindowLong(GetDlgItem(prnthwnd,IDC_SEARCH),GWL_USERDATA,0); + SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA,0); - if (GetWindowLong(GetDlgItem(prnthwnd,IDC_REPLACE),GWL_USERDATA)) + if (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA)) { - SetWindowLong(GetDlgItem(prnthwnd,IDC_REPLACE),GWL_USERDATA, 0); + SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA, 0); EnableWindow(GetDlgItem(prnthwnd,IDC_SEARCH),1); SetWindowText(GetDlgItem(prnthwnd,IDOK),Translate("&Replace")); } @@ -715,9 +715,9 @@ void __cdecl FindSettings(LPVOID di) EnableWindow(GetDlgItem(prnthwnd,IDOK),1); } - safe_free(replace); - safe_free(text); - safe_free(di); + mir_free(replace); + mir_free(text); + mir_free(di); FreeModuleSettingLL(&ModuleList); EnableWindow(GetDlgItem(prnthwnd,IDCANCEL),1); diff --git a/dbeditorpp/headers.h b/dbeditorpp/headers.h index e3b19b0..9eda591 100644 --- a/dbeditorpp/headers.h +++ b/dbeditorpp/headers.h @@ -1,14 +1,11 @@ #ifndef _COMMONHEADERS_H #define _COMMONHEADERS_H -#pragma warning( disable : 4786 ) // limitation in MSVC's debugger. //===================================================== // Includes //===================================================== #define _WIN32_WINNT 0x0501 -#define MIRANDA_VER 0x0600 - -#pragma comment(lib,"shlwapi") +#define MIRANDA_VER 0x0900 #include #include @@ -20,6 +17,8 @@ #include #include #include +#include + #include #include #include @@ -42,32 +41,27 @@ #include "m_updater.h" #include "m_toptoolbar.h" +#include "resource.h" +#include "Version.h" +#include "modsettingenum.h" #define DEF_ICON 7 - -#define safe_free(ptr) if (ptr) { free(ptr); ptr = 0;} +#define crlf_string "\r\n\0" /////// icons support -BYTE UsingIconManager; +extern BYTE UsingIconManager; void addIcons(char* szModuleFileName); HICON LoadSkinnedDBEIcon(int icon); int AddIconToList(HIMAGELIST hil, HICON hIcon); void AddProtoIconsToList(HIMAGELIST hil, int newshift); int GetProtoIcon(char *szProto); -HANDLE hRestore; -HANDLE hUserMenu; +extern HANDLE hRestore; +extern HANDLE hUserMenu; ///////////////////// - -#include "resource.h" -#include "modsettingenum.h" - - #ifndef NDEBUG -//#define _CRTDBG_MAP_ALLOC -//#include -#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) + #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif //======================================================= @@ -82,35 +76,23 @@ HANDLE hUserMenu; #define WM_FINDITEM (WM_USER+1) // onyl for the main window, wparam is ItemIfno* lparam is 0 -#define mir_strlen(ptr) ((ptr==NULL)?0:strlen(ptr)) - +#define mir_strlen(ptr) ((ptr==NULL)?0:(int)strlen(ptr)) #define mir_strncpy(dst, src, len) strncpy(dst, src, len)[len-1]=0; +#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2)?strcmp(ptr1, ptr2):1) // (ptr1||ptr2) #define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \ { LV_ITEMW _ms_lvi;\ _ms_lvi.iSubItem = iSubItem_;\ _ms_lvi.pszText = pszText_;\ - _SendMessageW((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\ + SendMessageW((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\ } #define ListView_InsertItemW(hwnd, pitem) \ - _SendMessageW((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem)) + SendMessageW((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem)) #define TreeView_InsertItemW(hwnd, lpis) \ - (HTREEITEM)_SendMessageW((hwnd), TVM_INSERTITEMW, 0, (LPARAM)(LPTV_INSERTSTRUCTW)(lpis)) - -#define _CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\ -nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ -_CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\ -nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) - - -HWND (WINAPI *_CreateWindowExW)(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); -HWND (WINAPI *_CreateDialogParamW)(HINSTANCE,LPCWSTR,HWND,DLGPROC,LPARAM); -LRESULT (WINAPI *_CallWindowProcW)(WNDPROC,HWND,UINT,WPARAM,LPARAM); -LONG (WINAPI *_SetWindowLongW)(HWND,int,LONG); -LRESULT (WINAPI *_SendMessageW)(HWND,UINT,WPARAM,LPARAM); + (HTREEITEM)SendMessageW((hwnd), TVM_INSERTITEMW, 0, (LPARAM)(LPTV_INSERTSTRUCTW)(lpis)) /*********************** ModuleTreeInfoStruct @@ -125,7 +107,6 @@ LRESULT (WINAPI *_SendMessageW)(HWND,UINT,WPARAM,LPARAM); #define STUB 4 #define EMPTY 8 - typedef struct { int type; // from above types HANDLE hContact; @@ -141,6 +122,7 @@ typedef struct { #define WATCH_MODULE 1 #define WATCH_SETTING 0 + struct DBsetting { DBVARIANT dbv; HANDLE hContact; @@ -171,24 +153,23 @@ struct WatchListArrayStruct{ struct DBsetting *item; // gotta malloc this int count; int size; -} WatchListArray; +}; +extern WatchListArrayStruct WatchListArray; //======================================================= // Variables //======================================================= -PLUGINLINK *pluginLink; -HINSTANCE hInst; -HWND hwnd2mainWindow, hwnd2watchedVarsWindow, hwnd2importWindow; -HIMAGELIST himl; -HIMAGELIST himl2; -int Mode; -int Hex; -int Order; -BOOL UDB, UOS; - -BOOL usePopUps; +extern HINSTANCE hInst; +extern HWND hwnd2mainWindow, hwnd2watchedVarsWindow, hwnd2importWindow; +extern HIMAGELIST himl; +extern HIMAGELIST himl2; +extern int Mode; +extern int Hex; +extern int Order; +extern BOOL UDB, UOS; + +extern BOOL usePopUps; #define NAMEORDERCOUNT 8 -BYTE nameOrder[NAMEORDERCOUNT]; #define MODE_UNLOADED 1 #define MODE_LOADED 2 @@ -200,7 +181,6 @@ BYTE nameOrder[NAMEORDERCOUNT]; //main.c int DBGetContactSettingStringStatic(HANDLE hContact, char* szModule, char* szSetting, char* value, int maxLength); -int DBWriteContactSettingBlob(HANDLE hContact,const char *szModule,const char *szSetting, const BYTE *pbVal, WORD cbVal); int WriteBlobFromString(HANDLE hContact,const char *szModule,const char *szSetting, const char *Value, int len); int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* Value, int length); @@ -208,18 +188,17 @@ int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHA char* u2a( wchar_t* src ); wchar_t *a2u( char* src , wchar_t *buffer, int len ); int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...); -int GetDatabaseString(HANDLE hContact, const char *szModule, const char* szSetting, WCHAR *Value, int length, BOOL unicode); WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode); BOOL IsProtocolLoaded(char* pszProtocolName); // main_window.c -BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); // modules.c int deleteModule(char* module, HANDLE hContact, int fromMenu); void deleteModuleGui(); void renameModule(char* oldName, char* newName, HANDLE hContact); -BOOL CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); int CloneContact(HANDLE hContact); // moduletree.c @@ -241,23 +220,22 @@ void PopulateSettings(HWND hwnd2Settings, HANDLE hContact, char* module); void SelectSetting(char* setting); // addeditsettingsdlg.c -BOOL CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void editSetting(HANDLE hContact, char* module, char* setting); BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType); // 0 = byte, 1 = word, 2 = dword, 3 = string // exportimport.c void exportDB(HANDLE hContact, char* module); // hContact == -1 export entire db. module == NULL export entire contact void ImportSettingsMenuItem(HANDLE hContact); -void ImportSettingsFromFileMenuItem(HANDLE hContact); +void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath); // find window.c -BOOL CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -BOOL CALLBACK FindReplaceDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); // knownmodules.c -BYTE UseKnownModList; -int RegisterModule(WPARAM wParam, LPARAM lParam); -int RegisterSingleModule(WPARAM wParam, LPARAM lParam); +extern BYTE UseKnownModList; +INT_PTR RegisterModule(WPARAM wParam, LPARAM lParam); +INT_PTR RegisterSingleModule(WPARAM wParam, LPARAM lParam); void FreeKnownModuleList(); int IsModuleKnown(char* moduleName); void doOldKnownModulesList(); @@ -274,15 +252,7 @@ int addSettingToWatchList(HANDLE hContact, char* module, char* setting); void freeWatchListItem(int item); void PopulateWatchedWindow(HWND hwnd); void freeAllWatches(); -BOOL CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void popupWatchedVar(HANDLE hContact,const char* module,const char* setting); -#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2)?strcmp(ptr1, ptr2):1) // (ptr1||ptr2) - -#ifndef NDEBUG -#include -#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif -#pragma comment(lib,"comctl32.lib") - #endif //_COMMONHEADERS_H \ No newline at end of file diff --git a/dbeditorpp/icons.cpp b/dbeditorpp/icons.cpp index fb8248a..d3e977d 100644 --- a/dbeditorpp/icons.cpp +++ b/dbeditorpp/icons.cpp @@ -1,5 +1,7 @@ #include "headers.h" +HIMAGELIST himl; + void addIcons(char* szModuleFileName) { SKINICONDESC sid={0}; @@ -10,56 +12,56 @@ void addIcons(char* szModuleFileName) // closed known module sid.pszDescription = Translate("Closed Known Module"); - _snprintf(name,32,"DBE++_%d",ICO_KNOWN); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWN); sid.pszName = name; sid.iDefaultIndex = -ICO_KNOWN; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // open known module sid.pszDescription = Translate("Open Known Module"); - _snprintf(name,32,"DBE++_%d",ICO_KNOWNOPEN); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWNOPEN); sid.pszName = name;; sid.iDefaultIndex = -ICO_KNOWNOPEN; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // closed unknown module sid.pszDescription = Translate("Closed Unknown Module"); - _snprintf(name,32,"DBE++_%d",ICO_UNKNOWN); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWN); sid.pszName = name; sid.iDefaultIndex = -ICO_UNKNOWN; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // open unknown module sid.pszDescription = Translate("Open Unknown Module"); - _snprintf(name,32,"DBE++_%d",ICO_UNKNOWNOPEN); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWNOPEN); sid.pszName = name; sid.iDefaultIndex = -ICO_UNKNOWNOPEN; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // settings contact sid.pszDescription = Translate("Settings"); - _snprintf(name,32,"DBE++_%d",ICO_SETTINGS); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_SETTINGS); sid.pszName = name; sid.iDefaultIndex = -ICO_SETTINGS; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // contact group sid.pszDescription = Translate("Contacts Group"); - _snprintf(name,32,"DBE++_%d",ICO_CONTACTS); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_CONTACTS); sid.pszName = name; sid.iDefaultIndex = -ICO_CONTACTS; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // unknwon contact sid.pszDescription = Translate("Unknown Contact"); - _snprintf(name,32,"DBE++_%d",ICO_OFFLINE); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_OFFLINE); sid.pszName = name; sid.iDefaultIndex = -ICO_OFFLINE; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); // known contact sid.pszDescription = Translate("Known Contact"); - _snprintf(name,32,"DBE++_%d",ICO_ONLINE); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_ONLINE); sid.pszName = name; sid.iDefaultIndex = -ICO_ONLINE; CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid); @@ -71,7 +73,7 @@ HICON LoadSkinnedDBEIcon(int icon) if (UsingIconManager) { char name[32]; - _snprintf(name,32,"DBE++_%d",icon); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", icon); hIcon = (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)name); } diff --git a/dbeditorpp/knownmodules.cpp b/dbeditorpp/knownmodules.cpp index ecf95b3..13c4379 100644 --- a/dbeditorpp/knownmodules.cpp +++ b/dbeditorpp/knownmodules.cpp @@ -1,24 +1,26 @@ #include "headers.h" +BYTE UseKnownModList; + #define MAXMODS 1024 char *KnownModules[MAXMODS]; int KnownModulesCount = 0; -int RegisterModule(WPARAM wParam, LPARAM lParam) +INT_PTR RegisterModule(WPARAM wParam, LPARAM lParam) { char **mods = (char**)wParam; int count = lParam; int i; for (i=0;iname,&dbv) && dbv.type == DBVT_ASCIIZ) { - temp = (char*)malloc(strlen(dbv.pszVal)+5); + temp = (char*)mir_alloc((strlen(dbv.pszVal)+5)*sizeof(char)); if (!temp) break; strcpy(temp,dbv.pszVal); strcat(temp,",\0"); @@ -68,15 +70,15 @@ void doOldKnownModulesList() while (var) { if (KnownModulesCountnext; } FreeModuleSettingLL(&msll); - UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",1); + UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0); } diff --git a/dbeditorpp/main.cpp b/dbeditorpp/main.cpp index e5a0060..b94cceb 100644 --- a/dbeditorpp/main.cpp +++ b/dbeditorpp/main.cpp @@ -1,74 +1,60 @@ #include "headers.h" -#pragma comment(exestr, "\n\n Bio was here 8-) \n") - // {A8A417EF-07AA-4f37-869F-7BFD74886534} #define MIID_DBEDITOR {0xa8a417ef, 0x7aa, 0x4f37, { 0x86, 0x9f, 0x7b, 0xfd, 0x74, 0x88, 0x65, 0x34}} +PLUGINLINK *pluginLink; +HINSTANCE hInst = NULL; - +struct MM_INTERFACE mmi; +struct UTF8_INTERFACE utfi; HANDLE hTTBButt = NULL; -DWORD mirandaVer; BOOL bServiceMode = FALSE; +BOOL usePopUps; +HWND hwnd2watchedVarsWindow; +int UDB; +BYTE nameOrder[NAMEORDERCOUNT]; +HANDLE hUserMenu; +HANDLE hRestore; +WatchListArrayStruct WatchListArray; +BYTE UsingIconManager; //======================== // MirandaPluginInfo //======================== -PLUGININFO pluginInfo={ - sizeof(PLUGININFO), - modFullname, - PLUGIN_MAKE_VERSION(3,2,0,0), - "Advanced Database Editor. More advanced & bugfixed by Bio.\r\n[ "__DATE__" "__TIME__" ]", - "Bio, Jonathan Gordon", - "bio@msx.ru, jdgordy@gmail.com", - "© 2003-2006 Bio, Jonathan Gordon", - "http://addons.miranda-im.org/details.php?action=viewfile&id=2957", - 0, //not transient - 0 //doesn't replace anything built-in -}; - -__declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) -{ - if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 7, 0, 0)) // 0.4 better. 0.3 have too many bugs - { - return NULL; - } - return &pluginInfo; -} - PLUGININFOEX pluginInfoEx={ - sizeof(PLUGININFOEX), - modFullname, - PLUGIN_MAKE_VERSION(3,2,0,0), - "Advanced Database Editor. More advanced & bugfixed by Bio.\r\n[ "__DATE__" "__TIME__" ]", - "Bio, Jonathan Gordon", - "bio@msx.ru, jdgordy@gmail.com", - "© 2003-2006 Bio, Jonathan Gordon", - "http://addons.miranda-im.org/details.php?action=viewfile&id=2957", + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, UNICODE_AWARE, 0, MIID_DBEDITOR }; - -__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { - mirandaVer = mirandaVersion; + if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 7, 0, 0)) // 0.4 better. 0.3 have too many bugs + { + return NULL; + } return &pluginInfoEx; } // we implement service mode interface static const MUUID interfaces[] = {MIID_SERVICEMODE, MIID_LAST}; -__declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) { return interfaces; } - //======================== // WINAPI DllMain //======================== - BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { hInst=hinstDLL; @@ -78,7 +64,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) //=================== // MainInit //=================== - int MainInit(WPARAM wParam,LPARAM lParam) { return 0; @@ -97,11 +82,11 @@ int DBSettingChanged(WPARAM wParam,LPARAM lParam) if (hwnd2mainWindow) { HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow, IDC_SETTINGS); - if (info = (SettingListInfo*)GetWindowLong(hwnd2Settings,GWL_USERDATA)) + if (info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA)) { if ((hContact == info->hContact) && !mir_strcmp(info->module, cws->szModule)) { - setting = strdup(cws->szSetting); + setting = mir_tstrdup(cws->szSetting); if (cws->value.type == DBVT_DELETED) { LVFINDINFO lvfi; @@ -112,11 +97,11 @@ int DBSettingChanged(WPARAM wParam,LPARAM lParam) index = ListView_FindItem(hwnd2Settings,-1,&lvfi); if (index > -1) ListView_DeleteItem(hwnd2Settings, index); - safe_free(setting); + mir_free(setting); return 0; } settingChanged(hwnd2Settings, hContact, info->module, setting); - safe_free(setting); + mir_free(setting); } } } @@ -132,7 +117,7 @@ int DBSettingChanged(WPARAM wParam,LPARAM lParam) if (!WatchListArray.item[i].setting || !mir_strcmp(cws->szSetting, WatchListArray.item[i].setting)) { if (usePopUps) - popupWatchedVar(hContact,cws->szModule, cws->szSetting); + popupWatchedVar(hContact, cws->szModule, cws->szSetting); if (hwnd2watchedVarsWindow) PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); break; @@ -143,14 +128,14 @@ int DBSettingChanged(WPARAM wParam,LPARAM lParam) return 0; } -static int DBEditorppMenuCommand(WPARAM wParam,LPARAM lParam) +INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM lParam) { if (!hwnd2mainWindow) // so only opens 1 at a time { hRestore = (HANDLE)wParam; SetCursor(LoadCursor(NULL,IDC_WAIT)); - CreateDialog(hInst,MAKEINTRESOURCE(IDD_MAIN),0,MainDlgProc); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc); } else { @@ -168,7 +153,6 @@ static int DBEditorppMenuCommand(WPARAM wParam,LPARAM lParam) return 0; } - BOOL IsCP_UTF8(void) { CPINFO CPInfo; @@ -176,29 +160,6 @@ BOOL IsCP_UTF8(void) return GetCPInfo(CP_UTF8, &CPInfo); } - -BOOL InitWFuctions(void) -{ - HMODULE hDll = LoadLibrary("user32.dll"); - if (hDll) - { - _CreateDialogParamW = (HWND (WINAPI *)(HINSTANCE,LPCWSTR,HWND,DLGPROC,LPARAM))GetProcAddress(hDll, "CreateDialogParamW"); - _CreateWindowExW = (HWND (WINAPI *)(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID))GetProcAddress(hDll, "CreateWindowExW"); - _CallWindowProcW = (LRESULT (WINAPI *)(WNDPROC,HWND,UINT,WPARAM,LPARAM))GetProcAddress(hDll, "CallWindowProcW"); - _SetWindowLongW = (LONG (WINAPI *)(HWND,int,LONG))GetProcAddress(hDll, "SetWindowLongW"); - _SendMessageW = (LRESULT (WINAPI *)(HWND,UINT,WPARAM,LPARAM))GetProcAddress(hDll, "SendMessageW"); - - if (_CreateDialogParamW && - _CreateWindowExW && - _CallWindowProcW && - _SetWindowLongW && - _SendMessageW) - return 1; - - } - return 0; -} - HANDLE hTTBHook = NULL; static int OnTTBLoaded(WPARAM wParam,LPARAM lParam) { @@ -227,7 +188,7 @@ HANDLE hModulesLoadedHook = NULL; int ModulesLoaded(WPARAM wParam,LPARAM lParam) { DBVARIANT dbv; - char *coreMods = "AutoAway, CLC, CList CListGroups, CLUI, Contact, DBEditorpp, Icons, Idle, Ignore, Netlib, Options, PluginDisable, Skin, SkinHotKeys, SkinSounds, SkinSoundsOff, SRAway, SRFile, SRMsg, SRUrl, UpdateCheck, UserInfo, UserOnline, _Filter, Protocol, KnownModules, SkinIcons, FirstRun"; + char *coreMods = ""; char *mods; char mod[64] = ""; char szModuleFileName[MAX_PATH]; @@ -240,8 +201,8 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam) mods = coreMods; } - len=strlen(mods); - while (i - * Copyright (C) 2001 Edmund Grimley Evans - * - * under a GPL license - * - * -------------------------------------------------------------- - * Convert a string between UTF-8 and the locale's charset. - * Invalid bytes are replaced by '#', and characters that are - * not available in the target encoding are replaced by '?'. - * - * If the locale's charset is not set explicitly then it is - * obtained using nl_langinfo(CODESET), where available, the - * environment variable CHARSET, or assumed to be US-ASCII. - * - * Return value of conversion functions: - * - * -1 : memory allocation failed - * 0 : data was converted exactly - * 1 : valid data was converted approximately (using '?') - * 2 : input was invalid (but still converted, using '#') - * 3 : unknown encoding (but still converted, using '?') - */ - - -/* -unsigned char *make_utf8_string(const wchar_t *unicode) -{ - - int size = 0; - int index = 0; - int out_index = 0; - unsigned char* out; - unsigned short c; - - - // first calculate the size of the target string - c = unicode[index++]; - while(c) { - if(c < 0x0080) { - size += 1; - } else if(c < 0x0800) { - size += 2; - } else { - size += 3; - } - c = unicode[index++]; - } - - out = malloc(size + 1); - if (out == NULL) - return NULL; - index = 0; - - c = unicode[index++]; - while(c) - { - if(c < 0x080) { - out[out_index++] = (unsigned char)c; - } else if(c < 0x800) { - out[out_index++] = 0xc0 | (c >> 6); - out[out_index++] = 0x80 | (c & 0x3f); - } else { - out[out_index++] = 0xe0 | (c >> 12); - out[out_index++] = 0x80 | ((c >> 6) & 0x3f); - out[out_index++] = 0x80 | (c & 0x3f); - } - c = unicode[index++]; - } - out[out_index] = 0x00; - - return out; -} - - -wchar_t *make_unicode_string(const unsigned char *utf8) -{ - - int size = 0, index = 0, out_index = 0; - wchar_t *out; - unsigned char c; - - - // first calculate the size of the target string - c = utf8[index++]; - while(c) { - if((c & 0x80) == 0) { - index += 0; - } else if((c & 0xe0) == 0xe0) { - index += 2; - } else { - index += 1; - } - size += 1; - c = utf8[index++]; - } - - out = malloc((size + 1) * sizeof(wchar_t)); - if (out == NULL) - return NULL; - index = 0; - - c = utf8[index++]; - while(c) - { - if((c & 0x80) == 0) { - out[out_index++] = c; - } else if((c & 0xe0) == 0xe0) { - out[out_index] = (c & 0x1F) << 12; - c = utf8[index++]; - out[out_index] |= (c & 0x3F) << 6; - c = utf8[index++]; - out[out_index++] |= (c & 0x3F); - } else { - out[out_index] = (c & 0x3F) << 6; - c = utf8[index++]; - out[out_index++] |= (c & 0x3F); - } - c = utf8[index++]; - } - out[out_index] = 0; - - return out; -} -*/ - - int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...) { va_list va; @@ -833,7 +641,7 @@ WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) if (hContact && !proto) { - if (GetValue(hContact,"Protocol","p",name,sizeof(name))) + if (GetValue(hContact,"Protocol","p",name,SIZEOF(name))) proto = name; } @@ -883,9 +691,9 @@ WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) if (r = GetDatabaseString(hContact,proto,"FirstName",res,SIZEOF(res),unicode)) { if (unicode) - len = wcslen(res); + len = (int)wcslen(res); else - len = strlen((char*)res); + len = (int)strlen((char*)res); } else res[0] = 0; diff --git a/dbeditorpp/main_window.cpp b/dbeditorpp/main_window.cpp index 0c437fb..adb551e 100644 --- a/dbeditorpp/main_window.cpp +++ b/dbeditorpp/main_window.cpp @@ -1,5 +1,10 @@ #include "headers.h" +HWND hwnd2mainWindow; +int Order; +HIMAGELIST himl2; +int Hex; + #define GC_SPLITTERMOVED (WM_USER+101) extern BOOL bServiceMode; @@ -88,7 +93,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM break; case WM_CHAR: if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) - CreateDialog(hInst,MAKEINTRESOURCE(IDD_FIND),hwnd,FindWindowDlgProc); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; case WM_KEYUP: { @@ -116,14 +121,14 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM { if (deleteModule(module, hContact,0)) { - safe_free(mtis); + mir_free(mtis); TreeView_DeleteItem(hwnd,tvi.hItem); } } else if ((mtis->type == CONTACT) && hContact) { char msg[1024]; - mir_snprintf(msg, 1024, Translate("Are you sure you want to delete contact \"%s\"?"), module); + mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module); if (DBGetContactSettingByte(NULL,"CList", "ConfirmDelete",1)) { if (MessageBox(0,msg, Translate("Confirm Contact Delete"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) @@ -144,7 +149,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM else if (wParam == VK_F3) { - CreateDialog(hInst,MAKEINTRESOURCE(IDD_FIND),hwnd,FindWindowDlgProc); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; } } @@ -160,14 +165,14 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam switch(msg) { case WM_CHAR: if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) - CreateDialog(hInst,MAKEINTRESOURCE(IDD_FIND),hwnd,FindWindowDlgProc); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; case WM_KEYDOWN: if (wParam == VK_DELETE || wParam == VK_F5 || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) { char *module, setting[256]; HANDLE hContact; - SettingListInfo* sli = (SettingListInfo*)GetWindowLong(hwnd,GWL_USERDATA); + SettingListInfo* sli = (SettingListInfo*)GetWindowLongPtr(hwnd,GWLP_USERDATA); if (!sli) break; hContact = sli->hContact; module = sli->module; @@ -177,9 +182,9 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam editSetting(hContact,module, setting); else if (wParam == VK_F5) { - char *szModule = strdup(module); // need to do this, otheriwse the setlist stays empty + char *szModule = mir_tstrdup(module); // need to do this, otheriwse the setlist stays empty PopulateSettings(hwnd,hContact,szModule); - safe_free(szModule); + mir_free(szModule); } else if (wParam == VK_DELETE) DeleteSettingsFromList(hwnd, hContact, module, setting); @@ -187,7 +192,7 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam return 0; } else if (wParam == VK_F3) - CreateDialog(hInst,MAKEINTRESOURCE(IDD_FIND),hwnd,FindWindowDlgProc); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; default: break; @@ -195,7 +200,7 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam return CallWindowProc(SettingListSubClass,hwnd,msg,wParam,lParam); } -BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -212,15 +217,15 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) else SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); // setup the splitter - SetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_USERDATA,(LPARAM)DBGetContactSettingWord(NULL, modname, "Splitter", 300)); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA,(LPARAM)DBGetContactSettingWord(NULL, modname, "Splitter", 300)); SendMessage(hwnd, GC_SPLITTERMOVED, 0,0); - SplitterSubClass=(WNDPROC)SetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_WNDPROC,(LONG)SplitterSubclassProc); + SplitterSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_WNDPROC,(LONG)SplitterSubclassProc); // module tree TreeView_SetUnicodeFormat(GetDlgItem(hwnd,IDC_MODULES), UOS); - ModuleTreeSubClass=(WNDPROC)SetWindowLong(GetDlgItem(hwnd,IDC_MODULES),GWL_WNDPROC,(LONG)ModuleTreeSubclassProc); + ModuleTreeSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_MODULES),GWLP_WNDPROC,(LONG)ModuleTreeSubclassProc); //setting list setupSettingsList(GetDlgItem(hwnd,IDC_SETTINGS)); - SettingListSubClass=(WNDPROC)SetWindowLong(GetDlgItem(hwnd,IDC_SETTINGS),GWL_WNDPROC,(LONG)SettingListSubclassProc); + SettingListSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_WNDPROC,(LONG)SettingListSubclassProc); // traslation stuff TranslateDialogDefault(hwnd); CallService(MS_LANGPACK_TRANSLATEMENU,(WPARAM)hMenu,0); @@ -252,9 +257,9 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(GetSubMenu(hMenu,5),MENU_WORD_HEX,MF_BYCOMMAND|((Hex & HEX_WORD)?MF_CHECKED:MF_UNCHECKED)); CheckMenuItem(GetSubMenu(hMenu,5),MENU_DWORD_HEX,MF_BYCOMMAND|((Hex & HEX_DWORD)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",0)?MF_CHECKED:MF_UNCHECKED)); + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)?MF_CHECKED:MF_UNCHECKED)); - Order = DBGetContactSettingByte(NULL,modname,"SortMode",0); + Order = DBGetContactSettingByte(NULL,modname,"SortMode",1); CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SORT_ORDER,MF_BYCOMMAND|(Order?MF_CHECKED:MF_UNCHECKED)); @@ -330,7 +335,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (hRestore) restore = 3; else - if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",0)) + if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)) restore = 2; else restore = 0; @@ -346,7 +351,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) RECT rc; RECT rc2; - int splitterPos = GetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_USERDATA); + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); GetWindowRect(hwnd,&rc2); @@ -359,7 +364,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) splitterPos=rc.left+pt.x+1; if (splitterPos<65) splitterPos=65; if (splitterPos > rc2.right-rc2.left-65) splitterPos=rc2.right-rc2.left-65; - SetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_USERDATA, splitterPos); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA, splitterPos); DBWriteContactSettingWord(NULL, modname, "Splitter",(WORD)splitterPos); } PostMessage(hwnd,WM_SIZE,0,0); @@ -368,7 +373,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_GETMINMAXINFO: { MINMAXINFO *mmi=(MINMAXINFO*)lParam; - int splitterPos = GetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_USERDATA); + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); if(splitterPos+40 > 200) mmi->ptMinTrackSize.x=splitterPos+65; @@ -386,7 +391,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) urd.cbSize=sizeof(urd); urd.hInstance=hInst; urd.hwndDlg=hwnd; - urd.lParam=(LPARAM)GetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_USERDATA); + urd.lParam=(LPARAM)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); urd.lpTemplate=MAKEINTRESOURCE(IDD_MAIN); urd.pfnResizer=DialogResize; CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); @@ -404,7 +409,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: // free our shit! - if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",0)) + if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)) { HTREEITEM item; HWND hwnd2Tree = GetDlgItem(hwnd,IDC_MODULES); @@ -450,7 +455,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { char text[256]; - ListView_GetItemText(hwnd2Settings, pos, 0, text, sizeof(text)); + ListView_GetItemText(hwnd2Settings, pos, 0, text, SIZEOF(text)); DBWriteContactSettingString(NULL,modname,"LastSetting",text); } @@ -469,9 +474,9 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ImageList_Destroy(himl); if (himl2) ImageList_Destroy(himl2); - SetWindowLong(GetDlgItem(hwnd,IDC_SETTINGS),GWL_WNDPROC,(LONG)SettingListSubClass); - SetWindowLong(GetDlgItem(hwnd,IDC_MODULES),GWL_WNDPROC,(LONG)ModuleTreeSubClass); - SetWindowLong(GetDlgItem(hwnd,IDC_SPLITTER),GWL_WNDPROC,(LONG)SplitterSubClass); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_WNDPROC,(LONG)SettingListSubClass); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_MODULES),GWLP_WNDPROC,(LONG)ModuleTreeSubClass); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_WNDPROC,(LONG)SplitterSubClass); if (!DBGetContactSettingByte(NULL,modname,"Maximised",0)) { RECT rc; @@ -521,7 +526,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case MENU_VIEW_WATCHES: { if (!hwnd2watchedVarsWindow) // so only opens 1 at a time - hwnd2watchedVarsWindow = CreateDialog(hInst,MAKEINTRESOURCE(IDD_WATCH_DIAG),0,WatchDlgProc); + hwnd2watchedVarsWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), 0, WatchDlgProc); else SetForegroundWindow(hwnd2watchedVarsWindow); } break; @@ -538,10 +543,10 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) exportDB(NULL, 0); break; case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(INVALID_HANDLE_VALUE); + ImportSettingsFromFileMenuItem(NULL, ""); break; case MENU_IMPORTFROMTEXT: - ImportSettingsMenuItem(INVALID_HANDLE_VALUE); + ImportSettingsMenuItem(NULL); break; case MENU_EXIT: case IDCANCEL: @@ -551,7 +556,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) deleteModuleGui(); break; case MENU_FINDANDREPLACE: - CreateDialog(hInst,MAKEINTRESOURCE(IDD_FIND),hwnd,FindWindowDlgProc); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); break; case MENU_FILTER_ALL: if (Mode != MODE_ALL) @@ -606,7 +611,7 @@ BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case MENU_SAVE_POSITION: { - BOOL save = !DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",0); + BOOL save = !DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1); CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(save?MF_CHECKED:MF_UNCHECKED)); DBWriteContactSettingByte(NULL,modname,"RestoreOnOpen", (byte)save); } diff --git a/dbeditorpp/modsettingenum.cpp b/dbeditorpp/modsettingenum.cpp index 683434c..7eaecdd 100644 --- a/dbeditorpp/modsettingenum.cpp +++ b/dbeditorpp/modsettingenum.cpp @@ -10,10 +10,10 @@ void FreeModuleSettingLL(ModuleSettingLL* msll) while (item) { - safe_free(item->name); + mir_free(item->name); temp = item; item = (struct ModSetLinkLinkItem *)item->next; - safe_free(temp); + mir_free(temp); } msll->first = 0; @@ -26,19 +26,19 @@ int enumModulesSettingsProc( const char *szName , DWORD ofsModuleName , LPARAM l ModuleSettingLL *msll = (ModuleSettingLL *)lParam; if (!msll->first) { - msll->first = (struct ModSetLinkLinkItem *)malloc(sizeof(struct ModSetLinkLinkItem)); + msll->first = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem)); if (!msll->first) return 1; - msll->first->name = strdup(szName); + msll->first->name = mir_tstrdup(szName); msll->first->next = 0; msll->last = msll->first; } else { - struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)malloc(sizeof(struct ModSetLinkLinkItem)); + struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem)); if (!item) return 1; msll->last->next = (BYTE*)item; msll->last = (struct ModSetLinkLinkItem *)item; - item->name = strdup(szName); + item->name = mir_tstrdup(szName); item->next = 0; } return 0; diff --git a/dbeditorpp/modules.cpp b/dbeditorpp/modules.cpp index bfaff6e..4053180 100644 --- a/dbeditorpp/modules.cpp +++ b/dbeditorpp/modules.cpp @@ -44,11 +44,11 @@ void renameModule(char* oldName, char* newName, HANDLE hContact) FreeModuleSettingLL(&settinglist); } -BOOL CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_INITDIALOG) { - SetWindowLong(hwnd,GWL_USERDATA,lParam); + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); TranslateDialogDefault(hwnd); } if (msg == WM_COMMAND) @@ -74,7 +74,7 @@ BOOL CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } else { - DBWriteContactSettingByte((HANDLE)GetWindowLong(hwnd,GWL_USERDATA), modulename, "(Default)", 0); + DBWriteContactSettingByte((HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA), modulename, "(Default)", 0); } refreshTree(1); } diff --git a/dbeditorpp/moduletree.cpp b/dbeditorpp/moduletree.cpp index 699b3ac..a3828b8 100644 --- a/dbeditorpp/moduletree.cpp +++ b/dbeditorpp/moduletree.cpp @@ -32,7 +32,7 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H while (hContact && hwnd2mainWindow) // break after null contact { - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) { icon = GetProtoIcon(szProto); loaded = (icon != DEF_ICON); @@ -57,7 +57,7 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H // SetWindowText(hwnd2mainWindow, percent); // add the contact - lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1); + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; lParam->type = CONTACT; tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; @@ -86,9 +86,9 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H if (protoW) { if (Order) - mir_snwprintf(nick, SIZEOF(nick),L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); else - mir_snwprintf(nick, SIZEOF(nick),L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); } else wcscpy(nick, nick_unknownW); @@ -116,9 +116,9 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H if (szProto[0]) { if (Order) - mir_snprintf(nick, sizeof(nick),"(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); + mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); else - mir_snprintf(nick, sizeof(nick),"%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); + mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); } else strcpy(nick, nick_unknown); @@ -127,9 +127,9 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H { tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); if (Order) - mir_snprintf(nick, sizeof(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); + mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); else - mir_snprintf(nick, sizeof(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); } tvi.item.pszText = nick; @@ -151,7 +151,7 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tvi.item.pszText = module->name; - lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1); + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; if (!module->known) @@ -211,7 +211,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) HWND hwnd = GetParent(hwnd2Tree); int i = 0; - mir_snprintf(title, sizeof(title),Translate("Loading modules...")); + mir_snprintf(title, SIZEOF(title), Translate("Loading modules...")); item.mask = TVIF_STATE|TVIF_PARAM; @@ -238,7 +238,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) else continue; // Caption - mir_snprintf(percent,sizeof(percent),"%s %d%%",title,(int)(100*i/count)); + mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100*i/count)); SetWindowText(hwnd, percent); module = modlist->first; @@ -251,7 +251,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tvi.item.pszText = module->name; - lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1); + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; if (!module->known) @@ -351,7 +351,7 @@ http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?t { if (hContact != NULL) { TreeView_DeleteItem(hwnd2Tree,item.hItem); - safe_free(mtis); + mir_free(mtis); } else mtis->type = STUB; } @@ -395,7 +395,7 @@ http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?t ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; if (hContact == mtis->hContact && !mir_strcmp(text,module)) { - safe_free(mtis); + mir_free(mtis); TreeView_DeleteItem(hwnd2Tree,item.hItem); lastItem = prelastItem; Result = 1; @@ -430,7 +430,7 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char item.hItem = (HTREEITEM)hItem; if (TreeView_GetItem(hwnd, &item)) - safe_free((ModuleTreeInfoStruct *)item.lParam); + mir_free((ModuleTreeInfoStruct *)item.lParam); TreeView_DeleteItem(hwnd,item.hItem); } @@ -444,7 +444,7 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tvi.item.pszText = (char*)newModule; - lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1); + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; lParam->type = IsModuleKnown((char*)newModule)?KNOWN_MODULE:UNKNOWN_MODULE; if (lParam->type == UNKNOWN_MODULE) @@ -468,7 +468,7 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char void refreshTree(int restore) { - UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",1); + UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0); if (populating) return; populating = 1; forkthread(PopulateModuleTreeThreadFunc,0,(HWND)restore); @@ -524,12 +524,12 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) break; } case 2: // restore saved - if (GetValue(NULL,modname,"LastModule",SelectedModule,sizeof(SelectedModule))) + if (GetValue(NULL,modname,"LastModule",SelectedModule,SIZEOF(SelectedModule))) { hSelectedContact = (HANDLE)DBGetContactSettingDword(NULL,modname,"LastContact",(DWORD)INVALID_HANDLE_VALUE); if (hSelectedContact != INVALID_HANDLE_VALUE) Select = 1; - GetValue(NULL,modname,"LastSetting",SelectedSetting,sizeof(SelectedSetting)); + GetValue(NULL,modname,"LastSetting",SelectedSetting,SIZEOF(SelectedSetting)); } break; case 3: // restore from user menu @@ -600,7 +600,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tvi.item.pszText = module->name; - lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1); + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); lParam->hContact = hContact; if (!module->known) { @@ -714,7 +714,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tvi.item.pszText = module->name; - _lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1); + _lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); _lParam->hContact = hContact; if (IsModuleKnown(module->name)) @@ -768,7 +768,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) { - SettingListInfo *info = (SettingListInfo*)GetWindowLong(hwnd2Settings,GWL_USERDATA); + SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); BOOL refresh = 1; if (info) @@ -792,7 +792,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd lvi.iImage = 6; ClearListview(hwnd2Settings); - SetWindowLong(hwnd2Settings,GWL_USERDATA, (LONG)NULL); + SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)NULL); if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); if (mtis->type == CONTACT_ROOT_ITEM && !hContact) @@ -806,7 +806,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (multi) { // filter - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) loaded = IsProtocolLoaded(szProto); else loaded = 0; @@ -826,7 +826,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd else index = ListView_InsertItem(hwnd2Settings,&lvi); - _snprintf(data, sizeof(data), "0x%08X (%ld)", hContact, hContact); + mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact); ListView_SetItemText(hwnd2Settings,index,1,data); ListView_SetItemText(hwnd2Settings,index,2,Translate("HANDLE")); @@ -860,11 +860,11 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES)); if (!mtis->type || (mtis->type == CONTACT)) { - SetWindowLong(hwnd, DWL_MSGRESULT, TRUE); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); break; } - ModuleTreeLabelEditSubClass=(WNDPROC)SetWindowLong(hwnd2Edit,GWL_WNDPROC,(LONG)ModuleTreeLabelEditSubClassProc); - SetWindowLong(hwnd, DWL_MSGRESULT, FALSE); + ModuleTreeLabelEditSubClass = (WNDPROC)SetWindowLongPtr(hwnd2Edit, GWLP_WNDPROC, (LONG)ModuleTreeLabelEditSubClassProc); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); } break; case TVN_ENDLABELEDITA: @@ -885,13 +885,13 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (UOS) newtext = u2a((WCHAR*)ptvdi->item.pszText); else - newtext = _strdup(ptvdi->item.pszText); + newtext = mir_tstrdup(ptvdi->item.pszText); if (!newtext || // edit control failed !mtis->type || // its a root item mtis->type == CONTACT || // its a contact *newtext == 0) // empty string - SetWindowLong(hwnd, DWL_MSGRESULT, FALSE); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); else { if (mir_strcmp(tvi.pszText, newtext)) @@ -918,10 +918,10 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext); } } - SetWindowLong(hwnd, DWL_MSGRESULT, TRUE); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); } - safe_free(newtext); + mir_free(newtext); } break; } @@ -995,7 +995,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i if (deleteModule(module, hContact, 0)) { TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,hti.hItem); - safe_free(mtis); + mir_free(mtis); } break; case MENU_COPY_MOD: @@ -1029,9 +1029,9 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i } if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ) { - int len = strlen(dbv.pszVal)+10+strlen(moduletemp); + int len = (int)strlen(dbv.pszVal) + 10 + (int)strlen(moduletemp); char* temp = (char*)_alloca(len); - _snprintf(temp,len,"%s, %s",dbv.pszVal,moduletemp); + mir_snprintf(temp, len, "%s, %s", dbv.pszVal, moduletemp); DBWriteContactSettingString(NULL,modname,"CoreModules",temp); DBFreeVariant(&dbv); } @@ -1055,7 +1055,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i if (DBGetContactSettingByte(NULL,"CList", "ConfirmDelete",1)) { char msg[1024]; - mir_snprintf(msg, 1024, Translate("Are you sure you want to delete contact \"%s\"?"), module); + mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module); if (MessageBox(0,msg, Translate("Confirm Contact Delete"), MB_YESNO|MB_ICONEXCLAMATION) == IDYES) { CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact,0); @@ -1078,14 +1078,14 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i ImportSettingsMenuItem(hContact); break; case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(hContact); + ImportSettingsFromFileMenuItem(hContact, ""); break; ////////////////////////////////////////////////////////////////////// divider case MENU_ADD_MODULE: { - HWND AddModhwnd = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_ADD_MODULE),hwnd,AddModDlgProc, (LPARAM)hContact); + HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); char msg[1024]; - mir_snprintf(msg, 1024, Translate("Add module to contact \"%s\""),module); + mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); SetWindowText(AddModhwnd, module); } break; @@ -1096,9 +1096,9 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i { case MENU_ADD_MODULE: { - HWND AddModhwnd = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_ADD_MODULE),hwnd,AddModDlgProc, (LPARAM)hContact); + HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); char msg[1024]; - mir_snprintf(msg, 1024, Translate("Add module to contact \"%s\""),module); + mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); SetWindowText(AddModhwnd, module); } break; @@ -1109,7 +1109,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i ImportSettingsMenuItem(NULL); break; case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(NULL); + ImportSettingsFromFileMenuItem(NULL, ""); break; } break; @@ -1120,10 +1120,10 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i exportDB(INVALID_HANDLE_VALUE, ""); break; case MENU_IMPORTFROMTEXT: - ImportSettingsMenuItem(INVALID_HANDLE_VALUE); + ImportSettingsMenuItem(NULL); break; case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(INVALID_HANDLE_VALUE); + ImportSettingsFromFileMenuItem(NULL, ""); break; } break; diff --git a/dbeditorpp/options.cpp b/dbeditorpp/options.cpp index fb0224b..741796c 100644 --- a/dbeditorpp/options.cpp +++ b/dbeditorpp/options.cpp @@ -1,5 +1,6 @@ #include "headers.h" -BOOL CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + +INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -7,10 +8,10 @@ BOOL CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; CheckDlgButton(hwnd,IDC_EXPANDSETTINGS,DBGetContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",0)); - CheckDlgButton(hwnd,IDC_RESTORESETTINGS,DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",0)); - CheckDlgButton(hwnd,IDC_USEKNOWNMODS,DBGetContactSettingByte(NULL,modname,"UseKnownModList",1)); + CheckDlgButton(hwnd,IDC_RESTORESETTINGS,DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)); + CheckDlgButton(hwnd,IDC_USEKNOWNMODS,DBGetContactSettingByte(NULL,modname,"UseKnownModList",0)); CheckDlgButton(hwnd,IDC_WARNONDEL,DBGetContactSettingByte(NULL,modname,"WarnOnDelete",1)); - CheckDlgButton(hwnd,IDC_MENU,DBGetContactSettingByte(NULL,modname,"UserMenuItem",1)); + CheckDlgButton(hwnd,IDC_MENU,DBGetContactSettingByte(NULL,modname,"UserMenuItem",0)); CheckDlgButton(hwnd,IDC_POPUPS,usePopUps); if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ) SetDlgItemText(hwnd,IDC_MODULES,dbv.pszVal); @@ -77,7 +78,7 @@ BOOL CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return FALSE; } -int OptInit(WPARAM wParam,LPARAM lParam) +INT OptInit(WPARAM wParam,LPARAM lParam) { OPTIONSDIALOGPAGE odp; @@ -86,9 +87,9 @@ int OptInit(WPARAM wParam,LPARAM lParam) odp.position=0; odp.hInstance=hInst; odp.pszTemplate=MAKEINTRESOURCE(IDD_OPTIONS); - odp.pszGroup= Translate("Plugins"); - odp.pszTitle=Translate(modFullname); - odp.pfnDlgProc=DlgProcOpts; + odp.pszGroup= "Services"; + odp.pszTitle= modFullname; + odp.pfnDlgProc = DlgProcOpts; odp.flags = ODPF_BOLDGROUPS; odp.expertOnlyControls=NULL; CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); diff --git a/dbeditorpp/resource.rc b/dbeditorpp/resource.rc index 3d2b00d..5b48372 100644 --- a/dbeditorpp/resource.rc +++ b/dbeditorpp/resource.rc @@ -13,64 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,2,0,0 - PRODUCTVERSION 3,2,0,0 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Comments", "Licensed under the terms of the GNU General Public License" - VALUE "FileDescription", "Advanced Database Editor" - VALUE "FileVersion", "3, 2, 0, 0" - VALUE "InternalName", "DBEditor" - VALUE "LegalCopyright", "Copyright (C) 2003-2008 Bio, Jonathan Gordon" - VALUE "OriginalFilename", "dbeditor.dll" - VALUE "ProductName", "DBEditor plugin for Miranda-IM" - VALUE "ProductVersion", "3, 2, 0, 0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// Английский (США) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -78,49 +25,33 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // IDD_FIND DIALOGEX 0, 0, 340, 249 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME CAPTION "Database Editor++ Search and Replace" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN EDITTEXT IDC_TEXT,40,13,216,12,ES_AUTOHSCROLL - CONTROL "Case Sensitive",IDC_CASESENSITIVE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,40,30,72,10 - CONTROL "Module Name",IDC_MODNAME,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,40,44,73,10 - CONTROL "Exact Match",IDC_EXACT,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,115,30,64,10 - CONTROL "Setting Name",IDC_SETTINGNAME,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,115,44,72,10 - CONTROL "Setting Value",IDC_SETTINGVALUE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,194,44,69,10 + CONTROL "Case Sensitive",IDC_CASESENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,30,72,10 + CONTROL "Module Name",IDC_MODNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,44,73,10 + CONTROL "Exact Match",IDC_EXACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,115,30,64,10 + CONTROL "Setting Name",IDC_SETTINGNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,115,44,72,10 + CONTROL "Setting Value",IDC_SETTINGVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,194,44,69,10 DEFPUSHBUTTON "&Search",IDC_SEARCH,277,5,60,14 EDITTEXT IDC_REPLACE,40,72,216,12,ES_AUTOHSCROLL - CONTROL "Module Name",IDC_MODNAME2,"Button",BS_AUTORADIOBUTTON | - NOT WS_VISIBLE | WS_DISABLED | WS_GROUP | WS_TABSTOP,40, - 90,73,10 - CONTROL "Setting Name",IDC_SETTINGNAME2,"Button", - BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | - WS_TABSTOP,115,90,72,10 - CONTROL "Setting Value",IDC_SETTINGVALUE2,"Button", - BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | - WS_TABSTOP,194,90,67,10 - CONTROL "Found field",IDC_FOUND,"Button",BS_AUTORADIOBUTTON | - NOT WS_VISIBLE | WS_TABSTOP,267,90,65,10 + CONTROL "Module Name",IDC_MODNAME2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP | WS_TABSTOP,40,90,73,10 + CONTROL "Setting Name",IDC_SETTINGNAME2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,115,90,72,10 + CONTROL "Setting Value",IDC_SETTINGVALUE2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,194,90,67,10 + CONTROL "Found field",IDC_FOUND,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_TABSTOP,267,90,65,10 PUSHBUTTON "&Replace",IDOK,277,25,60,14 PUSHBUTTON "&Cancel",IDCANCEL,277,45,60,14 - LISTBOX IDC_LIST,3,95,334,136,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | - WS_HSCROLL | WS_TABSTOP + LISTBOX IDC_LIST,3,95,334,136,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP GROUPBOX "Search For",IDC_STATIC,3,1,268,58 LTEXT "Text:",IDC_STATIC,10,15,26,8 LTEXT "In:",IDC_STATIC,10,30,23,8 GROUPBOX "Replace With",IDC_STATIC,3,60,334,30 LTEXT "Text:",IDC_STATIC,10,74,26,8 LTEXT "In:",IDC_STATIC,10,90,23,8,NOT WS_VISIBLE - CONTROL "",IDC_SBAR,"msctls_statusbar32",WS_TABSTOP | 0x100,3, - 237,334,12 - CONTROL "Entirely",IDC_ENTIRELY,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,262,74,67,10 + CONTROL "",IDC_SBAR,"msctls_statusbar32",WS_TABSTOP | 0x100,3,237,334,12 + CONTROL "Entirely",IDC_ENTIRELY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,262,74,67,10 END IDD_OPTIONS DIALOGEX 0, 0, 314, 239 @@ -129,32 +60,22 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN CONTROL "Restore last opened position",IDC_RESTORESETTINGS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,13,283,10 - CONTROL "Automatically expand ""settings"" when Database Editor ++ starts", - IDC_EXPANDSETTINGS,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,26,283,10 - CONTROL "Use known modules list",IDC_USEKNOWNMODS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,39,253,10 - CONTROL "Warn when deleting modules",IDC_WARNONDEL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,52,280,10 - CONTROL """Open user tree in DBE++"" menu item",IDC_MENU,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,65,280,10 - CONTROL "Use popups when watched settings change values", - IDC_POPUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,78, - 275,10 + CONTROL "Automatically expand ""settings"" when Database Editor ++ starts",IDC_EXPANDSETTINGS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,26,283,10 + CONTROL "Use known modules list",IDC_USEKNOWNMODS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,39,253,10 + CONTROL "Warn when deleting modules",IDC_WARNONDEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,52,280,10 + CONTROL """Open user tree in DBE++"" menu item",IDC_MENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,65,280,10 + CONTROL "Use popups when watched settings change values",IDC_POPUPS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,78,275,10 EDITTEXT IDC_POPUPTIMEOUT,144,89,20,12,ES_NUMBER CONTROL "",IDC_COLOUR,"ColourPicker",WS_TABSTOP,257,89,26,12 - EDITTEXT IDC_MODULES,12,140,288,46,ES_MULTILINE | ES_AUTOVSCROLL | - ES_WANTRETURN | WS_VSCROLL - GROUPBOX "Modules to ALWAYS mark as known (e.g core modules)", - IDC_STATIC,7,105,300,96 - LTEXT "Put a space or comma between each module name", - IDC_STATIC,12,116,286,8 - LTEXT "Changes to this list will take effect next time miranda starts", - IDC_STATIC,12,189,284,8 + EDITTEXT IDC_MODULES,12,140,288,46,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + GROUPBOX "Modules to ALWAYS mark as known (e.g core modules)",IDC_STATIC,7,105,300,96 + LTEXT "Put a space or comma between each module name",IDC_STATIC,12,116,286,8 + LTEXT "Changes to this list will take effect next time miranda starts",IDC_STATIC,12,189,284,8 RTEXT "Popup timeout (0 for infinite)",IDC_STATIC,35,91,103,8 RTEXT "Background Colour",IDC_STATIC,177,91,77,8 - LTEXT "If the module name has a space in it, put a \\ before the space. eg ""aaa\\ bbb""", - IDC_STATIC,12,127,286,8 + LTEXT "If the module name has a space in it, put a \\ before the space. eg ""aaa\\ bbb""",IDC_STATIC,12,127,286,8 END @@ -209,18 +130,16 @@ ICO_UNKNOWNOPEN ICON "res\\Red_open.ico" ICO_UNKNOWN ICON "res\\Red.ico" ICO_SETTINGS ICON "res\\Icon_4.ico" ICO_ONLINE ICON "res\\online2.ico" -#endif // English (U.S.) resources +#endif // Английский (США) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// English (Australia) resources +// Английский (Австралия) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS #pragma code_page(1252) -#endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // @@ -228,8 +147,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS // IDD_ADD_MODULE DIALOGEX 0, 0, 186, 67 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | - DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Add a module to contact" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN @@ -242,17 +160,14 @@ BEGIN END IDD_EDIT_SETTING DIALOGEX 0, 0, 252, 121 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | - DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION CAPTION "Edit Setting" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN EDITTEXT IDC_SETTINGNAME,7,18,238,14,ES_AUTOHSCROLL EDITTEXT IDC_SETTINGVALUE,7,49,159,14,ES_AUTOHSCROLL - EDITTEXT IDC_STRING,49,37,196,61,ES_MULTILINE | ES_WANTRETURN | - NOT WS_VISIBLE | WS_VSCROLL | WS_HSCROLL - EDITTEXT IDC_BLOB,49,37,196,61, NOT WS_VISIBLE | WS_VSCROLL | - ES_MULTILINE + EDITTEXT IDC_STRING,49,37,196,61,ES_MULTILINE | ES_WANTRETURN | NOT WS_VISIBLE | WS_VSCROLL | WS_HSCROLL + EDITTEXT IDC_BLOB,49,37,196,61,ES_MULTILINE | NOT WS_VISIBLE | WS_VSCROLL RADIOBUTTON "Byte",CHK_BYTE,13,81,30,10 RADIOBUTTON "Word",CHK_WORD,50,81,33,10 RADIOBUTTON "Dword",CHK_DWORD,90,81,37,10 @@ -268,66 +183,47 @@ BEGIN END IDD_WATCH_DIAG DIALOGEX 0, 0, 414, 190 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | - WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | - WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME CAPTION "Watched Database Variables" MENU IDR_WATCHWINDOWMENU FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - CONTROL "List1",IDC_VARS,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | - LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_NOSORTHEADER | - WS_BORDER | WS_TABSTOP,0,0,414,190 + CONTROL "List1",IDC_VARS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,0,0,414,190 END IDD_COPY_MOD DIALOGEX 0, 0, 186, 67 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | - DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Copy module to contact" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - COMBOBOX IDC_CONTACTS,7,17,172,99,CBS_DROPDOWNLIST | - CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CONTACTS,7,17,172,99,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP CONTROL "Copy to all contacts (Includes Settings)",CHK_COPY2ALL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,172,10 DEFPUSHBUTTON "OK",IDOK,29,49,50,14 PUSHBUTTON "Cancel",IDCANCEL,107,49,50,14 - LTEXT "Contact to copy module and settings to",IDC_INFOTEXT,7, - 6,124,8 + LTEXT "Contact to copy module and settings to",IDC_INFOTEXT,7,6,124,8 END IDD_IMPORT DIALOGEX 0, 0, 268, 170 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Import Module/Settings" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - EDITTEXT IDC_TEXT,7,18,254,124,ES_MULTILINE | ES_WANTRETURN | - WS_VSCROLL | WS_HSCROLL + EDITTEXT IDC_TEXT,7,18,254,124,ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL DEFPUSHBUTTON "Import",IDOK,153,149,50,14 PUSHBUTTON "Cancel",IDCANCEL,211,149,50,14 - PUSHBUTTON "Insert &CR/LF",IDC_CRLF,20,149,50,14 - LTEXT "Paste the Settings to import here.",IDC_STATIC,7,7,105, - 8 + PUSHBUTTON "Insert &CR/LF",IDC_CRLF,20,149,58,14 + LTEXT "Paste the Settings to import here.",IDC_STATIC,7,7,105,8 END IDD_MAIN DIALOGEX 0, 0, 408, 225 -STYLE DS_ABSALIGN | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | - WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | - WS_SYSMENU | WS_THICKFRAME +STYLE DS_ABSALIGN | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME CAPTION "DBEditor++" MENU IDR_MAINMENU FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - CONTROL "Tree1",IDC_MODULES,"SysTreeView32",TVS_HASBUTTONS | - TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | - TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | - WS_TABSTOP,0,3,102,222 - CONTROL "List1",IDC_SETTINGS,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_SORTASCENDING | - LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | - WS_TABSTOP,103,3,305,222 + CONTROL "Tree1",IDC_MODULES,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,0,3,102,222 + CONTROL "List1",IDC_SETTINGS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,103,3,305,222 CONTROL "",IDC_SPLITTER,"Static",SS_ENHMETAFILE,102,3,1,222 END @@ -415,18 +311,18 @@ ICO_HANDLE ICON "res\\handle.ico" // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -602,7 +498,7 @@ BEGIN END END -#endif // English (Australia) resources +#endif // Английский (Австралия) resources ///////////////////////////////////////////////////////////////////////////// @@ -616,3 +512,4 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED + diff --git a/dbeditorpp/settinglist.cpp b/dbeditorpp/settinglist.cpp index 78bb941..c3c27cb 100644 --- a/dbeditorpp/settinglist.cpp +++ b/dbeditorpp/settinglist.cpp @@ -1,5 +1,6 @@ #include "headers.h" +int UOS; void setupSettingsList(HWND hwnd2List) { @@ -37,7 +38,7 @@ void saveListSettings(HWND hwnd2List) for (i=0; i <= 3; i++) if (ListView_GetColumn(hwnd2List,i,&sLC)) { - _snprintf(tmp, 32, "Column%dwidth", i); + mir_snprintf(tmp, SIZEOF(tmp), "Column%dwidth", i); DBWriteContactSettingWord(NULL, modname, tmp, (WORD)sLC.cx); } @@ -46,17 +47,17 @@ void saveListSettings(HWND hwnd2List) void ClearListview(HWND hwnd2Settings) { - SettingListInfo *info = (SettingListInfo*)GetWindowLong(hwnd2Settings,GWL_USERDATA); + SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); if (info && ListView_GetItemCount(hwnd2Settings)) { - safe_free(info->module); + mir_free(info->module); if (info->hwnd2Edit) { SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); info->hwnd2Edit = NULL; } - safe_free(info); - SetWindowLong(hwnd2Settings,GWL_USERDATA, 0); + mir_free(info); + SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, 0); } ListView_DeleteAllItems(hwnd2Settings); } @@ -81,7 +82,7 @@ void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char { if (ListView_GetItemState(hSettings,i,LVIS_SELECTED)) { - ListView_GetItemText(hSettings, i, 0, text, sizeof(text)); + ListView_GetItemText(hSettings, i, 0, text, SIZEOF(text)); DBDeleteContactSetting(hContact,module,text); items--; } @@ -102,7 +103,7 @@ void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char if ((int)item.hItem != -1) if (TreeView_GetItem(hModules, &item) && item.lParam) { - safe_free((char*)item.lParam); + mir_free((char*)item.lParam); TreeView_DeleteItem(hModules,item.hItem); } } @@ -125,51 +126,51 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in case DBVT_BLOB: { int j; - if (!(data = (char*)realloc(data, 3*(dbv.cpbVal+1)+10) )) + if (!(data = (char*)mir_realloc(data, 3*(dbv.cpbVal+1)+10) )) {msg(Translate("Couldnt allocate enough memory!"), modFullname); return;} data[0] = '\0'; for (j=0; jhContact = hContact; - info->module = strdup(module); - SetWindowLong(hwnd2Settings,GWL_USERDATA, (LONG)info); + info->module = mir_tstrdup(module); + SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)info); // icons if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); @@ -333,7 +334,10 @@ void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *w if (type != DBVT_ASCIIZ && type != DBVT_UTF8) DBDeleteContactSetting(info->hContact,info->module,info->setting); if (type == DBVT_UTF8 && wc) + { DBWriteContactSettingWString(info->hContact,info->module,info->setting,wc); + mir_free(wc); + } else DBWriteContactSettingString(info->hContact,info->module,info->setting,value); @@ -341,7 +345,7 @@ void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *w static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { - EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLong(hwnd,GWL_USERDATA); + EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLongPtr(hwnd,GWLP_USERDATA); switch(msg) { case WM_KEYDOWN: switch (wParam) @@ -357,7 +361,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w } break; case WM_USER: - SetWindowLong(hwnd,GWL_USERDATA,lParam); + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); SetFocus(hwnd); SendMessage(hwnd, WM_SETFONT, SendMessage(GetParent(hwnd), WM_GETFONT, 0, 0), 1); info = ((EditLabelInfoStruct*)lParam); @@ -375,17 +379,14 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w case IDOK: { int len = GetWindowTextLength(hwnd)+1; - char *value = _alloca(len); + char *value = (char*)_alloca(len); WCHAR *wc = NULL; DBVARIANT dbv = {0}; GetWindowText(hwnd,value,len); if (info->unicode) - { - wc = _alloca(len*sizeof(WCHAR)); - _SendMessageW(hwnd, WM_GETTEXT, len, (LPARAM)wc); - } + wc = mir_a2u(value); if (len <= 1 || GetSetting(info->hContact,info->module,info->setting,&dbv)) { @@ -593,12 +594,12 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w } // fall through case IDCANCEL: { - SettingListInfo *sli = (SettingListInfo*)GetWindowLong(info->hwnd,GWL_USERDATA); + SettingListInfo *sli = (SettingListInfo*)GetWindowLongPtr(info->hwnd,GWLP_USERDATA); if (sli && sli->hwnd2Edit==hwnd) sli->hwnd2Edit = NULL; - safe_free(info); + mir_free(info); DestroyWindow(hwnd); } return 0; @@ -608,7 +609,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w return DLGC_WANTALLKEYS; } if (UOS) - return _CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); + return CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); else return CallWindowProc(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); } @@ -620,8 +621,8 @@ void EditLabel(HWND hwnd2List, int item, int subitem) LVITEM lvi; char setting[256], value[16] = {0}; DBVARIANT dbv; - SettingListInfo* info = (SettingListInfo*)GetWindowLong(hwnd2List,GWL_USERDATA); - EditLabelInfoStruct *data = (EditLabelInfoStruct*)calloc(sizeof(EditLabelInfoStruct),1); + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hwnd2List,GWLP_USERDATA); + EditLabelInfoStruct *data = (EditLabelInfoStruct*)mir_calloc(sizeof(EditLabelInfoStruct)); if (!data || !info) return; if (info->hwnd2Edit) { @@ -639,7 +640,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem) (hwnd2List,item,subitem,LVIR_LABEL,&rc) || GetSetting(info->hContact,info->module,setting,&dbv)) { - safe_free(data); + mir_free(data); return; } @@ -658,10 +659,10 @@ void EditLabel(HWND hwnd2List, int item, int subitem) if (subitem && UOS) { int len = mir_strlen(dbv.pszVal)+1; - WCHAR *wc = _alloca(len*sizeof(WCHAR)); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); data->unicode = 1; - info->hwnd2Edit = _CreateWindowW(L"EDIT",wc,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0); + info->hwnd2Edit = CreateWindowW(L"EDIT",wc,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0); break; } // fall through @@ -675,21 +676,21 @@ void EditLabel(HWND hwnd2List, int item, int subitem) break; case DBVT_BYTE: if (Hex&HEX_BYTE) - _snprintf(value,15,"0x%02X",dbv.bVal); + mir_snprintf(value, SIZEOF(value), "0x%02X", dbv.bVal); else itoa(dbv.bVal,value,10); info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); break; case DBVT_WORD: if (Hex&HEX_WORD) - _snprintf(value,15,"0x%04X",dbv.wVal); + mir_snprintf(value, SIZEOF(value), "0x%04X", dbv.wVal); else itoa(dbv.wVal,value,10); info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); break; case DBVT_DWORD: if (Hex&HEX_DWORD) - _snprintf(value,15,"0x%08X",dbv.dVal); + mir_snprintf(value, SIZEOF(value), "0x%08X", dbv.dVal); else itoa(dbv.dVal,value,10); info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); @@ -708,7 +709,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem) for(j=0; jhwnd2Edit,GWL_WNDPROC,(LONG)SettingLabelEditSubClassProc); + SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtrW(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); else - SettingLabelEditSubClass=(WNDPROC)SetWindowLong(info->hwnd2Edit,GWL_WNDPROC,(LONG)SettingLabelEditSubClassProc); + SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtr(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); SendMessage(info->hwnd2Edit,WM_USER,0,(LPARAM)data); } @@ -736,7 +737,7 @@ void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { case NM_CLICK: { - SettingListInfo* info = (SettingListInfo*)GetWindowLong(GetDlgItem(hwnd,IDC_SETTINGS),GWL_USERDATA); + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA); LVHITTESTINFO hti; hti.pt=((NMLISTVIEW*)lParam)->ptAction; @@ -776,7 +777,7 @@ void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) break; case NM_DBLCLK: { - SettingListInfo* info = (SettingListInfo*)GetWindowLong(GetDlgItem(hwnd,IDC_SETTINGS),GWL_USERDATA); + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA); LVHITTESTINFO hti; @@ -805,7 +806,7 @@ void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here is to the main window, NOT the listview { HWND hSettings = GetDlgItem(hwnd,IDC_SETTINGS); - SettingListInfo* info = (SettingListInfo*)GetWindowLong(hSettings,GWL_USERDATA); + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hSettings,GWLP_USERDATA); char setting[256], *module; HANDLE hContact; LVHITTESTINFO hti; @@ -832,77 +833,77 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here { case MENU_ADD_BYTE: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_BYTE; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_WORD: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_WORD; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_DWORD: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_DWORD; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_STRING: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_ASCIIZ; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_UNICODE: if (UDB) { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_UTF8; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); if (UOS) - _CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); else CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_BLOB: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_BLOB; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; @@ -1016,77 +1017,77 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here //////////////////////// NEW item submenu case MENU_ADD_BYTE: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_BYTE; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_WORD: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_WORD; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_DWORD: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_DWORD; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_STRING: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_ASCIIZ; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_UNICODE: if (UDB) { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_UTF8; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); if (UOS) - _CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); else CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_BLOB: { - struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog dbv.type = DBVT_BLOB; dbsetting->dbv = dbv; dbsetting->hContact = hContact; - dbsetting->module = strdup(module); - dbsetting->setting = strdup(""); + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; @@ -1130,13 +1131,37 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here case MENU_VIEWDECRYPT: { DBVARIANT dbv; - char *text; if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) { - text = strdup(dbv.pszVal); - CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - msg(text, "Decoded string.."); - safe_free(text); + if (lstrcmpA(setting, "LoginPassword")) + { + char *text = mir_strdup(dbv.pszVal); + CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text); + msg(text, Translate("Decoded string..")); + mir_free(text); + } + else + { + char *str = mir_strdup(dbv.pszVal); + char *str1 = str; + for (;*str1; ++str1) + { + const char c = *str1 ^ 0xc3; + if (c) *str1 = c; + } + if (UOS) + { + WCHAR *res = mir_utf8decodeW(str); + MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); + mir_free(res); + } + else + { + mir_utf8decode(str, NULL); + MessageBoxA(0, str, Translate("Decoded string.."),MB_OK); + } + mir_free(str); + } } DBFreeVariant(&dbv); } @@ -1147,10 +1172,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here char *text; if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) { - text = strdup(dbv.pszVal); + text = mir_tstrdup(dbv.pszVal); CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - msg(text, "Encoded string.."); - safe_free(text); + msg(text, Translate("Encoded string..")); + mir_free(text); } DBFreeVariant(&dbv); } @@ -1161,10 +1186,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here char *text; if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) { - text = strdup(dbv.pszVal); + text = mir_tstrdup(dbv.pszVal); CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); DBWriteContactSettingString(hContact,module,setting,text); - safe_free(text); + mir_free(text); } DBFreeVariant(&dbv); } @@ -1175,10 +1200,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here char *text; if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) { - text = strdup(dbv.pszVal); + text = mir_tstrdup(dbv.pszVal); CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); DBWriteContactSettingString(hContact,module,setting,text); - safe_free(text); + mir_free(text); } DBFreeVariant(&dbv); } diff --git a/dbeditorpp/watchedvars.cpp b/dbeditorpp/watchedvars.cpp index f0959c4..08813de 100644 --- a/dbeditorpp/watchedvars.cpp +++ b/dbeditorpp/watchedvars.cpp @@ -1,18 +1,17 @@ #include "headers.h" - int addSettingToWatchList(HANDLE hContact, char* module, char* setting) { if (WatchListArray.count == WatchListArray.size) { WatchListArray.size += 32; - WatchListArray.item = (struct DBsetting*)realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); + WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); } if (!WatchListArray.item) return 0; if (setting && DBGetContactSetting(hContact,module, setting, &(WatchListArray.item[WatchListArray.count].dbv))) return 0; WatchListArray.item[WatchListArray.count].hContact = hContact; - WatchListArray.item[WatchListArray.count].module = strdup(module); - if (setting) WatchListArray.item[WatchListArray.count].setting = strdup(setting); + WatchListArray.item[WatchListArray.count].module = mir_tstrdup(module); + if (setting) WatchListArray.item[WatchListArray.count].setting = mir_tstrdup(setting); else WatchListArray.item[WatchListArray.count].setting = 0; WatchListArray.item[WatchListArray.count].WatchModule = setting?WATCH_SETTING:WATCH_MODULE; @@ -22,9 +21,9 @@ int addSettingToWatchList(HANDLE hContact, char* module, char* setting) void freeWatchListItem(int item) { - if (WatchListArray.item[item].module) safe_free(WatchListArray.item[item].module); + if (WatchListArray.item[item].module) mir_free(WatchListArray.item[item].module); WatchListArray.item[item].module = 0; - if (WatchListArray.item[item].setting) safe_free(WatchListArray.item[item].setting); + if (WatchListArray.item[item].setting) mir_free(WatchListArray.item[item].setting); WatchListArray.item[item].setting = 0; DBFreeVariant(&(WatchListArray.item[item].dbv)); WatchListArray.item[item].hContact = 0; @@ -53,7 +52,7 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) struct ModSetLinkLinkItem *setting; if (!EnumSettings(hContact,module,&settinglist)) return; dummy.hContact = hContact; - dummy.module = strdup(module); + dummy.module = mir_tstrdup(module); setting = settinglist.first; while (setting) { @@ -61,7 +60,7 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) addwatchtolist(hwnd2list, &dummy); setting = (struct ModSetLinkLinkItem *)setting->next; } - safe_free(dummy.module); + mir_free(dummy.module); FreeModuleSettingLL(&settinglist); return; } @@ -76,7 +75,11 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) index = ListView_InsertItem(hwnd2list,&lvItem); if (UOS) - ListView_SetItemTextW(hwnd2list,index,0,(WCHAR*)lvItem.pszText); + { + WCHAR* ptszText = mir_a2u(lvItem.pszText); + ListView_SetItemTextW(hwnd2list, index, 0, ptszText); + mir_free(ptszText); + } ListView_SetItemText(hwnd2list,index,1,module); ListView_SetItemText(hwnd2list,index,2,setting); @@ -87,32 +90,32 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) { int j; char *data = NULL; - if (!(data = (char*)realloc(data, 3*(dbv->cpbVal+1)) )) + if (!(data = (char*)mir_realloc(data, 3*(dbv->cpbVal+1)) )) return; data[0] = '\0'; for (j=0; jcpbVal; j++) { char tmp[16]; - _snprintf(tmp, 16, "%02X ", (BYTE)dbv->pbVal[j]); + mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv->pbVal[j]); strcat(data, tmp); } ListView_SetItemText(hwnd2list,index,4,data); ListView_SetItemText(hwnd2list,index,3,"BLOB"); - safe_free(data); + mir_free(data); } break; case DBVT_BYTE: - _snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); + mir_snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); ListView_SetItemText(hwnd2list,index,4,data); ListView_SetItemText(hwnd2list,index,3,"BYTE"); break; case DBVT_WORD: - _snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); + mir_snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); ListView_SetItemText(hwnd2list,index,4,data); ListView_SetItemText(hwnd2list,index,3,"WORD"); break; case DBVT_DWORD: - _snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); + mir_snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); ListView_SetItemText(hwnd2list,index,4,data); ListView_SetItemText(hwnd2list,index,3,"DWORD"); break; @@ -124,8 +127,8 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) { if (UOS) { - int length = strlen(dbv->pszVal)+1; - WCHAR *wc = _alloca(length*sizeof(WCHAR)); + int length = (int)strlen(dbv->pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, dbv->pszVal, -1, wc, length); ListView_SetItemTextW(hwnd2list,index,4,wc); } @@ -157,7 +160,7 @@ void freeAllWatches() { freeWatchListItem(i); } - safe_free(WatchListArray.item); + mir_free(WatchListArray.item); WatchListArray.item = 0; WatchListArray.count = 0; } @@ -174,9 +177,9 @@ int WatchDialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; } return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; - } -BOOL CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + +INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -336,8 +339,8 @@ void popupWatchedVar(HANDLE hContact,const char* module,const char* setting) { // contacts nick char szProto[256]; - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) - mir_snprintf(lpzContactName, MAX_SECONDLINE,"%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + mir_snprintf(lpzContactName, MAX_SECONDLINE, "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); else mir_snprintf(lpzContactName, MAX_SECONDLINE, nick_unknown); } @@ -351,19 +354,19 @@ void popupWatchedVar(HANDLE hContact,const char* module,const char* setting) switch (dbv.type) { case DBVT_BYTE: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal); break; case DBVT_WORD: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal); break; case DBVT_DWORD: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal); break; case DBVT_ASCIIZ: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal); break; case DBVT_UTF8: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal); break; default: return; -- cgit v1.2.3