source: trunk/gui/printer/manager/PRINTOOL.VRX@ 62

Last change on this file since 62 was 58, checked in by Alex Taylor, 8 years ago

Incremented version to 0.7.
Fix population of shipped driver list when opening Install Driver dialog.
Fix installation of non-PostScript drivers from Drivers tab (parsing of DFFF EA type).
Refresh properly when deleting the only printer, driver, or port.
Add 'ArcaOS' to branding logic.
Added more logging (still needs work).

File size: 98.8 KB
Line 
1/*:VRX Main
2*/
3/* Main
4*/
5Main:
6/* Process the arguments.
7 Get the parent window.
8*/
9 parse source . calledAs .
10 parent = ""
11 argCount = arg()
12 argOff = 0
13 if( calledAs \= "COMMAND" )then do
14 if argCount >= 1 then do
15 parent = arg(1)
16 argCount = argCount - 1
17 argOff = 1
18 end
19 end; else do
20 call VROptions 'ImplicitNames'
21 call VROptions 'NoEchoQuit'
22 end
23 InitArgs.0 = argCount
24 if( argCount > 0 )then do i = 1 to argCount
25 InitArgs.i = arg( i + argOff )
26 end
27 drop calledAs argCount argOff
28
29/* Load the windows
30*/
31 call VRInit
32 parse source . . spec
33 _VREPrimaryWindowPath = ,
34 VRParseFileName( spec, "dpn" ) || ".VRW"
35 _VREPrimaryWindow = ,
36 VRLoad( parent, _VREPrimaryWindowPath )
37 drop parent spec
38 if( _VREPrimaryWindow == "" )then do
39 call VRMessage "", "Cannot load window:" VRError(), ,
40 "Error!"
41 _VREReturnValue = 32000
42 signal _VRELeaveMain
43 end
44
45/* Process events
46*/
47 call Init
48 signal on halt
49 do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
50 _VREEvent = VREvent()
51 interpret _VREEvent
52 end
53_VREHalt:
54 _VREReturnValue = Fini()
55 call VRDestroy _VREPrimaryWindow
56_VRELeaveMain:
57 call VRFini
58exit _VREReturnValue
59
60VRLoadSecondary:
61 __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
62 if __vrlsWait then do
63 call VRFlush
64 end
65 __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
66 if __vrlsHWnd = '' then signal __vrlsDone
67 if __vrlsWait \= 1 then signal __vrlsDone
68 call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
69 __vrlsTmp = __vrlsWindows.0
70 if( DataType(__vrlsTmp) \= 'NUM' ) then do
71 __vrlsTmp = 1
72 end
73 else do
74 __vrlsTmp = __vrlsTmp + 1
75 end
76 __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
77 __vrlsWindows.0 = __vrlsTmp
78 do while( VRIsValidObject( VRWindow() ) = 1 )
79 __vrlsEvent = VREvent()
80 interpret __vrlsEvent
81 end
82 __vrlsTmp = __vrlsWindows.0
83 __vrlsWindows.0 = __vrlsTmp - 1
84 call VRWindow __vrlsWindows.__vrlsTmp
85 __vrlsHWnd = ''
86__vrlsDone:
87return __vrlsHWnd
88
89/*:VRX __VXREXX____APPENDS__
90*/
91__VXREXX____APPENDS__:
92/*
93#append ..\..\Shared\PrManUtl.VRS
94*/
95return
96/*:VRX CheckPrograms
97*/
98CheckPrograms: PROCEDURE EXPOSE globals.
99
100 globals.!hascups = 0
101
102 /* See if CUPSLPR.EXE (required by CUPS.PDR) is installed.
103 */
104 tcpipbin = SysSearchPath('PATH', 'inetd.exe')
105 IF tcpipbin <> '' THEN
106 tcpipbin = VRParseFileName( tcpipbin, 'DP')
107 ELSE
108 tcpipbin = globals.!bootdrv'\TCPIP\BIN'
109 globals.!programs.!cupslpr = STREAM( tcpipbin'\cupslpr.exe', 'C', 'QUERY EXISTS')
110 IF globals.!programs.!cupslpr == '' THEN
111 globals.!programs.!cupslpr = SysSearchPath('PATH', 'cupslpr.exe')
112 IF globals.!programs.!cupslpr == '' THEN
113 globals.!programs.!cupslpr = STREAM( globals.!mydir'\cupslpr.exe', 'C', 'QUERY EXISTS')
114
115 /* See if CUPS.PDR is installed.
116 */
117 IF globals.!programs.!cupslpr <> '' THEN DO
118 cups_pdr = VRGetIni('PM_PORT_DRIVER', 'CUPS', 'System')
119 IF cups_pdr == '' THEN DO
120 cups_pdr = STREAM( globals.!bootdrv'\OS2\DLL\CUPS.PDR', 'C', 'QUERY EXISTS')
121 IF cups_pdr <> '' THEN CALL VRSetIni 'PM_PORT_DRIVER', 'CUPS', cups_pdr, 'System'
122 END
123 IF cups_pdr <> '' THEN
124 globals.!hascups = 1
125 END
126
127 /* See if GZIP.EXE is installed (required for unpacking CUPS PPDs).
128 */
129 globals.!programs.!gzip = SysSearchPath('PATH', 'gzip.exe')
130 IF globals.!programs.!gzip == '' THEN
131 globals.!programs.!gzip = SysSearchPath('PATH', 'gunzip.exe')
132 IF globals.!programs.!gzip == '' THEN
133 globals.!programs.!gzip = STREAM( globals.!mydir'\gzip.exe', 'C', 'QUERY EXISTS')
134
135 /* Try and find some other CUPS programs we use.
136 */
137 globals.!programs.!lpadmin = STREAM( globals.!cupsdir'\sbin\lpadmin.exe', 'C', 'QUERY EXISTS')
138 globals.!programs.!lpinfo = STREAM( globals.!cupsdir'\sbin\lpinfo.exe', 'C', 'QUERY EXISTS')
139 globals.!programs.!lpoptions = STREAM( globals.!cupsdir'\bin\lpoptions.exe', 'C', 'QUERY EXISTS')
140 globals.!programs.!lpstat = STREAM( globals.!cupsdir'\bin\lpstat.exe', 'C', 'QUERY EXISTS')
141
142RETURN
143
144/*:VRX CN_DEVICES_ContextMenu
145*/
146CN_DEVICES_ContextMenu: PROCEDURE EXPOSE globals.
147
148 _record = VRInfo("Record")
149 IF _record <> '' THEN DO
150 CALL VRMethod 'CN_DEVICES', 'SetRecordAttr', _record, 'Selected', 1
151 CALL VRMethod 'MN_DRIVERS', 'Popup'
152 END
153 ELSE
154 CALL VRMethod 'MN_CONTEXT', 'Popup'
155
156RETURN
157
158/*:VRX CN_DEVICES_KeyPress
159*/
160CN_DEVICES_KeyPress:
161 IF VRGet('CN_DEVICES', 'KeyString') == '{Backtab}' THEN
162 CALL VRMethod 'TDL_MAIN', 'SetFocus'
163return
164
165/*:VRX CN_PORTS_ContextMenu
166*/
167CN_PORTS_ContextMenu: PROCEDURE EXPOSE globals.
168
169 _record = VRInfo("Record")
170 IF _record <> '' THEN DO
171 CALL VRMethod 'CN_PORTS', 'SetRecordAttr', _record, 'Selected', 1
172 CALL VRMethod 'MN_PORT', 'Popup'
173 END
174 ELSE DO
175 CALL VRMethod 'MN_CONTEXT', 'Popup'
176 END
177
178RETURN
179
180/*:VRX CN_PORTS_KeyPress
181*/
182CN_PORTS_KeyPress:
183 IF VRGet('CN_PORTS', 'KeyString') == '{Backtab}' THEN
184 CALL VRMethod 'TDL_MAIN', 'SetFocus'
185return
186
187/*:VRX CN_PRINTERPAKS_ContextMenu
188*/
189CN_PRINTERPAKS_ContextMenu: PROCEDURE EXPOSE globals.
190 _record = VRInfo("Record")
191 IF _record <> '' THEN DO
192 CALL VRMethod 'CN_PRINTERPAKS', 'SetRecordAttr', _record, 'Selected', 1
193 CALL VRMethod 'MN_PRINTERPAK', 'Popup'
194 END
195RETURN
196
197/*:VRX CN_PRINTERS_ContextMenu
198*/
199CN_PRINTERS_ContextMenu: PROCEDURE EXPOSE globals.
200
201 _record = VRInfo("Record")
202 IF _record <> '' THEN DO
203 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', _record, 'Selected', 1
204 _flags = VRMethod('CN_PRINTERS', 'GetFieldData', _record, globals.!hcfPrinters.!flags )
205 IF POS('D', _flags ) > 0 THEN
206 CALL VRSet 'MI_PRINTER_DEFAULT', 'Checked', 1
207 ELSE
208 CALL VRSet 'MI_PRINTER_DEFAULT', 'Checked', 0
209 IF POS('P', _flags ) > 0 THEN
210 CALL VRSet 'MI_PRINTER_HOLD', 'Checked', 1
211 ELSE
212 CALL VRSet 'MI_PRINTER_HOLD', 'Checked', 0
213 CALL VRMethod 'MN_PRINTER', 'Popup'
214 END
215 ELSE
216 CALL VRMethod 'MN_CONTEXT', 'Popup'
217
218RETURN
219
220/*:VRX CN_PRINTERS_DoubleClick
221*/
222CN_PRINTERS_DoubleClick:
223 CALL PrinterOpen VRInfo("Record")
224RETURN
225
226/*:VRX CN_PRINTERS_KeyPress
227*/
228CN_PRINTERS_KeyPress:
229 IF VRGet('CN_PRINTERS', 'KeyString') == '{Backtab}' THEN
230 CALL VRMethod 'TDL_MAIN', 'SetFocus'
231RETURN
232
233/*:VRX CupsDeletePrinter
234*/
235CupsDeletePrinter: PROCEDURE EXPOSE globals.
236 PARSE ARG _host, _dest
237
238 IF globals.!programs.!lpadmin == '' THEN DO
239 CALL LINEOUT globals.!log1, 'lpadmin is not available, cannot delete CUPS queue.'
240 RETURN 0
241 END
242
243 IF TRANSLATE( _host ) <> 'LOCALHOST' THEN
244 del_cmd = globals.!programs.!lpadmin '-h' _host '-x' _dest
245 ELSE
246 del_cmd = globals.!programs.!lpadmin '-x' _dest
247 CALL LINEOUT globals.!log1, 'Delete CUPS destination' _dest' with:' del_cmd
248
249/*
250 nq = RXQUEUE('CREATE')
251 oq = RXQUEUE('SET', nq )
252 ADDRESS CMD '@' del_cmd '2>&1 | RXQUEUE' nq
253 DO QUEUED()
254 PARSE PULL _output
255 CALL LINEOUT globals.!log2, _output
256 IF LEFT( _output, 12 ) == 'Password for' & RIGHT( STRIP( _output ), 1 ) == '?' THEN DO
257 CALL SysSleep 1
258 PUSH '0d0a'x
259 END
260 END
261 CALL RXQUEUE 'SET', oq
262 CALL RXQUEUE 'DELETE', nq
263*/
264
265 _od = DIRECTORY()
266 CALL DIRECTORY VRParseFileName( globals.!programs.!lpadmin, 'DP')
267 ADDRESS CMD '@' del_cmd '2>&1 >>' globals.!log2
268 CALL DIRECTORY _od
269
270 CALL LINEOUT globals.!log2, ''
271 CALL LINEOUT globals.!log2
272 CALL LINEOUT globals.!log1, ''
273
274RETURN rc
275
276/*:VRX DDCB_DEVICE_3RDPARTY_Click
277*/
278DDCB_DEVICE_3RDPARTY_Click: PROCEDURE EXPOSE globals. shipped.
279 IF VRGet('DDCB_DEVICE_3RDPARTY', 'Enabled') == 0 THEN RETURN
280
281 new_path = TRANSLATE( STRIP( VRGet('DDCB_DEVICE_3RDPARTY', 'SelectedString')))
282 IF new_path == '' THEN RETURN
283
284 old_path = VRGet('DDCB_DEVICE_3RDPARTY', 'UserData')
285 IF old_path == new_path THEN RETURN
286
287 CALL SetDriverList new_path
288RETURN
289
290/*:VRX DDCB_DEVICE_3RDPARTY_Verify
291*/
292DDCB_DEVICE_3RDPARTY_Verify: PROCEDURE EXPOSE globals. shipped.
293 IF VRGet('DDCB_DEVICE_3RDPARTY', 'Enabled') == 0 THEN RETURN
294
295 old_path = VRGet('DDCB_DEVICE_3RDPARTY', 'UserData')
296 new_path = TRANSLATE( STRIP( VRGet('DDCB_DEVICE_3RDPARTY', 'Value')))
297 IF new_path == '' THEN DO
298 IF old_path <> '' THEN CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Value', old_path
299 RETURN
300 END
301
302 new_path = VRExpandFileName( new_path )
303 IF new_path == '' THEN DO
304 IF old_path <> '' THEN CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Value', old_path
305 RETURN
306 END
307
308 IF old_path == new_path THEN RETURN
309
310 CALL SetDriverList new_path
311RETURN
312
313/*:VRX DriverAdd
314*/
315DriverAdd: PROCEDURE EXPOSE globals.
316 updated = 0
317 CALL VRLoadSecondary 'SW_DEVICE_ADD', 'W'
318 IF updated == 1 THEN
319 CALL RefreshDevices
320RETURN
321
322/*:VRX DriverDelete
323*/
324DriverDelete: PROCEDURE EXPOSE globals.
325 PARSE ARG record
326 IF record == '' THEN DO
327 ok = VRMethod( "CN_DEVICES", "GetRecordList", "Selected", "recs." )
328 IF ok == 0 | recs.0 < 1 THEN RETURN
329 record = recs.1
330 END
331 CALL VRMethod 'CN_DEVICES', 'SetRecordAttr', record, 'Source', 0
332
333 _name = VRMethod('CN_DEVICES', 'GetFieldData', record, globals.!hcfDevices.!model )
334 _driver = VRMethod('CN_DEVICES', 'GetFieldData', record, globals.!hcfDevices.!driver )
335 IF _name == '' THEN RETURN
336 IF _driver == '' THEN RETURN
337
338 IF _driver == 'IBMNULL' THEN DO
339 CALL VRMessage 'WN_MAIN', NLSGetMessage( 212 ), NLSGetMessage( 209 ), 'W'
340 RETURN
341 END
342
343 device_name = _driver'.'_name
344 device_in_use = 0
345 printers.0 = 0
346 CALL RPUEnumPrinters 'printers.'
347 DO i = 1 TO printers.0
348 CALL RPUPrinterQuery printers.i.!name, 'details.'
349 CALL StringTokenize details.!drivers, ',', 'used_dev.'
350 DO j = 1 TO used_dev.0
351 IF used_dev.j == device_name THEN DO
352 device_in_use = 1
353 LEAVE
354 END
355 END
356 IF device_in_use == 1 THEN DO
357 _title = TRANSLATE( printers.i.!description, ' ', '0d0a'x)
358 CALL VRMessage 'WN_MAIN', NLSGetMessage( 208, device_name, _title ), NLSGetMessage( 209 ), 'W'
359 RETURN
360 END
361 END
362
363 _btns.0 = 2
364 _btns.1 = NLSGetMessage( 14 )
365 _btns.2 = NLSGetMessage( 15 )
366 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 203, device_name ), NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
367 IF _confirm == 1 THEN DO
368 success = DeletePrintDriver( _driver, _name )
369 CALL LINEOUT globals.!log1, 'Deleting installed driver' device_name':' success
370 IF success == 1 THEN CALL RefreshDevices
371
372 /* TODO check if any other _driver definitions exist and if not, offer to delete _driver files & profile */
373 END
374
375RETURN
376
377/*:VRX Fini
378*/
379Fini:
380 window = VRWindow()
381 call VRSet window, "Visible", 0
382 drop window
383return 0
384
385/*:VRX GetPrinterPaks
386*/
387GetPrinterPaks: PROCEDURE EXPOSE globals.
388 IF globals.!prdrv == '' THEN RETURN 0
389
390 IF globals.!oem_os == 1 THEN _osname = 'eComStation'
391 ELSE IF globals.!oem_os == 2 THEN _osname = 'ArcaOS'
392 ELSE _osname = 'OS/2'
393
394 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
395
396 _count = 0
397 DO WHILE LINES( globals.!prdrv ) > 0
398 /* Read the driver definition from PRDRV.LST
399 */
400 _ppdef = STRIP( LINEIN( globals.!prdrv ))
401 IF _ppdef == '' THEN ITERATE
402 PARSE VAR _ppdef _ppdriver _ppdisk _ppdesc
403 IF _ppdisk == '' THEN ITERATE
404 _ppdesc = STRIP( _ppdesc )
405 _pppath = globals.!repository'\PMDD_'_ppdisk
406
407 /* Check to see if the driver is installed/active.
408 */
409 _flags = 'R'
410 PARSE UPPER VAR _ppdriver _basename'.DRV' .
411 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', _basename, 'USER') WITH used_drv '00'x .
412 IF ( used_drv <> '') & VRFileExists( used_drv ) THEN DO
413 _ppicon = '$1:'used_drv
414 _ppstatus = NLSGetMessage( 177, _osname ) NLSGetMessage( 180 )
415 _flags = 'I'
416 END
417 ELSE IF VRFileExists( _pppath'\'_ppdriver ) THEN DO
418 _ppicon = '$1:'_pppath'\'_ppdriver
419 _ppstatus = NLSGetMessage( 177, _osname )
420 END
421 ELSE ITERATE
422
423 _pprev = BldLevelVersion( _pppath'\'_ppdriver )
424
425 /* Driver found, add the record.
426 */
427 _count = _count + 1
428 _fielddata = globals.!hcfPaks.!icon';'_ppicon';' ||,
429 globals.!hcfPaks.!name';'_ppdriver';' ||,
430 globals.!hcfPaks.!status';'_ppstatus';' ||,
431 globals.!hcfPaks.!path';'_pppath';' ||,
432 globals.!hcfPaks.!version';'_pprev';' ||,
433 globals.!hcfPaks.!desc';'_ppdesc';' ||,
434 globals.!hcfPaks.!flags';'_flags';'
435 ppaks._count = ';'_ppdriver';'_ppicon';;;'_fielddata
436 END
437 CALL STREAM globals.!prdrv, 'C', 'CLOSE'
438
439 /* Now look for some known third-party drivers.
440 */
441 PARSE UPPER VALUE VRGetIni('PrinterManager', 'ThirdParty', 'USER') WITH known_3p '00'x .
442 IF known_3p == '' THEN
443 known_3p = 'ECUPS ECUPS-HP GUTENPRT PSPRINT'
444 DO i = 1 TO WORDS( known_3p )
445 _basename = WORD( known_3p, i )
446 _ppini = VRGetIni('PM_INSTALL', _basename'_DIR', 'USER')
447 IF _ppini == '' THEN ITERATE
448 PARSE VAR _ppini _pppath '00'x .
449
450 /* Check to see if the driver is installed/active.
451 */
452 _flags = ''
453 _ppdriver = _basename'.DRV'
454 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', _basename, 'USER') WITH used_drv '00'x .
455 IF ( used_drv <> '') & VRFileExists( used_drv ) THEN DO
456 _ppicon = '$1:'used_drv
457 _ppstatus = NLSGetMessage( 178 ) NLSGetMessage( 180 )
458 _flags = 'I'
459 END
460 ELSE IF VRFileExists( _pppath'\'_ppdriver ) THEN DO
461 _ppicon = '$1:'_pppath'\'_ppdriver
462 _ppstatus = NLSGetMessage( 178 )
463 END
464 ELSE ITERATE
465
466 _pprev = BldLevelVersion( _pppath'\'_ppdriver )
467
468 /* Driver found, add the record.
469 */
470 _count = _count + 1
471 _fielddata = globals.!hcfPaks.!icon';'_ppicon';' ||,
472 globals.!hcfPaks.!name';'_ppdriver';' ||,
473 globals.!hcfPaks.!status';'_ppstatus';' ||,
474 globals.!hcfPaks.!path';'_pppath';' ||,
475 globals.!hcfPaks.!version';'_pprev';' ||,
476 globals.!hcfPaks.!flags';'_flags';'
477 ppaks._count = ';'_ppdriver';'_ppicon';;;'_fielddata
478 END
479
480 ppaks.0 = _count
481
482 CALL VRMethod 'CN_PRINTERPAKS', 'RemoveRecord', 'All'
483 CALL VRMethod 'CN_PRINTERPAKS', 'AddRecordList',, 'Last', 'ppaks.'
484
485 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
486
487RETURN _count
488
489/*:VRX GetShippedDrivers
490*/
491GetShippedDrivers: PROCEDURE EXPOSE globals. shipped.
492
493 count = 0
494 CALL LINEIN globals.!prdesc, 1, 0
495 DO WHILE LINES( globals.!prdesc )
496 _next = LINEIN( globals.!prdesc )
497 PARSE VAR _next _desc':' _rest
498 _lp = LASTPOS('(', _rest )
499 IF _lp == 0 THEN ITERATE
500 _ppak = SUBSTR( _rest, _lp )
501 PARSE VAR _ppak '('_drvr')' .
502 count = count + 1
503 shipped.count = ';'_desc';#2;;;NAME;'_desc';DRIVER;'_drvr';'
504 END
505 CALL STREAM globals.!prdesc, 'C', 'CLOSE'
506 shipped.0 = count
507 CALL VRSortStem 'shipped.'
508
509 CALL LINEOUT globals.!log1, 'Enumerated' count 'shipped printer devices.'
510
511RETURN count
512
513/*:VRX Halt
514*/
515Halt:
516 signal _VREHalt
517return
518
519/*:VRX ImportPPD
520*/
521/* Import a new PPD file into a PostScript driver. This is unfortunately rather
522 * complicated, all the more so because we need to deal with a large number of
523 * possible situations.
524 */
525ImportPPD: PROCEDURE EXPOSE globals. driver_path
526 ARG driver, ppdfile
527 IF driver == '' THEN driver = 'PSCRIPT'
528
529 CALL LINEOUT globals.!log1, 'Going to import PPD file into driver' driver'.'
530
531 status = LocateDriverFiles( driver )
532
533 SELECT
534
535 /* An installable copy of the driver was found. No special action is
536 * required; we can proceed with the import logic below.
537 */
538 WHEN status == 1 THEN NOP
539
540 /* An installable (distribution) copy of the driver could not be located,
541 * but we found an installed (in use) version whence we can grab the files.
542 */
543 WHEN status == 2 THEN DO
544 /* We need somewhere for the installable copies to live. We ask
545 * the user to confirm this path, as they'll have to specify the
546 * directory later on if they install the driver from PM.
547 */
548 _btn.1 = NLSGetMessage( 2 )
549 _btn.2 = NLSGetMessage( 3 )
550 _btn.3 = NLSGetMessage( 188 )
551 _btn.0 = 3
552 _prompt = NLSGetMessage( 232, driver ) ||,
553 '0a0a0a'x || NLSGetMessage( 187, driver )
554
555 /* Try and determine a suitable default directory */
556 PARSE VALUE VRGetIni('PM_INSTALL', driver'_DIR', 'USER') WITH drvr_dir '00'x .
557 IF drvr_dir == '' THEN
558 PARSE VALUE VRGetIni('InstPDR', 'PATH_TO_'driver, 'USER') WITH drvr_dir '00'x .
559 IF drvr_dir == '' THEN
560 drvr_dir = globals.!repository'\'driver
561
562 /* Now prompt the user to confirm the path */
563 DO UNTIL _select <> 3
564 _select = VRPrompt( VRWindow(), _prompt, 'drvr_dir',,
565 NLSGetMessage( 189 ), '_btn.', 1, 2 )
566 IF _select == 3 THEN
567 drv_dir = VRXDirectoryDialog( VRWindow(), drvr_dir, NLSGetMessage( 189 ))
568 END
569 IF drvr_dir == '' THEN RETURN 1 /** RC=1 cancelled */
570 drvr_dir = VRExpandFileName( drvr_dir )
571 IF drvr_dir == '' THEN RETURN 3 /** RC=3 bad path */
572
573 /* Create the new directory if necessary */
574 IF \VRIsDir( drvr_dir ) THEN
575 IF VRMkDir( drvr_dir ) == 0 THEN RETURN 5 /** RC=5 failed to create directory */
576
577 /* Now copy the driver files */
578 IF CopyPrinterPak( driver_path, drvr_dir ) == 0 THEN RETURN 3 /** RC=4 failed to copy driver files */
579 CALL VRSetIni 'PM_INSTALL', driver'_DIR', drvr_dir||'00'x, 'USER'
580
581 /* Point to the copied driver files as our new working copy */
582 driver_path = drvr_dir'\'driver'.DRV'
583 END
584
585 OTHERWISE DO /* Driver was not found */
586 CALL VRMessage VRWindow(), NLSGetMessage( 231, driver ),,
587 NLSGetMessage( 13 ), 'E'
588 RETURN 2 /** RC=2 driver not found */
589 END
590
591 END
592
593 /* OK, we should now have an acceptable 'installable' copy of the
594 * PrinterPak files. Next, we will:
595 * - Create a temporary working directory & copy the PrinterPak files there
596 * - Pre-process the PPD file to make it ready for import, and also copy it
597 * to a driver-specific 'saved PPDs' directory for future use
598 * - Use PIN to import the PPD into into our temporary working copy
599 * - Copy the updated driver back to our installable copy
600 * - If the driver is actually installed, copy the updated driver back over
601 * the installed version as well.
602 * - If this is a 'shipped' driver (i.e. one listed in PRDRV.LST) then add
603 * the newly-defined printer to PRDESC.LST.
604 */
605
606/**** Moved all below this into a shared function
607
608 CALL LINEOUT globals.!log1, 'Driver source: ' driver_path
609
610 workdir = SysTempFileName( globals.!tmpdir'\PPD_????')
611 ok = VRMkDir( workdir )
612 IF ok == 1 THEN ok = VrMkDir( workdir'\OUT')
613 IF ok <> 1 THEN
614 RETURN 5 /** RC=5 failed to create directory */
615
616 CALL LINEOUT globals.!log1, 'Temporary directory: ' workdir
617
618 SELECT
619 WHEN driver == 'ECUPS' THEN ppddir = globals.!repository'\PPD_E'
620 WHEN driver == 'ECUPS-HP' THEN ppddir = globals.!repository'\PPD_EHP'
621 WHEN driver == 'PSPRINT' THEN ppddir = globals.!repository'\PPD_PS'
622 WHEN driver == 'PSPRINT2' THEN ppddir = globals.!repository'\PPD_PS2'
623 WHEN driver == 'PSCRIPT2' THEN ppddir = globals.!repository'\PPD2'
624 WHEN driver == 'GUTENPRT' THEN ppddir = globals.!repository'\PPD_GP'
625 OTHERWISE ppddir = globals.!repository'\PPD'
626 END
627
628 /* Make sure ppddir (for keeping PPD files) exists */
629 CALL SysFileTree ppddir, 'dirs.', 'DO'
630 IF dirs.0 == 0 THEN DO
631 ok = VRMkDir( ppddir )
632 IF ok <> 1 THEN
633 RETURN 5 /** RC=5 failed to create directory */
634 END
635
636 CALL LINEOUT globals.!log1, 'Directory for PPD files:' ppddir
637
638 /***
639 *** Now do the actual work.
640 ***/
641
642
643 /* Copy the needed driver files to our working directories.
644 */
645 drvr_dir = VRParseFileName( driver_path, 'DP')
646 drv_out = workdir'\OUT\'driver'.DRV'
647 pin_exe = workdir'\PIN.EXE'
648 ppd_exe = workdir'\PPDENC.EXE'
649 ok = VRCopyFile( driver_path, drv_out )
650 IF ok == 1 THEN ok = VRCopyFile( drvr_dir'\PIN.EXE', pin_exe )
651 IF ok == 1 THEN ok = VRCopyFile( drvr_dir'\PPDENC.EXE', ppd_exe )
652 IF ok == 0 THEN DO
653 RETURN 4 /*** RC=4 Failed to copy driver files ***/
654 END
655
656 /* Set up the output redirection.
657 */
658 nq = RXQUEUE('CREATE')
659 oq = RXQUEUE('SET', nq )
660
661 /* If the PPD file is compressed, uncompress it.
662 */
663 IF VRParseFilePath( ppdfile, 'E') == 'GZ' THEN DO
664 decppd = workdir'\' || VRParseFilePath( ppdfile, 'N')
665 CALL LINEOUT globals.!log1, 'Decompressing' ppdfile 'to' decppd
666 ADDRESS CMD '@'globals.!programs.!gzip '-c -d' ppdfile '| RXQUEUE' nq
667 DO QUEUED()
668 PARSE PULL line
669 CALL LINEOUT decppd, line
670 END
671 CALL LINEOUT decppd
672 ppdfile = decppd
673 END
674
675 IF VRFileExists( ppdfile ) == 0 THEN DO
676 CALL LINEOUT globals.!log1, 'PPD file' ppdfile 'could not be found.'
677 RETURN 6 /** RC=6 PPD import failed **/
678 END
679
680 ppd_use = ppddir'\' || VRParseFileName( ppdfile, 'NE')
681
682 /* Now we have to clean up and validate the PPD file so PIN can use it.
683 * First, PPDENC converts the codepage if necessary, and copies the results
684 * to our working directory.
685 */
686 CALL LINEOUT globals.!log1, 'Converting PPD with:' ppd_exe ppdfile ppd_use
687 ADDRESS CMD '@'ppd_exe ppdfile ppd_use '2>NUL | RXQUEUE' nq
688 DO QUEUED()
689 PULL output
690 CALL LINEOUT globals.!log2, output
691 END
692 CALL LINEOUT globals.!log2, ''
693 CALL LINEOUT globals.!log2
694
695 IF VRFileExists( ppd_use ) == 0 THEN DO
696 CALL LINEOUT globals.!log1, 'Hmm,' ppd_use 'was not created. Copying manually.'
697 CALL VRCopyFile ppdfile, ppd_use
698 END
699
700 /* Next we strip out some problematic PPD statements which are often
701 * encountered in (for example) CUPS-based PPD files.
702 */
703 CALL CleanPPD ppd_use, globals.!log1
704
705 /* Preparation complete. Now do the import.
706 */
707 count = 0
708 ADDRESS CMD '@'pin_exe 'ppd' ppddir drv_out '2>NUL | RXQUEUE' nq
709 DO QUEUED()
710 PARSE PULL output
711 CALL LINEOUT globals.!log2, output
712 PARSE VAR output . 'OK (' nickname
713 IF nickname <> '' THEN DO
714 count = count + 1
715 newprinters.count = STRIP( nickname, 'T', ')')
716 END
717 END
718 newprinters.0 = count
719 CALL LINEOUT globals.!log2, ''
720 CALL LINEOUT globals.!log2
721
722 /* End the output redirection.
723 */
724 CALL RXQUEUE 'SET', oq
725 CALL RXQUEUE 'DELETE', nq
726
727
728 /***
729 *** Post-import processing.
730 ***/
731
732 IF newprinters.0 == 0 THEN DO
733 RETURN 6 /** RC=6 PPD import failed **/
734 END
735
736 IF driver_repo == 1 THEN DO
737 /* If we're working out of the repository, we need to update the
738 * driver table in PRDESC.LST to add the new driver(s).
739 */
740
741 CALL LINEOUT globals.!log1, 'Updating' globals.!prdesc 'with new entries from' drv_out
742
743/* -- This causes a SYS3175 in the .DRV for some reason...
744 ok = UpdatePrDesc( driver'.DRV', drv_out )
745 IF ok <> 0 THEN
746 CALL LINEOUT globals.!log1, 'Failed to update' globals.!prdesc '(are EAs on' drv_out ' valid?)'
747*/
748
749 count = 0
750
751 /* First, copy all lines that don't refer to the driver just updated */
752 CALL LINEIN globals.!prdesc, 1, 0
753 DO WHILE LINES( globals.!prdesc )
754 _next = LINEIN( globals.!prdesc )
755 PARSE UPPER VAR _next . ':' _rest
756 _tail = SUBSTR( _rest, LASTPOS('(', _rest ))
757 PARSE VAR _tail '('_prdrv')' .
758 IF _prdrv == driver'.DRV' THEN ITERATE
759 count = count + 1
760 defs.count = _next
761 END
762 CALL STREAM globals.!prdesc, 'C', 'CLOSE'
763
764 /* Next, create a new list for the updated driver and merge that in */
765 newlist = workdir'\'driver'.LST'
766 CALL CreateDriverList drv_out, newlist
767 DO WHILE LINES( newlist )
768 _line = LINEIN( newlist )
769 count = count + 1
770 defs.count = _line
771 END
772 CALL STREAM newlist, 'C', 'CLOSE'
773 defs.0 = count
774
775 /* Now sort the list and recreate PRDESC.LST */
776 CALL SysStemSort 'defs.',, 'I'
777 prdesc_tmp = workdir'\PRDESC.LST'
778 IF STREAM( prdesc_tmp, 'C', 'QUERY EXISTS') <> '' THEN
779 CALL VRDeleteFile prdesc_tmp
780 DO i = 1 TO defs.0
781 CALL LINEOUT prdesc_tmp, defs.i
782 END
783 CALL LINEOUT prdesc_tmp
784 ok = VRCopyFile( prdesc_tmp, globals.!prdesc )
785 IF ok == 0 THEN DO
786 RETURN 7 /** RC=7 Error updating PRDESC.LST **/
787 END
788 CALL VRDeleteFile prdesc_tmp
789
790 END
791
792 /* Finally, copy the updated driver files.
793 */
794 target = VRParseFilePath( driver_path, 'DP')
795 CALL LINEOUT globals.!log1, 'Copying files from' workdir'\OUT to' target
796 CALL PRReplaceModule target'\'driver'.DRV', '', ''
797 ok = VRCopyFile( workdir'\OUT\'driver'.DRV', target'\'driver'.DRV')
798 IF ok == 1 THEN
799 ok = VRCopyFile( workdir'\OUT\AUXPRINT.PAK', target'\AUXPRINT.PAK')
800
801 IF ok == 1 THEN DO
802 /* Copy the updated files to \OS2\DLL\<driver>, replacing any
803 * existing copies. (This prevents problems if the OS/2 driver
804 * installation fails to copy them, which can happen under some
805 * circumstances.)
806 */
807 IF VRFileExists( globals.!os2dir'\DLL\'driver'\'driver'.DRV') THEN DO
808 CALL VRCopyFile workdir'\OUT\AUXPRINT.PAK',,
809 globals.!os2dir'\DLL\'driver'\AUXPRINT.PAK'
810 CALL PRReplaceModule globals.!os2dir'\DLL\'driver'\'driver'.DRV', '', ''
811 CALL VRCopyFile workdir'\OUT\'driver'.DRV', globals.!os2dir'\DLL\'driver'\'driver'.DRV'
812 END
813 END
814 IF ok == 0 THEN DO
815 CALL LINEOUT globals.!log1, VRError()
816 RETURN 4 /*** RC=4 Failed to copy driver files ***/
817 END
818
819 CALL LINEOUT globals.!log1, newprinters.0 'printers imported successfully.'
820 DO i = 1 TO newprinters.0
821 CALL LINEOUT globals.!log1, ' ->' newprinters.i
822 END
823 CALL LINEOUT globals.!log1, ''
824 CALL LINEOUT globals.!log1
825
826 /* Clean up our work directories.
827 */
828 CALL VRDeleteFile workdir'\OUT\*'
829 CALL VRDeleteFile workdir'\*'
830 CALL VRRmDir( workdir'\OUT')
831 CALL VRRmDir( workdir )
832
833****/
834
835 ok = PinWrapper( 1, driver, ppdfile )
836
837RETURN ok
838
839/*:VRX Init
840*/
841Init:
842 /* Hide the VX-REXX console window
843 */
844 CALL VRSet 'Console', 'WindowListTitle', ''
845
846 CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
847 CALL SysLoadFuncs
848 CALL RxFuncAdd 'RPULoadFuncs', 'RXPRTUTL', 'RPULoadFuncs'
849 CALL RPULoadFuncs
850 CALL RxFuncAdd 'PRLoadFuncs', 'PR1UTIL', 'PRLoadFuncs'
851 CALL PRLoadFuncs
852 CALL RxFuncAdd 'WPToolsLoadFuncs', 'WPTOOLS', 'WPToolsLoadFuncs'
853 CALL WPToolsLoadFuncs
854 CALL RxFuncAdd 'VRXLoadFuncs', 'VROBJEX', 'VRXLoadFuncs'
855 CALL VRXLoadFuncs
856
857 globals.!wizard = 0
858 globals.!debug = 0
859 globals.!initstate = 0
860
861 DO i = 1 TO InitArgs.0
862 PARSE UPPER VAR InitArgs.i _arg
863 SELECT
864 WHEN _arg == '/CREATE' THEN globals.!wizard = 1
865 WHEN LEFT( _arg, 2 ) == '/D' THEN globals.!debug = 1
866 OTHERWISE NOP
867 END
868 END
869
870 CALL LoadSettings
871 CALL SetLanguage
872 CALL CheckPrograms
873
874 window = VRWindow()
875 call VRMethod window, "CenterWindow"
876 call VRMethod window, "Activate"
877 IF globals.!wizard THEN DO
878 CALL VRMethod 'Application', 'PostQueue', 0, 1, 'CALL PB_PRINTER_ADD_Click'
879 END
880 ELSE DO
881 CALL VRSet window, "Visible", 1
882 CALL VRMethod 'TDL_MAIN', 'SetFocus'
883 END
884 drop window
885
886RETURN
887
888/*:VRX InitMessageLog
889*/
890/* Initialize the message logfile. Unlike the error log, which is cleared and
891 * recreated every time the program starts, the message log is appended to
892 * until it reaches 100kB in size. If the message log is larger than 100kB when
893 * this function is called, it is renamed (with '~' appended to the name) and
894 * a new message log is started.
895 */
896InitMessageLog: PROCEDURE EXPOSE globals.
897
898 logsize = STREAM( globals.!log1, 'C', 'QUERY SIZE')
899 IF ( logsize <> '') & ( logsize > 102400 ) THEN DO
900 CALL VRCopyFile globals.!log1, globals.!log1 || '~'
901 CALL VRDeleteFile globals.!log1
902 END
903
904 datestr = DATE('L') TIME('N')
905 CALL LINEOUT globals.!log1, '--[' datestr ']' ||,
906 COPIES('-', 73 - LENGTH( datestr ))
907RETURN
908
909/*:VRX LoadSettings
910*/
911LoadSettings: PROCEDURE EXPOSE globals.
912
913 globals.!version = '0.7'
914 globals.!copyright = '2013-2017'
915
916 me = VRGet('Application', 'Program')
917 IF me == '' THEN PARSE SOURCE . . me
918 globals.!mydir = VRParseFilePath( me, 'DP')
919
920 /* Get CUPS paths.
921 */
922 PARSE VALUE VRGetIni('eCups', 'CUPS', 'USER') WITH cupsdrv '00'x .
923 IF cupsdrv == '' THEN
924 cupsdrv = VRParseFilePath( me, 'D') || ':'
925 ELSE
926 cupsdrv = STRIP( cupsdrv, 'T', '\')
927 globals.!cupsdir = cupsdrv'\cups'
928 IF \VRIsDir( globals.!cupsdir ) THEN DO
929 unixroot = VALUE('UNIXROOT',,'OS2ENVIRONMENT')
930 IF unixroot <> '' THEN
931 globals.!cupsdir = unixroot'\usr'
932 ELSE
933 globals.!cupsdir = cupsdrv'\usr'
934 END
935
936 /* Get system paths.
937 */
938 globals.!bootdrv = SysBootDrive()
939 IF globals.!bootdrv == '' THEN
940 globals.!bootdrv = FILESPEC('DRIVE', VALUE('OS2_SHELL',,'OS2ENVIRONMENT'))
941 globals.!os2dir = globals.!bootdrv'\OS2'
942 globals.!tmpdir = VALUE('TMP',,'OS2ENVIRONMENT')
943 IF globals.!tmpdir == '' THEN
944 globals.!tmpdir = VALUE('TEMP',,'OS2ENVIRONMENT')
945 IF globals.!tmpdir == '' THEN
946 globals.!tmpdir = globals.!mydir
947 globals.!logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT')
948 IF globals.!logdir == '' THEN
949 globals.!logdir = globals.!mydir
950
951 globals.!log1 = globals.!logdir'\printman.l1'
952 globals.!log2 = globals.!logdir'\printman.l2'
953 CALL InitMessageLog
954 IF VRFileExists( globals.!log2 ) THEN
955 CALL VRDeleteFile globals.!log2
956
957
958 /* Get printer-related paths.
959 */
960 PARSE VALUE VRGetIni('PM_INSTALL', 'PDR_DIR', 'USER') WITH repos_dir '00'x .
961 globals.!repository = repos_dir
962 globals.!prdrv = STREAM( globals.!os2dir'\install\prdrv.lst', 'C', 'QUERY EXISTS')
963 globals.!prdesc = STREAM( globals.!os2dir'\install\prdesc.lst', 'C', 'QUERY EXISTS')
964
965 /* Set the language file name.
966 */
967 globals.!nlsname = 'printm'
968
969 /* Determine the OS.
970 */
971 globals.!oem_os = 0
972 oem_osdir = VALUE('OSDIR',,'OS2ENVIRONMENT')
973 IF oem_osdir == '' THEN oem_osdir = globals.!os2dir
974 IF VRFileExists( globals.!os2dir'\INSTALL\SYSLEVEL.ECS') THEN
975 globals.!oem_os = 1
976 IF VRFileExists( oem_osdir'\INSTALL\INSTALL.FLG') THEN DO
977 PARSE VALUE LINEIN( oem_osdir'\INSTALL\INSTALL.FLG') WITH p_os p_release p_nlv .
978 CALL STREAM oem_osdir'\INSTALL\INSTALL.FLG', 'C', 'CLOSE'
979 IF p_os == 'ArcaOS' THEN globals.!oem_os = 2
980 END
981
982 globals.!create_mode = ''
983
984RETURN
985
986/*:VRX MI_ABOUT_Click
987*/
988MI_ABOUT_Click:
989 CALL VRLoadSecondary 'SW_ABOUT', 'W'
990RETURN
991
992/*:VRX MI_CONTEXT_DETAIL_Click
993*/
994MI_CONTEXT_DETAIL_Click: PROCEDURE EXPOSE globals.
995 CALL MI_DETAILVIEW_Click
996RETURN
997
998/*:VRX MI_CONTEXT_ICON_Click
999*/
1000MI_CONTEXT_ICON_Click: PROCEDURE EXPOSE globals.
1001 CALL MI_ICONVIEW_Click
1002RETURN
1003
1004
1005/*:VRX MI_CONTEXT_INSTALL_Click
1006*/
1007MI_CONTEXT_INSTALL_Click: PROCEDURE EXPOSE globals.
1008
1009 _page = VRGet('TDL_MAIN', 'Selected')
1010 _pagewin = VRMethod('TDL_MAIN', 'GetPageWindow', _page )
1011 _cnr = VRGet( _pagewin, 'UserData')
1012 IF _cnr == '' THEN RETURN
1013
1014 CALL VRSet _cnr, 'Source', 0
1015
1016 SELECT
1017 WHEN _cnr == 'CN_PRINTERS' THEN CALL PrinterWizard
1018 WHEN _cnr == 'CN_PORTS' THEN CALL PortAdd
1019 WHEN _cnr == 'CN_DEVICES' THEN CALL DriverAdd
1020 OTHERWISE NOP
1021 END
1022
1023RETURN
1024
1025/*:VRX MI_CONTEXT_REFRESH_Click
1026*/
1027MI_CONTEXT_REFRESH_Click: PROCEDURE EXPOSE globals.
1028 CALL MI_REFRESH_Click
1029RETURN
1030
1031/*:VRX MI_DETAILVIEW_Click
1032*/
1033MI_DETAILVIEW_Click: PROCEDURE EXPOSE globals.
1034
1035 _page = VRGet('TDL_MAIN', 'Selected')
1036 _pagewin = VRMethod('TDL_MAIN', 'GetPageWindow', _page )
1037 _cnr = VRGet( _pagewin, 'UserData')
1038 IF _cnr == '' THEN RETURN
1039
1040 CALL VRSet _cnr, 'Source', 0
1041 _set = VRGet('MI_DETAILVIEW', 'Checked')
1042 IF _set == 1 THEN RETURN
1043
1044 CALL VRSet _cnr, 'View', 'Detail'
1045 CALL VRSet _cnr, 'MiniIcons', 1
1046
1047 CALL VRSet 'MI_ICONVIEW', 'Checked', 0
1048 CALL VRSet 'MI_CONTEXT_ICON', 'Checked', 0
1049 CALL VRSet 'MI_DETAILVIEW', 'Checked', 1
1050 CALL VRSet 'MI_CONTEXT_DETAIL','Checked', 1
1051
1052RETURN
1053
1054/*:VRX MI_DRIVERS_INSTALL_Click
1055*/
1056MI_DRIVERS_INSTALL_Click:
1057 CALL DriverAdd
1058return
1059
1060/*:VRX MI_DRIVERS_REMOVE_Click
1061*/
1062MI_DRIVERS_REMOVE_Click:
1063 CALL DriverDelete
1064return
1065
1066/*:VRX MI_ICONVIEW_Click
1067*/
1068MI_ICONVIEW_Click: PROCEDURE EXPOSE globals.
1069
1070 _page = VRGet('TDL_MAIN', 'Selected')
1071 _pagewin = VRMethod('TDL_MAIN', 'GetPageWindow', _page )
1072 _cnr = VRGet( _pagewin, 'UserData')
1073 IF _cnr == '' THEN RETURN
1074
1075 CALL VRSet _cnr, 'Source', 0
1076 _set = VRGet('MI_ICONVIEW', 'Checked')
1077 IF _set == 1 THEN RETURN
1078
1079 CALL VRSet _cnr, 'View', 'Icon'
1080 CALL VRSet _cnr, 'MiniIcons', 0
1081
1082 CALL VRSet 'MI_ICONVIEW', 'Checked', 1
1083 CALL VRSet 'MI_CONTEXT_ICON', 'Checked', 1
1084 CALL VRSet 'MI_DETAILVIEW', 'Checked', 0
1085 CALL VRSet 'MI_CONTEXT_DETAIL', 'Checked', 0
1086
1087RETURN
1088
1089/*:VRX MI_IMPORT_Click
1090*/
1091MI_IMPORT_Click: PROCEDURE EXPOSE globals. new_ppd
1092
1093 /* Prompt the user for the PPD file to import.
1094 */
1095 new_ppd = VRFileDialog( VRWindow(), NLSGetMessage( 230 ), 'O', '*.PPD')
1096 IF new_ppd == '' THEN RETURN 0
1097
1098 /* Let the user select the Postscript driver to update.
1099 */
1100 CALL VRLoadSecondary 'SW_IMPORT', 'W'
1101
1102RETURN ok
1103
1104/*:VRX MI_MANAGE_Click
1105*/
1106MI_MANAGE_Click: PROCEDURE EXPOSE globals.
1107 CALL VRLoadSecondary 'SW_PRINTERPAKS', 'W'
1108RETURN
1109
1110/*:VRX MI_PORT_CREATE_Click
1111*/
1112MI_PORT_CREATE_Click:
1113 CALL PortAdd
1114return
1115
1116/*:VRX MI_PORT_DELETE_Click
1117*/
1118MI_PORT_DELETE_Click:
1119 CALL PortDelete
1120return
1121
1122/*:VRX MI_PORT_PROPS_Click
1123*/
1124MI_PORT_PROPS_Click:
1125 CALL PortProperties
1126RETURN
1127
1128/*:VRX MI_PPAK_COPY_Click
1129*/
1130MI_PPAK_COPY_Click:
1131 ok = VRMethod( "CN_PRINTERPAKS", "GetRecordList", "Selected", "recs." )
1132 IF ok == 0 | recs.0 < 1 THEN RETURN
1133 record = recs.1
1134
1135 _path = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!path )
1136 CALL VRMethod 'Application', 'PutClipboard', _path
1137
1138 CALL VRMethod 'CN_PRINTERPAKS', 'SetRecordAttr', record, 'Source', 0
1139RETURN
1140
1141/*:VRX MI_PPAK_MODELS_Click
1142*/
1143MI_PPAK_MODELS_Click: PROCEDURE EXPOSE globals.
1144
1145 ok = VRMethod( "CN_PRINTERPAKS", "GetRecordList", "Selected", "recs." )
1146 IF ok == 0 | recs.0 < 1 THEN RETURN
1147 CALL VRMethod 'CN_PRINTERPAKS', 'SetRecordAttr', recs.1, 'Source', 0
1148
1149 CALL VRLoadSecondary 'SW_MODELS', 'W'
1150
1151RETURN
1152
1153/*:VRX MI_PRINTER_CREATE_Click
1154*/
1155MI_PRINTER_CREATE_Click:
1156 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1157 IF ok == 1 & recs.0 > 0 THEN
1158 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', recs.1, 'Source', 0
1159 CALL PrinterWizard
1160RETURN
1161
1162/*:VRX MI_PRINTER_DEFAULT_Click
1163*/
1164MI_PRINTER_DEFAULT_Click:
1165 CALL PrinterSetDefault
1166RETURN
1167
1168/*:VRX MI_PRINTER_DELETE_Click
1169*/
1170MI_PRINTER_DELETE_Click:
1171 CALL PrinterDelete
1172RETURN
1173
1174/*:VRX MI_PRINTER_HOLD_Click
1175*/
1176MI_PRINTER_HOLD_Click:
1177 CALL PrinterHold
1178return
1179
1180/*:VRX MI_PRINTER_OPEN_Click
1181*/
1182MI_PRINTER_OPEN_Click:
1183 CALL PrinterOpen
1184RETURN
1185
1186/*:VRX MI_PRINTER_PROPS_Click
1187*/
1188MI_PRINTER_PROPS_Click:
1189 CALL PrinterProperties
1190RETURN
1191
1192/*:VRX MI_QUIT_Click
1193*/
1194MI_QUIT_Click:
1195 CALL Quit
1196return
1197
1198/*:VRX MI_REFRESH_Click
1199*/
1200MI_REFRESH_Click: PROCEDURE EXPOSE globals.
1201
1202 _page = VRGet('TDL_MAIN', 'Selected')
1203 _pagewin = VRMethod('TDL_MAIN', 'GetPageWindow', _page )
1204 _cnr = VRGet( _pagewin, 'UserData')
1205 IF _cnr == '' THEN RETURN
1206
1207 CALL VRSet _cnr, 'Source', 0
1208
1209 SELECT
1210 WHEN _cnr == 'CN_PRINTERS' THEN CALL RefreshPrinters
1211 WHEN _cnr == 'CN_PORTS' THEN CALL RefreshPorts
1212 WHEN _cnr == 'CN_DEVICES' THEN CALL RefreshDevices
1213 OTHERWISE NOP
1214 END
1215
1216RETURN
1217
1218/*:VRX New_CUPS
1219*/
1220New_CUPS: PROCEDURE EXPOSE globals.
1221 PARSE ARG ppd_file
1222
1223 IF WPToolsQueryObject('<ECUPS_WIZARD>',,,'SetupString') == 1 THEN DO
1224 PARSE VAR SetupString . 'EXENAME='cupswiz';' .
1225 PARSE VAR SetupString . 'STARTUPDIR='_workdir';' .
1226 PARSE VAR SetupString . 'PARAMETERS='_parms';' .
1227 IF _workdir == '' THEN _workdir = VRParseFilePath( cupswiz, 'DP')
1228 END
1229 ELSE DO
1230 cupswiz = Stream( globals.!cupsdir'\cupswiz.exe', 'C', 'QUERY EXISTS')
1231 _workdir = VRParseFilePath( cupswiz, 'DP')
1232 _parms = ''
1233 END
1234 IF cupswiz <> '' THEN DO
1235 od = DIRECTORY()
1236 CALL DIRECTORY _workdir
1237 IF ppd_file <> '' & VRFileExists( ppd_file ) THEN
1238 _parms = _parms ppd_file
1239 CALL LINEOUT globals.!log1, 'Launching CUPS wizard with: start' cupswiz _parms
1240 ADDRESS CMD 'start' cupswiz _parms
1241 CALL DIRECTORY od
1242 CALL Quit
1243 END
1244 ELSE DO
1245 CALL LINEOUT globals.!log1, 'Failed to locate CUPS wizard.'
1246 END
1247
1248
1249RETURN
1250
1251/*:VRX New_LAN
1252*/
1253New_LAN: PROCEDURE EXPOSE globals.
1254
1255 ok = OpenPrinterTemplate('WPRPrinter')
1256 CALL Quit
1257
1258RETURN ok
1259
1260/*:VRX New_Standard
1261*/
1262New_Standard: PROCEDURE EXPOSE globals.
1263
1264 ok = OpenPrinterTemplate('WPPrinter')
1265 CALL Quit
1266
1267RETURN ok
1268
1269/*:VRX OpenPrinterTemplate
1270*/
1271OpenPrinterTemplate: PROCEDURE EXPOSE globals.
1272 PARSE ARG _class
1273
1274 ok = 0
1275 IF WPToolsFolderContent('<WP_TEMPS>', '_temps.', 'F') THEN
1276 DO i = 1 TO _temps.0
1277 IF WPToolsQueryObject( _temps.i, 'szClass') THEN DO
1278 IF szClass == _class THEN DO
1279 ok = WPToolsSetObjectData( _temps.i, 'OPEN=DEFAULT;')
1280 LEAVE
1281 END
1282 END
1283 END
1284
1285 IF ok == 0 THEN DO
1286 IF SysCreateObject( _class, _class, globals.!tmpdir,,
1287 'OBJECTID=<TEMP_PRT>;TAKEDEFAULTS=NO;TEMPLATE=YES', 'R') THEN
1288 DO
1289 ok = SysSetObjectData '<TEMP_PRT>','OPEN=DEFAULT;'
1290 CALL SysDestroyObject '<TEMP_PRT>'
1291 END
1292 END
1293
1294RETURN ok
1295
1296/*:VRX PB_ABOUT_OK_Click
1297*/
1298PB_ABOUT_OK_Click:
1299 CALL SW_ABOUT_Close
1300RETURN
1301
1302/*:VRX PB_ADDPORT_CANCEL_Click
1303*/
1304PB_ADDPORT_CANCEL_Click:
1305 CALL SW_PORT_ADD_Close
1306RETURN
1307
1308/*:VRX PB_ADDPORT_OK_Click
1309*/
1310PB_ADDPORT_OK_Click: PROCEDURE EXPOSE globals. updated
1311
1312 ok = VRMethod('CN_ADDPORT', 'GetRecordList', 'Selected', 'recs.')
1313 IF ok == 0 | recs.0 < 1 THEN RETURN
1314 record = recs.1
1315
1316 _name = VRMethod('CN_ADDPORT', 'GetFieldData', record, 'NAME')
1317 btns.0 = 2
1318 btns.1 = NLSGetMessage( 14 )
1319 btns.2 = NLSGetMessage( 15 )
1320 ok = VRMessage('SW_PORT_ADD', NLSGetMessage( 205, _name ), NLSGetMessage( 200 ), 'Q', 'btns.', 1, 2 )
1321 IF ok == 1 THEN DO
1322 _portname = GetNextPortName( _name )
1323 ok = RPUPortInstall( _name, _portname )
1324 IF ok <> 1 THEN
1325 CALL VRMessage 'SW_PORT_ADD', NLSGetMessage( 167 ) RPUERROR, NLSGetMessage( 13 ), 'E'
1326 ELSE DO
1327 CALL RPUPortDialog _name, _portname
1328 CALL SW_PORT_ADD_Close
1329 updated = 1
1330 END
1331 END
1332
1333RETURN ok
1334
1335/*:VRX PB_DEVICE_ADD_Click
1336*/
1337PB_DEVICE_ADD_Click:
1338 CALL DriverAdd
1339RETURN
1340
1341/*:VRX PB_DEVICE_CANCEL_Click
1342*/
1343PB_DEVICE_CANCEL_Click:
1344 CALL SW_DEVICE_ADD_Close
1345RETURN
1346
1347/*:VRX PB_DEVICE_INSTALL_Click
1348*/
1349PB_DEVICE_INSTALL_Click: PROCEDURE EXPOSE globals. updated
1350 updated = 1
1351
1352 ok = VRMethod('CN_DEVICE_LIST', 'GetRecordList', 'Selected', 'recs.')
1353 IF ok == 0 THEN RETURN
1354 IF recs.0 == 0 THEN RETURN
1355 selected = recs.1
1356
1357 dev_name = VRMethod('CN_DEVICE_LIST', 'GetFieldData', selected, 'NAME')
1358 dev_driver = VRMethod('CN_DEVICE_LIST', 'GetFieldData', selected, 'DRIVER')
1359 driver_short = TRANSLATE( VRParseFileName( dev_driver, 'N'))
1360 IF dev_name == '' | dev_driver == '' | driver_short == '' THEN RETURN
1361
1362 /* Shipped drivers don't include the FQ path in dev_driver so we must
1363 * resolve it first.
1364 */
1365 IF VRGet('RB_DEVICE_SHIPPED', 'Set') == 1 THEN
1366 dev_driver = GetDriverSource( driver_short )
1367 IF dev_driver == '' THEN RETURN
1368
1369 ok = InstallPrintDriver( driver_short, dev_driver, dev_name )
1370
1371 IF ok <> 0 THEN DO
1372 CALL VRMessage VRWindow(), NLSGetMessage( 168, driver_short'.'dev_name ), NLSGetMessage( 13 ), 'E'
1373 END
1374 CALL SW_DEVICE_ADD_Close
1375
1376RETURN
1377
1378/*:VRX PB_DEVICE_OTHER_Click
1379*/
1380PB_DEVICE_OTHER_Click: PROCEDURE EXPOSE globals. shipped.
1381
1382 old_path = VRGet('DDCB_DEVICE_3RDPARTY', 'UserData')
1383 new_path = VRXDirectoryDialog( VRWindow(), old_path, NLSGetMessage( 189 ))
1384 IF new_path == '' THEN RETURN
1385 IF old_path == TRANSLATE( new_path ) THEN RETURN
1386
1387 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Value', new_path
1388 CALL SetDriverList new_path
1389
1390RETURN
1391
1392/*:VRX PB_DEVICE_REFRESH_Click
1393*/
1394PB_DEVICE_REFRESH_Click: PROCEDURE EXPOSE globals. shipped.
1395 CALL SetDriverList
1396return
1397
1398/*:VRX PB_DEVICE_REMOVE_Click
1399*/
1400PB_DEVICE_REMOVE_Click:
1401 CALL DriverDelete
1402RETURN
1403
1404/*:VRX PB_DEVICE_REMOVE_KeyPress
1405*/
1406PB_DEVICE_REMOVE_KeyPress:
1407 IF VRGet('PB_DEVICE_REMOVE', 'KeyString') == '{Tab}' THEN
1408 CALL VRMethod 'TDL_MAIN', 'SetFocus'
1409return
1410
1411/*:VRX PB_IMPORTCANCEL_Click
1412*/
1413PB_IMPORTCANCEL_Click:
1414 CALL SW_IMPORT_Close
1415return
1416
1417/*:VRX PB_IMPORTOK_Click
1418*/
1419PB_IMPORTOK_Click: PROCEDURE EXPOSE globals. new_ppd
1420
1421 IF VRGet('RB_IMPORTCUPS', 'Set') == 1 THEN DO
1422 CALL New_CUPS new_ppd
1423 CALL SW_IMPORT_Close
1424 CALL VRSet 'WN_MAIN', 'Shutdown', 1
1425 RETURN
1426 END
1427 driver = VRGet('DDCB_IMPORTDRV', 'Value')
1428 ok = ImportPPD( driver, new_ppd ) /* Also sets driver_path variable */
1429
1430 SELECT
1431 /* Check the return code from ImportPPD and display an appropriate message.
1432 */
1433
1434 WHEN ok == 0 THEN DO /* Success! */
1435 _message = NLSGetMessage( 238 )
1436 _mbtitle = NLSGetMessage( 16 )
1437 _mbicon = 'I'
1438 END
1439
1440 /* Note: Error codes 1 & 2 are ignored here.
1441 * 1 means the user cancelled, so no message is required.
1442 * For 2, ImportPPD itself already displayed the error message.
1443 */
1444
1445 WHEN ok == 3 THEN DO /* Invalid path specified */
1446 _message = NLSGetMessage( 222 )
1447 _mbtitle = NLSGetMessage( 13 )
1448 _mbicon = 'E'
1449 END
1450 WHEN ok == 4 THEN DO /* Failed to copy driver files */
1451 _message = NLSGetMessage( 220 )
1452 _mbtitle = NLSGetMessage( 13 )
1453 _mbicon = 'E'
1454 END
1455 WHEN ok == 5 THEN DO /* Failed to create directory */
1456 _message = NLSGetMessage( 221 )
1457 _mbtitle = NLSGetMessage( 13 )
1458 _mbicon = 'E'
1459 END
1460 WHEN ok == 6 THEN DO /* PPD import failed */
1461 _message = NLSGetMessage( 223 )
1462 _mbtitle = NLSGetMessage( 13 )
1463 _mbicon = 'E'
1464 END
1465 WHEN ok == 7 THEN DO /* Error updating PRDESC.LST */
1466 _message = NLSGetMessage( 224, globals.!prdesc )
1467 _mbtitle = NLSGetMessage( 13 )
1468 _mbicon = 'E'
1469 END
1470
1471 OTHERWISE DO
1472 _message = ''
1473 _mbtitle = ''
1474 _mbicon = 'N'
1475 END
1476 END
1477
1478 IF message <> '' THEN
1479 CALL VRMessage VRWindow(), _message, _mbtitle, _mbicon
1480
1481 IF ok == 0 THEN DO
1482 /* The PPD was imported into the driver install directory. Now we should
1483 * ask the user if they want to actually install this printer driver so
1484 * that existing printer objects can use it.
1485 */
1486 _new_model = GetNameFromPPD( new_ppd )
1487 _btns.0 = 2
1488 _btns.1 = NLSGetMessage( 14 )
1489 _btns.2 = NLSGetMessage( 15 )
1490 _create = VRMessage( VRWindow(), NLSGetMessage( 240, _new_model ) || '0d0d0a'x ||,
1491 NLSGetMessage( 241 ), NLSGetMessage( 239 ), 'Q', '_btns.', 1, 2 )
1492 IF _create == 1 THEN DO
1493 _ipd = InstallPrintDriver( driver, driver_path, _new_model )
1494 IF _ipd <> 0 THEN
1495 CALL VRMessage VRWindow(), NLSGetMessage( 168, driver'.'_new_model ), NLSGetMessage( 13 ), 'E'
1496 END
1497 END
1498
1499 CALL SW_IMPORT_Close
1500RETURN
1501
1502/*:VRX PB_MODELS_CLOSE_Click
1503*/
1504PB_MODELS_CLOSE_Click:
1505 CALL SW_MODELS_Close
1506return
1507
1508/*:VRX PB_OTHERPORT_Click
1509*/
1510PB_OTHERPORT_Click: PROCEDURE EXPOSE globals.
1511 _new_pdr = VRFileDialog('SW_PORT_ADD', NLSGetMessage( 165 ), 'O', '*.PDR')
1512 IF _new_pdr == '' THEN RETURN 0
1513
1514 ok = InstallPortDriver( _new_pdr )
1515 IF ok == 0 THEN DO
1516 _name = VRParseFileName( _new_pdr, 'N')
1517 _rec = VRMethod('CN_ADDPORT', 'AddRecord',,, _name, _new_pdr )
1518 CALL VRMethod 'CN_ADDPORT', 'SetFieldData', _rec, 'NAME', _name, 'PATH', _new_pdr
1519 END
1520 ELSE
1521 CALL VRMessage 'SW_PORT_ADD', NLSGetMessage( 166 ) || '0a0a'x || VRError(), NLSGetMessage( 13 ), 'E'
1522RETURN ok
1523
1524/*:VRX PB_PORT_ADD_Click
1525*/
1526PB_PORT_ADD_Click:
1527 CALL PortAdd
1528RETURN
1529
1530/*:VRX PB_PORT_DELETE_Click
1531*/
1532PB_PORT_DELETE_Click:
1533 CALL PortDelete
1534return
1535
1536/*:VRX PB_PORT_EDIT_Click
1537*/
1538PB_PORT_EDIT_Click:
1539 CALL PortProperties
1540return
1541
1542/*:VRX PB_PORT_EDIT_KeyPress
1543*/
1544PB_PORT_EDIT_KeyPress:
1545 IF VRGet('PB_PORT_EDIT', 'KeyString') == '{Tab}' THEN
1546 CALL VRMethod 'TDL_MAIN', 'SetFocus'
1547return
1548
1549/*:VRX PB_PPCLOSE_Click
1550*/
1551PB_PPCLOSE_Click:
1552 CALL SW_PRINTERPAKS_Close
1553return
1554
1555/*:VRX PB_PPUPDATE_Click
1556*/
1557PB_PPUPDATE_Click: PROCEDURE EXPOSE globals.
1558
1559 /* Let the user select the driver .DRV to install.
1560 */
1561 new_drv = VRFileDialog( VRWindow(), NLSGetMessage( 182 ), 'O', '*.DRV')
1562 IF new_drv == '' THEN RETURN 0
1563
1564 drv_stem = TRANSLATE( VRParseFileName( new_drv, 'N'))
1565 drv_name = TRANSLATE( VRParseFileName( new_drv, 'NE'))
1566 drv_source = TRANSLATE( VRParseFileName( new_drv, 'DP'))
1567
1568 /* See if this is the same as an existing driver (compared by filename).
1569 */
1570 existing = 0
1571 skip_repo = 0
1572 ok = VRMethod('CN_PRINTERPAKS', 'GetRecordList', 'All', 'recs.')
1573 DO i = 1 TO recs.0
1574 _ppname = VRMethod('CN_PRINTERPAKS', 'GetFieldData', recs.i, globals.!hcfPaks.!name )
1575 IF TRANSLATE( _ppname ) == TRANSLATE( new_name ) THEN DO
1576 existing = 1
1577 _pppath = VRMethod('CN_PRINTERPAKS', 'GetFieldData', recs.i, globals.!hcfPaks.!path )
1578 LEAVE
1579 END
1580 END
1581
1582 PARSE UPPER VALUE VRGetIni('PrinterManager', 'ThirdParty', 'USER') WITH known_3p '00'x .
1583 IF known_3p == '' THEN
1584 known_3p = 'ECUPS ECUPS-HP GUTENPRT PSPRINT'
1585
1586 IF existing THEN DO
1587 drv_target = TRANSLATE( _pppath )
1588 IF drv_source == drv_target ) THEN DO
1589 CALL VRMessage VRWindow(), NLSGetMessage( 183 ), NLSGetMessage( 13 ), 'E'
1590 RETURN 1
1591 END
1592 IF CheckWritablePath( drv_target ) <> 0 THEN DO
1593 existing = 0
1594 _msg.1 = NLSGetMessage( 185, drv_target )
1595 _msg.2 = ''
1596 _msg.3 = NLSGetMessage( 186, drv_name )
1597 _msg.0 = 3
1598 _btns.1 = NLSGetMessage( 2 )
1599 _btns.2 = NLSGetMessage( 3 )
1600 _btns.0 = 2
1601 _select = VRMessageStem( VRWindow(), '_msg.', NLSGetMessage( 184 ),
1602 'I', '_btns.', 1, 2 )
1603 IF _select == 2 THEN skip_repo = 1
1604 END
1605 END
1606
1607 IF \skip_repo THEN DO
1608 IF \existing THEN DO
1609 /* If we already know about this driver, try and get its saved location. */
1610 drv_target = ''
1611 IF WORDPOS( drv_stem, known_3p ) > 0 THEN
1612 PARSE UPPER VALUE VRGetIni('PM_INSTALL', drv_stem'_DIR', 'USER') WITH drv_target '00'x .
1613 ELSE DO
1614 known_3p = known_3p drv_stem
1615 CALL VRSetIni 'PrinterManager', 'ThirdParty', known_3p || '00'x, 'USER'
1616 END
1617 IF drv_target == '' THEN DO
1618 drv_target = globals.!repository'\'drv_stem
1619 _btns.1 = NLSGetMessage( 2 )
1620 _btns.2 = NLSGetMessage( 3 )
1621 _btns.3 = NLSGetMessage( 188 )
1622 _btns.0 = 3
1623 DO UNTIL _select <> 3
1624 _select = VRPrompt( VRWindow(), NLSGetMessage( 187, drv_name ),,
1625 'drv_target', NLSGetMessage( 189 ), '_btns.', 1, 2 )
1626 IF _select == 3 THEN
1627 drv_target = VRXDirectoryDialog( VRWindow(), drv_target, NLSGetMessage( 189 ))
1628 END
1629 IF _select == 2 THEN
1630 skip_repo = 1
1631 ELSE
1632 CALL VRSetIni 'PM_INSTALL', drv_stem'_DIR', TRANSLATE( drv_target ) || '00'x, 'USER'
1633 END
1634 END
1635
1636 IF \skip_repo THEN DO
1637 IF VRFileExists( drv_target ) THEN DO
1638 /* Clear any RHS attributes on existing files */
1639 CALL SysFileTree drv_target'\*', '_ignore.',,, '**---'
1640 CALL PRReplaceModule drv_target'\'drv_name, '', ''
1641 END
1642 ELSE
1643 /* Create the target directory if necessary */
1644 ok = VRMkDir( drv_target )
1645
1646 ok = CopyPrinterPak( new_drv, drv_target )
1647
1648 /* Update any previously-imported PPDs for this driver
1649 */
1650 IF ok == 1 THEN DO
1651/* TODO use drv_target and parse it for pmdx directly */
1652 driver_path = GetDriverSource( drv_stem ) /* Also sets pmdx */
1653 IF pmdx == '' THEN
1654 driver_repo = 0
1655 ELSE
1656 driver_repo = 1
1657 pwok = PinWrapper( 0, drv_stem, '')
1658 IF pwok <> 0 THEN DO
1659 CALL CHAROUT globals.!log1, 'Encountered error' pwok 'from PIN wrapper:'
1660 SELECT
1661 WHEN ok == 3 THEN CALL LINEOUT globals.!log1, 'Invalid path specified'
1662 WHEN ok == 4 THEN CALL LINEOUT globals.!log1, 'Failed to copy driver files'
1663 WHEN ok == 5 THEN CALL LINEOUT globals.!log1, 'Failed to create directory'
1664 WHEN ok == 6 THEN CALL LINEOUT globals.!log1, 'PPD import failed'
1665 WHEN ok == 7 THEN CALL LINEOUT globals.!log1, 'Error updating PRDESC.LST'
1666 OTHERWISE CALL LINEOUT globals.!log1, 'Unknown error ('pwok')'
1667 END
1668 ok = 0
1669 END
1670 END
1671
1672 IF existing & ok == 1 THEN DO
1673 CALL UpdatePrDesc drv_name, drv_target'\'drv_name
1674 END
1675 IF ok == 0 THEN DO
1676 CALL VRMessage VRWindow(), NLSGetMessage( 220 ), NLSGetMessage( 13 ), 'E'
1677 RETURN 2
1678 END
1679 ELSE
1680 CALL VRMessage VRWindow(), NLSGetMessage( 193 ), NLSGetMessage( 16 ), 'I'
1681
1682 new_drv = drv_target'\'drv_name
1683 END
1684 END
1685
1686 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', drv_stem, 'USER') WITH drv_used '00'x .
1687 IF ( drv_used <> '') & VRFileExists( drv_used ) THEN DO
1688 /* Driver is currently installed; ask if the user wants to update the
1689 * in-use copy as well.
1690 */
1691 _btns.1 = NLSGetMessage( 14 )
1692 _btns.2 = NLSGetMessage( 15 )
1693 _btns.0 = 2
1694 _select = VRMessage( VRWindow(), NLSGetMessage( 190 ), NLSGetMessage( 191 ), 'Q', '_btns.', 1, 2 )
1695 IF _select == 1 THEN DO
1696 CALL PRSetFileAttr drv_used , 'rsh'
1697 CALL PRReplaceModule drv_used, '', ''
1698 used_target = VRParseFileName( drv_used, 'DP')
1699 ok = CopyPrinterPak( new_drv, used_target )
1700 IF ok == 0 THEN DO
1701 CALL VRMessage VRWindow(), NLSGetMessage( 220 ), NLSGetMessage( 13 ), 'E'
1702 RETURN 2
1703 END
1704 ELSE
1705 CALL VRMessage VRWindow(), NLSGetMessage( 192 ), NLSGetMessage( 16 ), 'I'
1706 END
1707 END
1708
1709 /* Refresh the list */
1710 CALL GetPrinterPaks
1711RETURN 0
1712
1713/*:VRX PB_PRINTER_ADD_Click
1714*/
1715PB_PRINTER_ADD_Click:
1716 CALL PrinterWizard
1717RETURN
1718
1719/*:VRX PB_PRINTER_DEL_Click
1720*/
1721PB_PRINTER_DEL_Click:
1722 CALL PrinterDelete
1723return
1724
1725/*:VRX PB_PRINTER_EDIT_Click
1726*/
1727PB_PRINTER_EDIT_Click:
1728 CALL PrinterProperties
1729RETURN
1730
1731/*:VRX PB_PRINTER_EDIT_KeyPress
1732*/
1733PB_PRINTER_EDIT_KeyPress:
1734 IF VRGet('PB_PRINTER_EDIT', 'KeyString') == '{Tab}' THEN
1735 CALL VRMethod 'TDL_MAIN', 'SetFocus'
1736return
1737
1738/*:VRX PB_PRINTER_OPEN_Click
1739*/
1740PB_PRINTER_OPEN_Click:
1741 CALL PrinterOpen
1742RETURN
1743
1744/*:VRX PB_WIZARD_CANCEL_Click
1745*/
1746PB_WIZARD_CANCEL_Click:
1747
1748 CALL SW_WIZARD_Close
1749
1750return
1751
1752/*:VRX PB_WIZARD_NEXT_Click
1753*/
1754PB_WIZARD_NEXT_Click: PROCEDURE EXPOSE globals.
1755 SELECT
1756 WHEN VRGet('RB_CREATE_CUPS', 'Set') == 1 THEN DO
1757 globals.!create_mode = 'C'
1758 CALL New_CUPS
1759 END
1760 WHEN ( VRGet('RB_CREATE_LEGACY', 'Set') == 1 ) & ( VRGet('RB_CREATE_STANDARD', 'Set') == 1 ) THEN DO
1761 globals.!create_mode = 'S'
1762 CALL New_Standard
1763 END
1764 WHEN ( VRGet('RB_CREATE_LEGACY', 'Set') == 1 ) & ( VRGet('RB_CREATE_LAN', 'Set') == 1 ) THEN DO
1765 globals.!create_mode = 'L'
1766 CALL New_LAN
1767 END
1768 OTHERWISE DO
1769 globals.!create_mode = ''
1770 globals.!wizard = 0
1771 END
1772 END
1773 CALL SW_WIZARD_Fini
1774
1775RETURN
1776
1777/*:VRX PortAdd
1778*/
1779PortAdd: PROCEDURE EXPOSE globals.
1780
1781 updated = 0
1782 CALL VRLoadSecondary 'SW_PORT_ADD', 'W'
1783 IF updated == 1 THEN
1784 CALL RefreshPorts
1785
1786RETURN
1787
1788/*:VRX PortDelete
1789*/
1790PortDelete: PROCEDURE EXPOSE globals.
1791 PARSE ARG record
1792 IF record == '' THEN DO
1793 ok = VRMethod( "CN_PORTS", "GetRecordList", "Selected", "recs." )
1794 IF ok == 0 | recs.0 < 1 THEN RETURN
1795 record = recs.1
1796 END
1797 CALL VRMethod 'CN_PORTS', 'SetRecordAttr', record, 'Source', 0
1798
1799 _name = VRMethod('CN_PORTS', 'GetFieldData', record, globals.!hcfPorts.!name )
1800
1801 printers.0 = 0
1802 CALL RPUEnumPrinters 'printers.'
1803 DO i = 1 TO printers.0
1804 CALL RPUPrinterQuery printers.i.!name, 'details.'
1805 IF _name == details.!port THEN DO
1806 _title = TRANSLATE( printers.i.!description, ' ', '0d0a'x)
1807 CALL VRMessage 'WN_MAIN', NLSGetMessage( 206, _name, _title ), NLSGetMessage( 207 ), 'W'
1808 RETURN
1809 END
1810 END
1811
1812 IF _name == '' THEN RETURN
1813 _btns.0 = 2
1814 _btns.1 = NLSGetMessage( 14 )
1815 _btns.2 = NLSGetMessage( 15 )
1816 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 202, _name ), NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
1817 IF _confirm == 1 THEN DO
1818 CALL LINEOUT globals.!log1, 'Deleting port' _name
1819 success = RPUPortDelete( _name )
1820 IF success <> 1 THEN CALL LINEOUT globals.!log1, 'Error deleting port:' RPUERROR
1821 CALL RefreshPorts
1822 END
1823
1824RETURN
1825
1826/*:VRX PortProperties
1827*/
1828PortProperties: PROCEDURE EXPOSE globals.
1829 PARSE ARG record
1830 IF record == '' THEN DO
1831 ok = VRMethod( "CN_PORTS", "GetRecordList", "Selected", "recs." )
1832 IF ok == 0 | recs.0 < 1 THEN RETURN
1833 record = recs.1
1834 END
1835
1836 _name = VRMethod('CN_PORTS', 'GetFieldData', record, globals.!hcfPorts.!name )
1837 _module = VRMethod('CN_PORTS', 'GetFieldData', record, globals.!hcfPorts.!driver )
1838 IF _module == '' THEN DO
1839 CALL VRMessage VRWindow(), NLSGetMessage( 211, _name ), NLSGetMessage( 210 ), 'N'
1840 RETURN
1841 END
1842
1843 CALL RPUPortDialog _module, _name
1844
1845 CALL VRMethod 'CN_PORTS', 'SetRecordAttr', record, 'Source', 0
1846RETURN
1847
1848/*:VRX PrinterDelete
1849*/
1850PrinterDelete: PROCEDURE EXPOSE globals.
1851 PARSE ARG record
1852 IF record == '' THEN DO
1853 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1854 IF ok == 0 | recs.0 < 1 THEN RETURN 0
1855 record = recs.1
1856 END
1857 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1858
1859 success = 0
1860 _title = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!title )
1861 _device= VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!name )
1862 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1863 _port = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!port )
1864
1865 _btns.0 = 2
1866 _btns.1 = NLSGetMessage( 14 )
1867 _btns.2 = NLSGetMessage( 15 )
1868 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 201, _title ), NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
1869 IF _confirm == 1 THEN DO
1870
1871 IF _queue == '' THEN DO
1872 CALL LINEOUT globals.!log1, 'Printer' _device '(no queue) will be deleted.'
1873 success = RPUDeviceDelete( _device )
1874 END
1875 ELSE DO
1876 CALL LINEOUT globals.!log1, 'Printer' _device 'with queue' _queue 'will be deleted.'
1877 success = RPUPrinterDelete( _queue )
1878 END
1879 CALL LINEOUT globals.!log1, 'Deletion status:' success
1880
1881 CALL RPUPortInfo _port, 'port.'
1882 IF port.!driver == 'CUPS' THEN DO
1883 /* If this corresponds to a locally-defined CUPS queue, offer to
1884 * to delete that as well.
1885 */
1886 cups_prnt = RPUPortQuery('CUPS', _port )
1887 IF cups_prnt <> '' & ( LENGTH( cups_prnt ) == 130 ) THEN DO
1888 PARSE VAR cups_prnt 1 _cups_host 66 _cups_queue
1889 PARSE VAR _cups_host cups_host '00'x .
1890 PARSE VAR _cups_queue cups_queue '00'x .
1891 IF ( TRANSLATE( cups_host ) == 'LOCALHOST') | cups_host = '127.0.0.1' THEN DO
1892 CALL LINEOUT globals.!log1, 'Printer points to local CUPS queue' cups_queue 'via port:' _port
1893 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 204, _title, cups_queue, _port ),,
1894 NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
1895 IF _confirm == 1 THEN DO
1896 CALL LINEOUT globals.!log1, 'Deleting CUPS printer' cups_queue 'on host' cups_host'.'
1897 success = CupsDeletePrinter( cups_host, cups_queue )
1898 CALL LINEOUT globals.!log1, 'CUPS deletion status:' success
1899 IF success == 0 THEN DO
1900 CALL RPUPortDelete _port
1901 CALL RefreshPorts
1902 END
1903 ELSE
1904 CALL VRMessage 'WN_MAIN', NLSGetMessage( 251, cups_queue, success ), NLSGetMessage( 18 ), 'E'
1905 END
1906 END
1907 END
1908 END
1909 END
1910
1911 CALL RefreshPrinters
1912
1913RETURN success
1914
1915/*:VRX PrinterHold
1916*/
1917PrinterHold: PROCEDURE EXPOSE globals.
1918 PARSE ARG record
1919 IF record == '' THEN DO
1920 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1921 IF ok == 0 | recs.0 < 1 THEN RETURN
1922 record = recs.1
1923 END
1924 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1925 _flags = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!flags )
1926 _p = POS('P', _flags )
1927 IF _p > 0 THEN DO
1928 ok = RPUQueueHold( _queue, 'N')
1929 IF ok == 1 THEN DO
1930 CALL VRSet 'MI_PRINTER_HOLD', 'Checked', 0
1931 _flags = DELSTR( _flags, _p, 1 )
1932 CALL VRMethod 'CN_PRINTERS', 'SetFieldData', record, globals.!hcfPrinters.!flags, _flags
1933 END
1934 END
1935 ELSE DO
1936 ok = RPUQueueHold( _queue, 'Y')
1937 IF ok == 1 THEN DO
1938 CALL VRSet 'MI_PRINTER_HOLD', 'Checked', 1
1939 _flags = _flags'P'
1940 CALL VRMethod 'CN_PRINTERS', 'SetFieldData', record, globals.!hcfPrinters.!flags, _flags
1941 END
1942 END
1943
1944 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1945RETURN
1946
1947/*:VRX PrinterOpen
1948*/
1949PrinterOpen: PROCEDURE EXPOSE globals.
1950 PARSE ARG record
1951 IF record == '' THEN DO
1952 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1953 IF ok == 0 | recs.0 < 1 THEN RETURN
1954 record = recs.1
1955 END
1956
1957 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1958 IF _queue <> '' THEN
1959 CALL RPUOpenView _queue, 'O'
1960
1961 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1962RETURN
1963
1964/*:VRX PrinterProperties
1965*/
1966PrinterProperties: PROCEDURE EXPOSE globals.
1967 PARSE ARG record
1968 IF record == '' THEN DO
1969 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1970 IF ok == 0 | recs.0 < 1 THEN RETURN
1971 record = recs.1
1972 END
1973
1974 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1975 IF _queue <> '' THEN
1976 CALL RPUOpenView _queue, 'S'
1977
1978 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1979RETURN
1980
1981/*:VRX PrinterSetDefault
1982*/
1983PrinterSetDefault: PROCEDURE EXPOSE globals.
1984 PARSE ARG record
1985 IF record == '' THEN DO
1986 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1987 IF ok == 0 | recs.0 < 1 THEN RETURN 0
1988 record = recs.1
1989 END
1990 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1991 ok = RPUQueueDefault( _queue )
1992
1993/*** Would also need to remove 'D' flag from previous default printer. Simpler
1994 *** just to call RefreshPrinters (below) instead.
1995 *
1996 * IF ok == 1 THEN DO
1997 * CALL VRSet 'MI_PRINTER_DEFAULT', 'Checked', 1
1998 * _flags = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!flags )
1999 * IF POS( _flags, 'D') == 0 THEN DO
2000 * _flags = 'D'_flags
2001 * CALL VRMethod 'CN_PRINTERS', 'SetFieldData', record, globals.!hcfPrinters.!flags, _flags
2002 * END
2003 * END
2004 */
2005
2006 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
2007 CALL RefreshPrinters
2008RETURN ok
2009
2010/*:VRX PrinterWizard
2011*/
2012PrinterWizard: PROCEDURE EXPOSE globals.
2013 CALL VRLoadSecondary 'SW_WIZARD', 'N'
2014RETURN
2015
2016/*:VRX Quit
2017*/
2018Quit:
2019 window = VRWindow()
2020 call VRSet window, "Shutdown", 1
2021 drop window
2022return
2023
2024/*:VRX RB_ADVANCED_Click
2025*/
2026RB_ADVANCED_Click: PROCEDURE
2027 CALL VRSet 'RB_CREATE_STANDARD', 'Enabled', 0
2028 CALL VRSet 'RB_CREATE_LAN', 'Enabled', 0
2029RETURN
2030
2031/*:VRX RB_CREATE_CUPS_Click
2032*/
2033RB_CREATE_CUPS_Click: PROCEDURE
2034 CALL VRSet 'RB_CREATE_STANDARD', 'Enabled', 0
2035 CALL VRSet 'RB_CREATE_LAN', 'Enabled', 0
2036RETURN
2037
2038/*:VRX RB_CREATE_LEGACY_Click
2039*/
2040RB_CREATE_LEGACY_Click: PROCEDURE
2041 CALL VRSet 'RB_CREATE_STANDARD', 'Enabled', 1
2042 CALL VRSet 'RB_CREATE_LAN', 'Enabled', 1
2043RETURN
2044
2045/*:VRX RB_DEVICE_3RDPARTY_Click
2046*/
2047RB_DEVICE_3RDPARTY_Click: PROCEDURE EXPOSE globals. shipped.
2048 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Enabled', 1
2049 CALL VRSet 'PB_DEVICE_OTHER', 'Enabled', 1
2050 CALL VRSet 'PB_DEVICE_REFRESH', 'Enabled', 1
2051 CALL SetDriverList
2052RETURN
2053
2054/*:VRX RB_DEVICE_SHIPPED_Click
2055*/
2056RB_DEVICE_SHIPPED_Click: PROCEDURE EXPOSE globals. shipped.
2057 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Enabled', 0
2058 CALL VRSet 'PB_DEVICE_OTHER', 'Enabled', 0
2059 CALL VRSet 'PB_DEVICE_REFRESH', 'Enabled', 0
2060 CALL SetDriverList
2061RETURN
2062
2063
2064/*:VRX RefreshDevices
2065*/
2066RefreshDevices: PROCEDURE EXPOSE globals.
2067
2068 ok = RPUEnumDrivers('drivers.')
2069 CALL LINEOUT globals.!log1, 'Enumerating drivers:' ok
2070
2071 CALL VRSet 'CN_DEVICES', 'Painting', 0
2072 CALL VRMethod 'CN_DEVICES', 'RemoveRecord', 'All'
2073
2074 IF rc <> 0 THEN DO
2075 CALL LINEOUT globals.!log1, drivers.0 'drivers found.'
2076 DO i = 1 TO drivers.0
2077 PARSE VAR drivers.i _pdrv'.'_model
2078 IF _pdrv == 'IBMNULL' & _model == '' THEN
2079 _model = NLSGetMessage( 106 )
2080 ELSE IF _model == '' THEN
2081 _model = '-'
2082 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', _pdrv, 'USER') WITH _drvspec '00'x .
2083 driverinfo.i = ';'drivers.i';'_drvspec';;;'globals.!hcfDevices.!icon';'_drvspec';'globals.!hcfDevices.!model';'_model';'globals.!hcfDevices.!driver';'_pdrv
2084 END
2085 driverinfo.0 = drivers.0
2086 ok = VRMethod( "CN_DEVICES", "AddRecordList",,, "driverinfo.")
2087 DROP drivers.
2088 DROP driverinfo.
2089 END
2090 CALL VRSet 'CN_DEVICES', 'Painting', 1
2091
2092RETURN
2093
2094/*:VRX RefreshPorts
2095*/
2096RefreshPorts: PROCEDURE EXPOSE globals.
2097
2098 ok = RPUEnumPorts('ports.')
2099 CALL LINEOUT globals.!log1, 'Enumerating ports:' ok
2100
2101 CALL VRSet 'CN_PORTS', 'Painting', 0
2102 CALL VRMethod 'CN_PORTS', 'RemoveRecord', 'All'
2103
2104 IF rc <> 0 THEN DO
2105 CALL LINEOUT globals.!log1, ports.0 'ports found.'
2106 DO i = 1 TO ports.0
2107 PARSE VAR ports.i _name _driver _path
2108 SELECT
2109 WHEN _name == 'FILE' THEN _icon = '$24,PMWP'
2110 WHEN _driver == 'USBPRT' THEN _icon = '$7001,'_path
2111 WHEN _driver == 'SERIAL' THEN _icon = '$7001,'_path
2112 WHEN _driver == 'PARALLEL' THEN _icon = '$7001,'_path
2113 WHEN _driver == 'SLPR' THEN _icon = '$7001,'_path
2114 WHEN _driver == 'LPRPDRVR' THEN _icon = '$256,'_path
2115/*
2116 WHEN _driver == 'USBPRT' THEN _icon = '$7'
2117 WHEN _driver == 'SMB' THEN _icon = '$6'
2118 WHEN _driver == 'SLPR' THEN _icon = '$6'
2119 WHEN _driver == 'LPR32' THEN _icon = '$6'
2120 WHEN _driver == 'LPRPDRVR' THEN _icon = '$6'
2121 WHEN _driver == 'CUPS' THEN _icon = '$10'
2122 OTHERWISE _icon = '$5'
2123*/
2124 OTHERWISE _icon = _path
2125 END
2126
2127 portinfo.i = ';'_name';'_icon';;;'globals.!hcfPorts.!icon';'_icon';'globals.!hcfPorts.!name';'_name';'globals.!hcfPorts.!driver';'_driver';'
2128 END
2129 portinfo.0 = ports.0
2130 ok = VRMethod( "CN_PORTS", "AddRecordList",,, "portinfo.")
2131 DROP ports.
2132 DROP portinfo.
2133 END
2134 CALL VRSet 'CN_PORTS', 'Painting', 1
2135
2136RETURN
2137
2138/*:VRX RefreshPrinters
2139*/
2140RefreshPrinters: PROCEDURE EXPOSE globals.
2141 ok = RPUEnumPrinters('printers.')
2142 CALL LINEOUT globals.!log1, 'Enumerating printers:' ok
2143
2144 CALL VRSet 'CN_PRINTERS', 'Painting', 0
2145 CALL VRMethod 'CN_PRINTERS', 'RemoveRecord', 'All'
2146
2147 IF ok <> 0 THEN DO
2148 CALL LINEOUT globals.!log1, printers.0 'printers found.'
2149
2150 DO i = 1 TO printers.0
2151 _title = TRANSLATE( printers.i.!description, ' ', '0d0a'x)
2152 ok = RPUPrinterQuery( printers.i.!name, 'details.')
2153 IF ok == 0 THEN DO
2154 _driver = '?'
2155 _port = '?'
2156 END
2157 ELSE DO
2158 PARSE VAR details.!drivers _driver ',' .
2159 _port = details.!port
2160 END
2161 IF printers.i.!host <> '' THEN
2162 _icon = '$65,PMWP'
2163 ELSE IF _driver <> '?' THEN DO
2164 PARSE VAR _driver _pdrv'.'_model
2165 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', _pdrv, 'USER') WITH _icon '00'x .
2166 END
2167 ELSE _icon = '$2'
2168
2169 printerinfo.i = ';'printers.i.!description';'_icon';;;' ||,
2170 globals.!hcfPrinters.!title';'_title';' ||,
2171 globals.!hcfPrinters.!icon';'_icon';' ||,
2172 globals.!hcfPrinters.!name';'printers.i.!name';' ||,
2173 globals.!hcfPrinters.!queue';'printers.i.!queue';' ||,
2174 globals.!hcfPrinters.!host';'printers.i.!host';' ||,
2175 globals.!hcfPrinters.!port';'_port';' ||,
2176 globals.!hcfPrinters.!driver';'_driver';' ||,
2177 globals.!hcfPrinters.!flags';'printers.i.!flags';' ||,
2178 globals.!hcfPrinters.!handle';'printers.i.!handle';'
2179 END
2180 printerinfo.0 = printers.0
2181 ok = VRMethod( "CN_PRINTERS", "AddRecordList",,, "printerinfo.")
2182 DROP printers.
2183 DROP printerinfo.
2184 DROP details.
2185
2186 END
2187 CALL VRSet 'CN_PRINTERS', 'Painting', 1
2188
2189RETURN
2190
2191/*:VRX SetDriverList
2192*/
2193SetDriverList: PROCEDURE EXPOSE globals. shipped.
2194 ARG driver_path
2195
2196 CALL VRSet VRWindow(), 'Pointer', 'WAIT'
2197 CALL VRMethod 'CN_DEVICE_LIST', 'RemoveRecord', 'All'
2198
2199 IF VRGet('RB_DEVICE_SHIPPED', 'Set') == 1 THEN DO
2200 CALL LINEOUT globals.!log1, 'Refreshing shipped driver list ('shipped.0' devices).'
2201 CALL VRMethod 'CN_DEVICE_LIST', 'AddRecordList',,, 'shipped.'
2202 END
2203 ELSE DO
2204 IF driver_path == '' THEN
2205 driver_path = TRANSLATE( STRIP( VRGet('DDCB_DEVICE_3RDPARTY', 'Value')))
2206 IF driver_path <> '' THEN DO
2207 CALL LINEOUT globals.!log1, 'Refreshing third-party driver list for' driver_path'.'
2208 drivers.0 = 0
2209 _total = 0
2210 CALL SysFileTree driver_path'\*.DRV', 'drivers.', 'FO'
2211 DO i = 1 TO drivers.0
2212 list.0 = 0
2213 IF SysGetEA( drivers.i, '.EXPAND', 'eaval') == 0 THEN DO
2214 PARSE VAR eaval 3 ealen 5 models
2215 offs = 1
2216 datalen = C2D( REVERSE( ealen ))
2217 DO WHILE offs <= datalen
2218 start = SUBSTR( models, offs )
2219 inc = POS('00'x, start )
2220 IF inc > 1 THEN DO
2221 current_name = STRIP( SUBSTR( start, 1, inc-1 ))
2222 _total = _total + 1
2223 list._total = ';'_desc';#2;;;NAME;'current_name';DRIVER;'|| TRANSLATE( drivers.i ) ||';'
2224 END
2225 offs = offs + inc
2226 END
2227 END
2228 END
2229
2230 list.0 = _total
2231 CALL VRSortStem 'list.'
2232 CALL VRMethod 'CN_DEVICE_LIST', 'AddRecordList',,, 'list.'
2233 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'UserData', driver_path
2234 END
2235 END
2236
2237 CALL VRSet VRWindow(), 'Pointer', '<default>'
2238
2239RETURN
2240
2241/*:VRX SetLanguage
2242*/
2243SetLanguage: PROCEDURE EXPOSE globals.
2244 PARSE ARG locale
2245
2246 /*
2247 * This function locates the proper language files, and uses the message
2248 * file to sets all UI text. If the language could not be determined, we
2249 * default to English.
2250 */
2251 execPath = VRGet('Application', 'Program')
2252 IF execPath <> '' THEN
2253 execDir = VRParseFileName( execPath, 'DP')
2254 ELSE
2255 execDir = DIRECTORY()
2256
2257 /*
2258 * First, figure out what language/message file to use.
2259 */
2260 IF locale <> '' THEN
2261 syslanguage = locale
2262 ELSE
2263 syslanguage = VALUE('LANG',,'OS2ENVIRONMENT')
2264
2265 SELECT
2266 WHEN TRANSLATE( syslanguage ) == 'ZH_TW' THEN nlv = 'tw'
2267 WHEN TRANSLATE( syslanguage ) == 'ZH_CN' THEN nlv = 'cx'
2268 OTHERWISE PARSE VAR syslanguage nlv '_' .
2269 END
2270 nlvfile = globals.!nlsname || nlv
2271 IF ( STREAM( execDir'\'nlvfile'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', nlvfile'.msg') \= '') THEN DO
2272 globals.!messages = nlvfile'.msg'
2273 helpfile = nlvfile'.hlp'
2274 CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
2275 END
2276 ELSE DO
2277 globals.!messages = globals.!nlsname || 'en.msg'
2278 helpfile = globals.!nlsname || 'en.hlp'
2279 CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
2280 END
2281
2282 /*
2283 * If the message file is missing or unreadable, display an error and then exit.
2284 */
2285 IF NLSGetMessage( 1 ) == '' THEN DO
2286 CALL VRMessage VRWindow(), 'Language file' TRANSLATE( globals.!messages ) 'could not be loaded.', 'Cannot Continue', 'E'
2287 RETURN 0
2288 END
2289
2290 /*
2291 * Now set the captions for the UI controls on the main window, according
2292 * to the specified language.
2293 */
2294 CALL NLSSetText 'WN_MAIN', 'Caption', 1
2295 CALL VRMethod 'TDL_MAIN', 'SetTabText', 1, NLSGetMessage( 100 )
2296 CALL VRMethod 'TDL_MAIN', 'SetTabText', 2, NLSGetMessage( 101 )
2297 CALL VRMethod 'TDL_MAIN', 'SetTabText', 3, NLSGetMessage( 102 )
2298
2299 CALL NLSSetText 'MN_PROGRAM', 'Caption', 20
2300 CALL NLSSetText 'MI_MANAGE', 'Caption', 21
2301 CALL NLSSetText 'MI_IMPORT', 'Caption', 22
2302 CALL NLSSetText 'MI_QUIT', 'Caption', 29
2303
2304 CALL NLSSetText 'MN_PRINTER', 'Caption', 30
2305 CALL NLSSetText 'MI_PRINTER_OPEN', 'Caption', 31
2306 CALL NLSSetText 'MI_PRINTER_PROPS', 'Caption', 32
2307 CALL NLSSetText 'MI_PRINTER_HOLD', 'Caption', 33
2308 CALL NLSSetText 'MI_PRINTER_DEFAULT', 'Caption', 34
2309 CALL NLSSetText 'MI_PRINTER_CREATE', 'Caption', 35
2310 CALL NLSSetText 'MI_PRINTER_DELETE', 'Caption', 36
2311
2312 CALL NLSSetText 'MN_PORT', 'Caption', 40
2313 CALL NLSSetText 'MI_PORT_CREATE', 'Caption', 41
2314 CALL NLSSetText 'MI_PORT_DELETE', 'Caption', 42
2315 CALL NLSSetText 'MI_PORT_PROPS', 'Caption', 43
2316
2317 CALL NLSSetText 'MN_DRIVERS', 'Caption', 50
2318 CALL NLSSetText 'MI_DRIVERS_INSTALL', 'Caption', 51
2319 CALL NLSSetText 'MI_DRIVERS_REMOVE', 'Caption', 52
2320
2321 CALL NLSSetText 'MN_VIEW', 'Caption', 60
2322 CALL NLSSetText 'MI_DETAILVIEW', 'Caption', 61
2323 CALL NLSSetText 'MI_ICONVIEW', 'Caption', 62
2324 CALL NLSSetText 'MI_REFRESH', 'Caption', 63
2325
2326 CALL NLSSetText 'MI_CONTEXT_INSTALL', 'Caption', 8
2327 CALL NLSSetText 'MI_CONTEXT_DETAIL', 'Caption', 61
2328 CALL NLSSetText 'MI_CONTEXT_ICON', 'Caption', 62
2329 CALL NLSSetText 'MI_CONTEXT_REFRESH', 'Caption', 63
2330
2331 CALL NLSSetText 'MN_PRINTERPAK', 'Caption', 70
2332 CALL NLSSetText 'MI_PPAK_MODELS', 'Caption', 71
2333 CALL NLSSetText 'MI_PPAK_COPY', 'Caption', 72
2334
2335 CALL NLSSetText 'MN_HELP', 'Caption', 80
2336 CALL NLSSetText 'MI_HELP_GENERAL', 'Caption', 81
2337 CALL NLSSetText 'MI_ABOUT', 'Caption', 89
2338
2339 CALL VRMethod 'WN_MAIN', 'InstallAccelerators'
2340
2341RETURN 1
2342
2343/*:VRX SW_ABOUT_Close
2344*/
2345SW_ABOUT_Close:
2346 call SW_ABOUT_Fini
2347return
2348
2349/*:VRX SW_ABOUT_Create
2350*/
2351SW_ABOUT_Create:
2352 call SW_ABOUT_Init
2353return
2354
2355/*:VRX SW_ABOUT_Fini
2356*/
2357SW_ABOUT_Fini:
2358 window = VRInfo( "Window" )
2359 call VRDestroy window
2360 drop window
2361return
2362/*:VRX SW_ABOUT_Init
2363*/
2364SW_ABOUT_Init: PROCEDURE EXPOSE globals.
2365
2366 IF globals.!oem_os == 1 THEN
2367 _platform = 'eComStation'
2368 ELSE
2369 _platform = 'PM'
2370
2371 CALL NLSSetText 'SW_ABOUT', 'Caption', 130
2372 CALL NLSSetText 'DT_PRODUCT', 'Caption', 131, _platform
2373 CALL NLSSetText 'DT_VERSION', 'Caption', 132, globals.!version
2374 CALL NLSSetText 'DT_COPYRIGHT', 'Caption', 133, globals.!copyright
2375 CALL NLSSetText 'PB_ABOUT_OK', 'Caption', 2
2376
2377 PARSE VERSION _rexxver
2378 PARSE VALUE VRVersion('VROBJ.DLL') WITH _vrver .
2379 PARSE VALUE RPUVersion() WITH _rpuver .
2380 PARSE VALUE VRXVersion() WITH _vrxver .
2381 _pr1ver = PRVersion()
2382 _wptver = WPToolsVersion()
2383 _bullet = NLSGetMessage( 135 )
2384 CALL VRSet 'MLE_LICENSES', 'Value', NLSGetMessage( 134, _rexxver ) || '0a'x ,
2385 _bullet 'IBM REXXUTIL' SysUtilVersion() || '0a'x ,
2386 _bullet 'VX-REXX VROBJ' _vrver || '0a'x ,
2387 _bullet 'VX-REXX Extras (VROBJEX)' _vrxver || '0a'x ,
2388 _bullet 'RXPRTUTL' _rpuver || '0a'x ,
2389 _bullet 'WPTOOLS' _wptver || '0a'x ,
2390 _bullet _pr1ver || '0a'x||' ----- '||'0a'x || ,
2391 NLSGetMessage( 137 ) || '0a'x' ----- '||'0a'x || ,
2392 NLSGetMessage( 138 )
2393
2394 window = VRInfo( "Object" )
2395 if( \VRIsChildOf( window, "Notebook" ) ) then do
2396 call VRMethod window, "CenterWindow"
2397 call VRSet window, "Visible", 1
2398 call VRMethod window, "Activate"
2399 end
2400 drop window
2401return
2402
2403/*:VRX SW_DEVICE_ADD_Close
2404*/
2405SW_DEVICE_ADD_Close:
2406 call SW_DEVICE_ADD_Fini
2407return
2408
2409/*:VRX SW_DEVICE_ADD_Create
2410*/
2411SW_DEVICE_ADD_Create:
2412 call SW_DEVICE_ADD_Init
2413return
2414
2415/*:VRX SW_DEVICE_ADD_Fini
2416*/
2417SW_DEVICE_ADD_Fini:
2418 window = VRInfo( "Window" )
2419 call VRDestroy window
2420 drop window
2421return
2422/*:VRX SW_DEVICE_ADD_Init
2423*/
2424SW_DEVICE_ADD_Init: PROCEDURE EXPOSE globals. shipped.
2425
2426 fld_name = VRMethod('CN_DEVICE_LIST', 'AddField', 'String', NLSGetMessage( 265 ), 'NAME')
2427 fld_driver = VRMethod('CN_DEVICE_LIST', 'AddField', 'String', NLSGetMessage( 266 ), 'DRIVER')
2428
2429 IF globals.!oem_os == 1 THEN
2430 _platform = 'eComStation'
2431 ELSE IF globals.!oem_os == 2 THEN
2432 _platform = 'ArcaOS'
2433 ELSE
2434 _platform = 'OS/2'
2435 CALL NLSSetText 'SW_DEVICE_ADD', 'Caption', 260
2436 CALL NLSSetText 'RB_DEVICE_SHIPPED', 'Caption', 261, _platform
2437 CALL NLSSetText 'RB_DEVICE_3RDPARTY', 'Caption', 262, _platform
2438 CALL NLSSetText 'PB_DEVICE_OTHER', 'Caption', 188
2439 CALL NLSSetText 'PB_DEVICE_REFRESH', 'Caption', 63
2440 CALL NLSSetText 'PB_DEVICE_INSTALL', 'Caption', 2
2441 CALL NLSSetText 'PB_DEVICE_CANCEL', 'Caption', 3
2442
2443 window = VRInfo( "Object" )
2444 CALL VRSet window, 'Pointer', 'WAIT'
2445
2446 extras_num = 0
2447 PARSE UPPER VALUE VRGetIni('PrinterManager', 'LastDriverPath', 'USER') WITH last_path '00'x .
2448 IF last_path <> '' THEN DO
2449 extras_num = extras_num + 1
2450 extras_path.extras_num = last_path
2451 END
2452 PARSE UPPER VALUE VRGetIni('PrinterManager', 'ThirdParty', 'USER') WITH known_3p '00'x .
2453 IF known_3p == '' THEN known_3p = 'ECUPS ECUPS-HP GUTENPRT PSPRINT'
2454 DO i = 1 TO WORDS( known_3p )
2455 _basename = WORD( known_3p, i )
2456 _ppdriver = _basename'.DRV'
2457 _ppini = VRGetIni('PM_INSTALL', _basename'_DIR', 'USER')
2458 IF _ppini == '' THEN ITERATE
2459 PARSE VAR _ppini _pppath '00'x .
2460 IF VRFileExists( _pppath'\'_ppdriver ) THEN DO
2461 extras_num = extras_num + 1
2462 extras_name.extras_num = _ppdriver
2463 extras_path.extras_num = _pppath
2464 END
2465 END
2466 extras_name.0 = extras_num
2467 extras_path.0 = extras_num
2468 CALL VRMethod 'DDCB_DEVICE_3RDPARTY', 'AddStringList', 'extras_path.'
2469 IF extras_num > 0 THEN CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Selected', 1
2470
2471 if( \VRIsChildOf( window, "Notebook" ) ) then do
2472 call VRMethod window, "CenterWindow"
2473 call VRSet window, "Visible", 1
2474 call VRMethod window, "Activate"
2475 end
2476
2477 IF GetShippedDrivers() > 0 THEN DO
2478/*
2479 CALL VRSet 'RB_DEVICE_SHIPPED', 'Set', 1
2480*/
2481 CALL VRMethod 'CN_DEVICE_LIST', 'AddRecordList',,, 'shipped.'
2482 END
2483
2484 CALL VRSet window, 'Pointer', '<default>'
2485 drop window
2486
2487RETURN
2488
2489/*:VRX SW_DEVICES_Close
2490*/
2491SW_DEVICES_Close:
2492 call SW_DEVICES_Fini
2493return
2494
2495/*:VRX SW_DEVICES_Create
2496*/
2497SW_DEVICES_Create:
2498 call SW_DEVICES_Init
2499return
2500
2501/*:VRX SW_DEVICES_Fini
2502*/
2503SW_DEVICES_Fini:
2504 window = VRInfo( "Window" )
2505 call VRDestroy window
2506 drop window
2507return
2508/*:VRX SW_DEVICES_Init
2509*/
2510SW_DEVICES_Init: PROCEDURE EXPOSE globals.
2511
2512 globals.!hcfDevices.!icon = VRMethod( "CN_DEVICES", "AddField", "Icon", "" )
2513 globals.!hcfDevices.!model = VRMethod( "CN_DEVICES", "AddField", "String", NLSGetMessage( 111 ))
2514 globals.!hcfDevices.!driver = VRMethod( "CN_DEVICES", "AddField", "String", NLSGetMessage( 116 ))
2515
2516 CALL VRSet "CN_DEVICES", "DetailSort", globals.!hcfDevices.!model
2517 ok = VRMethod( "CN_DEVICES", "SetFieldAttr", globals.!hcfDevices.!icon, "HorizSeparator", "0" )
2518
2519 CALL NLSSetText 'CN_DEVICES', 'Caption', 104
2520 CALL NLSSetText 'PB_DEVICE_ADD', 'Caption', 8
2521 CALL NLSSetText 'PB_DEVICE_REMOVE', 'Caption', 9
2522
2523 CALL RefreshDevices
2524
2525 window = VRInfo( "Object" )
2526 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2527 call VRMethod window, "CenterWindow"
2528 call VRSet window, "Visible", 1
2529 call VRMethod window, "Activate"
2530 end
2531
2532 CALL VRSet window, 'UserData', 'CN_DEVICES'
2533 drop window
2534/*
2535 globals.!initstate = globals.!initstate + 1
2536 IF globals.!initstate == 3 THEN CALL VRSet 'TM_REFRESH', 'Enabled', 1
2537*/
2538RETURN
2539
2540/*:VRX SW_IMPORT_Close
2541*/
2542SW_IMPORT_Close:
2543 call SW_IMPORT_Fini
2544return
2545
2546/*:VRX SW_IMPORT_Create
2547*/
2548SW_IMPORT_Create:
2549 call SW_IMPORT_Init
2550return
2551
2552/*:VRX SW_IMPORT_Fini
2553*/
2554SW_IMPORT_Fini:
2555 window = VRInfo( "Window" )
2556 call VRDestroy window
2557 drop window
2558return
2559/*:VRX SW_IMPORT_Init
2560*/
2561SW_IMPORT_Init: PROCEDURE EXPOSE globals. new_ppd
2562
2563 CALL NLSSetText 'SW_IMPORT', 'Caption', 236
2564 CALL NLSSetText 'DT_IMPORT', 'Caption', 233
2565 CALL NLSSetText 'RB_IMPORTCUPS', 'Caption', 234
2566 CALL NLSSetText 'RB_IMPORTLEGACY', 'Caption', 235
2567 CALL NLSSetText 'PB_IMPORTOK', 'Caption', 2
2568 CALL NLSSetText 'PB_IMPORTCANCEL', 'Caption', 3
2569
2570 _count = 0
2571 IF ( DriverIsInstalled('PSCRIPT') <> '') | ( GetDriverSource('PSCRIPT') <> '') THEN DO
2572 _count = _count + 1
2573 psdrv._count = 'PSCRIPT'
2574 END
2575 IF ( DriverIsInstalled('PSCRIPT2') <> '') | ( GetDriverSource('PSCRIPT2') <> '') THEN DO
2576 _count = _count + 1
2577 psdrv._count = 'PSCRIPT2'
2578 END
2579 IF ( DriverIsInstalled('PSPRINT') <> '') | ( GetDriverSource('PSPRINT') <> '') THEN DO
2580 _count = _count + 1
2581 psdrv._count = 'PSPRINT'
2582 END
2583 IF ( DriverIsInstalled('PSPRINT2') <> '') | ( GetDriverSource('PSPRINT2') <> '') THEN DO
2584 _count = _count + 1
2585 psdrv._count = 'PSPRINT2'
2586 END
2587 IF ( DriverIsInstalled('ECUPS') <> '') | ( GetDriverSource('ECUPS') <> '') THEN DO
2588 _count = _count + 1
2589 psdrv._count = 'ECUPS'
2590 END
2591 IF ( DriverIsInstalled('ECUPS-HP') <> '') | ( GetDriverSource('ECUPS-HP') <> '') THEN DO
2592 _count = _count + 1
2593 psdrv._count = 'ECUPS-HP'
2594 END
2595 IF DriverIsInstalled('GUTENPRT') <> '' THEN DO
2596 _count = _count + 1
2597 psdrv._count = 'GUTENPRT'
2598 END
2599
2600 IF _count < 1 THEN DO
2601 IF globals.!hascups == 0 THEN DO
2602 CALL VRMessage VRWindow(), NLSGetMessage( 237 ), NLSGetMessage( 13 ), 'E'
2603 CALL SW_IMPORT_Close
2604 END
2605 CALL VRSet 'RB_IMPORTCUPS', 'Set', 1
2606 CALL VRSet 'RB_IMPORTLEGACY', 'Enabled', 0
2607 CALL VRSet 'DDCB_IMPORTDRV', 'Enabled', 0
2608 END
2609 ELSE IF \globals.!hascups THEN DO
2610 CALL VRSet 'RB_IMPORTCUPS', 'Enabled', 0
2611 END
2612
2613 psdrv.0 = _count
2614 CALL VRMethod 'DDCB_IMPORTDRV', 'AddStringList', 'psdrv.'
2615 CALL VRSet 'DDCB_IMPORTDRV', 'Selected', 1
2616
2617 window = VRInfo( "Object" )
2618 if( \VRIsChildOf( window, "Notebook" ) ) then do
2619 call VRMethod window, "CenterWindow"
2620 call VRSet window, "Visible", 1
2621 call VRMethod window, "Activate"
2622 end
2623 drop window
2624RETURN
2625
2626/*:VRX SW_MODELS_Close
2627*/
2628SW_MODELS_Close:
2629 call SW_MODELS_Fini
2630return
2631
2632/*:VRX SW_MODELS_Create
2633*/
2634SW_MODELS_Create:
2635 call SW_MODELS_Init
2636return
2637
2638/*:VRX SW_MODELS_Fini
2639*/
2640SW_MODELS_Fini:
2641 window = VRInfo( "Window" )
2642 call VRDestroy window
2643 drop window
2644return
2645/*:VRX SW_MODELS_Init
2646*/
2647SW_MODELS_Init: PROCEDURE EXPOSE globals.
2648
2649 ok = VRMethod( "CN_PRINTERPAKS", "GetRecordList", "Selected", "recs." )
2650 IF ok == 0 | recs.0 < 1 THEN RETURN
2651 record = recs.1
2652
2653 _name = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!name )
2654 _path = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!path )
2655 _ver = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!version )
2656 IF _ver == '-' THEN _ver = '??'
2657 driver = _path'\'_name
2658
2659 CALL NLSSetText 'SW_MODELS', 'Caption', 194
2660 CALL NLSSetText 'PB_MODELS_CLOSE', 'Caption', 12
2661
2662 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
2663 ok = RPUEnumModels( driver, 'models.')
2664 IF ok == 1 THEN
2665 CALL VRMethod 'LB_MODELS', 'AddStringList', 'models.'
2666 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
2667
2668 CALL NLSSetText 'DT_MODELS', 'Caption', 195, _name, models.0
2669
2670 window = VRInfo( "Object" )
2671 if( \VRIsChildOf( window, "Notebook" ) ) then do
2672 call VRMethod window, "CenterWindow"
2673 call VRSet window, "Visible", 1
2674 call VRMethod window, "Activate"
2675 end
2676 drop window
2677
2678RETURN
2679
2680/*:VRX SW_PORT_ADD_Close
2681*/
2682SW_PORT_ADD_Close:
2683 call SW_PORT_ADD_Fini
2684return
2685
2686/*:VRX SW_PORT_ADD_Create
2687*/
2688SW_PORT_ADD_Create:
2689 call SW_PORT_ADD_Init
2690return
2691
2692/*:VRX SW_PORT_ADD_Fini
2693*/
2694SW_PORT_ADD_Fini:
2695 window = VRInfo( "Window" )
2696 call VRDestroy window
2697 drop window
2698return
2699/*:VRX SW_PORT_ADD_Init
2700*/
2701SW_PORT_ADD_Init: PROCEDURE EXPOSE globals. updated
2702
2703 fld_name = VRMethod('CN_ADDPORT', 'AddField', 'String',, 'NAME')
2704 fld_path = VRMethod('CN_ADDPORT', 'AddField', 'String',, 'PATH')
2705
2706 CALL NLSSetText 'SW_PORT_ADD', 'Caption', 160
2707 CALL NLSSetText 'DT_ADDPORT', 'Caption', 161
2708 CALL NLSSetText 'CN_ADDPORT', 'Caption', 162
2709 CALL NLSSetText 'DT_OTHERPORT', 'Caption', 163
2710 CALL NLSSetText 'PB_OTHERPORT', 'Caption', 164
2711
2712 CALL NLSSetText 'PB_ADDPORT_OK', 'Caption', 2
2713 CALL NLSSetText 'PB_ADDPORT_CANCEL', 'Caption', 3
2714
2715 IF GetPortDrivers() > 0 THEN DO
2716 objects.0 = portdrivers.0
2717 DO i = 1 TO portdrivers.0
2718 PARSE VAR portdrivers.i _name _path
2719 SELECT
2720 WHEN _name == 'FILE' THEN _icon = '$24,PMWP'
2721 WHEN _name == 'USBPRT' THEN _icon = '$7001,'_path
2722 WHEN _name == 'SERIAL' THEN _icon = '$7001,'_path
2723 WHEN _name == 'PARALLEL' THEN _icon = '$7001,'_path
2724 WHEN _name == 'SLPR' THEN _icon = '$7001,'_path
2725 WHEN _name == 'LPRPDRVR' THEN _icon = '$256,'_path
2726 OTHERWISE _icon = _path
2727 END
2728 objects.i = ';'_name';'_icon';;;'fld_name';'_name';'fld_path';'_path
2729 END
2730 CALL VRMethod 'CN_ADDPORT', 'AddRecordList',,, 'objects.'
2731 END
2732
2733 window = VRInfo( "Object" )
2734 if( \VRIsChildOf( window, "Notebook" ) ) then do
2735 call VRMethod window, "CenterWindow"
2736 call VRSet window, "Visible", 1
2737 call VRMethod window, "Activate"
2738 end
2739 drop window
2740RETURN
2741
2742/*:VRX SW_PORTS_Close
2743*/
2744SW_PORTS_Close:
2745 call SW_PORTS_Fini
2746return
2747
2748/*:VRX SW_PORTS_Create
2749*/
2750SW_PORTS_Create:
2751 call SW_PORTS_Init
2752return
2753
2754/*:VRX SW_PORTS_Fini
2755*/
2756SW_PORTS_Fini:
2757 window = VRInfo( "Window" )
2758 call VRDestroy window
2759 drop window
2760return
2761/*:VRX SW_PORTS_Init
2762*/
2763SW_PORTS_Init: PROCEDURE EXPOSE globals.
2764
2765 globals.!hcfPorts.!icon = VRMethod( "CN_PORTS", "AddField", "Icon", "" )
2766 globals.!hcfPorts.!name = VRMethod( "CN_PORTS", "AddField", "String", NLSGetMessage( 111 ))
2767 globals.!hcfPorts.!driver = VRMethod( "CN_PORTS", "AddField", "String", NLSGetMessage( 119 ))
2768
2769 CALL VRSet "CN_PORTS", "DetailSort", globals.!hcfPorts.!name
2770 ok = VRMethod( "CN_PORTS", "SetFieldAttr", globals.!hcfPorts.!icon, "HorizSeparator", "0" )
2771
2772 CALL NLSSetText 'CN_PORTS', 'Caption', 105
2773 CALL NLSSetText 'PB_PORT_ADD', 'Caption', 8
2774 CALL NLSSetText 'PB_PORT_DELETE', 'Caption', 9
2775 CALL NLSSetText 'PB_PORT_EDIT', 'Caption', 10
2776
2777 CALL RefreshPorts
2778
2779 window = VRInfo( "Object" )
2780 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2781 call VRMethod window, "CenterWindow"
2782 call VRSet window, "Visible", 1
2783 call VRMethod window, "Activate"
2784 end
2785
2786 CALL VRSet window, 'UserData', 'CN_PORTS'
2787 drop window
2788/*
2789 globals.!initstate = globals.!initstate + 1
2790 IF globals.!initstate == 3 THEN CALL VRSet 'TM_REFRESH', 'Enabled', 1
2791*/
2792RETURN
2793
2794/*:VRX SW_PRINTERPAKS_Close
2795*/
2796SW_PRINTERPAKS_Close:
2797 call SW_PRINTERPAKS_Fini
2798return
2799
2800/*:VRX SW_PRINTERPAKS_Create
2801*/
2802SW_PRINTERPAKS_Create:
2803 call SW_PRINTERPAKS_Init
2804return
2805
2806/*:VRX SW_PRINTERPAKS_Fini
2807*/
2808SW_PRINTERPAKS_Fini:
2809 window = VRInfo( "Window" )
2810 call VRDestroy window
2811 drop window
2812return
2813/*:VRX SW_PRINTERPAKS_Init
2814*/
2815SW_PRINTERPAKS_Init: PROCEDURE EXPOSE globals.
2816
2817 globals.!hcfPaks.!icon = VRMethod( "CN_PRINTERPAKS", "AddField", "Icon", "" )
2818 globals.!hcfPaks.!name = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 173 ))
2819 globals.!hcfPaks.!version= VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 181 ))
2820 globals.!hcfPaks.!status = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 176 ))
2821 globals.!hcfPaks.!path = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 175 ))
2822 globals.!hcfPaks.!desc = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 174 ))
2823 globals.!hcfPaks.!flags = VRMethod( "CN_PRINTERPAKS", "AddField", "String", 'FLAGS')
2824
2825 CALL VRSet "CN_PRINTERPAKS", "DetailSort", globals.!hcfPaks.!name
2826 ok = VRMethod( "CN_PRINTERPAKS", "SetFieldAttr", globals.!hcfPaks.!icon, "HorizSeparator", "0" )
2827 ok = VRMethod( "CN_PRINTERPAKS", "SetFieldAttr", globals.!hcfPaks.!flags, "Visible", "0" )
2828
2829 CALL NLSSetText 'SW_PRINTERPAKS', 'Caption', 170
2830 CALL NLSSetText 'DT_PRINTERPAKS', 'Caption', 171
2831 CALL NLSSetText 'PB_PPUPDATE', 'Caption', 179
2832 CALL NLSSetText 'PB_PPCLOSE', 'Caption', 12
2833
2834 CALL GetPrinterPaks
2835
2836 window = VRInfo( "Object" )
2837 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2838 call VRMethod window, "CenterWindow"
2839 call VRSet window, "Visible", 1
2840 call VRMethod window, "Activate"
2841 end
2842 drop window
2843return
2844
2845/*:VRX SW_PRINTERS_Close
2846*/
2847SW_PRINTERS_Close:
2848 call SW_PRINTERS_Fini
2849return
2850
2851/*:VRX SW_PRINTERS_Create
2852*/
2853SW_PRINTERS_Create:
2854 call SW_PRINTERS_Init
2855return
2856
2857/*:VRX SW_PRINTERS_Fini
2858*/
2859SW_PRINTERS_Fini:
2860 window = VRInfo( "Window" )
2861 call VRDestroy window
2862 drop window
2863return
2864/*:VRX SW_PRINTERS_Init
2865*/
2866SW_PRINTERS_Init: PROCEDURE EXPOSE globals.
2867
2868 CALL NLSSetText 'CN_PRINTERS', 'Caption', 103
2869 CALL NLSSetText 'PB_PRINTER_ADD', 'Caption', 8
2870 CALL NLSSetText 'PB_PRINTER_DEL', 'Caption', 9
2871 CALL NLSSetText 'PB_PRINTER_OPEN', 'Caption', 7
2872 CALL NLSSetText 'PB_PRINTER_EDIT', 'Caption', 10
2873
2874 globals.!hcfPrinters.!icon = VRMethod( "CN_PRINTERS", "AddField", "Icon", "" )
2875 globals.!hcfPrinters.!title = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 110 ))
2876 globals.!hcfPrinters.!name = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 112 ))
2877 globals.!hcfPrinters.!queue = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 113 ))
2878 globals.!hcfPrinters.!host = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 115 ))
2879 globals.!hcfPrinters.!driver = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 116 ))
2880 globals.!hcfPrinters.!port = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 117 ))
2881 globals.!hcfPrinters.!flags = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 118 ))
2882 globals.!hcfPrinters.!handle = VRMethod( "CN_PRINTERS", "AddField", "String", "HANDLE" )
2883
2884 CALL VRSet 'CN_PRINTERS', 'DetailSort', globals.!hcfPrinters.!title
2885 CALL VRSet 'CN_PRINTERS', 'LastSplitField', globals.!hcfPrinters.!host
2886 CALL VRSet 'CN_PRINTERS', 'SplitBarLeft', 3000
2887
2888 ok = VRMethod( "CN_PRINTERS", "SetFieldAttr", globals.!hcfPrinters.!icon, "HorizSeparator", "0" )
2889 ok = VRMethod( "CN_PRINTERS", "SetFieldAttr", globals.!hcfPrinters.!handle, "Visible", "0" )
2890/* ok = VRMethod( "CN_PRINTERS", "SetFieldAttr", globals.!hcfPrinters.!flags, "Visible", "0" ) */
2891
2892 CALL RefreshPrinters
2893
2894 window = VRInfo( "Object" )
2895 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2896 call VRMethod window, "CenterWindow"
2897 call VRSet window, "Visible", 1
2898 call VRMethod window, "Activate"
2899 end
2900
2901 CALL VRSet window, 'UserData', 'CN_PRINTERS'
2902 drop window
2903/*
2904 globals.!initstate = globals.!initstate + 1
2905 IF globals.!initstate == 3 THEN CALL VRSet 'TM_REFRESH', 'Enabled', 1
2906*/
2907
2908RETURN
2909
2910/*:VRX SW_PRINTERS_Resize
2911*/
2912SW_PRINTERS_Resize:
2913
2914return
2915
2916/*:VRX SW_WIZARD_Close
2917*/
2918SW_WIZARD_Close:
2919 call SW_WIZARD_Fini
2920return
2921
2922/*:VRX SW_WIZARD_Create
2923*/
2924SW_WIZARD_Create:
2925 call SW_WIZARD_Init
2926return
2927
2928/*:VRX SW_WIZARD_Fini
2929*/
2930SW_WIZARD_Fini:
2931 window = VRInfo( "Window" )
2932 call VRDestroy window
2933 drop window
2934
2935 IF globals.!wizard THEN CALL Quit
2936 ELSE DO
2937 call VRSet 'WN_MAIN', "Visible", 1
2938 IF globals.!create_mode == '' THEN DO
2939 call VRMethod 'WN_MAIN', "Activate"
2940 CALL VRMethod 'TDL_MAIN', 'SetFocus'
2941 END
2942 END
2943RETURN
2944/*:VRX SW_WIZARD_Init
2945*/
2946SW_WIZARD_Init:
2947
2948 CALL NLSSetText 'SW_WIZARD', 'Caption', 140
2949 IF globals.!wizard THEN
2950 CALL NLSSetText 'DT_WIZARD', 'Caption', 142
2951 ELSE
2952 CALL NLSSetText 'DT_WIZARD', 'Caption', 141
2953 CALL NLSSetText 'RB_CREATE_CUPS', 'Caption', 143
2954 CALL NLSSetText 'RB_CREATE_LEGACY', 'Caption', 144
2955 CALL NLSSetText 'RB_CREATE_STANDARD', 'Caption', 145
2956 CALL NLSSetText 'RB_CREATE_LAN', 'Caption', 146
2957 CALL NLSSetText 'RB_ADVANCED', 'Caption', 147
2958 CALL NLSSetText 'PB_WIZARD_NEXT', 'Caption', 11
2959 CALL NLSSetText 'PB_WIZARD_CANCEL', 'Caption', 3
2960 CALL NLSSetText 'PB_WIZARD_HELP', 'Caption', 4
2961
2962 IF globals.!wizard THEN CALL VRSet 'RB_ADVANCED', 'Visible', 1
2963 window = VRInfo( "Object" )
2964 if( \VRIsChildOf( window, "Notebook" ) ) then do
2965 call VRMethod window, "CenterWindow"
2966 call VRSet window, "Visible", 1
2967 call VRMethod window, "Activate"
2968 end
2969 drop window
2970
2971 globals.!create_mode = ''
2972
2973RETURN
2974
2975/*:VRX TDL_MAIN_PageSelected
2976*/
2977TDL_MAIN_PageSelected: PROCEDURE EXPOSE globals.
2978 _pageidx = VRInfo("Page")
2979 _pagewin = VRMethod( "TDL_MAIN", "GetPageWindow", _pageidx )
2980 _cnr = VRGet( _pagewin, "UserData")
2981 IF _cnr == '' THEN RETURN
2982
2983 _view = VRGet( _cnr, "View")
2984 IF _view == 'Detail' THEN DO
2985 CALL VRSet 'MI_ICONVIEW', 'Checked', 0
2986 CALL VRSet 'MI_DETAILVIEW', 'Checked', 1
2987 CALL VRSet 'MI_CONTEXT_ICON', 'Checked', 0
2988 CALL VRSet 'MI_CONTEXT_DETAIL', 'Checked', 1
2989 END
2990 ELSE DO
2991 CALL VRSet 'MI_ICONVIEW', 'Checked', 1
2992 CALL VRSet 'MI_DETAILVIEW', 'Checked', 0
2993 CALL VRSet 'MI_CONTEXT_ICON', 'Checked', 1
2994 CALL VRSet 'MI_CONTEXT_DETAIL', 'Checked', 0
2995 END
2996/*
2997 SELECT
2998 WHEN _cnr == 'CN_PRINTERS' THEN DO
2999 END
3000 WHEN _cnr == 'CN_PORTS' THEN DO
3001 END
3002 WHEN _cnr == 'CN_DEVICES' THEN DO
3003 END
3004 OTHERWISE DO
3005 END
3006 END
3007*/
3008RETURN
3009
3010/*:VRX WN_MAIN_Close
3011*/
3012WN_MAIN_Close:
3013 call Quit
3014return
3015
3016/*:VRX xxUpdatePrDesc
3017*/
3018xxUpdatePrDesc: PROCEDURE EXPOSE globals.
3019 ARG driver, fqn
3020
3021 IF globals.!prdesc == '' THEN RETURN 1
3022
3023 ok = RPUEnumModels( fqn, 'newdevs.')
3024 IF ok == 0 THEN RETURN 2
3025
3026 _count = 0
3027 CALL LINEIN globals.!prdesc, 1, 0
3028 DO WHILE LINES( globals.!prdesc )
3029 _next = LINEIN( globals.!prdesc )
3030 PARSE UPPER VAR _next WITH . ':' . '('_prdrv')' .
3031 IF _prdrv == driver THEN ITERATE
3032 _count = _count + 1
3033 prdefs.count = _next
3034 END
3035 CALL STREAM prdesc, 'C', 'CLOSE'
3036
3037 DO i = 1 TO devs.0
3038 _count = _count + 1
3039 prdefs._count = newdevs.i':' newdevs.i '('driver')'
3040 END
3041 prdefs.0 = count
3042
3043 CALL VRSortStem 'prdefs.'
3044
3045 _prdir = VRParseFileName( globals.!prdesc, 'DP')
3046 CALL VRCopyFile globals.!prdesc, _prdir'\PRDESC.BAK'
3047 CALL VRDeleteFile globals.!prdesc
3048 DO i = 1 TO prdefs.0
3049 CALL LINEOUT globals.!prdesc, prdefs.i
3050 END
3051 CALL LINEOUT globals.!prdesc
3052
3053RETURN 0
3054
Note: See TracBrowser for help on using the repository browser.