summaryrefslogtreecommitdiff
path: root/dbeditorpp/settinglist.cpp
diff options
context:
space:
mode:
authorgeorge.hazan <george.hazan@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-05-26 20:18:42 +0000
committergeorge.hazan <george.hazan@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb>2011-05-26 20:18:42 +0000
commit2ebb53adcd4663ac2f1da74972b7b21d53b0ce53 (patch)
tree0c11a849c6bd2cff094017e8de6895a54363c586 /dbeditorpp/settinglist.cpp
parent4b6195fe205b03838ce334893e1141bf43f9fc6d (diff)
patch for dbeditorpp: C++ support, other improvements
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@122 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'dbeditorpp/settinglist.cpp')
-rw-r--r--dbeditorpp/settinglist.cpp227
1 files changed, 126 insertions, 101 deletions
diff --git a/dbeditorpp/settinglist.cpp b/dbeditorpp/settinglist.cpp
index 78bb941..c3c27cb 100644
--- a/dbeditorpp/settinglist.cpp
+++ b/dbeditorpp/settinglist.cpp
@@ -1,5 +1,6 @@
#include "headers.h"
+int UOS;
void setupSettingsList(HWND hwnd2List)
{
@@ -37,7 +38,7 @@ void saveListSettings(HWND hwnd2List)
for (i=0; i <= 3; i++)
if (ListView_GetColumn(hwnd2List,i,&sLC))
{
- _snprintf(tmp, 32, "Column%dwidth", i);
+ mir_snprintf(tmp, SIZEOF(tmp), "Column%dwidth", i);
DBWriteContactSettingWord(NULL, modname, tmp, (WORD)sLC.cx);
}
@@ -46,17 +47,17 @@ void saveListSettings(HWND hwnd2List)
void ClearListview(HWND hwnd2Settings)
{
- SettingListInfo *info = (SettingListInfo*)GetWindowLong(hwnd2Settings,GWL_USERDATA);
+ SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA);
if (info && ListView_GetItemCount(hwnd2Settings))
{
- safe_free(info->module);
+ mir_free(info->module);
if (info->hwnd2Edit)
{
SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0);
info->hwnd2Edit = NULL;
}
- safe_free(info);
- SetWindowLong(hwnd2Settings,GWL_USERDATA, 0);
+ mir_free(info);
+ SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, 0);
}
ListView_DeleteAllItems(hwnd2Settings);
}
@@ -81,7 +82,7 @@ void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char
{
if (ListView_GetItemState(hSettings,i,LVIS_SELECTED))
{
- ListView_GetItemText(hSettings, i, 0, text, sizeof(text));
+ ListView_GetItemText(hSettings, i, 0, text, SIZEOF(text));
DBDeleteContactSetting(hContact,module,text);
items--;
}
@@ -102,7 +103,7 @@ void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char
if ((int)item.hItem != -1)
if (TreeView_GetItem(hModules, &item) && item.lParam)
{
- safe_free((char*)item.lParam);
+ mir_free((char*)item.lParam);
TreeView_DeleteItem(hModules,item.hItem);
}
}
@@ -125,51 +126,51 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in
case DBVT_BLOB:
{
int j;
- if (!(data = (char*)realloc(data, 3*(dbv.cpbVal+1)+10) ))
+ if (!(data = (char*)mir_realloc(data, 3*(dbv.cpbVal+1)+10) ))
{msg(Translate("Couldnt allocate enough memory!"), modFullname); return;}
data[0] = '\0';
for (j=0; j<dbv.cpbVal; j++)
{
char tmp[16];
- _snprintf(tmp, 16, "%02X ", (BYTE)dbv.pbVal[j]);
+ mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv.pbVal[j]);
strcat(data, tmp);
}
lvi.iImage = 0;
ListView_SetItem(hwnd2Settings,&lvi);
ListView_SetItemText(hwnd2Settings,index,1,data);
ListView_SetItemText(hwnd2Settings,index,2,Translate("BLOB"));
- _snprintf(data, 3*(dbv.cpbVal+1)+10, "0x%04X (%d)", dbv.cpbVal,dbv.cpbVal);
+ 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*)realloc(data, 16))) // 0x00 (000)
+ if (!(data = (char*)mir_realloc(data, 16))) // 0x00 (000)
return;
lvi.iImage = 1;
ListView_SetItem(hwnd2Settings,&lvi);
- _snprintf(data, 16, "0x%02X (%d)", dbv.bVal, dbv.bVal);
+ mir_snprintf(data, 16, "0x%02X (%d)", dbv.bVal, dbv.bVal);
ListView_SetItemText(hwnd2Settings,index,1,data);
ListView_SetItemText(hwnd2Settings,index,2,Translate("BYTE"));
ListView_SetItemText(hwnd2Settings,index,3,"0x0001 (1)");
break;
case DBVT_WORD:
- if (!(data = (char*)realloc(data, 16))) // 0x0000 (00000)
+ if (!(data = (char*)mir_realloc(data, 16))) // 0x0000 (00000)
return;
lvi.iImage = 2;
ListView_SetItem(hwnd2Settings,&lvi);
- _snprintf(data, 16, "0x%04X (%ld)", dbv.wVal,dbv.wVal);
+ mir_snprintf(data, 16, "0x%04X (%ld)", dbv.wVal,dbv.wVal);
ListView_SetItemText(hwnd2Settings,index,1,data);
ListView_SetItemText(hwnd2Settings,index,2,Translate("WORD"));
ListView_SetItemText(hwnd2Settings,index,3,"0x0002 (2)");
break;
case DBVT_DWORD:
- if (!(data = (char*)realloc(data, 32))) // 0x00000000 (0000000000)
+ if (!(data = (char*)mir_realloc(data, 32))) // 0x00000000 (0000000000)
return;
lvi.iImage = 3;
ListView_SetItem(hwnd2Settings,&lvi);
- _snprintf(data, 32, "0x%08X (%ld)", dbv.dVal, dbv.dVal);
+ mir_snprintf(data, 32, "0x%08X (%ld)", dbv.dVal, dbv.dVal);
ListView_SetItemText(hwnd2Settings,index,1,data);
ListView_SetItemText(hwnd2Settings,index,2,Translate("DWORD"));
ListView_SetItemText(hwnd2Settings,index,3,"0x0004 (4)");
@@ -177,22 +178,22 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in
case DBVT_ASCIIZ:
{
int length = mir_strlen(dbv.pszVal)+1;
- if (!(data = (char*)realloc(data, 512)))
+ if (!(data = (char*)mir_realloc(data, 512)))
return;
lvi.iImage = 4;
ListView_SetItem(hwnd2Settings,&lvi);
ListView_SetItemText(hwnd2Settings,index,1,dbv.pszVal);
ListView_SetItemText(hwnd2Settings,index,2,Translate("STRING"));
- _snprintf(data, 512, "0x%04X (%d)", length,length);
+ mir_snprintf(data, 512, "0x%04X (%d)", length,length);
ListView_SetItemText(hwnd2Settings,index,3,data);
}
break;
case DBVT_UTF8:
{
- int length = strlen(dbv.pszVal)+1;
+ int length = (int)strlen(dbv.pszVal) + 1;
- if (!(data = (char*)realloc(data, 512)))
+ if (!(data = (char*)mir_realloc(data, 512)))
return;
lvi.iImage = 5;
@@ -200,7 +201,7 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in
if (UOS)
{
- WCHAR *wc = _alloca(length*sizeof(WCHAR));
+ WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR));
MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, length);
ListView_SetItemTextW(hwnd2Settings,index,1,wc);
}
@@ -211,7 +212,7 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in
}
ListView_SetItemText(hwnd2Settings,index,2,Translate("UNICODE"));
- _snprintf(data, 512, "0x%04X (%d)", length,length);
+ mir_snprintf(data, 512, "0x%04X (%d)", length,length);
ListView_SetItemText(hwnd2Settings,index,3,data);
}
break;
@@ -234,24 +235,24 @@ void additem(HWND hwnd2Settings,HANDLE hContact, char* module, char* setting, in
ListView_DeleteItem(hwnd2Settings,index);
DBFreeVariant(&dbv);
- safe_free(data);
+ mir_free(data);
}
void PopulateSettings(HWND hwnd2Settings, HANDLE hContact, char* module)
{
- SettingListInfo* info = (SettingListInfo*)calloc(sizeof(SettingListInfo),1);
+ SettingListInfo* info = (SettingListInfo*)mir_calloc(sizeof(SettingListInfo));
LVITEM lvItem;
struct ModSetLinkLinkItem *setting;
ModuleSettingLL setlist;
- if (!EnumSettings(hContact,module,&setlist)) { msg(Translate("Error Loading Setting List"),modFullname); safe_free(info); return;}
+ if (!EnumSettings(hContact,module,&setlist)) { msg(Translate("Error Loading Setting List"),modFullname); mir_free(info); return;}
// clear any settings that may be there...
ClearListview(hwnd2Settings);
info->hContact = hContact;
- info->module = strdup(module);
- SetWindowLong(hwnd2Settings,GWL_USERDATA, (LONG)info);
+ info->module = mir_tstrdup(module);
+ SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)info);
// icons
if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL);
@@ -333,7 +334,10 @@ void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *w
if (type != DBVT_ASCIIZ && type != DBVT_UTF8)
DBDeleteContactSetting(info->hContact,info->module,info->setting);
if (type == DBVT_UTF8 && wc)
+ {
DBWriteContactSettingWString(info->hContact,info->module,info->setting,wc);
+ mir_free(wc);
+ }
else
DBWriteContactSettingString(info->hContact,info->module,info->setting,value);
@@ -341,7 +345,7 @@ void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *w
static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
- EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLong(hwnd,GWL_USERDATA);
+ EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLongPtr(hwnd,GWLP_USERDATA);
switch(msg) {
case WM_KEYDOWN:
switch (wParam)
@@ -357,7 +361,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w
}
break;
case WM_USER:
- SetWindowLong(hwnd,GWL_USERDATA,lParam);
+ SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam);
SetFocus(hwnd);
SendMessage(hwnd, WM_SETFONT, SendMessage(GetParent(hwnd), WM_GETFONT, 0, 0), 1);
info = ((EditLabelInfoStruct*)lParam);
@@ -375,17 +379,14 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w
case IDOK:
{
int len = GetWindowTextLength(hwnd)+1;
- char *value = _alloca(len);
+ char *value = (char*)_alloca(len);
WCHAR *wc = NULL;
DBVARIANT dbv = {0};
GetWindowText(hwnd,value,len);
if (info->unicode)
- {
- wc = _alloca(len*sizeof(WCHAR));
- _SendMessageW(hwnd, WM_GETTEXT, len, (LPARAM)wc);
- }
+ wc = mir_a2u(value);
if (len <= 1 || GetSetting(info->hContact,info->module,info->setting,&dbv))
{
@@ -593,12 +594,12 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w
} // fall through
case IDCANCEL:
{
- SettingListInfo *sli = (SettingListInfo*)GetWindowLong(info->hwnd,GWL_USERDATA);
+ SettingListInfo *sli = (SettingListInfo*)GetWindowLongPtr(info->hwnd,GWLP_USERDATA);
if (sli && sli->hwnd2Edit==hwnd)
sli->hwnd2Edit = NULL;
- safe_free(info);
+ mir_free(info);
DestroyWindow(hwnd);
}
return 0;
@@ -608,7 +609,7 @@ static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM w
return DLGC_WANTALLKEYS;
}
if (UOS)
- return _CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam);
+ return CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam);
else
return CallWindowProc(SettingLabelEditSubClass,hwnd,msg,wParam,lParam);
}
@@ -620,8 +621,8 @@ void EditLabel(HWND hwnd2List, int item, int subitem)
LVITEM lvi;
char setting[256], value[16] = {0};
DBVARIANT dbv;
- SettingListInfo* info = (SettingListInfo*)GetWindowLong(hwnd2List,GWL_USERDATA);
- EditLabelInfoStruct *data = (EditLabelInfoStruct*)calloc(sizeof(EditLabelInfoStruct),1);
+ SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hwnd2List,GWLP_USERDATA);
+ EditLabelInfoStruct *data = (EditLabelInfoStruct*)mir_calloc(sizeof(EditLabelInfoStruct));
if (!data || !info) return;
if (info->hwnd2Edit)
{
@@ -639,7 +640,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem)
(hwnd2List,item,subitem,LVIR_LABEL,&rc) ||
GetSetting(info->hContact,info->module,setting,&dbv))
{
- safe_free(data);
+ mir_free(data);
return;
}
@@ -658,10 +659,10 @@ void EditLabel(HWND hwnd2List, int item, int subitem)
if (subitem && UOS)
{
int len = mir_strlen(dbv.pszVal)+1;
- WCHAR *wc = _alloca(len*sizeof(WCHAR));
+ WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR));
MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len);
data->unicode = 1;
- info->hwnd2Edit = _CreateWindowW(L"EDIT",wc,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0);
+ info->hwnd2Edit = CreateWindowW(L"EDIT",wc,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0);
break;
}
// fall through
@@ -675,21 +676,21 @@ void EditLabel(HWND hwnd2List, int item, int subitem)
break;
case DBVT_BYTE:
if (Hex&HEX_BYTE)
- _snprintf(value,15,"0x%02X",dbv.bVal);
+ mir_snprintf(value, SIZEOF(value), "0x%02X", dbv.bVal);
else
itoa(dbv.bVal,value,10);
info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0);
break;
case DBVT_WORD:
if (Hex&HEX_WORD)
- _snprintf(value,15,"0x%04X",dbv.wVal);
+ mir_snprintf(value, SIZEOF(value), "0x%04X", dbv.wVal);
else
itoa(dbv.wVal,value,10);
info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0);
break;
case DBVT_DWORD:
if (Hex&HEX_DWORD)
- _snprintf(value,15,"0x%08X",dbv.dVal);
+ mir_snprintf(value, SIZEOF(value), "0x%08X", dbv.dVal);
else
itoa(dbv.dVal,value,10);
info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0);
@@ -708,7 +709,7 @@ void EditLabel(HWND hwnd2List, int item, int subitem)
for(j=0; j<dbv.cpbVal; j++)
{
- _snprintf(tmp, sizeof(tmp), "%02X ", (BYTE)dbv.pbVal[j]);
+ mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv.pbVal[j]);
strcat(data, tmp);
}
@@ -721,9 +722,9 @@ void EditLabel(HWND hwnd2List, int item, int subitem)
DBFreeVariant(&dbv);
if (UOS)
- SettingLabelEditSubClass=(WNDPROC)_SetWindowLongW(info->hwnd2Edit,GWL_WNDPROC,(LONG)SettingLabelEditSubClassProc);
+ SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtrW(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc);
else
- SettingLabelEditSubClass=(WNDPROC)SetWindowLong(info->hwnd2Edit,GWL_WNDPROC,(LONG)SettingLabelEditSubClassProc);
+ SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtr(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc);
SendMessage(info->hwnd2Edit,WM_USER,0,(LPARAM)data);
}
@@ -736,7 +737,7 @@ void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
case NM_CLICK:
{
- SettingListInfo* info = (SettingListInfo*)GetWindowLong(GetDlgItem(hwnd,IDC_SETTINGS),GWL_USERDATA);
+ SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA);
LVHITTESTINFO hti;
hti.pt=((NMLISTVIEW*)lParam)->ptAction;
@@ -776,7 +777,7 @@ void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
break;
case NM_DBLCLK:
{
- SettingListInfo* info = (SettingListInfo*)GetWindowLong(GetDlgItem(hwnd,IDC_SETTINGS),GWL_USERDATA);
+ SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA);
LVHITTESTINFO hti;
@@ -805,7 +806,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
{
HWND hSettings = GetDlgItem(hwnd,IDC_SETTINGS);
- SettingListInfo* info = (SettingListInfo*)GetWindowLong(hSettings,GWL_USERDATA);
+ SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hSettings,GWLP_USERDATA);
char setting[256], *module;
HANDLE hContact;
LVHITTESTINFO hti;
@@ -832,77 +833,77 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
{
case MENU_ADD_BYTE:
{
- struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ dbsetting->module = mir_tstrdup(module);
+ dbsetting->setting = mir_tstrdup("");
if (UOS)
- _CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
+ CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
else
CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
}
break;
case MENU_ADD_BLOB:
{
- struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ dbsetting->module = mir_tstrdup(module);
+ dbsetting->setting = mir_tstrdup("");
CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
}
break;
@@ -1016,77 +1017,77 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
//////////////////////// NEW item submenu
case MENU_ADD_BYTE:
{
- struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ 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 *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ dbsetting->module = mir_tstrdup(module);
+ dbsetting->setting = mir_tstrdup("");
if (UOS)
- _CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
+ CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
else
CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
}
break;
case MENU_ADD_BLOB:
{
- struct DBsetting *dbsetting = (struct DBsetting *)malloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc
+ 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 = strdup(module);
- dbsetting->setting = strdup("");
+ dbsetting->module = mir_tstrdup(module);
+ dbsetting->setting = mir_tstrdup("");
CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting);
}
break;
@@ -1130,13 +1131,37 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
case MENU_VIEWDECRYPT:
{
DBVARIANT dbv;
- char *text;
if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ)
{
- text = strdup(dbv.pszVal);
- CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
- msg(text, "Decoded string..");
- safe_free(text);
+ 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;
+ }
+ 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);
+ }
+ mir_free(str);
+ }
}
DBFreeVariant(&dbv);
}
@@ -1147,10 +1172,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
char *text;
if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ)
{
- text = strdup(dbv.pszVal);
+ text = mir_tstrdup(dbv.pszVal);
CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
- msg(text, "Encoded string..");
- safe_free(text);
+ msg(text, Translate("Encoded string.."));
+ mir_free(text);
}
DBFreeVariant(&dbv);
}
@@ -1161,10 +1186,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
char *text;
if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ)
{
- text = strdup(dbv.pszVal);
+ text = mir_tstrdup(dbv.pszVal);
CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
DBWriteContactSettingString(hContact,module,setting,text);
- safe_free(text);
+ mir_free(text);
}
DBFreeVariant(&dbv);
}
@@ -1175,10 +1200,10 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
char *text;
if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ)
{
- text = strdup(dbv.pszVal);
+ text = mir_tstrdup(dbv.pszVal);
CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
DBWriteContactSettingString(hContact,module,setting,text);
- safe_free(text);
+ mir_free(text);
}
DBFreeVariant(&dbv);
}