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

Last change on this file since 18 was 18, checked in by Alex Taylor, 13 years ago

Start NLS-enablement.

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