Changeset 49 for trunk/gui


Ignore:
Timestamp:
Dec 17, 2014, 1:36:21 PM (11 years ago)
Author:
Alex Taylor
Message:

Updates for v0.50:
Moved much of the PPD-import logic into a shared function.
Automatically reimport previously-imported PPDs when updating to a new version of a known PostScript driver.
Ask if the user wants to update the active copy of a driver when the repository version is updated.
Fixed error in locating cupswiz.exe when the desktop object doesn't exist.
Fixed broken update of PRDESC.LST when upgrading to a new version of a known PostScript driver.

Location:
trunk/gui
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/printer/manager/PRINTOOL.VRP

    r39 r49  
    22VRX: PRINTOOL.VRX
    33VXOFile: VROBJEX
    4 MacroPath: VRM:G:\netlabs\svn\ecups\trunk\gui\printer\manager
    5 EXEPath: G:\netlabs\svn\ecups\trunk\gui\printer\manager\PRINTMAN.EXE
     4MacroPath: VRM:E:\DEVELOPMENT\VXREXX\Projects\PrintTool
     5EXEPath: E:\Development\VXREXX\Projects\PrintTool\PRINTMAN.EXE
    66RunParameters:
    77RunDirectory:
    8 VRXWindow: __VREMainWindow,1,554,4095,6697,8046
    9 VRXWindow: __VRESectionListWindow,1,687,16044,4204,4059
    10 VRXWindow: __VREToolsWindow,1,687,14309,4963,1669
    11 VRXWindow: __VREWindListWindow,1,4902,16044,3505,4059
     8VRXWindow: __VREMainWindow,1,506,4095,6697,8046
     9VRXWindow: __VRESectionListWindow,1,614,16044,4204,4059
     10VRXWindow: __VREToolsWindow,1,638,14309,5472,1659
     11VRXWindow: __VREWindListWindow,1,4854,16044,3505,4059
    1212UserFile: 1
    1313UserWindow: WN_MAIN,1
  • trunk/gui/printer/manager/PRINTOOL.VRX

    r48 r49  
    507507 * possible situations.
    508508 */
    509 ImportPPD: PROCEDURE EXPOSE globals.
     509ImportPPD: PROCEDURE EXPOSE globals. driver_path
    510510    ARG driver, ppdfile
    511511    IF driver == '' THEN driver = 'PSCRIPT'
     
    522522        WHEN status == 1 THEN NOP
    523523
    524         /* An installable (working) copy of the driver could not be located, but
    525          * we found an installed (in use) version whence we can grab the files.
     524        /* An installable (distribution) copy of the driver could not be located,
     525         * but we found an installed (in use) version whence we can grab the files.
    526526         */
    527527        WHEN status == 2 THEN DO
     
    588588     */
    589589
    590     /** TODO should move all below this into a new shared function **/
     590/**** Moved all below this into a shared function
    591591
    592592    CALL LINEOUT globals.!log1, 'Driver source:          ' driver_path
     
    782782    IF ok == 1 THEN
    783783        ok = VRCopyFile( workdir'\OUT\AUXPRINT.PAK', target'\AUXPRINT.PAK')
     784
    784785    IF ok == 1 THEN DO
    785786        /* Copy the updated files to \OS2\DLL\<driver>, replacing any
    786787         * existing copies.  (This prevents problems if the OS/2 driver
    787          * installation doesn't/fails to copy them, which can happen under
    788          * some circumstances.)
     788         * installation fails to copy them, which can happen under some
     789         * circumstances.)
    789790         */
    790791        IF VRFileExists( globals.!os2dir'\DLL\'driver'\'driver'.DRV') THEN DO
     
    814815    CALL VRRmDir( workdir )
    815816
    816 RETURN 0
     817****/
     818
     819    ok = PinWrapper( 1, driver, ppdfile )
     820
     821RETURN ok
    817822
    818823/*:VRX         Init
     
    890895LoadSettings: PROCEDURE EXPOSE globals.
    891896
    892     globals.!version = '0.46'
    893     globals.!copyright = '2013'
     897    globals.!version = '0.50'
     898    globals.!copyright = '2013-2014'
    894899
    895900    me = VRGet('Application', 'Program')
     
    11941199    END
    11951200    ELSE DO
    1196         cupswiz = Stream( globals.!cupsdir'\cups\cupswiz.exe', 'C', 'QUERY EXISTS')
     1201        cupswiz = Stream( globals.!cupsdir'\cupswiz.exe', 'C', 'QUERY EXISTS')
    11971202        _workdir = VRParseFilePath( cupswiz, 'DP')
    11981203        _parms = ''
     
    12031208        IF ppd_file <> '' & VRFileExists( ppd_file ) THEN
    12041209            _parms = _parms ppd_file
     1210        CALL LINEOUT globals.!log1, 'Launching CUPS wizard with: start' cupswiz _parms
    12051211        ADDRESS CMD 'start' cupswiz _parms
    12061212        CALL DIRECTORY od
    12071213        CALL Quit
    12081214    END
     1215    ELSE DO
     1216        CALL LINEOUT globals.!log1, 'Failed to locate CUPS wizard.'
     1217    END
     1218
    12091219
    12101220RETURN
     
    13871397    END
    13881398    driver = VRGet('DDCB_IMPORTDRV', 'Value')
    1389     ok = ImportPPD( driver, new_ppd )
     1399    ok = ImportPPD( driver, new_ppd )           /* Also sets driver_path variable */
    13901400
    13911401    SELECT
     
    14391449    IF message <> '' THEN
    14401450        CALL VRMessage VRWindow(), _message, _mbtitle, _mbicon
     1451
     1452    IF ok == 0 THEN DO
     1453        /* The PPD was imported into the driver install directory. Now we should
     1454         * ask the user if they want to actually install this printer driver so
     1455         * that existing printer objects can use it.
     1456         */
     1457        _new_model = GetNameFromPPD( new_ppd )
     1458        _btns.0 = 2
     1459        _btns.1 = NLSGetMessage( 14 )
     1460        _btns.2 = NLSGetMessage( 15 )
     1461        _create = VRMessage( VRWindow(), NLSGetMessage( 240, _new_model ) || '0d0d0a'x ||,
     1462                             NLSGetMessage( 241 ), NLSGetMessage( 239 ), 'Q', '_btns.', 1, 2 )
     1463        IF _create == 1 THEN DO
     1464            _ipd = InstallPrintDriver( driver, driver_path, _new_model )
     1465            IF _ipd <> 0 THEN
     1466                CALL VRMessage VRWindow(), NLSGetMessage( 168, driver'.'_new_model ), NLSGetMessage( 13 ), 'E'
     1467        END
     1468    END
    14411469
    14421470    CALL SW_IMPORT_Close
     
    15881616
    15891617            ok = CopyPrinterPak( new_drv, drv_target )
     1618
     1619            /* Update any previously-imported PPDs for this driver
     1620             */
     1621            IF ok == 1 THEN DO
     1622/* TODO use drv_target and parse it for pmdx directly */
     1623                driver_path = GetDriverSource( drv_stem )      /* Also sets pmdx */
     1624                IF pmdx == '' THEN
     1625                    driver_repo = 0
     1626                ELSE
     1627                    driver_repo = 1
     1628                pwok = PinWrapper( 0, drv_stem, '')
     1629                IF pwok <> 0 THEN DO
     1630                    CALL CHAROUT globals.!log1, 'Encountered error' pwok 'from PIN wrapper:'
     1631                    SELECT
     1632                        WHEN ok == 3 THEN CALL LINEOUT globals.!log1, 'Invalid path specified'
     1633                        WHEN ok == 4 THEN CALL LINEOUT globals.!log1, 'Failed to copy driver files'
     1634                        WHEN ok == 5 THEN CALL LINEOUT globals.!log1, 'Failed to create directory'
     1635                        WHEN ok == 6 THEN CALL LINEOUT globals.!log1, 'PPD import failed'
     1636                        WHEN ok == 7 THEN CALL LINEOUT globals.!log1, 'Error updating PRDESC.LST'
     1637                        OTHERWISE CALL LINEOUT globals.!log1, 'Unknown error'
     1638                    END
     1639                    ok = 0
     1640                END
     1641            END
     1642
    15901643            IF existing & ok == 1 THEN DO
    1591                 CALL UpdatePrDesc new_drv, drv_target'\'new_drv
     1644                CALL UpdatePrDesc drv_name, drv_target'\'drv_name
    15921645            END
    15931646            IF ok == 0 THEN DO
     
    15971650            ELSE
    15981651                CALL VRMessage VRWindow(), NLSGetMessage( 193 ), NLSGetMessage( 16 ), 'I'
     1652
     1653            new_drv = drv_target'\'drv_name
    15991654        END
    16001655    END
  • trunk/gui/printer/manager/printm_en.txt

    r39 r49  
    251251PTM0237I: You cannot import a PPD file unless you have either CUPS or at least one legacy PostScript driver installed.
    252252PTM0238I: The PPD has been imported.
    253 PTM0239?:
    254 PTM0240?:
    255 PTM0241?:
     253PTM0239I: Install Driver?
     254PTM0240I: The driver "%1" is now available. Do you want to install this driver?
     255PTM0241I: (Saying 'Yes' will allow existing printer objects to use this driver.)
    256256PTM0242?:
    257257PTM0243?:
  • trunk/gui/printer/manager/readme.txt

    r48 r49  
    11PM Printer Manager
    2 Version 0.46
     2Version 0.50
    33
    44  Printer Manager is a new graphical printer management tool designed to
    55  replace several older, separate programs by integrating their functions
    6   in one, centralize utility:
     6  in one, centralized utility:
    77    - INSTPDR.EXE (done)
    88    - ECSPRINT.EXE (done)
     
    1616   - WPTOOLS.DLL (widely available, included with eCS)
    1717   - PR1UTIL.DLL (widely available, included with eCS 2.x)
    18    - VROBJEX.DLL (included here, to be included in eCS 2.2)
     18   - VROBJEX.DLL (available from http://trac.netlabs.org/vxapps,
     19                  included in eCS 2.2)
    1920   - RXPRTUTL.DLL (included here)
    2021
     
    7172--
    7273Alex Taylor
    73 May 2014
     74December 2014
  • trunk/gui/shared/PrManUtl.VRS

    r45 r49  
    275275    copyfile = drv_dir'\AUXPRINT.PAK'
    276276    IF STREAM( copyfile, 'C', 'QUERY EXISTS') <> '' THEN DO
    277         ok = VRCopyFile( copyfile, newdrvdir'\AUXPRINT.PAK'
     277        ok = VRCopyFile( copyfile, newdrvdir'\AUXPRINT.PAK')
    278278        CALL LINEOUT globals.!log1, ' -' copyfile ':' ok
    279279    END
     
    760760
    761761
     762/*:VRX         PinWrapper
     763*/
     764/*  Wrapper for PIN, which performs the following tasks:
     765 *  - Create a temporary working directory & copy the PrinterPak files there.
     766 *  - Pre-process the PPD file to make it ready for import, and saves it in
     767 *    a driver-specific 'saved PPDs' directory for future use.
     768 *  - Uses PIN to import the PPD into our temporary working copy of the driver.
     769 *  - Copy the updated driver back to our installable copy.
     770 *  - If update_all is 1 then also do the following:
     771 *      - If the driver is actually installed, copy the updated driver back
     772 *        over the installed version as well.
     773 *      - If this is a 'shipped' driver (i.e. one listed in PRDRV.LST) then
     774 *        add the newly-defined printer to PRDESC.LST.
     775 */
     776PinWrapper: PROCEDURE EXPOSE globals. driver_path driver_repo
     777    ARG update_all, driver, ppdfile
     778
     779    CALL LINEOUT globals.!log1, 'Driver source:          ' driver_path
     780
     781    workdir = SysTempFileName( globals.!tmpdir'\PPD_????')
     782    ok = VRMkDir( workdir )
     783    IF ok == 1 THEN ok = VrMkDir( workdir'\OUT')
     784    IF ok <> 1 THEN
     785        RETURN 5                        /** RC=5 failed to create directory */
     786
     787    CALL LINEOUT globals.!log1, 'Temporary directory:    ' workdir
     788
     789    SELECT
     790        WHEN driver == 'ECUPS'    THEN ppddir = globals.!repository'\PPD_E'
     791        WHEN driver == 'ECUPS-HP' THEN ppddir = globals.!repository'\PPD_EHP'
     792        WHEN driver == 'PSPRINT'  THEN ppddir = globals.!repository'\PPD_PS'
     793        WHEN driver == 'PSPRINT2' THEN ppddir = globals.!repository'\PPD_PS2'
     794        WHEN driver == 'PSCRIPT2' THEN ppddir = globals.!repository'\PPD2'
     795        WHEN driver == 'GUTENPRT' THEN ppddir = globals.!repository'\PPD_GP'
     796        OTHERWISE                      ppddir = globals.!repository'\PPD'
     797    END
     798
     799    /* Make sure ppddir (for keeping PPD files) exists */
     800    CALL SysFileTree ppddir, 'dirs.', 'DO'
     801    IF dirs.0 == 0 THEN DO
     802        ok = VRMkDir( ppddir )
     803        IF ok <> 1 THEN
     804            RETURN 5                    /** RC=5 failed to create directory */
     805    END
     806
     807    CALL LINEOUT globals.!log1, 'Directory for PPD files:' ppddir
     808
     809    /***
     810     *** Now do the actual work.
     811     ***/
     812
     813    /* Copy the needed driver files to our working directories.
     814     */
     815    drvr_dir = VRParseFileName( driver_path, 'DP')
     816    drv_out  = workdir'\OUT\'driver'.DRV'
     817    pin_exe  = workdir'\PIN.EXE'
     818    ppd_exe  = workdir'\PPDENC.EXE'
     819    ok = VRCopyFile( driver_path, drv_out )
     820    IF ok == 1 THEN ok = VRCopyFile( drvr_dir'\PIN.EXE', pin_exe )
     821    IF ok == 1 THEN ok = VRCopyFile( drvr_dir'\PPDENC.EXE', ppd_exe )
     822    IF ok == 0 THEN DO
     823        RETURN 4                        /*** RC=4  Failed to copy driver files ***/
     824    END
     825
     826    /* Set up the output redirection.
     827     */
     828    nq = RXQUEUE('CREATE')
     829    oq = RXQUEUE('SET', nq )
     830
     831    /* If we are importing a new PPD file, prep it first.
     832     * (If ppdfile is undefined, it means we are reimporting a directory of
     833     * previously-imported PPDs, and we can assume they are already prepped.)
     834     */
     835    IF ppdfile <> '' THEN DO
     836
     837        /* If the PPD file is compressed, uncompress it.
     838         */
     839        IF VRParseFilePath( ppdfile, 'E') == 'GZ' THEN DO
     840            decppd = workdir'\' || VRParseFilePath( ppdfile, 'N')
     841            CALL LINEOUT globals.!log1, 'Decompressing' ppdfile 'to' decppd
     842            ADDRESS CMD '@'globals.!programs.!gzip '-c -d' ppdfile '| RXQUEUE' nq
     843            DO QUEUED()
     844                PARSE PULL line
     845                CALL LINEOUT decppd, line
     846            END
     847            CALL LINEOUT decppd
     848            ppdfile = decppd
     849        END
     850
     851        IF VRFileExists( ppdfile ) == 0 THEN DO
     852            CALL LINEOUT globals.!log1, 'PPD file' ppdfile 'could not be found.'
     853            RETURN 6                        /** RC=6  PPD import failed **/
     854        END
     855
     856        ppd_use = ppddir'\' || VRParseFileName( ppdfile, 'NE')
     857
     858        /* Now we have to clean up and validate the PPD file so PIN can use it.
     859         * First, PPDENC converts the codepage if necessary, and copies the results
     860         * to our working directory.
     861         */
     862        CALL LINEOUT globals.!log1, 'Converting PPD with:' ppd_exe ppdfile ppd_use
     863        ADDRESS CMD '@'ppd_exe ppdfile ppd_use '2>NUL | RXQUEUE' nq
     864        DO QUEUED()
     865            PULL output
     866            CALL LINEOUT globals.!log2, output
     867        END
     868        CALL LINEOUT globals.!log2, ''
     869        CALL LINEOUT globals.!log2
     870
     871        IF VRFileExists( ppd_use ) == 0 THEN DO
     872            CALL LINEOUT globals.!log1, 'Hmm,' ppd_use 'was not created.  Copying manually.'
     873            CALL VRCopyFile ppdfile, ppd_use
     874        END
     875
     876        /* Next we strip out some problematic PPD statements which are often
     877         * encountered in (for example) CUPS-based PPD files.
     878         */
     879        CALL CleanPPD ppd_use, globals.!log1
     880
     881    END
     882
     883    /* Preparation complete.  Now do the import.
     884     */
     885    count = 0
     886    ADDRESS CMD '@'pin_exe 'ppd' ppddir drv_out '2>NUL | RXQUEUE' nq
     887    DO QUEUED()
     888        PARSE PULL output
     889        CALL LINEOUT globals.!log2, output
     890        PARSE VAR output . 'OK (' nickname
     891        IF nickname <> '' THEN DO
     892            count = count + 1
     893            newprinters.count = STRIP( nickname, 'T', ')')
     894        END
     895    END
     896    newprinters.0 = count
     897    CALL LINEOUT globals.!log2, ''
     898    CALL LINEOUT globals.!log2
     899
     900    /* End the output redirection.
     901     */
     902    CALL RXQUEUE 'SET',    oq
     903    CALL RXQUEUE 'DELETE', nq
     904
     905    IF newprinters.0 == 0 THEN DO
     906        RETURN 6                        /** RC=6  PPD import failed **/
     907    END
     908
     909    /***
     910     *** Post-import processing.
     911     ***/
     912
     913    IF ( driver_repo == 1 ) & ( update_all <> 0 ) THEN DO
     914        /* If we're working out of the repository, we need to update the
     915         * driver table in PRDESC.LST to add the new driver(s).
     916         */
     917
     918        CALL LINEOUT globals.!log1, 'Updating' globals.!prdesc 'with new entries from' drv_out
     919
     920/* -- This causes a SYS3175 in the .DRV for some reason...
     921        ok = UpdatePrDesc( driver'.DRV', drv_out )
     922        IF ok <> 0 THEN
     923            CALL LINEOUT globals.!log1, 'Failed to update' globals.!prdesc '(are EAs on' drv_out ' valid?)'
     924*/
     925
     926        count = 0
     927
     928        /* First, copy all lines that don't refer to the driver just updated */
     929        CALL LINEIN globals.!prdesc, 1, 0
     930        DO WHILE LINES( globals.!prdesc )
     931            _next = LINEIN( globals.!prdesc )
     932            PARSE UPPER VAR _next . ':' _rest
     933            _tail = SUBSTR( _rest, LASTPOS('(', _rest ))
     934            PARSE VAR _tail '('_prdrv')' .
     935            IF _prdrv == driver'.DRV' THEN ITERATE
     936            count = count + 1
     937            defs.count = _next
     938        END
     939        CALL STREAM globals.!prdesc, 'C', 'CLOSE'
     940
     941        /* Next, create a new list for the updated driver and merge that in */
     942        newlist = workdir'\'driver'.LST'
     943        CALL CreateDriverList drv_out, newlist
     944        DO WHILE LINES( newlist )
     945            _line = LINEIN( newlist )
     946            count = count + 1
     947            defs.count = _line
     948        END
     949        CALL STREAM newlist, 'C', 'CLOSE'
     950        defs.0 = count
     951
     952        /* Now sort the list and recreate PRDESC.LST */
     953        CALL SysStemSort 'defs.',, 'I'
     954        prdesc_tmp = workdir'\PRDESC.LST'
     955        IF STREAM( prdesc_tmp, 'C', 'QUERY EXISTS') <> '' THEN
     956            CALL VRDeleteFile prdesc_tmp
     957        DO i = 1 TO defs.0
     958            CALL LINEOUT prdesc_tmp, defs.i
     959        END
     960        CALL LINEOUT prdesc_tmp
     961        ok = VRCopyFile( prdesc_tmp, globals.!prdesc )
     962        IF ok == 0 THEN DO
     963            RETURN 7                    /** RC=7  Error updating PRDESC.LST **/
     964        END
     965        CALL VRDeleteFile prdesc_tmp
     966
     967    END
     968
     969    /* Finally, copy the updated driver files.
     970     */
     971    target = VRParseFilePath( driver_path, 'DP')
     972    CALL LINEOUT globals.!log1, 'Copying files from' workdir'\OUT to' target
     973    CALL PRReplaceModule target'\'driver'.DRV', '', ''
     974    ok = VRCopyFile( workdir'\OUT\'driver'.DRV', target'\'driver'.DRV')
     975    IF ok == 1 THEN
     976        ok = VRCopyFile( workdir'\OUT\AUXPRINT.PAK', target'\AUXPRINT.PAK')
     977
     978    IF ( ok == 1 ) & ( update_all <> 0 ) THEN DO
     979        /* Copy the updated files to \OS2\DLL\<driver>, replacing any
     980         * existing copies.  (This prevents problems if the OS/2 driver
     981         * installation fails to copy them, which can happen under some
     982         * circumstances.)
     983         */
     984        IF VRFileExists( globals.!os2dir'\DLL\'driver'\'driver'.DRV') THEN DO
     985            CALL VRCopyFile workdir'\OUT\AUXPRINT.PAK',,
     986                            globals.!os2dir'\DLL\'driver'\AUXPRINT.PAK'
     987            CALL PRReplaceModule globals.!os2dir'\DLL\'driver'\'driver'.DRV', '', ''
     988            CALL VRCopyFile workdir'\OUT\'driver'.DRV', globals.!os2dir'\DLL\'driver'\'driver'.DRV'
     989        END
     990    END
     991    IF ok == 0 THEN DO
     992        CALL LINEOUT globals.!log1, VRError()
     993        RETURN 4                        /*** RC=4  Failed to copy driver files ***/
     994    END
     995
     996    CALL LINEOUT globals.!log1, newprinters.0 'printers imported successfully.'
     997    DO i = 1 TO newprinters.0
     998        CALL LINEOUT globals.!log1, ' ->' newprinters.i
     999    END
     1000    CALL LINEOUT globals.!log1, ''
     1001    CALL LINEOUT globals.!log1
     1002
     1003    /* Clean up our work directories.
     1004     */
     1005    CALL VRDeleteFile workdir'\OUT\*'
     1006    CALL VRDeleteFile workdir'\*'
     1007    CALL VRRmDir( workdir'\OUT')
     1008    CALL VRRmDir( workdir )
     1009
     1010RETURN 0
     1011
     1012
    7621013/*:VRX         UpdatePrDesc
    7631014*/
     
    7811032    CALL STREAM globals.!prdesc, 'C', 'CLOSE'
    7821033
    783     DO i = 1 TO devs.0
     1034    DO i = 1 TO newdevs.0
    7841035        _count = _count + 1
    7851036        prdefs._count = newdevs.i':' newdevs.i '('driver')'
Note: See TracChangeset for help on using the changeset viewer.