xref: /reactos/dll/cpl/inetcpl/inetcpl.c (revision 90cb67a7)
1c2c66affSColin Finck /*
2c2c66affSColin Finck  * Internet control panel applet
3c2c66affSColin Finck  *
4c2c66affSColin Finck  * Copyright 2010 Detlef Riekenberg
5c2c66affSColin Finck  *
6c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck  * License as published by the Free Software Foundation; either
9c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck  *
11c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14c2c66affSColin Finck  * Lesser General Public License for more details.
15c2c66affSColin Finck  *
16c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck  *
20c2c66affSColin Finck  */
21c2c66affSColin Finck 
2288d36209SAmine Khaldi #define NONAMELESSUNION
2388d36209SAmine Khaldi #define COBJMACROS
2488d36209SAmine Khaldi #define CONST_VTABLE
2588d36209SAmine Khaldi 
2688d36209SAmine Khaldi #include <stdarg.h>
2788d36209SAmine Khaldi #include <windef.h>
2888d36209SAmine Khaldi #include <winbase.h>
2988d36209SAmine Khaldi #include <wingdi.h>
3088d36209SAmine Khaldi #include <winuser.h>
3188d36209SAmine Khaldi #include <commctrl.h>
3288d36209SAmine Khaldi #include <cpl.h>
3388d36209SAmine Khaldi #include "ole2.h"
3488d36209SAmine Khaldi 
3588d36209SAmine Khaldi #include "wine/debug.h"
3688d36209SAmine Khaldi 
37c2c66affSColin Finck #include "inetcpl.h"
38c2c66affSColin Finck 
3988d36209SAmine Khaldi 
4088d36209SAmine Khaldi WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
41c2c66affSColin Finck 
42c2c66affSColin Finck DECLSPEC_HIDDEN HMODULE hcpl;
43c2c66affSColin Finck 
44c2c66affSColin Finck /*********************************************************************
45c2c66affSColin Finck  *  DllMain (inetcpl.@)
46c2c66affSColin Finck  */
DllMain(HINSTANCE hdll,DWORD reason,LPVOID reserved)47c2c66affSColin Finck BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved)
48c2c66affSColin Finck {
49c2c66affSColin Finck     TRACE("(%p, %d, %p)\n", hdll, reason, reserved);
50c2c66affSColin Finck 
51c2c66affSColin Finck     switch (reason)
52c2c66affSColin Finck     {
53c2c66affSColin Finck #ifndef __REACTOS__
54c2c66affSColin Finck         case DLL_WINE_PREATTACH:
55c2c66affSColin Finck             return FALSE;  /* prefer native version */
56c2c66affSColin Finck #endif
57c2c66affSColin Finck 
58c2c66affSColin Finck         case DLL_PROCESS_ATTACH:
59c2c66affSColin Finck             DisableThreadLibraryCalls(hdll);
60c2c66affSColin Finck             hcpl = hdll;
61c2c66affSColin Finck     }
62c2c66affSColin Finck     return TRUE;
63c2c66affSColin Finck }
64c2c66affSColin Finck 
65c2c66affSColin Finck /***********************************************************************
66c2c66affSColin Finck  *  DllInstall (inetcpl.@)
67c2c66affSColin Finck  */
DllInstall(BOOL bInstall,LPCWSTR cmdline)68c2c66affSColin Finck HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
69c2c66affSColin Finck {
70c2c66affSColin Finck     FIXME("(%s, %s): stub\n", bInstall ? "TRUE" : "FALSE", debugstr_w(cmdline));
71c2c66affSColin Finck     return S_OK;
72c2c66affSColin Finck }
73c2c66affSColin Finck 
74c2c66affSColin Finck /******************************************************************************
75c2c66affSColin Finck  * propsheet_callback [internal]
76c2c66affSColin Finck  *
77c2c66affSColin Finck  */
propsheet_callback(HWND hwnd,UINT msg,LPARAM lparam)78c2c66affSColin Finck static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
79c2c66affSColin Finck {
80*90cb67a7SAmine Khaldi #ifdef __REACTOS__
81bd55105cSKatayama Hirofumi MZ     // NOTE: This callback is needed to set large icon correctly.
82bd55105cSKatayama Hirofumi MZ     HICON hIcon;
83*90cb67a7SAmine Khaldi #endif
84c2c66affSColin Finck     TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
85c2c66affSColin Finck     switch (msg)
86c2c66affSColin Finck     {
87c2c66affSColin Finck         case PSCB_INITIALIZED:
88*90cb67a7SAmine Khaldi #ifdef __REACTOS__
89bd55105cSKatayama Hirofumi MZ         {
90bd55105cSKatayama Hirofumi MZ             hIcon = LoadIconW(hcpl, MAKEINTRESOURCEW(ICO_MAIN));
91bd55105cSKatayama Hirofumi MZ             SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
92c2c66affSColin Finck             break;
93c2c66affSColin Finck         }
94*90cb67a7SAmine Khaldi #else
95*90cb67a7SAmine Khaldi             SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIconW(hcpl, MAKEINTRESOURCEW(ICO_MAIN)));
96*90cb67a7SAmine Khaldi             break;
97*90cb67a7SAmine Khaldi #endif
98bd55105cSKatayama Hirofumi MZ     }
99c2c66affSColin Finck     return 0;
100c2c66affSColin Finck }
101c2c66affSColin Finck 
102c2c66affSColin Finck /******************************************************************************
103c2c66affSColin Finck  * display_cpl_sheets [internal]
104c2c66affSColin Finck  *
105c2c66affSColin Finck  * Build and display the dialog with all control panel propertysheets
106c2c66affSColin Finck  *
107c2c66affSColin Finck  */
display_cpl_sheets(HWND parent)108c2c66affSColin Finck static void display_cpl_sheets(HWND parent)
109c2c66affSColin Finck {
110c2c66affSColin Finck     INITCOMMONCONTROLSEX icex;
111c2c66affSColin Finck     PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
112c2c66affSColin Finck     PROPSHEETHEADERW psh;
113c2c66affSColin Finck     DWORD id = 0;
114c2c66affSColin Finck 
115c2c66affSColin Finck     OleInitialize(NULL);
116c2c66affSColin Finck     /* Initialize common controls */
117c2c66affSColin Finck     icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
118c2c66affSColin Finck     icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES;
119c2c66affSColin Finck     InitCommonControlsEx(&icex);
120c2c66affSColin Finck 
121c2c66affSColin Finck     ZeroMemory(&psh, sizeof(psh));
122c2c66affSColin Finck     ZeroMemory(psp, sizeof(psp));
123c2c66affSColin Finck 
124c2c66affSColin Finck     /* Fill out all PROPSHEETPAGE */
125c2c66affSColin Finck     psp[id].dwSize = sizeof (PROPSHEETPAGEW);
126c2c66affSColin Finck     psp[id].hInstance = hcpl;
127c2c66affSColin Finck     psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL);
128c2c66affSColin Finck     psp[id].pfnDlgProc = general_dlgproc;
129c2c66affSColin Finck     id++;
130c2c66affSColin Finck 
131c2c66affSColin Finck     psp[id].dwSize = sizeof (PROPSHEETPAGEW);
132c2c66affSColin Finck     psp[id].hInstance = hcpl;
133c2c66affSColin Finck     psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_SECURITY);
134c2c66affSColin Finck     psp[id].pfnDlgProc = security_dlgproc;
135c2c66affSColin Finck     id++;
136c2c66affSColin Finck 
137c2c66affSColin Finck     psp[id].dwSize = sizeof (PROPSHEETPAGEW);
138c2c66affSColin Finck     psp[id].hInstance = hcpl;
139c2c66affSColin Finck     psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONTENT);
140c2c66affSColin Finck     psp[id].pfnDlgProc = content_dlgproc;
141c2c66affSColin Finck     id++;
142c2c66affSColin Finck 
143d02c7225SAmine Khaldi     psp[id].dwSize = sizeof (PROPSHEETPAGEW);
144d02c7225SAmine Khaldi     psp[id].hInstance = hcpl;
145d02c7225SAmine Khaldi     psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONNECTIONS);
146d02c7225SAmine Khaldi     psp[id].pfnDlgProc = connections_dlgproc;
147d02c7225SAmine Khaldi     id++;
148d02c7225SAmine Khaldi 
149c2c66affSColin Finck     /* Fill out the PROPSHEETHEADER */
150c2c66affSColin Finck     psh.dwSize = sizeof (PROPSHEETHEADERW);
151c2c66affSColin Finck     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
152c2c66affSColin Finck     psh.hwndParent = parent;
153c2c66affSColin Finck     psh.hInstance = hcpl;
154c2c66affSColin Finck     psh.u.pszIcon = MAKEINTRESOURCEW(ICO_MAIN);
155c2c66affSColin Finck     psh.pszCaption = MAKEINTRESOURCEW(IDS_CPL_NAME);
156c2c66affSColin Finck     psh.nPages = id;
157c2c66affSColin Finck     psh.u3.ppsp = psp;
158c2c66affSColin Finck     psh.pfnCallback = propsheet_callback;
159c2c66affSColin Finck 
160c2c66affSColin Finck     /* display the dialog */
161c2c66affSColin Finck     PropertySheetW(&psh);
162c2c66affSColin Finck 
163c2c66affSColin Finck     OleUninitialize();
164c2c66affSColin Finck }
165c2c66affSColin Finck 
166c2c66affSColin Finck /*********************************************************************
167c2c66affSColin Finck  * CPlApplet (inetcpl.@)
168c2c66affSColin Finck  *
169c2c66affSColin Finck  * Control Panel entry point
170c2c66affSColin Finck  *
171c2c66affSColin Finck  * PARAMS
172c2c66affSColin Finck  *  hWnd    [I] Handle for the Control Panel Window
173c2c66affSColin Finck  *  command [I] CPL_* Command
174c2c66affSColin Finck  *  lParam1 [I] first extra Parameter
175c2c66affSColin Finck  *  lParam2 [I] second extra Parameter
176c2c66affSColin Finck  *
177c2c66affSColin Finck  * RETURNS
178c2c66affSColin Finck  *  Depends on the command
179c2c66affSColin Finck  *
180c2c66affSColin Finck  */
CPlApplet(HWND hWnd,UINT command,LPARAM lParam1,LPARAM lParam2)181c2c66affSColin Finck LONG CALLBACK CPlApplet(HWND hWnd, UINT command, LPARAM lParam1, LPARAM lParam2)
182c2c66affSColin Finck {
183c2c66affSColin Finck     TRACE("(%p, %u, 0x%lx, 0x%lx)\n", hWnd, command, lParam1, lParam2);
184c2c66affSColin Finck 
185c2c66affSColin Finck     switch (command)
186c2c66affSColin Finck     {
187c2c66affSColin Finck         case CPL_INIT:
188c2c66affSColin Finck             return TRUE;
189c2c66affSColin Finck 
190c2c66affSColin Finck         case CPL_GETCOUNT:
191c2c66affSColin Finck             return 1;
192c2c66affSColin Finck 
193c2c66affSColin Finck         case CPL_INQUIRE:
194c2c66affSColin Finck         {
195c2c66affSColin Finck             CPLINFO *appletInfo = (CPLINFO *) lParam2;
196c2c66affSColin Finck 
197c2c66affSColin Finck             appletInfo->idIcon = ICO_MAIN;
198c2c66affSColin Finck             appletInfo->idName = IDS_CPL_NAME;
199c2c66affSColin Finck             appletInfo->idInfo = IDS_CPL_INFO;
200c2c66affSColin Finck             appletInfo->lData = 0;
201c2c66affSColin Finck             return TRUE;
202c2c66affSColin Finck         }
203c2c66affSColin Finck 
204c2c66affSColin Finck         case CPL_DBLCLK:
205c2c66affSColin Finck             display_cpl_sheets(hWnd);
206c2c66affSColin Finck             break;
207c2c66affSColin Finck     }
208c2c66affSColin Finck 
209c2c66affSColin Finck     return FALSE;
210c2c66affSColin Finck }
211c2c66affSColin Finck 
212c2c66affSColin Finck /*********************************************************************
213c2c66affSColin Finck  * LaunchInternetControlPanel (inetcpl.@)
214c2c66affSColin Finck  *
215c2c66affSColin Finck  * Launch the Internet Control Panel dialog
216c2c66affSColin Finck  *
217c2c66affSColin Finck  * PARAMS
218c2c66affSColin Finck  *  parent  [I] Handle for the parent window
219c2c66affSColin Finck  *
220c2c66affSColin Finck  * RETURNS
221c2c66affSColin Finck  *  Success: TRUE
222c2c66affSColin Finck  *
223c2c66affSColin Finck  * NOTES
224c2c66affSColin Finck  *  rundll32 callable function: rundll32 inetcpl.cpl,LaunchInternetControlPanel
225c2c66affSColin Finck  *
226c2c66affSColin Finck  */
LaunchInternetControlPanel(HWND parent)227c2c66affSColin Finck BOOL WINAPI LaunchInternetControlPanel(HWND parent)
228c2c66affSColin Finck {
229c2c66affSColin Finck     display_cpl_sheets(parent);
230c2c66affSColin Finck     return TRUE;
231c2c66affSColin Finck }
232c2c66affSColin Finck 
233c2c66affSColin Finck /*********************************************************************
234c2c66affSColin Finck  * LaunchConnectionDialog (inetcpl.@)
235c2c66affSColin Finck  *
236c2c66affSColin Finck  */
LaunchConnectionDialog(HWND hParent)237c2c66affSColin Finck BOOL WINAPI LaunchConnectionDialog(HWND hParent)
238c2c66affSColin Finck {
239c2c66affSColin Finck     FIXME("(%p): stub\n", hParent);
240c2c66affSColin Finck     return FALSE;
241c2c66affSColin Finck }
242c2c66affSColin Finck 
243c2c66affSColin Finck /*********************************************************************
244c2c66affSColin Finck  * LaunchInternetControlPanel (inetcpl.@)
245c2c66affSColin Finck  *
246c2c66affSColin Finck  */
LaunchPrivacyDialog(HWND hParent)247c2c66affSColin Finck BOOL WINAPI LaunchPrivacyDialog(HWND hParent)
248c2c66affSColin Finck {
249c2c66affSColin Finck     FIXME("(%p): stub\n", hParent);
250c2c66affSColin Finck     return FALSE;
251c2c66affSColin Finck }
252