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