From 380664004b21439985f148faaec988b0f28dc489 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Dec 2012 18:24:23 +0000 Subject: - crash fix for Win64 builds; - some unneeded Unicode stuff wiped out git-svn-id: http://svn.miranda-ng.org/main/trunk@2762 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbEditorPP/src/addeditsettingsdlg.cpp | 146 +++++++++++--------------- plugins/DbEditorPP/src/copymodule.cpp | 79 ++++---------- plugins/DbEditorPP/src/exportimport.cpp | 18 ++-- plugins/DbEditorPP/src/headers.h | 2 +- plugins/DbEditorPP/src/main.cpp | 90 +++++++--------- plugins/DbEditorPP/src/main_window.cpp | 8 +- plugins/DbEditorPP/src/moduletree.cpp | 89 +++++----------- plugins/DbEditorPP/src/settinglist.cpp | 77 ++++---------- plugins/DbEditorPP/src/watchedvars.cpp | 73 ++++++------- 9 files changed, 211 insertions(+), 371 deletions(-) (limited to 'plugins/DbEditorPP') diff --git a/plugins/DbEditorPP/src/addeditsettingsdlg.cpp b/plugins/DbEditorPP/src/addeditsettingsdlg.cpp index 6c21fe498c..968ee92bc0 100644 --- a/plugins/DbEditorPP/src/addeditsettingsdlg.cpp +++ b/plugins/DbEditorPP/src/addeditsettingsdlg.cpp @@ -6,26 +6,25 @@ static BOOL Convert(HANDLE hContact, char* module, char* setting, int value, int int Result = 1; char temp[64]; - switch (toType) - { - case 0: - if (value > 0xFF) - Result = 0; - else - DBWriteContactSettingByte(hContact, module, setting, (BYTE)value); + switch (toType) { + case 0: + if (value > 0xFF) + Result = 0; + else + DBWriteContactSettingByte(hContact, module, setting, (BYTE)value); break; - case 1: - if (value > 0xFFFF) - Result = 0; - else - DBWriteContactSettingWord(hContact, module, setting, (WORD)value); + case 1: + if (value > 0xFFFF) + Result = 0; + else + DBWriteContactSettingWord(hContact, module, setting, (WORD)value); break; - case 2: - DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); + case 2: + DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); break; - case 3: - DBDeleteContactSetting(hContact, module, setting); - DBWriteContactSettingString(hContact, module, setting, itoa(value,temp,10)); + case 3: + DBDeleteContactSetting(hContact, module, setting); + DBWriteContactSettingString(hContact, module, setting, itoa(value,temp,10)); break; } return Result; @@ -37,51 +36,47 @@ BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // DBVARIANT dbv = {0}; BOOL Result = 0; - if (!GetSetting(hContact, module, setting, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - Result = Convert(hContact, module, setting, dbv.bVal, toType); - break; + if (!GetSetting(hContact, module, setting, &dbv)) { + switch (dbv.type) { + case DBVT_BYTE: + Result = Convert(hContact, module, setting, dbv.bVal, toType); + break; - case DBVT_WORD: - Result = Convert(hContact, module, setting, dbv.wVal, toType); - break; + case DBVT_WORD: + Result = Convert(hContact, module, setting, dbv.wVal, toType); + break; - case DBVT_DWORD: - Result = Convert(hContact, module, setting, dbv.dVal, toType); - break; + case DBVT_DWORD: + Result = Convert(hContact, module, setting, dbv.dVal, toType); + break; - case DBVT_ASCIIZ: - if (toType == 4) // convert to UNICODE - { - int len = (int)strlen(dbv.pszVal) + 1; - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); - Result = !DBWriteContactSettingWString(hContact, module, setting, wc); - } - else - if (strlen(dbv.pszVal) < 11 && toType != 3) - { - int val = atoi(dbv.pszVal); - if (val == 0 && dbv.pszVal[0] != '0') - break; + case DBVT_ASCIIZ: + if (toType == 4) // convert to UNICODE + { + int len = (int)strlen(dbv.pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); + Result = !DBWriteContactSettingWString(hContact, module, setting, wc); + } + else if (strlen(dbv.pszVal) < 11 && toType != 3) { + int val = atoi(dbv.pszVal); + if (val == 0 && dbv.pszVal[0] != '0') + break; - Result = Convert(hContact, module, setting, val, toType); - } - break; - case DBVT_UTF8: - if (toType == 3 && UOS) // convert to ANSI - { - int len = (int)strlen(dbv.pszVal) + 1; - char *sz = (char*)_alloca(len*3); - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); - WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); - Result = !DBWriteContactSettingString(hContact, module, setting, sz); - } - break; + Result = Convert(hContact, module, setting, val, toType); + } + break; + + case DBVT_UTF8: + if (toType == 3) { // convert to ANSI + int len = (int)strlen(dbv.pszVal) + 1; + char *sz = (char*)_alloca(len*3); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); + WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); + Result = !DBWriteContactSettingString(hContact, module, setting, sz); + } + break; } if (!Result) @@ -205,17 +200,11 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l else { char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); - if (UOS) - { - int length = (int)strlen(tmp) + 1; - WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); - SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); - } - else { - // convert from UTF8 - SetDlgItemText(hwnd, IDC_STRING, tmp); - } + int length = (int)strlen(tmp) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); + SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); + SetWindowText(hwnd, Translate("Edit UNICODE value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); } @@ -331,7 +320,7 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l valueLength = GetWindowTextLength(GetDlgItem(hwnd, valueID)); - if (dbsetting->dbv.type == DBVT_UTF8 && UOS) + if (dbsetting->dbv.type == DBVT_UTF8) valueLength *= sizeof(WCHAR); if (settingLength) @@ -355,7 +344,7 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l if (valueLength) { - if (dbsetting->dbv.type == DBVT_UTF8 && UOS) + if (dbsetting->dbv.type == DBVT_UTF8) SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); else GetWindowText(GetDlgItem(hwnd, valueID), value, valueLength+1); @@ -406,17 +395,10 @@ INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l break; case 3: if (dbsetting->dbv.type == DBVT_UTF8) - { - if (UOS) - DBWriteContactSettingWString(dbsetting->hContact, dbsetting->module, setting, (WCHAR*)value); - else - DBWriteContactSettingStringUtf(dbsetting->hContact, dbsetting->module, setting, value); - } - else - if (dbsetting->dbv.type == DBVT_BLOB) + DBWriteContactSettingWString(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) + else if (dbsetting->dbv.type == DBVT_ASCIIZ) DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); break; } @@ -450,7 +432,7 @@ void editSetting(HANDLE hContact, char* module, char* setting) dbsetting->module = mir_tstrdup(module); dbsetting->setting = mir_tstrdup(setting); - if (dbv.type == DBVT_UTF8 && UOS) + if (dbv.type == DBVT_UTF8) CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); else CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); diff --git a/plugins/DbEditorPP/src/copymodule.cpp b/plugins/DbEditorPP/src/copymodule.cpp index 4bc2b21f4c..28ee01a696 100644 --- a/plugins/DbEditorPP/src/copymodule.cpp +++ b/plugins/DbEditorPP/src/copymodule.cpp @@ -65,68 +65,35 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } // contacts name - if (UOS) - { - DBVARIANT dbv ={0}; - WCHAR nick[256]; - WCHAR protoW[256]; // unicode proto + DBVARIANT dbv ={0}; + WCHAR nick[256]; + WCHAR protoW[256]; // unicode proto - if (szProto[0]) - a2u(szProto, protoW, SIZEOF(protoW)); - else - protoW[0] = 0; + if (szProto[0]) + a2u(szProto, protoW, SIZEOF(protoW)); + else + protoW[0] = 0; - if (!szProto[0] || !loaded) - { - if (protoW) - { - if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); - else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); - } - else - wcscpy(nick, nick_unknownW); - } - else - { + if (!szProto[0] || !loaded) { + if (protoW) { if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); } - - index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); - SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); + else + wcscpy(nick, nick_unknownW); } - else - { - char nick[256]; - - if (!szProto[0] || !loaded) - { - if (szProto[0]) - { - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); - } - else - strcpy(nick, nick_unknown); - } + else { + if (Order) + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); else - { - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); - } - - index = SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); - SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); } + index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); + SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); + hContact = db_find_next(hContact); } @@ -185,13 +152,9 @@ INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara void copyModuleMenuItem(char* module, HANDLE hContact) { - HWND hwnd; ModuleAndContact *mac = (ModuleAndContact *)mir_calloc(sizeof(ModuleAndContact)); mac->hContact = hContact; strncpy(mac->module, module, 255); - if (UOS) - hwnd = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); - else - hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); + CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); } \ No newline at end of file diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index b4c1142e2c..5f8006e9ec 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -415,41 +415,35 @@ void importSettings(HANDLE hContact, char *importstring ) i = i + (int)strlen("CONTACT:"); len = (int)strlen(&importstring[i]); - if (len > 10) - { + if (len > 10) { 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)) - { + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szUID)) { strncpy(szUID, p1+1, p2-p1-2); p1 = strrchr(&importstring[i], ')*<'); p2 = strrchr(&importstring[i], '>*{'); - if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(uid)) - { + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(uid)) { strncpy(uid, p1+1, p2-p1-3); p1 = strrchr(&importstring[i], ' *('); p2 = strrchr(&importstring[i], ')*<'); - if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szProto)) - { + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szProto)) { char *protouid; strncpy(szProto, p1+1, p2-p1-3); protouid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); - if ((int)protouid!=CALLSERVICE_NOTFOUND) - { + if ((INT_PTR)protouid != CALLSERVICE_NOTFOUND) { if (!mir_strcmp(protouid, uid)) hContact = CheckNewContact(szProto, uid, szUID); } - else - hContact = CheckNewContact(szProto, uid, szUID); + else hContact = CheckNewContact(szProto, uid, szUID); } } } diff --git a/plugins/DbEditorPP/src/headers.h b/plugins/DbEditorPP/src/headers.h index 488d190f16..3ededc9129 100644 --- a/plugins/DbEditorPP/src/headers.h +++ b/plugins/DbEditorPP/src/headers.h @@ -170,7 +170,7 @@ extern HIMAGELIST himl2; extern int Mode; extern int Hex; extern int Order; -extern BOOL UDB, UOS; +extern BOOL UDB; extern BOOL usePopUps; diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index beb025d7d3..0fd4440ec8 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -249,19 +249,15 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam) if (DBGetContactSettingByte(NULL,modname,"WarnOnDelete",-1) == -1) DBWriteContactSettingByte(NULL,modname,"WarnOnDelete",1); - cgs.szModule=modname; - cgs.szSetting="WarnOnDelete"; - cgs.pValue=&dbv; + cgs.szModule = modname; + cgs.szSetting = "WarnOnDelete"; + cgs.pValue = &dbv; if (!CallService(MS_DB_CONTACT_GETSETTING_STR, 0,(LPARAM)&cgs)) if (dbv.type == DBVT_BYTE) UDB = TRUE; } - // check OS support for unicode - // useless if DB doesnt not support unicode - UOS = (UDB && IsCP_UTF8() && IsWinVerNT()); - hTTBHook = HookEvent(ME_TTB_MODULELOADED, OnTTBLoaded); if ( bServiceMode ) @@ -429,17 +425,6 @@ int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) { switch(dbv.type) { - case DBVT_UTF8: - if (UOS) - { - int len = (int)strlen(dbv.pszVal)+1; - char *sz = (char*)_alloca(len*3); - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); - WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); - strncpy(Value, sz, length); - break; - }// else fall through case DBVT_ASCIIZ: strncpy(Value, dbv.pszVal, length); break; @@ -452,6 +437,14 @@ int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* case DBVT_WORD: _itoa(dbv.wVal,Value,10); break; + case DBVT_UTF8: + int len = (int)strlen(dbv.pszVal)+1; + char *sz = (char*)_alloca(len*3); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); + WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); + strncpy(Value, sz, length); + break; } DBFreeVariant(&dbv); @@ -577,51 +570,41 @@ WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) char name[256]; if (hContact && !proto) - { if (GetValue(hContact,"Protocol","p",name,SIZEOF(name))) proto = name; - } - if (proto) - { - - for(i=0;itype |= EMPTY; // contacts name - if (UOS) - { - DBVARIANT dbv ={0}; - WCHAR nick[256]; - WCHAR protoW[256]; // unicode proto + DBVARIANT dbv ={0}; + WCHAR nick[256]; + WCHAR protoW[256]; // unicode proto - if (szProto) - a2u(szProto, protoW, SIZEOF(protoW)); - else - protoW[0] = 0; + if (szProto) + a2u(szProto, protoW, SIZEOF(protoW)); + else + protoW[0] = 0; - if (!szProto || !loaded) - { - tvi.item.iSelectedImage = (tvi.item.iImage = 4); + if (!szProto || !loaded) + { + tvi.item.iSelectedImage = (tvi.item.iImage = 4); - if (protoW) { - if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); - else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); - } - else wcscpy(nick, nick_unknownW); - } - else { - tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); + if (protoW) { if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); } - - tvi.item.pszText = (char*)nick; - contact = TreeView_InsertItemW(hwnd2Tree, &tvi); + else wcscpy(nick, nick_unknownW); } else { - char nick[256]; - - if (!szProto[0] || !loaded) { - tvi.item.iSelectedImage = (tvi.item.iImage = 4); - - if (szProto[0]) { - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); - } - else strcpy(nick, nick_unknown); - } - else { - tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); - } - - tvi.item.pszText = nick; - contact = TreeView_InsertItem(hwnd2Tree, &tvi); + tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); + if (Order) + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); + else + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); } + tvi.item.pszText = (char*)nick; + contact = TreeView_InsertItemW(hwnd2Tree, &tvi); + itemscount++; if (hSelectedContact == hContact) { @@ -230,10 +202,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) } } - if (UOS) - SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); - else - SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); + SetWindowText(hwnd, TranslateT("Database Editor++")); } int findItemInTree(HWND hwnd2Tree, HANDLE hContact, char* module) @@ -744,12 +713,9 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd } lvi.iItem = 0; - lvi.pszText = (char*)GetContactName(hContact,NULL,UOS); + lvi.pszText = (char*)GetContactName(hContact, NULL, FALSE); - if (UOS) - index = ListView_InsertItemW(hwnd2Settings,&lvi); - else - index = ListView_InsertItem(hwnd2Settings,&lvi); + index = ListView_InsertItem(hwnd2Settings, &lvi); mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact); @@ -805,10 +771,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; - if (UOS) - newtext = u2a((WCHAR*)ptvdi->item.pszText); - else - newtext = mir_tstrdup(ptvdi->item.pszText); + newtext = u2a((WCHAR*)ptvdi->item.pszText); if (!newtext || // edit control failed !mtis->type || // its a root item diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index 5fff4fed21..0e9efb6c6a 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -1,12 +1,10 @@ #include "headers.h" -int UOS; - void setupSettingsList(HWND hwnd2List) { LVCOLUMN sLC; - ListView_SetUnicodeFormat(hwnd2List, UOS); + ListView_SetUnicodeFormat(hwnd2List, TRUE); sLC.fmt = LVCFMT_LEFT; ListView_SetExtendedListViewStyle(hwnd2List, 32|LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT @@ -199,17 +197,9 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in lvi.iImage = 5; ListView_SetItem(hwnd2Settings,&lvi); - if (UOS) - { - WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, length); - ListView_SetItemTextW(hwnd2Settings,index,1,wc); - } - else - { - // convert from UTF8 - ListView_SetItemText(hwnd2Settings,index,1,dbv.pszVal); - } + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, length); + ListView_SetItemTextW(hwnd2Settings,index,1,wc); ListView_SetItemText(hwnd2Settings,index,2,Translate("UNICODE")); mir_snprintf(data, 512, "0x%04X (%d)", length,length); @@ -608,10 +598,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w case WM_GETDLGCODE: return DLGC_WANTALLKEYS; } - if (UOS) - return CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); - else - return CallWindowProc(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); + return CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); } @@ -656,7 +643,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem) switch (dbv.type) { case DBVT_UTF8: - if (subitem && UOS) + if (subitem) { int len = mir_strlen(dbv.pszVal)+1; WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); @@ -721,10 +708,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem) DBFreeVariant(&dbv); - if (UOS) - SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtrW(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); - else - SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtr(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); + SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtrW(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); SendMessage(info->hwnd2Edit,WM_USER,0,(LPARAM)data); } @@ -852,8 +836,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here hContact = info->hContact; hti.pt=((NMLISTVIEW*)lParam)->ptAction; - if (ListView_SubItemHitTest(hSettings,&hti) == -1) - { + if (ListView_SubItemHitTest(hSettings,&hti) == -1) { // nowhere.. new item menu GetCursorPos(&pt); hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); @@ -863,9 +846,8 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here if (!UDB) RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL)) - { - case MENU_ADD_BYTE: + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL)) { + case MENU_ADD_BYTE: { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog @@ -877,7 +859,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; - case MENU_ADD_WORD: + case MENU_ADD_WORD: { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog @@ -889,7 +871,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; - case MENU_ADD_DWORD: + case MENU_ADD_DWORD: { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog @@ -901,7 +883,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; - case MENU_ADD_STRING: + case MENU_ADD_STRING: { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog @@ -913,7 +895,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; - case MENU_ADD_UNICODE: + case MENU_ADD_UNICODE: if (UDB) { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc @@ -923,13 +905,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here dbsetting->hContact = hContact; dbsetting->module = mir_tstrdup(module); dbsetting->setting = mir_tstrdup(""); - if (UOS) - CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - else - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; - case MENU_ADD_BLOB: + case MENU_ADD_BLOB: { struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc DBVARIANT dbv = {0}; // freed in the dialog @@ -941,7 +920,6 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; - } // switch } else // on item @@ -964,8 +942,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here ListView_GetItem(hSettings,&lvi); ListView_GetItemText(hSettings, hti.iItem, 2, type, 8); - if (!UDB) - { + if (!UDB) { RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); } @@ -1107,10 +1084,7 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here dbsetting->hContact = hContact; dbsetting->module = mir_tstrdup(module); dbsetting->setting = mir_tstrdup(""); - if (UOS) - CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - else - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); } break; case MENU_ADD_BLOB: @@ -1183,17 +1157,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here const char c = *str1 ^ 0xc3; if (c) *str1 = c; } - if (UOS) - { - WCHAR *res = mir_utf8decodeW(str); - MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); - mir_free(res); - } - else - { - mir_utf8decode(str, NULL); - MessageBoxA(0, str, Translate("Decoded string.."),MB_OK); - } + + WCHAR *res = mir_utf8decodeW(str); + MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); + mir_free(res); mir_free(str); } } diff --git a/plugins/DbEditorPP/src/watchedvars.cpp b/plugins/DbEditorPP/src/watchedvars.cpp index 1e315451b8..2bd929209c 100644 --- a/plugins/DbEditorPP/src/watchedvars.cpp +++ b/plugins/DbEditorPP/src/watchedvars.cpp @@ -70,23 +70,19 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) if (!hContact) lvItem.pszText = "NULL"; else - lvItem.pszText = (char*)GetContactName(hContact,NULL,UOS); + lvItem.pszText = (char*)GetContactName(hContact, NULL, 1); index = ListView_InsertItem(hwnd2list,&lvItem); - if (UOS) - { - WCHAR* ptszText = mir_a2u(lvItem.pszText); - ListView_SetItemTextW(hwnd2list, index, 0, ptszText); - mir_free(ptszText); - } + 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); - switch (dbv->type) - { - case DBVT_BLOB: + switch (dbv->type) { + case DBVT_BLOB: { int j; char *data = NULL; @@ -104,42 +100,37 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) mir_free(data); } break; - case DBVT_BYTE: - mir_snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"BYTE"); - break; - case DBVT_WORD: - mir_snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"WORD"); + + case DBVT_BYTE: + mir_snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"BYTE"); break; - case DBVT_DWORD: - mir_snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"DWORD"); + + case DBVT_WORD: + mir_snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"WORD"); break; - case DBVT_ASCIIZ: - ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); - ListView_SetItemText(hwnd2list,index,3,"STRING"); + + case DBVT_DWORD: + mir_snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"DWORD"); break; - case DBVT_UTF8: - { - if (UOS) - { - 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); - } - else { - // convert from UTF8 - ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); - } - ListView_SetItemText(hwnd2list,index,3,"UNICODE"); - } + + case DBVT_ASCIIZ: + 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"); + break; } } -- cgit v1.2.3