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

Last change on this file since 10 was 10, checked in by Alex Taylor, 14 years ago

Updated shared code file. New icon, other tweaks.

File size: 43.6 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 __NoValue
90*/
91__NoValue:
92 SAY FORMAT( sigl, 6 ) '+++' SOURCELINE( sigl )
93 SAY FORMAT( sigl, 6 ) '+++ Uninitialized variable'
94EXIT sigl
95
96/*:VRX __VXREXX____APPENDS__
97*/
98__VXREXX____APPENDS__:
99/*
100#append ..\..\Shared\PrintUtl.VRS
101*/
102return
103/*:VRX ConfirmAndCreate
104*/
105ConfirmAndCreate: PROCEDURE EXPOSE globals.
106
107 globals.!create = 0
108 CALL VRLoadSecondary 'SW_CREATE', 'W'
109 IF globals.!create <> 1 THEN RETURN
110
111 CALL SetPage4
112 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
113 CALL VRSet 'DT_INFO', 'Caption', 'Creating printer...'
114 ok = CreatePrinter( globals.!os2printer )
115 CALL VRSet 'DT_INFO', 'Caption', ''
116 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
117
118 IF ok <> 0 THEN DO
119 SELECT
120 WHEN ok == 1 THEN reason = 'Error importing PPD file.'
121 WHEN ok == 2 THEN reason = 'Error creating CUPS printer. See' globals.!log1 'for more information.'
122 WHEN ok == 3 THEN reason = 'Error creating printer object. See' globals.!log1 'for more information.'
123 OTHERWISE reason = 'Unknown error.'
124 END
125 CALL VRMessage VRWindow(), 'The following error occurred when trying to create the printer:' ||,
126 '0d0a0d0a'x || reason, 'Error Creating Printer', 'E'
127 CALL VRSet 'DT_INFO', 'Caption', 'The printer could not be created.'
128 CALL VRSet 'PB_NEXT', 'Caption', 'Return'
129 END
130 ELSE DO
131 CALL VRSet 'DT_INFO', 'Caption', 'The printer has been created.'
132 CALL VRSet 'PB_NEXT', 'Caption', 'Create another'
133 END
134 CALL VRSet 'PB_CANCEL', 'Caption', 'Close'
135
136 CALL LINEOUT globals.!log1, ''
137 CALL LINEOUT globals.!log1
138
139RETURN
140
141/*:VRX CreateCupsPrinter
142*/
143CreateCupsPrinter: PROCEDURE EXPOSE globals.
144
145 od = DIRECTORY()
146 CALL DIRECTORY globals.!cupsdir'\sbin'
147 cups_cmd = 'lpadmin -p' globals.!prt_name '-E'
148 IF globals.!prt_info <> '' THEN
149 cups_cmd = cups_cmd '-D "'globals.!prt_info'"'
150 IF globals.!prt_loc <> '' THEN
151 cups_cmd = cups_cmd '-L "'globals.!prt_loc'"'
152 IF globals.!prt_dev <> '' THEN
153 cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m' globals.!prt_dev
154 ELSE
155 cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m "'globals.!prt_ppd'"'
156
157
158 CALL LINEOUT globals.!log1, 'Creating CUPS printer using:'
159 CALL LINEOUT globals.!log1, ' ' cups_cmd
160 IF VRFileExists( globals.!log2 ) THEN DO
161 CALL LINEOUT globals.!log2, ''
162 CALL LINEOUT globals.!log2
163 END
164 ADDRESS CMD '@' cups_cmd '1>NUL 2>>' globals.!log2
165 CALL LINEOUT globals.!log1, 'Return code: 0x' || D2X( rc, 4 )
166 IF rc <> 0 THEN
167 CALL LINEOUT globals.!log1, 'See' globals.!log2 'for details.'
168 CALL DIRECTORY od
169 CALL LINEOUT globals.!log1, ''
170
171RETURN rc
172
173/*:VRX CreateOS2Printer
174*/
175/* Creates an OS/2 printer port, queue, and desktop object which point to
176 * the just-created CUPS printer. Uses the RINSTPRN utility from IBM.
177 */
178CreateOS2Printer: PROCEDURE EXPOSE globals.
179 ARG prnt_drv
180
181 IF globals.!remotecups == '' THEN DO
182 host = LoopbackName()
183 printer = globals.!prt_name
184 END
185 ELSE
186 PARSE VAR globals.!remotecups host printer .
187
188 printer_title = globals.!prt_info
189 printer_model = globals.!prt_nick
190 queue_name = GetQueueName( printer_title )
191 port_name = GetNextPortName('CUPS')
192 use_drv = globals.!prdrv
193
194 /* Determine the source directories/files to pass to RINSTPRN.EXE. (Some
195 * of this logic is repeated from ImportPPD, but we have to do it again
196 * here because (a) we might not have gone through ImportPPD to get to this
197 * point, and (b) even if we did, the repository information might have
198 * changed.)
199 */
200 copied_driver = 0
201 driver_path = GetDriverSource( prnt_drv )
202
203 IF ( pmdx <> '') & ( globals.!prdrv <> '') & ( globals.!prdesc <> '') THEN DO
204 /* Printer driver is in the local repository, so we can just point
205 * to that, and use the system PRDESC.LST file.
206 */
207 use_desc = globals.!prdesc
208 use_src = globals.!repository
209 END
210 ELSE IF driver_path <> '' THEN DO
211 /* Driver is not in the repository, but was found in another designated
212 * location. Point to that location, and create a temporary PRDESC.LST
213 * file for it.
214 */
215 use_src = VRParseFilePath( driver_path, 'DP')
216 use_desc = use_src'\PRDESC.LST'
217 CALL CreateDriverList driver_path'\'prnt_drv'.DRV', use_desc
218 END
219 ELSE DO
220 /* Driver is not in the repository. Try to grab the installed files
221 * from under \OS2\DLL, copy them into a temporary working directory,
222 * and create a temporary PRDESC.LST file.
223 */
224 driver_path = globals.!os2dir'\DLL\'prnt_drv'\'prnt_drv'.DRV'
225
226 use_src = SysTempFileName( globals.!tmpdir'\PDR_????')
227 use_desc = use_src'\PRDESC.LST'
228
229 IF VRMkDir( use_src ) == 0 THEN DO
230 CALL LINEOUT globals.!log1, 'Failed to create working directory' use_src':' VRError()
231 RETURN 1
232 END
233 IF CopyDriverToSource( driver_path, use_src ) == 0 THEN DO
234 CALL LINEOUT globals.!log1, 'Failed to copy driver' driver_path 'to working directory' use_src'.'
235 RETURN 1
236 END
237 CALL CreateDriverList driver_path, use_desc
238 copied_driver = 1
239 END
240
241 /* Create a new CUPS port. */
242 /* TODO currently this assumes that CUPS.PDR is already installed. */
243 port_ok = AddPort_CUPS( port_name, host, printer )
244 IF port_ok > 1 THEN
245 RETURN 1
246
247 rsp_file = globals.!tmpdir'\printer.rsp'
248 CALL RSPCreatePrinter rsp_file, prnt_drv, printer_model,,
249 port_name, queue_name, printer_title
250 result = ExecRINSTPRN( use_desc, use_drv, use_src, rsp_file )
251
252 IF result <> 0 THEN
253 CALL DeletePort port_name
254 ELSE IF port_ok == 1 THEN DO
255 CALL VRMessage VRWindow(),
256 'The installed version of CUPS.PDR appears to be out of ',
257 'date. As a result, the desktop printer will not be ',
258 'useable until the desktop is restarted.',,
259 'Port Driver Problem', 'W'
260 END
261
262 IF copied_driver == 1 THEN DO
263 CALL VRDeleteFile use_src'\*'
264 CALL VRRmDir use_src
265 END
266
267RETURN result
268
269/*:VRX CreatePrinter
270*/
271CreatePrinter: PROCEDURE EXPOSE globals.
272 ARG create_os2
273
274 /* Create the CUPS printer */
275 IF globals.!remotecups == '' THEN DO
276 ok = CreateCupsPrinter()
277 IF ok <> 0 THEN
278 RETURN 2 /** RC=2 Error running lpadmin **/
279 END
280
281 /* Now create the OS/2 printer object */
282 IF create_os2 == 1 THEN DO
283
284 /* Make sure ECUPS.DRV has the printer */
285 IF globals.!mode == 2 THEN DO
286 /* Always (re)import when a PPD is provided by the user
287 */
288 ok = ImportPPD('ECUPS', globals.!prt_ppd )
289 IF ok <> 0 THEN DO
290 CALL LINEOUT globals.!log1, 'PPD import failed:' ok
291 RETURN 1 /** RC=1 PPD import failed **/
292 END
293 END
294 ELSE IF PrinterExistsInDRV('ECUPS', globals.!prt_nick ) == 0 THEN DO
295 IF globals.!prt_ppd == '' THEN
296 CALL PromptForPMName
297 ELSE DO
298 ok = ImportPPD('ECUPS', globals.!prt_ppd )
299 IF ok <> 0 THEN DO
300 CALL LINEOUT globals.!log1, 'PPD import failed:' ok
301 RETURN 1 /** RC=1 PPD import failed **/
302 END
303 END
304 END
305
306 ok = CreateOS2Printer('ECUPS')
307 IF ok <> 0 THEN
308 RETURN 3 /** RC=3 Error running rinstprn **/
309 END
310
311RETURN 0
312
313/*:VRX DDCB_PROTOCOL_Change
314*/
315DDCB_PROTOCOL_Change: PROCEDURE
316
317 which = VRGet('DDCB_PROTOCOL', 'Selected')
318 SELECT
319 WHEN which == 1 THEN DO /* IPP */
320 show_queue = 1
321 show_user = 1
322 show_pass = 1
323 END
324 WHEN which == 2 THEN DO /* SOCKET */
325 show_queue = 0
326 show_user = 0
327 show_pass = 0
328 END
329 WHEN which == 3 THEN DO /* LPD */
330 show_queue = 1
331 show_user = 1
332 show_pass = 0
333 END
334 WHEN which == 4 THEN DO /* SMB */
335 show_queue = 1
336 show_user = 1
337 show_pass = 1
338 END
339 OTHERWISE DO /* CUPS */
340 show_queue = 1
341 show_user = 0
342 show_pass = 0
343 END
344 END
345
346 CALL VRSet 'DT_QUEUE', 'Visible', show_queue
347 CALL VRSet 'EF_QUEUE', 'Visible', show_queue
348 CALL VRSet 'DT_USERID', 'Visible', show_user
349 CALL VRSet 'EF_USERID', 'Visible', show_user
350 CALL VRSet 'DT_PASSWORD', 'Visible', show_pass
351 CALL VRSet 'EF_PASSWORD', 'Visible', show_pass
352
353RETURN
354
355/*:VRX ExecRINSTPRN
356*/
357ExecRINSTPRN: PROCEDURE EXPOSE globals.
358 PARSE ARG dsc, drv, src, rsp
359
360 od = DIRECTORY()
361 CALL DIRECTORY src
362 rinstprn_cmd = 'rinstprn /DSC:'dsc '/DRV:'drv' /S:'src ,
363 '/T:'globals.!bootdrv '/L1:'globals.!logdir'\rinstprn.log' ,
364 '/R:'rsp
365
366 CALL LINEOUT globals.!log1, 'Creating OS/2 printer using:'
367 CALL LINEOUT globals.!log1, ' ' rinstprn_cmd
368 ADDRESS CMD '@' rinstprn_cmd '1>NUL 2>NUL'
369 CALL LINEOUT globals.!log1, 'Return code: 0x' || D2X( rc, 4 )
370 IF rc <> 0 THEN
371 CALL LINEOUT globals.!log1, 'See' globals.!logdir'\rinstprn.log for details.'
372 CALL DIRECTORY od
373 CALL LINEOUT globals.!log1, ''
374
375RETURN rc
376
377/*:VRX Fini
378*/
379Fini:
380 window = VRWindow()
381 call VRSet window, "Visible", 0
382 drop window
383return 0
384
385/*:VRX GetCupsPorts
386*/
387GetCupsPorts: PROCEDURE EXPOSE globals.
388
389 CALL VRSet 'DT_INFO', 'Caption', 'Looking for connected printers. Please wait...'
390 CALL VRMethod 'LB_SELECT', 'Clear'
391
392 lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe -v |rxqueue'
393
394 _od = DIRECTORY()
395 CALL DIRECTORY globals.!cupsdir
396 listqueue = RXQUEUE('CREATE')
397 defqueue = RXQUEUE('SET', listqueue )
398
399 ADDRESS CMD '@' lpinfo_cmd listqueue
400 i = 0
401 DO QUEUED()
402 PARSE PULL line
403 PARSE VAR line _type _name
404 IF _name == '' THEN ITERATE
405 IF _type == 'network' & POS('://', _name ) > 0 THEN DO
406 PARSE VAR _name _protocol '://' _host '/' _queue
407 IF _protocol == 'socket' THEN _protocol = 'AppSocket'
408 ELSE _protocol = TRANSLATE( _protocol )
409 i = i + 1
410 IF _queue == '' THEN _desc = '('_protocol')'
411 ELSE _desc = _queue '('_protocol')'
412 devices.i = 'Detected network printer' _desc 'at' _host
413 END
414 ELSE IF _type <> 'direct' THEN ITERATE
415 ELSE DO
416 i = i + 1
417 devices.i = 'Local printer:' _name
418 END
419 ports.i = _name
420 END
421 devices.0 = i
422
423 CALL RXQUEUE 'SET', defqueue
424 CALL RXQUEUE 'DELETE', listqueue
425 CALL DIRECTORY _od
426
427 CALL VRSet 'LB_SELECT', 'Painting', 0
428 CALL VRMethod 'LB_SELECT', 'AddStringList', 'devices.',, 'ports.'
429 CALL VRMethod 'LB_SELECT', 'AddString', 'Network printer (manual configuration)',, ''
430 CALL VRSet 'LB_SELECT', 'Selected', 1
431 CALL VRSet 'LB_SELECT', 'Painting', 1
432
433 CALL VRSet 'DT_INFO', 'Caption', 'Select the connection for this printer.'
434
435RETURN
436
437/*:VRX GetCupsPrinters
438*/
439GetCupsPrinters: PROCEDURE EXPOSE globals.
440
441 CALL VRSet 'DT_INFO', 'Caption', 'Getting list of supported printers. Please wait...'
442
443 lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe --exclude-schemes drv -m |rxqueue'
444
445 _od = DIRECTORY()
446 CALL DIRECTORY globals.!cupsdir
447 listqueue = RXQUEUE('CREATE')
448 defqueue = RXQUEUE('SET', listqueue )
449
450 ADDRESS CMD '@' lpinfo_cmd listqueue
451 i = 0
452 DO QUEUED()
453 PARSE PULL line
454 IF LEFT( line, 6 ) == 'drv://' THEN ITERATE
455 PARSE VAR line _ppd '.ppd.gz ' _name
456 _ppd = _ppd'.ppd.gz'
457 IF _name == '' THEN DO
458 PARSE VAR line _ppd '.ppd ' _name
459 _ppd = _ppd'.ppd'
460 END
461 IF _name == '' THEN DO
462 PARSE VAR line _ppd _name
463 END
464 IF _name <> '' THEN DO
465 i = i + 1
466 ppds.i = _ppd
467 models.i = _name
468 END
469 END
470 ppds.0 = i
471 models.0 = i
472
473 CALL RXQUEUE 'SET', defqueue
474 CALL RXQUEUE 'DELETE', listqueue
475 CALL DIRECTORY _od
476
477 CALL VRSet 'LB_SELECT', 'Painting', 0
478 CALL VRMethod 'LB_SELECT', 'AddString', '-- Other printer (requires PPD) --',, ''
479 CALL VRMethod 'LB_SELECT', 'AddStringList', 'models.',, 'ppds.'
480 CALL VRSet 'LB_SELECT', 'Selected', 1
481 CALL VRSet 'LB_SELECT', 'Painting', 1
482
483 CALL VRSet 'DT_INFO', 'Caption', 'Select your printer model.'
484
485RETURN
486
487/*:VRX Halt
488*/
489Halt:
490 signal _VREHalt
491return
492
493/*:VRX ImportPPD
494*/
495ImportPPD: PROCEDURE EXPOSE globals.
496 /* Import a new PPD file into a PostScript PrinterPak driver.
497 */
498 ARG driver, ppdfile
499 IF driver == '' THEN driver = 'PSCRIPT'
500
501 CALL LINEOUT globals.!log1, 'Going to import PPD file into driver' driver'.'
502
503 /***
504 *** First, get our working directories and locate the driver source files.
505 ***/
506
507 mustcopy = 0
508 driver_path = GetDriverSource( driver )
509 IF driver_path == '' THEN DO
510 /* No source found. We'll have to try copying the actual installed
511 * driver files from under \OS2\DLL.
512 */
513 CALL LINEOUT globals.!log1, 'Driver source not found.'
514 driver_path = STREAM( globals.!os2dir'\DLL\'driver'\'driver'.DRV', 'C', 'QUERY EXISTS')
515 mustcopy = 1
516 END
517 IF driver_path <> '' THEN DO
518 srcdir = VRParseFilePath( driver_path, 'DP')
519 pin = STREAM( srcdir'\PIN.EXE', 'C', 'QUERY EXISTS')
520 ppdenc = STREAM( srcdir'\PPDENC.EXE', 'C', 'QUERY EXISTS')
521 /* TODO should we check for all the REQUIREDDRIVER FILES as well? */
522 DROP srcdir
523 END
524
525 /* Driver (or one of its required files) was not found.
526 */
527 IF ( driver_path == '') | ( pin == '') | ( ppdenc == '') | ,
528 ( VerifyDriverEAs( driver_path ) == 0 ) THEN
529 DO
530 CALL LINEOUT globals.!log1, ' - Missing required driver files.'
531 /* TODO should prompt for installable driver package? */
532 RETURN 1 /** RC=1 Missing required driver files **/
533 END
534
535 IF mustcopy <> 0 THEN DO
536 /* Looks like the driver wasn't shipped with the OS; we have a source
537 * (either the active files from \OS2\DLL, or a package provided by
538 * the user), but we need somewhere for them to live. The user needs
539 * to tell us where, because they're going to have to specify the
540 * directory later on if they install the driver from PM.
541 */
542 pbtn.1 = 'OK'
543 pbtn.2 = 'Cancel'
544 pbtn.0 = 2
545 ptext = 'The install files for the' driver 'driver could not be ' ||,
546 'located. These files will be recreated from the driver ' ||,
547 'files which are already installed on your system.' ||,
548 '0d0a0d0a'x || 'Please enter the directory where the ' ||,
549 'install files will be placed.'
550 PARSE VALUE VRGetIni('PM_INSTALL', driver'_DIR', 'USER') WITH drvr_dir '00'x .
551 IF drvr_dir == '' THEN
552 PARSE VALUE VRGetIni('InstPDR', 'PATH_TO_'driver, 'USER') WITH drvr_dir '00'x .
553 ok = VRPrompt('WN_MAIN', ptext, 'drvr_dir',,
554 'Enter Directory', 'pbtn.', 1, 2 )
555 IF ok <> 1 THEN RETURN 9 /** RC=9 User cancelled **/
556 drvr_dir = VRExpandFileName( drvr_dir )
557 DO WHILE drvr_dir == ''
558 ok = VRPrompt('WN_MAIN', ptext, 'drvr_dir',,
559 'Enter Directory', 'pbtn.', 1, 2 )
560 drvr_dir = VRExpandFileName( drvr_dir )
561 END
562
563 /* Now create the new directory, if necessary */
564 IF VRMkDir( drvr_dir ) == 0 THEN
565 RETURN 3 /** RC=3 Failed to copy driver files **/
566 IF CopyDriverToSource( driver_path, drvr_dir ) == 0 THEN
567 RETURN 3 /** RC=3 Failed to copy driver files **/
568
569 /* Make sure we save the location (we'll need this information later) */
570 CALL VRSetIni 'PM_INSTALL', driver'_DIR', drvr_dir||'00'x, 'USER'
571
572 /* Now point to the new copy as the driver we will work on */
573 driver_path = drvr_dir'\'driver'.DRV'
574 END
575
576 workdir = SysTempFileName( globals.!tmpdir'\PPD_????')
577 ok = VrMkDir( workdir )
578 IF ok == 1 THEN ok = VrMkDir( workdir'\OUT')
579 IF ok <> 1 THEN
580 RETURN 2 /** RC=2 Failed to create temporary directory **/
581
582 SELECT
583 WHEN driver == 'ECUPS' THEN ppddir = globals.!repository'\PPD_E'
584 WHEN driver == 'ECUPS-HP' THEN ppddir = globals.!repository'\PPD_EHP'
585 WHEN driver == 'PSPRINT' THEN ppddir = globals.!repository'\PPD_PS'
586 WHEN driver == 'PSPRINT2' THEN ppddir = globals.!repository'\PPD_PS2'
587 WHEN driver == 'PSCRIPT2' THEN ppddir = globals.!repository'\PPD2'
588 OTHERWISE ppddir = globals.!repository'\PPD'
589 END
590
591 /* Make sure ppddir (for keeping PPD files) exists */
592 CALL SysFileTree ppddir, 'dirs.', 'DO'
593 IF dirs.0 == 0 THEN DO
594 ok = VrMkDir( ppddir )
595 IF ok <> 1 THEN
596 RETURN 4 /** RC=4 Failed to create PPD directory **/
597 END
598
599 /***
600 *** Now do the actual work.
601 ***/
602
603 /* Back up the modified files (AUXPRINT.PAK and <driver>.DRV) if we're
604 * working out of the repository.
605 IF mustcopy == 0 THEN DO
606 repfiles.0 = 2
607 repfiles.1 = driver'.DRV'
608 repfiles.2 = 'AUXPRINT.PAK'
609 CALL BackupDrivers driver_path
610 END
611 */
612
613 /* Copy the needed driver files to our working directories.
614 */
615 drv_out = workdir'\OUT\'driver'.DRV'
616 pin_exe = workdir'\PIN.EXE'
617 ppd_exe = workdir'\PPDENC.EXE'
618 ok = VRCopyFile( driver_path, drv_out )
619 IF ok == 1 THEN ok = VRCopyFile( pin, pin_exe )
620 IF ok == 1 THEN ok = VRCopyFile( ppdenc, ppd_exe )
621 IF ok == 0 THEN DO
622 RETURN 3 /*** RC=3 Failed to copy driver files ***/
623 END
624
625 /* Set up the output redirection.
626 */
627 nq = RXQUEUE('CREATE')
628 oq = RXQUEUE('SET', nq )
629
630 /* If the PPD file is compressed, uncompress it.
631 */
632 IF VRParseFilePath( ppdfile, 'E') == 'GZ' THEN DO
633 decppd = workdir'\' || VRParseFilePath( ppdfile, 'N')
634 CALL LINEOUT globals.!log1, 'Decompressing' ppdfile 'to' decppd
635 ADDRESS CMD '@gzip -c -d' ppdfile '| RXQUEUE' nq
636 DO QUEUED()
637 PARSE PULL line
638 CALL LINEOUT decppd, line
639 END
640 CALL LINEOUT decppd
641 ppdfile = decppd
642 END
643
644 IF VRFileExists( ppdfile ) == 0 THEN DO
645 CALL LINEOUT globals.!log1, 'PPD file' ppdfile 'could not be found.'
646 RETURN 5 /** RC=5 PPD import failed **/
647 END
648
649 ppd_use = ppddir'\' || VRParseFileName( ppdfile, 'NE')
650
651 /* Now we have to clean up and validate the PPD file so PIN can use it.
652 * First, PPDENC converts the codepage if necessary, and copies the results
653 * to our working directory.
654 */
655 ADDRESS CMD '@'ppd_exe ppdfile ppd_use '2>&1 | RXQUEUE' nq
656 DO QUEUED()
657 PULL output
658 CALL LINEOUT globals.!log2, output
659 END
660 CALL LINEOUT globals.!log2, ''
661 CALL LINEOUT globals.!log2
662
663 /* Next we strip out some problematic lines used which are often encountered
664 * in (e.g.) CUPS-based PPD files.
665 */
666 CALL CleanPPD ppd_use, globals.!log1
667
668 /* Preparation complete. Now do the import.
669 */
670 count = 0
671 ADDRESS CMD '@'pin_exe 'ppd' ppddir drv_out '2>&1 | RXQUEUE' nq
672 DO QUEUED()
673 PARSE PULL output
674 CALL LINEOUT globals.!log2, output
675 PARSE VAR output . 'OK (' nickname
676 IF nickname <> '' THEN DO
677 count = count + 1
678 newprinters.count = STRIP( nickname, 'T', ')')
679 END
680 END
681 newprinters.0 = count
682 CALL LINEOUT globals.!log2, ''
683 CALL LINEOUT globals.!log2
684
685 /* End the output redirection.
686 */
687 CALL RXQUEUE 'SET', oq
688 CALL RXQUEUE 'DELETE', nq
689
690
691 /***
692 *** Post-import processing.
693 ***/
694
695 IF newprinters.0 == 0 THEN DO
696 RETURN 5 /** RC=5 PPD import failed **/
697 END
698
699 IF mustcopy == 0 THEN DO
700 /* If we're working out of the repository, we need to update the
701 * driver table in PRDESC.LST to add the new driver(s).
702 */
703 CALL LINEOUT globals.!log1, 'Updating' globals.!prdesc 'with' newprinters.0 'new entries ...'
704 count = 0
705 match_drv = '('driver'.DRV)'
706 match_len = LENGTH( match_drv )
707
708 /* First, copy all lines that don't refer to the driver just updated */
709 DO WHILE LINES( globals.!prdesc )
710 _line = LINEIN( globals.!prdesc )
711 IF TRANSLATE( RIGHT( _line, LENGTH( match_len ))) == match_drv THEN ITERATE
712 count = count + 1
713 defs.count = _line
714 END
715 CALL STREAM globals.!prdesc, 'C', 'CLOSE'
716
717 /* Next, create a new list for the updated driver and merge that in */
718 newlist = workdir'\'driver'.LST'
719 CALL CreateDriverList driver, newlist
720 DO WHILE LINES( newlist )
721 _line = LINEIN( newlist )
722 count = count + 1
723 defs.count = _line
724 END
725 defs.0 = count
726
727 /* Now sort the list and recreate PRDESC.LST */
728 CALL SysStemSort 'defs.',, 'I'
729 prdesc_tmp = workdir'\PRDESC.LST'
730 IF STREAM( prdesc_tmp, 'C', 'QUERY EXISTS') <> '' THEN
731 CALL VRDeleteFile prdesc_tmp
732 DO i = 1 TO defs.0
733 CALL LINEOUT prdesc_tmp, defs.i
734 END
735 CALL LINEOUT prdesc_tmp
736 ok = VRCopyFile( prdesc_tmp, globals.!prdesc )
737 IF ok == 0 THEN DO
738 RETURN 6 /** RC=6 Error updating PRDESC.LST **/
739 END
740 CALL VRDeleteFile prdesc_tmp
741
742 END
743
744 /* Finally, copy the updated driver files.
745 */
746 target = VRParseFilePath( driver_path, 'DP')
747 ok = VRCopyFile( workdir'\OUT\*', target )
748 IF ok == 1 THEN DO
749 /* Copy the updated files to \OS2\DLL\<driver>, replacing any
750 * existing copies. (This prevents problems if the OS/2 driver
751 * installation doesn't/fails to copy them, which can happen under
752 * some circumstances.)
753 */
754 IF VRFileExists( globals.!os2dir'\DLL\'driver ) THEN DO
755 CALL VRCopyFile workdir'\OUT\AUXPRINT.PAK',,
756 globals.!os2dir'\DLL\'driver'\AUXPRINT.PAK'
757 CALL VRCopyFile workdir'\OUT\'driver'.DRV',,
758 globals.!os2dir'\DLL\'driver'\'driver'.DRV'
759 END
760 END
761 IF ok == 0 THEN
762 RETURN 3 /*** RC=3 Failed to copy driver files ***/
763
764 CALL LINEOUT globals.!log1, newprinters.0 'printers imported successfully.'
765 DO i = 1 TO newprinters.0
766 CALL LINEOUT globals.!log1, ' ->' newprinters.i
767 END
768 CALL LINEOUT globals.!log1, ''
769 CALL LINEOUT globals.!log1
770
771 /* Clean up our work directories.
772 */
773 CALL VRDeleteFile workdir'\OUT\*'
774 CALL VRDeleteFile workdir'\*'
775 CALL VRRmDir( workdir'\OUT')
776 CALL VRRmDir( workdir )
777
778RETURN 0
779
780/*:VRX Init
781*/
782Init:
783 SIGNAL ON NOVALUE NAME __NoValue
784
785 CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
786 CALL SysLoadFuncs
787
788 CALL LoadSettings
789
790 IF InitArgs.0 > 0 THEN globals.!cupsdir = InitArgs.1
791
792 IF \VRIsDir( globals.!cupsdir ) THEN DO
793 CALL VRMessage VRWindow(), 'Please specify the path where CUPS is installed as follows:' ||,
794 '0d0a0d0a'x || 'CUPSWIZ <cups-path>',,
795 'Unknown or Invalid CUPS Path', 'E'
796 EXIT
797 END
798
799 /* Delete the error log file each time the program starts.
800 */
801 IF VRFileExists( globals.!log2 ) THEN
802 CALL VRDeleteFile globals.!log2
803
804 window = VRWindow()
805 call VRMethod window, "CenterWindow"
806 call VRSet window, "Visible", 1
807 call VRMethod window, "Activate"
808 drop window
809
810 CALL SetPage1
811
812RETURN
813
814/*:VRX InitMessageLog
815*/
816/* Initialize the message logfile. Unlike the error log, which is cleared and
817 * recreated every time the program starts, the message log is appended to
818 * until it reaches 100kB in size. If the message log is larger than 100kB when
819 * this function is called, it is renamed (with '~' appended to the name) and
820 * a new message log is started.
821 */
822InitMessageLog: PROCEDURE EXPOSE globals.
823
824 logsize = STREAM( globals.!log1, 'C', 'QUERY SIZE')
825 IF ( logsize <> '') & ( logsize > 102400 ) THEN DO
826 CALL VRCopyFile globals.!log1, globals.!log1 || '~'
827 CALL VRDeleteFile globals.!log1
828 END
829
830 datestr = DATE('L') TIME('N')
831 CALL LINEOUT globals.!log1, '--[' datestr ']' ||,
832 COPIES('-', 73 - LENGTH( datestr ))
833RETURN
834
835/*:VRX LoadSettings
836*/
837LoadSettings: PROCEDURE EXPOSE globals.
838
839 me = VRGet('Application', 'Program')
840 IF me == '' THEN PARSE SOURCE . . me
841 globals.!mydir = VRParseFilePath( me, 'DP')
842
843 /* Get CUPS paths.
844 */
845 globals.!cupsdir = ''
846 cupsdrv = VRParseFilePath( me, 'D')
847 cupsdir = cupsdrv':\cups'
848
849 globals.!cupsdir = cupsdir
850
851 /* Get system paths.
852 */
853 globals.!bootdrv = SysBootDrive()
854 IF globals.!bootdrv == '' THEN
855 globals.!bootdrv = FILESPEC('DRIVE', VALUE('OS2_SHELL',,'OS2ENVIRONMENT'))
856 globals.!os2dir = globals.!bootdrv'\OS2'
857 globals.!tmpdir = VALUE('TMP',,'OS2ENVIRONMENT')
858 IF globals.!tmpdir == '' THEN
859 globals.!tmpdir = VALUE('TEMP',,'OS2ENVIRONMENT')
860 IF globals.!tmpdir == '' THEN
861 globals.!tmpdir = globals.!mydir
862 globals.!logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT')
863 IF globals.!logdir == '' THEN
864 globals.!logdir = globals.!mydir
865
866 globals.!log1 = globals.!logdir'\cupswiz.l1'
867 globals.!log2 = globals.!logdir'\cupswiz.l2'
868
869 /* Get printer-related paths.
870 */
871 PARSE VALUE VRGetIni('PM_INSTALL', 'PDR_DIR', 'USER') WITH repos_dir '00'x .
872 globals.!repository = repos_dir
873 globals.!prdrv = STREAM( globals.!os2dir'\install\prdrv.lst', 'C', 'QUERY EXISTS')
874 globals.!prdesc = STREAM( globals.!os2dir'\install\prdesc.lst', 'C', 'QUERY EXISTS')
875
876RETURN 0
877
878/*:VRX LoopbackName
879*/
880/* Check to see if 'localhost' is defined in the HOSTS file. If not, we'll
881 * have to use '127.0.0.1' instead.
882 */
883LoopbackName: PROCEDURE
884
885 lo_name = '127.0.0.1'
886 etcdir = VALUE('ETC',,'OS2ENVIRONMENT')
887 IF etcdir <> '' THEN DO
888 hosts = STREAM( etcdir'\HOSTS', 'C', 'QUERY EXISTS')
889 IF hosts <> '' THEN DO
890 CALL LINEIN hosts, 1, 0
891 DO WHILE LINES( hosts ) > 0
892 _hostdef = TRANSLATE( LINEIN( hosts ))
893 _hostdef = TRANSLATE( _hostdef, ' ', '09'x )
894 IF WORDPOS('LOCALHOST', _hostdef ) == 2 THEN DO
895 lo_name = 'localhost'
896 LEAVE
897 END
898 END
899 END
900 END
901
902RETURN lo_name
903
904/*:VRX PB_CANCEL_Click
905*/
906PB_CANCEL_Click:
907 CALL Quit
908return
909
910/*:VRX PB_CREATECANCEL_Click
911*/
912PB_CREATECANCEL_Click:
913 CALL SW_CREATE_Close
914RETURN
915
916/*:VRX PB_CREATEOK_Click
917*/
918PB_CREATEOK_Click:
919
920 create_os2 = VRGet('CHK_CREATEPM', 'Set')
921 globals.!os2printer = create_os2
922 globals.!create = 1
923
924 CALL SW_CREATE_Close
925
926RETURN
927
928/*:VRX PB_MODELCANCEL_Click
929*/
930PB_MODELCANCEL_Click:
931 CALL SW_MODEL_Close
932 globals.!prt_nick = 'Generic PostScript Printer'
933RETURN
934
935/*:VRX PB_MODELOK_Click
936*/
937PB_MODELOK_Click:
938 globals.!prt_nick = VRGet( "LB_OS2MODELS", "SelectedString" )
939 CALL SW_MODEL_Close
940RETURN
941
942/*:VRX PB_NETCANCEL_Click
943*/
944PB_NETCANCEL_Click:
945 CALL SW_NETWORK_Fini
946RETURN
947
948/*:VRX PB_NETOK_Click
949*/
950PB_NETOK_Click: PROCEDURE EXPOSE globals. port
951 which = VRGet('DDCB_PROTOCOL', 'Selected')
952 server = STRIP( VRGet("EF_SERVER", "Value"))
953 pqueue = STRIP( VRGet("EF_QUEUE", "Value"))
954 userid = STRIP( VRGet("EF_USERID", "Value"))
955 passwd = STRIP( VRGet("EF_PASSWORD", "Value"))
956
957 invalid = 0
958
959 SELECT
960 WHEN which == 1 THEN DO /* IPP */
961 IF server == '' | pqueue == '' THEN invalid = 1
962 uri = 'ipp://'
963 IF userid <> '' THEN DO
964 uri = uri || userid
965 IF passwd <> '' THEN uri = uri':'passwd
966 uri = uri'@'
967 END
968 uri = uri || server'/'pqueue
969 END
970 WHEN which == 2 THEN DO /* SOCKET */
971 IF server == '' THEN invalid = 1
972 uri = 'socket://'server
973 END
974 WHEN which == 3 THEN DO /* LPD */
975 IF server == '' THEN invalid = 1
976 IF pqueue == '' THEN pqueue = '*'
977 IF userid <> '' THEN
978 uri = 'ipp://'userid'@'server'/'pqueue
979 ELSE
980 uri = 'lpd://'server'/'pqueue
981 END
982 WHEN which == 4 THEN DO /* SMB */
983 IF server == '' | pqueue == '' THEN invalid = 1
984 uri = 'smb://'
985 IF userid <> '' THEN DO
986 uri = uri || userid
987 IF passwd <> '' THEN uri = uri':'passwd
988 uri = uri'@'
989 END
990 uri = uri || server'/'pqueue
991 END
992 OTHERWISE DO
993 IF server == '' | pqueue == '' THEN invalid = 1
994 ELSE DO
995 globals.!remotecups = server pqueue
996 uri = ''
997 END
998 END
999 END
1000
1001 IF invalid == 1 THEN DO
1002 CALL VRMessage VRWindow(), 'Missing required value(s).', 'Missing Value(s)', 'E'
1003 RETURN
1004 END
1005
1006 port = uri
1007 CALL SW_NETWORK_Fini
1008
1009RETURN
1010
1011/*:VRX PB_NEXT_Click
1012*/
1013PB_NEXT_Click: PROCEDURE EXPOSE globals.
1014
1015 SELECT
1016 WHEN globals.!page == 1 THEN DO
1017 selected = VRGet('LB_SELECT', 'Selected')
1018 IF selected == 0 THEN RETURN
1019
1020 ppd = VRMethod('LB_SELECT', 'GetItemData', selected )
1021 IF ppd == '' THEN DO
1022 globals.!mode = 2 /* Mode 2: user-selected PPD file */
1023 ppd = VRFileDialog( VRWindow(), 'Select PPD', 'O', '*.ppd')
1024 IF ppd == '' THEN RETURN
1025 globals.!prt_ppd = ppd
1026 globals.!prt_dev = ''
1027 globals.!prt_nick = GetNameFromPPD( ppd )
1028 END
1029 ELSE DO
1030 globals.!mode = 1 /* Mode 1: CUPS-included model */
1031 IF POS('exe://', ppd ) > 0 THEN DO
1032 globals.!prt_ppd = ''
1033 globals.!prt_dev = ppd
1034 sel_name = VRMethod('LB_SELECT', 'GetString', selected )
1035 PARSE VAR sel_name _nick ' - CUPS' .
1036 IF _nick == '' THEN
1037 globals.!prt_nick = STRIP( sel_name )
1038 ELSE
1039 globals.!prt_nick = STRIP( _nick )
1040 END
1041 ELSE DO
1042 globals.!prt_ppd = TRANSLATE( globals.!cupsdir'/share/cups/model/'ppd, '\', '/')
1043 globals.!prt_dev = ''
1044 globals.!prt_nick = GetNameFromPPD( ppd )
1045 END
1046 END
1047 globals.!remotecups = ''
1048
1049 CALL InitMessageLog
1050 IF globals.!mode ==2 THEN
1051 CALL LINEOUT globals.!log1, 'Starting printer install with user-provided PPD:'
1052 ELSE
1053 CALL LINEOUT globals.!log1, 'Starting printer install for built-in model:'
1054 IF globals.!prt_dev <> '' THEN
1055 CALL LINEOUT globals.!log1, ' - Device name:' globals.!prt_dev
1056 ELSE
1057 CALL LINEOUT globals.!log1, ' - PPD file: ' globals.!prt_ppd
1058 CALL LINEOUT globals.!log1, ' - Model name: ' globals.!prt_nick
1059 CALL LINEOUT globals.!log1, ''
1060
1061 CALL SetPage2
1062 END
1063
1064 WHEN globals.!page == 2 THEN DO
1065 selected = VRGet('LB_SELECT', 'Selected')
1066 IF selected == 0 THEN RETURN
1067 port = VRMethod('LB_SELECT', 'GetItemData', selected )
1068
1069 IF port == '' THEN DO
1070 /* Network printer selected; prompt for the connection details
1071 */
1072 CALL VRLoadSecondary 'SW_NETWORK', 'W'
1073 END
1074
1075 IF port == '' & globals.!remotecups == '' THEN RETURN
1076 globals.!prt_port = port
1077
1078 CALL SetPage3
1079 END
1080
1081 WHEN globals.!page == 3 THEN DO
1082 globals.!prt_name = STRIP( VRGet('EF_NAME', 'Value'))
1083 globals.!prt_loc = STRIP( VRGet('EF_LOCATION', 'Value'))
1084 globals.!prt_info = STRIP( VRGet('EF_DESC', 'Value'))
1085 IF ((( globals.!prt_name == '') |,
1086 ( globals.!prt_loc == '')) & ( globals.!remotecups == '')) |,
1087 ( globals.!prt_info == '') THEN
1088 DO
1089 IF ( globals.!remotecups <> '') THEN
1090 _errmsg = 'You must enter a description.'
1091 ELSE
1092 _errmsg = 'You must enter a name, a location, and a description.'
1093 CALL VRMessage VRWindow(), _errmsg, 'Missing Value(s)', 'E'
1094 RETURN
1095 END
1096 IF ( globals.!remotecups == '' &,
1097 ( POS( LEFT( globals.!prt_name, 1 ),,
1098 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') == 0 ) |,
1099 ( VERIFY( globals.!prt_name, '/# ' || '09'x, 'MATCH') <> 0 )) THEN
1100 DO
1101 CALL VRMessage VRWindow(), 'The printer name must start ' ||,
1102 'with a letter, and may not include "/", "#", ' ||,
1103 'space, or tab characters.', 'Invalid Name', 'E'
1104 RETURN
1105 END
1106
1107 /* TODO support other drivers
1108 */
1109 globals.!os2driver = 'ECUPS'
1110
1111 CALL ConfirmAndCreate
1112 END
1113
1114 WHEN globals.!page == 4 THEN DO
1115 CALL VRSet 'PB_NEXT', 'Caption', 'Next >'
1116 CALL VRSet 'EF_NAME', 'Value', ''
1117 CALL VRSet 'EF_LOCATION', 'Value', ''
1118 CALL VRSet 'EF_DESC', 'Value', ''
1119 CALL SetPage1
1120 END
1121
1122 OTHERWISE NOP
1123 END
1124
1125RETURN
1126
1127/*:VRX PromptForPMName
1128*/
1129PromptForPMName: PROCEDURE EXPOSE globals. models. best
1130 best = MatchPrinterModel( globals.!os2driver, globals.!prt_nick )
1131
1132 IF models.0 == 0 THEN DO
1133 /* No similar models were found in the list of supported printers.
1134 * Just use the generic PS driver.
1135 */
1136 CALL VRMessage VRWindow(),,
1137 'The printer "'globals.!prt_nick'" does not appear to' ,
1138 'be supported by the' globals.!os2driver 'driver, and' ,
1139 'no similar models were found. The generic PostScript',
1140 'driver will be used for application support.',,
1141 'Printer Name Not Found', 'E'
1142 globals.!prt_nick = 'Generic PostScript Printer'
1143 RETURN
1144 END
1145
1146 CALL VRLoadSecondary 'SW_MODEL', 'W'
1147
1148RETURN
1149
1150/*:VRX Quit
1151*/
1152Quit:
1153 window = VRWindow()
1154 call VRSet window, "Shutdown", 1
1155 drop window
1156return
1157
1158/*:VRX SetPage1
1159*/
1160SetPage1: PROCEDURE EXPOSE globals.
1161
1162 CALL VRSet 'LB_SELECT', 'Visible', 1
1163 CALL VRSet 'GB_INFO', 'Visible', 0
1164
1165 globals.!page = 1
1166 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
1167 CALL GetCupsPrinters
1168 CALL VRMethod 'LB_SELECT', 'SetFocus'
1169 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
1170RETURN
1171
1172/*:VRX SetPage2
1173*/
1174SetPage2: PROCEDURE EXPOSE globals.
1175
1176 globals.!page = 2
1177 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
1178 CALL GetCupsPorts
1179 CALL VRMethod 'LB_SELECT', 'SetFocus'
1180 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
1181
1182RETURN
1183
1184/*:VRX SetPage3
1185*/
1186SetPage3: PROCEDURE EXPOSE globals.
1187
1188 globals.!page = 3
1189 CALL VRSet 'EF_DESC', 'Value', globals.!prt_nick
1190
1191 CALL VRMethod 'LB_SELECT', 'Clear'
1192
1193 CALL VRSet 'LB_SELECT', 'Visible', 0
1194 CALL VRSet 'GB_INFO', 'Visible', 1
1195 IF globals.!remotecups == '' THEN DO
1196 CALL VRSet 'DT_INFO', 'Caption', 'Choose the printer name, and enter its location and a short description.'
1197 CALL VRSet 'DT_NAME', 'Visible', 1
1198 CALL VRSet 'EF_NAME', 'Visible', 1
1199 CALL VRSet 'DT_LOCATION', 'Visible', 1
1200 CALL VRSet 'EF_LOCATION', 'Visible', 1
1201 END
1202 ELSE
1203 CALL VRSet 'DT_INFO', 'Caption', 'Enter a short description of this printer. ',
1204 'This will be used for the printer object that appears on your desktop.'
1205 CALL VRSet 'DT_DESC', 'Visible', 1
1206 CALL VRSet 'EF_DESC', 'Visible', 1
1207
1208 CALL VRMethod 'EF_NAME', 'SetFocus'
1209
1210RETURN
1211
1212/*:VRX SetPage4
1213*/
1214SetPage4:
1215
1216 globals.!page = 4
1217 CALL VRSet 'LB_SELECT', 'Visible', 0
1218 CALL VRSet 'GB_INFO', 'Visible', 0
1219
1220RETURN
1221
1222/*:VRX SW_CREATE_Close
1223*/
1224SW_CREATE_Close:
1225 call SW_CREATE_Fini
1226return
1227
1228/*:VRX SW_CREATE_Create
1229*/
1230SW_CREATE_Create:
1231 call SW_CREATE_Init
1232return
1233
1234/*:VRX SW_CREATE_Fini
1235*/
1236SW_CREATE_Fini:
1237 window = VRInfo( "Window" )
1238 call VRDestroy window
1239 drop window
1240return
1241/*:VRX SW_CREATE_Init
1242*/
1243SW_CREATE_Init:
1244
1245 CALL VRSet 'EF_CRMODEL', 'Value', globals.!prt_nick
1246
1247 IF globals.!remotecups <> '' THEN DO
1248 /* An existing CUPS printer was indicated. This means we're not
1249 * creating a CUPS printer, but only a PM printer object (and port)
1250 * that points to it.
1251 */
1252 CALL VRSet 'DT_CREATE', 'Caption', 'Ready to create printer object with the following parameters.'
1253
1254 PARSE VAR globals.!remotecups cups_host cups_printer .
1255 CALL VRSet 'DT_CRNAME', 'Caption', 'CUPS server:'
1256 CALL VRSet 'EF_CRNAME', 'Value', cups_host
1257 CALL VRSet 'DT_CRURI', 'Caption', 'CUPS queue:'
1258 CALL VRSet 'EF_CRURI', 'Value', cups_printer
1259 CALL VRSet 'DT_CRLOC', 'Visible', 0
1260 CALL VRSet 'EF_CRLOC', 'Visible', 0
1261 CALL VRSet 'CHK_CREATEPM', 'Visible', 0
1262 END
1263 ELSE DO
1264 CALL VRSet 'EF_CRNAME', 'Value', globals.!prt_name
1265 CALL VRSet 'EF_CRURI', 'Value', globals.!prt_port
1266 CALL VRSet 'EF_CRLOC', 'Value', globals.!prt_loc
1267 END
1268 CALL VRSet 'EF_CRDESC', 'Value', globals.!prt_info
1269
1270 window = VRInfo( "Object" )
1271 if( \VRIsChildOf( window, "Notebook" ) ) then do
1272 call VRMethod window, "CenterWindow"
1273 call VRSet window, "Visible", 1
1274 call VRMethod window, "Activate"
1275 end
1276 drop window
1277
1278RETURN
1279
1280/*:VRX SW_MODEL_Close
1281*/
1282SW_MODEL_Close:
1283 call SW_MODEL_Fini
1284return
1285
1286/*:VRX SW_MODEL_Create
1287*/
1288SW_MODEL_Create:
1289 call SW_MODEL_Init
1290return
1291
1292/*:VRX SW_MODEL_Fini
1293*/
1294SW_MODEL_Fini:
1295
1296 CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
1297
1298 window = VRInfo( "Window" )
1299 call VRDestroy window
1300 drop window
1301return
1302/*:VRX SW_MODEL_Init
1303*/
1304SW_MODEL_Init:
1305
1306 /* We should have a list of suggested printer models whose names at least
1307 * partially match the requested model, sorted in order with the closest
1308 * match at the top.
1309 */
1310 ok = VRMethod( "LB_OS2MODELS", "AddStringList", "models.", )
1311 IF best > 0 THEN
1312 CALL VRSet 'LP_OS2MODELS', 'Selected', best
1313
1314 CALL VRSet 'DT_MODEL1', 'Caption',,
1315 'The printer "'globals.!prt_nick'" could not be found in the' ,
1316 globals.!os2driver'.DRV driver under that name. Please choose',
1317 'the model of printer which will be reported to applications.'
1318
1319 CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
1320
1321 window = VRInfo( "Object" )
1322 if( \VRIsChildOf( window, "Notebook" ) ) then do
1323 call VRMethod window, "CenterWindow"
1324 call VRSet window, "Visible", 1
1325 call VRMethod window, "Activate"
1326 end
1327 drop window
1328
1329RETURN
1330
1331/*:VRX SW_NETWORK_Close
1332*/
1333SW_NETWORK_Close:
1334 call SW_NETWORK_Fini
1335return
1336
1337/*:VRX SW_NETWORK_Create
1338*/
1339SW_NETWORK_Create:
1340 call SW_NETWORK_Init
1341return
1342
1343/*:VRX SW_NETWORK_Fini
1344*/
1345SW_NETWORK_Fini:
1346 window = VRInfo( "Window" )
1347 call VRDestroy window
1348 drop window
1349return
1350/*:VRX SW_NETWORK_Init
1351*/
1352SW_NETWORK_Init:
1353
1354 CALL VRSet 'DDCB_PROTOCOL', 'Selected', 1
1355
1356 window = VRInfo( "Object" )
1357 if( \VRIsChildOf( window, "Notebook" ) ) then do
1358 call VRMethod window, "CenterWindow"
1359 call VRSet window, "Visible", 1
1360 call VRMethod window, "Activate"
1361 end
1362 drop window
1363return
1364
1365/*:VRX WN_MAIN_Close
1366*/
1367WN_MAIN_Close:
1368 call Quit
1369return
1370
Note: See TracBrowser for help on using the repository browser.