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