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

Last change on this file since 73 was 72, checked in by Alex Taylor, 7 years ago

Fix some errors exposed by Object REXX

File size: 98.9 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.82'
914 globals.!copyright = '2013-2018'
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 _temps.0 = 0
1276 IF WPToolsFolderContent('<WP_TEMPS>', '_temps.', 'F') THEN
1277 DO i = 1 TO _temps.0
1278 IF WPToolsQueryObject( _temps.i, 'szClass') THEN DO
1279 IF szClass == _class THEN DO
1280 ok = WPToolsSetObjectData( _temps.i, 'OPEN=DEFAULT;')
1281 LEAVE
1282 END
1283 END
1284 END
1285
1286 IF ok == 0 THEN DO
1287 IF SysCreateObject( _class, _class, globals.!tmpdir,,
1288 'OBJECTID=<TEMP_PRT>;TAKEDEFAULTS=NO;TEMPLATE=YES', 'R') THEN
1289 DO
1290 ok = SysSetObjectData('<TEMP_PRT>','OPEN=DEFAULT;')
1291 CALL SysDestroyObject '<TEMP_PRT>'
1292 END
1293 END
1294
1295RETURN ok
1296
1297/*:VRX PB_ABOUT_OK_Click
1298*/
1299PB_ABOUT_OK_Click:
1300 CALL SW_ABOUT_Close
1301RETURN
1302
1303/*:VRX PB_ADDPORT_CANCEL_Click
1304*/
1305PB_ADDPORT_CANCEL_Click:
1306 CALL SW_PORT_ADD_Close
1307RETURN
1308
1309/*:VRX PB_ADDPORT_OK_Click
1310*/
1311PB_ADDPORT_OK_Click: PROCEDURE EXPOSE globals. updated
1312
1313 ok = VRMethod('CN_ADDPORT', 'GetRecordList', 'Selected', 'recs.')
1314 IF ok == 0 | recs.0 < 1 THEN RETURN
1315 record = recs.1
1316
1317 _name = VRMethod('CN_ADDPORT', 'GetFieldData', record, 'NAME')
1318 btns.0 = 2
1319 btns.1 = NLSGetMessage( 14 )
1320 btns.2 = NLSGetMessage( 15 )
1321 ok = VRMessage('SW_PORT_ADD', NLSGetMessage( 205, _name ), NLSGetMessage( 200 ), 'Q', 'btns.', 1, 2 )
1322 IF ok == 1 THEN DO
1323 _portname = GetNextPortName( _name )
1324 ok = RPUPortInstall( _name, _portname )
1325 IF ok <> 1 THEN
1326 CALL VRMessage 'SW_PORT_ADD', NLSGetMessage( 167 ) RPUERROR, NLSGetMessage( 13 ), 'E'
1327 ELSE DO
1328 CALL RPUPortDialog _name, _portname
1329 CALL SW_PORT_ADD_Close
1330 updated = 1
1331 END
1332 END
1333
1334RETURN ok
1335
1336/*:VRX PB_DEVICE_ADD_Click
1337*/
1338PB_DEVICE_ADD_Click:
1339 CALL DriverAdd
1340RETURN
1341
1342/*:VRX PB_DEVICE_CANCEL_Click
1343*/
1344PB_DEVICE_CANCEL_Click:
1345 CALL SW_DEVICE_ADD_Close
1346RETURN
1347
1348/*:VRX PB_DEVICE_INSTALL_Click
1349*/
1350PB_DEVICE_INSTALL_Click: PROCEDURE EXPOSE globals. updated
1351 updated = 1
1352
1353 ok = VRMethod('CN_DEVICE_LIST', 'GetRecordList', 'Selected', 'recs.')
1354 IF ok == 0 THEN RETURN
1355 IF recs.0 == 0 THEN RETURN
1356 selected = recs.1
1357
1358 dev_name = VRMethod('CN_DEVICE_LIST', 'GetFieldData', selected, 'NAME')
1359 dev_driver = VRMethod('CN_DEVICE_LIST', 'GetFieldData', selected, 'DRIVER')
1360 driver_short = TRANSLATE( VRParseFileName( dev_driver, 'N'))
1361 IF dev_name == '' | dev_driver == '' | driver_short == '' THEN RETURN
1362
1363 /* Shipped drivers don't include the FQ path in dev_driver so we must
1364 * resolve it first.
1365 */
1366 IF VRGet('RB_DEVICE_SHIPPED', 'Set') == 1 THEN
1367 dev_driver = GetDriverSource( driver_short )
1368 IF dev_driver == '' THEN RETURN
1369
1370 ok = InstallPrintDriver( driver_short, dev_driver, dev_name )
1371
1372 IF ok <> 0 THEN DO
1373 CALL VRMessage VRWindow(), NLSGetMessage( 168, driver_short'.'dev_name ), NLSGetMessage( 13 ), 'E'
1374 END
1375 CALL SW_DEVICE_ADD_Close
1376
1377RETURN
1378
1379/*:VRX PB_DEVICE_OTHER_Click
1380*/
1381PB_DEVICE_OTHER_Click: PROCEDURE EXPOSE globals. shipped.
1382
1383 old_path = VRGet('DDCB_DEVICE_3RDPARTY', 'UserData')
1384 new_path = VRXDirectoryDialog( VRWindow(), old_path, NLSGetMessage( 189 ))
1385 IF new_path == '' THEN RETURN
1386 IF old_path == TRANSLATE( new_path ) THEN RETURN
1387
1388 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Value', new_path
1389 CALL SetDriverList new_path
1390
1391RETURN
1392
1393/*:VRX PB_DEVICE_REFRESH_Click
1394*/
1395PB_DEVICE_REFRESH_Click: PROCEDURE EXPOSE globals. shipped.
1396 CALL SetDriverList
1397return
1398
1399/*:VRX PB_DEVICE_REMOVE_Click
1400*/
1401PB_DEVICE_REMOVE_Click:
1402 CALL DriverDelete
1403RETURN
1404
1405/*:VRX PB_DEVICE_REMOVE_KeyPress
1406*/
1407PB_DEVICE_REMOVE_KeyPress:
1408 IF VRGet('PB_DEVICE_REMOVE', 'KeyString') == '{Tab}' THEN
1409 CALL VRMethod 'TDL_MAIN', 'SetFocus'
1410return
1411
1412/*:VRX PB_IMPORTCANCEL_Click
1413*/
1414PB_IMPORTCANCEL_Click:
1415 CALL SW_IMPORT_Close
1416return
1417
1418/*:VRX PB_IMPORTOK_Click
1419*/
1420PB_IMPORTOK_Click: PROCEDURE EXPOSE globals. new_ppd
1421
1422 IF VRGet('RB_IMPORTCUPS', 'Set') == 1 THEN DO
1423 CALL New_CUPS new_ppd
1424 CALL SW_IMPORT_Close
1425 CALL VRSet 'WN_MAIN', 'Shutdown', 1
1426 RETURN
1427 END
1428 driver = VRGet('DDCB_IMPORTDRV', 'Value')
1429 ok = ImportPPD( driver, new_ppd ) /* Also sets driver_path variable */
1430
1431 SELECT
1432 /* Check the return code from ImportPPD and display an appropriate message.
1433 */
1434
1435 WHEN ok == 0 THEN DO /* Success! */
1436 _message = NLSGetMessage( 238 )
1437 _mbtitle = NLSGetMessage( 16 )
1438 _mbicon = 'I'
1439 END
1440
1441 /* Note: Error codes 1 & 2 are ignored here.
1442 * 1 means the user cancelled, so no message is required.
1443 * For 2, ImportPPD itself already displayed the error message.
1444 */
1445
1446 WHEN ok == 3 THEN DO /* Invalid path specified */
1447 _message = NLSGetMessage( 222 )
1448 _mbtitle = NLSGetMessage( 13 )
1449 _mbicon = 'E'
1450 END
1451 WHEN ok == 4 THEN DO /* Failed to copy driver files */
1452 _message = NLSGetMessage( 220 )
1453 _mbtitle = NLSGetMessage( 13 )
1454 _mbicon = 'E'
1455 END
1456 WHEN ok == 5 THEN DO /* Failed to create directory */
1457 _message = NLSGetMessage( 221 )
1458 _mbtitle = NLSGetMessage( 13 )
1459 _mbicon = 'E'
1460 END
1461 WHEN ok == 6 THEN DO /* PPD import failed */
1462 _message = NLSGetMessage( 223 )
1463 _mbtitle = NLSGetMessage( 13 )
1464 _mbicon = 'E'
1465 END
1466 WHEN ok == 7 THEN DO /* Error updating PRDESC.LST */
1467 _message = NLSGetMessage( 224, globals.!prdesc )
1468 _mbtitle = NLSGetMessage( 13 )
1469 _mbicon = 'E'
1470 END
1471
1472 OTHERWISE DO
1473 _message = ''
1474 _mbtitle = ''
1475 _mbicon = 'N'
1476 END
1477 END
1478
1479 IF message <> '' THEN
1480 CALL VRMessage VRWindow(), _message, _mbtitle, _mbicon
1481
1482 IF ok == 0 THEN DO
1483 /* The PPD was imported into the driver install directory. Now we should
1484 * ask the user if they want to actually install this printer driver so
1485 * that existing printer objects can use it.
1486 */
1487 _new_model = GetNameFromPPD( new_ppd )
1488 _btns.0 = 2
1489 _btns.1 = NLSGetMessage( 14 )
1490 _btns.2 = NLSGetMessage( 15 )
1491 _create = VRMessage( VRWindow(), NLSGetMessage( 240, _new_model ) || '0d0d0a'x ||,
1492 NLSGetMessage( 241 ), NLSGetMessage( 239 ), 'Q', '_btns.', 1, 2 )
1493 IF _create == 1 THEN DO
1494 _ipd = InstallPrintDriver( driver, driver_path, _new_model )
1495 IF _ipd <> 0 THEN
1496 CALL VRMessage VRWindow(), NLSGetMessage( 168, driver'.'_new_model ), NLSGetMessage( 13 ), 'E'
1497 ELSE
1498 CALL RefreshDevices
1499 END
1500 END
1501
1502 CALL SW_IMPORT_Close
1503RETURN
1504
1505/*:VRX PB_MODELS_CLOSE_Click
1506*/
1507PB_MODELS_CLOSE_Click:
1508 CALL SW_MODELS_Close
1509return
1510
1511/*:VRX PB_OTHERPORT_Click
1512*/
1513PB_OTHERPORT_Click: PROCEDURE EXPOSE globals.
1514 _new_pdr = VRFileDialog('SW_PORT_ADD', NLSGetMessage( 165 ), 'O', '*.PDR')
1515 IF _new_pdr == '' THEN RETURN 0
1516
1517 ok = InstallPortDriver( _new_pdr )
1518 IF ok == 0 THEN DO
1519 _name = VRParseFileName( _new_pdr, 'N')
1520 _rec = VRMethod('CN_ADDPORT', 'AddRecord',,, _name, _new_pdr )
1521 CALL VRMethod 'CN_ADDPORT', 'SetFieldData', _rec, 'NAME', _name, 'PATH', _new_pdr
1522 END
1523 ELSE
1524 CALL VRMessage 'SW_PORT_ADD', NLSGetMessage( 166 ) || '0a0a'x || VRError(), NLSGetMessage( 13 ), 'E'
1525RETURN ok
1526
1527/*:VRX PB_PORT_ADD_Click
1528*/
1529PB_PORT_ADD_Click:
1530 CALL PortAdd
1531RETURN
1532
1533/*:VRX PB_PORT_DELETE_Click
1534*/
1535PB_PORT_DELETE_Click:
1536 CALL PortDelete
1537return
1538
1539/*:VRX PB_PORT_EDIT_Click
1540*/
1541PB_PORT_EDIT_Click:
1542 CALL PortProperties
1543return
1544
1545/*:VRX PB_PORT_EDIT_KeyPress
1546*/
1547PB_PORT_EDIT_KeyPress:
1548 IF VRGet('PB_PORT_EDIT', 'KeyString') == '{Tab}' THEN
1549 CALL VRMethod 'TDL_MAIN', 'SetFocus'
1550return
1551
1552/*:VRX PB_PPCLOSE_Click
1553*/
1554PB_PPCLOSE_Click:
1555 CALL SW_PRINTERPAKS_Close
1556return
1557
1558/*:VRX PB_PPUPDATE_Click
1559*/
1560PB_PPUPDATE_Click: PROCEDURE EXPOSE globals.
1561
1562 /* Let the user select the driver .DRV to install.
1563 */
1564 new_drv = VRFileDialog( VRWindow(), NLSGetMessage( 182 ), 'O', '*.DRV')
1565 IF new_drv == '' THEN RETURN 0
1566
1567 drv_stem = TRANSLATE( VRParseFileName( new_drv, 'N'))
1568 drv_name = TRANSLATE( VRParseFileName( new_drv, 'NE'))
1569 drv_source = TRANSLATE( VRParseFileName( new_drv, 'DP'))
1570
1571 /* See if this is the same as an existing driver (compared by filename).
1572 */
1573 existing = 0
1574 skip_repo = 0
1575 ok = VRMethod('CN_PRINTERPAKS', 'GetRecordList', 'All', 'recs.')
1576 DO i = 1 TO recs.0
1577 _ppname = VRMethod('CN_PRINTERPAKS', 'GetFieldData', recs.i, globals.!hcfPaks.!name )
1578 IF TRANSLATE( _ppname ) == TRANSLATE( new_name ) THEN DO
1579 existing = 1
1580 _pppath = VRMethod('CN_PRINTERPAKS', 'GetFieldData', recs.i, globals.!hcfPaks.!path )
1581 LEAVE
1582 END
1583 END
1584
1585 PARSE UPPER VALUE VRGetIni('PrinterManager', 'ThirdParty', 'USER') WITH known_3p '00'x .
1586 IF known_3p == '' THEN
1587 known_3p = 'ECUPS ECUPS-HP GUTENPRT PSPRINT'
1588
1589 IF existing THEN DO
1590 drv_target = TRANSLATE( _pppath )
1591 IF drv_source == drv_target THEN DO
1592 CALL VRMessage VRWindow(), NLSGetMessage( 183 ), NLSGetMessage( 13 ), 'E'
1593 RETURN 1
1594 END
1595 IF CheckWritablePath( drv_target ) <> 0 THEN DO
1596 existing = 0
1597 _msg.1 = NLSGetMessage( 185, drv_target )
1598 _msg.2 = ''
1599 _msg.3 = NLSGetMessage( 186, drv_name )
1600 _msg.0 = 3
1601 _btns.1 = NLSGetMessage( 2 )
1602 _btns.2 = NLSGetMessage( 3 )
1603 _btns.0 = 2
1604 _select = VRMessageStem( VRWindow(), '_msg.', NLSGetMessage( 184 ),
1605 'I', '_btns.', 1, 2 )
1606 IF _select == 2 THEN skip_repo = 1
1607 END
1608 END
1609
1610 IF \skip_repo THEN DO
1611 IF \existing THEN DO
1612 /* If we already know about this driver, try and get its saved location. */
1613 drv_target = ''
1614 IF WORDPOS( drv_stem, known_3p ) > 0 THEN
1615 PARSE UPPER VALUE VRGetIni('PM_INSTALL', drv_stem'_DIR', 'USER') WITH drv_target '00'x .
1616 ELSE DO
1617 known_3p = known_3p drv_stem
1618 CALL VRSetIni 'PrinterManager', 'ThirdParty', known_3p || '00'x, 'USER'
1619 END
1620 IF drv_target == '' THEN DO
1621 drv_target = globals.!repository'\'drv_stem
1622 _btns.1 = NLSGetMessage( 2 )
1623 _btns.2 = NLSGetMessage( 3 )
1624 _btns.3 = NLSGetMessage( 188 )
1625 _btns.0 = 3
1626 DO UNTIL _select <> 3
1627 _select = VRPrompt( VRWindow(), NLSGetMessage( 187, drv_name ),,
1628 'drv_target', NLSGetMessage( 189 ), '_btns.', 1, 2 )
1629 IF _select == 3 THEN
1630 drv_target = VRXDirectoryDialog( VRWindow(), drv_target, NLSGetMessage( 189 ))
1631 END
1632 IF _select == 2 THEN
1633 skip_repo = 1
1634 ELSE
1635 CALL VRSetIni 'PM_INSTALL', drv_stem'_DIR', TRANSLATE( drv_target ) || '00'x, 'USER'
1636 END
1637 END
1638
1639 IF \skip_repo THEN DO
1640 IF VRFileExists( drv_target ) THEN DO
1641 /* Clear any RHS attributes on existing files */
1642 CALL SysFileTree drv_target'\*', '_ignore.',,, '**---'
1643 CALL PRReplaceModule drv_target'\'drv_name, '', ''
1644 END
1645 ELSE
1646 /* Create the target directory if necessary */
1647 ok = VRMkDir( drv_target )
1648
1649 ok = CopyPrinterPak( new_drv, drv_target )
1650
1651 /* Update any previously-imported PPDs for this driver
1652 */
1653 IF ok == 1 THEN DO
1654/* TODO use drv_target and parse it for pmdx directly */
1655 driver_path = GetDriverSource( drv_stem ) /* Also sets pmdx */
1656 IF pmdx == '' THEN
1657 driver_repo = 0
1658 ELSE
1659 driver_repo = 1
1660 pwok = PinWrapper( 0, drv_stem, '')
1661 IF pwok <> 0 THEN DO
1662 CALL CHAROUT globals.!log1, 'Encountered error' pwok 'from PIN wrapper:'
1663 SELECT
1664 WHEN ok == 3 THEN CALL LINEOUT globals.!log1, 'Invalid path specified'
1665 WHEN ok == 4 THEN CALL LINEOUT globals.!log1, 'Failed to copy driver files'
1666 WHEN ok == 5 THEN CALL LINEOUT globals.!log1, 'Failed to create directory'
1667 WHEN ok == 6 THEN CALL LINEOUT globals.!log1, 'PPD import failed'
1668 WHEN ok == 7 THEN CALL LINEOUT globals.!log1, 'Error updating PRDESC.LST'
1669 OTHERWISE CALL LINEOUT globals.!log1, 'Unknown error ('pwok')'
1670 END
1671 ok = 0
1672 END
1673 END
1674
1675 IF existing & ok == 1 THEN DO
1676 CALL UpdatePrDesc drv_name, drv_target'\'drv_name
1677 END
1678 IF ok == 0 THEN DO
1679 CALL VRMessage VRWindow(), NLSGetMessage( 220 ), NLSGetMessage( 13 ), 'E'
1680 RETURN 2
1681 END
1682 ELSE
1683 CALL VRMessage VRWindow(), NLSGetMessage( 193 ), NLSGetMessage( 16 ), 'I'
1684
1685 new_drv = drv_target'\'drv_name
1686 END
1687 END
1688
1689 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', drv_stem, 'USER') WITH drv_used '00'x .
1690 IF ( drv_used <> '') & VRFileExists( drv_used ) THEN DO
1691 /* Driver is currently installed; ask if the user wants to update the
1692 * in-use copy as well.
1693 */
1694 _btns.1 = NLSGetMessage( 14 )
1695 _btns.2 = NLSGetMessage( 15 )
1696 _btns.0 = 2
1697 _select = VRMessage( VRWindow(), NLSGetMessage( 190 ), NLSGetMessage( 191 ), 'Q', '_btns.', 1, 2 )
1698 IF _select == 1 THEN DO
1699 CALL PRSetFileAttr drv_used , 'rsh'
1700 CALL PRReplaceModule drv_used, '', ''
1701 used_target = VRParseFileName( drv_used, 'DP')
1702 ok = CopyPrinterPak( new_drv, used_target )
1703 IF ok == 0 THEN DO
1704 CALL VRMessage VRWindow(), NLSGetMessage( 220 ), NLSGetMessage( 13 ), 'E'
1705 RETURN 2
1706 END
1707 ELSE
1708 CALL VRMessage VRWindow(), NLSGetMessage( 192 ), NLSGetMessage( 16 ), 'I'
1709 END
1710 END
1711
1712 /* Refresh the list */
1713 CALL GetPrinterPaks
1714RETURN 0
1715
1716/*:VRX PB_PRINTER_ADD_Click
1717*/
1718PB_PRINTER_ADD_Click:
1719 CALL PrinterWizard
1720RETURN
1721
1722/*:VRX PB_PRINTER_DEL_Click
1723*/
1724PB_PRINTER_DEL_Click:
1725 CALL PrinterDelete
1726return
1727
1728/*:VRX PB_PRINTER_EDIT_Click
1729*/
1730PB_PRINTER_EDIT_Click:
1731 CALL PrinterProperties
1732RETURN
1733
1734/*:VRX PB_PRINTER_EDIT_KeyPress
1735*/
1736PB_PRINTER_EDIT_KeyPress:
1737 IF VRGet('PB_PRINTER_EDIT', 'KeyString') == '{Tab}' THEN
1738 CALL VRMethod 'TDL_MAIN', 'SetFocus'
1739return
1740
1741/*:VRX PB_PRINTER_OPEN_Click
1742*/
1743PB_PRINTER_OPEN_Click:
1744 CALL PrinterOpen
1745RETURN
1746
1747/*:VRX PB_WIZARD_CANCEL_Click
1748*/
1749PB_WIZARD_CANCEL_Click:
1750
1751 CALL SW_WIZARD_Close
1752
1753return
1754
1755/*:VRX PB_WIZARD_NEXT_Click
1756*/
1757PB_WIZARD_NEXT_Click: PROCEDURE EXPOSE globals.
1758 SELECT
1759 WHEN VRGet('RB_CREATE_CUPS', 'Set') == 1 THEN DO
1760 globals.!create_mode = 'C'
1761 CALL New_CUPS
1762 END
1763 WHEN ( VRGet('RB_CREATE_LEGACY', 'Set') == 1 ) & ( VRGet('RB_CREATE_STANDARD', 'Set') == 1 ) THEN DO
1764 globals.!create_mode = 'S'
1765 CALL New_Standard
1766 END
1767 WHEN ( VRGet('RB_CREATE_LEGACY', 'Set') == 1 ) & ( VRGet('RB_CREATE_LAN', 'Set') == 1 ) THEN DO
1768 globals.!create_mode = 'L'
1769 CALL New_LAN
1770 END
1771 OTHERWISE DO
1772 globals.!create_mode = ''
1773 globals.!wizard = 0
1774 END
1775 END
1776 CALL SW_WIZARD_Fini
1777
1778RETURN
1779
1780/*:VRX PortAdd
1781*/
1782PortAdd: PROCEDURE EXPOSE globals.
1783
1784 updated = 0
1785 CALL VRLoadSecondary 'SW_PORT_ADD', 'W'
1786 IF updated == 1 THEN
1787 CALL RefreshPorts
1788
1789RETURN
1790
1791/*:VRX PortDelete
1792*/
1793PortDelete: PROCEDURE EXPOSE globals.
1794 PARSE ARG record
1795 IF record == '' THEN DO
1796 ok = VRMethod( "CN_PORTS", "GetRecordList", "Selected", "recs." )
1797 IF ok == 0 | recs.0 < 1 THEN RETURN
1798 record = recs.1
1799 END
1800 CALL VRMethod 'CN_PORTS', 'SetRecordAttr', record, 'Source', 0
1801
1802 _name = VRMethod('CN_PORTS', 'GetFieldData', record, globals.!hcfPorts.!name )
1803
1804 printers.0 = 0
1805 CALL RPUEnumPrinters 'printers.'
1806 DO i = 1 TO printers.0
1807 CALL RPUPrinterQuery printers.i.!name, 'details.'
1808 IF _name == details.!port THEN DO
1809 _title = TRANSLATE( printers.i.!description, ' ', '0d0a'x)
1810 CALL VRMessage 'WN_MAIN', NLSGetMessage( 206, _name, _title ), NLSGetMessage( 207 ), 'W'
1811 RETURN
1812 END
1813 END
1814
1815 IF _name == '' THEN RETURN
1816 _btns.0 = 2
1817 _btns.1 = NLSGetMessage( 14 )
1818 _btns.2 = NLSGetMessage( 15 )
1819 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 202, _name ), NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
1820 IF _confirm == 1 THEN DO
1821 CALL LINEOUT globals.!log1, 'Deleting port' _name
1822 success = RPUPortDelete( _name )
1823 IF success <> 1 THEN CALL LINEOUT globals.!log1, 'Error deleting port:' RPUERROR
1824 CALL RefreshPorts
1825 END
1826
1827RETURN
1828
1829/*:VRX PortProperties
1830*/
1831PortProperties: PROCEDURE EXPOSE globals.
1832 PARSE ARG record
1833 IF record == '' THEN DO
1834 ok = VRMethod( "CN_PORTS", "GetRecordList", "Selected", "recs." )
1835 IF ok == 0 | recs.0 < 1 THEN RETURN
1836 record = recs.1
1837 END
1838
1839 _name = VRMethod('CN_PORTS', 'GetFieldData', record, globals.!hcfPorts.!name )
1840 _module = VRMethod('CN_PORTS', 'GetFieldData', record, globals.!hcfPorts.!driver )
1841 IF _module == '' THEN DO
1842 CALL VRMessage VRWindow(), NLSGetMessage( 211, _name ), NLSGetMessage( 210 ), 'N'
1843 RETURN
1844 END
1845
1846 CALL RPUPortDialog _module, _name
1847
1848 CALL VRMethod 'CN_PORTS', 'SetRecordAttr', record, 'Source', 0
1849RETURN
1850
1851/*:VRX PrinterDelete
1852*/
1853PrinterDelete: PROCEDURE EXPOSE globals.
1854 PARSE ARG record
1855 IF record == '' THEN DO
1856 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1857 IF ok == 0 | recs.0 < 1 THEN RETURN 0
1858 record = recs.1
1859 END
1860 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1861
1862 success = 0
1863 _title = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!title )
1864 _device= VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!name )
1865 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1866 _port = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!port )
1867
1868 _btns.0 = 2
1869 _btns.1 = NLSGetMessage( 14 )
1870 _btns.2 = NLSGetMessage( 15 )
1871 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 201, _title ), NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
1872 IF _confirm == 1 THEN DO
1873
1874 IF _queue == '' THEN DO
1875 CALL LINEOUT globals.!log1, 'Printer' _device '(no queue) will be deleted.'
1876 success = RPUDeviceDelete( _device )
1877 END
1878 ELSE DO
1879 CALL LINEOUT globals.!log1, 'Printer' _device 'with queue' _queue 'will be deleted.'
1880 success = RPUPrinterDelete( _queue )
1881 END
1882 CALL LINEOUT globals.!log1, 'Deletion status:' success
1883
1884 CALL RPUPortInfo _port, 'port.'
1885 IF port.!driver == 'CUPS' THEN DO
1886 /* If this corresponds to a locally-defined CUPS queue, offer to
1887 * to delete that as well.
1888 */
1889 cups_prnt = RPUPortQuery('CUPS', _port )
1890 IF cups_prnt <> '' & ( LENGTH( cups_prnt ) == 130 ) THEN DO
1891 PARSE VAR cups_prnt 1 _cups_host 66 _cups_queue
1892 PARSE VAR _cups_host cups_host '00'x .
1893 PARSE VAR _cups_queue cups_queue '00'x .
1894 IF ( TRANSLATE( cups_host ) == 'LOCALHOST') | cups_host = '127.0.0.1' THEN DO
1895 CALL LINEOUT globals.!log1, 'Printer points to local CUPS queue' cups_queue 'via port:' _port
1896 _confirm = VRMessage('WN_MAIN', NLSGetMessage( 204, _title, cups_queue, _port ),,
1897 NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
1898 IF _confirm == 1 THEN DO
1899 CALL LINEOUT globals.!log1, 'Deleting CUPS printer' cups_queue 'on host' cups_host'.'
1900 success = CupsDeletePrinter( cups_host, cups_queue )
1901 CALL LINEOUT globals.!log1, 'CUPS deletion status:' success
1902 IF success == 0 THEN DO
1903 CALL RPUPortDelete _port
1904 CALL RefreshPorts
1905 END
1906 ELSE
1907 CALL VRMessage 'WN_MAIN', NLSGetMessage( 251, cups_queue, success ), NLSGetMessage( 18 ), 'E'
1908 END
1909 END
1910 END
1911 END
1912 END
1913
1914 CALL RefreshPrinters
1915
1916RETURN success
1917
1918/*:VRX PrinterHold
1919*/
1920PrinterHold: PROCEDURE EXPOSE globals.
1921 PARSE ARG record
1922 IF record == '' THEN DO
1923 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1924 IF ok == 0 | recs.0 < 1 THEN RETURN
1925 record = recs.1
1926 END
1927 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1928 _flags = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!flags )
1929 _p = POS('P', _flags )
1930 IF _p > 0 THEN DO
1931 ok = RPUQueueHold( _queue, 'N')
1932 IF ok == 1 THEN DO
1933 CALL VRSet 'MI_PRINTER_HOLD', 'Checked', 0
1934 _flags = DELSTR( _flags, _p, 1 )
1935 CALL VRMethod 'CN_PRINTERS', 'SetFieldData', record, globals.!hcfPrinters.!flags, _flags
1936 END
1937 END
1938 ELSE DO
1939 ok = RPUQueueHold( _queue, 'Y')
1940 IF ok == 1 THEN DO
1941 CALL VRSet 'MI_PRINTER_HOLD', 'Checked', 1
1942 _flags = _flags'P'
1943 CALL VRMethod 'CN_PRINTERS', 'SetFieldData', record, globals.!hcfPrinters.!flags, _flags
1944 END
1945 END
1946
1947 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1948RETURN
1949
1950/*:VRX PrinterOpen
1951*/
1952PrinterOpen: PROCEDURE EXPOSE globals.
1953 PARSE ARG record
1954 IF record == '' THEN DO
1955 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1956 IF ok == 0 | recs.0 < 1 THEN RETURN
1957 record = recs.1
1958 END
1959
1960 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1961 IF _queue <> '' THEN
1962 CALL RPUOpenView _queue, 'O'
1963
1964 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1965RETURN
1966
1967/*:VRX PrinterProperties
1968*/
1969PrinterProperties: PROCEDURE EXPOSE globals.
1970 PARSE ARG record
1971 IF record == '' THEN DO
1972 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1973 IF ok == 0 | recs.0 < 1 THEN RETURN
1974 record = recs.1
1975 END
1976
1977 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1978 IF _queue <> '' THEN
1979 CALL RPUOpenView _queue, 'S'
1980
1981 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
1982RETURN
1983
1984/*:VRX PrinterSetDefault
1985*/
1986PrinterSetDefault: PROCEDURE EXPOSE globals.
1987 PARSE ARG record
1988 IF record == '' THEN DO
1989 ok = VRMethod( "CN_PRINTERS", "GetRecordList", "Selected", "recs." )
1990 IF ok == 0 | recs.0 < 1 THEN RETURN 0
1991 record = recs.1
1992 END
1993 _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
1994 ok = RPUQueueDefault( _queue )
1995
1996/*** Would also need to remove 'D' flag from previous default printer. Simpler
1997 *** just to call RefreshPrinters (below) instead.
1998 *
1999 * IF ok == 1 THEN DO
2000 * CALL VRSet 'MI_PRINTER_DEFAULT', 'Checked', 1
2001 * _flags = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!flags )
2002 * IF POS( _flags, 'D') == 0 THEN DO
2003 * _flags = 'D'_flags
2004 * CALL VRMethod 'CN_PRINTERS', 'SetFieldData', record, globals.!hcfPrinters.!flags, _flags
2005 * END
2006 * END
2007 */
2008
2009 CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
2010 CALL RefreshPrinters
2011RETURN ok
2012
2013/*:VRX PrinterWizard
2014*/
2015PrinterWizard: PROCEDURE EXPOSE globals.
2016 CALL VRLoadSecondary 'SW_WIZARD', 'N'
2017RETURN
2018
2019/*:VRX Quit
2020*/
2021Quit:
2022 window = VRWindow()
2023 call VRSet window, "Shutdown", 1
2024 drop window
2025return
2026
2027/*:VRX RB_ADVANCED_Click
2028*/
2029RB_ADVANCED_Click: PROCEDURE
2030 CALL VRSet 'RB_CREATE_STANDARD', 'Enabled', 0
2031 CALL VRSet 'RB_CREATE_LAN', 'Enabled', 0
2032RETURN
2033
2034/*:VRX RB_CREATE_CUPS_Click
2035*/
2036RB_CREATE_CUPS_Click: PROCEDURE
2037 CALL VRSet 'RB_CREATE_STANDARD', 'Enabled', 0
2038 CALL VRSet 'RB_CREATE_LAN', 'Enabled', 0
2039RETURN
2040
2041/*:VRX RB_CREATE_LEGACY_Click
2042*/
2043RB_CREATE_LEGACY_Click: PROCEDURE
2044 CALL VRSet 'RB_CREATE_STANDARD', 'Enabled', 1
2045 CALL VRSet 'RB_CREATE_LAN', 'Enabled', 1
2046RETURN
2047
2048/*:VRX RB_DEVICE_3RDPARTY_Click
2049*/
2050RB_DEVICE_3RDPARTY_Click: PROCEDURE EXPOSE globals. shipped.
2051 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Enabled', 1
2052 CALL VRSet 'PB_DEVICE_OTHER', 'Enabled', 1
2053 CALL VRSet 'PB_DEVICE_REFRESH', 'Enabled', 1
2054 CALL SetDriverList
2055RETURN
2056
2057/*:VRX RB_DEVICE_SHIPPED_Click
2058*/
2059RB_DEVICE_SHIPPED_Click: PROCEDURE EXPOSE globals. shipped.
2060 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Enabled', 0
2061 CALL VRSet 'PB_DEVICE_OTHER', 'Enabled', 0
2062 CALL VRSet 'PB_DEVICE_REFRESH', 'Enabled', 0
2063 CALL SetDriverList
2064RETURN
2065
2066
2067/*:VRX RefreshDevices
2068*/
2069RefreshDevices: PROCEDURE EXPOSE globals.
2070
2071 drivers.0 = 0
2072 ok = RPUEnumDrivers('drivers.')
2073 CALL LINEOUT globals.!log1, 'Enumerating drivers:' ok
2074
2075 CALL VRSet 'CN_DEVICES', 'Painting', 0
2076 CALL VRMethod 'CN_DEVICES', 'RemoveRecord', 'All'
2077
2078 IF rc <> 0 THEN DO
2079 CALL LINEOUT globals.!log1, drivers.0 'drivers found.'
2080 DO i = 1 TO drivers.0
2081 PARSE VAR drivers.i _pdrv'.'_model
2082 IF _pdrv == 'IBMNULL' & _model == '' THEN
2083 _model = NLSGetMessage( 106 )
2084 ELSE IF _model == '' THEN
2085 _model = '-'
2086 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', _pdrv, 'USER') WITH _drvspec '00'x .
2087 driverinfo.i = ';'drivers.i';'_drvspec';;;'globals.!hcfDevices.!icon';'_drvspec';'globals.!hcfDevices.!model';'_model';'globals.!hcfDevices.!driver';'_pdrv
2088 END
2089 driverinfo.0 = drivers.0
2090 ok = VRMethod( "CN_DEVICES", "AddRecordList",,, "driverinfo.")
2091 DROP drivers.
2092 DROP driverinfo.
2093 END
2094 CALL VRSet 'CN_DEVICES', 'Painting', 1
2095
2096RETURN
2097
2098/*:VRX RefreshPorts
2099*/
2100RefreshPorts: PROCEDURE EXPOSE globals.
2101
2102 ports.0 = 0
2103 ok = RPUEnumPorts('ports.')
2104 CALL LINEOUT globals.!log1, 'Enumerating ports:' ok
2105
2106 CALL VRSet 'CN_PORTS', 'Painting', 0
2107 CALL VRMethod 'CN_PORTS', 'RemoveRecord', 'All'
2108
2109 IF rc <> 0 THEN DO
2110 CALL LINEOUT globals.!log1, ports.0 'ports found.'
2111 DO i = 1 TO ports.0
2112 PARSE VAR ports.i _name _driver _path
2113 SELECT
2114 WHEN _name == 'FILE' THEN _icon = '$24,PMWP'
2115 WHEN _driver == 'USBPRT' THEN _icon = '$7001,'_path
2116 WHEN _driver == 'SERIAL' THEN _icon = '$7001,'_path
2117 WHEN _driver == 'PARALLEL' THEN _icon = '$7001,'_path
2118 WHEN _driver == 'SLPR' THEN _icon = '$7001,'_path
2119 WHEN _driver == 'LPRPDRVR' THEN _icon = '$256,'_path
2120/*
2121 WHEN _driver == 'USBPRT' THEN _icon = '$7'
2122 WHEN _driver == 'SMB' THEN _icon = '$6'
2123 WHEN _driver == 'SLPR' THEN _icon = '$6'
2124 WHEN _driver == 'LPR32' THEN _icon = '$6'
2125 WHEN _driver == 'LPRPDRVR' THEN _icon = '$6'
2126 WHEN _driver == 'CUPS' THEN _icon = '$10'
2127 OTHERWISE _icon = '$5'
2128*/
2129 OTHERWISE _icon = _path
2130 END
2131
2132 portinfo.i = ';'_name';'_icon';;;'globals.!hcfPorts.!icon';'_icon';'globals.!hcfPorts.!name';'_name';'globals.!hcfPorts.!driver';'_driver';'
2133 END
2134 portinfo.0 = ports.0
2135 ok = VRMethod( "CN_PORTS", "AddRecordList",,, "portinfo.")
2136 DROP ports.
2137 DROP portinfo.
2138 END
2139 CALL VRSet 'CN_PORTS', 'Painting', 1
2140
2141RETURN
2142
2143/*:VRX RefreshPrinters
2144*/
2145RefreshPrinters: PROCEDURE EXPOSE globals.
2146
2147 printers.0 = 0
2148 ok = RPUEnumPrinters('printers.')
2149 CALL LINEOUT globals.!log1, 'Enumerating printers:' ok
2150
2151 CALL VRSet 'CN_PRINTERS', 'Painting', 0
2152 CALL VRMethod 'CN_PRINTERS', 'RemoveRecord', 'All'
2153
2154 IF ok <> 0 THEN DO
2155 CALL LINEOUT globals.!log1, printers.0 'printers found.'
2156
2157 DO i = 1 TO printers.0
2158 _title = TRANSLATE( printers.i.!description, ' ', '0d0a'x)
2159 ok = RPUPrinterQuery( printers.i.!name, 'details.')
2160 IF ok == 0 THEN DO
2161 _driver = '?'
2162 _port = '?'
2163 END
2164 ELSE DO
2165 PARSE VAR details.!drivers _driver ',' .
2166 _port = details.!port
2167 END
2168 IF printers.i.!host <> '' THEN
2169 _icon = '$65,PMWP'
2170 ELSE IF _driver <> '?' THEN DO
2171 PARSE VAR _driver _pdrv'.'_model
2172 PARSE VALUE VRGetIni('PM_DEVICE_DRIVERS', _pdrv, 'USER') WITH _icon '00'x .
2173 END
2174 ELSE _icon = '$2'
2175
2176 printerinfo.i = ';'printers.i.!description';'_icon';;;' ||,
2177 globals.!hcfPrinters.!title';'_title';' ||,
2178 globals.!hcfPrinters.!icon';'_icon';' ||,
2179 globals.!hcfPrinters.!name';'printers.i.!name';' ||,
2180 globals.!hcfPrinters.!queue';'printers.i.!queue';' ||,
2181 globals.!hcfPrinters.!host';'printers.i.!host';' ||,
2182 globals.!hcfPrinters.!port';'_port';' ||,
2183 globals.!hcfPrinters.!driver';'_driver';' ||,
2184 globals.!hcfPrinters.!flags';'printers.i.!flags';' ||,
2185 globals.!hcfPrinters.!handle';'printers.i.!handle';'
2186 END
2187 printerinfo.0 = printers.0
2188 ok = VRMethod( "CN_PRINTERS", "AddRecordList",,, "printerinfo.")
2189 DROP printers.
2190 DROP printerinfo.
2191 DROP details.
2192
2193 END
2194 CALL VRSet 'CN_PRINTERS', 'Painting', 1
2195
2196RETURN
2197
2198/*:VRX SetDriverList
2199*/
2200SetDriverList: PROCEDURE EXPOSE globals. shipped.
2201 ARG driver_path
2202
2203 CALL VRSet VRWindow(), 'Pointer', 'WAIT'
2204 CALL VRMethod 'CN_DEVICE_LIST', 'RemoveRecord', 'All'
2205
2206 IF VRGet('RB_DEVICE_SHIPPED', 'Set') == 1 THEN DO
2207 CALL LINEOUT globals.!log1, 'Refreshing shipped driver list ('shipped.0' devices).'
2208 CALL VRMethod 'CN_DEVICE_LIST', 'AddRecordList',,, 'shipped.'
2209 END
2210 ELSE DO
2211 IF driver_path == '' THEN
2212 driver_path = TRANSLATE( STRIP( VRGet('DDCB_DEVICE_3RDPARTY', 'Value')))
2213 IF driver_path <> '' THEN DO
2214 CALL LINEOUT globals.!log1, 'Refreshing third-party driver list for' driver_path'.'
2215 drivers.0 = 0
2216 _total = 0
2217 CALL SysFileTree driver_path'\*.DRV', 'drivers.', 'FO'
2218 DO i = 1 TO drivers.0
2219 list.0 = 0
2220 IF SysGetEA( drivers.i, '.EXPAND', 'eaval') == 0 THEN DO
2221 PARSE VAR eaval 3 ealen 5 models
2222 offs = 1
2223 datalen = C2D( REVERSE( ealen ))
2224 DO WHILE offs <= datalen
2225 start = SUBSTR( models, offs )
2226 inc = POS('00'x, start )
2227 IF inc > 1 THEN DO
2228 current_name = STRIP( SUBSTR( start, 1, inc-1 ))
2229 _total = _total + 1
2230 list._total = ';'_desc';#2;;;NAME;'current_name';DRIVER;'|| TRANSLATE( drivers.i ) ||';'
2231 END
2232 offs = offs + inc
2233 END
2234 END
2235 END
2236
2237 list.0 = _total
2238 CALL VRSortStem 'list.'
2239 CALL VRMethod 'CN_DEVICE_LIST', 'AddRecordList',,, 'list.'
2240 CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'UserData', driver_path
2241 END
2242 END
2243
2244 CALL VRSet VRWindow(), 'Pointer', '<default>'
2245
2246RETURN
2247
2248/*:VRX SetLanguage
2249*/
2250SetLanguage: PROCEDURE EXPOSE globals.
2251 PARSE ARG locale
2252
2253 /*
2254 * This function locates the proper language files, and uses the message
2255 * file to sets all UI text. If the language could not be determined, we
2256 * default to English.
2257 */
2258 execPath = VRGet('Application', 'Program')
2259 IF execPath <> '' THEN
2260 execDir = VRParseFileName( execPath, 'DP')
2261 ELSE
2262 execDir = DIRECTORY()
2263
2264 /*
2265 * First, figure out what language/message file to use.
2266 */
2267 IF locale <> '' THEN
2268 syslanguage = locale
2269 ELSE
2270 syslanguage = VALUE('LANG',,'OS2ENVIRONMENT')
2271
2272 SELECT
2273 WHEN TRANSLATE( syslanguage ) == 'ZH_TW' THEN nlv = 'tw'
2274 WHEN TRANSLATE( syslanguage ) == 'ZH_CN' THEN nlv = 'cx'
2275 OTHERWISE PARSE VAR syslanguage nlv '_' .
2276 END
2277 nlvfile = globals.!nlsname || nlv
2278 IF ( STREAM( execDir'\'nlvfile'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', nlvfile'.msg') \= '') THEN DO
2279 globals.!messages = nlvfile'.msg'
2280 helpfile = nlvfile'.hlp'
2281 CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
2282 END
2283 ELSE DO
2284 globals.!messages = globals.!nlsname || 'en.msg'
2285 helpfile = globals.!nlsname || 'en.hlp'
2286 CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
2287 END
2288
2289 /*
2290 * If the message file is missing or unreadable, display an error and then exit.
2291 */
2292 IF NLSGetMessage( 1 ) == '' THEN DO
2293 CALL VRMessage VRWindow(), 'Language file' TRANSLATE( globals.!messages ) 'could not be loaded.', 'Cannot Continue', 'E'
2294 RETURN 0
2295 END
2296
2297 /*
2298 * Now set the captions for the UI controls on the main window, according
2299 * to the specified language.
2300 */
2301 CALL NLSSetText 'WN_MAIN', 'Caption', 1
2302 CALL VRMethod 'TDL_MAIN', 'SetTabText', 1, NLSGetMessage( 100 )
2303 CALL VRMethod 'TDL_MAIN', 'SetTabText', 2, NLSGetMessage( 101 )
2304 CALL VRMethod 'TDL_MAIN', 'SetTabText', 3, NLSGetMessage( 102 )
2305
2306 CALL NLSSetText 'MN_PROGRAM', 'Caption', 20
2307 CALL NLSSetText 'MI_MANAGE', 'Caption', 21
2308 CALL NLSSetText 'MI_IMPORT', 'Caption', 22
2309 CALL NLSSetText 'MI_QUIT', 'Caption', 29
2310
2311 CALL NLSSetText 'MN_PRINTER', 'Caption', 30
2312 CALL NLSSetText 'MI_PRINTER_OPEN', 'Caption', 31
2313 CALL NLSSetText 'MI_PRINTER_PROPS', 'Caption', 32
2314 CALL NLSSetText 'MI_PRINTER_HOLD', 'Caption', 33
2315 CALL NLSSetText 'MI_PRINTER_DEFAULT', 'Caption', 34
2316 CALL NLSSetText 'MI_PRINTER_CREATE', 'Caption', 35
2317 CALL NLSSetText 'MI_PRINTER_DELETE', 'Caption', 36
2318
2319 CALL NLSSetText 'MN_PORT', 'Caption', 40
2320 CALL NLSSetText 'MI_PORT_CREATE', 'Caption', 41
2321 CALL NLSSetText 'MI_PORT_DELETE', 'Caption', 42
2322 CALL NLSSetText 'MI_PORT_PROPS', 'Caption', 43
2323
2324 CALL NLSSetText 'MN_DRIVERS', 'Caption', 50
2325 CALL NLSSetText 'MI_DRIVERS_INSTALL', 'Caption', 51
2326 CALL NLSSetText 'MI_DRIVERS_REMOVE', 'Caption', 52
2327
2328 CALL NLSSetText 'MN_VIEW', 'Caption', 60
2329 CALL NLSSetText 'MI_DETAILVIEW', 'Caption', 61
2330 CALL NLSSetText 'MI_ICONVIEW', 'Caption', 62
2331 CALL NLSSetText 'MI_REFRESH', 'Caption', 63
2332
2333 CALL NLSSetText 'MI_CONTEXT_INSTALL', 'Caption', 8
2334 CALL NLSSetText 'MI_CONTEXT_DETAIL', 'Caption', 61
2335 CALL NLSSetText 'MI_CONTEXT_ICON', 'Caption', 62
2336 CALL NLSSetText 'MI_CONTEXT_REFRESH', 'Caption', 63
2337
2338 CALL NLSSetText 'MN_PRINTERPAK', 'Caption', 70
2339 CALL NLSSetText 'MI_PPAK_MODELS', 'Caption', 71
2340 CALL NLSSetText 'MI_PPAK_COPY', 'Caption', 72
2341
2342 CALL NLSSetText 'MN_HELP', 'Caption', 80
2343 CALL NLSSetText 'MI_HELP_GENERAL', 'Caption', 81
2344 CALL NLSSetText 'MI_ABOUT', 'Caption', 89
2345
2346 CALL VRMethod 'WN_MAIN', 'InstallAccelerators'
2347
2348RETURN 1
2349
2350/*:VRX SW_ABOUT_Close
2351*/
2352SW_ABOUT_Close:
2353 call SW_ABOUT_Fini
2354return
2355
2356/*:VRX SW_ABOUT_Create
2357*/
2358SW_ABOUT_Create:
2359 call SW_ABOUT_Init
2360return
2361
2362/*:VRX SW_ABOUT_Fini
2363*/
2364SW_ABOUT_Fini:
2365 window = VRInfo( "Window" )
2366 call VRDestroy window
2367 drop window
2368return
2369/*:VRX SW_ABOUT_Init
2370*/
2371SW_ABOUT_Init: PROCEDURE EXPOSE globals.
2372
2373 IF globals.!oem_os == 1 THEN
2374 _platform = 'eComStation'
2375 ELSE
2376 _platform = 'PM'
2377
2378 CALL NLSSetText 'SW_ABOUT', 'Caption', 130
2379 CALL NLSSetText 'DT_PRODUCT', 'Caption', 131, _platform
2380 CALL NLSSetText 'DT_VERSION', 'Caption', 132, globals.!version
2381 CALL NLSSetText 'DT_COPYRIGHT', 'Caption', 133, globals.!copyright
2382 CALL NLSSetText 'PB_ABOUT_OK', 'Caption', 2
2383
2384 PARSE VERSION _rexxver
2385 PARSE VALUE VRVersion('VROBJ.DLL') WITH _vrver .
2386 PARSE VALUE RPUVersion() WITH _rpuver .
2387 PARSE VALUE VRXVersion() WITH _vrxver .
2388 _pr1ver = PRVersion()
2389 _wptver = WPToolsVersion()
2390 _bullet = NLSGetMessage( 135 )
2391 CALL VRSet 'MLE_LICENSES', 'Value', NLSGetMessage( 134, _rexxver ) || '0a'x ,
2392 _bullet 'IBM REXXUTIL' SysUtilVersion() || '0a'x ,
2393 _bullet 'VX-REXX VROBJ' _vrver || '0a'x ,
2394 _bullet 'VX-REXX Extras (VROBJEX)' _vrxver || '0a'x ,
2395 _bullet 'RXPRTUTL' _rpuver || '0a'x ,
2396 _bullet 'WPTOOLS' _wptver || '0a'x ,
2397 _bullet _pr1ver || '0a'x||' ----- '||'0a'x || ,
2398 NLSGetMessage( 137 ) || '0a'x' ----- '||'0a'x || ,
2399 NLSGetMessage( 138 )
2400
2401 window = VRInfo( "Object" )
2402 if( \VRIsChildOf( window, "Notebook" ) ) then do
2403 call VRMethod window, "CenterWindow"
2404 call VRSet window, "Visible", 1
2405 call VRMethod window, "Activate"
2406 end
2407 drop window
2408return
2409
2410/*:VRX SW_DEVICE_ADD_Close
2411*/
2412SW_DEVICE_ADD_Close:
2413 call SW_DEVICE_ADD_Fini
2414return
2415
2416/*:VRX SW_DEVICE_ADD_Create
2417*/
2418SW_DEVICE_ADD_Create:
2419 call SW_DEVICE_ADD_Init
2420return
2421
2422/*:VRX SW_DEVICE_ADD_Fini
2423*/
2424SW_DEVICE_ADD_Fini:
2425 window = VRInfo( "Window" )
2426 call VRDestroy window
2427 drop window
2428return
2429/*:VRX SW_DEVICE_ADD_Init
2430*/
2431SW_DEVICE_ADD_Init: PROCEDURE EXPOSE globals. shipped.
2432
2433 fld_name = VRMethod('CN_DEVICE_LIST', 'AddField', 'String', NLSGetMessage( 265 ), 'NAME')
2434 fld_driver = VRMethod('CN_DEVICE_LIST', 'AddField', 'String', NLSGetMessage( 266 ), 'DRIVER')
2435
2436 IF globals.!oem_os == 1 THEN
2437 _platform = 'eComStation'
2438 ELSE IF globals.!oem_os == 2 THEN
2439 _platform = 'ArcaOS'
2440 ELSE
2441 _platform = 'OS/2'
2442 CALL NLSSetText 'SW_DEVICE_ADD', 'Caption', 260
2443 CALL NLSSetText 'RB_DEVICE_SHIPPED', 'Caption', 261, _platform
2444 CALL NLSSetText 'RB_DEVICE_3RDPARTY', 'Caption', 262, _platform
2445 CALL NLSSetText 'PB_DEVICE_OTHER', 'Caption', 188
2446 CALL NLSSetText 'PB_DEVICE_REFRESH', 'Caption', 63
2447 CALL NLSSetText 'PB_DEVICE_INSTALL', 'Caption', 2
2448 CALL NLSSetText 'PB_DEVICE_CANCEL', 'Caption', 3
2449
2450 window = VRInfo( "Object" )
2451 CALL VRSet window, 'Pointer', 'WAIT'
2452
2453 extras_num = 0
2454 PARSE UPPER VALUE VRGetIni('PrinterManager', 'LastDriverPath', 'USER') WITH last_path '00'x .
2455 IF last_path <> '' THEN DO
2456 extras_num = extras_num + 1
2457 extras_path.extras_num = last_path
2458 END
2459 PARSE UPPER VALUE VRGetIni('PrinterManager', 'ThirdParty', 'USER') WITH known_3p '00'x .
2460 IF known_3p == '' THEN known_3p = 'ECUPS ECUPS-HP GUTENPRT PSPRINT'
2461 DO i = 1 TO WORDS( known_3p )
2462 _basename = WORD( known_3p, i )
2463 _ppdriver = _basename'.DRV'
2464 _ppini = VRGetIni('PM_INSTALL', _basename'_DIR', 'USER')
2465 IF _ppini == '' THEN ITERATE
2466 PARSE VAR _ppini _pppath '00'x .
2467 IF VRFileExists( _pppath'\'_ppdriver ) THEN DO
2468 extras_num = extras_num + 1
2469 extras_name.extras_num = _ppdriver
2470 extras_path.extras_num = _pppath
2471 END
2472 END
2473 extras_name.0 = extras_num
2474 extras_path.0 = extras_num
2475 CALL VRMethod 'DDCB_DEVICE_3RDPARTY', 'AddStringList', 'extras_path.'
2476 IF extras_num > 0 THEN CALL VRSet 'DDCB_DEVICE_3RDPARTY', 'Selected', 1
2477
2478 if( \VRIsChildOf( window, "Notebook" ) ) then do
2479 call VRMethod window, "CenterWindow"
2480 call VRSet window, "Visible", 1
2481 call VRMethod window, "Activate"
2482 end
2483
2484 IF GetShippedDrivers() > 0 THEN DO
2485/*
2486 CALL VRSet 'RB_DEVICE_SHIPPED', 'Set', 1
2487*/
2488 CALL VRMethod 'CN_DEVICE_LIST', 'AddRecordList',,, 'shipped.'
2489 END
2490
2491 CALL VRSet window, 'Pointer', '<default>'
2492 drop window
2493
2494RETURN
2495
2496/*:VRX SW_DEVICES_Close
2497*/
2498SW_DEVICES_Close:
2499 call SW_DEVICES_Fini
2500return
2501
2502/*:VRX SW_DEVICES_Create
2503*/
2504SW_DEVICES_Create:
2505 call SW_DEVICES_Init
2506return
2507
2508/*:VRX SW_DEVICES_Fini
2509*/
2510SW_DEVICES_Fini:
2511 window = VRInfo( "Window" )
2512 call VRDestroy window
2513 drop window
2514return
2515/*:VRX SW_DEVICES_Init
2516*/
2517SW_DEVICES_Init: PROCEDURE EXPOSE globals.
2518
2519 globals.!hcfDevices.!icon = VRMethod( "CN_DEVICES", "AddField", "Icon", "" )
2520 globals.!hcfDevices.!model = VRMethod( "CN_DEVICES", "AddField", "String", NLSGetMessage( 111 ))
2521 globals.!hcfDevices.!driver = VRMethod( "CN_DEVICES", "AddField", "String", NLSGetMessage( 116 ))
2522
2523 CALL VRSet "CN_DEVICES", "DetailSort", globals.!hcfDevices.!model
2524 ok = VRMethod( "CN_DEVICES", "SetFieldAttr", globals.!hcfDevices.!icon, "HorizSeparator", "0" )
2525
2526 CALL NLSSetText 'CN_DEVICES', 'Caption', 104
2527 CALL NLSSetText 'PB_DEVICE_ADD', 'Caption', 8
2528 CALL NLSSetText 'PB_DEVICE_REMOVE', 'Caption', 9
2529
2530 CALL RefreshDevices
2531
2532 window = VRInfo( "Object" )
2533 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2534 call VRMethod window, "CenterWindow"
2535 call VRSet window, "Visible", 1
2536 call VRMethod window, "Activate"
2537 end
2538
2539 CALL VRSet window, 'UserData', 'CN_DEVICES'
2540 drop window
2541/*
2542 globals.!initstate = globals.!initstate + 1
2543 IF globals.!initstate == 3 THEN CALL VRSet 'TM_REFRESH', 'Enabled', 1
2544*/
2545RETURN
2546
2547/*:VRX SW_IMPORT_Close
2548*/
2549SW_IMPORT_Close:
2550 call SW_IMPORT_Fini
2551return
2552
2553/*:VRX SW_IMPORT_Create
2554*/
2555SW_IMPORT_Create:
2556 call SW_IMPORT_Init
2557return
2558
2559/*:VRX SW_IMPORT_Fini
2560*/
2561SW_IMPORT_Fini:
2562 window = VRInfo( "Window" )
2563 call VRDestroy window
2564 drop window
2565return
2566/*:VRX SW_IMPORT_Init
2567*/
2568SW_IMPORT_Init: PROCEDURE EXPOSE globals. new_ppd
2569
2570 CALL NLSSetText 'SW_IMPORT', 'Caption', 236
2571 CALL NLSSetText 'DT_IMPORT', 'Caption', 233
2572 CALL NLSSetText 'RB_IMPORTCUPS', 'Caption', 234
2573 CALL NLSSetText 'RB_IMPORTLEGACY', 'Caption', 235
2574 CALL NLSSetText 'PB_IMPORTOK', 'Caption', 2
2575 CALL NLSSetText 'PB_IMPORTCANCEL', 'Caption', 3
2576
2577 _count = 0
2578 IF ( DriverIsInstalled('PSCRIPT') <> '') | ( GetDriverSource('PSCRIPT') <> '') THEN DO
2579 _count = _count + 1
2580 psdrv._count = 'PSCRIPT'
2581 END
2582 IF ( DriverIsInstalled('PSCRIPT2') <> '') | ( GetDriverSource('PSCRIPT2') <> '') THEN DO
2583 _count = _count + 1
2584 psdrv._count = 'PSCRIPT2'
2585 END
2586 IF ( DriverIsInstalled('PSPRINT') <> '') | ( GetDriverSource('PSPRINT') <> '') THEN DO
2587 _count = _count + 1
2588 psdrv._count = 'PSPRINT'
2589 END
2590 IF ( DriverIsInstalled('PSPRINT2') <> '') | ( GetDriverSource('PSPRINT2') <> '') THEN DO
2591 _count = _count + 1
2592 psdrv._count = 'PSPRINT2'
2593 END
2594 IF ( DriverIsInstalled('ECUPS') <> '') | ( GetDriverSource('ECUPS') <> '') THEN DO
2595 _count = _count + 1
2596 psdrv._count = 'ECUPS'
2597 END
2598 IF ( DriverIsInstalled('ECUPS-HP') <> '') | ( GetDriverSource('ECUPS-HP') <> '') THEN DO
2599 _count = _count + 1
2600 psdrv._count = 'ECUPS-HP'
2601 END
2602 IF DriverIsInstalled('GUTENPRT') <> '' THEN DO
2603 _count = _count + 1
2604 psdrv._count = 'GUTENPRT'
2605 END
2606
2607 IF _count < 1 THEN DO
2608 IF globals.!hascups == 0 THEN DO
2609 CALL VRMessage VRWindow(), NLSGetMessage( 237 ), NLSGetMessage( 13 ), 'E'
2610 CALL SW_IMPORT_Close
2611 END
2612 CALL VRSet 'RB_IMPORTCUPS', 'Set', 1
2613 CALL VRSet 'RB_IMPORTLEGACY', 'Enabled', 0
2614 CALL VRSet 'DDCB_IMPORTDRV', 'Enabled', 0
2615 END
2616 ELSE IF \globals.!hascups THEN DO
2617 CALL VRSet 'RB_IMPORTCUPS', 'Enabled', 0
2618 END
2619
2620 psdrv.0 = _count
2621 CALL VRMethod 'DDCB_IMPORTDRV', 'AddStringList', 'psdrv.'
2622 CALL VRSet 'DDCB_IMPORTDRV', 'Selected', 1
2623
2624 window = VRInfo( "Object" )
2625 if( \VRIsChildOf( window, "Notebook" ) ) then do
2626 call VRMethod window, "CenterWindow"
2627 call VRSet window, "Visible", 1
2628 call VRMethod window, "Activate"
2629 end
2630 drop window
2631RETURN
2632
2633/*:VRX SW_MODELS_Close
2634*/
2635SW_MODELS_Close:
2636 call SW_MODELS_Fini
2637return
2638
2639/*:VRX SW_MODELS_Create
2640*/
2641SW_MODELS_Create:
2642 call SW_MODELS_Init
2643return
2644
2645/*:VRX SW_MODELS_Fini
2646*/
2647SW_MODELS_Fini:
2648 window = VRInfo( "Window" )
2649 call VRDestroy window
2650 drop window
2651return
2652/*:VRX SW_MODELS_Init
2653*/
2654SW_MODELS_Init: PROCEDURE EXPOSE globals.
2655
2656 ok = VRMethod( "CN_PRINTERPAKS", "GetRecordList", "Selected", "recs." )
2657 IF ok == 0 | recs.0 < 1 THEN RETURN
2658 record = recs.1
2659
2660 _name = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!name )
2661 _path = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!path )
2662 _ver = VRMethod('CN_PRINTERPAKS', 'GetFieldData', record, globals.!hcfPaks.!version )
2663 IF _ver == '-' THEN _ver = '??'
2664 driver = _path'\'_name
2665
2666 CALL NLSSetText 'SW_MODELS', 'Caption', 194
2667 CALL NLSSetText 'PB_MODELS_CLOSE', 'Caption', 12
2668
2669 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
2670 ok = RPUEnumModels( driver, 'models.')
2671 IF ok == 1 THEN
2672 CALL VRMethod 'LB_MODELS', 'AddStringList', 'models.'
2673 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
2674
2675 CALL NLSSetText 'DT_MODELS', 'Caption', 195, _name, models.0
2676
2677 window = VRInfo( "Object" )
2678 if( \VRIsChildOf( window, "Notebook" ) ) then do
2679 call VRMethod window, "CenterWindow"
2680 call VRSet window, "Visible", 1
2681 call VRMethod window, "Activate"
2682 end
2683 drop window
2684
2685RETURN
2686
2687/*:VRX SW_PORT_ADD_Close
2688*/
2689SW_PORT_ADD_Close:
2690 call SW_PORT_ADD_Fini
2691return
2692
2693/*:VRX SW_PORT_ADD_Create
2694*/
2695SW_PORT_ADD_Create:
2696 call SW_PORT_ADD_Init
2697return
2698
2699/*:VRX SW_PORT_ADD_Fini
2700*/
2701SW_PORT_ADD_Fini:
2702 window = VRInfo( "Window" )
2703 call VRDestroy window
2704 drop window
2705return
2706/*:VRX SW_PORT_ADD_Init
2707*/
2708SW_PORT_ADD_Init: PROCEDURE EXPOSE globals. updated
2709
2710 fld_name = VRMethod('CN_ADDPORT', 'AddField', 'String',, 'NAME')
2711 fld_path = VRMethod('CN_ADDPORT', 'AddField', 'String',, 'PATH')
2712
2713 CALL NLSSetText 'SW_PORT_ADD', 'Caption', 160
2714 CALL NLSSetText 'DT_ADDPORT', 'Caption', 161
2715 CALL NLSSetText 'CN_ADDPORT', 'Caption', 162
2716 CALL NLSSetText 'DT_OTHERPORT', 'Caption', 163
2717 CALL NLSSetText 'PB_OTHERPORT', 'Caption', 164
2718
2719 CALL NLSSetText 'PB_ADDPORT_OK', 'Caption', 2
2720 CALL NLSSetText 'PB_ADDPORT_CANCEL', 'Caption', 3
2721
2722 IF GetPortDrivers() > 0 THEN DO
2723 objects.0 = portdrivers.0
2724 DO i = 1 TO portdrivers.0
2725 PARSE VAR portdrivers.i _name _path
2726 SELECT
2727 WHEN _name == 'FILE' THEN _icon = '$24,PMWP'
2728 WHEN _name == 'USBPRT' THEN _icon = '$7001,'_path
2729 WHEN _name == 'SERIAL' THEN _icon = '$7001,'_path
2730 WHEN _name == 'PARALLEL' THEN _icon = '$7001,'_path
2731 WHEN _name == 'SLPR' THEN _icon = '$7001,'_path
2732 WHEN _name == 'LPRPDRVR' THEN _icon = '$256,'_path
2733 OTHERWISE _icon = _path
2734 END
2735 objects.i = ';'_name';'_icon';;;'fld_name';'_name';'fld_path';'_path
2736 END
2737 CALL VRMethod 'CN_ADDPORT', 'AddRecordList',,, 'objects.'
2738 END
2739
2740 window = VRInfo( "Object" )
2741 if( \VRIsChildOf( window, "Notebook" ) ) then do
2742 call VRMethod window, "CenterWindow"
2743 call VRSet window, "Visible", 1
2744 call VRMethod window, "Activate"
2745 end
2746 drop window
2747RETURN
2748
2749/*:VRX SW_PORTS_Close
2750*/
2751SW_PORTS_Close:
2752 call SW_PORTS_Fini
2753return
2754
2755/*:VRX SW_PORTS_Create
2756*/
2757SW_PORTS_Create:
2758 call SW_PORTS_Init
2759return
2760
2761/*:VRX SW_PORTS_Fini
2762*/
2763SW_PORTS_Fini:
2764 window = VRInfo( "Window" )
2765 call VRDestroy window
2766 drop window
2767return
2768/*:VRX SW_PORTS_Init
2769*/
2770SW_PORTS_Init: PROCEDURE EXPOSE globals.
2771
2772 globals.!hcfPorts.!icon = VRMethod( "CN_PORTS", "AddField", "Icon", "" )
2773 globals.!hcfPorts.!name = VRMethod( "CN_PORTS", "AddField", "String", NLSGetMessage( 111 ))
2774 globals.!hcfPorts.!driver = VRMethod( "CN_PORTS", "AddField", "String", NLSGetMessage( 119 ))
2775
2776 CALL VRSet "CN_PORTS", "DetailSort", globals.!hcfPorts.!name
2777 ok = VRMethod( "CN_PORTS", "SetFieldAttr", globals.!hcfPorts.!icon, "HorizSeparator", "0" )
2778
2779 CALL NLSSetText 'CN_PORTS', 'Caption', 105
2780 CALL NLSSetText 'PB_PORT_ADD', 'Caption', 8
2781 CALL NLSSetText 'PB_PORT_DELETE', 'Caption', 9
2782 CALL NLSSetText 'PB_PORT_EDIT', 'Caption', 10
2783
2784 CALL RefreshPorts
2785
2786 window = VRInfo( "Object" )
2787 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2788 call VRMethod window, "CenterWindow"
2789 call VRSet window, "Visible", 1
2790 call VRMethod window, "Activate"
2791 end
2792
2793 CALL VRSet window, 'UserData', 'CN_PORTS'
2794 drop window
2795/*
2796 globals.!initstate = globals.!initstate + 1
2797 IF globals.!initstate == 3 THEN CALL VRSet 'TM_REFRESH', 'Enabled', 1
2798*/
2799RETURN
2800
2801/*:VRX SW_PRINTERPAKS_Close
2802*/
2803SW_PRINTERPAKS_Close:
2804 call SW_PRINTERPAKS_Fini
2805return
2806
2807/*:VRX SW_PRINTERPAKS_Create
2808*/
2809SW_PRINTERPAKS_Create:
2810 call SW_PRINTERPAKS_Init
2811return
2812
2813/*:VRX SW_PRINTERPAKS_Fini
2814*/
2815SW_PRINTERPAKS_Fini:
2816 window = VRInfo( "Window" )
2817 call VRDestroy window
2818 drop window
2819return
2820/*:VRX SW_PRINTERPAKS_Init
2821*/
2822SW_PRINTERPAKS_Init: PROCEDURE EXPOSE globals.
2823
2824 globals.!hcfPaks.!icon = VRMethod( "CN_PRINTERPAKS", "AddField", "Icon", "" )
2825 globals.!hcfPaks.!name = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 173 ))
2826 globals.!hcfPaks.!version= VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 181 ))
2827 globals.!hcfPaks.!status = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 176 ))
2828 globals.!hcfPaks.!path = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 175 ))
2829 globals.!hcfPaks.!desc = VRMethod( "CN_PRINTERPAKS", "AddField", "String", NLSGetMessage( 174 ))
2830 globals.!hcfPaks.!flags = VRMethod( "CN_PRINTERPAKS", "AddField", "String", 'FLAGS')
2831
2832 CALL VRSet "CN_PRINTERPAKS", "DetailSort", globals.!hcfPaks.!name
2833 ok = VRMethod( "CN_PRINTERPAKS", "SetFieldAttr", globals.!hcfPaks.!icon, "HorizSeparator", "0" )
2834 ok = VRMethod( "CN_PRINTERPAKS", "SetFieldAttr", globals.!hcfPaks.!flags, "Visible", "0" )
2835
2836 CALL NLSSetText 'SW_PRINTERPAKS', 'Caption', 170
2837 CALL NLSSetText 'DT_PRINTERPAKS', 'Caption', 171
2838 CALL NLSSetText 'PB_PPUPDATE', 'Caption', 179
2839 CALL NLSSetText 'PB_PPCLOSE', 'Caption', 12
2840
2841 CALL GetPrinterPaks
2842
2843 window = VRInfo( "Object" )
2844 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2845 call VRMethod window, "CenterWindow"
2846 call VRSet window, "Visible", 1
2847 call VRMethod window, "Activate"
2848 end
2849 drop window
2850return
2851
2852/*:VRX SW_PRINTERS_Close
2853*/
2854SW_PRINTERS_Close:
2855 call SW_PRINTERS_Fini
2856return
2857
2858/*:VRX SW_PRINTERS_Create
2859*/
2860SW_PRINTERS_Create:
2861 call SW_PRINTERS_Init
2862return
2863
2864/*:VRX SW_PRINTERS_Fini
2865*/
2866SW_PRINTERS_Fini:
2867 window = VRInfo( "Window" )
2868 call VRDestroy window
2869 drop window
2870return
2871/*:VRX SW_PRINTERS_Init
2872*/
2873SW_PRINTERS_Init: PROCEDURE EXPOSE globals.
2874
2875 CALL NLSSetText 'CN_PRINTERS', 'Caption', 103
2876 CALL NLSSetText 'PB_PRINTER_ADD', 'Caption', 8
2877 CALL NLSSetText 'PB_PRINTER_DEL', 'Caption', 9
2878 CALL NLSSetText 'PB_PRINTER_OPEN', 'Caption', 7
2879 CALL NLSSetText 'PB_PRINTER_EDIT', 'Caption', 10
2880
2881 globals.!hcfPrinters.!icon = VRMethod( "CN_PRINTERS", "AddField", "Icon", "" )
2882 globals.!hcfPrinters.!title = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 110 ))
2883 globals.!hcfPrinters.!name = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 112 ))
2884 globals.!hcfPrinters.!queue = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 113 ))
2885 globals.!hcfPrinters.!host = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 115 ))
2886 globals.!hcfPrinters.!driver = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 116 ))
2887 globals.!hcfPrinters.!port = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 117 ))
2888 globals.!hcfPrinters.!flags = VRMethod( "CN_PRINTERS", "AddField", "String", NLSGetMessage( 118 ))
2889 globals.!hcfPrinters.!handle = VRMethod( "CN_PRINTERS", "AddField", "String", "HANDLE" )
2890
2891 CALL VRSet 'CN_PRINTERS', 'DetailSort', globals.!hcfPrinters.!title
2892 CALL VRSet 'CN_PRINTERS', 'LastSplitField', globals.!hcfPrinters.!host
2893 CALL VRSet 'CN_PRINTERS', 'SplitBarLeft', 3000
2894
2895 ok = VRMethod( "CN_PRINTERS", "SetFieldAttr", globals.!hcfPrinters.!icon, "HorizSeparator", "0" )
2896 ok = VRMethod( "CN_PRINTERS", "SetFieldAttr", globals.!hcfPrinters.!handle, "Visible", "0" )
2897/* ok = VRMethod( "CN_PRINTERS", "SetFieldAttr", globals.!hcfPrinters.!flags, "Visible", "0" ) */
2898
2899 CALL RefreshPrinters
2900
2901 window = VRInfo( "Object" )
2902 if( \VRIsChildOf( window, "TabbedDialog" ) ) then do
2903 call VRMethod window, "CenterWindow"
2904 call VRSet window, "Visible", 1
2905 call VRMethod window, "Activate"
2906 end
2907
2908 CALL VRSet window, 'UserData', 'CN_PRINTERS'
2909 drop window
2910/*
2911 globals.!initstate = globals.!initstate + 1
2912 IF globals.!initstate == 3 THEN CALL VRSet 'TM_REFRESH', 'Enabled', 1
2913*/
2914
2915RETURN
2916
2917/*:VRX SW_PRINTERS_Resize
2918*/
2919SW_PRINTERS_Resize:
2920
2921return
2922
2923/*:VRX SW_WIZARD_Close
2924*/
2925SW_WIZARD_Close:
2926 call SW_WIZARD_Fini
2927return
2928
2929/*:VRX SW_WIZARD_Create
2930*/
2931SW_WIZARD_Create:
2932 call SW_WIZARD_Init
2933return
2934
2935/*:VRX SW_WIZARD_Fini
2936*/
2937SW_WIZARD_Fini:
2938 window = VRInfo( "Window" )
2939 call VRDestroy window
2940 drop window
2941
2942 IF globals.!wizard THEN CALL Quit
2943 ELSE DO
2944 call VRSet 'WN_MAIN', "Visible", 1
2945 IF globals.!create_mode == '' THEN DO
2946 call VRMethod 'WN_MAIN', "Activate"
2947 CALL VRMethod 'TDL_MAIN', 'SetFocus'
2948 END
2949 END
2950RETURN
2951/*:VRX SW_WIZARD_Init
2952*/
2953SW_WIZARD_Init:
2954
2955 CALL NLSSetText 'SW_WIZARD', 'Caption', 140
2956 IF globals.!wizard THEN
2957 CALL NLSSetText 'DT_WIZARD', 'Caption', 142
2958 ELSE
2959 CALL NLSSetText 'DT_WIZARD', 'Caption', 141
2960 CALL NLSSetText 'RB_CREATE_CUPS', 'Caption', 143
2961 CALL NLSSetText 'RB_CREATE_LEGACY', 'Caption', 144
2962 CALL NLSSetText 'RB_CREATE_STANDARD', 'Caption', 145
2963 CALL NLSSetText 'RB_CREATE_LAN', 'Caption', 146
2964 CALL NLSSetText 'RB_ADVANCED', 'Caption', 147
2965 CALL NLSSetText 'PB_WIZARD_NEXT', 'Caption', 11
2966 CALL NLSSetText 'PB_WIZARD_CANCEL', 'Caption', 3
2967 CALL NLSSetText 'PB_WIZARD_HELP', 'Caption', 4
2968
2969 IF globals.!wizard THEN CALL VRSet 'RB_ADVANCED', 'Visible', 1
2970 window = VRInfo( "Object" )
2971 if( \VRIsChildOf( window, "Notebook" ) ) then do
2972 call VRMethod window, "CenterWindow"
2973 call VRSet window, "Visible", 1
2974 call VRMethod window, "Activate"
2975 end
2976 drop window
2977
2978 globals.!create_mode = ''
2979
2980RETURN
2981
2982/*:VRX TDL_MAIN_PageSelected
2983*/
2984TDL_MAIN_PageSelected: PROCEDURE EXPOSE globals.
2985 _pageidx = VRInfo("Page")
2986 _pagewin = VRMethod( "TDL_MAIN", "GetPageWindow", _pageidx )
2987 _cnr = VRGet( _pagewin, "UserData")
2988 IF _cnr == '' THEN RETURN
2989
2990 _view = VRGet( _cnr, "View")
2991 IF _view == 'Detail' THEN DO
2992 CALL VRSet 'MI_ICONVIEW', 'Checked', 0
2993 CALL VRSet 'MI_DETAILVIEW', 'Checked', 1
2994 CALL VRSet 'MI_CONTEXT_ICON', 'Checked', 0
2995 CALL VRSet 'MI_CONTEXT_DETAIL', 'Checked', 1
2996 END
2997 ELSE DO
2998 CALL VRSet 'MI_ICONVIEW', 'Checked', 1
2999 CALL VRSet 'MI_DETAILVIEW', 'Checked', 0
3000 CALL VRSet 'MI_CONTEXT_ICON', 'Checked', 1
3001 CALL VRSet 'MI_CONTEXT_DETAIL', 'Checked', 0
3002 END
3003/*
3004 SELECT
3005 WHEN _cnr == 'CN_PRINTERS' THEN DO
3006 END
3007 WHEN _cnr == 'CN_PORTS' THEN DO
3008 END
3009 WHEN _cnr == 'CN_DEVICES' THEN DO
3010 END
3011 OTHERWISE DO
3012 END
3013 END
3014*/
3015RETURN
3016
3017/*:VRX WN_MAIN_Close
3018*/
3019WN_MAIN_Close:
3020 call Quit
3021return
3022
3023/*:VRX xxUpdatePrDesc
3024*/
3025xxUpdatePrDesc: PROCEDURE EXPOSE globals.
3026 ARG driver, fqn
3027
3028 IF globals.!prdesc == '' THEN RETURN 1
3029
3030 ok = RPUEnumModels( fqn, 'newdevs.')
3031 IF ok == 0 THEN RETURN 2
3032
3033 _count = 0
3034 CALL LINEIN globals.!prdesc, 1, 0
3035 DO WHILE LINES( globals.!prdesc )
3036 _next = LINEIN( globals.!prdesc )
3037 PARSE UPPER VAR _next WITH . ':' . '('_prdrv')' .
3038 IF _prdrv == driver THEN ITERATE
3039 _count = _count + 1
3040 prdefs.count = _next
3041 END
3042 CALL STREAM prdesc, 'C', 'CLOSE'
3043
3044 DO i = 1 TO devs.0
3045 _count = _count + 1
3046 prdefs._count = newdevs.i':' newdevs.i '('driver')'
3047 END
3048 prdefs.0 = count
3049
3050 CALL VRSortStem 'prdefs.'
3051
3052 _prdir = VRParseFileName( globals.!prdesc, 'DP')
3053 CALL VRCopyFile globals.!prdesc, _prdir'\PRDESC.BAK'
3054 CALL VRDeleteFile globals.!prdesc
3055 DO i = 1 TO prdefs.0
3056 CALL LINEOUT globals.!prdesc, prdefs.i
3057 END
3058 CALL LINEOUT globals.!prdesc
3059
3060RETURN 0
3061
Note: See TracBrowser for help on using the repository browser.