1 | /*:VRX Main
|
---|
2 | */
|
---|
3 | /* Main
|
---|
4 | */
|
---|
5 | Main:
|
---|
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
|
---|
59 | exit _VREReturnValue
|
---|
60 |
|
---|
61 | VRLoadSecondary:
|
---|
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:
|
---|
88 | return __vrlsHWnd
|
---|
89 |
|
---|
90 | /*:VRX __NoValue
|
---|
91 | */
|
---|
92 | __NoValue:
|
---|
93 | SAY FORMAT( sigl, 6 ) '+++' SOURCELINE( sigl )
|
---|
94 | SAY FORMAT( sigl, 6 ) '+++ Uninitialized variable'
|
---|
95 | EXIT sigl
|
---|
96 |
|
---|
97 | /*:VRX __VXREXX____APPENDS__
|
---|
98 | */
|
---|
99 | __VXREXX____APPENDS__:
|
---|
100 | /*
|
---|
101 | #append ..\..\Shared\PrintUtl.VRS
|
---|
102 | */
|
---|
103 | return
|
---|
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 |
|
---|
130 | RETURN InitArgs.0
|
---|
131 |
|
---|
132 | /*:VRX CheckPrograms
|
---|
133 | */
|
---|
134 | CheckPrograms: 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 |
|
---|
191 | RETURN
|
---|
192 |
|
---|
193 | /*:VRX CHK_CREATEPM_Click
|
---|
194 | */
|
---|
195 | CHK_CREATEPM_Click: PROCEDURE
|
---|
196 | set = VRGet( "CHK_CREATEPM", "Set" )
|
---|
197 | CALL VRSet 'DT_PRESDRV', 'Enabled', set
|
---|
198 | CALL VRSet 'DDCB_PRESDRV', 'Enabled', set
|
---|
199 | RETURN
|
---|
200 |
|
---|
201 | /*:VRX ConfirmAndCreate
|
---|
202 | */
|
---|
203 | ConfirmAndCreate: 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 |
|
---|
238 | RETURN
|
---|
239 |
|
---|
240 | /*:VRX CreateCupsPrinter
|
---|
241 | */
|
---|
242 | CreateCupsPrinter: 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 |
|
---|
286 | RETURN 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 | */
|
---|
293 | CreateOS2Printer: 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 |
|
---|
381 | RETURN ok
|
---|
382 |
|
---|
383 | /*:VRX CreatePrinter
|
---|
384 | */
|
---|
385 | CreatePrinter: 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 |
|
---|
478 | RETURN 0
|
---|
479 |
|
---|
480 | /*:VRX DDCB_PROTOCOL_Change
|
---|
481 | */
|
---|
482 | DDCB_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 |
|
---|
546 | RETURN
|
---|
547 |
|
---|
548 | /*:VRX EF_SERVER_LostFocus
|
---|
549 | */
|
---|
550 | EF_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.'
|
---|
566 | RETURN
|
---|
567 |
|
---|
568 | /*:VRX ExecRINSTPRN
|
---|
569 | */
|
---|
570 | ExecRINSTPRN: 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 |
|
---|
588 | RETURN rc
|
---|
589 |
|
---|
590 | /*:VRX Fini
|
---|
591 | */
|
---|
592 | Fini:
|
---|
593 | window = VRWindow()
|
---|
594 | call VRSet window, "Visible", 0
|
---|
595 | drop window
|
---|
596 |
|
---|
597 | CALL PrintManCheckIn 'CUPSWIZ DONE'
|
---|
598 |
|
---|
599 | return 0
|
---|
600 |
|
---|
601 | /*:VRX GetCupsPorts
|
---|
602 | */
|
---|
603 | GetCupsPorts: 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 |
|
---|
669 | RETURN
|
---|
670 |
|
---|
671 | /*:VRX GetCupsPrinters
|
---|
672 | */
|
---|
673 | GetCupsPrinters: 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 |
|
---|
809 | RETURN
|
---|
810 |
|
---|
811 | /*:VRX GetCupsQueues
|
---|
812 | */
|
---|
813 | GetCupsQueues: 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 |
|
---|
849 | RETURN _count
|
---|
850 |
|
---|
851 | /*:VRX Halt
|
---|
852 | */
|
---|
853 | Halt:
|
---|
854 | signal _VREHalt
|
---|
855 | return
|
---|
856 |
|
---|
857 | /*:VRX ImportPPD
|
---|
858 | */
|
---|
859 | ImportPPD: 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 |
|
---|
1154 | RETURN 0
|
---|
1155 |
|
---|
1156 | /*:VRX Init
|
---|
1157 | */
|
---|
1158 | Init:
|
---|
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 |
|
---|
1212 | RETURN
|
---|
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 | */
|
---|
1222 | InitMessageLog: 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 |
|
---|
1239 | RETURN
|
---|
1240 |
|
---|
1241 | /*:VRX LB_BRAND_Click
|
---|
1242 | */
|
---|
1243 | LB_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
|
---|
1262 | say 'Model: ' manufacturers.item.!printers.i.!model
|
---|
1263 | say 'Driver: ' manufacturers.item.!printers.i.!driver
|
---|
1264 | say ' ' manufacturers.item.!printers.i.!longname
|
---|
1265 | if manufacturers.item.!printers.i.!driver2 <> '' then
|
---|
1266 | say 'Alternate:' manufacturers.item.!printers.i.!driver2
|
---|
1267 | if manufacturers.item.!printers.i.!longname2 <> '' then
|
---|
1268 | say ' ' manufacturers.item.!printers.i.!longname2
|
---|
1269 | say 'Type: ' manufacturers.item.!printers.i.!type
|
---|
1270 | say '---'
|
---|
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 |
|
---|
1285 | RETURN
|
---|
1286 |
|
---|
1287 | /*:VRX LB_SELECT_Click
|
---|
1288 | */
|
---|
1289 | LB_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
|
---|
1321 | RETURN
|
---|
1322 |
|
---|
1323 | /*:VRX LoadSettings
|
---|
1324 | */
|
---|
1325 | LoadSettings: 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.!tmpdir = STRIP( globals.!tmpdir, 'T', '\')
|
---|
1362 | globals.!logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT')
|
---|
1363 | IF globals.!logdir == '' THEN
|
---|
1364 | globals.!logdir = globals.!mydir
|
---|
1365 | globals.!logdir = STRIP( globals.!logdir, 'T', '\')
|
---|
1366 |
|
---|
1367 | globals.!log1 = globals.!logdir'\cupswiz.l1'
|
---|
1368 | globals.!log2 = globals.!logdir'\cupswiz.l2'
|
---|
1369 |
|
---|
1370 | /* Get printer-related paths.
|
---|
1371 | */
|
---|
1372 | PARSE VALUE VRGetIni('PM_INSTALL', 'PDR_DIR', 'USER') WITH repos_dir '00'x .
|
---|
1373 | globals.!repository = repos_dir
|
---|
1374 | globals.!prdrv = STREAM( globals.!os2dir'\install\prdrv.lst', 'C', 'QUERY EXISTS')
|
---|
1375 | globals.!prdesc = STREAM( globals.!os2dir'\install\prdesc.lst', 'C', 'QUERY EXISTS')
|
---|
1376 |
|
---|
1377 | /* Set the language file name.
|
---|
1378 | */
|
---|
1379 | globals.!nlsfile = 'cupswz'
|
---|
1380 |
|
---|
1381 | RETURN 0
|
---|
1382 |
|
---|
1383 | /*:VRX LoopbackName
|
---|
1384 | */
|
---|
1385 | /* Check to see if 'localhost' is defined in the HOSTS file. If not, we'll
|
---|
1386 | * have to use '127.0.0.1' instead.
|
---|
1387 | */
|
---|
1388 | LoopbackName: PROCEDURE
|
---|
1389 |
|
---|
1390 | lo_name = '127.0.0.1'
|
---|
1391 | etcdir = VALUE('ETC',,'OS2ENVIRONMENT')
|
---|
1392 | IF etcdir <> '' THEN DO
|
---|
1393 | hosts = STREAM( etcdir'\HOSTS', 'C', 'QUERY EXISTS')
|
---|
1394 | IF hosts <> '' THEN DO
|
---|
1395 | CALL LINEIN hosts, 1, 0
|
---|
1396 | DO WHILE LINES( hosts ) > 0
|
---|
1397 | _hostdef = TRANSLATE( LINEIN( hosts ))
|
---|
1398 | _hostdef = TRANSLATE( _hostdef, ' ', '09'x )
|
---|
1399 | IF WORDPOS('LOCALHOST', _hostdef ) == 2 THEN DO
|
---|
1400 | lo_name = 'localhost'
|
---|
1401 | LEAVE
|
---|
1402 | END
|
---|
1403 | END
|
---|
1404 | END
|
---|
1405 | END
|
---|
1406 |
|
---|
1407 | RETURN lo_name
|
---|
1408 |
|
---|
1409 | /*:VRX PB_ABOUT_Click
|
---|
1410 | */
|
---|
1411 | PB_ABOUT_Click:
|
---|
1412 | CALL SW_ABOUT_Close
|
---|
1413 | RETURN
|
---|
1414 |
|
---|
1415 | /*:VRX PB_CANCEL_Click
|
---|
1416 | */
|
---|
1417 | PB_CANCEL_Click:
|
---|
1418 | CALL Quit
|
---|
1419 | return
|
---|
1420 |
|
---|
1421 | /*:VRX PB_CREATECANCEL_Click
|
---|
1422 | */
|
---|
1423 | PB_CREATECANCEL_Click:
|
---|
1424 | CALL SW_CREATE_Close
|
---|
1425 | RETURN
|
---|
1426 |
|
---|
1427 | /*:VRX PB_CREATEHELP_Click
|
---|
1428 | */
|
---|
1429 | PB_CREATEHELP_Click:
|
---|
1430 | CALL VRMethod 'SW_CREATE', 'InvokeHelp'
|
---|
1431 | return
|
---|
1432 |
|
---|
1433 | /*:VRX PB_CREATEOK_Click
|
---|
1434 | */
|
---|
1435 | PB_CREATEOK_Click:
|
---|
1436 |
|
---|
1437 | create_os2 = VRGet('CHK_CREATEPM', 'Set')
|
---|
1438 | globals.!os2printer = create_os2
|
---|
1439 | globals.!os2driver = VRGet('DDCB_PRESDRV', 'SelectedString')
|
---|
1440 | globals.!create = 1
|
---|
1441 |
|
---|
1442 | CALL SW_CREATE_Close
|
---|
1443 |
|
---|
1444 | RETURN
|
---|
1445 |
|
---|
1446 | /*:VRX PB_HELP_Click
|
---|
1447 | */
|
---|
1448 | PB_HELP_Click:
|
---|
1449 | CALL VRMethod 'WN_MAIN', 'InvokeHelp'
|
---|
1450 | return
|
---|
1451 |
|
---|
1452 | /*:VRX PB_MODELCANCEL_Click
|
---|
1453 | */
|
---|
1454 | PB_MODELCANCEL_Click:
|
---|
1455 | CALL SW_MODEL_Close
|
---|
1456 | globals.!prt_nick = 'Generic PostScript Printer'
|
---|
1457 | RETURN
|
---|
1458 |
|
---|
1459 | /*:VRX PB_MODELOK_Click
|
---|
1460 | */
|
---|
1461 | PB_MODELOK_Click:
|
---|
1462 | globals.!prt_nick = VRGet( "LB_OS2MODELS", "SelectedString" )
|
---|
1463 | CALL SW_MODEL_Close
|
---|
1464 | RETURN
|
---|
1465 |
|
---|
1466 | /*:VRX PB_NETCANCEL_Click
|
---|
1467 | */
|
---|
1468 | PB_NETCANCEL_Click:
|
---|
1469 | CALL SW_NETWORK_Fini
|
---|
1470 | RETURN
|
---|
1471 |
|
---|
1472 | /*:VRX PB_NETHELP_Click
|
---|
1473 | */
|
---|
1474 | PB_NETHELP_Click:
|
---|
1475 | CALL VRMethod 'SW_NETWORK', 'InvokeHelp'
|
---|
1476 | return
|
---|
1477 |
|
---|
1478 | /*:VRX PB_NETOK_Click
|
---|
1479 | */
|
---|
1480 | PB_NETOK_Click: PROCEDURE EXPOSE globals. port
|
---|
1481 |
|
---|
1482 | idx = VRGet('DDCB_PROTOCOL', 'Selected')
|
---|
1483 | which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
|
---|
1484 | server = STRIP( VRGet("EF_SERVER", "Value"))
|
---|
1485 | pqueue = STRIP( VRGet("EF_QUEUE", "Value"))
|
---|
1486 | cqueue = STRIP( VRGet("DDCB_CUPSQUEUES","Value"))
|
---|
1487 | userid = STRIP( VRGet("EF_USERID", "Value"))
|
---|
1488 | passwd = STRIP( VRGet("EF_PASSWORD", "Value"))
|
---|
1489 |
|
---|
1490 | invalid = 0
|
---|
1491 |
|
---|
1492 | SELECT
|
---|
1493 | WHEN which == 1 THEN DO /* IPP */
|
---|
1494 | IF server == '' | pqueue == '' THEN invalid = 1
|
---|
1495 | uri = 'ipp://'
|
---|
1496 | IF userid <> '' THEN DO
|
---|
1497 | uri = uri || userid
|
---|
1498 | IF passwd <> '' THEN uri = uri':'passwd
|
---|
1499 | uri = uri'@'
|
---|
1500 | END
|
---|
1501 | uri = uri || server'/'pqueue
|
---|
1502 | END
|
---|
1503 | WHEN which == 2 THEN DO /* SOCKET */
|
---|
1504 | IF server == '' THEN invalid = 1
|
---|
1505 | uri = 'socket://'server
|
---|
1506 | END
|
---|
1507 | WHEN which == 3 THEN DO /* LPD */
|
---|
1508 | IF server == '' THEN invalid = 1
|
---|
1509 | IF pqueue == '' THEN pqueue = '*'
|
---|
1510 | IF userid <> '' THEN
|
---|
1511 | uri = 'ipp://'userid'@'server'/'pqueue
|
---|
1512 | ELSE
|
---|
1513 | uri = 'lpd://'server'/'pqueue
|
---|
1514 | END
|
---|
1515 | WHEN which == 4 THEN DO /* SMB */
|
---|
1516 | IF server == '' | pqueue == '' THEN invalid = 1
|
---|
1517 | uri = 'smb://'
|
---|
1518 | IF userid <> '' THEN DO
|
---|
1519 | uri = uri || userid
|
---|
1520 | IF passwd <> '' THEN uri = uri':'passwd
|
---|
1521 | uri = uri'@'
|
---|
1522 | END
|
---|
1523 | uri = uri || server'/'pqueue
|
---|
1524 | END
|
---|
1525 | OTHERWISE DO /* Existing CUPS */
|
---|
1526 | IF server == '' | cqueue == '' THEN invalid = 1
|
---|
1527 | ELSE DO
|
---|
1528 | globals.!remotecups = server cqueue
|
---|
1529 | uri = ''
|
---|
1530 | END
|
---|
1531 | END
|
---|
1532 | END
|
---|
1533 |
|
---|
1534 | IF invalid == 1 THEN DO
|
---|
1535 | CALL VRMessage VRWindow(), NLSGetMessage( 74 ),, /* 74: Missing required value(s). */
|
---|
1536 | NLSGetMessage( 75 ), 'E' /* 75: Missing Value(s) */
|
---|
1537 | RETURN
|
---|
1538 | END
|
---|
1539 |
|
---|
1540 | port = uri
|
---|
1541 | CALL SW_NETWORK_Fini
|
---|
1542 |
|
---|
1543 | RETURN
|
---|
1544 |
|
---|
1545 | /*:VRX PB_NEXT_Click
|
---|
1546 | */
|
---|
1547 | PB_NEXT_Click: PROCEDURE EXPOSE globals. manufacturers.
|
---|
1548 |
|
---|
1549 | SELECT
|
---|
1550 | WHEN globals.!page == 1 THEN DO
|
---|
1551 | brand = VRGet('LB_BRAND', 'Selected')
|
---|
1552 | IF brand == 0 THEN RETURN
|
---|
1553 | selected = VRGet('LB_SELECT', 'Selected')
|
---|
1554 | IF selected == 0 THEN RETURN
|
---|
1555 |
|
---|
1556 | CALL VRSet 'WN_MAIN', 'StatusText', ''
|
---|
1557 |
|
---|
1558 | which = VRMethod('LB_SELECT', 'GetItemData', selected )
|
---|
1559 | IF which == '' THEN DO
|
---|
1560 | globals.!mode = 2 /* Mode 2: user-selected PPD file */
|
---|
1561 | ppd = VRFileDialog( VRWindow(), NLSGetMessage( 24 ), 'O', '*.ppd') /* 24: Select PPD */
|
---|
1562 | IF ppd == '' THEN RETURN
|
---|
1563 | globals.!prt_ppd = ppd
|
---|
1564 | globals.!prt_dev = ''
|
---|
1565 | globals.!prt_nick = GetNameFromPPD( ppd )
|
---|
1566 | IF globals.!prt_nick == '' THEN DO
|
---|
1567 | CALL VRMessage VRWindow(), NLSGetMessage( 76, ppd ),, /* 76: Could not read printer name from %1. */
|
---|
1568 | NLSGetMessage( 77 ), 'E' /* 77: Invalid PPD */
|
---|
1569 | RETURN
|
---|
1570 | END
|
---|
1571 | END
|
---|
1572 | ELSE DO
|
---|
1573 | man = VRMethod('LB_BRAND', 'GetItemData', brand )
|
---|
1574 | IF man == '' THEN DO
|
---|
1575 | /* TODO display an error? But this shouldn't be possible... */
|
---|
1576 | RETURN
|
---|
1577 | END
|
---|
1578 | ppd = manufacturers.man.!printers.which.!driver
|
---|
1579 | globals.!mode = 1 /* Mode 1: CUPS-included model */
|
---|
1580 |
|
---|
1581 | /* We're dealing with a device which lpadmin reported as supported
|
---|
1582 | * by the current CUPS installation. In this mode, we will set
|
---|
1583 | * both !prt_ppd and !prt_dev if a path to a PPD file was returned, or
|
---|
1584 | * only !prt_dev if it was reported as a URI (e.g. drv:///whatever) to
|
---|
1585 | * a dynamic PPD.
|
---|
1586 | */
|
---|
1587 | IF POS('://', ppd ) > 0 THEN DO /* lpadmin returned URI for dynamic PPD */
|
---|
1588 | globals.!prt_ppd = ''
|
---|
1589 | globals.!prt_dev = ppd
|
---|
1590 | sel_brand = VRGet('LB_BRAND', 'SelectedString')
|
---|
1591 | sel_name = sel_brand VRMethod('LB_SELECT', 'GetString', selected )
|
---|
1592 | PARSE VAR sel_name _nick ' - CUPS' .
|
---|
1593 | IF _nick == '' THEN
|
---|
1594 | globals.!prt_nick = STRIP( sel_name )
|
---|
1595 | ELSE
|
---|
1596 | globals.!prt_nick = STRIP( _nick )
|
---|
1597 | END
|
---|
1598 | ELSE DO /* lpadmin returned path to an actual PPD */
|
---|
1599 | globals.!prt_dev = ppd /* <-- or is relative_ppd needed for this? */
|
---|
1600 | IF LEFT( ppd, 10 ) == 'lsb/local/' THEN DO
|
---|
1601 | path_to_ppd = globals.!cupsroot'/usr/local/share'
|
---|
1602 | relative_ppd = SUBSTR( ppd, 11 )
|
---|
1603 | END
|
---|
1604 | ELSE IF LEFT( ppd, 8 ) == 'lsb/usr/' THEN DO
|
---|
1605 | path_to_ppd = globals.!cupsroot'/usr/share'
|
---|
1606 | relative_ppd = SUBSTR( ppd, 9 )
|
---|
1607 | END
|
---|
1608 | ELSE DO
|
---|
1609 | path_to_ppd = globals.!cupsdir'/share/cups'
|
---|
1610 | relative_ppd = ppd
|
---|
1611 | END
|
---|
1612 | globals.!prt_ppd = TRANSLATE( path_to_ppd'/ppd/' || relative_ppd, '\', '/')
|
---|
1613 | /* TODO check for '/@unixroot' and replace with globals.!cupsroot if present */
|
---|
1614 | globals.!prt_nick = GetNameFromPPD( globals.!prt_ppd )
|
---|
1615 | IF globals.!prt_nick = '' THEN DO
|
---|
1616 | globals.!prt_ppd = TRANSLATE( path_to_ppd'/model/' || relative_ppd, '\', '/')
|
---|
1617 | globals.!prt_nick = GetNameFromPPD( globals.!prt_ppd )
|
---|
1618 | END
|
---|
1619 | IF globals.!prt_nick = '' THEN DO
|
---|
1620 | CALL VRMessage VRWindow(), NLSGetMessage( 76, globals.!prt_ppd ),, /* 76: Could not read printer name from %1. */
|
---|
1621 | NLSGetMessage( 77 ), 'E' /* 77: Invalid PPD */
|
---|
1622 | RETURN
|
---|
1623 | END
|
---|
1624 | END
|
---|
1625 | END
|
---|
1626 | globals.!remotecups = ''
|
---|
1627 |
|
---|
1628 | CALL InitMessageLog
|
---|
1629 | IF globals.!mode == 2 THEN
|
---|
1630 | CALL LINEOUT globals.!log1, 'Starting printer install with user-provided PPD:'
|
---|
1631 | ELSE
|
---|
1632 | CALL LINEOUT globals.!log1, 'Starting printer install for built-in model:' ppd
|
---|
1633 | IF globals.!prt_ppd <> '' THEN
|
---|
1634 | CALL LINEOUT globals.!log1, ' - PPD file: ' globals.!prt_ppd
|
---|
1635 | ELSE
|
---|
1636 | CALL LINEOUT globals.!log1, ' - Device name:' globals.!prt_dev
|
---|
1637 | CALL LINEOUT globals.!log1, ' - Model name: ' globals.!prt_nick
|
---|
1638 | CALL LINEOUT globals.!log1, ''
|
---|
1639 |
|
---|
1640 | CALL SetPage2
|
---|
1641 | END
|
---|
1642 |
|
---|
1643 | WHEN globals.!page == 2 THEN DO
|
---|
1644 | selected = VRGet('LB_SELECT', 'Selected')
|
---|
1645 | IF selected == 0 THEN RETURN
|
---|
1646 | port = VRMethod('LB_SELECT', 'GetItemData', selected )
|
---|
1647 |
|
---|
1648 | IF port == '' THEN DO
|
---|
1649 | /* Network printer selected; prompt for the connection details
|
---|
1650 | */
|
---|
1651 | CALL VRLoadSecondary 'SW_NETWORK', 'W'
|
---|
1652 | END
|
---|
1653 |
|
---|
1654 | IF port == '' & globals.!remotecups == '' THEN RETURN
|
---|
1655 | globals.!prt_port = port
|
---|
1656 |
|
---|
1657 | CALL SetPage3
|
---|
1658 | END
|
---|
1659 |
|
---|
1660 | WHEN globals.!page == 3 THEN DO
|
---|
1661 | globals.!prt_name = STRIP( VRGet('EF_NAME', 'Value'))
|
---|
1662 | globals.!prt_loc = STRIP( VRGet('EF_LOCATION', 'Value'))
|
---|
1663 | globals.!prt_info = STRIP( VRGet('EF_DESC', 'Value'))
|
---|
1664 | IF ((( globals.!prt_name == '') |,
|
---|
1665 | ( globals.!prt_loc == '')) & ( globals.!remotecups == '')) |,
|
---|
1666 | ( globals.!prt_info == '') THEN
|
---|
1667 | DO
|
---|
1668 | IF ( globals.!remotecups <> '') THEN
|
---|
1669 | _errmsg = NLSGetMessage( 42 ) /* 42: You must enter a description. */
|
---|
1670 | ELSE
|
---|
1671 | _errmsg = NLSGetMessage( 43 ) /* 43: You must enter a name, a location, and a description. */
|
---|
1672 | CALL VRMessage VRWindow(), _errmsg, NLSGetMessage( 75 ), 'E' /* 75: Missing Value(s) */
|
---|
1673 | RETURN
|
---|
1674 | END
|
---|
1675 | IF ( globals.!remotecups == '' &,
|
---|
1676 | ( POS( LEFT( globals.!prt_name, 1 ),,
|
---|
1677 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') == 0 ) |,
|
---|
1678 | ( VERIFY( globals.!prt_name, '/# ' || '09'x, 'MATCH') <> 0 )) THEN
|
---|
1679 | DO
|
---|
1680 | CALL VRMessage VRWindow(), NLSGetMessage( 44 ),, /* 44: The printer name must start with ... or tab characters. */
|
---|
1681 | NLSGetMessage( 45 ), 'E' /* 45: Invalid Name */
|
---|
1682 | RETURN
|
---|
1683 | END
|
---|
1684 |
|
---|
1685 | /* TODO support other drivers
|
---|
1686 | */
|
---|
1687 | IF WORD( globals.!prt_nick, 1 ) == 'Apollo' |,
|
---|
1688 | WORD( globals.!prt_nick, 1 ) == 'HP' |,
|
---|
1689 | WORD( globals.!prt_nick, 1 ) == 'Hewlett-Packard' THEN
|
---|
1690 | globals.!os2driver = 'ECUPS-HP'
|
---|
1691 | ELSE IF TRANSLATE( WORD( globals.!prt_nick, 1 )) == 'EPSON' THEN
|
---|
1692 | globals.!os2driver = 'EPSONINK'
|
---|
1693 | ELSE
|
---|
1694 | globals.!os2driver = 'ECUPS'
|
---|
1695 |
|
---|
1696 | CALL ConfirmAndCreate
|
---|
1697 | END
|
---|
1698 |
|
---|
1699 | WHEN globals.!page == 4 THEN DO
|
---|
1700 | CALL NLSSetText 'PB_NEXT', 'Caption', 5 /* 5: Next > */
|
---|
1701 | CALL VRSet 'EF_NAME', 'Value', ''
|
---|
1702 | CALL VRSet 'EF_LOCATION', 'Value', ''
|
---|
1703 | CALL VRSet 'EF_DESC', 'Value', ''
|
---|
1704 |
|
---|
1705 | globals.!prt_ppd = ''
|
---|
1706 | CALL SetPage1
|
---|
1707 | END
|
---|
1708 |
|
---|
1709 | OTHERWISE NOP
|
---|
1710 | END
|
---|
1711 |
|
---|
1712 | RETURN
|
---|
1713 |
|
---|
1714 | /*:VRX PICT_ICON_Click
|
---|
1715 | */
|
---|
1716 | PICT_ICON_Click: PROCEDURE EXPOSE globals.
|
---|
1717 | CALL VRLoadSecondary 'SW_ABOUT', 'W'
|
---|
1718 | RETURN
|
---|
1719 |
|
---|
1720 | /*:VRX PrintManCheckIn
|
---|
1721 | */
|
---|
1722 | PrintManCheckIn: PROCEDURE
|
---|
1723 | PARSE ARG data
|
---|
1724 |
|
---|
1725 | /* This function attempts to report in to Printer Manager (if it's running)
|
---|
1726 | * by using a named pipe.
|
---|
1727 | */
|
---|
1728 | IF data == '' THEN RETURN 0
|
---|
1729 |
|
---|
1730 | npipe = '\PIPE\PRINTMAN'
|
---|
1731 | RC_PIPE_BUSY = '231'
|
---|
1732 |
|
---|
1733 | PARSE UPPER VALUE STREAM( npipe, 'C', 'OPEN WRITE') WITH state ':' rc .
|
---|
1734 | IF state <> 'READY' THEN DO
|
---|
1735 | IF rc == RC_PIPE_BUSY THEN
|
---|
1736 | rc = SysWaitNamedPipe( npipe, 0 )
|
---|
1737 | IF rc <> 0 THEN RETURN 0
|
---|
1738 | END
|
---|
1739 | CALL CHAROUT npipe, data
|
---|
1740 | CALL STREAM npipe, 'C', 'CLOSE'
|
---|
1741 |
|
---|
1742 | RETURN 0
|
---|
1743 |
|
---|
1744 | /*:VRX PromptForPMName
|
---|
1745 | */
|
---|
1746 | PromptForPMName: PROCEDURE EXPOSE globals. models. best
|
---|
1747 | best = MatchPrinterModel( globals.!os2driver, globals.!prt_nick )
|
---|
1748 |
|
---|
1749 | IF models.0 == 0 THEN DO
|
---|
1750 | /* No similar models were found in the list of supported printers.
|
---|
1751 | * Just use the generic PS driver.
|
---|
1752 | */
|
---|
1753 | CALL VRMessage VRWindow(), NLSGetMessage( 67, globals.!prt_nick, globals.!os2driver ),, /* 67: The printer "%1" does not ... application support. */
|
---|
1754 | NLSGetMessage( 68 ), 'W' /* 68: Printer Name Not Found */
|
---|
1755 | globals.!prt_nick = 'Generic PostScript Printer'
|
---|
1756 | RETURN
|
---|
1757 | END
|
---|
1758 |
|
---|
1759 | CALL VRLoadSecondary 'SW_MODEL', 'W'
|
---|
1760 |
|
---|
1761 | RETURN
|
---|
1762 |
|
---|
1763 | /*:VRX Quit
|
---|
1764 | */
|
---|
1765 | Quit:
|
---|
1766 | window = VRWindow()
|
---|
1767 | call VRSet window, "Shutdown", 1
|
---|
1768 | drop window
|
---|
1769 | return
|
---|
1770 |
|
---|
1771 | /*:VRX SetLanguage
|
---|
1772 | */
|
---|
1773 | SetLanguage: PROCEDURE EXPOSE globals.
|
---|
1774 | PARSE ARG locale
|
---|
1775 |
|
---|
1776 | /*
|
---|
1777 | * This function locates the proper language files, and uses the message
|
---|
1778 | * file to sets all UI text. If the language could not be determined, we
|
---|
1779 | * default to English.
|
---|
1780 | */
|
---|
1781 | execPath = VRGet('Application', 'Program')
|
---|
1782 | execDir = VRParseFileName( execPath, 'DP')
|
---|
1783 |
|
---|
1784 | /*
|
---|
1785 | * First, figure out what language/message file to use.
|
---|
1786 | */
|
---|
1787 | IF locale <> '' THEN
|
---|
1788 | syslanguage = locale
|
---|
1789 | ELSE
|
---|
1790 | syslanguage = VALUE('LANG',,'OS2ENVIRONMENT')
|
---|
1791 |
|
---|
1792 | SELECT
|
---|
1793 | WHEN TRANSLATE( syslanguage ) == 'ZH_TW' THEN nlv = 'tw'
|
---|
1794 | WHEN TRANSLATE( syslanguage ) == 'ZH_CN' THEN nlv = 'cx'
|
---|
1795 | OTHERWISE PARSE VAR syslanguage nlv '_' .
|
---|
1796 | END
|
---|
1797 | nlvfile = globals.!nlsfile || nlv
|
---|
1798 | IF ( STREAM( execDir'\'nlvfile'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', nlvfile'.msg') \= '') THEN DO
|
---|
1799 | globals.!messages = nlvfile'.msg'
|
---|
1800 | helpfile = nlvfile'.hlp'
|
---|
1801 | CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
|
---|
1802 | END
|
---|
1803 | ELSE DO
|
---|
1804 | globals.!messages = globals.!nlsfile || 'en.msg'
|
---|
1805 | helpfile = globals.!nlsfile || 'en.hlp'
|
---|
1806 | CALL VRSet 'WN_MAIN', 'HelpFile', helpfile
|
---|
1807 | END
|
---|
1808 |
|
---|
1809 | /*
|
---|
1810 | * If the message file is missing or unreadable, display an error and then exit.
|
---|
1811 | */
|
---|
1812 | IF NLSGetMessage( 1 ) == '' THEN DO
|
---|
1813 | CALL VRMessage VRWindow(), 'Language file' TRANSLATE( globals.!messages ) 'could not be loaded.', 'Cannot Continue', 'E'
|
---|
1814 | RETURN 0
|
---|
1815 | END
|
---|
1816 |
|
---|
1817 | /*
|
---|
1818 | * Now set the captions for the UI controls on the main window, according
|
---|
1819 | * to the specified language.
|
---|
1820 | */
|
---|
1821 | CALL NLSSetText 'WN_MAIN', 'Caption', 1 /* 1: Create CUPS Printer */
|
---|
1822 | CALL NLSSetText 'PB_NEXT', 'Caption', 5 /* 5: Next > */
|
---|
1823 | CALL NLSSetText 'PB_CANCEL', 'Caption', 3 /* 3: Cancel */
|
---|
1824 | CALL NLSSetText 'PB_HELP', 'Caption', 4 /* 6: Help */
|
---|
1825 |
|
---|
1826 | RETURN 1
|
---|
1827 |
|
---|
1828 | /*:VRX SetPage1
|
---|
1829 | */
|
---|
1830 | SetPage1: PROCEDURE EXPOSE globals. manufacturers.
|
---|
1831 |
|
---|
1832 | CALL VRMethod 'LB_BRAND', 'Clear'
|
---|
1833 |
|
---|
1834 | globals.!page = 1
|
---|
1835 | globals.!prt_port = ''
|
---|
1836 | globals.!remotecups = ''
|
---|
1837 | globals.!prt_name = ''
|
---|
1838 | globals.!prt_loc = ''
|
---|
1839 | globals.!prt_info = ''
|
---|
1840 | globals.!os2driver = ''
|
---|
1841 |
|
---|
1842 | /* If a PPD was passed on the command line, skip to page 2 */
|
---|
1843 | IF globals.!prt_ppd <> '' THEN DO
|
---|
1844 | globals.!prt_dev = ''
|
---|
1845 | globals.!prt_nick = GetNameFromPPD( globals.!prt_ppd )
|
---|
1846 | IF globals.!prt_nick == '' THEN DO
|
---|
1847 | CALL VRMessage VRWindow(), NLSGetMessage( 76, globals.!prt_ppd ),, /* 76: Could not read printer name from %1. */
|
---|
1848 | NLSGetMessage( 77 ), 'E' /* 77: Invalid PPD */
|
---|
1849 | END
|
---|
1850 | ELSE DO
|
---|
1851 | globals.!mode = 2 /* Mode 2: user-selected PPD file */
|
---|
1852 | globals.!remotecups = ''
|
---|
1853 | CALL InitMessageLog
|
---|
1854 | CALL LINEOUT globals.!log1, 'Starting printer install with user-provided PPD:'
|
---|
1855 | CALL LINEOUT globals.!log1, ''
|
---|
1856 | CALL SetPage2
|
---|
1857 | RETURN
|
---|
1858 | END
|
---|
1859 | END
|
---|
1860 |
|
---|
1861 | globals.!prt_ppd = ''
|
---|
1862 | globals.!prt_dev = ''
|
---|
1863 | globals.!prt_nick = ''
|
---|
1864 |
|
---|
1865 | CALL VRSet 'PB_NEXT', 'Enabled', 0
|
---|
1866 | CALL VRSet 'LB_BRAND', 'Visible', 1
|
---|
1867 |
|
---|
1868 | CALL VRSet 'WN_MAIN', 'HelpTag', 200
|
---|
1869 |
|
---|
1870 | /* Resize LB_SELECT if necessary to make room for LB_BRAND */
|
---|
1871 | lb_x = VRGet('LB_BRAND', 'Left') + VRGet('LB_BRAND', 'Width') + 60
|
---|
1872 | lb_w = VRGet('GB_INFO', 'Width') - lb_x + VRGet('GB_INFO', 'Left')
|
---|
1873 | CALL VRSet 'LB_SELECT', 'Left', lb_x
|
---|
1874 | CALL VRSet 'LB_SELECT', 'Width', lb_w
|
---|
1875 |
|
---|
1876 | CALL VRSet 'LB_SELECT', 'Visible', 1
|
---|
1877 | CALL VRSet 'GB_INFO', 'Visible', 0
|
---|
1878 |
|
---|
1879 | CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
|
---|
1880 |
|
---|
1881 | IF manufacturers.0 == 0 THEN DO
|
---|
1882 |
|
---|
1883 | /* Populate the manufacturer list */
|
---|
1884 | IF globals.!cupsdir == '' THEN DO
|
---|
1885 | manufacturers.1.!name = NLSGetMessage( 22 ) /* 22: -- Custom -- */
|
---|
1886 | manufacturers.1.!printers.0 = 1
|
---|
1887 | manufacturers.1.!printers.1.!model = NLSGetMessage( 23 ) /* 23: -- Other printer (requires PPD) -- */
|
---|
1888 | manufacturers.1.!printers.1.!driver = ''
|
---|
1889 | manufacturers.1.!printers.1.!type = ''
|
---|
1890 | manufacturers.1.!printers.1.!remark = NLSGetMessage( 23 ) /* 23: -- Other printer (requires PPD) -- */
|
---|
1891 | manufacturers.1.!printers.1.!driver2 = ''
|
---|
1892 | manufacturers.1.!printers.1.!remark2 = ''
|
---|
1893 | manufacturers.0 = 1
|
---|
1894 | END
|
---|
1895 | ELSE
|
---|
1896 | CALL GetCupsPrinters
|
---|
1897 |
|
---|
1898 | END
|
---|
1899 | CALL NLSSetText 'DT_INFO', 'Caption', 21 /* 21: Select the printer manufacturer and model from the list below. */
|
---|
1900 |
|
---|
1901 | CALL VRSet 'LB_BRAND', 'Painting', 0
|
---|
1902 | DO i = 1 TO manufacturers.0
|
---|
1903 | addman.i = manufacturers.i.!name
|
---|
1904 | addidx.i = i
|
---|
1905 | END
|
---|
1906 | addman.0 = manufacturers.0
|
---|
1907 | addidx.0 = manufacturers.0
|
---|
1908 | CALL VRMethod 'LB_BRAND', 'AddStringList', 'addman.',, 'addidx.'
|
---|
1909 | CALL VRSet 'LB_BRAND', 'Painting', 1
|
---|
1910 |
|
---|
1911 | CALL VRMethod 'LB_BRAND', 'SetFocus'
|
---|
1912 | CALL VRSet 'LB_BRAND', 'Selected', 1
|
---|
1913 | CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
|
---|
1914 |
|
---|
1915 | RETURN
|
---|
1916 |
|
---|
1917 | /*:VRX SetPage2
|
---|
1918 | */
|
---|
1919 | SetPage2: PROCEDURE EXPOSE globals.
|
---|
1920 |
|
---|
1921 | globals.!page = 2
|
---|
1922 | CALL VRSet 'WN_MAIN', 'HelpTag', 300
|
---|
1923 |
|
---|
1924 | CALL VRSet 'LB_BRAND', 'Visible', 0
|
---|
1925 | CALL VRSet 'PB_NEXT', 'Enabled', 0
|
---|
1926 | CALL NLSSetText 'WN_MAIN', 'StatusText', 29, globals.!prt_nick /* 29: Selected printer: %1 */
|
---|
1927 |
|
---|
1928 | /* Resize LB_SELECT to the full width of GB_INFO */
|
---|
1929 | lb_x = VRGet('GB_INFO', 'Left')
|
---|
1930 | lb_w = VRGet('GB_INFO', 'Width')
|
---|
1931 | CALL VRSet 'LB_SELECT', 'Left', lb_x
|
---|
1932 | CALL VRSet 'LB_SELECT', 'Width', lb_w
|
---|
1933 |
|
---|
1934 | CALL VRMethod 'LB_SELECT', 'Clear'
|
---|
1935 |
|
---|
1936 | CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
|
---|
1937 | IF globals.!cupsdir == '' THEN DO
|
---|
1938 | CALL VRMethod 'LB_SELECT', 'AddString', NLSGetMessage( 34 ),, '' /* 34: Network printer (manual configuration) */
|
---|
1939 | CALL VRSet 'LB_SELECT', 'Selected', 1
|
---|
1940 | END
|
---|
1941 | ELSE
|
---|
1942 | CALL GetCupsPorts
|
---|
1943 | CALL VRMethod 'LB_SELECT', 'SetFocus'
|
---|
1944 | CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
|
---|
1945 |
|
---|
1946 | RETURN
|
---|
1947 |
|
---|
1948 | /*:VRX SetPage3
|
---|
1949 | */
|
---|
1950 | SetPage3: PROCEDURE EXPOSE globals.
|
---|
1951 |
|
---|
1952 | globals.!page = 3
|
---|
1953 | CALL VRSet 'WN_MAIN', 'HelpTag', 400
|
---|
1954 |
|
---|
1955 | CALL VRSet 'EF_DESC', 'Value', globals.!prt_nick
|
---|
1956 | CALL NLSSetText DT_NAME, 'Caption', 103 /* 103: Name: */
|
---|
1957 | CALL NLSSetText DT_LOCATION, 'Caption', 105 /* 105: Location: */
|
---|
1958 | CALL NLSSetText DT_DESC, 'Caption', 106 /* 106: Description: */
|
---|
1959 |
|
---|
1960 | CALL VRMethod 'LB_SELECT', 'Clear'
|
---|
1961 |
|
---|
1962 | CALL VRSet 'LB_SELECT', 'Visible', 0
|
---|
1963 | CALL VRSet 'GB_INFO', 'Visible', 1
|
---|
1964 | IF globals.!remotecups == '' THEN DO
|
---|
1965 | CALL NLSSetText 'DT_INFO', 'Caption', 40 /* 40: Choose the printer name, and enter its location and a short description. */
|
---|
1966 | CALL VRSet 'DT_NAME', 'Visible', 1
|
---|
1967 | CALL VRSet 'EF_NAME', 'Visible', 1
|
---|
1968 | CALL VRSet 'DT_LOCATION', 'Visible', 1
|
---|
1969 | CALL VRSet 'EF_LOCATION', 'Visible', 1
|
---|
1970 | END
|
---|
1971 | ELSE
|
---|
1972 | 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. */
|
---|
1973 | CALL VRSet 'DT_DESC', 'Visible', 1
|
---|
1974 | CALL VRSet 'EF_DESC', 'Visible', 1
|
---|
1975 |
|
---|
1976 | CALL VRMethod 'EF_NAME', 'SetFocus'
|
---|
1977 |
|
---|
1978 | RETURN
|
---|
1979 |
|
---|
1980 | /*:VRX SetPage4
|
---|
1981 | */
|
---|
1982 | SetPage4:
|
---|
1983 |
|
---|
1984 | globals.!page = 4
|
---|
1985 | CALL VRSet 'WN_MAIN', 'HelpTag', 100
|
---|
1986 |
|
---|
1987 | CALL VRSet 'LB_SELECT', 'Visible', 0
|
---|
1988 | CALL VRSet 'GB_INFO', 'Visible', 0
|
---|
1989 | CALL VRSet 'WN_MAIN', 'StatusText', ''
|
---|
1990 |
|
---|
1991 | RETURN
|
---|
1992 |
|
---|
1993 | /*:VRX SW_ABOUT_Close
|
---|
1994 | */
|
---|
1995 | SW_ABOUT_Close:
|
---|
1996 | call SW_ABOUT_Fini
|
---|
1997 | return
|
---|
1998 |
|
---|
1999 | /*:VRX SW_ABOUT_Create
|
---|
2000 | */
|
---|
2001 | SW_ABOUT_Create:
|
---|
2002 | call SW_ABOUT_Init
|
---|
2003 | return
|
---|
2004 |
|
---|
2005 | /*:VRX SW_ABOUT_Fini
|
---|
2006 | */
|
---|
2007 | SW_ABOUT_Fini:
|
---|
2008 | window = VRInfo( "Window" )
|
---|
2009 | call VRDestroy window
|
---|
2010 | drop window
|
---|
2011 | return
|
---|
2012 | /*:VRX SW_ABOUT_Init
|
---|
2013 | */
|
---|
2014 | SW_ABOUT_Init:
|
---|
2015 |
|
---|
2016 | CALL NLSSetText 'SW_ABOUT', 'Caption', 10 /* 10: Product Information */
|
---|
2017 | CALL NLSSetText 'DT_ABOUT1', 'Caption', 11 /* 11: eCups Printer Install Utility */
|
---|
2018 | CALL NLSSetText 'DT_ABOUT2', 'Caption', 12, '1.19' /* 12: Version %1 */
|
---|
2019 | CALL NLSSetText 'DT_ABOUT3', 'Caption', 13, '2010-2019' /* 13: (C) %1 Alex Taylor */
|
---|
2020 | CALL NLSSetText 'PB_ABOUT', 'Caption', 2 /* 10: Product Information */
|
---|
2021 |
|
---|
2022 | CALL NLSSetText 'DT_BOOTDRIVE', 'Caption', 14, TRANSLATE( globals.!bootdrv ) /* 14: System boot volume: %1 */
|
---|
2023 | CALL NLSSetText 'DT_CUPSPATH', 'Caption', 15, TRANSLATE( globals.!cupsdir ) /* 15: Local CUPS directory: %1 */
|
---|
2024 | CALL NLSSetText 'DT_REPOSITORY', 'Caption', 16, TRANSLATE( globals.!repository ) /* 16: Local driver repository: %1 */
|
---|
2025 |
|
---|
2026 | window = VRInfo( "Object" )
|
---|
2027 | if( \VRIsChildOf( window, "Notebook" ) ) then do
|
---|
2028 | call VRMethod window, "CenterWindow"
|
---|
2029 | call VRSet window, "Visible", 1
|
---|
2030 | call VRMethod window, "Activate"
|
---|
2031 | end
|
---|
2032 | drop window
|
---|
2033 | return
|
---|
2034 |
|
---|
2035 | /*:VRX SW_CREATE_Close
|
---|
2036 | */
|
---|
2037 | SW_CREATE_Close:
|
---|
2038 | call SW_CREATE_Fini
|
---|
2039 | return
|
---|
2040 |
|
---|
2041 | /*:VRX SW_CREATE_Create
|
---|
2042 | */
|
---|
2043 | SW_CREATE_Create:
|
---|
2044 | call SW_CREATE_Init
|
---|
2045 | return
|
---|
2046 |
|
---|
2047 | /*:VRX SW_CREATE_Fini
|
---|
2048 | */
|
---|
2049 | SW_CREATE_Fini:
|
---|
2050 | window = VRInfo( "Window" )
|
---|
2051 | call VRDestroy window
|
---|
2052 | drop window
|
---|
2053 | return
|
---|
2054 | /*:VRX SW_CREATE_Init
|
---|
2055 | */
|
---|
2056 | SW_CREATE_Init:
|
---|
2057 |
|
---|
2058 | CALL VRSet 'SW_CREATE', 'HelpFile', VRGet('WN_MAIN', 'HelpFile')
|
---|
2059 |
|
---|
2060 | CALL NLSSetText 'SW_CREATE', 'Caption', 115 /* 115: Confirm Create Printer */
|
---|
2061 | CALL NLSSetText 'DT_CRMODEL', 'Caption', 102 /* 102: Model: */
|
---|
2062 | CALL NLSSetText 'DT_CRLOC', 'Caption', 105 /* 105: Location: */
|
---|
2063 | CALL NLSSetText 'DT_CRDESC', 'Caption', 106 /* 106: Description: */
|
---|
2064 |
|
---|
2065 | CALL NLSSetText 'CHK_CREATEPM', 'Caption', 109 /* 109: Create printer object */
|
---|
2066 | CALL NLSSetText 'DT_PRESDRV', 'Caption', 110 /* 110: Presentation driver: */
|
---|
2067 | CALL NLSSetText 'PB_CREATEOK', 'Caption', 111 /* 111: Create */
|
---|
2068 | CALL NLSSetText 'PB_CREATECANCEL', 'Caption', 3 /* 3: Cancel */
|
---|
2069 | CALL NLSSetText 'PB_CREATEHELP', 'Caption', 4 /* 4: ~Help */
|
---|
2070 |
|
---|
2071 | CALL VRSet 'EF_CRMODEL', 'Value', globals.!prt_nick
|
---|
2072 |
|
---|
2073 | IF globals.!remotecups <> '' THEN DO
|
---|
2074 | /* An existing CUPS printer was indicated. This means we're not
|
---|
2075 | * creating a CUPS printer, but only a PM printer object (and port)
|
---|
2076 | * that points to it.
|
---|
2077 | */
|
---|
2078 | CALL NLSSetText 'DT_CREATE', 'Caption', 101 /* 101: Ready to create printer object with the following parameters. */
|
---|
2079 |
|
---|
2080 | PARSE VAR globals.!remotecups cups_host cups_printer .
|
---|
2081 | CALL NLSSetText 'DT_CRNAME', 'Caption', 107 /* 107: CUPS server: */
|
---|
2082 | CALL NLSSetText 'DT_CRURI', 'Caption', 108 /* 108: CUPS queue: */
|
---|
2083 | CALL VRSet 'DT_CRLOC', 'Visible', 0
|
---|
2084 | CALL VRSet 'EF_CRNAME', 'Value', cups_host
|
---|
2085 | CALL VRSet 'EF_CRURI', 'Value', cups_printer
|
---|
2086 | CALL VRSet 'EF_CRLOC', 'Visible', 0
|
---|
2087 | CALL VRSet 'CHK_CREATEPM', 'Visible', 0
|
---|
2088 | END
|
---|
2089 | ELSE DO
|
---|
2090 | CALL NLSSetText 'DT_CREATE', 'Caption', 100 /* 100: Ready to create CUPS printer with the following parameters. */
|
---|
2091 | CALL NLSSetText 'DT_CRNAME', 'Caption', 103 /* 103: Name: */
|
---|
2092 | CALL NLSSetText 'DT_CRURI', 'Caption', 104 /* 104: URI: */
|
---|
2093 | CALL VRSet 'EF_CRNAME', 'Value', globals.!prt_name
|
---|
2094 | CALL VRSet 'EF_CRURI', 'Value', globals.!prt_port
|
---|
2095 | CALL VRSet 'EF_CRLOC', 'Value', globals.!prt_loc
|
---|
2096 | END
|
---|
2097 | CALL VRSet 'EF_CRDESC', 'Value', globals.!prt_info
|
---|
2098 |
|
---|
2099 | IF QueryAvailableDrivers() > 0 THEN DO
|
---|
2100 | def_idx = 1
|
---|
2101 | CALL VRMethod 'DDCB_PRESDRV', 'AddStringList', 'drv_list.'
|
---|
2102 | DO i = 1 TO drv_list.0
|
---|
2103 | IF drv_list.i == globals.!os2driver THEN DO
|
---|
2104 | def_idx = i
|
---|
2105 | LEAVE
|
---|
2106 | END
|
---|
2107 | /* If PSPRINT is present use it as a fallback default */
|
---|
2108 | ELSE IF drv_list.i == 'PSPRINT' THEN def_idx = i
|
---|
2109 | END
|
---|
2110 | CALL VRSet 'DDCB_PRESDRV', 'Selected', def_idx
|
---|
2111 | END
|
---|
2112 | ELSE DO /* 112: No eCups-compatible OS/2 presentation drivers are installed. */
|
---|
2113 | /* 113: Please install the ECUPS or ECUPS-HP printer driver before continuing. */
|
---|
2114 | CALL VRMessage VRWindow(),
|
---|
2115 | NLSGetMessage( 112 ) || '0d0a0d0a'x || NLSGetMessage( 113 ),,
|
---|
2116 | NLSGetMessage( 114 ), 'E' /* 114: Missing PM Driver */
|
---|
2117 | CALL VRSet 'PB_CREATEOK', 'Enabled', 0
|
---|
2118 | /* TODO give an error if no drivers were found */
|
---|
2119 | END
|
---|
2120 |
|
---|
2121 | window = VRInfo( "Object" )
|
---|
2122 | if( \VRIsChildOf( window, "Notebook" ) ) then do
|
---|
2123 | call VRMethod window, "CenterWindow"
|
---|
2124 | call VRSet window, "Visible", 1
|
---|
2125 | call VRMethod window, "Activate"
|
---|
2126 | end
|
---|
2127 | drop window
|
---|
2128 |
|
---|
2129 | RETURN
|
---|
2130 |
|
---|
2131 | /*:VRX SW_MODEL_Close
|
---|
2132 | */
|
---|
2133 | SW_MODEL_Close:
|
---|
2134 | call SW_MODEL_Fini
|
---|
2135 | return
|
---|
2136 |
|
---|
2137 | /*:VRX SW_MODEL_Create
|
---|
2138 | */
|
---|
2139 | SW_MODEL_Create:
|
---|
2140 | call SW_MODEL_Init
|
---|
2141 | return
|
---|
2142 |
|
---|
2143 | /*:VRX SW_MODEL_Fini
|
---|
2144 | */
|
---|
2145 | SW_MODEL_Fini:
|
---|
2146 |
|
---|
2147 | CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
|
---|
2148 |
|
---|
2149 | window = VRInfo( "Window" )
|
---|
2150 | call VRDestroy window
|
---|
2151 | drop window
|
---|
2152 | return
|
---|
2153 | /*:VRX SW_MODEL_Init
|
---|
2154 | */
|
---|
2155 | SW_MODEL_Init:
|
---|
2156 |
|
---|
2157 | CALL NLSSetText 'SW_MODEL', 'Caption', 120 /* 120: Select Printer Model */
|
---|
2158 |
|
---|
2159 | /* We should have a list of suggested printer models whose names at least
|
---|
2160 | * partially match the requested model, sorted in order with the closest
|
---|
2161 | * match at the top.
|
---|
2162 | */
|
---|
2163 | ok = VRMethod( "LB_OS2MODELS", "AddStringList", "models.", )
|
---|
2164 | IF best > 0 THEN
|
---|
2165 | CALL VRSet 'LB_OS2MODELS', 'Selected', best
|
---|
2166 |
|
---|
2167 | CALL NLSSetText 'DT_MODEL1', 'Caption',,
|
---|
2168 | 121, globals.!prt_nick, globals.!os2driver /* 121: The printer "%1" could not ... to applications. */
|
---|
2169 | CALL NLSSetText 'DT_MODEL2', 'Caption', 122 /* 122: You can select one of ... use a generic driver. */
|
---|
2170 |
|
---|
2171 | CALL NLSSetText 'PB_MODELOK', 'Caption', 2 /* 2: OK */
|
---|
2172 | CALL NLSSetText 'PB_MODELCANCEL', 'Caption', 3 /* 3: Cancel */
|
---|
2173 |
|
---|
2174 | CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
|
---|
2175 |
|
---|
2176 | window = VRInfo( "Object" )
|
---|
2177 | if( \VRIsChildOf( window, "Notebook" ) ) then do
|
---|
2178 | call VRMethod window, "CenterWindow"
|
---|
2179 | call VRSet window, "Visible", 1
|
---|
2180 | call VRMethod window, "Activate"
|
---|
2181 | end
|
---|
2182 | drop window
|
---|
2183 |
|
---|
2184 | RETURN
|
---|
2185 |
|
---|
2186 | /*:VRX SW_NETWORK_Close
|
---|
2187 | */
|
---|
2188 | SW_NETWORK_Close:
|
---|
2189 | call SW_NETWORK_Fini
|
---|
2190 | return
|
---|
2191 |
|
---|
2192 | /*:VRX SW_NETWORK_Create
|
---|
2193 | */
|
---|
2194 | SW_NETWORK_Create:
|
---|
2195 | call SW_NETWORK_Init
|
---|
2196 | return
|
---|
2197 |
|
---|
2198 | /*:VRX SW_NETWORK_Fini
|
---|
2199 | */
|
---|
2200 | SW_NETWORK_Fini:
|
---|
2201 |
|
---|
2202 | network_dialog = 0
|
---|
2203 |
|
---|
2204 | window = VRInfo( "Window" )
|
---|
2205 | call VRDestroy window
|
---|
2206 | drop window
|
---|
2207 | return
|
---|
2208 | /*:VRX SW_NETWORK_Init
|
---|
2209 | */
|
---|
2210 | SW_NETWORK_Init:
|
---|
2211 |
|
---|
2212 | CALL VRSet 'SW_NETWORK', 'HelpFile', VRGet('WN_MAIN', 'HelpFile')
|
---|
2213 |
|
---|
2214 | /* Flag to keep track of whether dialog is open */
|
---|
2215 | network_dialog = 1
|
---|
2216 |
|
---|
2217 | CALL NLSSetText 'SW_NETWORK', 'Caption', 80 /* 80: Network Printer */
|
---|
2218 | CALL NLSSetText 'DT_PROTOCOL', 'Caption', 81 /* 81: Network protocol: */
|
---|
2219 | CALL NLSSetText 'DT_PASSWORD', 'Caption', 90 /* 90: Password: */
|
---|
2220 | CALL NLSSetText 'PB_NETOK', 'Caption', 2 /* 2: OK */
|
---|
2221 | CALL NLSSetText 'PB_NETCANCEL', 'Caption', 3 /* 3: Cancel */
|
---|
2222 | CALL NLSSetText 'PB_NETHELP', 'Caption', 4 /* 4: ~Help */
|
---|
2223 |
|
---|
2224 | IF globals.!cupsdir == '' THEN DO
|
---|
2225 | protos.0 = 1
|
---|
2226 | protos.1 = NLSGetMessage( 91 ) /* 91: Existing CUPS printer (remote server) */
|
---|
2227 | pnums.0 = 1
|
---|
2228 | pnums.1 = 5
|
---|
2229 | END
|
---|
2230 | ELSE DO
|
---|
2231 | protos.0 = 5
|
---|
2232 | protos.1 = NLSGetMessage( 92 ) /* 92: Internet Printing Protocol (IPP) */
|
---|
2233 | protos.2 = NLSGetMessage( 93 ) /* 93: AppSocket/JetDirect */
|
---|
2234 | protos.3 = NLSGetMessage( 94 ) /* 94: Line Printer Remote daemon (LPD) */
|
---|
2235 | protos.4 = NLSGetMessage( 95 ) /* 95: Windows/SMB network */
|
---|
2236 | protos.5 = NLSGetMessage( 96 ) /* 96: Existing CUPS printer */
|
---|
2237 | pnums.0 = 5
|
---|
2238 | pnums.1 = 1
|
---|
2239 | pnums.2 = 2
|
---|
2240 | pnums.3 = 3
|
---|
2241 | pnums.4 = 4
|
---|
2242 | pnums.5 = 5
|
---|
2243 | END
|
---|
2244 |
|
---|
2245 | CALL VRMethod 'DDCB_PROTOCOL', 'AddStringList', 'protos.',, 'pnums.'
|
---|
2246 | CALL VRSet 'DDCB_PROTOCOL', 'Selected', 1
|
---|
2247 |
|
---|
2248 | window = VRInfo( "Object" )
|
---|
2249 | if( \VRIsChildOf( window, "Notebook" ) ) then do
|
---|
2250 | call VRMethod window, "CenterWindow"
|
---|
2251 | call VRSet window, "Visible", 1
|
---|
2252 | call VRMethod window, "Activate"
|
---|
2253 | end
|
---|
2254 | drop window
|
---|
2255 | return
|
---|
2256 |
|
---|
2257 | /*:VRX WN_MAIN_Close
|
---|
2258 | */
|
---|
2259 | WN_MAIN_Close:
|
---|
2260 | call Quit
|
---|
2261 | return
|
---|
2262 |
|
---|