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