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