From 82fc26a0fdbd50cf60b2c93f456cbef33046ac48 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 14 Dec 2014 15:31:37 +0000 Subject: DbEditorPP: changed warning lavel to w4 git-svn-id: http://svn.miranda-ng.org/main/trunk@11414 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbEditorPP/dbeditorpp_12.vcxproj | 8 +- plugins/DbEditorPP/src/addeditsettingsdlg.cpp | 582 +++++++++++++------------- plugins/DbEditorPP/src/copymodule.cpp | 17 +- plugins/DbEditorPP/src/deletemodule.cpp | 76 ++-- plugins/DbEditorPP/src/exportimport.cpp | 437 ++++++++++--------- plugins/DbEditorPP/src/findwindow.cpp | 56 ++- plugins/DbEditorPP/src/headers.h | 6 +- plugins/DbEditorPP/src/icons.cpp | 32 +- plugins/DbEditorPP/src/main.cpp | 86 ++-- plugins/DbEditorPP/src/main_window.cpp | 144 +++---- plugins/DbEditorPP/src/modsettingenum.cpp | 4 +- plugins/DbEditorPP/src/moduletree.cpp | 318 +++++++------- plugins/DbEditorPP/src/options.cpp | 92 ++-- plugins/DbEditorPP/src/settinglist.cpp | 316 +++++++------- plugins/DbEditorPP/src/watchedvars.cpp | 300 ++++++------- 15 files changed, 1232 insertions(+), 1242 deletions(-) (limited to 'plugins') diff --git a/plugins/DbEditorPP/dbeditorpp_12.vcxproj b/plugins/DbEditorPP/dbeditorpp_12.vcxproj index f96aa8a685..700752fe80 100644 --- a/plugins/DbEditorPP/dbeditorpp_12.vcxproj +++ b/plugins/DbEditorPP/dbeditorpp_12.vcxproj @@ -82,7 +82,7 @@ MultiThreadedDebugDLL Use headers.h - Level3 + Level4 EditAndContinue false @@ -109,7 +109,7 @@ MultiThreadedDebugDLL Use headers.h - Level3 + Level4 false @@ -136,7 +136,7 @@ true Use headers.h - Level3 + Level4 false @@ -165,7 +165,7 @@ true Use headers.h - Level3 + Level4 false diff --git a/plugins/DbEditorPP/src/addeditsettingsdlg.cpp b/plugins/DbEditorPP/src/addeditsettingsdlg.cpp index 15e880e93a..f17a97b740 100644 --- a/plugins/DbEditorPP/src/addeditsettingsdlg.cpp +++ b/plugins/DbEditorPP/src/addeditsettingsdlg.cpp @@ -2,7 +2,7 @@ static BOOL Convert(MCONTACT hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string { - int Result = 1; + int Result = 1; char temp[64]; switch (toType) { @@ -23,7 +23,7 @@ static BOOL Convert(MCONTACT hContact, char* module, char* setting, int value, i break; case 3: db_unset(hContact, module, setting); - db_set_s(hContact, module, setting, itoa(value,temp,10)); + db_set_s(hContact, module, setting, itoa(value, temp, 10)); break; } return Result; @@ -32,7 +32,7 @@ static BOOL Convert(MCONTACT hContact, char* module, char* setting, int value, i BOOL convertSetting(MCONTACT hContact, char* module, char* setting, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string, 4 = unicode { - DBVARIANT dbv = {0}; + DBVARIANT dbv = { 0 }; BOOL Result = 0; if (!GetSetting(hContact, module, setting, &dbv)) { @@ -69,7 +69,7 @@ BOOL convertSetting(MCONTACT hContact, char* module, char* setting, int toType) case DBVT_UTF8: if (toType == 3) { // convert to ANSI int len = (int)strlen(dbv.pszVal) + 1; - char *sz = (char*)_alloca(len*3); + 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); @@ -90,13 +90,13 @@ BOOL convertSetting(MCONTACT hContact, char* module, char* setting, int toType) int saveAsType(HWND hwnd) { - if(IsDlgButtonChecked(hwnd, CHK_BYTE)) + if (IsDlgButtonChecked(hwnd, CHK_BYTE)) return 0; - else if(IsDlgButtonChecked(hwnd, CHK_WORD)) + else if (IsDlgButtonChecked(hwnd, CHK_WORD)) return 1; - else if(IsDlgButtonChecked(hwnd, CHK_DWORD)) + else if (IsDlgButtonChecked(hwnd, CHK_DWORD)) return 2; - else if(IsDlgButtonChecked(hwnd, CHK_STRING)) + else if (IsDlgButtonChecked(hwnd, CHK_STRING)) return 3; return 3; } @@ -104,325 +104,325 @@ int saveAsType(HWND hwnd) INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) + switch (msg) { - case WM_INITDIALOG: + case WM_INITDIALOG: + { + char tmp[32]; + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); + switch (((struct DBsetting*)lParam)->dbv.type) { - char tmp[32]; - SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG_PTR)lParam); - switch (((struct DBsetting*)lParam)->dbv.type) + case DBVT_BYTE: + ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) { - case DBVT_BYTE: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New BYTE value")); - } - else - { - SetWindowText(hwnd, Translate("Edit BYTE value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.bVal, tmp, 10)); - } - CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE); - break; - case DBVT_WORD: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New WORD value")); - } - else - { - SetWindowText(hwnd, Translate("Edit WORD value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.wVal, tmp, 10)); - } - CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD); - break; - case DBVT_DWORD: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New DWORD value")); - } - else - { - char text[32]; - SetWindowText(hwnd, Translate("Edit DWORD value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); - SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); - } - CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD); - break; - case DBVT_ASCIIZ: - 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); - 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 (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New STRING value")); - } - else - { - SetWindowText(hwnd, Translate("Edit STRING value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - SetDlgItemText(hwnd, IDC_STRING, ((struct DBsetting*)lParam)->dbv.pszVal); - } - break; - case DBVT_UTF8: - 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); - 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 (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New UNICODE value")); - } - else - { - char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); - int length = (int)strlen(tmp) + 1; - WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); - SetDlgItemTextW(hwnd, IDC_STRING, wc); - - SetWindowText(hwnd, Translate("Edit UNICODE value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - } - 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); - - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New BLOB value")); - } - else - { - int j; - char tmp[16]; - int len = ((struct DBsetting*)lParam)->dbv.cpbVal; - char *data = (char*)_alloca(3*(len+1)+10); - BYTE *p = ((struct DBsetting*)lParam)->dbv.pbVal; + SetWindowText(hwnd, Translate("New BYTE value")); + } + else + { + SetWindowText(hwnd, Translate("Edit BYTE value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.bVal, tmp, 10)); + } + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE); + break; + case DBVT_WORD: + ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New WORD value")); + } + else + { + SetWindowText(hwnd, Translate("Edit WORD value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.wVal, tmp, 10)); + } + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD); + break; + case DBVT_DWORD: + ShowWindow(GetDlgItem(hwnd, IDC_STRING), SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New DWORD value")); + } + else + { + char text[32]; + SetWindowText(hwnd, Translate("Edit DWORD value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); + SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); + } + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD); + break; + case DBVT_ASCIIZ: + 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); + 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 (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New STRING value")); + } + else + { + SetWindowText(hwnd, Translate("Edit STRING value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_STRING, ((struct DBsetting*)lParam)->dbv.pszVal); + } + break; + case DBVT_UTF8: + 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); + 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 (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New UNICODE value")); + } + else + { + char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); + int length = (int)strlen(tmp) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); + SetDlgItemTextW(hwnd, IDC_STRING, wc); + + SetWindowText(hwnd, Translate("Edit UNICODE value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + } + 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); - if (!data) return TRUE; - data[0] = '\0'; + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New BLOB value")); + } + else + { + int j; + char tmp[16]; + int len = ((struct DBsetting*)lParam)->dbv.cpbVal; + char *data = (char*)_alloca(3 * (len + 1) + 10); + BYTE *p = ((struct DBsetting*)lParam)->dbv.pbVal; - for(j=0; jsetting); - SetDlgItemText(hwnd, IDC_BLOB, data); - } - ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); - 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); + for (j = 0; j < len; j++) + { + mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)p[j]); + strcat(data, tmp); } - break; - default: return TRUE; + + SetWindowText(hwnd, Translate("Edit BLOB value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_BLOB, data); } - TranslateDialogDefault(hwnd); + ShowWindow(GetDlgItem(hwnd, CHK_HEX), SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL), SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_BASE), SW_HIDE); + 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); } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) + break; + default: return TRUE; + } + TranslateDialogDefault(hwnd); + } + return TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case CHK_BYTE: + case CHK_WORD: + case CHK_DWORD: + EnableWindow(GetDlgItem(hwnd, CHK_HEX), 1); + EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL), 1); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); + break; + case CHK_STRING: + EnableWindow(GetDlgItem(hwnd, CHK_HEX), 0); + EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL), 0); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); + break; + + case CHK_HEX: + case CHK_DECIMAL: + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, LOWORD(wParam)); { - case CHK_BYTE: - case CHK_WORD: - case CHK_DWORD: - EnableWindow(GetDlgItem(hwnd, CHK_HEX),1); - EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),1); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); - break; - case CHK_STRING: - EnableWindow(GetDlgItem(hwnd, CHK_HEX),0); - EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),0); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); - break; - - case CHK_HEX: - case CHK_DECIMAL: - CheckRadioButton(hwnd,CHK_HEX, CHK_DECIMAL, LOWORD(wParam)); + char *setting, temp[32]; + int settingLength, tmp; + settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGVALUE)); + if (settingLength) + { + setting = (char*)_alloca(settingLength + 1); + if (setting) { - char *setting, temp[32]; - int settingLength, tmp; - settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGVALUE)); - if (settingLength) + // havta convert it with mir_snprintf() + GetDlgItemText(hwnd, IDC_SETTINGVALUE, setting, settingLength + 1); + if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL)) { - setting = (char*)_alloca(settingLength + 1); - if (setting) - { - // havta convert it with mir_snprintf() - GetDlgItemText(hwnd, IDC_SETTINGVALUE, setting, settingLength + 1); - if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL)) - { - sscanf(setting, "%X", &tmp); - mir_snprintf(temp, SIZEOF(temp), "%ld", tmp); - } - else - { - sscanf(setting, "%d", &tmp); - mir_snprintf(temp, SIZEOF(temp), "%X", tmp); - } - SetDlgItemText(hwnd, IDC_SETTINGVALUE, temp); - } + sscanf(setting, "%X", &tmp); + mir_snprintf(temp, SIZEOF(temp), "%ld", tmp); } + else + { + sscanf(setting, "%d", &tmp); + mir_snprintf(temp, SIZEOF(temp), "%X", tmp); + } + SetDlgItemText(hwnd, IDC_SETTINGVALUE, temp); } - break; - case IDOK: - { - struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - char *setting, *value; - int settingLength, valueLength, valueID = IDC_SETTINGVALUE; - settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGNAME)); - - if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING))) - valueID = IDC_STRING; - else - if (IsWindowVisible(GetDlgItem(hwnd,IDC_SETTINGVALUE))) - valueID = IDC_SETTINGVALUE; - else - if (IsWindowVisible(GetDlgItem(hwnd,IDC_BLOB))) + } + } + break; + case IDOK: + { + struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + char *setting, *value; + int settingLength, valueLength, valueID = IDC_SETTINGVALUE; + settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGNAME)); + + if (IsWindowVisible(GetDlgItem(hwnd, IDC_STRING))) + valueID = IDC_STRING; + else + if (IsWindowVisible(GetDlgItem(hwnd, IDC_SETTINGVALUE))) + valueID = IDC_SETTINGVALUE; + else + if (IsWindowVisible(GetDlgItem(hwnd, IDC_BLOB))) valueID = IDC_BLOB; else break; - valueLength = GetWindowTextLength(GetDlgItem(hwnd, valueID)); + valueLength = GetWindowTextLength(GetDlgItem(hwnd, valueID)); - if (dbsetting->dbv.type == DBVT_UTF8) - valueLength *= sizeof(WCHAR); + if (dbsetting->dbv.type == DBVT_UTF8) + valueLength *= sizeof(WCHAR); - if (settingLength) - { - int settingValue; - setting = (char*)_alloca(settingLength + 1); - - if (valueLength) - value = (char*)_alloca(valueLength + 2); - else - value = (char*)_alloca(2); + if (settingLength) + { + int settingValue; + setting = (char*)_alloca(settingLength + 1); - if (!setting || !value) - { - msg(Translate("Couldn't allocate enough memory!"), modFullname); - DestroyWindow(hwnd); - break; - } + if (valueLength) + value = (char*)_alloca(valueLength + 2); + else + value = (char*)_alloca(2); - GetDlgItemText(hwnd, IDC_SETTINGNAME, setting, settingLength + 1); + if (!setting || !value) + { + msg(Translate("Couldn't allocate enough memory!"), modFullname); + DestroyWindow(hwnd); + break; + } - if (valueLength) - { - if (dbsetting->dbv.type == DBVT_UTF8) - GetDlgItemTextW(hwnd, valueID, (LPWSTR)value, (valueLength + 2)); - else - GetDlgItemText(hwnd, valueID, value, valueLength + 1); - } - else - if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING)) || (saveAsType(hwnd)==3)) - memcpy(value,"\0\0",2); - else - strcpy(value,"0"); + GetDlgItemText(hwnd, IDC_SETTINGNAME, setting, settingLength + 1); - // delete the old setting - if (mir_strcmp(setting, dbsetting->setting) && dbsetting->setting && (dbsetting->setting)[0] != 0) - db_unset(dbsetting->hContact, dbsetting->module, dbsetting->setting); + if (valueLength) + { + if (dbsetting->dbv.type == DBVT_UTF8) + GetDlgItemTextW(hwnd, valueID, (LPWSTR)value, (valueLength + 2)); + else + GetDlgItemText(hwnd, valueID, value, valueLength + 1); + } + else + if (IsWindowVisible(GetDlgItem(hwnd, IDC_STRING)) || (saveAsType(hwnd) == 3)) + memcpy(value, "\0\0", 2); + else + strcpy(value, "0"); - // delete the setting if we are saving as a different type - switch (dbsetting->dbv.type) - { - case DBVT_BYTE: - if (saveAsType(hwnd) != 0) db_unset(dbsetting->hContact, dbsetting->module, setting); - break; - case DBVT_WORD: - if (saveAsType(hwnd) != 1) db_unset(dbsetting->hContact, dbsetting->module, setting); - break; - case DBVT_DWORD: - if (saveAsType(hwnd) != 2) db_unset(dbsetting->hContact, dbsetting->module, setting); - break; - //case DBVT_ASCIIZ: - //db_set_s(dbsetting->hContact, dbsetting->module, setting, value); - //break; - } - // write the setting - switch (saveAsType(hwnd)) - { - case 0: - if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); - else sscanf(value, "%d", &settingValue); - db_set_b(dbsetting->hContact, dbsetting->module, setting, (BYTE)settingValue); - break; - case 1: - if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); - else sscanf(value, "%d", &settingValue); - db_set_w(dbsetting->hContact, dbsetting->module, setting, (WORD)settingValue); - break; - case 2: - if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); - else sscanf(value, "%d", &settingValue); - db_set_dw(dbsetting->hContact, dbsetting->module, setting, (DWORD)settingValue); - break; - case 3: - if (dbsetting->dbv.type == DBVT_UTF8) - db_set_ws(dbsetting->hContact, dbsetting->module, setting, (WCHAR*)value); - else if (dbsetting->dbv.type == DBVT_BLOB) - WriteBlobFromString(dbsetting->hContact,dbsetting->module,setting,value,valueLength); - else if (dbsetting->dbv.type == DBVT_ASCIIZ) - db_set_s(dbsetting->hContact, dbsetting->module, setting, value); - break; - } + // delete the old setting + if (mir_strcmp(setting, dbsetting->setting) && dbsetting->setting && (dbsetting->setting)[0] != 0) + db_unset(dbsetting->hContact, dbsetting->module, dbsetting->setting); - } - } // fall through - case IDCANCEL: + // delete the setting if we are saving as a different type + switch (dbsetting->dbv.type) { - struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - mir_free(dbsetting->module); - mir_free(dbsetting->setting); - mir_free(dbsetting); - DestroyWindow(hwnd); + case DBVT_BYTE: + if (saveAsType(hwnd) != 0) db_unset(dbsetting->hContact, dbsetting->module, setting); + break; + case DBVT_WORD: + if (saveAsType(hwnd) != 1) db_unset(dbsetting->hContact, dbsetting->module, setting); + break; + case DBVT_DWORD: + if (saveAsType(hwnd) != 2) db_unset(dbsetting->hContact, dbsetting->module, setting); + break; + //case DBVT_ASCIIZ: + //db_set_s(dbsetting->hContact, dbsetting->module, setting, value); + //break; } - break; + // write the setting + switch (saveAsType(hwnd)) + { + case 0: + if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); + else sscanf(value, "%d", &settingValue); + db_set_b(dbsetting->hContact, dbsetting->module, setting, (BYTE)settingValue); + break; + case 1: + if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); + else sscanf(value, "%d", &settingValue); + db_set_w(dbsetting->hContact, dbsetting->module, setting, (WORD)settingValue); + break; + case 2: + if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); + else sscanf(value, "%d", &settingValue); + db_set_dw(dbsetting->hContact, dbsetting->module, setting, (DWORD)settingValue); + break; + case 3: + if (dbsetting->dbv.type == DBVT_UTF8) + db_set_ws(dbsetting->hContact, dbsetting->module, setting, (WCHAR*)value); + else if (dbsetting->dbv.type == DBVT_BLOB) + WriteBlobFromString(dbsetting->hContact, dbsetting->module, setting, value, valueLength); + else if (dbsetting->dbv.type == DBVT_ASCIIZ) + db_set_s(dbsetting->hContact, dbsetting->module, setting, value); + break; + } + } + } // fall through + case IDCANCEL: + { + struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + mir_free(dbsetting->module); + mir_free(dbsetting->setting); + mir_free(dbsetting); + DestroyWindow(hwnd); + } break; } + break; + } return 0; } void editSetting(MCONTACT hContact, char* module, char* setting) { - DBVARIANT dbv = {0}; // freed in the dialog - if (!GetSetting(hContact,module, setting, &dbv)) + DBVARIANT dbv = { 0 }; // freed in the dialog + if (!GetSetting(hContact, module, setting, &dbv)) { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets free()ed in the window proc diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp index 87d6b23c91..1e580ba6a4 100644 --- a/plugins/DbEditorPP/src/copymodule.cpp +++ b/plugins/DbEditorPP/src/copymodule.cpp @@ -39,13 +39,13 @@ void copyModule(char* module, MCONTACT hContactFrom, MCONTACT hContactTo) INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd,GWLP_USERDATA); + ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (msg == WM_INITDIALOG) { int index, loaded; char szProto[256]; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + if (GetValue(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) loaded = IsProtocolLoaded(szProto); else loaded = 0; @@ -55,7 +55,6 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara continue; // contacts name - DBVARIANT dbv ={0}; WCHAR nick[256]; WCHAR protoW[256]; // unicode proto @@ -88,27 +87,27 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_SETITEMDATA, index, 0); SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_SETCURSEL, index, 0); - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); + SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); TranslateDialogDefault(hwnd); } else if (msg == WM_COMMAND) { - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case CHK_COPY2ALL: - EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),BST_UNCHECKED == IsDlgButtonChecked(hwnd,CHK_COPY2ALL)); + EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS), BST_UNCHECKED == IsDlgButtonChecked(hwnd, CHK_COPY2ALL)); break; case IDOK: - if (BST_UNCHECKED == IsDlgButtonChecked(hwnd,CHK_COPY2ALL)) { + if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, CHK_COPY2ALL)) { MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETITEMDATA, SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETCURSEL, 0, 0), 0); copyModule(mac->module, mac->hContact, hContact); } else { - SetCursor(LoadCursor(NULL,IDC_WAIT)); + SetCursor(LoadCursor(NULL, IDC_WAIT)); for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) copyModule(mac->module, mac->hContact, hContact); - SetCursor(LoadCursor(NULL,IDC_ARROW)); + SetCursor(LoadCursor(NULL, IDC_ARROW)); } mir_free(mac); refreshTree(1); diff --git a/plugins/DbEditorPP/src/deletemodule.cpp b/plugins/DbEditorPP/src/deletemodule.cpp index f933bb758d..7f94d13cd5 100644 --- a/plugins/DbEditorPP/src/deletemodule.cpp +++ b/plugins/DbEditorPP/src/deletemodule.cpp @@ -8,15 +8,15 @@ int deleteModule(char *module, MCONTACT hContact, int fromMenu) if (!module) return 0; - if (!fromMenu && db_get_b(NULL,modname, "WarnOnDelete",1)) { + if (!fromMenu && db_get_b(NULL, modname, "WarnOnDelete", 1)) { char msg[1024]; mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete module \"%s\"?"), module); - if (MessageBox(0,msg, Translate("Confirm module deletion"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) + if (MessageBox(0, msg, Translate("Confirm module deletion"), MB_YESNO | MB_ICONEXCLAMATION) == IDNO) return 0; } ModuleSettingLL settinglist; - if (!EnumSettings(hContact,module,&settinglist)) + if (!EnumSettings(hContact, module, &settinglist)) return 0; for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next) { @@ -40,29 +40,29 @@ void __cdecl PopulateModuleDropListThreadFunc(void *di) while (module && working) { moduleEmpty = 1; // check the null - if (!IsModuleEmpty(NULL,module->name)) { - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name); + if (!IsModuleEmpty(NULL, module->name)) { + SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_ADDSTRING, 0, (LPARAM)module->name); moduleEmpty = 0; module = module->next; continue; } - for (MCONTACT hContact = db_find_first();moduleEmpty && hContact;hContact = db_find_next(hContact)) { - if (!IsModuleEmpty(hContact,module->name)) { - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name); + for (MCONTACT hContact = db_find_first(); moduleEmpty && hContact; hContact = db_find_next(hContact)) { + if (!IsModuleEmpty(hContact, module->name)) { + SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_ADDSTRING, 0, (LPARAM)module->name); moduleEmpty = 0; break; } } module = module->next; - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_SETCURSEL,0,0); + SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_SETCURSEL, 0, 0); } - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_SETCURSEL,0,0); + SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_SETCURSEL, 0, 0); FreeModuleSettingLL(&msll); - SetWindowText(hwnd,Translate("Delete module from database")); - EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),1); - EnableWindow(GetDlgItem(hwnd,IDOK),1); - EnableWindow(GetDlgItem(hwnd,IDCANCEL),1); + SetWindowText(hwnd, Translate("Delete module from database")); + EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS), 1); + EnableWindow(GetDlgItem(hwnd, IDOK), 1); + EnableWindow(GetDlgItem(hwnd, IDCANCEL), 1); if (!working) PostMessage(hwnd, WM_COMMAND, (WPARAM)IDCANCEL, 0); @@ -70,42 +70,42 @@ void __cdecl PopulateModuleDropListThreadFunc(void *di) working = 2; } -INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) { - switch(msg) { + switch (msg) { case WM_INITDIALOG: - SetWindowText(hwnd,Translate("Delete module from database... Loading")); - EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),0); - EnableWindow(GetDlgItem(hwnd,IDOK),0); - SetDlgItemText(hwnd,IDC_INFOTEXT, Translate("Delete module from database")); - SetDlgItemText(hwnd,CHK_COPY2ALL, Translate("Delete module from all contacts (including Setting)")); - EnableWindow(GetDlgItem(hwnd,CHK_COPY2ALL),0); + SetWindowText(hwnd, Translate("Delete module from database... Loading")); + EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS), 0); + EnableWindow(GetDlgItem(hwnd, IDOK), 0); + SetDlgItemText(hwnd, IDC_INFOTEXT, Translate("Delete module from database")); + SetDlgItemText(hwnd, CHK_COPY2ALL, Translate("Delete module from all contacts (including Setting)")); + EnableWindow(GetDlgItem(hwnd, CHK_COPY2ALL), 0); CheckDlgButton(hwnd, CHK_COPY2ALL, BST_CHECKED); TranslateDialogDefault(hwnd); working = 1; - forkthread(PopulateModuleDropListThreadFunc,0,hwnd); + forkthread(PopulateModuleDropListThreadFunc, 0, hwnd); return TRUE; case WM_COMMAND: - switch(LOWORD(wParam)) { + switch (LOWORD(wParam)) { case IDOK: - { - char text[128]; - GetDlgItemText(hwnd,IDC_CONTACTS,text,SIZEOF(text)); - SetCursor(LoadCursor(NULL,IDC_WAIT)); - for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) - deleteModule(text,hContact,1); + { + char text[128]; + GetDlgItemText(hwnd, IDC_CONTACTS, text, SIZEOF(text)); + SetCursor(LoadCursor(NULL, IDC_WAIT)); + for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) + deleteModule(text, hContact, 1); - // do the null - deleteModule(text,NULL,1); - SetCursor(LoadCursor(NULL,IDC_ARROW)); - refreshTree(1); - } - // fall through + // do the null + deleteModule(text, NULL, 1); + SetCursor(LoadCursor(NULL, IDC_ARROW)); + refreshTree(1); + } + // fall through case IDCANCEL: if (working == 1) { working = 0; - EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); + EnableWindow(GetDlgItem(hwnd, IDCANCEL), 0); } else DestroyWindow(hwnd); } @@ -120,7 +120,7 @@ INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM void deleteModuleGui() { - if (!hwnd2Delete) + if (!hwnd2Delete) hwnd2Delete = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, DeleteModuleDlgProc, 0); else SetForegroundWindow(hwnd2Delete); diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index 4c751a76c0..a2e735783b 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -5,7 +5,7 @@ HWND hwnd2importWindow; int Openfile(char *outputFile, const char *module) { - OPENFILENAME ofn = {0}; + OPENFILENAME ofn = { 0 }; char filename[MAX_PATH] = ""; 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); @@ -16,18 +16,18 @@ int Openfile(char *outputFile, const char *module) int n = 0; mir_strncpy(filename, module, MAX_PATH); - while(filename[n]) + while (filename[n]) { - switch(filename[n]) + switch (filename[n]) { - case '*': - case ':': - case '/': - case '?': - case '|': - case '\\': - filename[n] = '_'; - break; + case '*': + case ':': + case '/': + case '?': + case '|': + case '\\': + filename[n] = '_'; + break; } n++; } @@ -43,11 +43,11 @@ int Openfile(char *outputFile, const char *module) if (!GetSaveFileName(&ofn)) return 0; - mir_tstrcpy(outputFile,filename); + mir_tstrcpy(outputFile, filename); return 1; } -char* StrReplace (char* Search, char* Replace, char* Resource) +char* StrReplace(char* Search, char* Replace, char* Resource) { int i = 0; int SearchLen = (int)_tcslen(Search); @@ -87,64 +87,64 @@ void exportModule(MCONTACT hContact, char* module, FILE* file) ModuleSettingLL settinglist; ModSetLinkLinkItem *setting; - EnumSettings(hContact,module,&settinglist); + EnumSettings(hContact, module, &settinglist); // print the module header.. fprintf(file, "\n[%s]", module); setting = settinglist.first; - while(setting) + while (setting) { DBVARIANT dbv; if (!GetSetting(hContact, module, setting->name, &dbv)) { switch (dbv.type) { - case DBVT_BYTE: - fprintf(file, "\n%s=b%s", setting->name, itoa(dbv.bVal,tmp,10)); - db_free(&dbv); - break; - case DBVT_WORD: - fprintf(file, "\n%s=w%s", setting->name, itoa(dbv.wVal,tmp,10)); - db_free(&dbv); - break; - case DBVT_DWORD: - fprintf(file, "\n%s=d%s", setting->name, itoa(dbv.dVal,tmp,10)); - db_free(&dbv); - break; - case DBVT_ASCIIZ: - case DBVT_UTF8: - 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); - db_free(&dbv); - break; - case DBVT_BLOB: + case DBVT_BYTE: + fprintf(file, "\n%s=b%s", setting->name, itoa(dbv.bVal, tmp, 10)); + db_free(&dbv); + break; + case DBVT_WORD: + fprintf(file, "\n%s=w%s", setting->name, itoa(dbv.wVal, tmp, 10)); + db_free(&dbv); + break; + case DBVT_DWORD: + fprintf(file, "\n%s=d%s", setting->name, itoa(dbv.dVal, tmp, 10)); + db_free(&dbv); + break; + case DBVT_ASCIIZ: + case DBVT_UTF8: + if (strchr(dbv.pszVal, '\r')) { - int j; - char *data = NULL; - if (!(data = (char*)mir_alloc( 3*(dbv.cpbVal+1)*sizeof(char)))) - break; - data[0] = '\0'; - for (j=0; jname , data); - mir_free(data); + 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); db_free(&dbv); break; + case DBVT_BLOB: + { + int j; + char *data = NULL; + if (!(data = (char*)mir_alloc(3 * (dbv.cpbVal + 1)*sizeof(char)))) + break; + data[0] = '\0'; + for (j = 0; j < dbv.cpbVal; j++) + { + char tmp[16]; + mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv.pbVal[j]); + strcat(data, tmp); + } + fprintf(file, "\n%s=n%s", setting->name, data); + mir_free(data); + } + db_free(&dbv); + break; } } setting = (ModSetLinkLinkItem *)setting->next; @@ -161,7 +161,7 @@ char *NickFromHContact(MCONTACT 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) @@ -170,13 +170,13 @@ char *NickFromHContact(MCONTACT 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 { @@ -184,9 +184,9 @@ char *NickFromHContact(MCONTACT hContact) if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) { char szUID[256]; GetValue(hContact, szProto, uid, szUID, SIZEOF(szUID)); - mir_snprintf(nick, SIZEOF(nick), "%s *(%s)*<%s>*{%s}*", (char*)GetContactName(hContact,szProto,0), szProto, uid, 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); + else mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); } } @@ -196,18 +196,17 @@ char *NickFromHContact(MCONTACT hContact) // hContact == -1, module == "" - all contacts void exportDB(MCONTACT hContact, char *module) { - int nullcontactDone = 0; ModSetLinkLinkItem *mod; // enum all the modules ModuleSettingLL modlist; if (!EnumModules(&modlist)) { - msg(Translate("Error loading module list"),modFullname); + msg(Translate("Error loading module list"), modFullname); return; } char fileName[MAX_PATH]; - if (Openfile(fileName, (hContact==INVALID_CONTACT_ID)?NULL:module)) + if (Openfile(fileName, (hContact == INVALID_CONTACT_ID) ? NULL : module)) { FILE *file = fopen(fileName, "wt"); if (!file) { @@ -215,7 +214,7 @@ void exportDB(MCONTACT hContact, char *module) return; } - SetCursor(LoadCursor(NULL,IDC_WAIT)); + SetCursor(LoadCursor(NULL, IDC_WAIT)); // exporting entire db if (hContact == INVALID_CONTACT_ID) @@ -226,7 +225,7 @@ void exportDB(MCONTACT hContact, char *module) { fprintf(file, "SETTINGS:\n"); mod = modlist.first; - while(mod) + while (mod) { if (IsModuleEmpty(hContact, mod->name)) { @@ -259,7 +258,7 @@ void exportDB(MCONTACT hContact, char *module) 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)) @@ -274,7 +273,7 @@ void exportDB(MCONTACT hContact, char *module) if (module == NULL) // export all modules { mod = modlist.first; - while(mod) + while (mod) { if (IsModuleEmpty(hContact, mod->name)) { @@ -305,7 +304,7 @@ void exportDB(MCONTACT hContact, char *module) fprintf(file, "SETTINGS:\n"); mod = modlist.first; - while(mod) + while (mod) { if (IsModuleEmpty(hContact, mod->name)) { @@ -330,7 +329,7 @@ void exportDB(MCONTACT hContact, char *module) } fclose(file); - SetCursor(LoadCursor(NULL,IDC_ARROW)); + SetCursor(LoadCursor(NULL, IDC_ARROW)); } FreeModuleSettingLL(&modlist); @@ -349,60 +348,60 @@ MCONTACT CheckNewContact(char *myProto, char *uid, char *myName) return INVALID_CONTACT_ID; } -void importSettings(MCONTACT hContact, char *importstring ) +void importSettings(MCONTACT hContact, char *importstring) { char module[256] = "", setting[256] = "", *end; - int i=0, value, type; + int i = 0, value, type; importstring = strtok(importstring, "\n"); - SetCursor(LoadCursor(NULL,IDC_WAIT)); + SetCursor(LoadCursor(NULL, IDC_WAIT)); while (importstring != NULL) { - i=0; + i = 0; rtrim(importstring); if (importstring[i] == '\0') { importstring = strtok(NULL, "\n"); continue; } - else if (!strncmp(&importstring[i],"SETTINGS:",strlen("SETTINGS:"))) + else if (!strncmp(&importstring[i], "SETTINGS:", strlen("SETTINGS:"))) { importstring = strtok(NULL, "\n"); continue; } - else if (!strncmp(&importstring[i],"CONTACT:", strlen("CONTACT:"))) + else if (!strncmp(&importstring[i], "CONTACT:", strlen("CONTACT:"))) { - int len, add = 1; + int len; hContact = INVALID_CONTACT_ID; i = i + (int)strlen("CONTACT:"); len = (int)strlen(&importstring[i]); if (len > 10) { - char uid[256]="",szUID[256]="",szProto[512]=""; - char *p1,*p2; + char uid[256] = "", szUID[256] = "", szProto[512] = ""; + char *p1, *p2; p1 = strrchr(&importstring[i], '>*{'); p2 = strrchr(&importstring[i], '}*'); - if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szUID)) { - strncpy(szUID, p1+1, p2-p1-2); + 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)) { - strncpy(uid, p1+1, p2-p1-3); + 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); + strncpy(szProto, p1 + 1, p2 - p1 - 3); - protouid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); + protouid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR)protouid != CALLSERVICE_NOTFOUND) { if (!mir_strcmp(protouid, uid)) hContact = CheckNewContact(szProto, uid, szUID); @@ -420,40 +419,40 @@ void importSettings(MCONTACT hContact, char *importstring ) hContact = temp; } } - else if (importstring[i] == '[' && !strchr(&importstring[i+1],'='))// get the module + else if (importstring[i] == '[' && !strchr(&importstring[i + 1], '='))// get the module { - if (end = strpbrk(&importstring[i+1], "]")) { + if (end = strpbrk(&importstring[i + 1], "]")) { *end = '\0'; - strcpy(module, &importstring[i+1]); + strcpy(module, &importstring[i + 1]); } } - else if (importstring[i] == '-' && importstring[i+1] == '[' && - !strchr(&importstring[i+2],'='))// get the module + else if (importstring[i] == '-' && importstring[i + 1] == '[' && + !strchr(&importstring[i + 2], '='))// get the module { - if (end = strpbrk(&importstring[i+2], "]")) { + if (end = strpbrk(&importstring[i + 2], "]")) { *end = '\0'; - strcpy(module, &importstring[i+2]); + strcpy(module, &importstring[i + 2]); deleteModule(module, hContact, 1); } } else if (strstr(&importstring[i], "=") && module[0]) // get the setting { - if (end = strpbrk(&importstring[i+1], "=")) { + if (end = strpbrk(&importstring[i + 1], "=")) { *end = '\0'; strcpy(setting, &importstring[i]); // get the type - type = *(end+1); + type = *(end + 1); if (mir_tstrcmp(module, "CList") == 0 && mir_tstrcmp(setting, "Group") == 0) { - WCHAR* GroupName = mir_a2u(end+2); + WCHAR* GroupName = mir_a2u(end + 2); if (!GroupName) continue; HANDLE GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPEXISTS, 0, LPARAM(GroupName)); - if(GroupHandle == 0) { + if (GroupHandle == 0) { GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)GroupName); - if(GroupHandle) { + if (GroupHandle) { CallService(MS_CLUI_GROUPADDED, (WPARAM)GroupHandle, 0); CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)GroupHandle, 1); } @@ -462,146 +461,146 @@ void importSettings(MCONTACT hContact, char *importstring ) } switch (type) { - case 'b': - case 'B': - if (sscanf((end+2), "%d", &value) == 1) - db_set_b(hContact, module, setting, (BYTE)value); - break; - case 'w': - case 'W': - if (sscanf((end+2), "%d", &value) == 1) - db_set_w(hContact, module, setting, (WORD)value); - break; - case 'd': - case 'D': - if (sscanf((end+2), "%d", &value) == 1) - db_set_dw(hContact, module, setting, (DWORD)value); - break; - case 's': - case 'S': - db_set_s(hContact,module, setting, (end+2)); - break; - 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; - } - memmove(pstr+1,pstr+2,mir_strlen(pstr+2)+1); - } + case 'b': + case 'B': + if (sscanf((end + 2), "%d", &value) == 1) + db_set_b(hContact, module, setting, (BYTE)value); + break; + case 'w': + case 'W': + if (sscanf((end + 2), "%d", &value) == 1) + db_set_w(hContact, module, setting, (WORD)value); + break; + case 'd': + case 'D': + if (sscanf((end + 2), "%d", &value) == 1) + db_set_dw(hContact, module, setting, (DWORD)value); + break; + case 's': + case 'S': + db_set_s(hContact, module, setting, (end + 2)); + break; + 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; } + memmove(pstr + 1, pstr + 2, mir_strlen(pstr + 2) + 1); } - case 'u': - case 'U': - db_set_utf(hContact,module, setting, (end+2)); - break; - case 'l': - case 'L': - case '-': - db_unset(hContact, module, setting); - break; - case 'n': - case 'N': - WriteBlobFromString(hContact, module, setting, (end+2), (int)strlen((end+2))); - break; + } + } + case 'u': + case 'U': + db_set_utf(hContact, module, setting, (end + 2)); + break; + case 'l': + case 'L': + case '-': + db_unset(hContact, module, setting); + break; + case 'n': + case 'N': + WriteBlobFromString(hContact, module, setting, (end + 2), (int)strlen((end + 2))); + break; } } } importstring = strtok(NULL, "\n"); } - SetCursor(LoadCursor(NULL,IDC_ARROW)); + SetCursor(LoadCursor(NULL, IDC_ARROW)); } INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) + switch (msg) { - case WM_INITDIALOG: - { - hwnd2importWindow = hwnd; - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); - TranslateDialogDefault(hwnd); - SendDlgItemMessage(hwnd, IDC_TEXT, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)*0x7FFFFFFF, 0); - } - break; + case WM_INITDIALOG: + { + hwnd2importWindow = hwnd; + SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); + TranslateDialogDefault(hwnd); + SendDlgItemMessage(hwnd, IDC_TEXT, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR) * 0x7FFFFFFF, 0); + } + break; - case WM_COMMAND: + case WM_COMMAND: + { + switch (LOWORD(wParam)) { - switch(LOWORD(wParam)) - { - case IDC_CRLF: - { - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); - char *string = (char*)_alloca(length+3); - int Pos = 2; + case IDC_CRLF: + { + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); + char *string = (char*)_alloca(length + 3); + int Pos = 2; - if (length) - { - int Range = SendDlgItemMessage(hwnd,IDC_TEXT,EM_GETSEL,0,0); - int Min = LOWORD(Range); - int Max = HIWORD(Range); + if (length) + { + int Range = SendDlgItemMessage(hwnd, IDC_TEXT, EM_GETSEL, 0, 0); + int Min = LOWORD(Range); + int Max = HIWORD(Range); - GetDlgItemText(hwnd, IDC_TEXT, string, length+1); + GetDlgItemText(hwnd, IDC_TEXT, string, length + 1); - if (Min == -1) - memcpy(string, crlf_string, sizeof(crlf_string)); - else - if (Max == -1 || Max >= length) - memcpy(&string[Min], crlf_string, sizeof(crlf_string)); - else - if (Max-Min > 2) + if (Min == -1) + memcpy(string, crlf_string, sizeof(crlf_string)); + else + if (Max == -1 || Max >= length) + memcpy(&string[Min], crlf_string, sizeof(crlf_string)); + else + if (Max - Min > 2) { memcpy(&string[Min], crlf_string, sizeof(crlf_string)); - memmove(&string[Min+2], &string[Max], length - Max + 1); + memmove(&string[Min + 2], &string[Max], length - Max + 1); } else { - memmove(&string[Min+2], &string[Max], length - Max + 1); + memmove(&string[Min + 2], &string[Max], length - Max + 1); memcpy(&string[Min], crlf_string, sizeof(crlf_string)); } - if (Min) Pos += Min; - } - else - memcpy(string, crlf_string, sizeof(crlf_string)); + if (Min) Pos += Min; + } + else + memcpy(string, crlf_string, sizeof(crlf_string)); - SetDlgItemText(hwnd, IDC_TEXT, string); - SendDlgItemMessage(hwnd,IDC_TEXT,EM_SETSEL,Pos,Pos); - SetFocus(GetDlgItem(hwnd, IDC_TEXT)); - } - break; - - case IDOK: - { - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); - if (length) - { - char *string = (char*)_alloca(length+1); - if (!string) { - msg(Translate("Couldn't allocate enough memory!"), modFullname); - DestroyWindow(hwnd); - } - GetDlgItemText(hwnd, IDC_TEXT, string, length+1); - importSettings(hContact, string); - refreshTree(1); - } - } - break; - - case IDCANCEL: + SetDlgItemText(hwnd, IDC_TEXT, string); + SendDlgItemMessage(hwnd, IDC_TEXT, EM_SETSEL, Pos, Pos); + SetFocus(GetDlgItem(hwnd, IDC_TEXT)); + } + break; + + case IDOK: + { + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); + if (length) + { + char *string = (char*)_alloca(length + 1); + if (!string) { + msg(Translate("Couldn't allocate enough memory!"), modFullname); DestroyWindow(hwnd); - hwnd2importWindow = 0; - break; + } + GetDlgItemText(hwnd, IDC_TEXT, string, length + 1); + importSettings(hContact, string); + refreshTree(1); } } break; + + case IDCANCEL: + DestroyWindow(hwnd); + hwnd2importWindow = 0; + break; + } + } + break; } return 0; } @@ -616,7 +615,7 @@ void ImportSettingsMenuItem(MCONTACT hContact) int Openfile2Import(char *outputFiles) { - OPENFILENAME ofn = {0}; + OPENFILENAME ofn = { 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"); @@ -625,7 +624,7 @@ int Openfile2Import(char *outputFiles) ofn.lpstrFilter = filter; ofn.hwndOwner = 0; ofn.lpstrFile = outputFiles; - ofn.nMaxFile = MAX_PATH*10; + ofn.nMaxFile = MAX_PATH * 10; ofn.nMaxFileTitle = MAX_PATH; ofn.Flags = OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; ofn.lpstrTitle = title; @@ -642,7 +641,7 @@ BOOL Exists(LPCTSTR strName) void ImportSettingsFromFileMenuItem(MCONTACT hContact, char* FilePath) { - char szFileNames[MAX_PATH*10] = {0}; + char szFileNames[MAX_PATH * 10] = { 0 }; char szPath[MAX_PATH] = ""; char szFile[MAX_PATH]; int index = 0; @@ -653,7 +652,7 @@ void ImportSettingsFromFileMenuItem(MCONTACT hContact, char* FilePath) offset = Openfile2Import(szFileNames); else { - if(Exists(FilePath)) + if (Exists(FilePath)) mir_tstrcpy(szFileNames, FilePath); else mir_tstrcpy(szFileNames, ""); @@ -668,21 +667,21 @@ void ImportSettingsFromFileMenuItem(MCONTACT hContact, char* FilePath) strcat(szPath, "\\"); } - while(szFileNames[index]) + while (szFileNames[index]) { strcpy(szFile, szPath); strcat(szFile, &szFileNames[index]); - index += (int)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) { - if (GetFileSize(hFile, NULL) > 0) + if (GetFileSize(hFile, NULL) > 0) { hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); if (hMap) { - pFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0 ,0); + pFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0, 0); if (pFile) { importSettings(hContact, (char*)pFile); diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp index 9cb1ae78aa..7071322571 100644 --- a/plugins/DbEditorPP/src/findwindow.cpp +++ b/plugins/DbEditorPP/src/findwindow.cpp @@ -31,7 +31,7 @@ typedef struct { } FindInfo; -int FindDialogResize(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc) +int FindDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc) { switch (urc->wId) { case IDC_LIST: @@ -87,8 +87,8 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP break; if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_MODNAME) && - BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) && - BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE)) + BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) && + BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE)) break; FindInfo *fi = (FindInfo*)mir_calloc(sizeof(FindInfo)); @@ -152,24 +152,24 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP } break; case WM_GETMINMAXINFO: - { - MINMAXINFO *mmi = (MINMAXINFO*)lParam; - mmi->ptMinTrackSize.x = 520; - mmi->ptMinTrackSize.y = 300; - } - return 0; + { + MINMAXINFO *mmi = (MINMAXINFO*)lParam; + mmi->ptMinTrackSize.x = 520; + mmi->ptMinTrackSize.y = 300; + } + return 0; case WM_SIZE: - { - UTILRESIZEDIALOG urd; - memset(&urd, 0, sizeof(urd)); - urd.cbSize = sizeof(urd); - urd.hInstance = hInst; - urd.hwndDlg = hwnd; - urd.lpTemplate = MAKEINTRESOURCE(IDD_FIND); - urd.pfnResizer = FindDialogResize; - CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); - } - break; + { + UTILRESIZEDIALOG urd; + memset(&urd, 0, sizeof(urd)); + urd.cbSize = sizeof(urd); + urd.hInstance = hInst; + urd.hwndDlg = hwnd; + urd.lpTemplate = MAKEINTRESOURCE(IDD_FIND); + urd.pfnResizer = FindDialogResize; + CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); + } + break; case WM_DESTROY: freeItems(hwnd); @@ -178,26 +178,25 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP return 0; } -void ItemFound(HWND hwnd, MCONTACT hContact,const char *module,const char *setting,const char* value,int type) +void ItemFound(HWND hwnd, MCONTACT hContact, const char *module, const char *setting, const char* value, int type) { ItemInfo *ii = (ItemInfo*)mir_calloc(sizeof(ItemInfo)); if (!ii) return; int index; char text[256] = ""; - int result = 0; char szValue[256]; char *name, *mode; if (type & FW_REPLACED) mode = Translate("Replaced with"); else - if (type & FW_DELETED) - mode = Translate("Deleted"); - else - mode = Translate("Found"); + if (type & FW_DELETED) + mode = Translate("Deleted"); + else + mode = Translate("Found"); - name = hContact?(char*)GetContactName(hContact,NULL,0):Translate("Settings"); + name = hContact ? (char*)GetContactName(hContact, NULL, 0) : Translate("Settings"); switch (type & 0xFF) { case FW_MODULE: @@ -219,7 +218,7 @@ void ItemFound(HWND hwnd, MCONTACT hContact,const char *module,const char *setti break; } - index = SendMessage(hwnd,LB_ADDSTRING,0,(LPARAM)text); + index = SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM)text); if (type & FW_DELETED) { SendMessage(hwnd, LB_SETITEMDATA, index, 0); mir_free(ii); @@ -266,7 +265,6 @@ int replaceValue(HWND hwnd, MCONTACT hContact, const char *module, const char *s { int count = 0; DWORD num = 0; - BOOL write = 0; int isNumeric; char *myreplace = NULL; DBVARIANT val = { 0 }; diff --git a/plugins/DbEditorPP/src/headers.h b/plugins/DbEditorPP/src/headers.h index ff5bac7f74..1c45c21b71 100644 --- a/plugins/DbEditorPP/src/headers.h +++ b/plugins/DbEditorPP/src/headers.h @@ -61,7 +61,7 @@ extern MCONTACT hRestore; ///////////////////// #ifndef NDEBUG - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif //======================================================= @@ -97,7 +97,7 @@ extern MCONTACT hRestore; /*********************** ModuleTreeInfoStruct this gets dumped as the lparam for each module tree item -************************/ + ************************/ // types #define CONTACT_ROOT_ITEM 0 #define CONTACT 1 @@ -187,7 +187,7 @@ int GetSetting(MCONTACT hContact, const char *szModule, const char *szSetting, D int GetValue(MCONTACT hContact, const char *szModule, const char *szSetting, char *Value, int length); int GetValueW(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *Value, int length); char *u2a(wchar_t *src); -wchar_t *a2u(char *src , wchar_t *buffer, int len); +wchar_t *a2u(char *src, wchar_t *buffer, int len); WCHAR *GetContactName(MCONTACT hContact, const char *szProto, int unicode); BOOL IsProtocolLoaded(char *pszProtocolName); diff --git a/plugins/DbEditorPP/src/icons.cpp b/plugins/DbEditorPP/src/icons.cpp index efee7c5d35..4ccb5d2dde 100644 --- a/plugins/DbEditorPP/src/icons.cpp +++ b/plugins/DbEditorPP/src/icons.cpp @@ -3,22 +3,22 @@ HIMAGELIST himl; IconItem iconList[] = { - { LPGENT("Main icon"), "DBE++_0", ICO_DBE_BUTT }, - { LPGENT("Closed known module"), "DBE++_1", ICO_KNOWN }, - { LPGENT("Open known module"), "DBE++_2", ICO_KNOWNOPEN }, - { LPGENT("Settings"), "DBE++_5", ICO_SETTINGS }, - { LPGENT("Contacts group"), "DBE++_6", ICO_CONTACTS }, - { LPGENT("Unknown contact"), "DBE++_7", ICO_OFFLINE }, - { LPGENT("Known contact"), "DBE++_8", ICO_ONLINE }, - { LPGENT("Open user tree"), "DBE++_9", ICO_REGUSER }, - - { LPGENT("BLOB setting"), "DBE++_BINARY", ICO_BINARY }, - { LPGENT("Byte setting"), "DBE++_BYTE", ICO_BYTE }, - { LPGENT("Word setting"), "DBE++_WORD", ICO_WORD }, - { LPGENT("Dword setting"), "DBE++_DWORD", ICO_DWORD }, - { LPGENT("String setting"), "DBE++_STRING", ICO_STRING }, + { LPGENT("Main icon"), "DBE++_0", ICO_DBE_BUTT }, + { LPGENT("Closed known module"), "DBE++_1", ICO_KNOWN }, + { LPGENT("Open known module"), "DBE++_2", ICO_KNOWNOPEN }, + { LPGENT("Settings"), "DBE++_5", ICO_SETTINGS }, + { LPGENT("Contacts group"), "DBE++_6", ICO_CONTACTS }, + { LPGENT("Unknown contact"), "DBE++_7", ICO_OFFLINE }, + { LPGENT("Known contact"), "DBE++_8", ICO_ONLINE }, + { LPGENT("Open user tree"), "DBE++_9", ICO_REGUSER }, + + { LPGENT("BLOB setting"), "DBE++_BINARY", ICO_BINARY }, + { LPGENT("Byte setting"), "DBE++_BYTE", ICO_BYTE }, + { LPGENT("Word setting"), "DBE++_WORD", ICO_WORD }, + { LPGENT("Dword setting"), "DBE++_DWORD", ICO_DWORD }, + { LPGENT("String setting"), "DBE++_STRING", ICO_STRING }, { LPGENT("Unicode setting"), "DBE++_UNICODE", ICO_UNICODE }, - { LPGENT("Handle"), "DBE++_HANDLE", ICO_HANDLE } + { LPGENT("Handle"), "DBE++_HANDLE", ICO_HANDLE } }; void addIcons(void) @@ -83,7 +83,7 @@ int GetProtoIcon(char *szProto) BOOL IsProtocolLoaded(char *pszProtocolName) { if (protoCount) - for(int i = 0; i < protoCount; i++) + for (int i = 0; i < protoCount; i++) if (!mir_strcmp(protocols[i]->szModuleName, pszProtocolName)) return TRUE; diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index 96f7c71493..0d0902f896 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -18,7 +18,7 @@ IconItem iconList[]; // MirandaPluginInfo //======================== -PLUGININFOEX pluginInfoEx = +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -30,21 +30,21 @@ PLUGININFOEX pluginInfoEx = __AUTHORWEB, UNICODE_AWARE, // {A8A417EF-07AA-4F37-869F-7BFD74886534} - {0xa8a417ef, 0x7aa, 0x4f37, {0x86, 0x9f, 0x7b, 0xfd, 0x74, 0x88, 0x65, 0x34}} + { 0xa8a417ef, 0x7aa, 0x4f37, { 0x86, 0x9f, 0x7b, 0xfd, 0x74, 0x88, 0x65, 0x34 } } }; -extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD) { return &pluginInfoEx; } // we implement service mode interface -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SERVICEMODE, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_LAST }; //======================== // WINAPI DllMain //======================== -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) { hInst = hinstDLL; return TRUE; @@ -54,7 +54,7 @@ void settingChanged(HWND hwnd2Settings, MCONTACT hContact, char *module, char *s int DBSettingChanged(WPARAM hContact, LPARAM lParam) { - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING *)lParam; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; char *setting; SettingListInfo *info; @@ -80,7 +80,7 @@ int DBSettingChanged(WPARAM hContact, LPARAM lParam) } } } - + // watch list if (!hwnd2watchedVarsWindow && !usePopups) return 0; @@ -101,7 +101,7 @@ int DBSettingChanged(WPARAM hContact, LPARAM lParam) return 0; } -INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM lParam) +INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM) { if (!hwnd2mainWindow) { // so only opens 1 at a time hRestore = wParam; @@ -129,7 +129,7 @@ BOOL IsCP_UTF8(void) return GetCPInfo(CP_UTF8, &CPInfo); } -static int OnTTBLoaded(WPARAM wParam, LPARAM lParam) +static int OnTTBLoaded(WPARAM, LPARAM) { TTBButton ttb = { sizeof(ttb) }; ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; @@ -141,7 +141,7 @@ static int OnTTBLoaded(WPARAM wParam, LPARAM lParam) return 0; } -int ModulesLoaded(WPARAM wParam, LPARAM lParam) +int ModulesLoaded(WPARAM, LPARAM) { addIcons(); @@ -192,7 +192,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) return 0; } -int PreShutdown(WPARAM wParam, LPARAM lParam) +int PreShutdown(WPARAM, LPARAM) { if (hwnd2watchedVarsWindow) DestroyWindow(hwnd2watchedVarsWindow); if (hwnd2mainWindow) DestroyWindow(hwnd2mainWindow); @@ -200,7 +200,7 @@ int PreShutdown(WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR ServiceMode(WPARAM wParam, LPARAM lParam) +INT_PTR ServiceMode(WPARAM, LPARAM) { addIcons(); bServiceMode = TRUE; @@ -266,8 +266,6 @@ int DBGetContactSettingStringStatic(MCONTACT hContact, char *szModule, char *szS db_free(&dbv); return 0; } - - return 0; } int WriteBlobFromString(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szValue, int len) @@ -310,7 +308,7 @@ int GetSetting(MCONTACT hContact, const char *szModule, const char *szSetting, D int GetValue(MCONTACT hContact, const char *szModule, const char *szSetting, char *Value, int length) { - DBVARIANT dbv = {0}; + DBVARIANT dbv = { 0 }; if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) { switch (dbv.type) { @@ -350,7 +348,7 @@ int GetValue(MCONTACT hContact, const char *szModule, const char *szSetting, cha int GetValueW(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *Value, int length) { - DBVARIANT dbv = {0}; + DBVARIANT dbv = { 0 }; WCHAR *wc; int len; @@ -465,40 +463,40 @@ WCHAR* GetContactName(MCONTACT hContact, const char *szProto, int unicode) break; case 5: // Unique id - { - // protocol must define a PFLAG_UNIQUEIDSETTING - char *uid = (char *)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) - r = GetDatabaseString(hContact, proto, uid, res, SIZEOF(res), unicode); - } - break; + { + // protocol must define a PFLAG_UNIQUEIDSETTING + char *uid = (char *)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) + r = GetDatabaseString(hContact, proto, uid, res, SIZEOF(res), unicode); + } + break; case 6: // first + last name - { - int len = 0; - - if (r = GetDatabaseString(hContact, proto, "FirstName", res, SIZEOF(res), unicode)) { - if (unicode) - len = (int)wcslen(res); - else - len = (int)strlen((char *)res); - } + { + int len = 0; + + if (r = GetDatabaseString(hContact, proto, "FirstName", res, SIZEOF(res), unicode)) { + if (unicode) + len = (int)wcslen(res); else - res[0] = 0; + len = (int)strlen((char *)res); + } + else + res[0] = 0; - if (len && len < SIZEOF(res) - 2) { - if (unicode) - wcscat(res, L" "); - else - strcat((char*)res, " "); + if (len && len < SIZEOF(res) - 2) { + if (unicode) + wcscat(res, L" "); + else + strcat((char*)res, " "); - len++; - } + len++; + } - if (SIZEOF(res) - len > 1) - r |= GetDatabaseString(hContact, proto, "LastName", &res[len], SIZEOF(res) - len, unicode); + if (SIZEOF(res) - len > 1) + r |= GetDatabaseString(hContact, proto, "LastName", &res[len], SIZEOF(res) - len, unicode); - break; - } + break; + } } if (r) diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 493927ce6b..7c74985b66 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -12,7 +12,7 @@ extern BOOL bServiceMode; void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); void SettingsListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -int DialogResize(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc) +int DialogResize(HWND, LPARAM lParam, UTILRESIZECONTROL *urc) { switch (urc->wId) { case IDC_MODULES: @@ -53,12 +53,12 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return HTCLIENT; case WM_SETCURSOR: - { - RECT rc; - GetClientRect(hwnd, &rc); - SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE)); - } - return TRUE; + { + RECT rc; + GetClientRect(hwnd, &rc); + SetCursor(rc.right > rc.bottom ? LoadCursor(NULL, IDC_SIZENS) : LoadCursor(NULL, IDC_SIZEWE)); + } + return TRUE; case WM_LBUTTONDOWN: SetCapture(hwnd); @@ -84,18 +84,18 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR { switch (msg) { case WM_RBUTTONDOWN: - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(hwnd, &hti.pt); - - if (TreeView_HitTest(hwnd, &hti)) { - if (hti.flags&TVHT_ONITEM) - TreeView_SelectItem(hwnd, hti.hItem); - } + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(hwnd, &hti.pt); + + if (TreeView_HitTest(hwnd, &hti)) { + if (hti.flags&TVHT_ONITEM) + TreeView_SelectItem(hwnd, hti.hItem); } - break; + } + break; case WM_CHAR: if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6) @@ -304,63 +304,63 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return TRUE; case GC_SPLITTERMOVED: - { - int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); - - RECT rc2; - GetWindowRect(hwnd, &rc2); - - if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) { - RECT rc; - GetClientRect(hwnd, &rc); - POINT pt = { wParam, 0 }; - ScreenToClient(hwnd, &pt); - - splitterPos = rc.left + pt.x + 1; - if (splitterPos < 65) - splitterPos = 65; - if (splitterPos > rc2.right - rc2.left - 65) - splitterPos = rc2.right - rc2.left - 65; - SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos); - db_set_w(NULL, modname, "Splitter", (WORD)splitterPos); - } - PostMessage(hwnd, WM_SIZE, 0, 0); - } - break; + { + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); - case WM_GETMINMAXINFO: - { - MINMAXINFO *mmi = (MINMAXINFO *)lParam; - int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); + RECT rc2; + GetWindowRect(hwnd, &rc2); - if (splitterPos + 40 > 200) - mmi->ptMinTrackSize.x = splitterPos + 65; - else - mmi->ptMinTrackSize.x = 200; - mmi->ptMinTrackSize.y = 150; + if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) { + RECT rc; + GetClientRect(hwnd, &rc); + POINT pt = { wParam, 0 }; + ScreenToClient(hwnd, &pt); + + splitterPos = rc.left + pt.x + 1; + if (splitterPos < 65) + splitterPos = 65; + if (splitterPos > rc2.right - rc2.left - 65) + splitterPos = rc2.right - rc2.left - 65; + SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos); + db_set_w(NULL, modname, "Splitter", (WORD)splitterPos); } - return 0; + PostMessage(hwnd, WM_SIZE, 0, 0); + } + break; + + case WM_GETMINMAXINFO: + { + MINMAXINFO *mmi = (MINMAXINFO *)lParam; + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA); + + if (splitterPos + 40 > 200) + mmi->ptMinTrackSize.x = splitterPos + 65; + else + mmi->ptMinTrackSize.x = 200; + mmi->ptMinTrackSize.y = 150; + } + return 0; case WM_MOVE: case WM_SIZE: - { - UTILRESIZEDIALOG urd; - - memset(&urd, 0, sizeof(urd)); - urd.cbSize = sizeof(urd); - urd.hInstance = hInst; - urd.hwndDlg = hwnd; - 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); - - if (msg == WM_SIZE && wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED) - db_set_b(NULL, modname, "Maximised", 1); - else if (msg == WM_SIZE && wParam == SIZE_RESTORED) - db_set_b(NULL, modname, "Maximised", 0); - } - break; + { + UTILRESIZEDIALOG urd; + + memset(&urd, 0, sizeof(urd)); + urd.cbSize = sizeof(urd); + urd.hInstance = hInst; + urd.hwndDlg = hwnd; + 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); + + if (msg == WM_SIZE && wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED) + db_set_b(NULL, modname, "Maximised", 1); + else if (msg == WM_SIZE && wParam == SIZE_RESTORED) + db_set_b(NULL, modname, "Maximised", 0); + } + break; case WM_DESTROY: // free our shit! if (db_get_b(NULL, modname, "RestoreOnOpen", 1)) { @@ -464,8 +464,8 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS)); } - break; - ///////////////////////// // watches + break; + ///////////////////////// // watches case MENU_VIEW_WATCHES: if (!hwnd2watchedVarsWindow) // so only opens 1 at a time hwnd2watchedVarsWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), 0, WatchDlgProc); @@ -548,7 +548,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED)); db_set_b(NULL, modname, "RestoreOnOpen", (byte)save); } - break; + break; case MENU_SORT_ORDER: Order = !Order; CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (Order ? MF_CHECKED : MF_UNCHECKED)); diff --git a/plugins/DbEditorPP/src/modsettingenum.cpp b/plugins/DbEditorPP/src/modsettingenum.cpp index a1a49bcf42..8c315f2a70 100644 --- a/plugins/DbEditorPP/src/modsettingenum.cpp +++ b/plugins/DbEditorPP/src/modsettingenum.cpp @@ -19,7 +19,7 @@ void FreeModuleSettingLL(ModuleSettingLL* msll) msll->last = 0; } -int enumModulesSettingsProc( const char *szName , DWORD ofsModuleName , LPARAM lParam) +int enumModulesSettingsProc(const char *szName, DWORD, LPARAM lParam) { ModuleSettingLL *msll = (ModuleSettingLL *)lParam; if (!msll->first) { @@ -68,7 +68,7 @@ int EnumSettings(MCONTACT hContact, char* module, ModuleSettingLL *msll) return !CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, (LPARAM)&dbces); } -int CheckIfModuleIsEmptyProc(const char *szSetting, LPARAM lParam) +int CheckIfModuleIsEmptyProc(const char *, LPARAM) { return 1; } diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index 7903ea7848..106f46c737 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -11,10 +11,8 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, HTREEITEM contact; ModuleTreeInfoStruct *lParam; ModSetLinkLinkItem *module; - int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); int itemscount = 0; int loaded, i = 0, icon = 0; - HWND hwnd = GetParent(hwnd2Tree); int hItem = -1; SetWindowText(hwnd2mainWindow, Translate("Loading contacts...")); @@ -51,7 +49,6 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, lParam->type |= EMPTY; // contacts name - DBVARIANT dbv = {0}; WCHAR nick[256]; WCHAR protoW[256]; // unicode proto @@ -128,7 +125,7 @@ void doItems(HWND hwnd2Tree, ModuleSettingLL *modlist, int count) char percent[96], title[64]; mir_snprintf(title, SIZEOF(title), Translate("Loading modules...")); - TVITEM item = {0}; + TVITEM item = { 0 }; item.mask = TVIF_STATE | TVIF_PARAM; HTREEITEM contact = TreeView_GetChild(hwnd2Tree, TVI_ROOT); @@ -255,8 +252,8 @@ void freeTree(HWND hwnd2Tree, MCONTACT hContact) } BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char *module) - /* the following code to go through the whole tree is nicked from codeguru.. - http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ +/* the following code to go through the whole tree is nicked from codeguru.. +http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ { TVITEM item; HTREEITEM lastItem, prelastItem; @@ -279,7 +276,7 @@ BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char *module) /* these next lines are not from code guru..... */ if (item.lParam) { ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; - if (hContact == mtis->hContact && !mir_strcmp(text,module)) { + if (hContact == mtis->hContact && !mir_strcmp(text, module)) { mir_free(mtis); TreeView_DeleteItem(hwnd2Tree, item.hItem); lastItem = prelastItem; @@ -294,7 +291,7 @@ BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char *module) while (!(item.hItem = TreeView_GetNextSibling(hwnd2Tree, lastItem)) && (lastItem = item.hItem = TreeView_GetParent(hwnd2Tree, lastItem))) {} - } while ( item.hItem ); + } while (item.hItem); /*****************************************************************************/ return Result; @@ -322,7 +319,7 @@ void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const cha } if (hParent && newModule) { - TVINSERTSTRUCT tvi = {0}; + TVINSERTSTRUCT tvi = { 0 }; ModuleTreeInfoStruct *lParam; tvi.hParent = hParent; @@ -354,8 +351,8 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) { TVINSERTSTRUCT tvi; HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow, IDC_MODULES); - char SelectedModule[256] = {0}; - char SelectedSetting[256] = {0}; + char SelectedModule[256] = { 0 }; + char SelectedSetting[256] = { 0 }; MCONTACT hSelectedContact = hRestore; MCONTACT hContact; HTREEITEM contact, contactsRoot; @@ -380,7 +377,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) switch ((int)di) { case 1: // restore after rebuild if (HTREEITEM item = TreeView_GetSelection(hwnd2Tree)) { - TVITEM tvi = {0}; + TVITEM tvi = { 0 }; tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; tvi.pszText = SelectedModule; tvi.cchTextMax = SIZEOF(SelectedModule); @@ -534,7 +531,7 @@ static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd, UINT msg, WPA void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam); -void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hwnd here is to the main window, NOT the treview +void moduleListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam)// hwnd here is to the main window, NOT the treview { switch (((NMHDR *)lParam)->code) { case TVN_ITEMEXPANDINGA: @@ -543,7 +540,6 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)((LPNMTREEVIEW)lParam)->itemNew.lParam; if (mtis && (mtis->type == (CONTACT | EMPTY))) { TVINSERTSTRUCT tvi; - HTREEITEM item = {0}; ModuleTreeInfoStruct *_lParam; HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow, IDC_MODULES); ModSetLinkLinkItem *module; @@ -585,96 +581,96 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw case TVN_SELCHANGEDA: case TVN_SELCHANGEDW: - { - ModuleTreeInfoStruct *mtis; - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; - TVITEM tvi = {0}; - char text[264]; - MCONTACT hContact; - HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); - tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; - tvi.hItem = pnmtv->itemNew.hItem; - tvi.pszText = text; - tvi.cchTextMax = SIZEOF(text); - TreeView_GetItem(pnmtv->hdr.hwndFrom, &tvi); + { + ModuleTreeInfoStruct *mtis; + LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; + TVITEM tvi = { 0 }; + char text[264]; + MCONTACT hContact; + HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); + tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; + tvi.hItem = pnmtv->itemNew.hItem; + tvi.pszText = text; + tvi.cchTextMax = SIZEOF(text); + TreeView_GetItem(pnmtv->hdr.hwndFrom, &tvi); - if (tvi.lParam) { - mtis = (ModuleTreeInfoStruct *)tvi.lParam; - hContact = mtis->hContact; + if (tvi.lParam) { + mtis = (ModuleTreeInfoStruct *)tvi.lParam; + hContact = mtis->hContact; - if (mtis->type == STUB) - break; + if (mtis->type == STUB) + break; - if (populating) - Select = 0; + if (populating) + Select = 0; - if (mtis->type == MODULE) { - SettingListInfo *info = (SettingListInfo *)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA); - BOOL refresh = 1; + if (mtis->type == MODULE) { + SettingListInfo *info = (SettingListInfo *)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA); + BOOL refresh = 1; - if (info) { - if (info->hContact == hContact && !mir_strcmp(info->module, text)) - refresh = 0; - } + if (info) { + if (info->hContact == hContact && !mir_strcmp(info->module, text)) + refresh = 0; + } + + if (refresh) + PopulateSettings(hwnd2Settings, hContact, text); + } + else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) { + char data[32], szProto[256]; + int index, loaded, multi = 0; + LVITEM lvi = { 0 }; + lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; + lvi.iImage = 6; + + ClearListview(hwnd2Settings); + SetWindowLongPtr(hwnd2Settings, GWLP_USERDATA, 0); + if (himl2) + ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); - if (refresh) - PopulateSettings(hwnd2Settings, hContact, text); + if (mtis->type == CONTACT_ROOT_ITEM && !hContact) { + multi = 1; + hContact = db_find_first(); } - else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) { - char data[32], szProto[256]; - int index, loaded, multi = 0; - LVITEM lvi = {0}; - lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; - lvi.iImage = 6; - - ClearListview(hwnd2Settings); - SetWindowLongPtr(hwnd2Settings, GWLP_USERDATA, 0); - if (himl2) - ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); - - if (mtis->type == CONTACT_ROOT_ITEM && !hContact) { - multi = 1; - hContact = db_find_first(); - } - while (hContact && hwnd2mainWindow) { - if (multi) { - // filter - if (GetValue(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) - loaded = IsProtocolLoaded(szProto); - else - loaded = 0; - - if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) { - hContact = db_find_next(hContact); - continue; - } + while (hContact && hwnd2mainWindow) { + if (multi) { + // filter + if (GetValue(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) + loaded = IsProtocolLoaded(szProto); + else + loaded = 0; + + if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) { + hContact = db_find_next(hContact); + continue; } + } - lvi.iItem = 0; - lvi.pszText = (char *)GetContactName(hContact, NULL, FALSE); + lvi.iItem = 0; + lvi.pszText = (char *)GetContactName(hContact, NULL, FALSE); - index = ListView_InsertItem(hwnd2Settings, &lvi); + index = ListView_InsertItem(hwnd2Settings, &lvi); - mir_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")); - ListView_SetItemText(hwnd2Settings, index, 3, "0x0004 (4)"); + ListView_SetItemText(hwnd2Settings, index, 1, data); + ListView_SetItemText(hwnd2Settings, index, 2, Translate("HANDLE")); + ListView_SetItemText(hwnd2Settings, index, 3, "0x0004 (4)"); - if (!multi) - break; + if (!multi) + break; - hContact = db_find_next(hContact); - } + hContact = db_find_next(hContact); } - else - ClearListview(hwnd2Settings); } - else // clear any settings that may be there... + else ClearListview(hwnd2Settings); } - break; //TVN_SELCHANGED: + else // clear any settings that may be there... + ClearListview(hwnd2Settings); + } + break; //TVN_SELCHANGED: case NM_RCLICK: if (((NMHDR *)lParam)->code == NM_RCLICK) @@ -683,23 +679,23 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw case TVN_BEGINLABELEDITA: // subclass it.. case TVN_BEGINLABELEDITW: - { - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; - HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES)); - if (!mtis->type || (mtis->type == CONTACT)) { - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); - break; - } - mir_subclassWindow(hwnd2Edit, ModuleTreeLabelEditSubClassProc); - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); + { + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; + HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES)); + if (!mtis->type || (mtis->type == CONTACT)) { + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); + break; } - break; + mir_subclassWindow(hwnd2Edit, ModuleTreeLabelEditSubClassProc); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); + } + break; case TVN_ENDLABELEDITA: case TVN_ENDLABELEDITW: LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; - TVITEM tvi = {0}; + TVITEM tvi = { 0 }; char text[264]; char *newtext; ModuleTreeInfoStruct *mtis; @@ -740,7 +736,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw } } -void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here is to the main window, NOT the treview +void moduleListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to the main window, NOT the treview { TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(GetMessagePos()); @@ -749,7 +745,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) { if (hti.flags & TVHT_ONITEM) { - TVITEM tvi = {0}; + TVITEM tvi = { 0 }; HMENU hMenu, hSubMenu; int menuNumber; char module[256]; @@ -781,57 +777,57 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here switch (menuNumber) { case 1: // null module case 5: // contact module - { - // check if we r already watching the module - int i, watching = 0; - // check if the setting is being watched and if it is then check the menu item - if (WatchListArray.item) - for (i = 0; i < WatchListArray.count; i++) - if (WatchListArray.item[i].module && (hContact == WatchListArray.item[i].hContact)) { - if (!mir_strcmp(module, WatchListArray.item[i].module) && !WatchListArray.item[i].setting) { - // yes so uncheck it - CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND); - watching = 1; - break; - } + { + // check if we r already watching the module + int i = 0, watching = 0; + // check if the setting is being watched and if it is then check the menu item + if (WatchListArray.item) + for (i = 0; i < WatchListArray.count; i++) + if (WatchListArray.item[i].module && (hContact == WatchListArray.item[i].hContact)) { + if (!mir_strcmp(module, WatchListArray.item[i].module) && !WatchListArray.item[i].setting) { + // yes so uncheck it + CheckMenuItem(hSubMenu, MENU_WATCH_ITEM, MF_CHECKED | MF_BYCOMMAND); + watching = 1; + break; } + } - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { - case MENU_RENAME_MOD: - TreeView_EditLabel(GetDlgItem(hwnd, IDC_MODULES), tvi.hItem); - break; + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { + case MENU_RENAME_MOD: + TreeView_EditLabel(GetDlgItem(hwnd, IDC_MODULES), tvi.hItem); + break; - case MENU_DELETE_MOD: - if (deleteModule(module, hContact, 0)) { - TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, hti.hItem); - mir_free(mtis); - } - break; - - case MENU_COPY_MOD: - copyModuleMenuItem(module, hContact); - break; - - ////////////////////////////////////////////////////////////////////// divider - case MENU_WATCH_ITEM: - if (!watching) - addSettingToWatchList(hContact, module, 0); - else - freeWatchListItem(i); - if (hwnd2watchedVarsWindow) - PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); - break; - - case MENU_EXPORTMODULE: - exportDB(hContact, module); - break; - - case MENU_EXPORTDB: - exportDB(INVALID_CONTACT_ID, module); - break; + case MENU_DELETE_MOD: + if (deleteModule(module, hContact, 0)) { + TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, hti.hItem); + mir_free(mtis); } + break; + + case MENU_COPY_MOD: + copyModuleMenuItem(module, hContact); + break; + + ////////////////////////////////////////////////////////////////////// divider + case MENU_WATCH_ITEM: + if (!watching) + addSettingToWatchList(hContact, module, 0); + else + freeWatchListItem(i); + if (hwnd2watchedVarsWindow) + PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); + break; + + case MENU_EXPORTMODULE: + exportDB(hContact, module); + break; + + case MENU_EXPORTDB: + exportDB(INVALID_CONTACT_ID, module); + break; } - break; + } + break; case 2: // contact switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { @@ -857,7 +853,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here } break; - ////////////////////////////////////////////////////////////////////// divider + ////////////////////////////////////////////////////////////////////// divider case MENU_EXPORTCONTACT: exportDB(hContact, 0); break; @@ -868,28 +864,28 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here ImportSettingsFromFileMenuItem(hContact, ""); break; - ////////////////////////////////////////////////////////////////////// divider + ////////////////////////////////////////////////////////////////////// divider case MENU_ADD_MODULE: - { - HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, hContact); - char msg[1024]; - mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); - SetWindowText(AddModhwnd, module); - } - break; + { + HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, hContact); + char msg[1024]; + mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); + SetWindowText(AddModhwnd, module); + } + break; } break; case 3: // NULL contact switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) { case MENU_ADD_MODULE: - { - HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, hContact); - char msg[1024]; - mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); - SetWindowText(AddModhwnd, module); - } - break; + { + HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, hContact); + char msg[1024]; + mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); + SetWindowText(AddModhwnd, module); + } + break; case MENU_EXPORTCONTACT: exportDB(NULL, 0); break; diff --git a/plugins/DbEditorPP/src/options.cpp b/plugins/DbEditorPP/src/options.cpp index c6aa2b3cdc..37a4d0fa29 100644 --- a/plugins/DbEditorPP/src/options.cpp +++ b/plugins/DbEditorPP/src/options.cpp @@ -3,63 +3,63 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool bInitDone = true; - switch(msg) + switch (msg) { - case WM_INITDIALOG: + 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); + CheckDlgButton(hwnd, IDC_WARNONDEL, db_get_b(NULL, modname, "WarnOnDelete", 1) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_POPUPS, usePopups ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, db_get_w(NULL, modname, "PopupDelay", 4), 0); + SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)db_get_dw(NULL, modname, "PopupColour", RGB(255, 0, 0))); + TranslateDialogDefault(hwnd); + bInitDone = true; + } + return TRUE; + case WM_COMMAND: + switch (LOWORD(wParam)) { - 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); - CheckDlgButton(hwnd, IDC_WARNONDEL, db_get_b(NULL, modname, "WarnOnDelete", 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_POPUPS, usePopups ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwnd,IDC_POPUPTIMEOUT,db_get_w(NULL,modname,"PopupDelay",4),0); - SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)db_get_dw(NULL,modname,"PopupColour",RGB(255,0,0))); - TranslateDialogDefault(hwnd); - bInitDone = true; + case IDC_RESTORESETTINGS: + case IDC_EXPANDSETTINGS: + case IDC_POPUPS: + case IDC_WARNONDEL: + 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; } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_RESTORESETTINGS: - case IDC_EXPANDSETTINGS: - case IDC_POPUPS: - case IDC_WARNONDEL: - 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) + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) + { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: { - case 0: - 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)); - usePopups = IsDlgButtonChecked(hwnd,IDC_POPUPS); - db_set_b(NULL,modname,"UsePopUps",(BYTE)usePopups); - db_set_w(NULL,modname,"PopupDelay",(WORD)GetDlgItemInt(hwnd,IDC_POPUPTIMEOUT,NULL,0)); - db_set_dw(NULL,modname,"PopupColour",(DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0)); - } - return TRUE; - } - break; + 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)); + usePopups = IsDlgButtonChecked(hwnd, IDC_POPUPS); + db_set_b(NULL, modname, "UsePopUps", (BYTE)usePopups); + db_set_w(NULL, modname, "PopupDelay", (WORD)GetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, NULL, 0)); + db_set_dw(NULL, modname, "PopupColour", (DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0)); + } + return TRUE; } break; + } + break; } return FALSE; } -INT OptInit(WPARAM wParam,LPARAM) +INT OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.hInstance = hInst; diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index ef4bedafb4..ff49c2eb1e 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -25,12 +25,12 @@ void setupSettingsList(HWND hwnd2List) void saveListSettings(HWND hwnd2List) { - LVCOLUMN sLC = {0}; + LVCOLUMN sLC = { 0 }; char tmp[33]; tmp[32] = 0; sLC.mask = LVCF_WIDTH; - for (int i=0; i <= 3; i++) + for (int i = 0; i <= 3; i++) if (ListView_GetColumn(hwnd2List, i, &sLC)) { mir_snprintf(tmp, SIZEOF(tmp), "Column%dwidth", i); db_set_w(NULL, modname, tmp, (WORD)sLC.cx); @@ -40,7 +40,7 @@ void saveListSettings(HWND hwnd2List) void ClearListview(HWND hwnd2Settings) { - SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); + SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA); if (info && ListView_GetItemCount(hwnd2Settings)) { mir_free(info->module); if (info->hwnd2Edit) { @@ -60,7 +60,7 @@ void DeleteSettingsFromList(HWND hSettings, MCONTACT hContact, char *module, cha if (!count) return; if (count == 1) - db_unset(hContact,module,setting); + db_unset(hContact, module, setting); else { int items = ListView_GetItemCount(hSettings); int i = 0; @@ -93,7 +93,7 @@ void DeleteSettingsFromList(HWND hSettings, MCONTACT hContact, char *module, cha } } -void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, int index) +void additem(HWND hwnd2Settings, MCONTACT hContact, char* module, char* setting, int index) { char *data = NULL; LVITEM lvi; @@ -132,7 +132,7 @@ void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, mir_snprintf(data, 3 * (dbv.cpbVal + 1) + 10, "0x%04X (%d)", dbv.cpbVal, dbv.cpbVal); ListView_SetItemText(hwnd2Settings, index, 3, data); break; - + case DBVT_BYTE: if (!(data = (char*)mir_realloc(data, 16))) // 0x00 (000) return; @@ -143,7 +143,7 @@ void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, ListView_SetItemText(hwnd2Settings, index, 2, Translate("BYTE")); ListView_SetItemText(hwnd2Settings, index, 3, "0x0001 (1)"); break; - + case DBVT_WORD: if (!(data = (char*)mir_realloc(data, 16))) // 0x0000 (00000) return; @@ -155,7 +155,7 @@ void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, ListView_SetItemText(hwnd2Settings, index, 2, Translate("WORD")); ListView_SetItemText(hwnd2Settings, index, 3, "0x0002 (2)"); break; - + case DBVT_DWORD: if (!(data = (char*)mir_realloc(data, 32))) // 0x00000000 (0000000000) return; @@ -167,7 +167,7 @@ void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, ListView_SetItemText(hwnd2Settings, index, 2, Translate("DWORD")); ListView_SetItemText(hwnd2Settings, index, 3, "0x0004 (4)"); break; - + case DBVT_ASCIIZ: if ((data = (char*)mir_realloc(data, 512))) { lvi.iImage = 4; @@ -179,7 +179,7 @@ void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, ListView_SetItemText(hwnd2Settings, index, 3, data); } break; - + case DBVT_UTF8: if ((data = (char*)mir_realloc(data, 512))) { lvi.iImage = 5; @@ -195,7 +195,7 @@ void additem(HWND hwnd2Settings,MCONTACT hContact, char* module, char* setting, ListView_SetItemText(hwnd2Settings, index, 3, data); } break; - + case DBVT_DELETED: return; } @@ -230,7 +230,7 @@ void PopulateSettings(HWND hwnd2Settings, MCONTACT hContact, char* module) info->hContact = hContact; info->module = mir_tstrdup(module); - SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG_PTR)info); + SetWindowLongPtr(hwnd2Settings, GWLP_USERDATA, (LONG_PTR)info); // icons if (himl2) @@ -314,9 +314,9 @@ void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *w else db_set_s(info->hContact, info->module, info->setting, value); } -static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_KEYDOWN: switch (wParam) { @@ -346,153 +346,111 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - { - int len = GetWindowTextLength(hwnd) + 1; - char *value = (char*)_alloca(len); - WCHAR *wc = NULL; - DBVARIANT dbv = { 0 }; + { + int len = GetWindowTextLength(hwnd) + 1; + char *value = (char*)_alloca(len); + WCHAR *wc = NULL; + DBVARIANT dbv = { 0 }; - GetWindowTextA(hwnd, value, len); + GetWindowTextA(hwnd, value, len); - if (info->unicode) - wc = mir_a2u(value); + if (info->unicode) + wc = mir_a2u(value); + + if (len <= 1 || GetSetting(info->hContact, info->module, info->setting, &dbv)) { + SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); + return 0; + } - if (len <= 1 || GetSetting(info->hContact, info->module, info->setting, &dbv)) { + switch (info->subitem) { + case 0: // setting name + if (!mir_strcmp(info->setting, value) || mir_strlen(value) > 255) { + db_free(&dbv); SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); return 0; } + db_set(info->hContact, info->module, value, &dbv); + db_unset(info->hContact, info->module, info->setting); + { + LVFINDINFO lvfi; + lvfi.flags = LVFI_STRING; + lvfi.psz = info->setting; + lvfi.vkDirection = VK_DOWN; + int item = ListView_FindItem(info->hwnd, -1, &lvfi); + ListView_DeleteItem(info->hwnd, item); + } + break; - switch (info->subitem) { - case 0: // setting name - if (!mir_strcmp(info->setting, value) || mir_strlen(value) > 255) { - db_free(&dbv); - SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDCANCEL, 0), 0); - return 0; + case 1: // value + int val; + int i = 0; + + if (dbv.type == DBVT_BLOB) { + WriteBlobFromString(info->hContact, info->module, info->setting, value, len); + break; + } + + switch (value[0]) { + case 'b': + case 'B': + if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) + sscanf(&value[3], "%x", &val); + else if (value[1] >= '0' && value[1] <= '9') { + val = atoi(&value[1]); + if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) + db_unset(info->hContact, info->module, info->setting); + + db_set_b(info->hContact, info->module, info->setting, (BYTE)val); } - db_set(info->hContact, info->module, value, &dbv); - db_unset(info->hContact, info->module, info->setting); - { - LVFINDINFO lvfi; - lvfi.flags = LVFI_STRING; - lvfi.psz = info->setting; - lvfi.vkDirection = VK_DOWN; - int item = ListView_FindItem(info->hwnd, -1, &lvfi); - ListView_DeleteItem(info->hwnd, item); + else writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case 'w': + case 'W': + if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) + sscanf(&value[3], "%x", &val); + else if (value[1] >= '0' && value[1] <= '9') { + val = atoi(&value[1]); + if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) + db_unset(info->hContact, info->module, info->setting); + db_set_w(info->hContact, info->module, info->setting, (WORD)val); } + else writeStandardTextfromLabel(info, value, wc, dbv.type); break; - - case 1: // value - int val; - int i = 0; - - if (dbv.type == DBVT_BLOB) { - WriteBlobFromString(info->hContact, info->module, info->setting, value, len); - break; + case 'd': + case 'D': + if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) + sscanf(&value[3], "%x", &val); + else if (value[1] >= '0' && value[1] <= '9') { + val = atoi(&value[1]); + if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) + db_unset(info->hContact, info->module, info->setting); + db_set_dw(info->hContact, info->module, info->setting, val); } - - switch (value[0]) { - case 'b': - case 'B': - if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) - sscanf(&value[3], "%x", &val); - else if (value[1] >= '0' && value[1] <= '9') { - val = atoi(&value[1]); - if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) - db_unset(info->hContact, info->module, info->setting); - + else writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case '0': + i = 1; + case 'x': + case 'X': + if (value[i] == 'x' || value[i] == 'X') { + sscanf(&value[i + 1], "%x", &val); + switch (dbv.type) { + case DBVT_UTF8: + case DBVT_ASCIIZ: + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case DBVT_BYTE: db_set_b(info->hContact, info->module, info->setting, (BYTE)val); - } - else writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case 'w': - case 'W': - if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) - sscanf(&value[3], "%x", &val); - else if (value[1] >= '0' && value[1] <= '9') { - val = atoi(&value[1]); - if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) - db_unset(info->hContact, info->module, info->setting); + break; + case DBVT_WORD: db_set_w(info->hContact, info->module, info->setting, (WORD)val); + break; + case DBVT_DWORD: + db_set_dw(info->hContact, info->module, info->setting, (DWORD)val); + break; } - else writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case 'd': - case 'D': - if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) - sscanf(&value[3], "%x", &val); - else if (value[1] >= '0' && value[1] <= '9') { - val = atoi(&value[1]); - if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) - db_unset(info->hContact, info->module, info->setting); - db_set_dw(info->hContact, info->module, info->setting, val); - } - else writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case '0': - i = 1; - case 'x': - case 'X': - if (value[i] == 'x' || value[i] == 'X') { - sscanf(&value[i + 1], "%x", &val); - switch (dbv.type) { - case DBVT_UTF8: - case DBVT_ASCIIZ: - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case DBVT_BYTE: - db_set_b(info->hContact, info->module, info->setting, (BYTE)val); - break; - case DBVT_WORD: - db_set_w(info->hContact, info->module, info->setting, (WORD)val); - break; - case DBVT_DWORD: - db_set_dw(info->hContact, info->module, info->setting, (DWORD)val); - break; - } - } - else { - val = atoi(value); - switch (dbv.type) { - case DBVT_ASCIIZ: - case DBVT_UTF8: - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case DBVT_BYTE: - db_set_b(info->hContact, info->module, info->setting, (BYTE)val); - break; - case DBVT_WORD: - db_set_w(info->hContact, info->module, info->setting, (WORD)val); - break; - case DBVT_DWORD: - db_set_dw(info->hContact, info->module, info->setting, (DWORD)val); - break; - } - } - break; - case '\"': - case '\'': - { - int nlen = mir_strlen(value); - int sh = 0; - if (nlen > 3) { - if (value[nlen - 1] == value[0]) { - value[nlen - 1] = '\0'; - sh = 1; - } - } - writeStandardTextfromLabel(info, &value[sh], wc, dbv.type); - } - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': + } + else { val = atoi(value); switch (dbv.type) { case DBVT_ASCIIZ: @@ -509,16 +467,58 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w db_set_dw(info->hContact, info->module, info->setting, (DWORD)val); break; } - break; - - default: + } + break; + case '\"': + case '\'': + { + int nlen = mir_strlen(value); + int sh = 0; + if (nlen > 3) { + if (value[nlen - 1] == value[0]) { + value[nlen - 1] = '\0'; + sh = 1; + } + } + writeStandardTextfromLabel(info, &value[sh], wc, dbv.type); + } + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + val = atoi(value); + switch (dbv.type) { + case DBVT_ASCIIZ: + case DBVT_UTF8: writeStandardTextfromLabel(info, value, wc, dbv.type); break; + case DBVT_BYTE: + db_set_b(info->hContact, info->module, info->setting, (BYTE)val); + break; + case DBVT_WORD: + db_set_w(info->hContact, info->module, info->setting, (WORD)val); + break; + case DBVT_DWORD: + db_set_dw(info->hContact, info->module, info->setting, (DWORD)val); + break; } break; + + default: + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; } - db_free(&dbv); - } // fall through + break; + } + db_free(&dbv); + } // fall through case IDCANCEL: SettingListInfo *sli = (SettingListInfo*)GetWindowLongPtr(info->hwnd, GWLP_USERDATA); if (sli && sli->hwnd2Edit == hwnd) @@ -643,7 +643,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem) } static int test; -void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam); +void SettingsListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam); static int lastColumn = -1; struct SettingsSortParams @@ -666,7 +666,7 @@ INT_PTR CALLBACK SettingsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) return res; } -void SettingsListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +void SettingsListWM_NOTIFY(HWND hwnd, UINT, WPARAM wParam, LPARAM lParam) { SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd, IDC_SETTINGS), GWLP_USERDATA); LVHITTESTINFO hti; @@ -732,7 +732,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 +void SettingsListRightClick(HWND hwnd, WPARAM, LPARAM lParam) // hwnd here is to the main window, NOT the listview { HWND hSettings = GetDlgItem(hwnd, IDC_SETTINGS); SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hSettings, GWLP_USERDATA); @@ -966,7 +966,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd her CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd, EditSettingDlgProc, (LPARAM)dbsetting); break; - ///////////////////////// convert to submenu + ///////////////////////// convert to submenu case MENU_CHANGE2BYTE: if (convertSetting(hContact, module, setting, 0)) { lvi.iImage = 1; @@ -1002,7 +1002,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd her } break; - ///////////////////////// convert to submenu + ///////////////////////// convert to submenu case MENU_VIEWDECRYPT: if (!db_get(hContact, module, setting, &dbv) && dbv.type == DBVT_ASCIIZ) { if (mir_strcmp(setting, "LoginPassword")) @@ -1042,7 +1042,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd her db_free(&dbv); break; - ///////////////////////// divider + ///////////////////////// divider case MENU_WATCH_ITEM: if (!watching) addSettingToWatchList(hContact, module, setting); diff --git a/plugins/DbEditorPP/src/watchedvars.cpp b/plugins/DbEditorPP/src/watchedvars.cpp index c237745bff..18250c4f09 100644 --- a/plugins/DbEditorPP/src/watchedvars.cpp +++ b/plugins/DbEditorPP/src/watchedvars.cpp @@ -8,13 +8,13 @@ int addSettingToWatchList(MCONTACT hContact, char* module, char* setting) WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); } if (!WatchListArray.item) return 0; - if (setting && db_get(hContact,module, setting, &(WatchListArray.item[WatchListArray.count].dbv))) return 0; + if (setting && db_get(hContact, module, setting, &(WatchListArray.item[WatchListArray.count].dbv))) return 0; WatchListArray.item[WatchListArray.count].hContact = hContact; 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; + WatchListArray.item[WatchListArray.count].WatchModule = setting ? WATCH_SETTING : WATCH_MODULE; WatchListArray.count++; return 1; } @@ -41,7 +41,7 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) char *setting = lParam->setting; if (!module) return; lvItem.lParam = (LPARAM)lParam->hContact; - lvItem.mask = LVIF_TEXT|LVIF_PARAM; + lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.iItem = 0; lvItem.iSubItem = 0; @@ -50,7 +50,7 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) ModuleSettingLL settinglist; struct DBsetting dummy; ModSetLinkLinkItem *setting; - if (!EnumSettings(hContact,module,&settinglist)) return; + if (!EnumSettings(hContact, module, &settinglist)) return; dummy.hContact = hContact; dummy.module = mir_tstrdup(module); setting = settinglist.first; @@ -72,64 +72,64 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) else lvItem.pszText = (char*)GetContactName(hContact, NULL, 1); - index = ListView_InsertItem(hwnd2list,&lvItem); + index = ListView_InsertItem(hwnd2list, &lvItem); 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); + ListView_SetItemText(hwnd2list, index, 1, module); + ListView_SetItemText(hwnd2list, index, 2, setting); switch (dbv->type) { case DBVT_BLOB: + { + int j; + char *data = NULL; + if (!(data = (char*)mir_realloc(data, 3 * (dbv->cpbVal + 1)))) + return; + data[0] = '\0'; + for (j = 0; j < dbv->cpbVal; j++) { - int j; - char *data = NULL; - if (!(data = (char*)mir_realloc(data, 3*(dbv->cpbVal+1)) )) - return; - data[0] = '\0'; - for (j=0; jcpbVal; j++) - { - char tmp[16]; - 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"); - mir_free(data); + char tmp[16]; + mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv->pbVal[j]); + strcat(data, tmp); } - break; + ListView_SetItemText(hwnd2list, index, 4, data); + ListView_SetItemText(hwnd2list, index, 3, "BLOB"); + mir_free(data); + } + break; case DBVT_BYTE: - mir_snprintf(data, SIZEOF(data), "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"BYTE"); + mir_snprintf(data, SIZEOF(data), "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: - mir_snprintf(data, SIZEOF(data), "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"WORD"); + mir_snprintf(data, SIZEOF(data), "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: - mir_snprintf(data, SIZEOF(data), "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"DWORD"); + mir_snprintf(data, SIZEOF(data), "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal, tmp, 10)); + ListView_SetItemText(hwnd2list, index, 4, data); + ListView_SetItemText(hwnd2list, index, 3, "DWORD"); break; case DBVT_ASCIIZ: - ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); - ListView_SetItemText(hwnd2list,index,3,"STRING"); + ListView_SetItemText(hwnd2list, index, 4, dbv->pszVal); + ListView_SetItemText(hwnd2list, index, 3, "STRING"); break; case DBVT_UTF8: 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); - ListView_SetItemText(hwnd2list,index,3,"UNICODE"); + ListView_SetItemTextW(hwnd2list, index, 4, wc); + ListView_SetItemText(hwnd2list, index, 3, "UNICODE"); break; } } @@ -138,7 +138,7 @@ void PopulateWatchedWindow(HWND hwnd) { int i; ListView_DeleteAllItems(hwnd); - for (i=0;iwId) - { - case IDC_VARS: - urc->rcItem.top = 0; - urc->rcItem.bottom = urc->dlgNewSize.cy; - urc->rcItem.left = 0; - urc->rcItem.right = urc->dlgNewSize.cx; - return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; - } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; + switch (urc->wId) + { + case IDC_VARS: + urc->rcItem.top = 0; + urc->rcItem.bottom = urc->dlgNewSize.cy; + urc->rcItem.left = 0; + urc->rcItem.right = urc->dlgNewSize.cx; + return RD_ANCHORY_CUSTOM | RD_ANCHORX_CUSTOM; + } + return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch(msg) + switch (msg) { - case WM_INITDIALOG: - { - // setup the list... - LVCOLUMN sLC; - - sLC.fmt = LVCFMT_LEFT; - ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_VARS), 32|LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT - sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; - - sLC.pszText = Translate("Contact"); sLC.cx = 80; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),0,&sLC); - sLC.pszText = Translate("Module"); sLC.cx = 80; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),1,&sLC); - sLC.pszText = Translate("Setting"); sLC.cx = 80; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),2,&sLC); - sLC.pszText = Translate("Type"); sLC.cx = 60; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),3,&sLC); - sLC.pszText = Translate("Data"); sLC.cx = 300; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),4,&sLC); + case WM_INITDIALOG: + { + // setup the list... + LVCOLUMN sLC; + + sLC.fmt = LVCFMT_LEFT; + ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_VARS), 32 | LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT + sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; + + sLC.pszText = Translate("Contact"); sLC.cx = 80; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS), 0, &sLC); + sLC.pszText = Translate("Module"); sLC.cx = 80; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS), 1, &sLC); + sLC.pszText = Translate("Setting"); sLC.cx = 80; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS), 2, &sLC); + sLC.pszText = Translate("Type"); sLC.cx = 60; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS), 3, &sLC); + sLC.pszText = Translate("Data"); sLC.cx = 300; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS), 4, &sLC); + + PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); + + TranslateMenu(GetMenu(hwnd)); + TranslateMenu(GetSubMenu(GetMenu(hwnd), 0)); + TranslateDialogDefault(hwnd); + // do the icon + SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT))); + } + return TRUE; + // for the resize + case WM_GETMINMAXINFO: + { + MINMAXINFO *mmi = (MINMAXINFO*)lParam; + mmi->ptMinTrackSize.x = 200; + mmi->ptMinTrackSize.y = 90; + return 0; + } + case WM_SIZE: + { + UTILRESIZEDIALOG urd; + memset(&urd, 0, sizeof(urd)); + urd.cbSize = sizeof(urd); + urd.hInstance = hInst; + urd.hwndDlg = hwnd; + urd.lParam = 0; + urd.lpTemplate = MAKEINTRESOURCE(IDD_WATCH_DIAG); + urd.pfnResizer = WatchDialogResize; + CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); + break; + } + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case MENU_REMALL_WATCHES: + freeAllWatches(); + ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_VARS)); + break; + case MENU_EXIT: + case IDCANCEL: + hwnd2watchedVarsWindow = 0; + DestroyWindow(hwnd); + break; + case MENU_REFRESH: PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); - - TranslateMenu(GetMenu(hwnd)); - TranslateMenu(GetSubMenu(GetMenu(hwnd),0)); - TranslateDialogDefault(hwnd); - // do the icon - SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); } - return TRUE; - // for the resize - case WM_GETMINMAXINFO: - { - MINMAXINFO *mmi=(MINMAXINFO*)lParam; - mmi->ptMinTrackSize.x=200; - mmi->ptMinTrackSize.y=90; - return 0; - } - case WM_SIZE: - { - UTILRESIZEDIALOG urd; - memset(&urd, 0, sizeof(urd)); - urd.cbSize=sizeof(urd); - urd.hInstance=hInst; - urd.hwndDlg=hwnd; - urd.lParam=0; - urd.lpTemplate=MAKEINTRESOURCE(IDD_WATCH_DIAG); - urd.pfnResizer=WatchDialogResize; - CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); - break; - - } - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case MENU_REMALL_WATCHES: - freeAllWatches(); - ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_VARS)); - break; - case MENU_EXIT: - case IDCANCEL: - hwnd2watchedVarsWindow = 0; - DestroyWindow(hwnd); - break; - case MENU_REFRESH: - PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); - } - break; + break; - case WM_NOTIFY: - switch(LOWORD(wParam)) + case WM_NOTIFY: + switch (LOWORD(wParam)) + { + case IDC_VARS: + switch (((NMHDR*)lParam)->code) { - case IDC_VARS: - switch(((NMHDR*)lParam)->code) + case NM_DBLCLK: + { + LVHITTESTINFO hti; + LVITEM lvi; + hti.pt = ((NMLISTVIEW*)lParam)->ptAction; + if (ListView_SubItemHitTest(GetDlgItem(hwnd, IDC_VARS), &hti) > -1) + { + if (hti.flags&LVHT_ONITEM) { - case NM_DBLCLK: + lvi.mask = LVIF_PARAM; + lvi.iItem = hti.iItem; + lvi.iSubItem = 0; + if (ListView_GetItem(GetDlgItem(hwnd, IDC_VARS), &lvi)) { - LVHITTESTINFO hti; - LVITEM lvi; - hti.pt=((NMLISTVIEW*)lParam)->ptAction; - if (ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_VARS),&hti) >-1) - { - if (hti.flags&LVHT_ONITEM) - { - lvi.mask = LVIF_PARAM; - lvi.iItem = hti.iItem; - lvi.iSubItem = 0; - if (ListView_GetItem(GetDlgItem(hwnd,IDC_VARS),&lvi)) - { - ItemInfo ii; - ii.hContact = (MCONTACT)lvi.lParam; - ListView_GetItemText(GetDlgItem(hwnd, IDC_VARS), hti.iItem, 1, ii.module, SIZEOF(ii.module)); - ListView_GetItemText(GetDlgItem(hwnd, IDC_VARS), hti.iItem, 2, ii.setting, SIZEOF(ii.setting)); - ii.type = FW_SETTINGNAME; - SendMessage(hwnd2mainWindow,WM_FINDITEM,(WPARAM)&ii,0); - } - } - } + ItemInfo ii; + ii.hContact = (MCONTACT)lvi.lParam; + ListView_GetItemText(GetDlgItem(hwnd, IDC_VARS), hti.iItem, 1, ii.module, SIZEOF(ii.module)); + ListView_GetItemText(GetDlgItem(hwnd, IDC_VARS), hti.iItem, 2, ii.setting, SIZEOF(ii.setting)); + ii.type = FW_SETTINGNAME; + SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0); } - break; } - break; + } } + break; + } + break; + } break; } return 0; } -void popupWatchedVar(MCONTACT hContact,const char* module,const char* setting) +void popupWatchedVar(MCONTACT hContact, const char* module, const char* setting) { HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)); char lpzContactName[MAX_CONTACTNAME]; char lpzText[MAX_SECONDLINE]; - COLORREF colorBack = db_get_dw(NULL,modname,"PopupColour",RGB(255,0,0)); - COLORREF colorText = RGB(0,0,0); - int timeout = db_get_b(NULL,modname,"PopupDelay",3); + COLORREF colorBack = db_get_dw(NULL, modname, "PopupColour", RGB(255, 0, 0)); + COLORREF colorText = RGB(0, 0, 0); + int timeout = db_get_b(NULL, modname, "PopupDelay", 3); if (hContact) { // contacts nick char szProto[256]; - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + if (GetValue(hContact, "Protocol", "p", szProto, SIZEOF(szProto))) mir_snprintf(lpzContactName, SIZEOF(lpzContactName), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); else mir_snprintf(lpzContactName, SIZEOF(lpzContactName), nick_unknown); } - else strcpy(lpzContactName,Translate("Settings")); + else strcpy(lpzContactName, Translate("Settings")); // 2nd line DBVARIANT dbv; - if ( GetSetting(hContact, module, setting, &dbv)) + if (GetSetting(hContact, module, setting, &dbv)) return; switch (dbv.type) { @@ -331,8 +331,8 @@ void popupWatchedVar(MCONTACT hContact,const char* module,const char* setting) POPUPDATA ppd = { 0 }; ppd.lchContact = (MCONTACT)hContact; ppd.lchIcon = hIcon; - mir_tstrncpy(ppd.lpzContactName, lpzContactName,MAX_CONTACTNAME); - mir_tstrncpy(ppd.lpzText, lpzText,MAX_SECONDLINE); + mir_tstrncpy(ppd.lpzContactName, lpzContactName, MAX_CONTACTNAME); + mir_tstrncpy(ppd.lpzText, lpzText, MAX_SECONDLINE); ppd.colorBack = colorBack; ppd.colorText = colorText; ppd.iSeconds = timeout ? timeout : -1; -- cgit v1.2.3