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

Last change on this file since 91 was 91, checked in by Alex Taylor, 5 years ago

Update CleanPPD function to scrub *ru. and *zh.

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