summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-11-24 14:52:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-11-24 14:52:14 +0300
commitbaa0c8ab5a4e5dc7a94a6bb0b8be095a760f48d0 (patch)
treed4a6b214ca5407cbc236f61190e9e7ec91cea929 /plugins/DbEditorPP
parent7394160d234881ab31ba5f5e996e052ef5002b6c (diff)
dbeditor:
- code cleaning - version bump
Diffstat (limited to 'plugins/DbEditorPP')
-rw-r--r--plugins/DbEditorPP/src/copymodule.cpp2
-rw-r--r--plugins/DbEditorPP/src/deletemodule.cpp3
-rw-r--r--plugins/DbEditorPP/src/modsettingenum.cpp20
-rw-r--r--plugins/DbEditorPP/src/moduletree.cpp7
-rw-r--r--plugins/DbEditorPP/src/options.cpp25
-rw-r--r--plugins/DbEditorPP/src/renamemodule.cpp12
-rw-r--r--plugins/DbEditorPP/src/settinglist.cpp36
-rw-r--r--plugins/DbEditorPP/src/settingsdlg.cpp363
-rw-r--r--plugins/DbEditorPP/src/version.h2
9 files changed, 201 insertions, 269 deletions
diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp
index 95a27b2f68..419efd7ff7 100644
--- a/plugins/DbEditorPP/src/copymodule.cpp
+++ b/plugins/DbEditorPP/src/copymodule.cpp
@@ -3,7 +3,6 @@
void copyModule(const char *module, MCONTACT hContactFrom, MCONTACT hContactTo)
{
ModuleSettingLL msll;
-
if (IsModuleEmpty(hContactFrom, module) || !EnumSettings(hContactFrom, module, &msll))
return;
@@ -97,7 +96,6 @@ int CloneContact(MCONTACT hContact)
// enum all the modules
ModuleSettingLL modlist;
-
if (!EnumModules(&modlist))
return 0;
diff --git a/plugins/DbEditorPP/src/deletemodule.cpp b/plugins/DbEditorPP/src/deletemodule.cpp
index 62e63426fd..41b3a123ed 100644
--- a/plugins/DbEditorPP/src/deletemodule.cpp
+++ b/plugins/DbEditorPP/src/deletemodule.cpp
@@ -19,9 +19,8 @@ int deleteModule(MCONTACT hContact, const char *module, int confirm)
if (!EnumSettings(hContact, module, &settinglist))
return 0;
- for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next) {
+ for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next)
db_unset(hContact, module, setting->name);
- }
FreeModuleSettingLL(&settinglist);
return 1;
diff --git a/plugins/DbEditorPP/src/modsettingenum.cpp b/plugins/DbEditorPP/src/modsettingenum.cpp
index 9e4ee6c580..e0a4d40ba1 100644
--- a/plugins/DbEditorPP/src/modsettingenum.cpp
+++ b/plugins/DbEditorPP/src/modsettingenum.cpp
@@ -1,17 +1,15 @@
#include "stdafx.h"
-
void FreeModuleSettingLL(ModuleSettingLL *msll)
{
if (msll == nullptr)
return;
ModSetLinkLinkItem *item = msll->first;
- ModSetLinkLinkItem *temp;
while (item) {
mir_free(item->name);
- temp = item;
+ ModSetLinkLinkItem *temp = item;
item = (ModSetLinkLinkItem *)item->next;
mir_free(temp);
}
@@ -20,7 +18,6 @@ void FreeModuleSettingLL(ModuleSettingLL *msll)
msll->last = nullptr;
}
-
int enumModulesSettingsProc(const char *setting, void *pParam)
{
ModuleSettingLL *msll = (ModuleSettingLL *)pParam;
@@ -46,7 +43,6 @@ int enumModulesSettingsProc(const char *setting, void *pParam)
return 0;
}
-
int EnumModules(ModuleSettingLL *msll) // 1 = success, 0 = fail
{
msll->first = nullptr;
@@ -58,13 +54,11 @@ int EnumModules(ModuleSettingLL *msll) // 1 = success, 0 = fail
return 1;
}
-
int enumSettingsProc(const char *setting, void *lParam)
{
return enumModulesSettingsProc(setting, lParam);
}
-
int EnumSettings(MCONTACT hContact, const char *module, ModuleSettingLL *msll)
{
// enum all setting the contact has for the module
@@ -77,25 +71,21 @@ int EnumSettings(MCONTACT hContact, const char *module, ModuleSettingLL *msll)
return 1;
}
-
int CheckIfModuleIsEmptyProc(const char*, void*)
{
return 1;
}
-
int IsModuleEmpty(MCONTACT hContact, const char *module)
{
return 0 > db_enum_settings(hContact, CheckIfModuleIsEmptyProc, module);
}
-
static int stringCompare(const char *p1, const char *p2)
{
return mir_strcmp(p1, p2);
}
-
LIST<char> m_lResidentSettings(10, stringCompare);
int enumResidentProc(const char *setting, void*)
@@ -104,7 +94,6 @@ int enumResidentProc(const char *setting, void*)
return 0;
}
-
int LoadResidentSettings()
{
if (g_db)
@@ -112,16 +101,14 @@ int LoadResidentSettings()
return 0;
}
-
void FreeResidentSettings()
{
- for (int i = 0; i < m_lResidentSettings.getCount(); i++) {
+ for (int i = 0; i < m_lResidentSettings.getCount(); i++)
mir_free(m_lResidentSettings[i]);
- }
+
m_lResidentSettings.destroy();
}
-
int IsResidentSetting(const char *module, const char *setting)
{
if (!m_lResidentSettings.getCount()) return 0;
@@ -134,7 +121,6 @@ int IsResidentSetting(const char *module, const char *setting)
return m_lResidentSettings.getIndex(str) != -1;
}
-
int EnumResidentSettings(const char *module, ModuleSettingLL *msll)
{
msll->first = nullptr;
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp
index 6abd34c7ec..e23dfe866a 100644
--- a/plugins/DbEditorPP/src/moduletree.cpp
+++ b/plugins/DbEditorPP/src/moduletree.cpp
@@ -8,7 +8,6 @@ volatile int Select = 0;
static ModuleTreeInfoStruct contacts_mtis = { CONTACT_ROOT_ITEM, 0 };
static ModuleTreeInfoStruct settings_mtis = { CONTACT, 0 };
-
void insertItem(MCONTACT hContact, const char *module, HTREEITEM hParent)
{
_A2T text(module);
@@ -30,7 +29,6 @@ void insertItem(MCONTACT hContact, const char *module, HTREEITEM hParent)
TreeView_InsertItem(hwnd2Tree, &tvi);
}
-
int doContacts(HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelectedContact, const char *selectedModule, const char *selectedSetting)
{
TVINSERTSTRUCT tvi;
@@ -79,7 +77,6 @@ int doContacts(HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelec
itemscount++;
if (hSelectedContact == hContact) {
-
for (ModSetLinkLinkItem *module = modlist->first; module && hwnd2mainWindow; module = module->next) {
if (!module->name[0] || IsModuleEmpty(hContact, module->name))
continue;
@@ -100,7 +97,6 @@ int doContacts(HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelec
return itemscount;
}
-
void doItems(ModuleSettingLL* modlist, int count)
{
HWND hwnd = GetParent(hwnd2Tree); //!!!
@@ -273,7 +269,6 @@ http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?t
return Result;
}
-
void replaceTreeItem(MCONTACT hContact, const char* module, const char* newModule)
{
HTREEITEM hItem = findItemInTree(hContact, module);
@@ -301,7 +296,6 @@ void replaceTreeItem(MCONTACT hContact, const char* module, const char* newModul
}
}
-
void __cdecl PopulateModuleTreeThreadFunc(LPVOID param)
{
char SelectedModule[FLD_SIZE] = "";
@@ -789,5 +783,4 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t
break;
}
DestroyMenu(hMenu);
-
}
diff --git a/plugins/DbEditorPP/src/options.cpp b/plugins/DbEditorPP/src/options.cpp
index 3e2ca49646..12a60c0693 100644
--- a/plugins/DbEditorPP/src/options.cpp
+++ b/plugins/DbEditorPP/src/options.cpp
@@ -1,12 +1,10 @@
#include "stdafx.h"
-INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bool bInitDone = true;
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
bInitDone = false;
CheckDlgButton(hwnd, IDC_EXPANDSETTINGS, db_get_b(NULL, modname, "ExpandSettingsOnOpen", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_RESTORESETTINGS, db_get_b(NULL, modname, "RestoreOnOpen", 1) ? BST_CHECKED : BST_UNCHECKED);
@@ -16,11 +14,10 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)db_get_dw(NULL, modname, "PopupColour", RGB(255, 0, 0)));
TranslateDialogDefault(hwnd);
bInitDone = true;
- }
- return TRUE;
+ return TRUE;
+
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case IDC_RESTORESETTINGS:
case IDC_EXPANDSETTINGS:
case IDC_POPUPS:
@@ -28,20 +25,19 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_COLOUR:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
+
case IDC_POPUPTIMEOUT:
if (bInitDone && (HIWORD(wParam) == EN_CHANGE))
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
}
break;
+
case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom)
- {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
- switch (((LPNMHDR)lParam)->code)
- {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- {
db_set_b(NULL, modname, "ExpandSettingsOnOpen", (BYTE)IsDlgButtonChecked(hwnd, IDC_EXPANDSETTINGS));
db_set_b(NULL, modname, "RestoreOnOpen", (BYTE)IsDlgButtonChecked(hwnd, IDC_RESTORESETTINGS));
db_set_b(NULL, modname, "WarnOnDelete", (BYTE)IsDlgButtonChecked(hwnd, IDC_WARNONDEL));
@@ -49,8 +45,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
db_set_b(NULL, modname, "UsePopUps", (BYTE)g_bUsePopups);
db_set_w(NULL, modname, "PopupDelay", (WORD)GetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, nullptr, 0));
db_set_dw(NULL, modname, "PopupColour", (DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0));
- }
- return TRUE;
+ return TRUE;
}
break;
}
diff --git a/plugins/DbEditorPP/src/renamemodule.cpp b/plugins/DbEditorPP/src/renamemodule.cpp
index 3f87c49644..74e9e00a4a 100644
--- a/plugins/DbEditorPP/src/renamemodule.cpp
+++ b/plugins/DbEditorPP/src/renamemodule.cpp
@@ -1,19 +1,17 @@
#include "stdafx.h"
-
int renameModule(MCONTACT hContact, const char *oldName, const char *newName)
{
- DBVARIANT dbv;
ModuleSettingLL settinglist;
-
if (IsModuleEmpty(hContact, oldName) || !EnumSettings(hContact, oldName, &settinglist))
- return 0;
+ return 0;
int cnt = 0;
- for(ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next) {
+ for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next) {
+ DBVARIANT dbv;
if (!db_get_s(hContact, oldName, setting->name, &dbv, 0)) {
- db_set(hContact, newName, setting->name, &dbv);
+ db_set(hContact, newName, setting->name, &dbv);
db_unset(hContact, oldName, setting->name);
db_free(&dbv);
cnt++;
@@ -23,7 +21,7 @@ int renameModule(MCONTACT hContact, const char *oldName, const char *newName)
return cnt;
}
-INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp
index 8718da8bec..26f5a6f9f7 100644
--- a/plugins/DbEditorPP/src/settinglist.cpp
+++ b/plugins/DbEditorPP/src/settinglist.cpp
@@ -26,7 +26,6 @@ int ListView_GetItemTextA(HWND hwndLV, int i, int iSubItem, char *pszText, int c
return SendMessageA(hwndLV, LVM_GETITEMTEXTA, (WPARAM)(i), (LPARAM)(LV_ITEMA *)&lvi);
}
-
int ListView_SetItemTextA(HWND hwndLV, int i, int iSubItem, const char *pszText)
{
LV_ITEMA lvi;
@@ -35,7 +34,6 @@ int ListView_SetItemTextA(HWND hwndLV, int i, int iSubItem, const char *pszText)
return SendMessageA(hwndLV, LVM_SETITEMTEXTA, (WPARAM)(i), (LPARAM)(LV_ITEMA *)&lvi);
}
-
int convertSetting(MCONTACT hContact, const char *module, const char *setting, int toType)
{
DBVARIANT dbv = { 0 };
@@ -78,7 +76,6 @@ int convertSetting(MCONTACT hContact, const char *module, const char *setting, i
}
switch (toType) {
-
case DBVT_BYTE:
case DBVT_WORD:
case DBVT_DWORD:
@@ -103,7 +100,6 @@ int convertSetting(MCONTACT hContact, const char *module, const char *setting, i
return res;
}
-
void EditFinish(int selected)
{
if (info.hwnd2Edit) {
@@ -113,7 +109,6 @@ void EditFinish(int selected)
info.selectedItem = selected;
}
-
void ClearListView()
{
EditFinish(0);
@@ -124,7 +119,6 @@ void ClearListView()
ListView_DeleteAllItems(hwnd2List);
}
-
void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *setting)
{
int count = ListView_GetSelectedCount(hwnd2List);
@@ -160,7 +154,6 @@ void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *s
replaceTreeItem(hContact, module, nullptr);
}
-
int findListItem(const char *setting)
{
if (!setting || !setting[0]) return -1;
@@ -172,7 +165,6 @@ int findListItem(const char *setting)
return SendMessageA(hwnd2List, LVM_FINDITEMA, -1, (LPARAM)&lvfi);
}
-
void deleteListItem(const char *setting)
{
int item = findListItem(setting);
@@ -180,7 +172,6 @@ void deleteListItem(const char *setting)
ListView_DeleteItem(hwnd2List, item);
}
-
void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident)
{
if (!dbv || !dbv->type) {
@@ -292,7 +283,6 @@ void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident
ListView_SetItemText(hwnd2List, index, 2, DBVType(dbv->type));
}
-
void addListHandle(MCONTACT hContact)
{
wchar_t name[NAME_SIZE], data[32];
@@ -322,7 +312,6 @@ void addListHandle(MCONTACT hContact)
}
}
-
void addListItem(const char *setting, int resident)
{
DBVARIANT dbv;
@@ -334,18 +323,16 @@ void addListItem(const char *setting, int resident)
updateListItem(index, setting, &dbv, resident);
db_free(&dbv);
}
- else
- if (!resident) {
- LVITEMA lvi = { 0 };
- lvi.mask = LVIF_TEXT;
- lvi.pszText = (char*)setting;
- int index = SendMessageA(hwnd2List, LVM_INSERTITEMA, 0, (LPARAM)&lvi);
- ListView_SetItemText(hwnd2List, index, 1, TranslateT("*** buggy resident ***"));
- return;
- }
+ else if (!resident) {
+ LVITEMA lvi = { 0 };
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = (char*)setting;
+ int index = SendMessageA(hwnd2List, LVM_INSERTITEMA, 0, (LPARAM)&lvi);
+ ListView_SetItemText(hwnd2List, index, 1, TranslateT("*** buggy resident ***"));
+ return;
+ }
}
-
void PopulateSettings(MCONTACT hContact, const char *module)
{
// save module as it can be erased by ClearListView()
@@ -359,7 +346,6 @@ void PopulateSettings(MCONTACT hContact, const char *module)
mir_strncpy(info.module, tmp, _countof(info.module));
ModuleSettingLL setlist;
-
if (IsModuleEmpty(info.hContact, info.module) || !EnumSettings(info.hContact, info.module, &setlist))
return;
@@ -378,7 +364,6 @@ void PopulateSettings(MCONTACT hContact, const char *module)
FreeModuleSettingLL(&setlist);
}
-
void SelectSetting(const char *setting)
{
LVITEM lvItem = { 0 };
@@ -401,7 +386,6 @@ void SelectSetting(const char *setting)
}
}
-
void settingChanged(MCONTACT hContact, const char *module, const char *setting, DBVARIANT *dbv)
{
// modules tree
@@ -433,7 +417,6 @@ void settingChanged(MCONTACT hContact, const char *module, const char *setting,
}
}
-
static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
@@ -683,10 +666,8 @@ void EditLabel(int item, int subitem)
SendMessage(info.hwnd2Edit, WM_USER, 0, 0);
}
-
void SettingsListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam);
-
void SettingsListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)
{
LVHITTESTINFO hti;
@@ -745,7 +726,6 @@ void SettingsListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)
}
}
-
void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to the main window, NOT the listview
{
LVHITTESTINFO hti;
diff --git a/plugins/DbEditorPP/src/settingsdlg.cpp b/plugins/DbEditorPP/src/settingsdlg.cpp
index 0690d65b62..30ddd1b373 100644
--- a/plugins/DbEditorPP/src/settingsdlg.cpp
+++ b/plugins/DbEditorPP/src/settingsdlg.cpp
@@ -2,8 +2,8 @@
int saveAsType(HWND hwnd, int original)
{
- if (!IsWindowVisible(GetDlgItem(hwnd, GRP_TYPE)))
- return original;
+ if (!IsWindowVisible(GetDlgItem(hwnd, GRP_TYPE)))
+ return original;
if (IsDlgButtonChecked(hwnd, CHK_BYTE))
return DBVT_BYTE;
@@ -14,132 +14,126 @@ int saveAsType(HWND hwnd, int original)
else if (IsDlgButtonChecked(hwnd, CHK_STRING))
return DBVT_ASCIIZ;
- return original;
+ return original;
}
-
INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
-
- struct DBsetting *dbsetting = (struct DBsetting*)lParam;
-
- char val[16] = {0};
- int convert = 0;
-
- switch (dbsetting->dbv.type)
{
- case DBVT_BYTE:
- CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE);
- ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
- CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, (g_Hex & HEX_BYTE) ? CHK_HEX : CHK_DECIMAL);
- if (dbsetting->setting) mir_snprintf(val, (g_Hex & HEX_BYTE) ? "0x%02X" : "%u", dbsetting->dbv.bVal);
- break;
- case DBVT_WORD:
- CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD);
- ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
- CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, (g_Hex & HEX_WORD) ? CHK_HEX : CHK_DECIMAL);
- if (dbsetting->setting) mir_snprintf(val, (g_Hex & HEX_WORD) ? "0x%04X" : "%u", dbsetting->dbv.wVal);
- break;
- case DBVT_DWORD:
- CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD);
- ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
- CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, (g_Hex & HEX_DWORD) ? CHK_HEX : CHK_DECIMAL);
- if (dbsetting->setting) mir_snprintf(val, (g_Hex & HEX_DWORD) ? "0x%08X" : "%u", dbsetting->dbv.dVal);
- break;
-
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- case DBVT_WCHAR:
- ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_SHOW);
- ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_HEX), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, GRP_BASE), SW_HIDE);
- break;
-
- case DBVT_BLOB:
- ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, IDC_BLOB), SW_SHOW);
- ShowWindow(GetDlgItem(hwnd, CHK_HEX), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, GRP_BASE), SW_HIDE);
- break;
-
- case DBVT_DELETED: // resident
- CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_STRING);
- CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL);
- convert = 1;
- break;
-
- default:
- msg(TranslateT("Unknown DBVariant type!"));
- DestroyWindow(hwnd);
- return TRUE;
- }
+ struct DBsetting *dbsetting = (struct DBsetting*)lParam;
+ char val[16] = { 0 };
+ int convert = 0;
- if (dbsetting->setting) {
- SetDlgItemTextA(hwnd, IDC_SETTINGNAME, dbsetting->setting);
-
- switch (dbsetting->dbv.type)
- {
+ switch (dbsetting->dbv.type) {
case DBVT_BYTE:
+ CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE);
+ ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
+ CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, (g_Hex & HEX_BYTE) ? CHK_HEX : CHK_DECIMAL);
+ if (dbsetting->setting) mir_snprintf(val, (g_Hex & HEX_BYTE) ? "0x%02X" : "%u", dbsetting->dbv.bVal);
+ break;
case DBVT_WORD:
+ CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD);
+ ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
+ CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, (g_Hex & HEX_WORD) ? CHK_HEX : CHK_DECIMAL);
+ if (dbsetting->setting) mir_snprintf(val, (g_Hex & HEX_WORD) ? "0x%04X" : "%u", dbsetting->dbv.wVal);
+ break;
case DBVT_DWORD:
- SetDlgItemTextA(hwnd, IDC_SETTINGVALUE, val);
- convert = 1;
+ CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD);
+ ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
+ CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, (g_Hex & HEX_DWORD) ? CHK_HEX : CHK_DECIMAL);
+ if (dbsetting->setting) mir_snprintf(val, (g_Hex & HEX_DWORD) ? "0x%08X" : "%u", dbsetting->dbv.dVal);
break;
case DBVT_ASCIIZ:
- SetDlgItemTextA(hwnd, IDC_STRING, dbsetting->dbv.pszVal);
+ case DBVT_UTF8:
+ case DBVT_WCHAR:
+ ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_SHOW);
+ ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_HEX), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, GRP_BASE), SW_HIDE);
break;
- case DBVT_WCHAR:
- SetDlgItemTextW(hwnd, IDC_STRING, dbsetting->dbv.pwszVal);
+ case DBVT_BLOB:
+ ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, IDC_BLOB), SW_SHOW);
+ ShowWindow(GetDlgItem(hwnd, CHK_HEX), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, GRP_BASE), SW_HIDE);
break;
- case DBVT_UTF8:
- {
- ptrW tmp(mir_utf8decodeW(dbsetting->dbv.pszVal));
- SetDlgItemTextW(hwnd, IDC_STRING, tmp);
+ case DBVT_DELETED: // resident
+ CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_STRING);
+ CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL);
+ convert = 1;
+ break;
+
+ default:
+ msg(TranslateT("Unknown DBVariant type!"));
+ DestroyWindow(hwnd);
+ return TRUE;
+ }
+
+
+ if (dbsetting->setting) {
+ SetDlgItemTextA(hwnd, IDC_SETTINGNAME, dbsetting->setting);
+
+ switch (dbsetting->dbv.type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ SetDlgItemTextA(hwnd, IDC_SETTINGVALUE, val);
+ convert = 1;
break;
- }
- case DBVT_BLOB:
- {
- ptrA tmp(StringFromBlob(dbsetting->dbv.pbVal, dbsetting->dbv.cpbVal));
- SetDlgItemTextA(hwnd, IDC_BLOB, tmp);
+ case DBVT_ASCIIZ:
+ SetDlgItemTextA(hwnd, IDC_STRING, dbsetting->dbv.pszVal);
+ break;
+
+ case DBVT_WCHAR:
+ SetDlgItemTextW(hwnd, IDC_STRING, dbsetting->dbv.pwszVal);
break;
+
+ case DBVT_UTF8:
+ {
+ ptrW tmp(mir_utf8decodeW(dbsetting->dbv.pszVal));
+ SetDlgItemTextW(hwnd, IDC_STRING, tmp);
+ break;
+ }
+
+ case DBVT_BLOB:
+ {
+ ptrA tmp(StringFromBlob(dbsetting->dbv.pbVal, dbsetting->dbv.cpbVal));
+ SetDlgItemTextA(hwnd, IDC_BLOB, tmp);
+ break;
+ }
}
}
- }
- if (!convert) {
- ShowWindow(GetDlgItem(hwnd, GRP_TYPE), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_BYTE), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_WORD), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_DWORD), SW_HIDE);
- ShowWindow(GetDlgItem(hwnd, CHK_STRING), SW_HIDE);
- }
+ if (!convert) {
+ ShowWindow(GetDlgItem(hwnd, GRP_TYPE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_BYTE), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_WORD), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_DWORD), SW_HIDE);
+ ShowWindow(GetDlgItem(hwnd, CHK_STRING), SW_HIDE);
+ }
- TranslateDialogDefault(hwnd);
- {
- wchar_t text[MSG_SIZE];
- mir_snwprintf(text, dbsetting->setting?TranslateT("Edit setting (%s)"):TranslateT("New setting (%s)"), DBVType(dbsetting->dbv.type));
- SetWindowText(hwnd, text);
+ TranslateDialogDefault(hwnd);
+ {
+ wchar_t text[MSG_SIZE];
+ mir_snwprintf(text, dbsetting->setting ? TranslateT("Edit setting (%s)") : TranslateT("New setting (%s)"), DBVType(dbsetting->dbv.type));
+ SetWindowText(hwnd, text);
+ }
}
- }
- return TRUE;
+ return TRUE;
case WM_COMMAND:
- switch (LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
case CHK_BYTE:
case CHK_WORD:
case CHK_DWORD:
@@ -160,17 +154,14 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
wchar_t *setting, text[32];
int settingLength, tmp;
settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGVALUE));
- if (settingLength)
- {
- setting = (wchar_t*)mir_alloc((settingLength+1)*sizeof(wchar_t));
+ if (settingLength) {
+ setting = (wchar_t*)mir_alloc((settingLength + 1) * sizeof(wchar_t));
GetDlgItemText(hwnd, IDC_SETTINGVALUE, setting, settingLength + 1);
- if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL))
- {
+ if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL)) {
swscanf(setting, L"%X", &tmp);
mir_snwprintf(text, L"%u", tmp);
}
- else
- {
+ else {
swscanf(setting, L"%u", &tmp);
mir_snwprintf(text, L"%X", tmp);
}
@@ -185,131 +176,124 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
break;
case IDOK:
- {
- struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
-
- wchar_t settingname[FLD_SIZE];
- GetDlgItemText(hwnd, IDC_SETTINGNAME, settingname, _countof(settingname));
-
- if (settingname[0])
{
- int valueID = 0;
-
- switch (dbsetting->dbv.type)
- {
- case DBVT_BYTE:
- case DBVT_WORD:
- case DBVT_DWORD:
- case DBVT_DELETED:
- valueID = IDC_SETTINGVALUE;
- break;
-
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- case DBVT_WCHAR:
- valueID = IDC_STRING;
- break;
-
- case DBVT_BLOB:
- valueID = IDC_BLOB;
- break;
- default:
- break;
- }
-
- if (!valueID)
- break;
-
- int len = GetWindowTextLength(GetDlgItem(hwnd, valueID))+1;
- wchar_t *value = (wchar_t*)mir_alloc(len*sizeof(wchar_t));
-
- GetDlgItemText(hwnd, valueID, value, len);
- _T2A setting(settingname);
+ struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+ wchar_t settingname[FLD_SIZE];
+ GetDlgItemText(hwnd, IDC_SETTINGNAME, settingname, _countof(settingname));
+
+ if (settingname[0]) {
+ int valueID = 0;
+
+ switch (dbsetting->dbv.type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ case DBVT_DELETED:
+ valueID = IDC_SETTINGVALUE;
+ break;
+
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ case DBVT_WCHAR:
+ valueID = IDC_STRING;
+ break;
+
+ case DBVT_BLOB:
+ valueID = IDC_BLOB;
+ break;
+ default:
+ break;
+ }
- int type = saveAsType(hwnd, dbsetting->dbv.type);
- int res = 0;
+ if (!valueID)
+ break;
+
+ int len = GetWindowTextLength(GetDlgItem(hwnd, valueID)) + 1;
+ wchar_t *value = (wchar_t*)mir_alloc(len * sizeof(wchar_t));
+
+ GetDlgItemText(hwnd, valueID, value, len);
+ _T2A setting(settingname);
+
+ int type = saveAsType(hwnd, dbsetting->dbv.type);
+ int res = 0;
+
+ // write the setting
+ switch (type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ res = setNumericValue(dbsetting->hContact, dbsetting->module, setting, wcstoul(value, nullptr, IsDlgButtonChecked(hwnd, CHK_HEX) ? 16 : 10), type);
+ break;
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ case DBVT_WCHAR:
+ res = setTextValue(dbsetting->hContact, dbsetting->module, setting, value, type);
+ break;
+ case DBVT_BLOB:
+ res = WriteBlobFromString(dbsetting->hContact, dbsetting->module, setting, _T2A(value), len);
+ break;
+ }
- // write the setting
- switch (type)
- {
- case DBVT_BYTE:
- case DBVT_WORD:
- case DBVT_DWORD:
- res = setNumericValue(dbsetting->hContact, dbsetting->module, setting, wcstoul(value, nullptr, IsDlgButtonChecked(hwnd, CHK_HEX)? 16 : 10), type);
- break;
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- case DBVT_WCHAR:
- res = setTextValue(dbsetting->hContact, dbsetting->module, setting, value, type);
- break;
- case DBVT_BLOB:
- res = WriteBlobFromString(dbsetting->hContact, dbsetting->module, setting, _T2A(value), len);
- break;
- }
+ mir_free(value);
- mir_free(value);
+ if (!res) {
+ msg(TranslateT("Unable to store value in this data type!"));
+ break;
+ }
- if (!res) {
- msg(TranslateT("Unable to store value in this data type!"));
- break;
+ // delete old setting
+ if (dbsetting->setting && mir_strcmp(setting, dbsetting->setting))
+ db_unset(dbsetting->hContact, dbsetting->module, dbsetting->setting);
}
- // delete old setting
- if (dbsetting->setting && mir_strcmp(setting, dbsetting->setting))
- db_unset(dbsetting->hContact, dbsetting->module, dbsetting->setting);
- }
+ } // fall through
- } // fall through
case IDCANCEL:
- {
struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
mir_free(dbsetting->module);
mir_free(dbsetting->setting);
db_free(&dbsetting->dbv);
mir_free(dbsetting);
DestroyWindow(hwnd);
- }
- break;
+ break;
}
}
return 0;
}
-
void editSetting(MCONTACT hContact, const char *module, const char *setting)
{
- DBVARIANT dbv = { 0 };
- if (!db_get_s(hContact, module, setting, &dbv, 0) || IsResidentSetting(module, setting))
- {
- // gets free()ed in the window proc
- struct DBsetting *dbsetting = (struct DBsetting *)mir_calloc(sizeof(struct DBsetting));
+ DBVARIANT dbv = { 0 };
+ if (!db_get_s(hContact, module, setting, &dbv, 0) || IsResidentSetting(module, setting)) {
+ // gets free()ed in the window proc
+ struct DBsetting *dbsetting = (struct DBsetting *)mir_calloc(sizeof(struct DBsetting));
- dbsetting->dbv = dbv;
+ dbsetting->dbv = dbv;
dbsetting->hContact = hContact;
dbsetting->module = mir_strdup(module);
dbsetting->setting = mir_strdup(setting);
-
+
CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
}
}
-
void copySetting(MCONTACT hContact, const char *module, const char *setting)
{
- DBVARIANT dbv = { 0 }, dbv2;
+ DBVARIANT dbv = { 0 }, dbv2;
if (db_get_s(hContact, module, setting, &dbv, 0)) return;
char tmp[FLD_SIZE];
- for (int i = 1; i < 10; i++) {
+ for (int i = 1; i < 10; i++) {
mir_snprintf(tmp, "%s (%d)", setting, i);
if (!db_get_s(hContact, module, tmp, &dbv2, 0))
db_free(&dbv2);
else {
// gets free()ed in the window proc
- struct DBsetting *dbsetting = (struct DBsetting *)mir_calloc(sizeof(struct DBsetting));
+ struct DBsetting *dbsetting = (struct DBsetting *)mir_calloc(sizeof(struct DBsetting));
- dbsetting->dbv = dbv;
+ dbsetting->dbv = dbv;
dbsetting->hContact = hContact;
dbsetting->module = mir_strdup(module);
dbsetting->setting = mir_strdup(tmp);
@@ -320,7 +304,6 @@ void copySetting(MCONTACT hContact, const char *module, const char *setting)
db_free(&dbv);
}
-
void newSetting(MCONTACT hContact, const char *module, int type)
{
// gets safe_free()ed in the window proc
diff --git a/plugins/DbEditorPP/src/version.h b/plugins/DbEditorPP/src/version.h
index af169619ad..eef9fdf000 100644
--- a/plugins/DbEditorPP/src/version.h
+++ b/plugins/DbEditorPP/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 4
#define __MINOR_VERSION 0
#define __RELEASE_NUM 1
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>