- Localization to Portuguese of Brazil
[wine] / dlls / user / network.c
1 /*
2  * USER Windows Network functions
3  *
4  * Copyright 1995 Martin von Loewis
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <ctype.h>
24 #include <string.h>
25 #include <sys/types.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29
30 #include "winbase.h"
31 #include "wine/winnet16.h"
32 #include "winnetwk.h"
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(wnet);
36
37 /*
38  * Remote printing
39  */
40
41 /**************************************************************************
42  *              WNetOpenJob       [USER.501]
43  */
44 WORD WINAPI WNetOpenJob16( LPSTR szQueue, LPSTR szJobTitle, WORD nCopies, LPINT16 pfh )
45 {
46     FIXME( "(%s, %s, %d, %p): stub\n",
47            debugstr_a(szQueue), debugstr_a(szJobTitle), nCopies, pfh );
48     return WN16_NET_ERROR;
49 }
50
51 /**************************************************************************
52  *              WNetCloseJob      [USER.502]
53  */
54 WORD WINAPI WNetCloseJob16( WORD fh, LPINT16 pidJob, LPSTR szQueue )
55 {
56     FIXME( "(%d, %p, %s): stub\n", fh, pidJob, debugstr_a(szQueue) );
57     return WN16_NET_ERROR;
58 }
59
60 /**************************************************************************
61  *              WNetWriteJob      [USER.524]
62  */
63 WORD WINAPI WNetWriteJob16( HANDLE16 hJob, LPSTR lpData, LPINT16 lpcbData )
64 {
65     FIXME( "(%04x, %p, %p): stub\n", hJob, lpData, lpcbData );
66     return WN16_NET_ERROR;
67 }
68
69 /**************************************************************************
70  *              WNetAbortJob       [USER.503]
71  */
72 WORD WINAPI WNetAbortJob16( LPSTR szQueue, WORD wJobId )
73 {
74     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
75     return WN16_NET_ERROR;
76 }
77
78 /**************************************************************************
79  *              WNetHoldJob       [USER.504]
80  */
81 WORD WINAPI WNetHoldJob16( LPSTR szQueue, WORD wJobId )
82 {
83     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
84     return WN16_NET_ERROR;
85 }
86
87 /**************************************************************************
88  *              WNetReleaseJob       [USER.505]
89  */
90 WORD WINAPI WNetReleaseJob16( LPSTR szQueue, WORD wJobId )
91 {
92     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
93     return WN16_NET_ERROR;
94 }
95
96 /**************************************************************************
97  *              WNetCancelJob       [USER.506]
98  */
99 WORD WINAPI WNetCancelJob16( LPSTR szQueue, WORD wJobId )
100 {
101     FIXME( "(%s, %d): stub\n", debugstr_a(szQueue), wJobId );
102     return WN16_NET_ERROR;
103 }
104
105 /**************************************************************************
106  *              WNetSetJobCopies     [USER.507]
107  */
108 WORD WINAPI WNetSetJobCopies16( LPSTR szQueue, WORD wJobId, WORD nCopies )
109 {
110     FIXME( "(%s, %d, %d): stub\n", debugstr_a(szQueue), wJobId, nCopies );
111     return WN16_NET_ERROR;
112 }
113
114 /**************************************************************************
115  *              WNetWatchQueue       [USER.508]
116  */
117 WORD WINAPI WNetWatchQueue16( HWND16 hWnd, LPSTR szLocal, LPSTR szUser, WORD nQueue )
118 {
119     FIXME( "(%04x, %s, %s, %d): stub\n",
120            hWnd, debugstr_a(szLocal), debugstr_a(szUser), nQueue );
121     return WN16_NET_ERROR;
122 }
123
124 /**************************************************************************
125  *              WNetUnwatchQueue     [USER.509]
126  */
127 WORD WINAPI WNetUnwatchQueue16( LPSTR szQueue )
128 {
129     FIXME( "(%s): stub\n", debugstr_a(szQueue) );
130     return WN16_NET_ERROR;
131 }
132
133 /**************************************************************************
134  *              WNetLockQueueData       [USER.510]
135  */
136 WORD WINAPI WNetLockQueueData16( LPSTR szQueue, LPSTR szUser,
137                                  LPQUEUESTRUCT16 *lplpQueueStruct )
138 {
139     FIXME( "(%s, %s, %p): stub\n",
140            debugstr_a(szQueue), debugstr_a(szUser), lplpQueueStruct );
141     return WN16_NET_ERROR;
142 }
143
144 /**************************************************************************
145  *              WNetUnlockQueueData       [USER.511]
146  */
147 WORD WINAPI WNetUnlockQueueData16( LPSTR szQueue )
148 {
149     FIXME( "(%s): stub\n", debugstr_a(szQueue) );
150     return WN16_NET_ERROR;
151 }
152
153
154 /*
155  * Connections
156  */
157
158 /********************************************************************
159  *  WNetAddConnection [USER.517]  Directs a local device to net
160  *
161  * Redirects a local device (either a disk drive or printer port)
162  * to a shared device on a remote server.
163  */
164 WORD WINAPI WNetAddConnection16( LPSTR lpNetPath, LPSTR lpPassWord,
165                                  LPSTR lpLocalName )
166 {
167     FIXME( "(%s, %p, %s): stub\n",
168            debugstr_a(lpNetPath), lpPassWord, debugstr_a(lpLocalName) );
169     return WN16_NET_ERROR;
170 }
171
172 /********************************************************************
173  *   WNetCancelConnection [USER.518]  undirects a local device
174  */
175 WORD WINAPI WNetCancelConnection16( LPSTR lpName, BOOL16 bForce )
176 {
177     FIXME( "(%s, %04X): stub\n", debugstr_a(lpName), bForce);
178     return WN16_NOT_SUPPORTED;
179 }
180
181 /********************************************************************
182  * WNetGetConnection [USER.512] reverse-resolves a local device
183  */
184 WORD WINAPI WNetGetConnection16( LPSTR lpLocalName,
185                                  LPSTR lpRemoteName, UINT16 *cbRemoteName )
186 {
187     char label[32];
188
189     TRACE( "local %s\n", lpLocalName );
190     switch(GetDriveTypeA(lpLocalName))
191     {
192     case DRIVE_REMOTE:
193         GetVolumeInformationA( lpLocalName, label, sizeof(label), NULL, NULL, NULL, NULL, 0 );
194         if (strlen(label) + 1 > *cbRemoteName)
195         {
196             *cbRemoteName = strlen(label) + 1;
197             return WN16_MORE_DATA;
198         }
199         strcpy( lpRemoteName, label );
200         *cbRemoteName = strlen(lpRemoteName) + 1;
201         return WN16_SUCCESS;
202     case DRIVE_REMOVABLE:
203     case DRIVE_FIXED:
204     case DRIVE_CDROM:
205         TRACE("file is local\n");
206         return WN16_NOT_CONNECTED;
207     default:
208         return WN16_BAD_LOCALNAME;
209     }
210 }
211
212 /**************************************************************************
213  *              WNetRestoreConnection       [USER.523]
214  */
215 WORD WINAPI WNetRestoreConnection16( HWND16 hwndOwner, LPSTR lpszDevice )
216 {
217     FIXME( "(%04x, %s): stub\n", hwndOwner, debugstr_a(lpszDevice) );
218     return WN16_NOT_SUPPORTED;
219 }
220
221
222 /*
223  * Capabilities
224  */
225
226 /**************************************************************************
227  *              WNetGetCaps             [USER.513]
228  */
229 WORD WINAPI WNetGetCaps16( WORD capability )
230 {
231     switch (capability)
232     {
233     case WNNC16_SPEC_VERSION:
234         return 0x30a; /* WfW 3.11 (and apparently other 3.1x) */
235
236     case WNNC16_NET_TYPE:
237         /* hi byte = network type,
238            lo byte = network vendor (Netware = 0x03) [15 types] */
239         return WNNC16_NET_MultiNet | WNNC16_SUBNET_WinWorkgroups;
240
241     case WNNC16_DRIVER_VERSION:
242         /* driver version of vendor */
243         return 0x100; /* WfW 3.11 */
244
245     case WNNC16_USER:
246         /* 1 = WNetGetUser is supported */
247         return 1;
248
249     case WNNC16_CONNECTION:
250         /* returns mask of the supported connection functions */
251         return   WNNC16_CON_AddConnection | WNNC16_CON_CancelConnection
252                | WNNC16_CON_GetConnections /* | WNNC16_CON_AutoConnect */
253                | WNNC16_CON_BrowseDialog | WNNC16_CON_RestoreConnection;
254
255     case WNNC16_PRINTING:
256         /* returns mask of the supported printing functions */
257         return   WNNC16_PRT_OpenJob | WNNC16_PRT_CloseJob | WNNC16_PRT_HoldJob
258                | WNNC16_PRT_ReleaseJob | WNNC16_PRT_CancelJob
259                | WNNC16_PRT_SetJobCopies | WNNC16_PRT_WatchQueue
260                | WNNC16_PRT_UnwatchQueue | WNNC16_PRT_LockQueueData
261                | WNNC16_PRT_UnlockQueueData | WNNC16_PRT_AbortJob
262                | WNNC16_PRT_WriteJob;
263
264     case WNNC16_DIALOG:
265         /* returns mask of the supported dialog functions */
266         return   WNNC16_DLG_DeviceMode | WNNC16_DLG_BrowseDialog
267                | WNNC16_DLG_ConnectDialog | WNNC16_DLG_DisconnectDialog
268                | WNNC16_DLG_ViewQueueDialog | WNNC16_DLG_PropertyDialog
269                | WNNC16_DLG_ConnectionDialog
270             /* | WNNC16_DLG_PrinterConnectDialog
271                | WNNC16_DLG_SharesDialog | WNNC16_DLG_ShareAsDialog */;
272
273     case WNNC16_ADMIN:
274         /* returns mask of the supported administration functions */
275         /* not sure if long file names is a good idea */
276         return   WNNC16_ADM_GetDirectoryType
277             /* | WNNC16_ADM_DirectoryNotify */ /*not yet supported*/
278                | WNNC16_ADM_LongNames /* | WNNC16_ADM_SetDefaultDrive */;
279
280     case WNNC16_ERROR:
281         /* returns mask of the supported error functions */
282         return   WNNC16_ERR_GetError | WNNC16_ERR_GetErrorText;
283
284     case WNNC16_PRINTMGREXT:
285         /* returns the Print Manager version in major and
286            minor format if Print Manager functions are available */
287         return 0x30e; /* printman version of WfW 3.11 */
288
289     case 0xffff:
290         /* Win 3.11 returns HMODULE of network driver here
291            FIXME: what should we return ?
292            logonoff.exe needs it, msmail crashes with wrong value */
293         return 0;
294
295     default:
296         return 0;
297     }
298 }
299
300
301 /*
302  * Get User
303  */
304
305 /**************************************************************************
306  *              WNetGetUser                     [USER.516]
307  */
308 WORD WINAPI WNetGetUser16( LPCSTR lpName, LPSTR szUser, LPINT16 nBufferSize )
309 {
310     FIXME( "(%p, %p, %p): stub\n", lpName, szUser, nBufferSize );
311     return WN16_NOT_SUPPORTED;
312 }
313
314
315 /*
316  * Browsing
317  */
318
319 /**************************************************************************
320  *              WNetDeviceMode       [USER.514]
321  */
322 WORD WINAPI WNetDeviceMode16( HWND16 hWndOwner )
323 {
324     FIXME( "(%04x): stub\n", hWndOwner );
325     return WN16_NOT_SUPPORTED;
326 }
327
328 /**************************************************************************
329  *              WNetBrowseDialog       [USER.515]
330  */
331 WORD WINAPI WNetBrowseDialog16( HWND16 hParent, WORD nType, LPSTR szPath )
332 {
333     FIXME( "(%04x, %x, %s): stub\n", hParent, nType, szPath );
334     return WN16_NOT_SUPPORTED;
335 }
336
337 /********************************************************************
338  *              WNetConnectDialog       [USER.525]
339  */
340 WORD WINAPI WNetConnectDialog( HWND16 hWndParent, WORD iType )
341 {
342     FIXME( "(%04x, %x): stub\n", hWndParent, iType );
343     return WN16_SUCCESS;
344 }
345
346 /**************************************************************************
347  *              WNetDisconnectDialog       [USER.526]
348  */
349 WORD WINAPI WNetDisconnectDialog16( HWND16 hwndOwner, WORD iType )
350 {
351     FIXME( "(%04x, %x): stub\n", hwndOwner, iType );
352     return WN16_NOT_SUPPORTED;
353 }
354
355 /**************************************************************************
356  *              WNetConnectionDialog     [USER.527]
357  */
358 WORD WINAPI WNetConnectionDialog16( HWND16 hWndParent, WORD iType )
359 {
360     FIXME( "(%04x, %x): stub\n", hWndParent, iType );
361     return WN16_SUCCESS;
362 }
363
364 /**************************************************************************
365  *              WNetViewQueueDialog       [USER.528]
366  */
367 WORD WINAPI WNetViewQueueDialog16( HWND16 hwndOwner, LPSTR lpszQueue )
368 {
369     FIXME(" (%04x, %s): stub\n", hwndOwner, debugstr_a(lpszQueue) );
370     return WN16_NOT_SUPPORTED;
371 }
372
373 /**************************************************************************
374  *              WNetPropertyDialog       [USER.529]
375  */
376 WORD WINAPI WNetPropertyDialog16( HWND16 hwndParent, WORD iButton,
377                                   WORD nPropSel, LPSTR lpszName, WORD nType )
378 {
379     FIXME( "(%04x, %x, %x, %s, %x ): stub\n",
380           hwndParent, iButton, nPropSel, debugstr_a(lpszName), nType );
381     return WN16_NOT_SUPPORTED;
382 }
383
384 /**************************************************************************
385  *              WNetGetPropertyText       [USER.532]
386  */
387 WORD WINAPI WNetGetPropertyText16( WORD iButton, WORD nPropSel, LPSTR lpszName,
388                                    LPSTR lpszButtonName, WORD cbButtonName, WORD nType )
389 {
390     FIXME( "(%04x, %04x, %s, %s, %04x): stub\n",
391            iButton, nPropSel, debugstr_a(lpszName), debugstr_a(lpszButtonName), nType);
392     return WN16_NOT_SUPPORTED;
393 }
394
395
396 /*
397  * Admin
398  */
399
400 /*********************************************************************
401  *  WNetGetDirectoryType [USER.530]  Decides whether resource is local
402  *
403  * RETURNS
404  *    on success,  puts one of the following in *lpType:
405  * - WNDT_NETWORK   on a network
406  * - WNDT_LOCAL     local
407  */
408 WORD WINAPI WNetGetDirectoryType16( LPSTR lpName, LPINT16 lpType )
409 {
410     UINT type = GetDriveTypeA(lpName);
411     if ( type == DRIVE_NO_ROOT_DIR )
412         type = GetDriveTypeA(NULL);
413
414     *lpType = (type == DRIVE_REMOTE)? WNDT_NETWORK : WNDT_NORMAL;
415
416     TRACE( "%s is %s\n", debugstr_a(lpName),
417            (*lpType == WNDT_NETWORK)? "WNDT_NETWORK" : "WNDT_NORMAL" );
418     return WN16_SUCCESS;
419 }
420
421 /**************************************************************************
422  *              WNetDirectoryNotify       [USER.531]
423  */
424 WORD WINAPI WNetDirectoryNotify16( HWND16 hwndOwner, LPSTR lpDir, WORD wOper )
425 {
426     FIXME( "(%04x, %s, %s): stub\n", hwndOwner, debugstr_a(lpDir),
427            (wOper == WNDN_MKDIR)? "WNDN_MKDIR" :
428            (wOper == WNDN_MVDIR)? "WNDN_MVDIR" :
429            (wOper == WNDN_RMDIR)? "WNDN_RMDIR" : "unknown" );
430     return WN16_NOT_SUPPORTED;
431 }
432
433
434 /*
435  * Error handling
436  */
437
438 /**************************************************************************
439  *              WNetGetError       [USER.519]
440  */
441 WORD WINAPI WNetGetError16( LPINT16 nError )
442 {
443     FIXME( "(%p): stub\n", nError );
444     return WN16_NOT_SUPPORTED;
445 }
446
447 /**************************************************************************
448  *              WNetGetErrorText       [USER.520]
449  */
450 WORD WINAPI WNetGetErrorText16( WORD nError, LPSTR lpBuffer, LPINT16 nBufferSize )
451 {
452     FIXME( "(%x, %p, %p): stub\n", nError, lpBuffer, nBufferSize );
453     return WN16_NET_ERROR;
454 }
455
456 /**************************************************************************
457  *              WNetErrorText       [USER.499]
458  */
459 WORD WINAPI WNetErrorText16( WORD nError, LPSTR lpszText, WORD cbText )
460 {
461     FIXME("(%x, %p, %x): stub\n", nError, lpszText, cbText );
462     return FALSE;
463 }
464