diff options
Diffstat (limited to 'dbeditorpp/moduletree.cpp')
-rw-r--r-- | dbeditorpp/moduletree.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/dbeditorpp/moduletree.cpp b/dbeditorpp/moduletree.cpp index 699b3ac..a3828b8 100644 --- a/dbeditorpp/moduletree.cpp +++ b/dbeditorpp/moduletree.cpp @@ -32,7 +32,7 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H while (hContact && hwnd2mainWindow) // break after null contact
{
- if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto)))
+ if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto)))
{
icon = GetProtoIcon(szProto);
loaded = (icon != DEF_ICON);
@@ -57,7 +57,7 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H // SetWindowText(hwnd2mainWindow, percent);
// add the contact
- lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1);
+ lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
lParam->hContact = hContact;
lParam->type = CONTACT;
tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
@@ -86,9 +86,9 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H if (protoW)
{
if (Order)
- mir_snwprintf(nick, SIZEOF(nick),L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)");
+ 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)");
+ mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)");
}
else
wcscpy(nick, nick_unknownW);
@@ -116,9 +116,9 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H if (szProto[0])
{
if (Order)
- mir_snprintf(nick, sizeof(nick),"(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)");
+ 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)");
+ mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)");
}
else
strcpy(nick, nick_unknown);
@@ -127,9 +127,9 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H {
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));
+ 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);
+ mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto);
}
tvi.item.pszText = nick;
@@ -151,7 +151,7 @@ int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, H tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tvi.item.pszText = module->name;
- lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1);
+ lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
lParam->hContact = hContact;
if (!module->known)
@@ -211,7 +211,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) HWND hwnd = GetParent(hwnd2Tree);
int i = 0;
- mir_snprintf(title, sizeof(title),Translate("Loading modules..."));
+ mir_snprintf(title, SIZEOF(title), Translate("Loading modules..."));
item.mask = TVIF_STATE|TVIF_PARAM;
@@ -238,7 +238,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) else continue;
// Caption
- mir_snprintf(percent,sizeof(percent),"%s %d%%",title,(int)(100*i/count));
+ mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100*i/count));
SetWindowText(hwnd, percent);
module = modlist->first;
@@ -251,7 +251,7 @@ void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tvi.item.pszText = module->name;
- lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1);
+ lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
lParam->hContact = hContact;
if (!module->known)
@@ -351,7 +351,7 @@ http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?t {
if (hContact != NULL) {
TreeView_DeleteItem(hwnd2Tree,item.hItem);
- safe_free(mtis);
+ mir_free(mtis);
} else
mtis->type = STUB;
}
@@ -395,7 +395,7 @@ http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?t ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam;
if (hContact == mtis->hContact && !mir_strcmp(text,module))
{
- safe_free(mtis);
+ mir_free(mtis);
TreeView_DeleteItem(hwnd2Tree,item.hItem);
lastItem = prelastItem;
Result = 1;
@@ -430,7 +430,7 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char item.hItem = (HTREEITEM)hItem;
if (TreeView_GetItem(hwnd, &item))
- safe_free((ModuleTreeInfoStruct *)item.lParam);
+ mir_free((ModuleTreeInfoStruct *)item.lParam);
TreeView_DeleteItem(hwnd,item.hItem);
}
@@ -444,7 +444,7 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tvi.item.pszText = (char*)newModule;
- lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1);
+ lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
lParam->hContact = hContact;
lParam->type = IsModuleKnown((char*)newModule)?KNOWN_MODULE:UNKNOWN_MODULE;
if (lParam->type == UNKNOWN_MODULE)
@@ -468,7 +468,7 @@ void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char void refreshTree(int restore)
{
- UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",1);
+ UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0);
if (populating) return;
populating = 1;
forkthread(PopulateModuleTreeThreadFunc,0,(HWND)restore);
@@ -524,12 +524,12 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) break;
}
case 2: // restore saved
- if (GetValue(NULL,modname,"LastModule",SelectedModule,sizeof(SelectedModule)))
+ if (GetValue(NULL,modname,"LastModule",SelectedModule,SIZEOF(SelectedModule)))
{
hSelectedContact = (HANDLE)DBGetContactSettingDword(NULL,modname,"LastContact",(DWORD)INVALID_HANDLE_VALUE);
if (hSelectedContact != INVALID_HANDLE_VALUE)
Select = 1;
- GetValue(NULL,modname,"LastSetting",SelectedSetting,sizeof(SelectedSetting));
+ GetValue(NULL,modname,"LastSetting",SelectedSetting,SIZEOF(SelectedSetting));
}
break;
case 3: // restore from user menu
@@ -600,7 +600,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tvi.item.pszText = module->name;
- lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1);
+ lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
lParam->hContact = hContact;
if (!module->known)
{
@@ -714,7 +714,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tvi.item.pszText = module->name;
- _lParam = (ModuleTreeInfoStruct *)calloc(sizeof(ModuleTreeInfoStruct),1);
+ _lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
_lParam->hContact = hContact;
if (IsModuleKnown(module->name))
@@ -768,7 +768,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE)
{
- SettingListInfo *info = (SettingListInfo*)GetWindowLong(hwnd2Settings,GWL_USERDATA);
+ SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA);
BOOL refresh = 1;
if (info)
@@ -792,7 +792,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd lvi.iImage = 6;
ClearListview(hwnd2Settings);
- SetWindowLong(hwnd2Settings,GWL_USERDATA, (LONG)NULL);
+ SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)NULL);
if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL);
if (mtis->type == CONTACT_ROOT_ITEM && !hContact)
@@ -806,7 +806,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (multi)
{
// filter
- if (GetValue(hContact,"Protocol","p",szProto,sizeof(szProto)))
+ if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto)))
loaded = IsProtocolLoaded(szProto);
else
loaded = 0;
@@ -826,7 +826,7 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd else
index = ListView_InsertItem(hwnd2Settings,&lvi);
- _snprintf(data, sizeof(data), "0x%08X (%ld)", hContact, hContact);
+ mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact);
ListView_SetItemText(hwnd2Settings,index,1,data);
ListView_SetItemText(hwnd2Settings,index,2,Translate("HANDLE"));
@@ -860,11 +860,11 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES));
if (!mtis->type || (mtis->type == CONTACT))
{
- SetWindowLong(hwnd, DWL_MSGRESULT, TRUE);
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
break;
}
- ModuleTreeLabelEditSubClass=(WNDPROC)SetWindowLong(hwnd2Edit,GWL_WNDPROC,(LONG)ModuleTreeLabelEditSubClassProc);
- SetWindowLong(hwnd, DWL_MSGRESULT, FALSE);
+ ModuleTreeLabelEditSubClass = (WNDPROC)SetWindowLongPtr(hwnd2Edit, GWLP_WNDPROC, (LONG)ModuleTreeLabelEditSubClassProc);
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
}
break;
case TVN_ENDLABELEDITA:
@@ -885,13 +885,13 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd if (UOS)
newtext = u2a((WCHAR*)ptvdi->item.pszText);
else
- newtext = _strdup(ptvdi->item.pszText);
+ newtext = mir_tstrdup(ptvdi->item.pszText);
if (!newtext || // edit control failed
!mtis->type || // its a root item
mtis->type == CONTACT || // its a contact
*newtext == 0) // empty string
- SetWindowLong(hwnd, DWL_MSGRESULT, FALSE);
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
else
{
if (mir_strcmp(tvi.pszText, newtext))
@@ -918,10 +918,10 @@ void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext);
}
}
- SetWindowLong(hwnd, DWL_MSGRESULT, TRUE);
+ SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE);
}
- safe_free(newtext);
+ mir_free(newtext);
}
break;
}
@@ -995,7 +995,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i if (deleteModule(module, hContact, 0))
{
TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,hti.hItem);
- safe_free(mtis);
+ mir_free(mtis);
}
break;
case MENU_COPY_MOD:
@@ -1029,9 +1029,9 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i }
if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ)
{
- int len = strlen(dbv.pszVal)+10+strlen(moduletemp);
+ int len = (int)strlen(dbv.pszVal) + 10 + (int)strlen(moduletemp);
char* temp = (char*)_alloca(len);
- _snprintf(temp,len,"%s, %s",dbv.pszVal,moduletemp);
+ mir_snprintf(temp, len, "%s, %s", dbv.pszVal, moduletemp);
DBWriteContactSettingString(NULL,modname,"CoreModules",temp);
DBFreeVariant(&dbv);
}
@@ -1055,7 +1055,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i if (DBGetContactSettingByte(NULL,"CList", "ConfirmDelete",1))
{
char msg[1024];
- mir_snprintf(msg, 1024, Translate("Are you sure you want to delete contact \"%s\"?"), module);
+ mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module);
if (MessageBox(0,msg, Translate("Confirm Contact Delete"), MB_YESNO|MB_ICONEXCLAMATION) == IDYES)
{
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact,0);
@@ -1078,14 +1078,14 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i ImportSettingsMenuItem(hContact);
break;
case MENU_IMPORTFROMFILE:
- ImportSettingsFromFileMenuItem(hContact);
+ ImportSettingsFromFileMenuItem(hContact, "");
break;
////////////////////////////////////////////////////////////////////// divider
case MENU_ADD_MODULE:
{
- HWND AddModhwnd = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_ADD_MODULE),hwnd,AddModDlgProc, (LPARAM)hContact);
+ HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact);
char msg[1024];
- mir_snprintf(msg, 1024, Translate("Add module to contact \"%s\""),module);
+ mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module);
SetWindowText(AddModhwnd, module);
}
break;
@@ -1096,9 +1096,9 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i {
case MENU_ADD_MODULE:
{
- HWND AddModhwnd = CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_ADD_MODULE),hwnd,AddModDlgProc, (LPARAM)hContact);
+ HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact);
char msg[1024];
- mir_snprintf(msg, 1024, Translate("Add module to contact \"%s\""),module);
+ mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module);
SetWindowText(AddModhwnd, module);
}
break;
@@ -1109,7 +1109,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i ImportSettingsMenuItem(NULL);
break;
case MENU_IMPORTFROMFILE:
- ImportSettingsFromFileMenuItem(NULL);
+ ImportSettingsFromFileMenuItem(NULL, "");
break;
}
break;
@@ -1120,10 +1120,10 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here i exportDB(INVALID_HANDLE_VALUE, "");
break;
case MENU_IMPORTFROMTEXT:
- ImportSettingsMenuItem(INVALID_HANDLE_VALUE);
+ ImportSettingsMenuItem(NULL);
break;
case MENU_IMPORTFROMFILE:
- ImportSettingsFromFileMenuItem(INVALID_HANDLE_VALUE);
+ ImportSettingsFromFileMenuItem(NULL, "");
break;
}
break;
|