diff options
-rw-r--r-- | plugins/DbEditorPP/src/exportimport.cpp | 6 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/findwindow.cpp | 8 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/main.cpp | 10 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/main_window.cpp | 2 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/moduletree.cpp | 10 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/settinglist.cpp | 354 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/settingsdlg.cpp | 6 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/version.h | 2 | ||||
-rw-r--r-- | plugins/DbEditorPP/src/watchedvars.cpp | 2 |
9 files changed, 193 insertions, 207 deletions
diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index 956e317ccb..a182418881 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -31,7 +31,7 @@ int Openfile(wchar_t *outputFile, const char *module, int maxlen) }
else filename[0] = 0;
- OPENFILENAME ofn = { 0 };
+ OPENFILENAME ofn = {};
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = filename;
ofn.lpstrFilter = GetFilter();
@@ -459,7 +459,7 @@ void ImportSettingsMenuItem(MCONTACT hContact) int Openfile2Import(wchar_t *outputFiles, int maxlen)
{
- OPENFILENAME ofn = { 0 };
+ OPENFILENAME ofn = {};
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = GetFilter();
ofn.lpstrFile = outputFiles;
@@ -481,7 +481,7 @@ BOOL Exists(LPCTSTR strName) void ImportSettingsFromFileMenuItem(MCONTACT hContact, const char *FilePath)
{
wchar_t szFileNames[MAX_PATH * 10];
- wchar_t szPath[MAX_PATH] = { 0 };
+ wchar_t szPath[MAX_PATH] = {};
wchar_t szFile[MAX_PATH];
DWORD offset = 0;
diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp index 2d21dac0c9..fb049cd941 100644 --- a/plugins/DbEditorPP/src/findwindow.cpp +++ b/plugins/DbEditorPP/src/findwindow.cpp @@ -97,7 +97,7 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0);
else {
wchar_t text[FLD_SIZE];
- wchar_t replace[FLD_SIZE] = { 0 };
+ wchar_t replace[FLD_SIZE] = {};
if (!GetDlgItemText(hwnd, IDC_TEXT, text, _countof(text)) && !IsDlgButtonChecked(hwnd, IDC_EXACT)) break;
@@ -180,7 +180,7 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem = hti.iItem;
lvi.iSubItem = 0;
if (ListView_GetItem(hwndResults, &lvi)) {
- ItemInfo ii = { 0 };
+ ItemInfo ii = {};
ii.hContact = (MCONTACT)lvi.lParam;
ListView_GetItemTextA(hwndResults, hti.iItem, 2, ii.module, _countof(ii.module));
ListView_GetItemTextA(hwndResults, hti.iItem, 3, ii.setting, _countof(ii.setting));
@@ -236,7 +236,7 @@ void ItemFound(HWND hwnd, MCONTACT hContact, const char *module, const char *set GetContactName(hContact, nullptr, name, _countof(name));
- LVITEM lvi = { 0 };
+ LVITEM lvi = {};
lvi.mask = LVIF_PARAM;
lvi.lParam = (LPARAM)hContact;
@@ -350,7 +350,7 @@ void __cdecl FindSettings(LPVOID param) ModSetLinkLinkItem *module, *setting;
MCONTACT hContact;
- DBVARIANT dbv = { 0 };
+ DBVARIANT dbv = {};
int foundCount = 0, replaceCount = 0, deleteCount = 0;
diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index af14893ded..86d8116c54 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -133,7 +133,7 @@ static int ModulesLoaded(WPARAM, LPARAM) for (int i = 0; i < NAMEORDERCOUNT; i++)
nameOrder[i] = i;
- DBVARIANT dbv = { 0 };
+ DBVARIANT dbv = {};
if (!db_get_s(0, "Contact", "NameOrder", &dbv, DBVT_BLOB)) {
memcpy(nameOrder, dbv.pbVal, dbv.cpbVal);
db_free(&dbv);
@@ -320,7 +320,7 @@ int setTextValue(MCONTACT hContact, const char *module, const char *setting, wch int GetValueA(MCONTACT hContact, const char *module, const char *setting, char *value, int length)
{
- DBVARIANT dbv = { 0 };
+ DBVARIANT dbv = {};
if (!module || !setting || !value)
return 0;
@@ -362,7 +362,7 @@ int GetValueA(MCONTACT hContact, const char *module, const char *setting, char * int GetValueW(MCONTACT hContact, const char *module, const char *setting, WCHAR *value, int length)
{
- DBVARIANT dbv = { 0 };
+ DBVARIANT dbv = {};
if (!module || !setting || !value)
return 0;
@@ -511,7 +511,7 @@ int ApplyProtoFilter(MCONTACT hContact) void loadListSettings(HWND hwnd, ColumnsSettings *cs)
{
- LVCOLUMN sLC = { 0 };
+ LVCOLUMN sLC = {};
sLC.fmt = LVCFMT_LEFT;
sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
int i = 0;
@@ -526,7 +526,7 @@ void loadListSettings(HWND hwnd, ColumnsSettings *cs) void saveListSettings(HWND hwnd, ColumnsSettings *cs)
{
char tmp[FLD_SIZE];
- LVCOLUMN sLC = { 0 };
+ LVCOLUMN sLC = {};
sLC.mask = LVCF_WIDTH;
int i = 0;
while (cs[i].name) {
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 2318e21397..1f81ee24a8 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -309,7 +309,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (item = TreeView_GetSelection(hwnd2Tree)) {
int type = MODULE;
- TVITEM tvi = { 0 };
+ TVITEM tvi = {};
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
tvi.pszText = text;
tvi.cchTextMax = _countof(text);
diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index 109dc77f0a..f5048a6567 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -104,7 +104,7 @@ void doItems(ModuleSettingLL* modlist, int count) wchar_t percent[128], title[96];
mir_snwprintf(title, TranslateT("Loading modules..."));
- TVITEM item = { 0 };
+ TVITEM item = {};
item.mask = TVIF_STATE | TVIF_PARAM;
HTREEITEM contact = TreeView_GetChild(hwnd2Tree, TVI_ROOT);
@@ -320,7 +320,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID param) case 1: // restore after rebuild
if (HTREEITEM item = TreeView_GetSelection(hwnd2Tree)) {
wchar_t text[FLD_SIZE];
- TVITEM tvi = { 0 };
+ TVITEM tvi = {};
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
tvi.pszText = text;
tvi.cchTextMax = _countof(text);
@@ -496,7 +496,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)// hwnd h case TVN_SELCHANGED:
{
LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
- TVITEM tvi = { 0 };
+ TVITEM tvi = {};
wchar_t text[FLD_SIZE];
MCONTACT hContact;
tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
@@ -577,7 +577,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)// hwnd h case TVN_ENDLABELEDIT:
LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
- TVITEM tvi = { 0 };
+ TVITEM tvi = {};
wchar_t text[FLD_SIZE];
ModuleTreeInfoStruct *mtis;
tvi.mask = TVIF_HANDLE | TVIF_TEXT | TVIF_PARAM;
@@ -617,7 +617,7 @@ void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to t if (!TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || !(hti.flags & TVHT_ONITEM)) return;
- TVITEM tvi = { 0 };
+ TVITEM tvi = {};
HMENU hMenu, hSubMenu;
int menuNumber;
wchar_t text[FLD_SIZE];
diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index c1804603f6..9c609515c1 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -1,10 +1,8 @@ #include "stdafx.h"
-
-SettingListInfo info = { 0 };
+SettingListInfo info = {};
HWND hwnd2List = nullptr;
-
static int lastColumn = -1;
struct ColumnsSettings csSettingList[] =
@@ -36,7 +34,7 @@ int ListView_SetItemTextA(HWND hwndLV, int i, int iSubItem, const char *pszText) int convertSetting(MCONTACT hContact, const char *module, const char *setting, int toType)
{
- DBVARIANT dbv = { 0 };
+ DBVARIANT dbv = {};
if (db_get_s(hContact, module, setting, &dbv, 0)) return 0;
@@ -51,7 +49,6 @@ int convertSetting(MCONTACT hContact, const char *module, const char *setting, i ptrW value;
switch (dbv.type) {
-
case DBVT_BYTE:
case DBVT_WORD:
case DBVT_DWORD:
@@ -124,8 +121,8 @@ void ClearListView() void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *setting)
{
int count = ListView_GetSelectedCount(hwnd2List);
-
- if (!count) return;
+ if (!count)
+ return;
if (g_plugin.getByte("WarnOnDelete", 1)) {
wchar_t text[MSG_SIZE];
@@ -138,17 +135,14 @@ void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *s db_unset(hContact, module, setting);
else {
int items = ListView_GetItemCount(hwnd2List);
- int i = 0;
- char text[FLD_SIZE];
-
- while (i < items) {
+ for (int i = 0; i < items;) {
if (ListView_GetItemState(hwnd2List, i, LVIS_SELECTED)) {
+ char text[FLD_SIZE];
if (ListView_GetItemTextA(hwnd2List, i, 0, text, _countof(text)))
db_unset(hContact, module, text);
items--;
}
- else
- i++;
+ else i++;
}
}
@@ -158,13 +152,18 @@ void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *s int findListItem(const char *setting)
{
- if (!setting || !setting[0]) return -1;
+ if (!setting || !setting[0])
+ return -1;
- LVFINDINFOA lvfi;
- lvfi.flags = LVFI_STRING;
- lvfi.psz = setting;
- lvfi.vkDirection = VK_DOWN;
- return SendMessageA(hwnd2List, LVM_FINDITEMA, -1, (LPARAM)&lvfi);
+ int items = ListView_GetItemCount(hwnd2List);
+ for (int i = 0; i < items; i++) {
+ char text[FLD_SIZE];
+ if (ListView_GetItemTextA(hwnd2List, i, 0, text, _countof(text)))
+ if (!strcmp(setting, text))
+ return i;
+ }
+
+ return -1;
}
void deleteListItem(const char *setting)
@@ -181,9 +180,10 @@ void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident return;
}
- if (index < 0) return;
+ if (index < 0)
+ return;
- LVITEM lvi = { 0 };
+ LVITEM lvi = {};
lvi.mask = LVIF_IMAGE;
lvi.iItem = index;
@@ -246,7 +246,6 @@ void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident case DBVT_ASCIIZ:
lvi.iImage = IMAGE_STRING;
ListView_SetItem(hwnd2List, &lvi);
-
ListView_SetItemTextA(hwnd2List, index, 1, dbv->pszVal);
length = (int)mir_strlen(dbv->pszVal) + 1;
@@ -257,10 +256,9 @@ void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident case DBVT_WCHAR:
lvi.iImage = IMAGE_UNICODE;
ListView_SetItem(hwnd2List, &lvi);
-
- length = (int)mir_wstrlen(dbv->pwszVal) + 1;
ListView_SetItemText(hwnd2List, index, 1, dbv->pwszVal);
+ length = (int)mir_wstrlen(dbv->pwszVal) + 1;
mir_snwprintf(data, L"0x%04X (%u)", length, length);
ListView_SetItemText(hwnd2List, index, 3, data);
break;
@@ -268,12 +266,9 @@ void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident case DBVT_UTF8:
lvi.iImage = IMAGE_UNICODE;
ListView_SetItem(hwnd2List, &lvi);
+ ListView_SetItemText(hwnd2List, index, 1, ptrW(mir_utf8decodeW(dbv->pszVal)));
length = (int)mir_strlen(dbv->pszVal) + 1;
- {
- ptrW tszText(mir_utf8decodeW(dbv->pszVal));
- ListView_SetItemText(hwnd2List, index, 1, tszText);
- }
mir_snwprintf(data, L"0x%04X (%u)", length, length);
ListView_SetItemText(hwnd2List, index, 3, data);
break;
@@ -288,7 +283,7 @@ void updateListItem(int index, const char *setting, DBVARIANT *dbv, int resident void addListHandle(MCONTACT hContact)
{
wchar_t name[NAME_SIZE], data[32];
- LVITEM lvi = { 0 };
+ LVITEM lvi = {};
lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
lvi.lParam = hContact;
lvi.iImage = IMAGE_HANDLE;
@@ -307,10 +302,9 @@ void addListHandle(MCONTACT hContact) if (db_mc_isSub(hContact)) {
ListView_SetItemText(hwnd2List, index, 4, L"[S]");
}
- else
- if (db_mc_isMeta(hContact)) {
- ListView_SetItemText(hwnd2List, index, 4, L"[M]");
- }
+ else if (db_mc_isMeta(hContact)) {
+ ListView_SetItemText(hwnd2List, index, 4, L"[M]");
+ }
}
}
@@ -318,20 +312,19 @@ void addListItem(const char *setting, int resident) {
DBVARIANT dbv;
if (!db_get_s(info.hContact, info.module, setting, &dbv, 0)) {
- LVITEMA lvi = { 0 };
+ LVITEMA lvi = {};
lvi.mask = LVIF_TEXT;
- lvi.pszText = (char*)setting;
+ lvi.pszText = (char *)setting;
int index = SendMessageA(hwnd2List, LVM_INSERTITEMA, 0, (LPARAM)&lvi);
updateListItem(index, setting, &dbv, resident);
db_free(&dbv);
}
else if (!resident) {
- LVITEMA lvi = { 0 };
+ LVITEMA lvi = {};
lvi.mask = LVIF_TEXT;
- lvi.pszText = (char*)setting;
+ lvi.pszText = (char *)setting;
int index = SendMessageA(hwnd2List, LVM_INSERTITEMA, 0, (LPARAM)&lvi);
ListView_SetItemText(hwnd2List, index, 1, TranslateT("*** buggy resident ***"));
- return;
}
}
@@ -368,19 +361,16 @@ void PopulateSettings(MCONTACT hContact, const char *module) void SelectSetting(const char *setting)
{
- LVITEM lvItem = { 0 };
-
+ LVITEM lvItem = {};
lvItem.mask = LVIF_STATE;
lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
int items = ListView_GetItemCount(hwnd2List);
- for (int i = 0; i < items; i++) {
+ for (int i = 0; i < items; i++)
if (ListView_GetItemState(hwnd2List, i, lvItem.stateMask))
ListView_SetItemState(hwnd2List, i, 0, lvItem.stateMask);
- }
lvItem.iItem = findListItem(setting);
-
if (lvItem.iItem != -1) {
EditFinish(lvItem.iItem);
lvItem.state = LVIS_SELECTED | LVIS_FOCUSED;
@@ -401,22 +391,21 @@ void settingChanged(MCONTACT hContact, const char *module, const char *setting, }
// settings list
- if (hContact != info.hContact || mir_strcmp(info.module, module)) return;
+ if (hContact != info.hContact || mir_strcmp(info.module, module))
+ return;
- if (dbv->type == DBVT_DELETED) {
- deleteListItem(setting);
- }
- else {
- LVITEMA lvi = { 0 };
+ if (dbv->type != DBVT_DELETED) {
+ LVITEMA lvi = {};
lvi.iItem = findListItem(setting);
if (lvi.iItem == -1) {
lvi.iItem = 0;
lvi.mask = LVIF_TEXT;
- lvi.pszText = (char*)setting;
+ lvi.pszText = (char *)setting;
lvi.iItem = SendMessageA(hwnd2List, LVM_INSERTITEMA, 0, (LPARAM)&lvi);
}
updateListItem(lvi.iItem, setting, dbv, IsResidentSetting(module, setting));
}
+ else deleteListItem(setting);
}
static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -451,139 +440,139 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- DBVARIANT dbv = { 0 };
- int len = GetWindowTextLength(hwnd) + 1;
+ {
+ DBVARIANT dbv = {};
+ int len = GetWindowTextLength(hwnd) + 1;
- if ((!info.subitem && len <= 1) || db_get_s(info.hContact, info.module, info.setting, &dbv, 0)) {
- SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
- }
+ if ((!info.subitem && len <= 1) || db_get_s(info.hContact, info.module, info.setting, &dbv, 0)) {
+ SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
+ return 0;
+ }
- wchar_t *value = (wchar_t*)mir_alloc(len * sizeof(wchar_t));
+ wchar_t *value = (wchar_t *)mir_alloc(len * sizeof(wchar_t));
- GetWindowText(hwnd, value, len);
+ GetWindowTextW(hwnd, value, len);
- _T2A szValue(value);
+ _T2A szValue(value);
- int res = 0;
+ int res = 0;
- switch (info.subitem) {
- case 0: // setting name
- if (!mir_strcmp(info.setting, szValue) || mir_strlen(szValue) > 0xFE) {
- db_free(&dbv);
- mir_free(value);
- SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
- return 0;
- }
- if (db_set(info.hContact, info.module, szValue, &dbv))
+ switch (info.subitem) {
+ case 0: // setting name
+ if (!mir_strcmp(info.setting, szValue) || mir_strlen(szValue) > 0xFE) {
+ db_free(&dbv);
+ mir_free(value);
+ SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0);
+ return 0;
+ }
+ if (db_set(info.hContact, info.module, szValue, &dbv))
+ break;
+ res = 1;
+ db_unset(info.hContact, info.module, info.setting);
+ deleteListItem(info.setting);
break;
- res = 1;
- db_unset(info.hContact, info.module, info.setting);
- deleteListItem(info.setting);
- break;
- case 1: // value
- DWORD val;
- int i = 0;
+ case 1: // value
+ DWORD val;
+ int i = 0;
- if (dbv.type == DBVT_BLOB) {
- res = WriteBlobFromString(info.hContact, info.module, info.setting, szValue, (int)mir_strlen(szValue));
- break;
- }
-
- switch (value[0]) {
- case 'b':
- case 'B':
- val = wcstoul(&value[1], nullptr, 0);
- if (!val || value[1] == '0') {
- res = !db_set_b(info.hContact, info.module, info.setting, (BYTE)val);
+ if (dbv.type == DBVT_BLOB) {
+ res = WriteBlobFromString(info.hContact, info.module, info.setting, szValue, (int)mir_strlen(szValue));
+ break;
}
- else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
- case 'w':
- case 'W':
- val = wcstoul(&value[1], nullptr, 0);
- if (!val || value[1] == '0')
- res = !db_set_w(info.hContact, info.module, info.setting, (WORD)val);
- else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
- case 'd':
- case 'D':
- val = wcstoul(&value[1], nullptr, 0);
- if (!val || value[1] == '0')
- res = !db_set_dw(info.hContact, info.module, info.setting, val);
- else
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
- break;
- case '0':
- i = 1;
- __fallthrough;
-
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- case 'x':
- case 'X':
- if (value[i] == 'x' || value[i] == 'X')
- val = wcstoul(&value[i + 1], nullptr, 16);
- else
- val = wcstoul(value, nullptr, 10);
-
- switch (dbv.type) {
- case DBVT_BYTE:
- case DBVT_WORD:
- case DBVT_DWORD:
- res = setNumericValue(info.hContact, info.module, info.setting, val, dbv.type);
+ switch (value[0]) {
+ case 'b':
+ case 'B':
+ val = wcstoul(&value[1], nullptr, 0);
+ if (!val || value[1] == '0') {
+ res = !db_set_b(info.hContact, info.module, info.setting, (BYTE)val);
+ }
+ else
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
+ case 'w':
+ case 'W':
+ val = wcstoul(&value[1], nullptr, 0);
+ if (!val || value[1] == '0')
+ res = !db_set_w(info.hContact, info.module, info.setting, (WORD)val);
+ else
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
+ case 'd':
+ case 'D':
+ val = wcstoul(&value[1], nullptr, 0);
+ if (!val || value[1] == '0')
+ res = !db_set_dw(info.hContact, info.module, info.setting, val);
+ else
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
+
+ case '0':
+ i = 1;
+ __fallthrough;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ case 'x':
+ case 'X':
+ if (value[i] == 'x' || value[i] == 'X')
+ val = wcstoul(&value[i + 1], nullptr, 16);
+ else
+ val = wcstoul(value, nullptr, 10);
+
+ switch (dbv.type) {
+ case DBVT_BYTE:
+ case DBVT_WORD:
+ case DBVT_DWORD:
+ res = setNumericValue(info.hContact, info.module, info.setting, val, dbv.type);
+ break;
+ case DBVT_ASCIIZ:
+ case DBVT_WCHAR:
+ case DBVT_UTF8:
+ res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ break;
+ }
+ break;
+ case '\"':
+ case '\'':
+ {
+ size_t nlen = mir_wstrlen(value);
+ int sh = 0;
+ if (nlen > 3) {
+ if (value[nlen - 1] == value[0]) {
+ value[nlen - 1] = 0;
+ sh = 1;
+ }
+ }
+ res = setTextValue(info.hContact, info.module, info.setting, &value[sh], dbv.type);
+ }
break;
- case DBVT_ASCIIZ:
- case DBVT_WCHAR:
- case DBVT_UTF8:
+
+ default:
res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
break;
}
break;
- case '\"':
- case '\'':
- {
- size_t nlen = mir_wstrlen(value);
- int sh = 0;
- if (nlen > 3) {
- if (value[nlen - 1] == value[0]) {
- value[nlen - 1] = 0;
- sh = 1;
- }
- }
- res = setTextValue(info.hContact, info.module, info.setting, &value[sh], dbv.type);
}
- break;
- default:
- res = setTextValue(info.hContact, info.module, info.setting, value, dbv.type);
+ mir_free(value);
+ db_free(&dbv);
+
+ if (!res) {
+ msg(TranslateT("Unable to store value in this data type!"));
break;
}
- break;
- }
-
- mir_free(value);
- db_free(&dbv);
-
- if (!res) {
- msg(TranslateT("Unable to store value in this data type!"));
- break;
}
- }
- __fallthrough;
+ __fallthrough;
case IDCANCEL:
DestroyWindow(hwnd);
@@ -624,7 +613,7 @@ void EditLabel(int item, int subitem) if (!subitem)
info.hwnd2Edit = CreateWindow(L"EDIT", _A2T(setting), WS_BORDER | WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), hwnd2List, nullptr, g_plugin.getInst(), nullptr);
else {
- wchar_t *str = nullptr, value[16] = { 0 };
+ wchar_t *str = nullptr, value[16] = {};
switch (dbv.type) {
case DBVT_ASCIIZ:
@@ -654,7 +643,7 @@ void EditLabel(int item, int subitem) int height = (rc.bottom - rc.top) * 4;
RECT rclist;
GetClientRect(hwnd2List, &rclist);
- if (rc.top + height > rclist.bottom && rclist.bottom - rclist.top > height)
+ if (rc.top + height > rclist.bottom &&rclist.bottom - rclist.top > height)
rc.top = rc.bottom - height;
info.hwnd2Edit = CreateWindow(L"EDIT", str, WS_BORDER | WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL, rc.left, rc.top, rc.right - rc.left, height, hwnd2List, nullptr, g_plugin.getInst(), nullptr);
mir_free(str);
@@ -675,41 +664,40 @@ void SettingsListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam) {
LVHITTESTINFO hti;
- switch (((NMHDR*)lParam)->code) {
+ switch (((NMHDR *)lParam)->code) {
case NM_CLICK:
- hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
+ hti.pt = ((NMLISTVIEW *)lParam)->ptAction;
if (ListView_SubItemHitTest(hwnd2List, &hti) > -1) {
if (g_Inline && hti.iSubItem <= 1 && hti.flags != LVHT_ONITEMICON && info.selectedItem == hti.iItem)
EditLabel(hti.iItem, hti.iSubItem);
else
EditFinish(hti.iItem);
}
- else
- EditFinish(0);
+ else EditFinish(0);
break;
case NM_DBLCLK:
- hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
+ hti.pt = ((NMLISTVIEW *)lParam)->ptAction;
if (ListView_SubItemHitTest(hwnd2List, &hti) > -1) {
if (!info.module[0]) { // contact
- LVITEM lvi = { 0 };
+ LVITEM lvi = {};
lvi.mask = LVIF_PARAM;
lvi.iItem = hti.iItem;
if (!ListView_GetItem(hwnd2List, &lvi)) break;
- ItemInfo ii = { 0 };
+ ItemInfo ii = {};
ii.hContact = (MCONTACT)lvi.lParam;
SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0);
break;
}
+
if (!g_Inline || hti.iSubItem > 1 || hti.flags == LVHT_ONITEMICON) {
char setting[FLD_SIZE];
EditFinish(hti.iItem);
if (ListView_GetItemTextA(hwnd2List, hti.iItem, 0, setting, _countof(setting)))
editSetting(info.hContact, info.module, setting);
}
- else
- EditLabel(hti.iItem, hti.iSubItem);
+ else EditLabel(hti.iItem, hti.iSubItem);
}
break;
@@ -735,7 +723,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to POINT pt;
HMENU hMenu, hSubMenu;
- hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
+ hti.pt = ((NMLISTVIEW *)lParam)->ptAction;
if (ListView_SubItemHitTest(hwnd2List, &hti) == -1) {
// nowhere.. new item menu
@@ -752,31 +740,31 @@ void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, nullptr)) {
case MENU_ADD_BYTE:
newSetting(info.hContact, info.module, DBVT_BYTE);
- return;
+ break;
case MENU_ADD_WORD:
newSetting(info.hContact, info.module, DBVT_WORD);
- return;
+ break;
case MENU_ADD_DWORD:
newSetting(info.hContact, info.module, DBVT_DWORD);
- return;
+ break;
case MENU_ADD_STRING:
newSetting(info.hContact, info.module, DBVT_ASCIIZ);
- return;
+ break;
case MENU_ADD_UNICODE:
newSetting(info.hContact, info.module, DBVT_WCHAR);
- return;
+ break;
case MENU_ADD_BLOB:
newSetting(info.hContact, info.module, DBVT_BLOB);
- return;
+ break;
case MENU_REFRESH:
PopulateSettings(info.hContact, info.module);
- return;
+ break;
}
return;
}
@@ -787,11 +775,9 @@ void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to hSubMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hSubMenu);
- LVITEM lvi = { 0 };
-
+ LVITEM lvi = {};
lvi.mask = LVIF_IMAGE;
lvi.iItem = hti.iItem;
- lvi.iSubItem = 0;
ListView_GetItem(hwnd2List, &lvi);
switch (lvi.iImage) {
diff --git a/plugins/DbEditorPP/src/settingsdlg.cpp b/plugins/DbEditorPP/src/settingsdlg.cpp index 8c0f0d78a9..49a52e443c 100644 --- a/plugins/DbEditorPP/src/settingsdlg.cpp +++ b/plugins/DbEditorPP/src/settingsdlg.cpp @@ -25,7 +25,7 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l {
struct DBsetting *dbsetting = (struct DBsetting*)lParam;
- char val[16] = { 0 };
+ char val[16] = {};
int convert = 0;
switch (dbsetting->dbv.type) {
@@ -265,7 +265,7 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l void editSetting(MCONTACT hContact, const char *module, const char *setting)
{
- DBVARIANT dbv = { 0 };
+ DBVARIANT dbv = {};
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));
@@ -281,7 +281,7 @@ void editSetting(MCONTACT hContact, const char *module, const char *setting) void copySetting(MCONTACT hContact, const char *module, const char *setting)
{
- DBVARIANT dbv = { 0 }, dbv2;
+ DBVARIANT dbv = {}, dbv2;
if (db_get_s(hContact, module, setting, &dbv, 0)) return;
char tmp[FLD_SIZE];
diff --git a/plugins/DbEditorPP/src/version.h b/plugins/DbEditorPP/src/version.h index 25a7946f64..caeaefe5ba 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 2 +#define __BUILD_NUM 3 #include <stdver.h> diff --git a/plugins/DbEditorPP/src/watchedvars.cpp b/plugins/DbEditorPP/src/watchedvars.cpp index c1c10266e5..cc4e945452 100644 --- a/plugins/DbEditorPP/src/watchedvars.cpp +++ b/plugins/DbEditorPP/src/watchedvars.cpp @@ -90,7 +90,7 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam) if (IsModuleEmpty(lParam->hContact, lParam->module) || !EnumSettings(lParam->hContact, lParam->module, &settinglist))
return;
- struct DBsetting dummy = { 0 };
+ struct DBsetting dummy = {};
dummy.hContact = lParam->hContact;
dummy.module = lParam->module;
|