Ignore:
Timestamp:
Nov 6, 2012, 6:22:25 PM (13 years ago)
Author:
Alex Taylor
Message:

Eliminate need for RINSTPRN. Try to import PPD from \cups\etc\cups\ppd if it doesn't exist in OS/2 driver. Some minor UI-related fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/printer/cupswiz/cupswiz.VRX

    r16 r17  
    202202    queue_name    = GetQueueName( printer_title )
    203203    port_name     = GetNextPortName('CUPS')
    204     use_drv       = globals.!prdrv
    205 
    206     /* Determine the source directories/files to pass to RINSTPRN.EXE.  (Some
    207      * of this logic is repeated from ImportPPD, but we have to do it again
    208      * here because (a) we might not have gone through ImportPPD to get to this
    209      * point, and (b) even if we did, the repository information might have
    210      * changed.)
    211      */
    212     copied_driver = 0
     204
     205    /* Determine the printer driver source directories/files.  Yes, this is
     206     * repeated from ImportPPD, but we have to do it again here because
     207     * (a) we might not have gone through ImportPPD to get to this point, and
     208     * (b) even if we did, the repository information might have changed.
     209     */
    213210    driver_path = GetDriverSource( prnt_drv )
    214 
    215     IF ( pmdx <> '') & ( globals.!prdrv <> '') & ( globals.!prdesc <> '') THEN DO
    216         /* Printer driver is in the local repository, so we can just point
    217          * to that, and use the system PRDESC.LST file.
     211    IF driver_path == '' THEN
     212        /* Driver was not found in the repository.  Check for a previously-
     213         * installed copy under \OS2\DLL.
    218214         */
    219         use_desc = globals.!prdesc
    220         use_src  = globals.!repository
    221     END
    222     ELSE IF driver_path <> '' THEN DO
    223         /* Driver is not in the repository, but was found in another designated
    224          * location.  Point to that location, and create a temporary PRDESC.LST
    225          * file for it.
    226          */
    227         use_src  = VRParseFilePath( driver_path, 'DP')
    228         use_desc = use_src'\PRDESC.LST'
    229         CALL CreateDriverList driver_path, use_desc
    230     END
    231     ELSE DO
    232         /* Driver is not in the repository.  Try to grab the installed files
    233          * from under \OS2\DLL, copy them into a temporary working directory,
    234          * and create a temporary PRDESC.LST file.
    235          */
    236         driver_path = globals.!os2dir'\DLL\'prnt_drv'\'prnt_drv'.DRV'
    237 
    238         use_src  = SysTempFileName( globals.!tmpdir'\PDR_????')
    239         use_desc = use_src'\PRDESC.LST'
    240 
    241         IF VRMkDir( use_src ) == 0 THEN DO
    242             CALL LINEOUT globals.!log1, 'Failed to create working directory' use_src':' VRError()
    243             RETURN 1
    244         END
    245         IF CopyDriverToSource( driver_path, use_src ) == 0 THEN DO
    246             CALL LINEOUT globals.!log1, 'Failed to copy driver' driver_path 'to working directory' use_src'.'
    247             RETURN 1
    248         END
    249         CALL CreateDriverList driver_path, use_desc
    250         copied_driver = 1
     215        driver_path = STREAM( globals.!os2dir'\DLL\'prnt_drv'\'prnt_drv'.DRV', 'C', 'QUERY EXISTS')
     216
     217    IF driver_path == '' THEN DO
     218        /* TODO allow the user to browse for the driver on their system */
     219        CALL VRMessage VRWindow(), 'The printer driver' prnt_drv 'could not  ',
     220                                   'be located.  If you have the driver      ',
     221                                   'files, please copy them to the directory ',
     222                                   globals.!os2dir'\DLL\'prnt_drv' and then  ',
     223                                   'try again.', 'Driver Not Found', 'E'
     224        RETURN 1
    251225    END
    252226
     
    257231        RETURN 1
    258232
    259     rsp_file = globals.!tmpdir'\printer.rsp'
    260     CALL RSPCreatePrinter rsp_file, prnt_drv, printer_model,,
    261                           port_name, queue_name, printer_title
    262 
    263     /* Install the printer driver.  (We do this manually because doing it
    264      * through RINSTPRN seems not to work properly on some systems.)
    265      */
     233    /* New logic to create the printer ourselves (instead of using RINSTPRN).
     234     * There are two necessary steps: make sure the driver is installed, and
     235     * then create the printer object (which causes the underlying device and
     236     * queue to be created automatically as well).
     237     */
     238
    266239    result = InstallPrintDriver( prnt_drv, driver_path, printer_model )
    267     IF result == 0 THEN CALL RSPInstallDriver rsp_file, prnt_drv, printer_model
    268 
    269     /* Now call RINSTPRN to create the printer queue/device and object.
    270      */
    271     result = ExecRINSTPRN( use_desc, use_drv, use_src, rsp_file )
     240    CALL LINEOUT globals.!log1, 'InstallPrintDriver(' prnt_drv',' driver_path',' printer_model ') RC =' result
     241
     242    IF result == 0 THEN
     243        result = CreatePrinterObject( prnt_drv, printer_model,,
     244                                      port_name, queue_name, printer_title )
     245    CALL LINEOUT globals.!log1, 'CreatePrinterObject(' prnt_drv',' printer_model,
     246                                ',' port_name',' queue_name',' printer_title,
     247                                ') RC =' result
     248
    272249    IF result <> 0 THEN
    273250        CALL DeletePort port_name
     
    278255                       'usable until the desktop is restarted.',,
    279256                       'Port Driver Problem', 'W'
    280     END
    281 
    282     IF copied_driver == 1 THEN DO
    283         CALL VRDeleteFile use_src'\*'
    284         CALL VRRmDir use_src
    285257    END
    286258
     
    313285        END
    314286        ELSE IF PrinterExistsInDRV( globals.!os2driver, globals.!prt_nick ) == 0 THEN DO
    315             IF globals.!prt_ppd == '' THEN
     287            cups_ppd = globals.!prt_ppd
     288            IF cups_ppd == '' THEN
     289                cups_ppd = STREAM( globals.!cupsdir'\etc\cups\ppd'globals.!prt_name'.ppd', 'C', 'QUERY EXISTS')
     290            IF cups_ppd == '' THEN
    316291                CALL PromptForPMName
    317292            ELSE DO
    318                 ok = ImportPPD(globals.!os2driver, globals.!prt_ppd )
     293                ok = ImportPPD(globals.!os2driver, cups_ppd )
    319294                IF ok <> 0 THEN DO
    320295                    CALL LINEOUT globals.!log1, 'PPD import failed:' ok
     
    618593    manufacturers.count.!printers.1.!remark2 = ''
    619594    manufacturers.0 = count
     595
     596    CALL VRSet 'DT_INFO', 'Caption', 'Select the printer manufacturer and model from the list below.'
    620597
    621598RETURN
     
    14031380                       'no similar models were found.  The generic PostScript',
    14041381                       'driver will be used for application support.',,
    1405                        'Printer Name Not Found', 'E'
     1382                       'Printer Name Not Found', 'W'
    14061383        globals.!prt_nick = 'Generic PostScript Printer'
    14071384        RETURN
     
    14481425
    14491426    CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
    1450     CALL VRSet 'DT_INFO', 'Caption', 'Select your printer model.'
    14511427
    14521428    /* Populate the manufacturer list */
Note: See TracChangeset for help on using the changeset viewer.