From 2ebb53adcd4663ac2f1da74972b7b21d53b0ce53 Mon Sep 17 00:00:00 2001 From: "george.hazan" Date: Thu, 26 May 2011 20:18:42 +0000 Subject: patch for dbeditorpp: C++ support, other improvements git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@122 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- dbeditorpp/watchedvars.cpp | 57 ++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'dbeditorpp/watchedvars.cpp') diff --git a/dbeditorpp/watchedvars.cpp b/dbeditorpp/watchedvars.cpp index f0959c4..08813de 100644 --- a/dbeditorpp/watchedvars.cpp +++ b/dbeditorpp/watchedvars.cpp @@ -1,18 +1,17 @@ #include "headers.h" - int addSettingToWatchList(HANDLE hContact, char* module, char* setting) { if (WatchListArray.count == WatchListArray.size) { WatchListArray.size += 32; - WatchListArray.item = (struct DBsetting*)realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); + WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); } if (!WatchListArray.item) return 0; if (setting && DBGetContactSetting(hContact,module, setting, &(WatchListArray.item[WatchListArray.count].dbv))) return 0; WatchListArray.item[WatchListArray.count].hContact = hContact; - WatchListArray.item[WatchListArray.count].module = strdup(module); - if (setting) WatchListArray.item[WatchListArray.count].setting = strdup(setting); + WatchListArray.item[WatchListArray.count].module = mir_tstrdup(module); + if (setting) WatchListArray.item[WatchListArray.count].setting = mir_tstrdup(setting); else WatchListArray.item[WatchListArray.count].setting = 0; WatchListArray.item[WatchListArray.count].WatchModule = setting?WATCH_SETTING:WATCH_MODULE; @@ -22,9 +21,9 @@ int addSettingToWatchList(HANDLE hContact, char* module, char* setting) void freeWatchListItem(int item) { - if (WatchListArray.item[item].module) safe_free(WatchListArray.item[item].module); + if (WatchListArray.item[item].module) mir_free(WatchListArray.item[item].module); WatchListArray.item[item].module = 0; - if (WatchListArray.item[item].setting) safe_free(WatchListArray.item[item].setting); + if (WatchListArray.item[item].setting) mir_free(WatchListArray.item[item].setting); WatchListArray.item[item].setting = 0; DBFreeVariant(&(WatchListArray.item[item].dbv)); WatchListArray.item[item].hContact = 0; @@ -53,7 +52,7 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) struct ModSetLinkLinkItem *setting; if (!EnumSettings(hContact,module,&settinglist)) return; dummy.hContact = hContact; - dummy.module = strdup(module); + dummy.module = mir_tstrdup(module); setting = settinglist.first; while (setting) { @@ -61,7 +60,7 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) addwatchtolist(hwnd2list, &dummy); setting = (struct ModSetLinkLinkItem *)setting->next; } - safe_free(dummy.module); + mir_free(dummy.module); FreeModuleSettingLL(&settinglist); return; } @@ -76,7 +75,11 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) index = ListView_InsertItem(hwnd2list,&lvItem); if (UOS) - ListView_SetItemTextW(hwnd2list,index,0,(WCHAR*)lvItem.pszText); + { + 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); @@ -87,32 +90,32 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) { int j; char *data = NULL; - if (!(data = (char*)realloc(data, 3*(dbv->cpbVal+1)) )) + if (!(data = (char*)mir_realloc(data, 3*(dbv->cpbVal+1)) )) return; data[0] = '\0'; for (j=0; jcpbVal; 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); } ListView_SetItemText(hwnd2list,index,4,data); ListView_SetItemText(hwnd2list,index,3,"BLOB"); - safe_free(data); + mir_free(data); } break; case DBVT_BYTE: - _snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); + 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: - _snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); + 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_DWORD: - _snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); + 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; @@ -124,8 +127,8 @@ void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) { if (UOS) { - int length = strlen(dbv->pszVal)+1; - WCHAR *wc = _alloca(length*sizeof(WCHAR)); + 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); } @@ -157,7 +160,7 @@ void freeAllWatches() { freeWatchListItem(i); } - safe_free(WatchListArray.item); + mir_free(WatchListArray.item); WatchListArray.item = 0; WatchListArray.count = 0; } @@ -174,9 +177,9 @@ int WatchDialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; } return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; - } -BOOL CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) + +INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { @@ -336,8 +339,8 @@ void popupWatchedVar(HANDLE hContact,const char* module,const char* setting) { // contacts nick char szProto[256]; - if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto))) - mir_snprintf(lpzContactName, MAX_SECONDLINE,"%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + mir_snprintf(lpzContactName, MAX_SECONDLINE, "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); else mir_snprintf(lpzContactName, MAX_SECONDLINE, nick_unknown); } @@ -351,19 +354,19 @@ void popupWatchedVar(HANDLE hContact,const char* module,const char* setting) switch (dbv.type) { case DBVT_BYTE: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal); break; case DBVT_WORD: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal); break; case DBVT_DWORD: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal); break; case DBVT_ASCIIZ: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal); break; case DBVT_UTF8: - mir_snprintf(lpzText, sizeof(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal); + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal); break; default: return; -- cgit v1.2.3