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

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

Fall back to PSPRINT (if available) if default presentation driver is not installed.

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