From 7f35b5c32df443cf13dbb476c641e01f30db1d6c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Jan 2014 15:19:47 +0000 Subject: encrypted settings are not displayed in dbeditor git-svn-id: http://svn.miranda-ng.org/main/trunk@7631 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbEditorPP/src/findwindow.cpp | 581 +++++++++++++++------------------- 1 file changed, 261 insertions(+), 320 deletions(-) (limited to 'plugins/DbEditorPP/src/findwindow.cpp') diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp index da1b9cf673..6ac376233d 100644 --- a/plugins/DbEditorPP/src/findwindow.cpp +++ b/plugins/DbEditorPP/src/findwindow.cpp @@ -31,185 +31,164 @@ typedef struct { } FindInfo; -int FindDialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) +int FindDialogResize(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc) { - switch(urc->wId) { + switch (urc->wId) { case IDC_LIST: - return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; + return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT; case IDC_SBAR: - return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; + return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM; default: - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; + return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } } - void freeItems(HWND hwnd) { - int i; - ItemInfo *ii; - for (i=0;ihwnd = GetDlgItem(hwnd,IDC_LIST); - fi->options = (IsDlgButtonChecked(hwnd,IDC_CASESENSITIVE)?FW_CASE:0)| - (IsDlgButtonChecked(hwnd,IDC_EXACT)?FW_EXACT:0)| - (IsDlgButtonChecked(hwnd,IDC_MODNAME)?FW_MODNAME:0)| - (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME)?FW_SETNAME:0)| - (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE)?FW_SETVAL:0); - - if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA)) - { - if (IsDlgButtonChecked(hwnd,IDC_FOUND)) - fi->mode = RW_FOUND; - else - if (IsDlgButtonChecked(hwnd,IDC_MODNAME2)) - fi->mode = RW_MODULE; - else - if (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME2)) - fi->mode = RW_SETNAME; - else - if (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE2)) - fi->mode = RW_SETVAL; - - if (IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) - fi->mode |= RW_FULL; - - fi->replace = mir_tstrdup(replace); - - SetWindowText(GetDlgItem(hwnd,IDOK),Translate("Stop")); - EnableWindow(GetDlgItem(hwnd,IDC_SEARCH),0); - - if (IsDlgButtonChecked(hwnd,IDC_CASESENSITIVE)) - fi->mode |= RW_CASE; - } - else - { - SetWindowText(GetDlgItem(hwnd,IDC_SEARCH),Translate("Stop")); - EnableWindow(GetDlgItem(hwnd,IDOK),0); - } + if (GetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA) && + !GetDlgItemText(hwnd, IDC_REPLACE, replace, SIZEOF(replace)) && + !IsDlgButtonChecked(hwnd, IDC_ENTIRELY)) + break; - fi->text = mir_tstrdup(text); + if (!IsDlgButtonChecked(hwnd, IDC_MODNAME) && + !IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) && + !IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE)) + break; - SendDlgItemMessage(hwnd,IDC_LIST,LB_RESETCONTENT,0,0); - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,1); + FindInfo *fi = (FindInfo*)mir_calloc(sizeof(FindInfo)); + if (!fi) + break; - EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); - forkthread(FindSettings,0,fi); - } + fi->hwnd = GetDlgItem(hwnd, IDC_LIST); + fi->options = (IsDlgButtonChecked(hwnd, IDC_CASESENSITIVE) ? FW_CASE : 0) | + (IsDlgButtonChecked(hwnd, IDC_EXACT) ? FW_EXACT : 0) | + (IsDlgButtonChecked(hwnd, IDC_MODNAME) ? FW_MODNAME : 0) | + (IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) ? FW_SETNAME : 0) | + (IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE) ? FW_SETVAL : 0); + + if (GetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA)) { + if (IsDlgButtonChecked(hwnd, IDC_FOUND)) + fi->mode = RW_FOUND; + else if (IsDlgButtonChecked(hwnd, IDC_MODNAME2)) + fi->mode = RW_MODULE; + else if (IsDlgButtonChecked(hwnd, IDC_SETTINGNAME2)) + fi->mode = RW_SETNAME; + else if (IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE2)) + fi->mode = RW_SETVAL; + + if (IsDlgButtonChecked(hwnd, IDC_ENTIRELY)) + fi->mode |= RW_FULL; + + fi->replace = mir_tstrdup(replace); + + SetWindowText(GetDlgItem(hwnd, IDOK), Translate("Stop")); + EnableWindow(GetDlgItem(hwnd, IDC_SEARCH), 0); + + if (IsDlgButtonChecked(hwnd, IDC_CASESENSITIVE)) + fi->mode |= RW_CASE; } - break; - case IDCANCEL: - DestroyWindow(hwnd); - break; - case IDC_LIST: - if (HIWORD(wParam) == LBN_DBLCLK) - { - int i = SendDlgItemMessage(hwnd,IDC_LIST,LB_GETCURSEL,0,0); - ItemInfo *ii =(ItemInfo*)SendDlgItemMessage(hwnd,IDC_LIST,LB_GETITEMDATA,i,0); - if (!ii) break; - SendMessage(GetParent(hwnd),WM_FINDITEM,(WPARAM)ii,0); - } - break; + else { + SetWindowText(GetDlgItem(hwnd, IDC_SEARCH), Translate("Stop")); + EnableWindow(GetDlgItem(hwnd, IDOK), 0); + } + + fi->text = mir_tstrdup(text); + + SendDlgItemMessage(hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0); + SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 1); + + EnableWindow(GetDlgItem(hwnd, IDCANCEL), 0); + forkthread(FindSettings, 0, fi); + } + break; + + case IDCANCEL: + DestroyWindow(hwnd); + break; + case IDC_LIST: + if (HIWORD(wParam) == LBN_DBLCLK) { + int i = SendDlgItemMessage(hwnd, IDC_LIST, LB_GETCURSEL, 0, 0); + ItemInfo *ii = (ItemInfo*)SendDlgItemMessage(hwnd, IDC_LIST, LB_GETITEMDATA, i, 0); + if (!ii) break; + SendMessage(GetParent(hwnd), WM_FINDITEM, (WPARAM)ii, 0); } + break; + } break; - case WM_GETMINMAXINFO: + 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; } - case WM_SIZE: + return 0; + case WM_SIZE: { UTILRESIZEDIALOG urd; - ZeroMemory(&urd,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); + ZeroMemory(&urd, 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); + + case WM_DESTROY: + freeItems(hwnd); break; } return 0; } - void ItemFound(HWND hwnd, HANDLE 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 (!ii) return; - if (type & FW_REPLACED) mode = Translate("Replaced with"); else @@ -220,57 +199,52 @@ void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting name = hContact?(char*)GetContactName(hContact,NULL,0):Translate("Settings"); - switch (type & 0xFF) - { - case FW_MODULE: - ii->type = FW_MODULE; - mir_snprintf(text, SIZEOF(text), Translate("%s Module \"%s\" in contact \"%s\""), mode, module, name); + switch (type & 0xFF) { + case FW_MODULE: + ii->type = FW_MODULE; + mir_snprintf(text, SIZEOF(text), Translate("%s Module \"%s\" in contact \"%s\""), mode, module, name); break; - case FW_SETTINGNAME: - mir_strncpy(ii->setting,setting,256); - ii->type = FW_SETTINGNAME; - if (GetValue(hContact,module,setting, szValue, SIZEOF(szValue))) - mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""), mode, setting, module, name, szValue); - else - mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, setting, module, name); + case FW_SETTINGNAME: + mir_strncpy(ii->setting, setting, 256); + ii->type = FW_SETTINGNAME; + if (GetValue(hContact, module, setting, szValue, SIZEOF(szValue))) + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""), mode, setting, module, name, szValue); + else + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, setting, module, name); break; - case FW_SETTINGVALUE: - mir_strncpy(ii->setting,setting,256); - ii->type = FW_SETTINGVALUE; - mir_snprintf(text, SIZEOF(text), Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, value, setting, module, name); + case FW_SETTINGVALUE: + mir_strncpy(ii->setting, setting, 256); + ii->type = FW_SETTINGVALUE; + mir_snprintf(text, SIZEOF(text), Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, value, setting, module, name); break; } index = SendMessage(hwnd,LB_ADDSTRING,0,(LPARAM)text); - if (type & FW_DELETED) - { - SendMessage(hwnd,LB_SETITEMDATA,index,0); + if (type & FW_DELETED) { + SendMessage(hwnd, LB_SETITEMDATA, index, 0); mir_free(ii); } - else - { - ii->hContact= hContact; - mir_strncpy(ii->module,module,256); - SendMessage(hwnd,LB_SETITEMDATA,index,(LPARAM)ii); + else { + ii->hContact = hContact; + mir_strncpy(ii->module, module, 256); + SendMessage(hwnd, LB_SETITEMDATA, index, (LPARAM)ii); } } - -char *multiReplace(const char* value, const char *find, const char *replace, int cs) +char* multiReplace(const char* value, const char *find, const char *replace, int cs) { char *head, *temp, *string; int len = (int)strlen(find); int replen = (int)strlen(replace); - if (head = (char*)(cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... - { + // only should be 1 '=' sign there... + if (head = (char*)(cs ? strstr(value, find) : StrStrI(value, find))) { string = (char*)value; - temp = (char*)mir_alloc(1*sizeof(char)); + temp = (char*)mir_alloc(1 * sizeof(char)); temp[0] = '\0'; - while (head) - { + while (head) { temp = (char*)mir_realloc(temp, strlen(temp) + strlen(string) + replen + 1); if (!temp) mir_tstrdup(value); @@ -278,7 +252,7 @@ char *multiReplace(const char* value, const char *find, const char *replace, int string = head + len; strcat(temp, replace); - head = (cs?strstr(string, find):StrStrI(string, find)); + head = (cs ? strstr(string, find) : StrStrI(string, find)); } strcat(temp, string); @@ -288,7 +262,6 @@ char *multiReplace(const char* value, const char *find, const char *replace, int return mir_tstrdup(value); } - int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) { int count = 0; @@ -296,7 +269,7 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set BOOL write = 0; int isNumeric; char *myreplace = NULL; - DBVARIANT val = {0}; + DBVARIANT val = { 0 }; if (!dbv->type || dbv->type == DBVT_BLOB) return 0; @@ -304,11 +277,11 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set if (!replace[0]) isNumeric = 1; else - isNumeric = sscanf(replace,"%d",&num); + isNumeric = sscanf(replace, "%d", &num); - val.type=dbv->type; + val.type = dbv->type; - switch(dbv->type) { + switch (dbv->type) { case DBVT_UTF8: case DBVT_ASCIIZ: if (mode & RW_FULL) @@ -345,15 +318,15 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set } if ((!val.pszVal && !replace[0]) || (val.pszVal && !val.pszVal[0])) { - ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); - db_unset(hContact,module,setting); + ItemFound(hwnd, hContact, module, setting, NULL, FW_SETTINGNAME | FW_DELETED); + db_unset(hContact, module, setting); mir_free(myreplace); return 1; } if (!db_set(hContact, module, setting, &val)) { count++; - ItemFound(hwnd,hContact,module,setting,myreplace?myreplace:(char*)replace,FW_SETTINGVALUE|FW_REPLACED); + ItemFound(hwnd, hContact, module, setting, myreplace ? myreplace : (char*)replace, FW_SETTINGVALUE | FW_REPLACED); } mir_free(myreplace); @@ -361,7 +334,6 @@ int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *set return count; } - int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) { char *szSetting; @@ -379,16 +351,16 @@ int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *s } if (szSetting[0] == 0) { - ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); + ItemFound(hwnd, hContact, module, setting, NULL, FW_SETTINGNAME | FW_DELETED); db_unset(hContact, module, setting); return 1; } // check & write - if ( GetSetting(hContact, module, myreplace, &dbv2)) { - if ( !db_set(hContact, module, szSetting, &dbv2)) { + if (GetSetting(hContact, module, myreplace, &dbv2)) { + if (!db_set(hContact, module, szSetting, &dbv2)) { count++; - db_unset(hContact,module,setting); + db_unset(hContact, module, setting); ItemFound(hwnd, hContact, module, szSetting, NULL, FW_SETTINGNAME | FW_REPLACED); } } @@ -400,26 +372,23 @@ int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *s int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *find, const char *replace, int mode) { - ModuleSettingLL msll; - struct ModSetLinkLinkItem *setting; + ModSetLinkLinkItem *setting; char *myreplace = NULL; char *newModule; int count = 0; if (mode & RW_FULL) newModule = (char*)replace; - else - { + else { myreplace = multiReplace(module, find, replace, mode & RW_CASE); newModule = myreplace; } - if (newModule[0]==0) - { - ItemFound(hwnd,hContact,module,NULL,NULL,FW_MODULE|FW_DELETED); + if (newModule[0] == 0) { + ItemFound(hwnd, hContact, module, NULL, NULL, FW_MODULE | FW_DELETED); deleteModule((char*)module, hContact, 1); - replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, NULL); + replaceTreeItem(GetDlgItem(hwnd2mainWindow, IDC_MODULES), hContact, module, NULL); mir_free(myreplace); return 1; } @@ -427,35 +396,31 @@ int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *fi if (!IsModuleEmpty(hContact, newModule)) return 0; - if (EnumSettings(hContact,(char*)module,&msll)) - { + if (EnumSettings(hContact, (char*)module, &msll)) { setting = msll.first; - while(setting) - { + while (setting) { DBVARIANT dbv; - if (!GetSetting(hContact, module, setting->name, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - db_set_b(hContact, newModule, setting->name, dbv.bVal); + if (!GetSetting(hContact, module, setting->name, &dbv)) { + switch (dbv.type) { + case DBVT_BYTE: + db_set_b(hContact, newModule, setting->name, dbv.bVal); break; - case DBVT_WORD: - db_set_w(hContact, newModule, setting->name, dbv.wVal); + case DBVT_WORD: + db_set_w(hContact, newModule, setting->name, dbv.wVal); break; - case DBVT_DWORD: - db_set_dw(hContact, newModule, setting->name, dbv.dVal); + case DBVT_DWORD: + db_set_dw(hContact, newModule, setting->name, dbv.dVal); break; - case DBVT_ASCIIZ: - db_set_s(hContact, newModule, setting->name, dbv.pszVal); + case DBVT_ASCIIZ: + db_set_s(hContact, newModule, setting->name, dbv.pszVal); break; - case DBVT_UTF8: - db_set_utf(hContact, newModule, setting->name, dbv.pszVal); + case DBVT_UTF8: + db_set_utf(hContact, newModule, setting->name, dbv.pszVal); break; - case DBVT_BLOB: - db_set_blob(hContact, newModule, setting->name, dbv.pbVal, dbv.cpbVal); + case DBVT_BLOB: + db_set_blob(hContact, newModule, setting->name, dbv.pbVal, dbv.cpbVal); break; } @@ -463,36 +428,32 @@ int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *fi db_unset(hContact, module, setting->name); } - setting = (struct ModSetLinkLinkItem *)setting->next; + setting = setting->next; } FreeModuleSettingLL(&msll); - replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, newModule); + replaceTreeItem(GetDlgItem(hwnd2mainWindow, IDC_MODULES), hContact, module, newModule); - ItemFound(hwnd,hContact,newModule,NULL,NULL,FW_MODULE|FW_REPLACED); + ItemFound(hwnd, hContact, newModule, NULL, NULL, FW_MODULE | FW_REPLACED); count++; } mir_free(myreplace); - return count; } - char* stringToUpper(char* in, char* out, int maxlen) { - int i; int len; - - if (maxlen>0) + if (maxlen > 0) len = maxlen - 1; else len = 0x10000; - for (i=0;in[i] && i='a' && in[i]<='z')?toupper(in[i]):in[i]; + int i; + for (i = 0; in[i] && i < len; i++) + out[i] = (in[i] >= 'a' && in[i] <= 'z') ? toupper(in[i]) : in[i]; out[i] = '\0'; - return out; } @@ -506,37 +467,39 @@ void __cdecl FindSettings(LPVOID di) HWND prnthwnd = GetParent(hwnd); int options = ((FindInfo*)di)->options; ModuleSettingLL ModuleList, SettingList; - struct ModSetLinkLinkItem *module, *setting; + ModSetLinkLinkItem *module, *setting; HANDLE hContact; - DBVARIANT dbv = {0}; - int caseSensitive = options&FW_CASE; - int exactMatch = options&FW_EXACT; - int inModuleName = options&FW_MODNAME; - int inSettingName = options&FW_SETNAME; - int inSettingValue = options&FW_SETVAL; + DBVARIANT dbv = { 0 }; + int caseSensitive = options & FW_CASE; + int exactMatch = options & FW_EXACT; + int inModuleName = options & FW_MODNAME; + int inSettingName = options & FW_SETNAME; + int inSettingValue = options & FW_SETVAL; int foundCount = 0; int replaceCount = 0; char szTmp[128]; int settingValue, isNumber, NULLContactDone = 0; freeItems(hwnd); - if (!text) return; + if (!text) + return; - if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); mir_free(di); return;} + if (!EnumModules(&ModuleList)) { + msg(Translate("Error Loading Module List"), modFullname); + mir_free(di); + return; + } - SendMessage(GetDlgItem(GetParent(hwnd),IDC_SBAR),SB_SETTEXT,0,(LPARAM)Translate("Searching...")); + SendMessage(GetDlgItem(GetParent(hwnd), IDC_SBAR), SB_SETTEXT, 0, (LPARAM)Translate("Searching...")); hContact = 0; - isNumber = sscanf(text,"%d",&settingValue); + isNumber = sscanf(text, "%d", &settingValue); - while (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA)) - { - if (!hContact) - { + while (GetWindowLongPtr(GetDlgItem(prnthwnd, IDC_SEARCH), GWLP_USERDATA)) { + if (!hContact) { if (NULLContactDone) break; - else - { + else { NULLContactDone = 1; hContact = db_find_first(); } @@ -544,17 +507,14 @@ void __cdecl FindSettings(LPVOID di) else hContact = db_find_next(hContact); module = ModuleList.first; - while (module) - { - if (IsModuleEmpty(hContact, module->name)) - { - module = (struct ModSetLinkLinkItem *)module->next; + while (module) { + if (IsModuleEmpty(hContact, module->name)) { + module = module->next; continue; } - if (!EnumSettings(hContact,module->name,&SettingList)) - { - msg(Translate("Error Loading Setting List"),modFullname); + if (!EnumSettings(hContact, module->name, &SettingList)) { + msg(Translate("Error Loading Setting List"), modFullname); mir_free(text); mir_free(di); FreeModuleSettingLL(&ModuleList); @@ -563,60 +523,52 @@ void __cdecl FindSettings(LPVOID di) setting = SettingList.first; // check in settings value - while (setting) - { - if (inSettingValue) - { + while (setting) { + if (inSettingValue) { dbv.type = 0; // check the setting value - if (!GetSetting(hContact,module->name,setting->name,&dbv)) - { - switch (dbv.type) - { - case DBVT_UTF8: // no conversion atm - case DBVT_ASCIIZ: - if ((exactMatch && !(caseSensitive?strcmp(dbv.pszVal,text):strcmpi(dbv.pszVal,text))) || (!exactMatch && (caseSensitive?strstr(dbv.pszVal,text):StrStrI(dbv.pszVal,text)))) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,dbv.pszVal,FW_SETTINGVALUE); - - foundCount++; - } + if (!GetSetting(hContact, module->name, setting->name, &dbv)) { + switch (dbv.type) { + case DBVT_UTF8: // no conversion atm + case DBVT_ASCIIZ: + if ((exactMatch && !(caseSensitive ? strcmp(dbv.pszVal, text) : strcmpi(dbv.pszVal, text))) || (!exactMatch && (caseSensitive ? strstr(dbv.pszVal, text) : StrStrI(dbv.pszVal, text)))) { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); + else + ItemFound(hwnd, hContact, module->name, setting->name, dbv.pszVal, FW_SETTINGVALUE); + + foundCount++; + } break; - case DBVT_BYTE: - if (isNumber && settingValue == dbv.bVal) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); - foundCount++; - } + case DBVT_BYTE: + if (isNumber && settingValue == dbv.bVal) { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); + else + ItemFound(hwnd, hContact, module->name, setting->name, text, FW_SETTINGVALUE); + foundCount++; + } break; - case DBVT_WORD: - if (isNumber && settingValue == dbv.wVal) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); - foundCount++; - } + case DBVT_WORD: + if (isNumber && settingValue == dbv.wVal) { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); + else + ItemFound(hwnd, hContact, module->name, setting->name, text, FW_SETTINGVALUE); + foundCount++; + } break; - case DBVT_DWORD: - if (isNumber && settingValue == (int)dbv.dVal) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); - foundCount++; - } + case DBVT_DWORD: + if (isNumber && settingValue == (int)dbv.dVal) { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); + else + ItemFound(hwnd, hContact, module->name, setting->name, text, FW_SETTINGVALUE); + foundCount++; + } break; } @@ -625,69 +577,59 @@ void __cdecl FindSettings(LPVOID di) } // check in setting name - if (inSettingName) - { - if ((exactMatch && !(caseSensitive?strcmp(setting->name,text):strcmpi(setting->name,text))) || (!exactMatch && (caseSensitive?StrStrI(setting->name,text):StrStrI(setting->name,text)))) - { - if ((mode & RW_FOUND) || (mode & RW_SETNAME)) - { - if (!GetSetting(hContact,module->name,setting->name,&dbv)) - { + if (inSettingName) { + if ((exactMatch && !(caseSensitive ? strcmp(setting->name, text) : strcmpi(setting->name, text))) || (!exactMatch && (caseSensitive ? StrStrI(setting->name, text) : StrStrI(setting->name, text)))) { + if ((mode & RW_FOUND) || (mode & RW_SETNAME)) { + if (!GetSetting(hContact, module->name, setting->name, &dbv)) { replaceCount += replaceSetting(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); db_free(&dbv); } } else - ItemFound(hwnd,hContact,module->name,setting->name, NULL, FW_SETTINGNAME); + ItemFound(hwnd, hContact, module->name, setting->name, NULL, FW_SETTINGNAME); foundCount++; } } - setting = (struct ModSetLinkLinkItem *)setting->next; + setting = (ModSetLinkLinkItem *)setting->next; } // check in module name - if (inModuleName) - { - if ((exactMatch && !(caseSensitive?strcmp(module->name,text):strcmpi(module->name,text))) || (!exactMatch && (caseSensitive?strstr(module->name,text):StrStrI(module->name,text)))) - { + if (inModuleName) { + if ((exactMatch && !(caseSensitive ? strcmp(module->name, text) : strcmpi(module->name, text))) || (!exactMatch && (caseSensitive ? strstr(module->name, text) : StrStrI(module->name, text)))) { if ((mode & RW_FOUND) || (mode & RW_MODULE)) replaceCount += replaceModule(hwnd, hContact, module->name, text, replace, mode); else - ItemFound(hwnd,hContact,module->name,0, 0, FW_MODULE); + ItemFound(hwnd, hContact, module->name, 0, 0, FW_MODULE); foundCount++; } } FreeModuleSettingLL(&SettingList); - module = (struct ModSetLinkLinkItem *)module->next; + module = (ModSetLinkLinkItem *)module->next; } } - if (mode) - { + if (mode) { if (!replace[0]) mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were deleted."), foundCount, replaceCount); else mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were replaced."), foundCount, replaceCount); } - else - mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); + else mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); - SendMessage(GetDlgItem(prnthwnd,IDC_SBAR),SB_SETTEXT,0,(LPARAM)szTmp); + SendMessage(GetDlgItem(prnthwnd, IDC_SBAR), SB_SETTEXT, 0, (LPARAM)szTmp); - SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA,0); + SetWindowLongPtr(GetDlgItem(prnthwnd, IDC_SEARCH), GWLP_USERDATA, 0); - if (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA)) - { - SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA, 0); - EnableWindow(GetDlgItem(prnthwnd,IDC_SEARCH),1); - SetWindowText(GetDlgItem(prnthwnd,IDOK),Translate("&Replace")); + if (GetWindowLongPtr(GetDlgItem(prnthwnd, IDC_REPLACE), GWLP_USERDATA)) { + SetWindowLongPtr(GetDlgItem(prnthwnd, IDC_REPLACE), GWLP_USERDATA, 0); + EnableWindow(GetDlgItem(prnthwnd, IDC_SEARCH), 1); + SetWindowText(GetDlgItem(prnthwnd, IDOK), Translate("&Replace")); } - else - { - SetWindowText(GetDlgItem(prnthwnd,IDC_SEARCH),Translate("&Search")); - EnableWindow(GetDlgItem(prnthwnd,IDOK),1); + else { + SetWindowText(GetDlgItem(prnthwnd, IDC_SEARCH), Translate("&Search")); + EnableWindow(GetDlgItem(prnthwnd, IDOK), 1); } mir_free(replace); @@ -695,6 +637,5 @@ void __cdecl FindSettings(LPVOID di) mir_free(di); FreeModuleSettingLL(&ModuleList); - EnableWindow(GetDlgItem(prnthwnd,IDCANCEL),1); - + EnableWindow(GetDlgItem(prnthwnd, IDCANCEL), 1); } -- cgit v1.2.3