xref: /reactos/dll/win32/mpr/nps.c (revision 53221834)
1 /*
2  * MPR Network Provider Services functions
3  *
4  * Copyright 1999 Ulrich Weigand
5  * Copyright 2004 Mike McCormack for CodeWeavers Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #include <stdarg.h>
23 
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "netspi.h"
28 #include "wine/debug.h"
29 #include "winerror.h"
30 
31 WINE_DEFAULT_DEBUG_CHANNEL(mpr);
32 
33 
34 #include "mprres.h"
35 
36 /***********************************************************************
37  *         NPS_ProxyPasswordDialog
38  */
39 static INT_PTR WINAPI NPS_ProxyPasswordDialog(
40     HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
41 {
42     HWND hitem;
43     LPAUTHDLGSTRUCTA lpAuthDlgStruct;
44 
45     if( uMsg == WM_INITDIALOG )
46     {
47         TRACE("WM_INITDIALOG (%08lx)\n", lParam);
48 
49         /* save the parameter list */
50         lpAuthDlgStruct = (LPAUTHDLGSTRUCTA) lParam;
51         SetWindowLongPtrW( hdlg, GWLP_USERDATA, lParam );
52 
53         if( lpAuthDlgStruct->lpExplainText )
54         {
55             hitem = GetDlgItem( hdlg, IDC_EXPLAIN );
56             SetWindowTextA( hitem, lpAuthDlgStruct->lpExplainText );
57         }
58 
59         /* extract the Realm from the proxy response and show it */
60         if( lpAuthDlgStruct->lpResource )
61         {
62             hitem = GetDlgItem( hdlg, IDC_REALM );
63             SetWindowTextA( hitem, lpAuthDlgStruct->lpResource );
64         }
65 
66         return TRUE;
67     }
68 
69     lpAuthDlgStruct = (LPAUTHDLGSTRUCTA) GetWindowLongPtrW( hdlg, GWLP_USERDATA );
70 
71     switch( uMsg )
72     {
73     case WM_COMMAND:
74         if( wParam == IDOK )
75         {
76             hitem = GetDlgItem( hdlg, IDC_USERNAME );
77             if( hitem )
78                 GetWindowTextA( hitem, lpAuthDlgStruct->lpUsername, lpAuthDlgStruct->cbUsername );
79 
80             hitem = GetDlgItem( hdlg, IDC_PASSWORD );
81             if( hitem )
82                 GetWindowTextA( hitem, lpAuthDlgStruct->lpPassword, lpAuthDlgStruct->cbPassword );
83 
84             EndDialog( hdlg, WN_SUCCESS );
85             return TRUE;
86         }
87         if( wParam == IDCANCEL )
88         {
89             EndDialog( hdlg, WN_CANCEL );
90             return TRUE;
91         }
92         break;
93     }
94     return FALSE;
95 }
96 
97 /*****************************************************************
98  *  NPSAuthenticationDialogA [MPR.@]
99  */
100 DWORD WINAPI NPSAuthenticationDialogA( LPAUTHDLGSTRUCTA lpAuthDlgStruct )
101 {
102     HMODULE hwininet = GetModuleHandleA( "mpr.dll" );
103 
104     TRACE("%p\n", lpAuthDlgStruct);
105 
106     if( !lpAuthDlgStruct )
107         return WN_BAD_POINTER;
108     if( lpAuthDlgStruct->cbStructure < sizeof *lpAuthDlgStruct )
109         return WN_BAD_POINTER;
110 
111     TRACE("%s %s %s\n",lpAuthDlgStruct->lpResource,
112           lpAuthDlgStruct->lpOUTitle, lpAuthDlgStruct->lpExplainText);
113 
114     return DialogBoxParamW( hwininet, MAKEINTRESOURCEW( IDD_PROXYDLG ),
115              lpAuthDlgStruct->hwndOwner, NPS_ProxyPasswordDialog,
116              (LPARAM) lpAuthDlgStruct );
117 }
118 
119 /*****************************************************************
120  *  NPSGetProviderHandleA [MPR.@]
121  */
122 DWORD WINAPI NPSGetProviderHandleA( PHPROVIDER phProvider )
123 {
124     FIXME( "(%p): stub\n", phProvider );
125     return WN_NOT_SUPPORTED;
126 }
127 
128 /*****************************************************************
129  *  NPSGetProviderNameA [MPR.@]
130  */
131 DWORD WINAPI NPSGetProviderNameA( HPROVIDER hProvider, LPCSTR *lpszProviderName )
132 {
133     FIXME( "(%p, %p): stub\n", hProvider, lpszProviderName );
134     return WN_NOT_SUPPORTED;
135 }
136 
137 /*****************************************************************
138  *  NPSGetSectionNameA [MPR.@]
139  */
140 DWORD WINAPI NPSGetSectionNameA( HPROVIDER hProvider, LPCSTR *lpszSectionName )
141 {
142     FIXME( "(%p, %p): stub\n", hProvider, lpszSectionName );
143     return WN_NOT_SUPPORTED;
144 }
145 
146 /*****************************************************************
147  *  NPSSetExtendedErrorA [MPR.@]
148  */
149 DWORD WINAPI NPSSetExtendedErrorA( DWORD NetSpecificError, LPSTR lpExtendedErrorText )
150 {
151     FIXME( "(%08x, %s): stub\n", NetSpecificError, debugstr_a(lpExtendedErrorText) );
152     return WN_NOT_SUPPORTED;
153 }
154 
155 /*****************************************************************
156  *  NPSSetCustomTextA [MPR.@]
157  */
158 VOID WINAPI NPSSetCustomTextA( LPSTR lpCustomErrorText )
159 {
160     FIXME( "(%s): stub\n", debugstr_a(lpCustomErrorText) );
161 }
162 
163 /*****************************************************************
164  *  NPSCopyStringA [MPR.@]
165  */
166 DWORD WINAPI NPSCopyStringA( LPCSTR lpString, LPVOID lpBuffer, LPDWORD lpdwBufferSize )
167 {
168     FIXME( "(%s, %p, %p): stub\n", debugstr_a(lpString), lpBuffer, lpdwBufferSize );
169     return WN_NOT_SUPPORTED;
170 }
171 
172 /*****************************************************************
173  *  NPSDeviceGetNumberA [MPR.@]
174  */
175 DWORD WINAPI NPSDeviceGetNumberA( LPSTR lpLocalName, LPDWORD lpdwNumber, LPDWORD lpdwType )
176 {
177     FIXME( "(%s, %p, %p): stub\n", debugstr_a(lpLocalName), lpdwNumber, lpdwType );
178     return WN_NOT_SUPPORTED;
179 }
180 
181 /*****************************************************************
182  *  NPSDeviceGetStringA [MPR.@]
183  */
184 DWORD WINAPI NPSDeviceGetStringA( DWORD dwNumber, DWORD dwType, LPSTR lpLocalName, LPDWORD lpdwBufferSize )
185 {
186     FIXME( "(%d, %d, %p, %p): stub\n", dwNumber, dwType, lpLocalName, lpdwBufferSize );
187     return WN_NOT_SUPPORTED;
188 }
189 
190 /*****************************************************************
191  *  NPSNotifyRegisterA [MPR.@]
192  */
193 DWORD WINAPI NPSNotifyRegisterA( enum NOTIFYTYPE NotifyType, NOTIFYCALLBACK pfNotifyCallBack )
194 {
195     FIXME( "(%d, %p): stub\n", NotifyType, pfNotifyCallBack );
196     return WN_NOT_SUPPORTED;
197 }
198 
199 /*****************************************************************
200  *  NPSNotifyGetContextA [MPR.@]
201  */
202 LPVOID WINAPI NPSNotifyGetContextA( NOTIFYCALLBACK pfNotifyCallBack )
203 {
204     FIXME( "(%p): stub\n", pfNotifyCallBack );
205     return NULL;
206 }
207 
208 /*****************************************************************
209  *  PwdGetPasswordStatusA [MPR.@]
210  */
211 DWORD WINAPI PwdGetPasswordStatusA( LPCSTR lpProvider, DWORD dwIndex, LPDWORD status )
212 {
213     FIXME("%s %d %p\n", debugstr_a(lpProvider), dwIndex, status );
214     *status = 0;
215     return WN_SUCCESS;
216 }
217 
218 /*****************************************************************
219  *  PwdGetPasswordStatusA [MPR.@]
220  */
221 DWORD WINAPI PwdGetPasswordStatusW( LPCWSTR lpProvider, DWORD dwIndex, LPDWORD status )
222 {
223     FIXME("%s %d %p\n", debugstr_w(lpProvider), dwIndex, status );
224     *status = 0;
225     return WN_SUCCESS;
226 }
227 
228 /*****************************************************************
229  *  PwdSetPasswordStatusA [MPR.@]
230  */
231 DWORD WINAPI PwdSetPasswordStatusA( LPCSTR lpProvider, DWORD dwIndex, DWORD status )
232 {
233     FIXME("%s %d %d\n", debugstr_a(lpProvider), dwIndex, status );
234     return WN_SUCCESS;
235 }
236 
237 /*****************************************************************
238  *  PwdSetPasswordStatusW [MPR.@]
239  */
240 DWORD WINAPI PwdSetPasswordStatusW( LPCWSTR lpProvider, DWORD dwIndex, DWORD status )
241 {
242     FIXME("%s %d %d\n", debugstr_w(lpProvider), dwIndex, status );
243     return WN_SUCCESS;
244 }
245 
246 typedef struct _CHANGEPWDINFOA {
247     LPSTR lpUsername;
248     LPSTR lpPassword;
249     DWORD cbPassword;
250 } CHANGEPWDINFOA, *LPCHANGEPWDINFOA;
251 
252 typedef struct _CHANGEPWDINFOW {
253     LPWSTR lpUsername;
254     LPWSTR lpPassword;
255     DWORD cbPassword;
256 } CHANGEPWDINFOW, *LPCHANGEPWDINFOW;
257 
258 /*****************************************************************
259  *  PwdChangePasswordA [MPR.@]
260  */
261 DWORD WINAPI PwdChangePasswordA( LPCSTR lpProvider, HWND hWnd, DWORD flags, LPCHANGEPWDINFOA info )
262 {
263     FIXME("%s %p %x %p\n", debugstr_a(lpProvider), hWnd, flags, info );
264     return WN_SUCCESS;
265 }
266 
267 /*****************************************************************
268  *  PwdChangePasswordA [MPR.@]
269  */
270 DWORD WINAPI PwdChangePasswordW( LPCWSTR lpProvider, HWND hWnd, DWORD flags, LPCHANGEPWDINFOW info )
271 {
272     FIXME("%s %p %x %p\n", debugstr_w(lpProvider), hWnd, flags, info );
273     return WN_SUCCESS;
274 }
275