source: trunk/gui/printer/cupswiz/cupswiz.VRX@ 57

Last change on this file since 57 was 55, checked in by Alex Taylor, 9 years ago

Fix bad return value from PrinterExistsInDRV, more logging.

File size: 79.4 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 InitArgs.0 = argCount
20 if( argCount > 0 )then do i = 1 to argCount
21 InitArgs.i = arg( i + argOff )
22 end
23 end; else do
24 call VROptions 'ImplicitNames'
25 call VROptions 'NoEchoQuit'
26 argCount = _ParseParams( arg(1) )
27 end
28 drop calledAs argCount argOff
29
30/* Load the windows
31*/
32 call VRInit
33 parse source . . spec
34 _VREPrimaryWindowPath = ,
35 VRParseFileName( spec, "dpn" ) || ".VRW"
36 _VREPrimaryWindow = ,
37 VRLoad( parent, _VREPrimaryWindowPath )
38 drop parent spec
39 if( _VREPrimaryWindow == "" )then do
40 call VRMessage "", "Cannot load window:" VRError(), ,
41 "Error!"
42 _VREReturnValue = 32000
43 signal _VRELeaveMain
44 end
45
46/* Process events
47*/
48 call Init
49 signal on halt
50 do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
51 _VREEvent = VREvent()
52 interpret _VREEvent
53 end
54_VREHalt:
55 _VREReturnValue = Fini()
56 call VRDestroy _VREPrimaryWindow
57_VRELeaveMain:
58 call VRFini
59exit _VREReturnValue
60
61VRLoadSecondary:
62 __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 )
63 if __vrlsWait then do
64 call VRFlush
65 end
66 __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) )
67 if __vrlsHWnd = '' then signal __vrlsDone
68 if __vrlsWait \= 1 then signal __vrlsDone
69 call VRSet __vrlsHWnd, 'WindowMode', 'Modal'
70 __vrlsTmp = __vrlsWindows.0
71 if( DataType(__vrlsTmp) \= 'NUM' ) then do
72 __vrlsTmp = 1
73 end
74 else do
75 __vrlsTmp = __vrlsTmp + 1
76 end
77 __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd )
78 __vrlsWindows.0 = __vrlsTmp
79 do while( VRIsValidObject( VRWindow() ) = 1 )
80 __vrlsEvent = VREvent()
81 interpret __vrlsEvent
82 end
83 __vrlsTmp = __vrlsWindows.0
84 __vrlsWindows.0 = __vrlsTmp - 1
85 call VRWindow __vrlsWindows.__vrlsTmp
86 __vrlsHWnd = ''
87__vrlsDone:
88return __vrlsHWnd
89
90/*:VRX __NoValue
91*/
92__NoValue:
93 SAY FORMAT( sigl, 6 ) '+++' SOURCELINE( sigl )
94 SAY FORMAT( sigl, 6 ) '+++ Uninitialized variable'
95EXIT sigl
96
97/*:VRX __VXREXX____APPENDS__
98*/
99__VXREXX____APPENDS__:
100/*
101#append ..\..\Shared\PrintUtl.VRS
102*/
103return
104/*:VRX _ParseParams
105*/
106_ParseParams: PROCEDURE EXPOSE InitArgs.
107 /* Parse program parameters when they are provided as a single string,
108 * including handling quotes.
109 */
110
111 parse arg thisArgs
112
113 InitArgs. = ''
114 InitArgs.0 = 0
115
116 do while thisargs <> ''
117
118 parse value strip( thisArgs, "B" ) with curArg thisArgs
119
120 parse var curArg tc1 +1 .
121 if tc1 = '"' | tc1 = "'" then
122 parse value curArg thisArgs with (tc1) curArg (tc1) ThisArgs
123
124 i = InitArgs.0 + 1
125 InitArgs.i = strip( curArg )
126 InitArgs.0 = i
127
128 end /* do while thisArgs <> '' */
129
130RETURN InitArgs.0
131
132/*:VRX CheckPrograms
133*/
134CheckPrograms: PROCEDURE EXPOSE globals.
135
136 /* Make sure CUPS.PDR is installed.
137 */
138 cups_pdr = VRGetIni('PM_PORT_DRIVER', 'CUPS', 'System')
139 IF cups_pdr == '' THEN DO
140 cups_pdr = STREAM( globals.!bootdrv'\OS2\DLL\CUPS.PDR', 'C', 'QUERY EXISTS')
141 IF cups_pdr == '' THEN DO
142 CALL VRMessage VRWindow(),,
143 NLSGetMessage( 78, globals.!bootdrv'\OS2\DLL\CUPS.PDR'),, /* 78: The required program %1 is not installed... */
144 NLSGetMessage( 79 ), 'E' /* 79: Missing File */
145 CALL Quit
146 END
147 ELSE CALL VRSetIni('PM_PORT_DRIVER', 'CUPS', cups_pdr, 'System')
148 END
149
150 /* Make sure \TCPIP\BIN\CUPSLPR.EXE (required by CUPS.PDR) is installed.
151 */
152 tcpipbin = SysSearchPath('PATH', 'inetd.exe')
153 IF tcpipbin <> '' THEN
154 tcpipbin = VRParseFileName( tcpipbin, 'DP')
155 ELSE
156 tcpipbin = globals.!bootdrv'\TCPIP\BIN'
157 IF \VRFileExists( tcpipbin'\cupslpr.exe') & (SysSearchPath('PATH', 'cupslpr.exe') == '') THEN DO
158 CALL VRMessage VRWindow(),,
159 NLSGetMessage( 78, 'CUPSLPR.EXE'),,
160 NLSGetMessage( 79 ), 'E'
161 CALL Quit
162 END
163
164 /* Make sure GZIP.EXE is installed (required for unpacking PPDs).
165 */
166 gzip_exe = SysSearchPath('PATH', 'gzip.exe')
167 IF gzip_exe == '' THEN gzip_exe = STREAM( DIRECTORY() || '\gzip.exe', 'C', 'QUERY EXISTS')
168 IF gzip_exe == '' THEN DO
169 CALL VRMessage VRWindow(), NLSGetMessage( 78, 'GZIP.EXE'), NLSGetMessage( 79 ), 'E'
170 CALL Quit
171 END
172
173 /* Make sure CUPSPORT.EXE is installed.
174 */
175 port_exe = SysSearchPath('PATH', 'cupsport.exe')
176 IF port_exe == '' THEN port_exe = STREAM( DIRECTORY() || '\cupsport.exe', 'C', 'QUERY EXISTS')
177 IF port_exe == '' THEN DO
178 CALL VRMessage VRWindow(), NLSGetMessage( 78, 'CUPSPORT.EXE'), NLSGetMessage( 79 ), 'E'
179 CALL Quit
180 END
181
182 /* Make sure PRNTOBJ.EXE is installed.
183 */
184 prntobj_exe = SysSearchPath('PATH', 'prntobj.exe')
185 IF prntobj_exe == '' THEN prntobj_exe = STREAM( DIRECTORY() || '\prntobj.exe', 'C', 'QUERY EXISTS')
186 IF prntobj_exe == '' THEN DO
187 CALL VRMessage VRWindow(), NLSGetMessage( 78, 'PRNTOBJ.EXE'), NLSGetMessage( 79 ), 'E'
188 CALL Quit
189 END
190
191RETURN
192
193/*:VRX CHK_CREATEPM_Click
194*/
195CHK_CREATEPM_Click: PROCEDURE
196 set = VRGet( "CHK_CREATEPM", "Set" )
197 CALL VRSet 'DT_PRESDRV', 'Enabled', set
198 CALL VRSet 'DDCB_PRESDRV', 'Enabled', set
199RETURN
200
201/*:VRX ConfirmAndCreate
202*/
203ConfirmAndCreate: PROCEDURE EXPOSE globals.
204
205 globals.!create = 0
206 CALL VRLoadSecondary 'SW_CREATE', 'W'
207 IF globals.!create <> 1 THEN RETURN
208
209 CALL SetPage4
210 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
211 CALL NLSSetText 'DT_INFO', 'Caption', 50 /* 50: Creating printer... */
212 ok = CreatePrinter( globals.!os2printer )
213
214 CALL VRSet 'DT_INFO', 'Caption', ''
215 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
216
217 IF ok <> 0 THEN DO
218 SELECT
219 WHEN ok == 1 THEN reason = NLSGetMessage( 70 ) /* 70: Error importing PPD file. */
220 WHEN ok == 2 THEN reason = NLSGetMessage( 71, globals.!log1 ) /* 71: Error creating CUPS printer. See %1 for more information. */
221 WHEN ok == 3 THEN reason = NLSGetMessage( 72, globals.!log1 ) /* 72: Error creating printer object. See %1 for more information. */
222 OTHERWISE reason = NLSGetMessage( 73) /* 73: Unknown error. */
223 END
224 CALL VRMessage VRWindow(), NLSGetMessage( 60 ) ||, /* 60: The following error occurred when trying to create the printer: */
225 '0d0a0d0a'x || reason, NLSGetMessage( 56 ), 'E' /* 56: Error Creating Printer */
226 CALL NLSSetText 'DT_INFO', 'Caption', 52 /* 52: The printer could not be created. */
227 CALL NLSSetText 'PB_NEXT', 'Caption', 54 /* 54: Return */
228 END
229 ELSE DO
230 CALL NLSSetText 'DT_INFO', 'Caption', 51 /* 51: The printer has been created. */
231 CALL NLSSetText 'PB_NEXT', 'Caption', 53 /* 53: Create another */
232 END
233 CALL NLSSetText 'PB_CANCEL', 'Caption', 55 /* 55: Close */
234
235 CALL LINEOUT globals.!log1, ''
236 CALL LINEOUT globals.!log1
237
238RETURN
239
240/*:VRX CreateCupsPrinter
241*/
242CreateCupsPrinter: PROCEDURE EXPOSE globals.
243
244 od = DIRECTORY()
245 CALL DIRECTORY globals.!cupsdir'\sbin'
246 cups_cmd = 'lpadmin -p' globals.!prt_name '-E'
247 IF globals.!prt_info <> '' THEN
248 cups_cmd = cups_cmd '-D "'globals.!prt_info'"'
249 IF globals.!prt_loc <> '' THEN
250 cups_cmd = cups_cmd '-L "'globals.!prt_loc'"'
251 IF globals.!prt_dev <> '' THEN
252 cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m' globals.!prt_dev
253 ELSE IF globals.!mode == 2 THEN
254 cups_cmd = cups_cmd '-v "'globals.!prt_port'" -P "'globals.!prt_ppd'"'
255 ELSE DO
256 PARSE VAR globals.!prt_ppd (globals.!cupsdir)'\share\cups\model\' model
257 IF model == '' THEN model = globals.!prt_ppd
258 cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m "'model'"'
259 END
260
261 /* Temporary until we can offer user configuration:
262 */
263 PARSE UPPER VALUE VALUE('LANG',,'OS2ENVIRONMENT') WITH 1 . 4 _ctry 6 .
264 IF ( WORDPOS( _ctry, 'US CA MX BO CO VE PH CL') > 0 ) THEN
265 page = 'Letter'
266 ELSE
267 page = 'A4'
268 cups_cmd = cups_cmd '-o media='page
269
270 CALL LINEOUT globals.!log1, 'Creating CUPS printer using:'
271 CALL LINEOUT globals.!log1, ' ' cups_cmd
272 IF VRFileExists( globals.!log2 ) THEN DO
273 CALL LINEOUT globals.!log2, ''
274 CALL LINEOUT globals.!log2
275 END
276 ADDRESS CMD '@' cups_cmd '1>NUL 2>>' globals.!log2
277 CALL LINEOUT globals.!log1, 'Return code: 0x' || D2X( rc, 4 )
278 IF rc <> 0 THEN
279 CALL LINEOUT globals.!log1, 'See' globals.!log2 'for details.'
280 CALL DIRECTORY od
281 CALL LINEOUT globals.!log1, ''
282
283RETURN rc
284
285/*:VRX CreateOS2Printer
286*/
287/* Creates an OS/2 printer port, queue, and desktop object which point to
288 * the just-created CUPS printer.
289 */
290CreateOS2Printer: PROCEDURE EXPOSE globals.
291 ARG prnt_drv
292
293 IF globals.!remotecups == '' THEN DO
294 host = LoopbackName()
295 printer = globals.!prt_name
296 END
297 ELSE
298 PARSE VAR globals.!remotecups host printer .
299
300 printer_title = globals.!prt_info
301 printer_model = globals.!prt_nick
302 queue_name = GetQueueName( printer_title )
303 port_name = GetNextPortName('CUPS')
304
305 /* Determine the printer driver source directories/files. Yes, this is
306 * repeated from ImportPPD, but we have to do it again here because
307 * (a) we might not have gone through ImportPPD to get to this point, and
308 * (b) even if we did, the repository information might have changed.
309 */
310 driver_path = GetDriverSource( prnt_drv )
311 IF driver_path == '' THEN
312 /* Driver was not found in the repository. Check for a previously-
313 * installed copy under \OS2\DLL.
314 */
315 driver_path = STREAM( globals.!os2dir'\DLL\'prnt_drv'\'prnt_drv'.DRV', 'C', 'QUERY EXISTS')
316
317 IF driver_path == '' THEN DO
318 /* TODO allow the user to browse for the driver on their system */
319 CALL VRMessage VRWindow(),,
320 NLSGetMessage( 61, prnt_drv, globals.!os2dir'\DLL\'prnt_drv ),, /* 61: The printer driver %1 could not be located. If you have the driver files, please copy them to the directory %2 and then try again. */
321 NLSGetMessage( 57 ), 'E' /* 57: Driver Not Found */
322 RETURN 1
323 END
324
325 /* Create a new CUPS port.
326 */
327 port_ok = AddPort_CUPS( port_name, host, printer )
328 IF port_ok > 1 THEN
329 RETURN 1
330
331 /* New logic to create the printer ourselves (instead of using RINSTPRN).
332 * There are two necessary steps: make sure the driver is installed, and
333 * then create the printer object (which causes the underlying device and
334 * queue to be created automatically as well).
335 */
336
337 ok = InstallPrintDriver( prnt_drv, driver_path, printer_model )
338 CALL LINEOUT globals.!log1, 'InstallPrintDriver(' prnt_drv',' driver_path',' printer_model ') RC =' ok
339
340 IF ok == 0 THEN DO
341 ok = CreatePrinterObject( prnt_drv, printer_model,,
342 port_name, queue_name, printer_title )
343 CALL LINEOUT globals.!log1, 'CreatePrinterObject(' prnt_drv',' printer_model ||,
344 ',' port_name',' queue_name',' printer_title ') RC =' ok
345 IF ( ok <> 0 ) & ( printer_model <> 'Generic Postscript Printer') THEN DO
346 CALL LINEOUT globals.!log1, 'Failed to create printer object; trying again with generic driver.'
347 ok = CreatePrinterObject( prnt_drv, 'Generic Postscript Printer',,
348 port_name, queue_name, printer_title )
349 CALL LINEOUT globals.!log1, 'CreatePrinterObject(' prnt_drv', Generic Postscript Printer' ||,
350 ',' port_name',' queue_name',' printer_title ') RC =' ok
351 END
352 END
353
354 IF ok <> 0 THEN DO
355 CALL LINEOUT globals.!log1, 'Printer object creation failed.'
356 IF SysIni('SYSTEM', 'PM_SPOOLER_PRINTER', 'ALL:', 'prt_keys.') == '' THEN DO
357 DO i = 1 TO prt_keys.0
358 key_val = SysIni('SYSTEM', 'PM_SPOOLER_PRINTER', prt_keys.0 )
359 PARSE VAR key_val _kport ';' _ktitle ';' .
360 IF ( _kport == port_name ) & ( _ktitle == printer_title ) THEN DO
361 CALL LINEOUT globals.!log1, 'Cleaning INI entry:' prt_keys.0 '=' key_val
362 CALL SysIni 'SYSTEM', 'PM_SPOOLER_PRINTER_DESCR', prt_keys.0, 'DELETE:'
363 CALL LINEOUT globals.!log1, 'Cleaning INI entry:' prt_keys.0 '=' key_val
364 CALL SysIni 'SYSTEM', 'PM_SPOOLER_PRINTER', prt_keys.0, 'DELETE:'
365 LEAVE
366 END
367 END
368 END
369 CALL LINEOUT globals.!log1, 'Deleting port' port_name
370 CALL DeletePort port_name
371 END
372 ELSE IF port_ok == 1 THEN DO
373 CALL VRMessage VRWindow(),,
374 NLSGetMessage( 62 ),, /* 62: The installed version of CUPS.PDR appears to be out of date. As a result, the desktop printer will not be usable until the desktop is restarted. */
375 NLSGetMessage( 58 ), 'W' /* 58: Port Driver Problem */
376 END
377
378RETURN ok
379
380/*:VRX CreatePrinter
381*/
382CreatePrinter: PROCEDURE EXPOSE globals.
383 ARG create_os2
384
385 cups_etc = globals.!cupsdir'\etc'
386 IF \VRIsDir( cups_etc'\cups\ppd') THEN
387 cups_etc = globals.!cupsdrv'\etc'
388 IF \VRIsDir( cups_etc'\cups\ppd') THEN
389 cups_etc = VALUE('ETC',,'OS2ENVIRONMENT')
390 IF \VRIsDir( cups_etc'\cups\ppd') THEN
391 cups_etc = '\etc'
392
393 /* Create the CUPS printer */
394 IF globals.!remotecups == '' THEN DO
395 CALL LINEOUT globals.!log1, 'No local printer, creating remote CUPS printer'
396 ok = CreateCupsPrinter()
397 IF ok <> 0 THEN
398 RETURN 2 /** RC=2 Error running lpadmin **/
399 END
400
401 /* Now create the OS/2 printer object */
402 IF create_os2 == 1 & globals.!os2driver <> '' THEN DO
403
404 CALL LINEOUT globals.!log1, 'Creating OS/2 printer object:'
405 CALL LINEOUT globals.!log1, 'Mode: ' globals.!mode
406 CALL LINEOUT globals.!log1, 'Driver:' globals.!os2driver
407 CALL LINEOUT globals.!log1, 'Model: ' globals.!prt_nick
408
409 /* Make sure the presentation driver supports the printer */
410 IF globals.!mode == 2 THEN DO
411 /* Always (re)import when a PPD is provided by the user
412 */
413 CALL LINEOUT globals.!log1, 'Importing user-supplied PPD' globals.!prt_ppd
414
415 ok = ImportPPD( globals.!os2driver, globals.!prt_ppd )
416 IF ok <> 0 THEN DO
417 CALL LINEOUT globals.!log1, 'PPD import failed:' ok
418 buttons.1 = NLSGetMessage( 2 ) /* 2: OK */
419 buttons.2 = NLSGetMessage( 3 ) /* 3: Cancel */
420 buttons.0 = 2
421 ok = VRMessage( VRWindow(), NLSGetMessage( 69 ),, /* 69: The printer parameters could not ... PPD file. */
422 NLSGetMessage( 70 ), 'W',, /* 70: Error importing PPD file */
423 'buttons.', 1, 2 )
424 IF ok == 1 THEN
425 CALL PromptForPMName
426 ELSE
427 RETURN 1 /* RC=1 PPD import failed **/
428 END
429 END
430 ELSE DO
431 drv_model = PrinterExistsInDRV( globals.!os2driver, globals.!prt_nick )
432 CALL LINEOUT globals.!log1, 'PrinterExistsInDRV(' globals.!os2driver',' globals.!prt_nick '):' drv_model
433 IF drv_model == '' THEN DO
434 cups_ppd = globals.!prt_ppd
435 IF cups_ppd == '' THEN
436 cups_ppd = STREAM( cups_etc'\cups\ppd\'globals.!prt_name'.ppd', 'C', 'QUERY EXISTS')
437 IF cups_ppd == '' THEN DO
438 CALL LINEOUT globals.!log1, 'CUPS PPD for this printer ('cups_etc'\cups\ppd\'globals.!prt_name'.ppd) does not exist.'
439 CALL LINEOUT globals.!log1, 'Cannot import PPD. Prompting user for preferred printer model.'
440 CALL PromptForPMName
441 END
442 ELSE DO
443 ok = ImportPPD(globals.!os2driver, cups_ppd )
444 IF ok <> 0 THEN DO
445 CALL LINEOUT globals.!log1, 'PPD import failed:' ok
446 CALL VRMessage VRWindow(), NLSGetMessage( 69 ), NLSGetMessage( 70 ), 'W'
447 CALL PromptForPMName
448 /* RETURN 1 RC=1 PPD import failed **/
449 END
450 END
451 END
452 ELSE
453 /* Make sure the name matches, including case */
454 globals.!prt_nick = drv_model
455 END
456
457 ok = CreateOS2Printer( globals.!os2driver )
458 IF ok <> 0 THEN
459 RETURN 3 /** RC=3 Error running rinstprn **/
460 END
461
462RETURN 0
463
464/*:VRX DDCB_PROTOCOL_Change
465*/
466DDCB_PROTOCOL_Change: PROCEDURE EXPOSE globals.
467
468 idx = VRGet('DDCB_PROTOCOL', 'Selected')
469 which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
470 SELECT
471 WHEN which == 1 THEN DO /* IPP */
472 show_queue = 1
473 show_user = 1
474 show_pass = 1
475 show_pick = 0
476 server_caption = 82 /* 82: Printer or server address: */
477 queue_caption = 84 /* 84: Printer queue name: */
478 userid_caption = 86 /* 86: User ID: */
479 END
480 WHEN which == 2 THEN DO /* SOCKET */
481 show_queue = 0
482 show_user = 0
483 show_pass = 0
484 show_pick = 0
485 server_caption = 82 /* 82: Printer or server address: */
486 queue_caption = 84 /* 84: Printer queue name: */
487 userid_caption = 86 /* 86: User ID: */
488 END
489 WHEN which == 3 THEN DO /* LPD */
490 show_queue = 1
491 show_user = 1
492 show_pass = 0
493 show_pick = 0
494 server_caption = 82 /* 82: Printer or server address: */
495 queue_caption = 84 /* 84: Printer queue name: */
496 userid_caption = 87 /* 87: User ID (if required): */
497 END
498 WHEN which == 4 THEN DO /* SMB */
499 show_queue = 1
500 show_user = 1
501 show_pass = 1
502 show_pick = 0
503 server_caption = 83 /* 83: Print server name: */
504 queue_caption = 85 /* 85: Shared printer name: */
505 userid_caption = 86 /* 86: User ID: */
506 END
507 OTHERWISE DO /* CUPS */
508 show_queue = 0
509 show_user = 0
510 show_pass = 0
511 show_pick = 1
512 server_caption = 88 /* 88: CUPS server name: */
513 queue_caption = 89 /* 89: CUPS printer name: */
514 userid_caption = 86 /* 86: User ID: */
515 END
516 END
517
518 r = NLSSetText('DT_SERVER', 'Caption', server_caption )
519 r = NLSSetText('DT_QUEUE', 'Caption', queue_caption )
520 r = NLSSetText('DT_USERID', 'Caption', userid_caption )
521
522 CALL VRSet 'DT_QUEUE', 'Visible', show_queue | show_pick
523 CALL VRSet 'EF_QUEUE', 'Visible', show_queue
524 CALL VRSet 'DT_USERID', 'Visible', show_user
525 CALL VRSet 'EF_USERID', 'Visible', show_user
526 CALL VRSet 'DT_PASSWORD', 'Visible', show_pass
527 CALL VRSet 'EF_PASSWORD', 'Visible', show_pass
528 CALL VRSet 'DDCB_CUPSQUEUES','Visible', show_pick
529
530RETURN
531
532/*:VRX EF_SERVER_LostFocus
533*/
534EF_SERVER_LostFocus: PROCEDURE EXPOSE globals. network_dialog
535
536 idx = VRGet('DDCB_PROTOCOL', 'Selected')
537 which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
538 IF which <> 5 THEN RETURN
539
540 CALL VRMethod 'DDCB_CUPSQUEUES', 'Clear'
541 server = STRIP( VRGet("EF_SERVER", "Value"))
542 IF server == '' THEN RETURN
543
544 IF GetCupsQueues( server ) == 0 THEN RETURN
545
546 /* Sanity check to make sure the dialog wasn't dismissed before lpstat returned */
547 IF network_dialog <> 1 THEN RETURN
548
549 CALL VRMethod 'DDCB_CUPSQUEUES', 'AddStringList', 'cupsdest.'
550RETURN
551
552/*:VRX ExecRINSTPRN
553*/
554ExecRINSTPRN: PROCEDURE EXPOSE globals.
555 PARSE ARG dsc, drv, src, rsp
556
557 od = DIRECTORY()
558 CALL DIRECTORY src
559 rinstprn_cmd = 'rinstprn /DSC:'dsc '/DRV:'drv' /S:'src ,
560 '/T:'globals.!bootdrv '/L1:'globals.!logdir'\rinstprn.log' ,
561 '/R:'rsp
562
563 CALL LINEOUT globals.!log1, 'Creating OS/2 printer using:'
564 CALL LINEOUT globals.!log1, ' ' rinstprn_cmd
565 ADDRESS CMD '@' rinstprn_cmd '1>NUL 2>NUL'
566 CALL LINEOUT globals.!log1, 'Return code: 0x' || D2X( rc, 4 )
567 IF rc <> 0 THEN
568 CALL LINEOUT globals.!log1, 'See' globals.!logdir'\rinstprn.log for details.'
569 CALL DIRECTORY od
570 CALL LINEOUT globals.!log1, ''
571
572RETURN rc
573
574/*:VRX Fini
575*/
576Fini:
577 window = VRWindow()
578 call VRSet window, "Visible", 0
579 drop window
580
581 CALL PrintManCheckIn 'CUPSWIZ DONE'
582
583return 0
584
585/*:VRX GetCupsPorts
586*/
587GetCupsPorts: PROCEDURE EXPOSE globals.
588
589 CALL NLSSetText 'DT_INFO', 'Caption', 30 /* 30: Looking for connected printers. Please wait... */
590
591 lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe -v 2>&1 |rxqueue'
592 snmp_cmd = globals.!cupsdir'\lib\cups\backend\snmp.exe 2>&1 |rxqueue'
593
594 _od = DIRECTORY()
595 CALL DIRECTORY globals.!cupsdir
596 listqueue = RXQUEUE('CREATE')
597 defqueue = RXQUEUE('SET', listqueue )
598
599 /* Use the SNMP backend to find network printers. We do this in addition
600 * to lpinfo because SNMP may provide the actual printer name. We'll
601 * merge this with the output of lpinfo in the next step.
602 */
603 ADDRESS CMD '@' snmp_cmd listqueue
604 DO QUEUED()
605 PARSE PULL line
606 PARSE VAR line _type _uri '"'_identifier'"' .
607 _uri = STRIP( _uri )
608 _type = STRIP( _type )
609 IF _uri == '' THEN ITERATE
610 IF _type <> 'network' THEN ITERATE
611 netnames._uri = _identifier
612 END
613
614 ADDRESS CMD '@' lpinfo_cmd listqueue
615 i = 0
616 DO QUEUED()
617 PARSE PULL line
618 PARSE VAR line _type _name
619 IF _name == '' THEN ITERATE
620 IF _type == 'network' & POS('://', _name ) > 0 THEN DO
621 PARSE VAR _name _protocol '://' _host '/' _queue
622 IF _protocol == 'socket' THEN _protocol = 'AppSocket'
623 ELSE _protocol = TRANSLATE( _protocol )
624 i = i + 1
625 IF _queue <> '' THEN _queue = '(queue '_queue')'
626 IF SYMBOL('netnames._name') == 'VAR' THEN
627 devices.i = NLSGetMessage( 32, _protocol, netnames._name, _host _queue ) /* 32: Detected network printer (%1) "%2" at %3 */
628 ELSE
629 devices.i = NLSGetMessage( 33, _protocol, _host _queue ) /* 33: Detected network printer (%1) at %2 */
630 END
631 ELSE IF _type <> 'direct' THEN ITERATE
632 ELSE DO
633 IF _name == 'hp' THEN ITERATE
634 i = i + 1
635 devices.i = NLSGetMessage( 35, _name ) /* 35: Local printer: %1 */
636 END
637 ports.i = _name
638 END
639 devices.0 = i
640
641 CALL RXQUEUE 'SET', defqueue
642 CALL RXQUEUE 'DELETE', listqueue
643 CALL DIRECTORY _od
644
645 CALL VRSet 'LB_SELECT', 'Painting', 0
646 CALL VRMethod 'LB_SELECT', 'AddStringList', 'devices.',, 'ports.'
647 CALL VRMethod 'LB_SELECT', 'AddString', NLSGetMessage( 34 ),, '' /* 34: Network printer (manual configuration) */
648 CALL VRSet 'LB_SELECT', 'Selected', 1
649 CALL VRSet 'LB_SELECT', 'Painting', 1
650
651 CALL VRSet 'DT_INFO', 'Caption', NLSGetMessage( 31 ) /* 31: Select the connection for this printer. */
652
653RETURN
654
655/*:VRX GetCupsPrinters
656*/
657GetCupsPrinters: PROCEDURE EXPOSE globals. manufacturers.
658
659 CALL NLSSetText 'DT_INFO', 'Caption', 20 /* 20: Getting list of supported printers. Please wait... */
660
661 lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe -m 2>&1 |rxqueue' /* --exclude-schemes drv */
662
663 _od = DIRECTORY()
664 CALL DIRECTORY globals.!cupsdir
665 listqueue = RXQUEUE('CREATE')
666 defqueue = RXQUEUE('SET', listqueue )
667
668 ADDRESS CMD '@' lpinfo_cmd listqueue
669 i = 0
670 makers = ''
671 DO QUEUED()
672 PARSE PULL line
673 /* IF LEFT( line, 6 ) == 'drv://' THEN ITERATE */
674 IF WORD( line, 1 ) == 'raw' THEN ITERATE
675 PARSE VAR line _ppd '.ppd.gz ' _name
676 _ppd = _ppd'.ppd.gz'
677 IF _name == '' THEN DO
678 PARSE VAR line _ppd '.ppd ' _name
679 _ppd = _ppd'.ppd'
680 END
681 IF _name == '' THEN DO
682 PARSE VAR line _ppd _name
683 END
684 IF _name <> '' THEN DO
685 PARSE VAR _name _brand _model
686 IF WORDPOS( _brand, makers ) == 0 THEN makers = makers || _brand' '
687 i = i + 1
688 ppds.i = _ppd
689 models.i = _name
690 END
691 END
692 ppds.0 = i
693 models.0 = i
694
695 CALL RXQUEUE 'SET', defqueue
696 CALL RXQUEUE 'DELETE', listqueue
697 CALL DIRECTORY _od
698
699/* Now build the 'manufacturers' stem.
700 * This stem takes the following format:
701 * manufacturers.0 number of manufacturers
702 * manufacturers.i.!name manufacturer name (e.g. 'Apple')
703 * manufacturers.i.!printers.0 number of printer models
704 * manufacturers.i.!printers.j.!model printer model name, short form (e.g. 'LaserWriter 330')
705 * manufacturers.i.!printers.j.!type driver version/type (e.g. 'Gutenprint v5.2.7')
706 * manufacturers.i.!printers.j.!driver the internal CUPS printer driver name (PPD or URI)
707 * - by preference this is the "simplified" version if available
708 * manufacturers.i.!printers.j.!remark any distinguishing remarks (e.g. 'Simplified')
709 * manufacturers.i.!printers.j.!driver2 alternate driver in case there is more than one (PPD or URI)
710 * - if defined this is usually the non-"simplified" driver
711 * manufacturers.i.!printers.j.!remark2 any distinguishing remarks for the alternate driver
712 */
713 manufacturers.0 = WORDS( makers )
714 DO i = 1 TO manufacturers.0
715 manufacturers.i.!name = WORD( makers, i )
716 manufacturers.i.!printers.0 = 0
717 END
718
719 DO i = 1 TO models.0
720 PARSE VAR models.i _brand _model ' - CUPS+' _type
721 IF _type == '' THEN DO
722 PARSE VAR models.i _brand _model ',' _type
723 IF WORD( _type, 1 ) == 'hpcups' THEN
724 _type = 'HPLIP' /* SUBWORD( _type, 2 ) */
725 ELSE IF ( _type == '') & ( LEFT( ppds.i, 3 ) == 'hp/') THEN
726 _type = 'HPLIP'
727 END
728 man = WORDPOS( _brand, makers )
729 IF man == 0 THEN ITERATE
730
731 PARSE VAR _type _version 'Simplified' .
732 _version = STRIP( _version )
733 _flag = RIGHT( _type, 10 )
734
735 count = manufacturers.man.!printers.0
736 IF count > 0 THEN DO
737 /* If there are two or more printers defined with the same model
738 * name and driver version, keep the first and last as the regular
739 * and alternate drivers; if one if them is 'Simplified', make that
740 * the regular driver by preference.
741 */
742 IF ( TRANSLATE( manufacturers.man.!printers.count.!model ) == TRANSLATE( _model )) THEN DO
743 IF ( manufacturers.man.!printers.count.!type == _version ) THEN DO
744 IF ( WORD( _version, 1 ) == 'Gutenprint') & ( _flag == 'Simplified') THEN DO
745 manufacturers.man.!printers.count.!driver2 = manufacturers.man.!printers.count.!driver
746 manufacturers.man.!printers.count.!remark2 = manufacturers.man.!printers.count.!remark
747 manufacturers.man.!printers.count.!driver = ppds.i
748 manufacturers.man.!printers.count.!remark = 'Simplified'
749 END
750 ELSE DO
751 manufacturers.man.!printers.count.!driver2 = ppds.i
752 IF _flag == 'Simplified' THEN
753 manufacturers.man.!printers.count.!remark2 = 'Simplified'
754 ELSE
755 manufacturers.man.!printers.count.!remark2 = ''
756 END
757 ITERATE
758 END
759 END
760 END
761 count = count + 1
762 manufacturers.man.!printers.count.!model = _model
763 manufacturers.man.!printers.count.!type = _version
764 manufacturers.man.!printers.count.!driver = ppds.i
765 IF _flag == 'Simplified' THEN
766 manufacturers.man.!printers.count.!remark = 'Simplified'
767 ELSE
768 manufacturers.man.!printers.count.!remark = ''
769 manufacturers.man.!printers.count.!driver2 = ''
770 manufacturers.man.!printers.count.!remark2 = ''
771 manufacturers.man.!printers.0 = count
772 END
773
774 /* Add one more category for special items ...
775 */
776 count = manufacturers.0 + 1
777 manufacturers.count.!name = NLSGetMessage( 22 ) /* 22: -- Custom -- */
778 manufacturers.count.!printers.0 = 1
779 manufacturers.count.!printers.1.!model = NLSGetMessage( 23 ) /* 23: -- Other printer (requires PPD) -- */
780 manufacturers.count.!printers.1.!driver = ''
781 manufacturers.count.!printers.1.!type = ''
782 manufacturers.count.!printers.1.!remark = manufacturers.count.!printers.1.!model
783 manufacturers.count.!printers.1.!driver2 = ''
784 manufacturers.count.!printers.1.!remark2 = ''
785 manufacturers.0 = count
786
787RETURN
788
789/*:VRX GetCupsQueues
790*/
791GetCupsQueues: PROCEDURE EXPOSE globals. cupsdest.
792 ARG hostaddr
793
794 /* Try to find lpstat.exe */
795 lpstat_exe = STREAM( globals.!cupsdir'\bin\lpstat.exe', 'C', 'QUERY EXISTS')
796 IF lpstat_exe == '' THEN lpstat_exe = STREAM( globals.!mydir'\lpstat.exe', 'C', 'QUERY EXISTS')
797 IF lpstat_exe == '' THEN lpstat_exe = STREAM( DIRECTORY()'\lpstat.exe', 'C', 'QUERY EXISTS')
798 IF lpstat_exe == '' THEN lpstat_exe = SysSearchPath('PATH', 'lpstat.exe')
799 IF lpstat_exe == '' THEN RETURN 0
800
801 sq = RXQUEUE('CREATE')
802 oq = RXQUEUE('SET', sq )
803
804 CALL VRSet VRWindow(), 'Pointer', 'WAIT'
805 ADDRESS CMD '@'lpstat_exe '-h' hostaddr '-p -c 2>&1 |rxqueue' sq
806 CALL VRSet VRWindow(), 'Pointer', '<default>'
807
808 _count = 0
809 DO QUEUED()
810 PARSE PULL _info
811 IF _info == '' THEN ITERATE
812 IF _info == 'lpstat: Connection refused' THEN LEAVE
813 IF WORD( _info, 1 ) == 'printer' THEN
814 PARSE VAR _info 'printer' _qname .
815 ELSE IF WORD( info, 1 ) == 'class' THEN
816 PARSE VAR _info 'class' _qname .
817 ELSE ITERATE
818 IF _qname == '' THEN ITERATE
819 _count = _count + 1
820 cupsdest._count = _qname
821 END
822 CALL RXQUEUE 'DELETE', sq
823 CALL RXQUEUE 'SET', oq
824
825 cupsdest.0 = _count
826
827RETURN _count
828
829/*:VRX Halt
830*/
831Halt:
832 signal _VREHalt
833return
834
835/*:VRX ImportPPD
836*/
837ImportPPD: PROCEDURE EXPOSE globals.
838 /* Import a new PPD file into a PostScript driver.
839 */
840 ARG driver, ppdfile
841 IF driver == '' THEN driver = 'PSCRIPT'
842
843 CALL LINEOUT globals.!log1, 'Going to import PPD file into driver' driver'.'
844
845 /***
846 *** First, get our working directories and locate the driver source files.
847 ***/
848
849 mustcopy = 0
850 driver_path = GetDriverSource( driver )
851 IF driver_path == '' THEN DO
852 /* No source found. We'll have to try copying the actual installed
853 * driver files from under \OS2\DLL.
854 */
855 CALL LINEOUT globals.!log1, 'Driver source not found.'
856 driver_path = STREAM( globals.!os2dir'\DLL\'driver'\'driver'.DRV', 'C', 'QUERY EXISTS')
857 mustcopy = 1
858 END
859 IF driver_path <> '' THEN DO
860 srcdir = VRParseFilePath( driver_path, 'DP')
861 pin = STREAM( srcdir'\PIN.EXE', 'C', 'QUERY EXISTS')
862 ppdenc = STREAM( srcdir'\PPDENC.EXE', 'C', 'QUERY EXISTS')
863 /* TODO should we check for all the REQUIREDDRIVER FILES as well? */
864 DROP srcdir
865 END
866
867 /* Driver (or one of its required files) was not found.
868 */
869 IF ( driver_path == '') | ( pin == '') | ( ppdenc == '') | ,
870 ( VerifyDriverEAs( driver_path ) == 0 ) THEN
871 DO
872 CALL LINEOUT globals.!log1, ' - Missing required driver files.'
873 /* TODO should prompt for installable driver package? */
874 RETURN 1 /** RC=1 Missing required driver files **/
875 END
876
877 IF mustcopy <> 0 THEN DO
878 /* Looks like the driver wasn't shipped with the OS; we have a source
879 * (either the active files from \OS2\DLL, or a package provided by
880 * the user), but we need somewhere for them to live. The user needs
881 * to tell us where, because they're going to have to specify the
882 * directory later on if they install the driver from PM.
883 */
884 pbtn.1 = NLSGetMessage( 2 ) /* 2: OK */
885 pbtn.2 = NLSGetMessage( 3 ) /* 3: Cancel */
886 pbtn.0 = 2
887 ptext = NLSGetMessage( 63, driver ) ||, /* 63: The install files for the %1 driver could not be located. These files will be recreated from the driver files which are already installed on your system. */
888 '0d0a0d0a'x || NLSGetMessage( 64 ) /* 64: Please enter the directory where the install files will be placed. */
889
890 PARSE VALUE VRGetIni('PM_INSTALL', driver'_DIR', 'USER') WITH drvr_dir '00'x .
891 IF drvr_dir == '' THEN
892 PARSE VALUE VRGetIni('InstPDR', 'PATH_TO_'driver, 'USER') WITH drvr_dir '00'x .
893 ok = VRPrompt('WN_MAIN', ptext, 'drvr_dir', NLSGetMessage( 59 ), 'pbtn.', 1, 2 ) /* 59: Enter Directory */
894 IF ok <> 1 THEN RETURN 9 /** RC=9 User cancelled **/
895 drvr_dir = VRExpandFileName( drvr_dir )
896 DO WHILE drvr_dir == ''
897 ok = VRPrompt('WN_MAIN', ptext, 'drvr_dir',,
898 'Enter Directory', 'pbtn.', 1, 2 )
899 drvr_dir = VRExpandFileName( drvr_dir )
900 END
901
902 /* Now create the new directory, if necessary */
903 IF VRMkDir( drvr_dir ) == 0 THEN
904 RETURN 3 /** RC=3 Failed to copy driver files **/
905 IF CopyDriverToSource( driver_path, drvr_dir ) == 0 THEN
906 RETURN 3 /** RC=3 Failed to copy driver files **/
907
908 /* Make sure we save the location (we'll need this information later) */
909 CALL VRSetIni 'PM_INSTALL', driver'_DIR', drvr_dir||'00'x, 'USER'
910
911 /* Now point to the new copy as the driver we will work on */
912 driver_path = drvr_dir'\'driver'.DRV'
913 END
914
915 workdir = SysTempFileName( globals.!tmpdir'\PPD_????')
916 ok = VrMkDir( workdir )
917 IF ok == 1 THEN ok = VrMkDir( workdir'\OUT')
918 IF ok <> 1 THEN
919 RETURN 2 /** RC=2 Failed to create temporary directory **/
920
921 SELECT
922 WHEN driver == 'ECUPS' THEN ppddir = globals.!repository'\PPD_E'
923 WHEN driver == 'ECUPS-HP' THEN ppddir = globals.!repository'\PPD_EHP'
924 WHEN driver == 'PSPRINT' THEN ppddir = globals.!repository'\PPD_PS'
925 WHEN driver == 'PSPRINT2' THEN ppddir = globals.!repository'\PPD_PS2'
926 WHEN driver == 'PSCRIPT2' THEN ppddir = globals.!repository'\PPD2'
927 OTHERWISE ppddir = globals.!repository'\PPD'
928 END
929
930 /* Make sure ppddir (for keeping PPD files) exists */
931 CALL SysFileTree ppddir, 'dirs.', 'DO'
932 IF dirs.0 == 0 THEN DO
933 ok = VrMkDir( ppddir )
934 IF ok <> 1 THEN
935 RETURN 4 /** RC=4 Failed to create PPD directory **/
936 END
937
938 /***
939 *** Now do the actual work.
940 ***/
941
942 /* Back up the modified files (AUXPRINT.PAK and <driver>.DRV) if we're
943 * working out of the repository.
944 IF mustcopy == 0 THEN DO
945 repfiles.0 = 2
946 repfiles.1 = driver'.DRV'
947 repfiles.2 = 'AUXPRINT.PAK'
948 CALL BackupDrivers driver_path
949 END
950 */
951
952 /* Copy the needed driver files to our working directories.
953 */
954 drv_out = workdir'\OUT\'driver'.DRV'
955 pin_exe = workdir'\PIN.EXE'
956 ppd_exe = workdir'\PPDENC.EXE'
957 ok = VRCopyFile( driver_path, drv_out )
958 IF ok == 1 THEN ok = VRCopyFile( pin, pin_exe )
959 IF ok == 1 THEN ok = VRCopyFile( ppdenc, ppd_exe )
960 IF ok == 0 THEN DO
961 RETURN 3 /*** RC=3 Failed to copy driver files ***/
962 END
963
964 /* Set up the output redirection.
965 */
966 nq = RXQUEUE('CREATE')
967 oq = RXQUEUE('SET', nq )
968
969 /* If the PPD file is compressed, uncompress it.
970 */
971 IF VRParseFilePath( ppdfile, 'E') == 'GZ' THEN DO
972 decppd = workdir'\' || VRParseFilePath( ppdfile, 'N')
973 CALL LINEOUT globals.!log1, 'Decompressing' ppdfile 'to' decppd
974 ADDRESS CMD '@gzip -c -d' ppdfile '| RXQUEUE' nq
975 DO QUEUED()
976 PARSE PULL line
977 CALL LINEOUT decppd, line
978 END
979 CALL LINEOUT decppd
980 ppdfile = decppd
981 END
982
983 IF VRFileExists( ppdfile ) == 0 THEN DO
984 CALL LINEOUT globals.!log1, 'PPD file' ppdfile 'could not be found.'
985 RETURN 5 /** RC=5 PPD import failed **/
986 END
987
988 ppd_use = ppddir'\' || VRParseFileName( ppdfile, 'NE')
989
990 /* Now we have to clean up and validate the PPD file so PIN can use it.
991 * First, PPDENC converts the codepage if necessary, and copies the results
992 * to our working directory.
993 */
994 CALL LINEOUT globals.!log1, 'Converting PPD with:' ppd_exe ppdfile ppd_use
995 ADDRESS CMD '@'ppd_exe ppdfile ppd_use '2>NUL | RXQUEUE' nq
996 DO QUEUED()
997 PULL output
998 CALL LINEOUT globals.!log2, output
999 END
1000 CALL LINEOUT globals.!log2, ''
1001 CALL LINEOUT globals.!log2
1002
1003 IF VRFileExists( ppd_use ) == 0 THEN DO
1004 CALL LINEOUT globals.!log1, 'Hmm,' ppd_use 'was not created. Copying manually.'
1005 CALL VRCopyFile ppdfile, ppd_use
1006 END
1007
1008 /* Next we strip out some problematic lines used which are often encountered
1009 * in (e.g.) CUPS-based PPD files.
1010 */
1011 CALL CleanPPD ppd_use, globals.!log1
1012
1013 /* Preparation complete. Now do the import.
1014 */
1015 count = 0
1016 ADDRESS CMD '@'pin_exe 'ppd' ppddir drv_out '2>NUL | RXQUEUE' nq
1017 DO QUEUED()
1018 PARSE PULL output
1019 CALL LINEOUT globals.!log2, output
1020 PARSE VAR output . 'OK (' nickname
1021 IF nickname <> '' THEN DO
1022 count = count + 1
1023 newprinters.count = STRIP( nickname, 'T', ')')
1024 END
1025 END
1026 newprinters.0 = count
1027 CALL LINEOUT globals.!log2, ''
1028 CALL LINEOUT globals.!log2
1029
1030 /* End the output redirection.
1031 */
1032 CALL RXQUEUE 'SET', oq
1033 CALL RXQUEUE 'DELETE', nq
1034
1035
1036 /***
1037 *** Post-import processing.
1038 ***/
1039
1040 IF newprinters.0 == 0 THEN DO
1041 RETURN 5 /** RC=5 PPD import failed **/
1042 END
1043
1044 /*IF mustcopy == 0 THEN DO*/
1045 IF pmdx <> '' THEN DO
1046 /* If we're working out of the repository, we need to update the
1047 * driver table in PRDESC.LST to add the new driver(s).
1048 */
1049
1050 CALL LINEOUT globals.!log1, 'Updating' globals.!prdesc 'with' newprinters.0 'new entries ...'
1051 count = 0
1052 match_drv = '('driver'.DRV)'
1053 match_len = LENGTH( match_drv )
1054
1055 /* First, copy all lines that don't refer to the driver just updated */
1056 DO WHILE LINES( globals.!prdesc )
1057 _line = LINEIN( globals.!prdesc )
1058 IF TRANSLATE( RIGHT( _line, LENGTH( match_len ))) == match_drv THEN ITERATE
1059 count = count + 1
1060 defs.count = _line
1061 END
1062 CALL STREAM globals.!prdesc, 'C', 'CLOSE'
1063
1064 /* Next, create a new list for the updated driver and merge that in */
1065 newlist = workdir'\'driver'.LST'
1066 CALL CreateDriverList driver, newlist
1067 DO WHILE LINES( newlist )
1068 _line = LINEIN( newlist )
1069 count = count + 1
1070 defs.count = _line
1071 END
1072 defs.0 = count
1073
1074 /* Now sort the list and recreate PRDESC.LST */
1075 CALL SysStemSort 'defs.',, 'I'
1076 prdesc_tmp = workdir'\PRDESC.LST'
1077 IF STREAM( prdesc_tmp, 'C', 'QUERY EXISTS') <> '' THEN
1078 CALL VRDeleteFile prdesc_tmp
1079 DO i = 1 TO defs.0
1080 CALL LINEOUT prdesc_tmp, defs.i
1081 END
1082 CALL LINEOUT prdesc_tmp
1083 ok = VRCopyFile( prdesc_tmp, globals.!prdesc )
1084 IF ok == 0 THEN DO
1085 RETURN 6 /** RC=6 Error updating PRDESC.LST **/
1086 END
1087 CALL VRDeleteFile prdesc_tmp
1088
1089 END
1090
1091 /* Finally, copy the updated driver files.
1092 */
1093 target = VRParseFilePath( driver_path, 'DP')
1094 CALL LINEOUT globals.!log1, 'Copying files from' workdir'\OUT to' target
1095 ADDRESS CMD '@UNLOCK' target'\'driver'.DRV 2>NUL 1>NUL'
1096 ok = VRCopyFile( workdir'\OUT\'driver'.DRV', target'\'driver'.DRV')
1097 IF ok == 1 THEN
1098 ok = VRCopyFile( workdir'\OUT\AUXPRINT.PAK', target'\AUXPRINT.PAK')
1099 IF ok == 1 THEN DO
1100 /* Copy the updated files to \OS2\DLL\<driver>, replacing any
1101 * existing copies. (This prevents problems if the OS/2 driver
1102 * installation doesn't/fails to copy them, which can happen under
1103 * some circumstances.)
1104 */
1105 IF VRFileExists( globals.!os2dir'\DLL\'driver ) THEN DO
1106 CALL VRCopyFile workdir'\OUT\AUXPRINT.PAK',,
1107 globals.!os2dir'\DLL\'driver'\AUXPRINT.PAK'
1108 ADDRESS CMD '@UNLOCK' workdir'\OUT\'driver'.DRV 2>NUL 1>NUL'
1109 CALL VRCopyFile workdir'\OUT\'driver'.DRV',,
1110 globals.!os2dir'\DLL\'driver'\'driver'.DRV'
1111 END
1112 END
1113 IF ok == 0 THEN DO
1114 CALL LINEOUT globals.!log1, VRError()
1115 RETURN 3 /*** RC=3 Failed to copy driver files ***/
1116 END
1117
1118 CALL LINEOUT globals.!log1, newprinters.0 'printers imported successfully.'
1119 DO i = 1 TO newprinters.0
1120 CALL LINEOUT globals.!log1, ' ->' newprinters.i
1121 END
1122 CALL LINEOUT globals.!log1, ''
1123 CALL LINEOUT globals.!log1
1124
1125 /* Clean up our work directories.
1126 */
1127 CALL VRDeleteFile workdir'\OUT\*'
1128 CALL VRDeleteFile workdir'\*'
1129 CALL VRRmDir( workdir'\OUT')
1130 CALL VRRmDir( workdir )
1131
1132RETURN 0
1133
1134/*:VRX Init
1135*/
1136Init:
1137 SIGNAL ON NOVALUE NAME __NoValue
1138
1139 /* Hide the VX-REXX console window
1140 */
1141 CALL VRSet 'Console', 'WindowListTitle', ''
1142
1143 CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
1144 CALL SysLoadFuncs
1145
1146 CALL LoadSettings
1147 CALL SetLanguage
1148 CALL CheckPrograms
1149
1150 _force_remote = 0
1151 globals.!prt_ppd = ''
1152 IF InitArgs.0 > 0 THEN
1153 DO i = 1 TO InitArgs.0
1154 InitArgs.i = TRANSLATE( InitArgs.i )
1155 IF VRIsDir( InitArgs.i ) THEN
1156 globals.!cupsdir = InitArgs.1
1157 ELSE IF InitArgs.i == '/R' THEN DO
1158 globals.!cupsdir = ''
1159 _force_remote = 1
1160 END
1161 ELSE IF VRFileExists( InitArgs.i ) THEN DO
1162 _filetype = VRParseFileName( InitArgs.i, 'E')
1163 IF _filetype == 'PPD' THEN
1164 globals.!prt_ppd = InitArgs.i
1165 END
1166 END
1167
1168 IF globals.!cupsdir == '' & \_force_remote THEN
1169 CALL VRMessage VRWindow(),,
1170 NLSGetMessage( 65, 'CUPSWIZ F:\CUPS') ||, /* 65: CUPS could not be located ... on the command line to this program (e.g "%1"). */
1171 '0d0a0d0a'x || NLSGetMessage( 66 ),, /* 66: Only remote CUPS queues ... start this program with the /R parameter.) */
1172 NLSGetMessage( 28 ), 'E' /* 28: CUPS Path Not Found or Not Valid */
1173
1174 /* Delete the error log file each time the program starts.
1175 */
1176 IF VRFileExists( globals.!log2 ) THEN
1177 CALL VRDeleteFile globals.!log2
1178
1179 CALL PrintManCheckIn 'CUPSWIZ INIT'
1180
1181 window = VRWindow()
1182 call VRMethod window, "CenterWindow"
1183 call VRSet window, "Visible", 1
1184 call VRMethod window, "Activate"
1185 drop window
1186
1187 manufacturers.0 = 0
1188 CALL SetPage1
1189
1190RETURN
1191
1192/*:VRX InitMessageLog
1193*/
1194/* Initialize the message logfile. Unlike the error log, which is cleared and
1195 * recreated every time the program starts, the message log is appended to
1196 * until it reaches 100kB in size. If the message log is larger than 100kB when
1197 * this function is called, it is renamed (with '~' appended to the name) and
1198 * a new message log is started.
1199 */
1200InitMessageLog: PROCEDURE EXPOSE globals.
1201
1202 logsize = STREAM( globals.!log1, 'C', 'QUERY SIZE')
1203 IF ( logsize <> '') & ( logsize > 102400 ) THEN DO
1204 CALL VRCopyFile globals.!log1, globals.!log1 || '~'
1205 CALL VRDeleteFile globals.!log1
1206 END
1207
1208 datestr = DATE('L') TIME('N')
1209 CALL LINEOUT globals.!log1, '--[' datestr ']' ||,
1210 COPIES('-', 73 - LENGTH( datestr ))
1211RETURN
1212
1213/*:VRX LB_BRAND_Click
1214*/
1215LB_BRAND_Click: PROCEDURE EXPOSE globals. manufacturers.
1216
1217 CALL VRSet 'WN_MAIN', 'StatusText', ''
1218
1219 index = VRGet('LB_BRAND', 'Selected')
1220 IF index == 0 THEN RETURN
1221
1222 item = VRMethod('LB_BRAND', 'GetItemData', index )
1223 IF item == 0 THEN RETURN
1224
1225 DO i = 1 TO manufacturers.item.!printers.0
1226 models.i = manufacturers.item.!printers.i.!model
1227 /* ppds.i = manufacturers.item.!printers.i.!driver */
1228 IF manufacturers.item.!printers.i.!driver == '' THEN
1229 ppds.i = ''
1230 ELSE
1231 ppds.i = i
1232
1233/* DEBUG
1234say 'Model: ' manufacturers.item.!printers.i.!model
1235say 'Driver: ' manufacturers.item.!printers.i.!driver
1236say ' ' manufacturers.item.!printers.i.!longname
1237if manufacturers.item.!printers.i.!driver2 <> '' then
1238 say 'Alternate:' manufacturers.item.!printers.i.!driver2
1239if manufacturers.item.!printers.i.!longname2 <> '' then
1240 say ' ' manufacturers.item.!printers.i.!longname2
1241say 'Type: ' manufacturers.item.!printers.i.!type
1242say '---'
1243 */
1244
1245 END
1246 models.0 = manufacturers.item.!printers.0
1247 ppds.0 = manufacturers.item.!printers.0
1248
1249 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
1250 CALL VRMethod 'LB_SELECT', 'Clear'
1251 CALL VRSet 'LB_SELECT', 'Painting', 0
1252 CALL VRMethod 'LB_SELECT', 'AddStringList', 'models.',, 'ppds.'
1253 CALL VRSet 'LB_SELECT', 'Painting', 1
1254 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
1255/* CALL VRSet 'LB_SELECT', 'Selected', 1 */
1256
1257RETURN
1258
1259/*:VRX LB_SELECT_Click
1260*/
1261LB_SELECT_Click: PROCEDURE EXPOSE globals. manufacturers.
1262 SELECT
1263 WHEN globals.!page == 1 THEN DO
1264 CALL VRSet 'WN_MAIN', 'StatusText', ''
1265
1266 brand = VRGet('LB_BRAND', 'Selected')
1267 IF brand == 0 THEN RETURN
1268 selected = VRGet('LB_SELECT', 'Selected')
1269 IF selected == 0 THEN RETURN
1270 which = VRMethod('LB_SELECT', 'GetItemData', selected )
1271 IF which <> '' THEN DO
1272 man = VRMethod('LB_BRAND', 'GetItemData', brand )
1273 IF man == '' THEN RETURN
1274 make = manufacturers.man.!name
1275 model = manufacturers.man.!printers.which.!model
1276 driver = manufacturers.man.!printers.which.!type
1277 IF WORD( driver, 1 ) == 'hpcups' THEN driver = 'HPLIP'
1278 remark = manufacturers.man.!printers.which.!remark
1279 IF driver == '' THEN
1280 type = ''
1281 ELSE IF remark == '' THEN
1282 type = ' ('driver')'
1283 ELSE
1284 type = ' ('driver' - 'remark')'
1285 CALL VRSet 'WN_MAIN', 'StatusText', make model type
1286 END
1287 END
1288
1289 OTHERWISE NOP
1290 END
1291
1292 CALL VRSet 'PB_NEXT', 'Enabled', 1
1293RETURN
1294
1295/*:VRX LoadSettings
1296*/
1297LoadSettings: PROCEDURE EXPOSE globals.
1298
1299 me = VRGet('Application', 'Program')
1300 IF me == '' THEN PARSE SOURCE . . me
1301 globals.!mydir = VRParseFilePath( me, 'DP')
1302
1303 /* Get CUPS paths.
1304 */
1305 PARSE VALUE VRGetIni('eCups', 'CUPS', 'USER') WITH cupsdrv '00'x
1306 IF cupsdrv == '' THEN DO
1307 cupsd_exe = SysSearchPath('PATH', 'cupsd.exe')
1308 IF cupsd_exe <> '' THEN
1309 cupsdrv = FILESPEC('DRIVE', cupsd_exe )
1310 END
1311 IF cupsdrv == '' THEN
1312 cupsdrv = VRParseFilePath( me, 'D') || ':'
1313 ELSE
1314 cupsdrv = STRIP( cupsdrv, 'T', '\')
1315
1316 IF VRIsDir( cupsdrv'\cups') THEN
1317 globals.!cupsdir = cupsdrv'\cups'
1318 ELSE
1319 globals.!cupsdir = cupsdrv'\usr'
1320 globals.!cupsroot = cupsdrv
1321
1322 /* Get system paths.
1323 */
1324 globals.!bootdrv = SysBootDrive()
1325 IF globals.!bootdrv == '' THEN
1326 globals.!bootdrv = FILESPEC('DRIVE', VALUE('OS2_SHELL',,'OS2ENVIRONMENT'))
1327 globals.!os2dir = globals.!bootdrv'\OS2'
1328 globals.!tmpdir = VALUE('TMP',,'OS2ENVIRONMENT')
1329 IF globals.!tmpdir == '' THEN
1330 globals.!tmpdir = VALUE('TEMP',,'OS2ENVIRONMENT')
1331 IF globals.!tmpdir == '' THEN
1332 globals.!tmpdir = globals.!mydir
1333 globals.!logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT')
1334 IF globals.!logdir == '' THEN
1335 globals.!logdir = globals.!mydir
1336
1337 globals.!log1 = globals.!logdir'\cupswiz.l1'
1338 globals.!log2 = globals.!logdir'\cupswiz.l2'
1339
1340 /* Get printer-related paths.
1341 */
1342 PARSE VALUE VRGetIni('PM_INSTALL', 'PDR_DIR', 'USER') WITH repos_dir '00'x .
1343 globals.!repository = repos_dir
1344 globals.!prdrv = STREAM( globals.!os2dir'\install\prdrv.lst', 'C', 'QUERY EXISTS')
1345 globals.!prdesc = STREAM( globals.!os2dir'\install\prdesc.lst', 'C', 'QUERY EXISTS')
1346
1347 /* Set the language file name.
1348 */
1349 globals.!nlsfile = 'cupswz'
1350
1351RETURN 0
1352
1353/*:VRX LoopbackName
1354*/
1355/* Check to see if 'localhost' is defined in the HOSTS file. If not, we'll
1356 * have to use '127.0.0.1' instead.
1357 */
1358LoopbackName: PROCEDURE
1359
1360 lo_name = '127.0.0.1'
1361 etcdir = VALUE('ETC',,'OS2ENVIRONMENT')
1362 IF etcdir <> '' THEN DO
1363 hosts = STREAM( etcdir'\HOSTS', 'C', 'QUERY EXISTS')
1364 IF hosts <> '' THEN DO
1365 CALL LINEIN hosts, 1, 0
1366 DO WHILE LINES( hosts ) > 0
1367 _hostdef = TRANSLATE( LINEIN( hosts ))
1368 _hostdef = TRANSLATE( _hostdef, ' ', '09'x )
1369 IF WORDPOS('LOCALHOST', _hostdef ) == 2 THEN DO
1370 lo_name = 'localhost'
1371 LEAVE
1372 END
1373 END
1374 END
1375 END
1376
1377RETURN lo_name
1378
1379/*:VRX PB_ABOUT_Click
1380*/
1381PB_ABOUT_Click:
1382 CALL SW_ABOUT_Close
1383RETURN
1384
1385/*:VRX PB_CANCEL_Click
1386*/
1387PB_CANCEL_Click:
1388 CALL Quit
1389return
1390
1391/*:VRX PB_CREATECANCEL_Click
1392*/
1393PB_CREATECANCEL_Click:
1394 CALL SW_CREATE_Close
1395RETURN
1396
1397/*:VRX PB_CREATEHELP_Click
1398*/
1399PB_CREATEHELP_Click:
1400 CALL VRMethod 'SW_CREATE', 'InvokeHelp'
1401return
1402
1403/*:VRX PB_CREATEOK_Click
1404*/
1405PB_CREATEOK_Click:
1406
1407 create_os2 = VRGet('CHK_CREATEPM', 'Set')
1408 globals.!os2printer = create_os2
1409 globals.!os2driver = VRGet('DDCB_PRESDRV', 'SelectedString')
1410 globals.!create = 1
1411
1412 CALL SW_CREATE_Close
1413
1414RETURN
1415
1416/*:VRX PB_HELP_Click
1417*/
1418PB_HELP_Click:
1419 CALL VRMethod 'WN_MAIN', 'InvokeHelp'
1420return
1421
1422/*:VRX PB_MODELCANCEL_Click
1423*/
1424PB_MODELCANCEL_Click:
1425 CALL SW_MODEL_Close
1426 globals.!prt_nick = 'Generic PostScript Printer'
1427RETURN
1428
1429/*:VRX PB_MODELOK_Click
1430*/
1431PB_MODELOK_Click:
1432 globals.!prt_nick = VRGet( "LB_OS2MODELS", "SelectedString" )
1433 CALL SW_MODEL_Close
1434RETURN
1435
1436/*:VRX PB_NETCANCEL_Click
1437*/
1438PB_NETCANCEL_Click:
1439 CALL SW_NETWORK_Fini
1440RETURN
1441
1442/*:VRX PB_NETHELP_Click
1443*/
1444PB_NETHELP_Click:
1445 CALL VRMethod 'SW_NETWORK', 'InvokeHelp'
1446return
1447
1448/*:VRX PB_NETOK_Click
1449*/
1450PB_NETOK_Click: PROCEDURE EXPOSE globals. port
1451
1452 idx = VRGet('DDCB_PROTOCOL', 'Selected')
1453 which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
1454 server = STRIP( VRGet("EF_SERVER", "Value"))
1455 pqueue = STRIP( VRGet("EF_QUEUE", "Value"))
1456 cqueue = STRIP( VRGet("DDCB_CUPSQUEUES","Value"))
1457 userid = STRIP( VRGet("EF_USERID", "Value"))
1458 passwd = STRIP( VRGet("EF_PASSWORD", "Value"))
1459
1460 invalid = 0
1461
1462 SELECT
1463 WHEN which == 1 THEN DO /* IPP */
1464 IF server == '' | pqueue == '' THEN invalid = 1
1465 uri = 'ipp://'
1466 IF userid <> '' THEN DO
1467 uri = uri || userid
1468 IF passwd <> '' THEN uri = uri':'passwd
1469 uri = uri'@'
1470 END
1471 uri = uri || server'/'pqueue
1472 END
1473 WHEN which == 2 THEN DO /* SOCKET */
1474 IF server == '' THEN invalid = 1
1475 uri = 'socket://'server
1476 END
1477 WHEN which == 3 THEN DO /* LPD */
1478 IF server == '' THEN invalid = 1
1479 IF pqueue == '' THEN pqueue = '*'
1480 IF userid <> '' THEN
1481 uri = 'ipp://'userid'@'server'/'pqueue
1482 ELSE
1483 uri = 'lpd://'server'/'pqueue
1484 END
1485 WHEN which == 4 THEN DO /* SMB */
1486 IF server == '' | pqueue == '' THEN invalid = 1
1487 uri = 'smb://'
1488 IF userid <> '' THEN DO
1489 uri = uri || userid
1490 IF passwd <> '' THEN uri = uri':'passwd
1491 uri = uri'@'
1492 END
1493 uri = uri || server'/'pqueue
1494 END
1495 OTHERWISE DO /* Existing CUPS */
1496 IF server == '' | cqueue == '' THEN invalid = 1
1497 ELSE DO
1498 globals.!remotecups = server cqueue
1499 uri = ''
1500 END
1501 END
1502 END
1503
1504 IF invalid == 1 THEN DO
1505 CALL VRMessage VRWindow(), NLSGetMessage( 74 ),, /* 74: Missing required value(s). */
1506 NLSGetMessage( 75 ), 'E' /* 75: Missing Value(s) */
1507 RETURN
1508 END
1509
1510 port = uri
1511 CALL SW_NETWORK_Fini
1512
1513RETURN
1514
1515/*:VRX PB_NEXT_Click
1516*/
1517PB_NEXT_Click: PROCEDURE EXPOSE globals. manufacturers.
1518
1519 SELECT
1520 WHEN globals.!page == 1 THEN DO
1521 brand = VRGet('LB_BRAND', 'Selected')
1522 IF brand == 0 THEN RETURN
1523 selected = VRGet('LB_SELECT', 'Selected')
1524 IF selected == 0 THEN RETURN
1525
1526 CALL VRSet 'WN_MAIN', 'StatusText', ''
1527
1528 which = VRMethod('LB_SELECT', 'GetItemData', selected )
1529 IF which == '' THEN DO
1530 globals.!mode = 2 /* Mode 2: user-selected PPD file */
1531 ppd = VRFileDialog( VRWindow(), NLSGetMessage( 24 ), 'O', '*.ppd') /* 24: Select PPD */
1532 IF ppd == '' THEN RETURN
1533 globals.!prt_ppd = ppd
1534 globals.!prt_dev = ''
1535 globals.!prt_nick = GetNameFromPPD( ppd )
1536 IF globals.!prt_nick == '' THEN DO
1537 CALL VRMessage VRWindow(), NLSGetMessage( 76, ppd ),, /* 76: Could not read printer name from %1. */
1538 NLSGetMessage( 77 ), 'E' /* 77: Invalid PPD */
1539 RETURN
1540 END
1541 END
1542 ELSE DO
1543 man = VRMethod('LB_BRAND', 'GetItemData', brand )
1544 IF man == '' THEN DO
1545 /* TODO display an error? But this shouldn't be possible... */
1546 RETURN
1547 END
1548 ppd = manufacturers.man.!printers.which.!driver
1549 globals.!mode = 1 /* Mode 1: CUPS-included model */
1550 IF POS('://', ppd ) > 0 THEN DO
1551 globals.!prt_ppd = ''
1552 globals.!prt_dev = ppd
1553 sel_brand = VRGet('LB_BRAND', 'SelectedString')
1554 sel_name = sel_brand VRMethod('LB_SELECT', 'GetString', selected )
1555 PARSE VAR sel_name _nick ' - CUPS' .
1556 IF _nick == '' THEN
1557 globals.!prt_nick = STRIP( sel_name )
1558 ELSE
1559 globals.!prt_nick = STRIP( _nick )
1560 END
1561 ELSE DO
1562 globals.!prt_ppd = TRANSLATE( globals.!cupsdir'/share/cups/model/'ppd, '\', '/')
1563 globals.!prt_dev = ''
1564 globals.!prt_nick = GetNameFromPPD( globals.!prt_ppd )
1565 END
1566 END
1567 globals.!remotecups = ''
1568
1569 CALL InitMessageLog
1570 IF globals.!mode == 2 THEN
1571 CALL LINEOUT globals.!log1, 'Starting printer install with user-provided PPD:'
1572 ELSE
1573 CALL LINEOUT globals.!log1, 'Starting printer install for built-in model:'
1574 IF globals.!prt_dev <> '' THEN
1575 CALL LINEOUT globals.!log1, ' - Device name:' globals.!prt_dev
1576 ELSE
1577 CALL LINEOUT globals.!log1, ' - PPD file: ' globals.!prt_ppd
1578 CALL LINEOUT globals.!log1, ' - Model name: ' globals.!prt_nick
1579 CALL LINEOUT globals.!log1, ''
1580
1581 CALL SetPage2
1582 END
1583
1584 WHEN globals.!page == 2 THEN DO
1585 selected = VRGet('LB_SELECT', 'Selected')
1586 IF selected == 0 THEN RETURN
1587 port = VRMethod('LB_SELECT', 'GetItemData', selected )
1588
1589 IF port == '' THEN DO
1590 /* Network printer selected; prompt for the connection details
1591 */
1592 CALL VRLoadSecondary 'SW_NETWORK', 'W'
1593 END
1594
1595 IF port == '' & globals.!remotecups == '' THEN RETURN
1596 globals.!prt_port = port
1597
1598 CALL SetPage3
1599 END
1600
1601 WHEN globals.!page == 3 THEN DO
1602 globals.!prt_name = STRIP( VRGet('EF_NAME', 'Value'))
1603 globals.!prt_loc = STRIP( VRGet('EF_LOCATION', 'Value'))
1604 globals.!prt_info = STRIP( VRGet('EF_DESC', 'Value'))
1605 IF ((( globals.!prt_name == '') |,
1606 ( globals.!prt_loc == '')) & ( globals.!remotecups == '')) |,
1607 ( globals.!prt_info == '') THEN
1608 DO
1609 IF ( globals.!remotecups <> '') THEN
1610 _errmsg = NLSGetMessage( 42 ) /* 42: You must enter a description. */
1611 ELSE
1612 _errmsg = NLSGetMessage( 43 ) /* 43: You must enter a name, a location, and a description. */
1613 CALL VRMessage VRWindow(), _errmsg, NLSGetMessage( 75 ), 'E' /* 75: Missing Value(s) */
1614 RETURN
1615 END
1616 IF ( globals.!remotecups == '' &,
1617 ( POS( LEFT( globals.!prt_name, 1 ),,
1618 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') == 0 ) |,
1619 ( VERIFY( globals.!prt_name, '/# ' || '09'x, 'MATCH') <> 0 )) THEN
1620 DO
1621 CALL VRMessage VRWindow(), NLSGetMessage( 44 ),, /* 44: The printer name must start with ... or tab characters. */
1622 NLSGetMessage( 45 ), 'E' /* 45: Invalid Name */
1623 RETURN
1624 END
1625
1626 /* TODO support other drivers
1627 */
1628 IF WORD( globals.!prt_nick, 1 ) == 'Apollo' |,
1629 WORD( globals.!prt_nick, 1 ) == 'HP' |,
1630 WORD( globals.!prt_nick, 1 ) == 'Hewlett-Packard' THEN
1631 globals.!os2driver = 'ECUPS-HP'
1632 ELSE
1633 globals.!os2driver = 'ECUPS'
1634
1635 CALL ConfirmAndCreate
1636 END
1637
1638 WHEN globals.!page == 4 THEN DO
1639 CALL NLSSetText 'PB_NEXT', 'Caption', 5 /* 5: Next > */
1640 CALL VRSet 'EF_NAME', 'Value', ''
1641 CALL VRSet 'EF_LOCATION', 'Value', ''
1642 CALL VRSet 'EF_DESC', 'Value', ''
1643
1644 globals.!prt_ppd = ''
1645 CALL SetPage1
1646 END
1647
1648 OTHERWISE NOP
1649 END
1650
1651RETURN
1652
1653/*:VRX PICT_ICON_Click
1654*/
1655PICT_ICON_Click: PROCEDURE EXPOSE globals.
1656 CALL VRLoadSecondary 'SW_ABOUT', 'W'
1657RETURN
1658
1659/*:VRX PrintManCheckIn
1660*/
1661PrintManCheckIn: PROCEDURE
1662 PARSE ARG data
1663
1664 /* This function attempts to report in to Printer Manager (if it's running)
1665 * by using a named pipe.
1666 */
1667 IF data == '' THEN RETURN 0
1668
1669 npipe = '\PIPE\PRINTMAN'
1670 RC_PIPE_BUSY = '231'
1671
1672 PARSE UPPER VALUE STREAM( npipe, 'C', 'OPEN WRITE') WITH state ':' rc .
1673 IF state <> 'READY' THEN DO
1674 IF rc == RC_PIPE_BUSY THEN
1675 rc = SysWaitNamedPipe( npipe, 0 )
1676 IF rc <> 0 THEN RETURN 0
1677 END
1678 CALL CHAROUT npipe, data
1679 CALL STREAM npipe, 'C', 'CLOSE'
1680
1681RETURN 0
1682
1683/*:VRX PromptForPMName
1684*/
1685PromptForPMName: PROCEDURE EXPOSE globals. models. best
1686 best = MatchPrinterModel( globals.!os2driver, globals.!prt_nick )
1687
1688 IF models.0 == 0 THEN DO
1689 /* No similar models were found in the list of supported printers.
1690 * Just use the generic PS driver.
1691 */
1692 CALL VRMessage VRWindow(), NLSGetMessage( 67, globals.!prt_nick, globals.!os2driver ),, /* 67: The printer "%1" does not ... application support. */
1693 NLSGetMessage( 68 ), 'W' /* 68: Printer Name Not Found */
1694 globals.!prt_nick = 'Generic PostScript Printer'
1695 RETURN
1696 END
1697
1698 CALL VRLoadSecondary 'SW_MODEL', 'W'
1699
1700RETURN
1701
1702/*:VRX Quit
1703*/
1704Quit:
1705 window = VRWindow()
1706 call VRSet window, "Shutdown", 1
1707 drop window
1708return
1709
1710/*:VRX SetLanguage
1711*/
1712SetLanguage: PROCEDURE EXPOSE globals.
1713 PARSE ARG locale
1714
1715 /*
1716 * This function locates the proper language files, and uses the message
1717 * file to sets all UI text. If the language could not be determined, we
1718 * default to English.
1719 */
1720 execPath = VRGet('Application', 'Program')
1721 execDir = VRParseFileName( execPath, 'DP')
1722
1723 /*
1724 * First, figure out what language/message file to use.
1725 */
1726 IF locale <> '' THEN
1727 syslanguage = locale
1728 ELSE
1729 syslanguage = VALUE('LANG',,'OS2ENVIRONMENT')
1730
1731 SELECT
1732 WHEN TRANSLATE( syslanguage ) == 'ZH_TW' THEN nlv = 'tw'
1733 WHEN TRANSLATE( syslanguage ) == 'ZH_CN' THEN nlv = 'cx'
1734 OTHERWISE PARSE VAR syslanguage nlv '_' .
1735 END
1736 nlvfile = globals.!nlsfile || nlv
1737 IF ( STREAM( execDir'\'nlvfile'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', nlvfile'.msg') \= '') THEN DO
1738 globals.!messages = nlvfile'.msg'
1739 helpfile = nlvfile'.hlp'
1740 CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
1741 END
1742 ELSE DO
1743 globals.!messages = globals.!nlsfile || 'en.msg'
1744 helpfile = globals.!nlsfile || 'en.hlp'
1745 CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
1746 END
1747
1748 /*
1749 * If the message file is missing or unreadable, display an error and then exit.
1750 */
1751 IF NLSGetMessage( 1 ) == '' THEN DO
1752 CALL VRMessage VRWindow(), 'Language file' TRANSLATE( globals.!messages ) 'could not be loaded.', 'Cannot Continue', 'E'
1753 RETURN 0
1754 END
1755
1756 /*
1757 * Now set the captions for the UI controls on the main window, according
1758 * to the specified language.
1759 */
1760 CALL NLSSetText 'WN_MAIN', 'Caption', 1 /* 1: Create CUPS Printer */
1761 CALL NLSSetText 'PB_NEXT', 'Caption', 5 /* 5: Next > */
1762 CALL NLSSetText 'PB_CANCEL', 'Caption', 3 /* 3: Cancel */
1763 CALL NLSSetText 'PB_HELP', 'Caption', 4 /* 6: Help */
1764
1765RETURN 1
1766
1767/*:VRX SetPage1
1768*/
1769SetPage1: PROCEDURE EXPOSE globals. manufacturers.
1770
1771 CALL VRMethod 'LB_BRAND', 'Clear'
1772
1773 globals.!page = 1
1774 globals.!prt_port = ''
1775 globals.!remotecups = ''
1776 globals.!prt_name = ''
1777 globals.!prt_loc = ''
1778 globals.!prt_info = ''
1779 globals.!os2driver = ''
1780
1781 /* If a PPD was passed on the command line, skip to page 2 */
1782 IF globals.!prt_ppd <> '' THEN DO
1783 globals.!prt_dev = ''
1784 globals.!prt_nick = GetNameFromPPD( globals.!prt_ppd )
1785 IF globals.!prt_nick == '' THEN DO
1786 CALL VRMessage VRWindow(), NLSGetMessage( 76, globals.!prt_ppd ),, /* 76: Could not read printer name from %1. */
1787 NLSGetMessage( 77 ), 'E' /* 77: Invalid PPD */
1788 END
1789 ELSE DO
1790 globals.!mode = 2 /* Mode 2: user-selected PPD file */
1791 globals.!remotecups = ''
1792 CALL InitMessageLog
1793 CALL LINEOUT globals.!log1, 'Starting printer install with user-provided PPD:'
1794 CALL LINEOUT globals.!log1, ''
1795 CALL SetPage2
1796 RETURN
1797 END
1798 END
1799
1800 globals.!prt_ppd = ''
1801 globals.!prt_dev = ''
1802 globals.!prt_nick = ''
1803
1804 CALL VRSet 'PB_NEXT', 'Enabled', 0
1805 CALL VRSet 'LB_BRAND', 'Visible', 1
1806
1807 CALL VRSet 'WN_MAIN', 'HelpTag', 200
1808
1809 /* Resize LB_SELECT if necessary to make room for LB_BRAND */
1810 lb_x = VRGet('LB_BRAND', 'Left') + VRGet('LB_BRAND', 'Width') + 60
1811 lb_w = VRGet('GB_INFO', 'Width') - lb_x + VRGet('GB_INFO', 'Left')
1812 CALL VRSet 'LB_SELECT', 'Left', lb_x
1813 CALL VRSet 'LB_SELECT', 'Width', lb_w
1814
1815 CALL VRSet 'LB_SELECT', 'Visible', 1
1816 CALL VRSet 'GB_INFO', 'Visible', 0
1817
1818 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
1819
1820 IF manufacturers.0 == 0 THEN DO
1821
1822 /* Populate the manufacturer list */
1823 IF globals.!cupsdir == '' THEN DO
1824 manufacturers.1.!name = NLSGetMessage( 22 ) /* 22: -- Custom -- */
1825 manufacturers.1.!printers.0 = 1
1826 manufacturers.1.!printers.1.!model = NLSGetMessage( 23 ) /* 23: -- Other printer (requires PPD) -- */
1827 manufacturers.1.!printers.1.!driver = ''
1828 manufacturers.1.!printers.1.!type = ''
1829 manufacturers.1.!printers.1.!remark = NLSGetMessage( 23 ) /* 23: -- Other printer (requires PPD) -- */
1830 manufacturers.1.!printers.1.!driver2 = ''
1831 manufacturers.1.!printers.1.!remark2 = ''
1832 manufacturers.0 = 1
1833 END
1834 ELSE
1835 CALL GetCupsPrinters
1836
1837 END
1838 CALL NLSSetText 'DT_INFO', 'Caption', 21 /* 21: Select the printer manufacturer and model from the list below. */
1839
1840 CALL VRSet 'LB_BRAND', 'Painting', 0
1841 DO i = 1 TO manufacturers.0
1842 addman.i = manufacturers.i.!name
1843 addidx.i = i
1844 END
1845 addman.0 = manufacturers.0
1846 addidx.0 = manufacturers.0
1847 CALL VRMethod 'LB_BRAND', 'AddStringList', 'addman.',, 'addidx.'
1848 CALL VRSet 'LB_BRAND', 'Painting', 1
1849
1850 CALL VRMethod 'LB_BRAND', 'SetFocus'
1851 CALL VRSet 'LB_BRAND', 'Selected', 1
1852 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
1853
1854RETURN
1855
1856/*:VRX SetPage2
1857*/
1858SetPage2: PROCEDURE EXPOSE globals.
1859
1860 globals.!page = 2
1861 CALL VRSet 'WN_MAIN', 'HelpTag', 300
1862
1863 CALL VRSet 'LB_BRAND', 'Visible', 0
1864 CALL VRSet 'PB_NEXT', 'Enabled', 0
1865 CALL NLSSetText 'WN_MAIN', 'StatusText', 29, globals.!prt_nick /* 29: Selected printer: %1 */
1866
1867 /* Resize LB_SELECT to the full width of GB_INFO */
1868 lb_x = VRGet('GB_INFO', 'Left')
1869 lb_w = VRGet('GB_INFO', 'Width')
1870 CALL VRSet 'LB_SELECT', 'Left', lb_x
1871 CALL VRSet 'LB_SELECT', 'Width', lb_w
1872
1873 CALL VRMethod 'LB_SELECT', 'Clear'
1874
1875 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
1876 IF globals.!cupsdir == '' THEN DO
1877 CALL VRMethod 'LB_SELECT', 'AddString', NLSGetMessage( 34 ),, '' /* 34: Network printer (manual configuration) */
1878 CALL VRSet 'LB_SELECT', 'Selected', 1
1879 END
1880 ELSE
1881 CALL GetCupsPorts
1882 CALL VRMethod 'LB_SELECT', 'SetFocus'
1883 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
1884
1885RETURN
1886
1887/*:VRX SetPage3
1888*/
1889SetPage3: PROCEDURE EXPOSE globals.
1890
1891 globals.!page = 3
1892 CALL VRSet 'WN_MAIN', 'HelpTag', 400
1893
1894 CALL VRSet 'EF_DESC', 'Value', globals.!prt_nick
1895 CALL NLSSetText DT_NAME, 'Caption', 103 /* 103: Name: */
1896 CALL NLSSetText DT_LOCATION, 'Caption', 105 /* 105: Location: */
1897 CALL NLSSetText DT_DESC, 'Caption', 106 /* 106: Description: */
1898
1899 CALL VRMethod 'LB_SELECT', 'Clear'
1900
1901 CALL VRSet 'LB_SELECT', 'Visible', 0
1902 CALL VRSet 'GB_INFO', 'Visible', 1
1903 IF globals.!remotecups == '' THEN DO
1904 CALL NLSSetText 'DT_INFO', 'Caption', 40 /* 40: Choose the printer name, and enter its location and a short description. */
1905 CALL VRSet 'DT_NAME', 'Visible', 1
1906 CALL VRSet 'EF_NAME', 'Visible', 1
1907 CALL VRSet 'DT_LOCATION', 'Visible', 1
1908 CALL VRSet 'EF_LOCATION', 'Visible', 1
1909 END
1910 ELSE
1911 CALL NLSSetText 'DT_INFO', 'Caption', 41 /* 41: Enter a short description of this printer. This will be used for the printer object that appears on your desktop. */
1912 CALL VRSet 'DT_DESC', 'Visible', 1
1913 CALL VRSet 'EF_DESC', 'Visible', 1
1914
1915 CALL VRMethod 'EF_NAME', 'SetFocus'
1916
1917RETURN
1918
1919/*:VRX SetPage4
1920*/
1921SetPage4:
1922
1923 globals.!page = 4
1924 CALL VRSet 'WN_MAIN', 'HelpTag', 100
1925
1926 CALL VRSet 'LB_SELECT', 'Visible', 0
1927 CALL VRSet 'GB_INFO', 'Visible', 0
1928 CALL VRSet 'WN_MAIN', 'StatusText', ''
1929
1930RETURN
1931
1932/*:VRX SW_ABOUT_Close
1933*/
1934SW_ABOUT_Close:
1935 call SW_ABOUT_Fini
1936return
1937
1938/*:VRX SW_ABOUT_Create
1939*/
1940SW_ABOUT_Create:
1941 call SW_ABOUT_Init
1942return
1943
1944/*:VRX SW_ABOUT_Fini
1945*/
1946SW_ABOUT_Fini:
1947 window = VRInfo( "Window" )
1948 call VRDestroy window
1949 drop window
1950return
1951/*:VRX SW_ABOUT_Init
1952*/
1953SW_ABOUT_Init:
1954
1955 CALL NLSSetText 'SW_ABOUT', 'Caption', 10 /* 10: Product Information */
1956 CALL NLSSetText 'DT_ABOUT1', 'Caption', 11 /* 11: eCups Printer Install Utility */
1957 CALL NLSSetText 'DT_ABOUT2', 'Caption', 12, '1.11' /* 12: Version %1 */
1958 CALL NLSSetText 'DT_ABOUT3', 'Caption', 13, '2010-2016' /* 13: (C) %1 Alex Taylor */
1959 CALL NLSSetText 'PB_ABOUT', 'Caption', 2 /* 10: Product Information */
1960
1961 CALL NLSSetText 'DT_BOOTDRIVE', 'Caption', 14, TRANSLATE( globals.!bootdrv ) /* 14: System boot volume: %1 */
1962 CALL NLSSetText 'DT_CUPSPATH', 'Caption', 15, TRANSLATE( globals.!cupsdir ) /* 15: Local CUPS directory: %1 */
1963 CALL NLSSetText 'DT_REPOSITORY', 'Caption', 16, TRANSLATE( globals.!repository ) /* 16: Local driver repository: %1 */
1964
1965 window = VRInfo( "Object" )
1966 if( \VRIsChildOf( window, "Notebook" ) ) then do
1967 call VRMethod window, "CenterWindow"
1968 call VRSet window, "Visible", 1
1969 call VRMethod window, "Activate"
1970 end
1971 drop window
1972return
1973
1974/*:VRX SW_CREATE_Close
1975*/
1976SW_CREATE_Close:
1977 call SW_CREATE_Fini
1978return
1979
1980/*:VRX SW_CREATE_Create
1981*/
1982SW_CREATE_Create:
1983 call SW_CREATE_Init
1984return
1985
1986/*:VRX SW_CREATE_Fini
1987*/
1988SW_CREATE_Fini:
1989 window = VRInfo( "Window" )
1990 call VRDestroy window
1991 drop window
1992return
1993/*:VRX SW_CREATE_Init
1994*/
1995SW_CREATE_Init:
1996
1997 CALL VRSet 'SW_CREATE', 'HelpFile', VRGet('WN_MAIN', 'HelpFile')
1998
1999 CALL NLSSetText 'SW_CREATE', 'Caption', 115 /* 115: Confirm Create Printer */
2000 CALL NLSSetText 'DT_CRMODEL', 'Caption', 102 /* 102: Model: */
2001 CALL NLSSetText 'DT_CRLOC', 'Caption', 105 /* 105: Location: */
2002 CALL NLSSetText 'DT_CRDESC', 'Caption', 106 /* 106: Description: */
2003
2004 CALL NLSSetText 'CHK_CREATEPM', 'Caption', 109 /* 109: Create printer object */
2005 CALL NLSSetText 'DT_PRESDRV', 'Caption', 110 /* 110: Presentation driver: */
2006 CALL NLSSetText 'PB_CREATEOK', 'Caption', 111 /* 111: Create */
2007 CALL NLSSetText 'PB_CREATECANCEL', 'Caption', 3 /* 3: Cancel */
2008 CALL NLSSetText 'PB_CREATEHELP', 'Caption', 4 /* 4: ~Help */
2009
2010 CALL VRSet 'EF_CRMODEL', 'Value', globals.!prt_nick
2011
2012 IF globals.!remotecups <> '' THEN DO
2013 /* An existing CUPS printer was indicated. This means we're not
2014 * creating a CUPS printer, but only a PM printer object (and port)
2015 * that points to it.
2016 */
2017 CALL NLSSetText 'DT_CREATE', 'Caption', 101 /* 101: Ready to create printer object with the following parameters. */
2018
2019 PARSE VAR globals.!remotecups cups_host cups_printer .
2020 CALL NLSSetText 'DT_CRNAME', 'Caption', 107 /* 107: CUPS server: */
2021 CALL NLSSetText 'DT_CRURI', 'Caption', 108 /* 108: CUPS queue: */
2022 CALL VRSet 'DT_CRLOC', 'Visible', 0
2023 CALL VRSet 'EF_CRNAME', 'Value', cups_host
2024 CALL VRSet 'EF_CRURI', 'Value', cups_printer
2025 CALL VRSet 'EF_CRLOC', 'Visible', 0
2026 CALL VRSet 'CHK_CREATEPM', 'Visible', 0
2027 END
2028 ELSE DO
2029 CALL NLSSetText 'DT_CREATE', 'Caption', 100 /* 100: Ready to create CUPS printer with the following parameters. */
2030 CALL NLSSetText 'DT_CRNAME', 'Caption', 103 /* 103: Name: */
2031 CALL NLSSetText 'DT_CRURI', 'Caption', 104 /* 104: URI: */
2032 CALL VRSet 'EF_CRNAME', 'Value', globals.!prt_name
2033 CALL VRSet 'EF_CRURI', 'Value', globals.!prt_port
2034 CALL VRSet 'EF_CRLOC', 'Value', globals.!prt_loc
2035 END
2036 CALL VRSet 'EF_CRDESC', 'Value', globals.!prt_info
2037
2038 IF QueryAvailableDrivers() > 0 THEN DO
2039 def_idx = 1
2040 CALL VRMethod 'DDCB_PRESDRV', 'AddStringList', 'drv_list.'
2041 DO i = 1 TO drv_list.0
2042 IF drv_list.i == globals.!os2driver THEN DO
2043 def_idx = i
2044 LEAVE
2045 END
2046 END
2047 CALL VRSet 'DDCB_PRESDRV', 'Selected', def_idx
2048 END
2049 ELSE DO /* 112: No eCups-compatible OS/2 presentation drivers are installed. */
2050 /* 113: Please install the ECUPS or ECUPS-HP printer driver before continuing. */
2051 CALL VRMessage VRWindow(),
2052 NLSGetMessage( 112 ) || '0d0a0d0a'x || NLSGetMessage( 113 ),,
2053 NLSGetMessage( 114 ), 'E' /* 114: Missing PM Driver */
2054 CALL VRSet 'PB_CREATEOK', 'Enabled', 0
2055 /* TODO give an error if no drivers were found */
2056 END
2057
2058 window = VRInfo( "Object" )
2059 if( \VRIsChildOf( window, "Notebook" ) ) then do
2060 call VRMethod window, "CenterWindow"
2061 call VRSet window, "Visible", 1
2062 call VRMethod window, "Activate"
2063 end
2064 drop window
2065
2066RETURN
2067
2068/*:VRX SW_MODEL_Close
2069*/
2070SW_MODEL_Close:
2071 call SW_MODEL_Fini
2072return
2073
2074/*:VRX SW_MODEL_Create
2075*/
2076SW_MODEL_Create:
2077 call SW_MODEL_Init
2078return
2079
2080/*:VRX SW_MODEL_Fini
2081*/
2082SW_MODEL_Fini:
2083
2084 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
2085
2086 window = VRInfo( "Window" )
2087 call VRDestroy window
2088 drop window
2089return
2090/*:VRX SW_MODEL_Init
2091*/
2092SW_MODEL_Init:
2093
2094 CALL NLSSetText 'SW_MODEL', 'Caption', 120 /* 120: Select Printer Model */
2095
2096 /* We should have a list of suggested printer models whose names at least
2097 * partially match the requested model, sorted in order with the closest
2098 * match at the top.
2099 */
2100 ok = VRMethod( "LB_OS2MODELS", "AddStringList", "models.", )
2101 IF best > 0 THEN
2102 CALL VRSet 'LB_OS2MODELS', 'Selected', best
2103
2104 CALL NLSSetText 'DT_MODEL1', 'Caption',,
2105 121, globals.!prt_nick, globals.!os2driver /* 121: The printer "%1" could not ... to applications. */
2106 CALL NLSSetText 'DT_MODEL2', 'Caption', 122 /* 122: You can select one of ... use a generic driver. */
2107
2108 CALL NLSSetText 'PB_MODELOK', 'Caption', 2 /* 2: OK */
2109 CALL NLSSetText 'PB_MODELCANCEL', 'Caption', 3 /* 3: Cancel */
2110
2111 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
2112
2113 window = VRInfo( "Object" )
2114 if( \VRIsChildOf( window, "Notebook" ) ) then do
2115 call VRMethod window, "CenterWindow"
2116 call VRSet window, "Visible", 1
2117 call VRMethod window, "Activate"
2118 end
2119 drop window
2120
2121RETURN
2122
2123/*:VRX SW_NETWORK_Close
2124*/
2125SW_NETWORK_Close:
2126 call SW_NETWORK_Fini
2127return
2128
2129/*:VRX SW_NETWORK_Create
2130*/
2131SW_NETWORK_Create:
2132 call SW_NETWORK_Init
2133return
2134
2135/*:VRX SW_NETWORK_Fini
2136*/
2137SW_NETWORK_Fini:
2138
2139 network_dialog = 0
2140
2141 window = VRInfo( "Window" )
2142 call VRDestroy window
2143 drop window
2144return
2145/*:VRX SW_NETWORK_Init
2146*/
2147SW_NETWORK_Init:
2148
2149 CALL VRSet 'SW_NETWORK', 'HelpFile', VRGet('WN_MAIN', 'HelpFile')
2150
2151 /* Flag to keep track of whether dialog is open */
2152 network_dialog = 1
2153
2154 CALL NLSSetText 'SW_NETWORK', 'Caption', 80 /* 80: Network Printer */
2155 CALL NLSSetText 'DT_PROTOCOL', 'Caption', 81 /* 81: Network protocol: */
2156 CALL NLSSetText 'DT_PASSWORD', 'Caption', 90 /* 90: Password: */
2157 CALL NLSSetText 'PB_NETOK', 'Caption', 2 /* 2: OK */
2158 CALL NLSSetText 'PB_NETCANCEL', 'Caption', 3 /* 3: Cancel */
2159 CALL NLSSetText 'PB_NETHELP', 'Caption', 4 /* 4: ~Help */
2160
2161 IF globals.!cupsdir == '' THEN DO
2162 protos.0 = 1
2163 protos.1 = NLSGetMessage( 91 ) /* 91: Existing CUPS printer (remote server) */
2164 pnums.0 = 1
2165 pnums.1 = 5
2166 END
2167 ELSE DO
2168 protos.0 = 5
2169 protos.1 = NLSGetMessage( 92 ) /* 92: Internet Printing Protocol (IPP) */
2170 protos.2 = NLSGetMessage( 93 ) /* 93: AppSocket/JetDirect */
2171 protos.3 = NLSGetMessage( 94 ) /* 94: Line Printer Remote daemon (LPD) */
2172 protos.4 = NLSGetMessage( 95 ) /* 95: Windows/SMB network */
2173 protos.5 = NLSGetMessage( 96 ) /* 96: Existing CUPS printer */
2174 pnums.0 = 5
2175 pnums.1 = 1
2176 pnums.2 = 2
2177 pnums.3 = 3
2178 pnums.4 = 4
2179 pnums.5 = 5
2180 END
2181
2182 CALL VRMethod 'DDCB_PROTOCOL', 'AddStringList', 'protos.',, 'pnums.'
2183 CALL VRSet 'DDCB_PROTOCOL', 'Selected', 1
2184
2185 window = VRInfo( "Object" )
2186 if( \VRIsChildOf( window, "Notebook" ) ) then do
2187 call VRMethod window, "CenterWindow"
2188 call VRSet window, "Visible", 1
2189 call VRMethod window, "Activate"
2190 end
2191 drop window
2192return
2193
2194/*:VRX WN_MAIN_Close
2195*/
2196WN_MAIN_Close:
2197 call Quit
2198return
2199
Note: See TracBrowser for help on using the repository browser.