18d47872eSGiannis Adamopoulos /*
28d47872eSGiannis Adamopoulos * PROJECT: ReactOS Shell
38d47872eSGiannis Adamopoulos * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
48d47872eSGiannis Adamopoulos * PURPOSE: ReactOS Networking Configuration
58d47872eSGiannis Adamopoulos * COPYRIGHT: Copyright 2008 Johannes Anderwald (johannes.anderwald@reactos.org)
68d47872eSGiannis Adamopoulos */
78d47872eSGiannis Adamopoulos
8c2c66affSColin Finck #include "precomp.h"
9c2c66affSColin Finck
10c73d8c64SGiannis Adamopoulos HMODULE g_hModule = NULL;
11c2c66affSColin Finck
12c2c66affSColin Finck HINSTANCE netshell_hInstance;
13c2c66affSColin Finck
14c73d8c64SGiannis Adamopoulos class CNetshellModule : public CComModule
15c73d8c64SGiannis Adamopoulos {
16c73d8c64SGiannis Adamopoulos public:
17c73d8c64SGiannis Adamopoulos };
18c73d8c64SGiannis Adamopoulos
19c73d8c64SGiannis Adamopoulos BEGIN_OBJECT_MAP(ObjectMap)
20*76014b92SVitaly Orekhov OBJECT_ENTRY(CLSID_NetworkConnections, CNetworkConnections)
21c73d8c64SGiannis Adamopoulos OBJECT_ENTRY(CLSID_ConnectionManager, CNetConnectionManager)
22c73d8c64SGiannis Adamopoulos OBJECT_ENTRY(CLSID_LanConnectionUi, CNetConnectionPropertyUi)
23c73d8c64SGiannis Adamopoulos OBJECT_ENTRY(CLSID_ConnectionTray, CLanStatus)
24c73d8c64SGiannis Adamopoulos END_OBJECT_MAP()
25c73d8c64SGiannis Adamopoulos
26c73d8c64SGiannis Adamopoulos CNetshellModule gModule;
27c73d8c64SGiannis Adamopoulos
28c73d8c64SGiannis Adamopoulos HPROPSHEETPAGE
InitializePropertySheetPage(LPWSTR resname,DLGPROC dlgproc,LPARAM lParam,LPWSTR szTitle)29c73d8c64SGiannis Adamopoulos InitializePropertySheetPage(LPWSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
30c73d8c64SGiannis Adamopoulos {
31c73d8c64SGiannis Adamopoulos PROPSHEETPAGEW ppage;
32c73d8c64SGiannis Adamopoulos
33c73d8c64SGiannis Adamopoulos memset(&ppage, 0x0, sizeof(PROPSHEETPAGEW));
34c73d8c64SGiannis Adamopoulos ppage.dwSize = sizeof(PROPSHEETPAGEW);
35c73d8c64SGiannis Adamopoulos ppage.dwFlags = PSP_DEFAULT;
36c73d8c64SGiannis Adamopoulos ppage.pszTemplate = resname;
37c73d8c64SGiannis Adamopoulos ppage.pfnDlgProc = dlgproc;
38c73d8c64SGiannis Adamopoulos ppage.lParam = lParam;
39c73d8c64SGiannis Adamopoulos ppage.hInstance = netshell_hInstance;
40c73d8c64SGiannis Adamopoulos if (szTitle)
41c73d8c64SGiannis Adamopoulos {
42c73d8c64SGiannis Adamopoulos ppage.dwFlags |= PSP_USETITLE;
43c73d8c64SGiannis Adamopoulos ppage.pszTitle = szTitle;
44c73d8c64SGiannis Adamopoulos }
45c73d8c64SGiannis Adamopoulos return CreatePropertySheetPageW(&ppage);
46c73d8c64SGiannis Adamopoulos }
47c73d8c64SGiannis Adamopoulos
48c2c66affSColin Finck extern "C"
49c2c66affSColin Finck {
50c2c66affSColin Finck
51c2c66affSColin Finck BOOL
52c2c66affSColin Finck WINAPI
DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID fImpLoad)53c2c66affSColin Finck DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
54c2c66affSColin Finck {
55c2c66affSColin Finck switch (fdwReason)
56c2c66affSColin Finck {
57c2c66affSColin Finck case DLL_PROCESS_ATTACH:
58c2c66affSColin Finck netshell_hInstance = hinstDLL;
59c2c66affSColin Finck DisableThreadLibraryCalls(netshell_hInstance);
60c73d8c64SGiannis Adamopoulos gModule.Init(ObjectMap, netshell_hInstance, NULL);
61c2c66affSColin Finck break;
62c2c66affSColin Finck default:
63c2c66affSColin Finck break;
64c2c66affSColin Finck }
65c2c66affSColin Finck
66c2c66affSColin Finck return TRUE;
67c2c66affSColin Finck }
68c2c66affSColin Finck
69c2c66affSColin Finck HRESULT
70c2c66affSColin Finck WINAPI
DllCanUnloadNow(void)71c2c66affSColin Finck DllCanUnloadNow(void)
72c2c66affSColin Finck {
73c2c66affSColin Finck return S_FALSE;
74c2c66affSColin Finck }
75c2c66affSColin Finck
76c2c66affSColin Finck STDAPI
DllRegisterServer(void)77c2c66affSColin Finck DllRegisterServer(void)
78c2c66affSColin Finck {
79c73d8c64SGiannis Adamopoulos HRESULT hr;
80c73d8c64SGiannis Adamopoulos
81c73d8c64SGiannis Adamopoulos hr = gModule.DllRegisterServer(FALSE);
82c73d8c64SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
83c73d8c64SGiannis Adamopoulos return hr;
84c73d8c64SGiannis Adamopoulos
85c73d8c64SGiannis Adamopoulos hr = gModule.UpdateRegistryFromResource(IDR_NETSHELL, TRUE, NULL);
86c73d8c64SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
87c73d8c64SGiannis Adamopoulos return hr;
88c73d8c64SGiannis Adamopoulos
89c73d8c64SGiannis Adamopoulos return S_OK;
90c2c66affSColin Finck }
91c2c66affSColin Finck
92c2c66affSColin Finck STDAPI
DllUnregisterServer(void)93c2c66affSColin Finck DllUnregisterServer(void)
94c2c66affSColin Finck {
95c73d8c64SGiannis Adamopoulos HRESULT hr;
96c73d8c64SGiannis Adamopoulos
97c73d8c64SGiannis Adamopoulos hr = gModule.DllUnregisterServer(FALSE);
98c73d8c64SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
99c73d8c64SGiannis Adamopoulos return hr;
100c73d8c64SGiannis Adamopoulos
101c73d8c64SGiannis Adamopoulos hr = gModule.UpdateRegistryFromResource(IDR_NETSHELL, FALSE, NULL);
102c73d8c64SGiannis Adamopoulos if (FAILED_UNEXPECTEDLY(hr))
103c73d8c64SGiannis Adamopoulos return hr;
104c73d8c64SGiannis Adamopoulos
105c73d8c64SGiannis Adamopoulos return S_OK;
106c2c66affSColin Finck }
107c2c66affSColin Finck
108c2c66affSColin Finck STDAPI
DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID * ppv)109c2c66affSColin Finck DllGetClassObject(
110c2c66affSColin Finck REFCLSID rclsid,
111c2c66affSColin Finck REFIID riid,
112c2c66affSColin Finck LPVOID *ppv)
113c2c66affSColin Finck {
114c73d8c64SGiannis Adamopoulos return gModule.DllGetClassObject(rclsid, riid, ppv);
115c2c66affSColin Finck }
116c2c66affSColin Finck
117c2c66affSColin Finck VOID
118c2c66affSColin Finck WINAPI
NcFreeNetconProperties(NETCON_PROPERTIES * pProps)119c2c66affSColin Finck NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
120c2c66affSColin Finck {
121c2c66affSColin Finck CoTaskMemFree(pProps->pszwName);
122c2c66affSColin Finck CoTaskMemFree(pProps->pszwDeviceName);
123c2c66affSColin Finck CoTaskMemFree(pProps);
124c2c66affSColin Finck }
125c2c66affSColin Finck
126c2c66affSColin Finck BOOL
127c2c66affSColin Finck WINAPI
NcIsValidConnectionName(_In_ PCWSTR pszwName)128c2c66affSColin Finck NcIsValidConnectionName(_In_ PCWSTR pszwName)
129c2c66affSColin Finck {
130c2c66affSColin Finck if (!pszwName)
131c2c66affSColin Finck return FALSE;
132c2c66affSColin Finck
133c2c66affSColin Finck BOOL nonSpace = FALSE;
134c2c66affSColin Finck while (*pszwName)
135c2c66affSColin Finck {
136c2c66affSColin Finck switch(*(pszwName++))
137c2c66affSColin Finck {
138c2c66affSColin Finck case L'\\':
139c2c66affSColin Finck case L'/':
140c2c66affSColin Finck case L':':
141c2c66affSColin Finck case L'*':
142c2c66affSColin Finck case L'\t':
143c2c66affSColin Finck case L'?':
144c2c66affSColin Finck case L'<':
145c2c66affSColin Finck case L'>':
146c2c66affSColin Finck case L'|':
147c2c66affSColin Finck case L'\"':
148c2c66affSColin Finck return FALSE;
149c2c66affSColin Finck case L' ':
150c2c66affSColin Finck break;
151c2c66affSColin Finck default:
152c2c66affSColin Finck nonSpace = TRUE;
153c2c66affSColin Finck break;
154c2c66affSColin Finck }
155c2c66affSColin Finck }
156c2c66affSColin Finck return nonSpace;
157c2c66affSColin Finck }
158c2c66affSColin Finck
159c2c66affSColin Finck } // extern "C"
160