From b218fc95603571df3e9a6181d7e0de7f37e3bcc4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Dec 2012 18:50:44 +0000 Subject: and also database Unicode support flag too git-svn-id: http://svn.miranda-ng.org/main/trunk@2763 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/DbEditorPP/src/headers.h | 1 - plugins/DbEditorPP/src/main.cpp | 89 ++--- plugins/DbEditorPP/src/settinglist.cpp | 630 +++++++++++++++------------------ 3 files changed, 307 insertions(+), 413 deletions(-) (limited to 'plugins/DbEditorPP/src') diff --git a/plugins/DbEditorPP/src/headers.h b/plugins/DbEditorPP/src/headers.h index 3ededc9129..2e8688d5b9 100644 --- a/plugins/DbEditorPP/src/headers.h +++ b/plugins/DbEditorPP/src/headers.h @@ -170,7 +170,6 @@ extern HIMAGELIST himl2; extern int Mode; extern int Hex; extern int Order; -extern BOOL UDB; extern BOOL usePopUps; diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index 0fd4440ec8..64bfbe4356 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -10,7 +10,6 @@ HANDLE hTTBButt = NULL; BOOL bServiceMode = FALSE; BOOL usePopUps; HWND hwnd2watchedVarsWindow; -int UDB; int hLangpack; BYTE nameOrder[NAMEORDERCOUNT]; HANDLE hUserMenu; @@ -239,25 +238,6 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam) DBFreeVariant(&dbv); } - // check DB engine for unicode support - UDB = FALSE; - - if (ServiceExists(MS_DB_CONTACT_GETSETTING_STR)) { - DBCONTACTGETSETTING cgs; - dbv.type = 0; - - if (DBGetContactSettingByte(NULL,modname,"WarnOnDelete",-1) == -1) - DBWriteContactSettingByte(NULL,modname,"WarnOnDelete",1); - - 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; - } - hTTBHook = HookEvent(ME_TTB_MODULELOADED, OnTTBLoaded); if ( bServiceMode ) @@ -398,32 +378,18 @@ int WriteBlobFromString(HANDLE hContact,const char *szModule,const char *szSetti int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) { DBCONTACTGETSETTING cgs; - - cgs.szModule=szModule; - cgs.szSetting=szSetting; - cgs.pValue=dbv; + cgs.szModule = szModule; + cgs.szSetting = szSetting; + cgs.pValue = dbv; dbv->type = 0; - - if (UDB) - return CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); - else - { - int rr = CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs); - - if (dbv->type != DBVT_UTF8) - return rr; - else - return 1; - } + return CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); } - int GetValue(HANDLE 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)) - { + if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) { switch(dbv.type) { case DBVT_ASCIIZ: strncpy(Value, dbv.pszVal, length); @@ -464,8 +430,7 @@ int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHA { DBVARIANT dbv ={0}; - if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) - { + if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) { switch(dbv.type) { case DBVT_UTF8: { @@ -475,6 +440,7 @@ int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHA wcsncpy((WCHAR*)Value, wc, length); } break; + case DBVT_ASCIIZ: { int len = (int)strlen(dbv.pszVal) + 1; @@ -483,12 +449,15 @@ int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHA wcsncpy((WCHAR*)Value, wc, length); } break; + case DBVT_DWORD: _itow(dbv.dVal,Value,10); break; + case DBVT_BYTE: _itow(dbv.bVal,Value,10); break; + case DBVT_WORD: _itow(dbv.wVal,Value,10); break; @@ -506,33 +475,29 @@ int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHA return 0; } - char *u2a( wchar_t* src ) { - if (src) - { - int cbLen = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL ); - char* result = (char*)mir_calloc((cbLen+1)*sizeof(char)); - if ( result == NULL ) - return NULL; - - WideCharToMultiByte( CP_ACP, 0, src, -1, result, cbLen, NULL, NULL ); - result[ cbLen ] = 0; - return result; - } - else + if (!src) + return NULL; + + int cbLen = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL ); + char* result = (char*)mir_calloc((cbLen+1)*sizeof(char)); + if ( result == NULL ) return NULL; -} + WideCharToMultiByte( CP_ACP, 0, src, -1, result, cbLen, NULL, NULL ); + result[ cbLen ] = 0; + return result; +} wchar_t *a2u( char* src , wchar_t *buffer, int len ) { - wchar_t *result = buffer; + wchar_t *result = buffer; if ( result == NULL || len < 3) return NULL; MultiByteToWideChar( CP_ACP, 0, src, -1, result, len - 1 ); - result[ len - 1 ] = 0; + result[ len - 1 ] = 0; return result; } @@ -551,7 +516,6 @@ int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...) return len; } - int GetDatabaseString(HANDLE hContact, const char *szModule, const char* szSetting, WCHAR *Value, int length, BOOL unicode) { if (unicode) @@ -560,10 +524,8 @@ int GetDatabaseString(HANDLE hContact, const char *szModule, const char* szSetti return GetValue(hContact, szModule, szSetting, (char*)Value, length); } - WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) { - int i, r = 0; static WCHAR res[512]; char *proto = (char*)szProto; @@ -638,8 +600,5 @@ WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) } } - if (unicode) - return nick_unknownW; - else - return (WCHAR*)nick_unknown; + return (unicode) ? nick_unknownW : (WCHAR*)nick_unknown; } diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index 0e9efb6c6a..3afbc56629 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -825,404 +825,340 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here { HWND hSettings = GetDlgItem(hwnd,IDC_SETTINGS); SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hSettings,GWLP_USERDATA); + if (!info) + return; + char setting[256], *module; HANDLE hContact; LVHITTESTINFO hti; POINT pt; HMENU hMenu, hSubMenu; + DBsetting *dbsetting; + DBVARIANT dbv = {0}; // freed in the dialog - if (!info) return; module = info->module; 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)); hSubMenu = GetSubMenu(hMenu, 6); TranslateMenu(hSubMenu); - 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: - { - 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 - dbv.type = DBVT_BYTE; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_BYTE; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; + 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 - dbv.type = DBVT_WORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_WORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; + 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 - dbv.type = DBVT_DWORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_DWORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; + 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 - dbv.type = DBVT_ASCIIZ; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_ASCIIZ; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; + case MENU_ADD_UNICODE: - if (UDB) - { - 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 - dbv.type = DBVT_UTF8; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_UTF8; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; + 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 - dbv.type = DBVT_BLOB; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_BLOB; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; - } // switch + } + return; } - else // on item - { - char type[8]; - LVITEM lvi; - int i; - int watching = 0; - GetCursorPos(&pt); - hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); - hSubMenu = GetSubMenu(hMenu, 0); - TranslateMenu(hSubMenu); + + // on item + char type[8]; + LVITEM lvi; + int i; + int watching = 0; + GetCursorPos(&pt); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); + hSubMenu = GetSubMenu(hMenu, 0); + TranslateMenu(hSubMenu); + + lvi.mask = LVIF_IMAGE|LVIF_TEXT; + lvi.iItem = hti.iItem; + lvi.iSubItem = 0; + lvi.pszText = setting; + lvi.cchTextMax = 256; + + ListView_GetItem(hSettings,&lvi); + ListView_GetItemText(hSettings, hti.iItem, 2, type, 8); - lvi.mask = LVIF_IMAGE|LVIF_TEXT; - lvi.iItem = hti.iItem; - lvi.iSubItem = 0; - lvi.pszText = setting; - lvi.cchTextMax = 256; + switch(lvi.iImage) { + case 4: // STRING + RemoveMenu(hSubMenu, MENU_CHANGE2STRING, MF_BYCOMMAND); + break; + case 1: // BYTE + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + case 2: // WORD + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + case 3: // DWORD + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + case 0: // BLOB + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, 1, MF_BYPOSITION); + RemoveMenu(hSubMenu, 2, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + break; + case 5: // UTF8 + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + } - ListView_GetItem(hSettings,&lvi); - ListView_GetItemText(hSettings, hti.iItem, 2, type, 8); + // watch list stuff - if (!UDB) { - RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + if (ListView_GetSelectedCount(hSettings) > 1) { + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, 1, MF_BYPOSITION); + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + } + + // check if the setting is being watched and if it is then check the menu item + for (i=0; ihContact,info->module, setting); break; - case 2: // WORD - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + + case MENU_ADD_BYTE: + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_BYTE; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; - case 3: // DWORD - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + + case MENU_ADD_WORD: + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_WORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; - case 0: // BLOB - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, 1, MF_BYPOSITION); - RemoveMenu(hSubMenu, 2, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + + case MENU_ADD_DWORD: + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_DWORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; - case 5: // UTF8 - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); - if (!UDB) - { - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, 1, MF_BYPOSITION); - RemoveMenu(hSubMenu, 2, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_WATCH_ITEM, MF_BYCOMMAND); - } - else - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + + case MENU_ADD_STRING: + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_ASCIIZ; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + break; + + case MENU_ADD_UNICODE: + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_UTF8; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); break; + + case MENU_ADD_BLOB: + dbsetting = (DBsetting*)mir_alloc(sizeof(DBsetting)); // gets safe_free()ed in the window proc + dbv.type = DBVT_BLOB; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + break; + + ///////////////////////// convert to submenu + case MENU_CHANGE2BYTE: + if (convertSetting(hContact, module, setting, 0)) { + lvi.iImage = 1; + ListView_SetItem(hSettings,&lvi); } + break; - // watch list stuff + case MENU_CHANGE2WORD: + if (convertSetting(hContact, module, setting, 1)) { + lvi.iImage = 2; + ListView_SetItem(hSettings,&lvi); + } + break; - if (ListView_GetSelectedCount(hSettings) >1) - { - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, 1, MF_BYPOSITION); - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + case MENU_CHANGE2DWORD: + if (convertSetting(hContact, module, setting, 2)) { + lvi.iImage = 3; + ListView_SetItem(hSettings,&lvi); } + break; - // check if the setting is being watched and if it is then check the menu item - for (i=0; ihContact,info->module, setting); - break; -///////////////////////// divider -//////////////////////// NEW item submenu - 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 - dbv.type = DBVT_BYTE; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - 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 - dbv.type = DBVT_WORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - 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 - dbv.type = DBVT_DWORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - 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 - dbv.type = DBVT_ASCIIZ; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_UNICODE: - if (UDB) - { - 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 - dbv.type = DBVT_UTF8; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - 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 - dbv.type = DBVT_BLOB; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; -///////////////////////// convert to submenu - case MENU_CHANGE2BYTE: - if (convertSetting(hContact, module, setting, 0)) - { - lvi.iImage = 1; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2WORD: - if (convertSetting(hContact, module, setting, 1)) - { - lvi.iImage = 2; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2DWORD: - if (convertSetting(hContact, module, setting, 2)) - { - lvi.iImage = 3; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2STRING: - if (convertSetting(hContact, module, setting, 3)) - { - lvi.iImage = 4; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2UNICODE: - if (convertSetting(hContact, module, setting, 4)) - { - lvi.iImage = 5; - ListView_SetItem(hSettings,&lvi); - } - break; -///////////////////////// convert to submenu - case MENU_VIEWDECRYPT: - { - DBVARIANT dbv; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - if (lstrcmpA(setting, "LoginPassword")) - { - char *text = mir_strdup(dbv.pszVal); - CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text); - msg(text, Translate("Decoded string..")); - mir_free(text); - } - else - { - char *str = mir_strdup(dbv.pszVal); - char *str1 = str; - for (;*str1; ++str1) - { - const char c = *str1 ^ 0xc3; - if (c) *str1 = c; - } + break; - WCHAR *res = mir_utf8decodeW(str); - MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); - mir_free(res); - mir_free(str); - } - } - DBFreeVariant(&dbv); + ///////////////////////// convert to submenu + case MENU_VIEWDECRYPT: + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) { + if (lstrcmpA(setting, "LoginPassword")) { + char *text = mir_strdup(dbv.pszVal); + CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text); + msg(text, Translate("Decoded string..")); + mir_free(text); } - break; - case MENU_VIEWENCRYPT: - { - DBVARIANT dbv; - char *text; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - text = mir_tstrdup(dbv.pszVal); - CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - msg(text, Translate("Encoded string..")); - mir_free(text); + else { + char *str = mir_strdup(dbv.pszVal); + char *str1 = str; + for (;*str1; ++str1) { + const char c = *str1 ^ 0xc3; + if (c) *str1 = c; } - DBFreeVariant(&dbv); - } - break; - case MENU_DECRYPT: - { - DBVARIANT dbv; - char *text; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - text = mir_tstrdup(dbv.pszVal); - CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - DBWriteContactSettingString(hContact,module,setting,text); - mir_free(text); - } - DBFreeVariant(&dbv); - } - break; - case MENU_ENCRYPT: - { - DBVARIANT dbv; - char *text; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - text = mir_tstrdup(dbv.pszVal); - CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - DBWriteContactSettingString(hContact,module,setting,text); - mir_free(text); - } - DBFreeVariant(&dbv); + + WCHAR *res = mir_utf8decodeW(str); + MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); + mir_free(res); + mir_free(str); } - break; -///////////////////////// divider - case MENU_WATCH_ITEM: + DBFreeVariant(&dbv); + } + break; - if (!watching) - { - addSettingToWatchList(hContact,module,setting); - } - else freeWatchListItem(i); - if (hwnd2watchedVarsWindow) - PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); - break; - case MENU_DELETE_SET: - DeleteSettingsFromList(hSettings, hContact, module, setting); - break; + case MENU_VIEWENCRYPT: + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) { + char *text = mir_tstrdup(dbv.pszVal); + CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); + msg(text, Translate("Encoded string..")); + mir_free(text); + } + DBFreeVariant(&dbv); + break; + + case MENU_DECRYPT: + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) { + char *text = mir_tstrdup(dbv.pszVal); + CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); + DBWriteContactSettingString(hContact,module,setting,text); + mir_free(text); + } + DBFreeVariant(&dbv); + break; + + case MENU_ENCRYPT: + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) { + char *text = mir_tstrdup(dbv.pszVal); + CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); + DBWriteContactSettingString(hContact,module,setting,text); + mir_free(text); } + DBFreeVariant(&dbv); + break; + + ///////////////////////// divider + case MENU_WATCH_ITEM: + if (!watching) + addSettingToWatchList(hContact,module,setting); + else + freeWatchListItem(i); + if (hwnd2watchedVarsWindow) + PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); + break; + + case MENU_DELETE_SET: + DeleteSettingsFromList(hSettings, hContact, module, setting); + break; } -} \ No newline at end of file +} -- cgit v1.2.3