From ab3c6601b7e4600419a2830f79e807324af17459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Fri, 21 Dec 2007 10:09:46 +0000 Subject: [PATCH] Use TRACE/WARN/ERR/FIXME macros for debugging, so they can be enabled at runtime svn path=/trunk/; revision=31367 --- reactos/dll/cpl/ncpa/ncpa.c | 85 +++++++++++++------------ reactos/dll/cpl/ncpa/ncpa.h | 2 - reactos/dll/cpl/ncpa/ncpa.rbuild | 3 +- reactos/dll/cpl/ncpa/tcpip_properties.c | 19 ++---- 4 files changed, 52 insertions(+), 57 deletions(-) diff --git a/reactos/dll/cpl/ncpa/ncpa.c b/reactos/dll/cpl/ncpa/ncpa.c index 637e0b1d213..271d8385431 100644 --- a/reactos/dll/cpl/ncpa/ncpa.c +++ b/reactos/dll/cpl/ncpa/ncpa.c @@ -40,7 +40,7 @@ * the new network support in Reactos. * * If you intend to extend this code by more, please contact me to avoid duplicate work. - * There are already resources and code for TCP/IP configuration that are not + * There are already resources and code for TCP/IP configuration that are not * mature enough for committing them to CVS yet. */ @@ -53,7 +53,13 @@ #include #include -#include +#include +WINE_DEFAULT_DEBUG_CHANNEL(ncpa); +#ifndef _UNICODE +#define debugstr_aw debugstr_a +#else +#define debugstr_aw debugstr_w +#endif #include "resource.h" #include "ncpa.h" @@ -96,7 +102,7 @@ EnumRegKeys(ENUMREGKEYCALLBACK *pCallback,PVOID pCookie,HKEY hBaseKey,TCHAR *tps if(RegOpenKeyEx(hBaseKey,tpszRegPath,0,KEY_ENUMERATE_SUB_KEYS,&hKey)!=ERROR_SUCCESS) { - DPRINT("EnumRegKeys failed (key not found): %S\n", tpszRegPath); + WARN("EnumRegKeys failed (key not found): %S\n", tpszRegPath); return; } @@ -106,12 +112,12 @@ EnumRegKeys(ENUMREGKEYCALLBACK *pCallback,PVOID pCookie,HKEY hBaseKey,TCHAR *tps ret = RegEnumKeyEx(hKey,i,tpszName,&dwNameLen,NULL,NULL,NULL,NULL); if(ret != ERROR_SUCCESS) { - DPRINT("EnumRegKeys: RegEnumKeyEx failed for %S (rc 0x%lx)\n", tpszName, ret); + WARN("EnumRegKeys: RegEnumKeyEx failed for %S (rc 0x%lx)\n", tpszName, ret); break; } _stprintf(pszNewPath,_T("%s\\%s"),tpszRegPath,tpszName); - DPRINT("EnumRegKeys: Calling user supplied enum function\n"); + TRACE("EnumRegKeys: Calling user supplied enum function\n"); pCallback(pCookie,hBaseKey,pszNewPath); dwNameLen = sizeof(tpszName); @@ -262,6 +268,7 @@ NICPropertyPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) if(!FindNICClassKeyForCfgInstance(pGlobalData->CurrentAdapterName, tpszSubKey)) { + WARN("NIC Entry not found for '%s'\n", debugstr_w(pGlobalData->CurrentAdapterName)); MessageBox(hwndDlg,_T("NIC Entry not found"),_T("Registry error"),MB_ICONSTOP); MessageBox(hwndDlg,pGlobalData->CurrentAdapterName,tpszSubKey,MB_ICONSTOP); } @@ -309,7 +316,6 @@ NICPropertyPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) RegCloseKey(hNDIKey); SetDlgItemText(hwndDlg,IDC_DESCRIPTION,tpszHelpText); - } if(HIWORD(wParam)!=LBN_DBLCLK) break; @@ -322,8 +328,9 @@ NICPropertyPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) } else { + FIXME("If you see this, then the IPHLPAPI.DLL probably needs more work because GetAdaptersInfo did not return the expected data.\n"); MessageBox(NULL,_T("If you see this, then the IPHLPAPI.DLL probably needs more work because GetAdaptersInfo did not return the expected data."),_T("Error"),MB_ICONSTOP); - } + } } break; } @@ -360,8 +367,7 @@ DisplayNICProperties(HWND hParent, GLOBAL_NCPA_DATA* pGlobalData) else _tcscat(tpszName,_T(" Properties")); RegCloseKey(hKey); - - + ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; @@ -373,7 +379,6 @@ DisplayNICProperties(HWND hParent, GLOBAL_NCPA_DATA* pGlobalData) psh.nStartPage = 0; psh.ppsp = psp; psh.pfnCallback = NULL; - InitPropSheetPage(&psp[0], IDD_NETPROPERTIES, NICPropertyPageProc, (LPARAM)pGlobalData); PropertySheet(&psh); @@ -388,17 +393,18 @@ void RefreshNICInfo(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) if (pGlobalData->pFirstAdapterInfo) HeapFree(GetProcessHeap(), 0, pGlobalData->pFirstAdapterInfo); - BufferSize = sizeof(IP_ADAPTER_INFO); + BufferSize = sizeof(IP_ADAPTER_INFO); pGlobalData->pFirstAdapterInfo = (PIP_ADAPTER_INFO) HeapAlloc(GetProcessHeap(), 0, BufferSize); - - if (GetAdaptersInfo(pGlobalData->pFirstAdapterInfo, &BufferSize) == ERROR_BUFFER_OVERFLOW) + + if (GetAdaptersInfo(pGlobalData->pFirstAdapterInfo, &BufferSize) == ERROR_BUFFER_OVERFLOW) { - HeapFree(GetProcessHeap(), 0, pGlobalData->pFirstAdapterInfo); - pGlobalData->pFirstAdapterInfo = (PIP_ADAPTER_INFO) HeapAlloc(GetProcessHeap(), 0, BufferSize); + HeapFree(GetProcessHeap(), 0, pGlobalData->pFirstAdapterInfo); + pGlobalData->pFirstAdapterInfo = (PIP_ADAPTER_INFO) HeapAlloc(GetProcessHeap(), 0, BufferSize); } if ((ErrRet = GetAdaptersInfo(pGlobalData->pFirstAdapterInfo, &BufferSize)) != NO_ERROR) { + ERR("error adapterinfo\n"); MessageBox(hwndDlg, _T("error adapterinfo") ,_T("ncpa.cpl"),MB_ICONSTOP); if (pGlobalData->pFirstAdapterInfo) @@ -449,9 +455,9 @@ void UpdateCurrentAdapterInfo(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) } } else if (ERROR_NO_DATA == dwRetVal) - DPRINT("There are no network adapters with IPv4 enabled on the local system\n"); + WARN("There are no network adapters with IPv4 enabled on the local system\n"); else - DPRINT1("GetInterfaceInfo failed.\n"); + ERR("GetInterfaceInfo failed.\n"); } static VOID @@ -471,7 +477,7 @@ UpdateNICStatusData(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) if (firstError) { firstError = FALSE; - DPRINT1("Out of memory - could not allocate MIB_IFTABLE(1)"); + WARN("Out of memory - could not allocate MIB_IFTABLE(1)"); return; } } @@ -490,7 +496,7 @@ UpdateNICStatusData(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) if (firstError) { firstError = FALSE; - DPRINT1("Out of memory - could not allocate MIB_IFTABLE(2)"); + WARN("Out of memory - could not allocate MIB_IFTABLE(2)"); } pGlobalData->IfTableSize = 0; @@ -518,7 +524,7 @@ UpdateNICStatusData(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) PMIB_IFROW pIfRow = NULL; TCHAR Buffer[256], LocBuffer[256]; SYSTEMTIME TimeConnected; - + memset(&TimeConnected, 0, sizeof(TimeConnected)); if (pGlobalData->pCurrentAdapterInfo) @@ -593,7 +599,7 @@ UpdateNICStatusData(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) break; default: - DPRINT1("Unknown operation status: %d\n", OperStatus); + WARN("Unknown operation status: %d\n", OperStatus); OperStatus = IDS_STATUS_OPERATIONAL; break; } @@ -630,7 +636,7 @@ UpdateNICStatusData(HWND hwndDlg, PGLOBAL_NCPA_DATA pGlobalData) if (firstError) { firstError = FALSE; - DPRINT1("GetIfTable failed with error code: %d\n", dwRet); + ERR("GetIfTable failed with error code: %d\n", dwRet); return; } } @@ -698,7 +704,7 @@ NICSupportPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) switch(uMsg) { case WM_INITDIALOG: - { + { pGlobalData = (PGLOBAL_NCPA_DATA)((LPPROPSHEETPAGE)lParam)->lParam; if (pGlobalData == NULL) return FALSE; @@ -706,14 +712,14 @@ NICSupportPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData); if (pGlobalData->pCurrentAdapterInfo) - { + { TCHAR Buffer[64]; if (pGlobalData->pCurrentAdapterInfo->DhcpEnabled) LoadString(hApplet, IDS_ASSIGNED_DHCP, Buffer, sizeof(Buffer) / sizeof(TCHAR)); else LoadString(hApplet, IDS_ASSIGNED_MANUAL, Buffer, sizeof(Buffer) / sizeof(TCHAR)); - + SendDlgItemMessage(hwndDlg, IDC_DETAILSTYPE, WM_SETTEXT, 0, (LPARAM)Buffer); _stprintf(Buffer, _T("%S"), pGlobalData->pCurrentAdapterInfo->IpAddressList.IpAddress.String); SendDlgItemMessage(hwndDlg, IDC_DETAILSIP, WM_SETTEXT, 0, (LPARAM)Buffer); @@ -721,7 +727,7 @@ NICSupportPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hwndDlg, IDC_DETAILSSUBNET, WM_SETTEXT, 0, (LPARAM)Buffer); _stprintf(Buffer, _T("%S"), pGlobalData->pCurrentAdapterInfo->GatewayList.IpAddress.String); SendDlgItemMessage(hwndDlg, IDC_DETAILSGATEWAY, WM_SETTEXT, 0, (LPARAM)Buffer); - } + } } break; case WM_COMMAND: @@ -733,10 +739,10 @@ NICSupportPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case IDC_DETAILS: { + FIXME("Not implemented: show detail window\n"); MessageBox(hwndDlg,_T("not implemented: show detail window"),_T("ncpa.cpl"),MB_ICONSTOP); } break; - } break; } @@ -808,7 +814,7 @@ DisplayNICStatus(HWND hParent,TCHAR *tpszCfgInstanceID) InitPropSheetPage(&psp[0], IDD_CARDPROPERTIES, NICStatusPageProc, (LPARAM)pGlobalData); InitPropSheetPage(&psp[1], IDD_CARDSUPPORT, NICSupportPageProc, (LPARAM)pGlobalData); - + PropertySheet(&psh); return; } @@ -828,6 +834,7 @@ EnumAdapters(HWND hwndDlg) size=sizeof(Info); if(GetAdaptersInfo(Info,&size)!=ERROR_SUCCESS) { + WARN("IPHLPAPI.DLL failed to provide Adapter information\n"); MessageBox(hwndDlg,L"IPHLPAPI.DLL failed to provide Adapter information",L"Error",MB_ICONSTOP); return; } @@ -859,33 +866,33 @@ NetAdapterCallback(void *pCookie,HKEY hBaseKey,TCHAR *tpszSubKey) HWND hwndDlg = (HWND)pCookie; DWORD dwCharacteristics; - DPRINT("NetAdapterCallback: %S\n", tpszSubKey); + TRACE("NetAdapterCallback: %s\n", debugstr_aw(tpszSubKey)); if(RegOpenKeyEx(hBaseKey,tpszSubKey,0,KEY_QUERY_VALUE,&hKey)!=ERROR_SUCCESS) return; - DPRINT("NetAdapterCallback: Reading Characteristics\n"); + TRACE("NetAdapterCallback: Reading Characteristics\n"); dwType = REG_DWORD; dwSize = sizeof(dwCharacteristics); if(RegQueryValueEx(hKey,_T("Characteristics"),NULL,&dwType,(BYTE*)&dwCharacteristics,&dwSize)!=ERROR_SUCCESS) dwCharacteristics = 0; - if (dwCharacteristics & NCF_HIDDEN) return; - if (!(dwCharacteristics & NCF_VIRTUAL) && !(dwCharacteristics & NCF_PHYSICAL)) return; - - DPRINT("NetAdapterCallback: Reading DriverDesc\n"); + + TRACE("NetAdapterCallback: Reading DriverDesc\n"); dwType = REG_SZ; dwSize = sizeof(tpszDisplayName); if (RegQueryValueEx(hKey,_T("DriverDesc"),NULL,&dwType,(BYTE*)tpszDisplayName,&dwSize)!= ERROR_SUCCESS) _tcscpy(tpszDisplayName,_T("Unnamed Adapter")); + TRACE("Network card: '%s'\n", debugstr_aw(tpszDisplayName)); // get the link to the Enum Subkey (currently unused) //dwType = REG_SZ; //dwSize = sizeof(tpszDeviceID); //if(RegQueryValueEx(hKey,_T("MatchingDeviceId"),NULL,&dwType,(BYTE*)tpszDeviceID,&dwSize) != ERROR_SUCCESS) { + // WARN("Missing MatchingDeviceId Entry\n"); // MessageBox(hwndDlg,_T("Missing MatchingDeviceId Entry"),_T("Registry Problem"),MB_ICONSTOP); // return; //} @@ -893,7 +900,9 @@ NetAdapterCallback(void *pCookie,HKEY hBaseKey,TCHAR *tpszSubKey) // get the card configuration GUID dwType = REG_SZ; dwSize = sizeof(tpszCfgInstanceID); - if(RegQueryValueEx(hKey,_T("NetCfgInstanceId"),NULL,&dwType,(BYTE*)tpszCfgInstanceID,&dwSize) != ERROR_SUCCESS) { + if(RegQueryValueEx(hKey,_T("NetCfgInstanceId"),NULL,&dwType,(BYTE*)tpszCfgInstanceID,&dwSize) != ERROR_SUCCESS) + { + ERR("Missing NetCfgInstanceId Entry\n"); MessageBox(hwndDlg,_T("Missing NetCfgInstanceId Entry"),_T("Registry Problem"),MB_ICONSTOP); return; } @@ -905,7 +914,6 @@ NetAdapterCallback(void *pCookie,HKEY hBaseKey,TCHAR *tpszSubKey) // really represents a device that is currently connected to the system // // How is this done properly ? - nIndex = (int) SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_ADDSTRING,0,(LPARAM)tpszDisplayName); SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETITEMDATA,nIndex,(LPARAM)ptpszCfgInstanceID); @@ -940,7 +948,7 @@ NetworkPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) EnableWindow(GetDlgItem(hwndDlg,IDC_ADD),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVE),FALSE); - + EnumAdapters(hwndDlg); SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETCURSEL,0,0); } @@ -1078,6 +1086,3 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) return TRUE; } - - - diff --git a/reactos/dll/cpl/ncpa/ncpa.h b/reactos/dll/cpl/ncpa/ncpa.h index e1489c5a581..a74b76eca81 100644 --- a/reactos/dll/cpl/ncpa/ncpa.h +++ b/reactos/dll/cpl/ncpa/ncpa.h @@ -23,8 +23,6 @@ typedef struct extern HINSTANCE hApplet; -extern ULONG DbgPrint(PCCH Fmt, ...); - #endif // __NCPA_H /* EOF */ diff --git a/reactos/dll/cpl/ncpa/ncpa.rbuild b/reactos/dll/cpl/ncpa/ncpa.rbuild index 6306011c792..f0dcc5809c1 100644 --- a/reactos/dll/cpl/ncpa/ncpa.rbuild +++ b/reactos/dll/cpl/ncpa/ncpa.rbuild @@ -5,6 +5,7 @@ . 0x600 0x501 + wine kernel32 advapi32 user32 @@ -12,8 +13,6 @@ iphlpapi ws2_32 dhcpcsvc - ntdll - msvcrt ncpa.c tcpip_properties.c ncpa.rc diff --git a/reactos/dll/cpl/ncpa/tcpip_properties.c b/reactos/dll/cpl/ncpa/tcpip_properties.c index d6d7c6bd99d..be5d92a553f 100644 --- a/reactos/dll/cpl/ncpa/tcpip_properties.c +++ b/reactos/dll/cpl/ncpa/tcpip_properties.c @@ -7,6 +7,7 @@ * Copyright 2006 Ge van Geldorp */ +#include #include #include #include @@ -21,20 +22,13 @@ #ifdef _MSC_VER #include -#else - -// this is missing on reactos... -#ifndef IPM_SETADDRESS -#define IPM_SETADDRESS (WM_USER+101) -#endif - #endif #include "resource.h" #include "ncpa.h" -#define NDEBUG -#include +#include +WINE_DEFAULT_DEBUG_CHANNEL(ncpa); typedef struct _TCPIP_PROPERTIES_DATA { DWORD AdapterIndex; @@ -135,6 +129,7 @@ ShowError(HWND Parent, UINT MsgId) MsgId, Msg, sizeof(Msg) / sizeof(Msg[0]))) { wcscpy(Msg, L"Unknown error"); } + ERR("%s\n", debugstr_w(Msg)); MessageBoxW(Parent, Msg, Error, MB_OK | MB_ICONSTOP); } @@ -204,7 +199,7 @@ ValidateAndStore(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData) RowToAdd.dwForwardNextHop = DlgData->Gateway; CreateIpForwardEntry( &RowToAdd ); - ASSERT(BST_CHECKED == IsDlgButtonChecked(Dlg, IDC_FIXEDDNS)); + assert(BST_CHECKED == IsDlgButtonChecked(Dlg, IDC_FIXEDDNS)); } else { DlgData->IpAddress = INADDR_NONE; DlgData->SubnetMask = INADDR_NONE; @@ -250,7 +245,7 @@ InternTCPIPSettings(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData) { if (! ValidateAndStore(Dlg, DlgData)) { /* Should never happen, we should have validated at PSN_KILLACTIVE */ - ASSERT(FALSE); + assert(FALSE); return FALSE; } @@ -300,8 +295,6 @@ InternTCPIPSettings(HWND Dlg, PTCPIP_PROPERTIES_DATA DlgData) { goto cleanup; } - // arty ... Not needed anymore ... We update the address live now - //MessageBox(NULL, TEXT("You need to reboot before the new parameters take effect."), TEXT("Reboot required"), MB_OK | MB_ICONWARNING); ret = TRUE; cleanup: