Ignore:
Timestamp:
Oct 8, 2012, 10:43:30 PM (13 years ago)
Author:
Alex Taylor
Message:

Try to fix occasional problems creating local printer object - no longer relying on RINSTPRN to install the printer driver.
Add support for systems without a local CUPS installation (requires providing a PPD).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/shared/PrintUtl.VRS

    r11 r14  
    119119/*:VRX         CopyDriverToSource
    120120*/
    121 /* Copy driver files to the source (repository) directory used for installation.
     121/* Copies a printerpak driver and all its files from one directory to another.
     122 * Usually the target is the source (repository) directory used for
     123 * installation, hence the function name.  However, this routine can be used
     124 * in other contexts as well.
     125 *
     126 *   driver    - The fully-qualified filename of the printerpak driver
     127 *   newdrvdir - The directory where the files will be copied; must exist
    122128 */
    123129CopyDriverToSource: PROCEDURE EXPOSE globals.
     
    228234        END
    229235        CALL LINEOUT listfile
    230     END
     236        CALL LINEOUT globals.!log1, 'Created driver list' listfile 'for' driver'.'
     237    END
     238    ELSE
     239        CALL LINEOUT globals.!log1, 'No drivers found in' driver '(missing .EXPAND extended attribute?)'
    231240
    232241RETURN 1
     
    304313
    305314RETURN queuename
     315
     316
     317/*:VRX         InstallPrintDriver
     318*/
     319/* 'Installs' (that is to say, registers with the spooler) an OS printer
     320 * device driver/model.  Installs the corresponding printerpak driver if
     321 * necessary.
     322 *
     323 *   driver     - The name of the printerpak driver (without path or extension)
     324 *   driverfull - The fully-qualified filename of the printerpak driver
     325 *   model      - The printer make/model name used by the driver
     326 */
     327InstallPrintDriver: PROCEDURE EXPOSE globals.
     328    PARSE ARG driver, driverfull, model
     329
     330    targetdir = globals.!os2dir'\DLL\'driver
     331    IF ( VRFileExists( targetdir'\'driver'.DRV') == 0 ) THEN DO
     332        CALL VRMkDir targetdir
     333        rc = CopyDriverToSource( driverfull, targetdir )
     334    END
     335    IF VRGetIni('PM_DEVICE_DRIVERS', driver, 'USER', 'NoClose') <> driverfull THEN
     336        CALL VRSetIni 'PM_DEVICE_DRIVERS', driver, driverfull||'00'x, 'USER'
     337    CALL VRSetIni 'PM_SPOOLER_DD', driver'.'model, driver'.DRV;;;'||'00'x, 'SYSTEM'
     338RETURN rc
    306339
    307340
     
    338371        CALL SysFileDelete rsp
    339372
    340 /* temporary for testing */
     373    /* This is temporary until we can implement proper options configuration */
    341374    PARSE UPPER VALUE VALUE('LANG',,'OS2ENVIRONMENT') WITH 1 . 4 _ctry 6 .
    342     IF _ctry == 'CA' | _ctry == 'US' THEN
     375    IF ( WORDPOS( _ctry, 'US CA MX BO CO VE PH CL') > 0 ) THEN
    343376        page = 'Letter'
    344377    ELSE
    345378        page = 'A4'
    346     o9n   = 'PORTRAIT'
    347 /* */
     379    o9n = 'PORTRAIT'
     380
     381    CALL LINEOUT rsp, '* Creates both a printer queue and a desktop object for this printer.'
     382    CALL LINEOUT rsp, '*'
     383    CALL LINEOUT rsp, 'ADDQUEUE'
     384    CALL LINEOUT rsp, '    NAME       =' queuename
     385    CALL LINEOUT rsp, '    COMMENT    =' printername
     386    CALL LINEOUT rsp, '    DRIVERNAME =' driver'.'model
     387    CALL LINEOUT rsp, '    PORT       =' portname
     388    CALL LINEOUT rsp, '    DEFINEQUEUEPROPS'
     389    CALL LINEOUT rsp, '        FORMNAME    =' page
     390    CALL LINEOUT rsp, '        ORIENTATION =' o9n
     391    CALL LINEOUT rsp, '    ENDQUEUEPROPS'
     392    CALL LINEOUT rsp, 'ENDQUEUE'
     393    CALL LINEOUT rsp, ''
     394    CALL LINEOUT rsp
     395RETURN 1
     396
     397
     398/*:VRX         RSPInstallDriver
     399*/
     400/* Create/update a RINSTPRN response file to install the specified printer
     401 * driver.  (This doesn't always seem to work so we don't use it except as
     402 * a fallback.)
     403 */
     404RSPInstallDriver: PROCEDURE
     405    PARSE ARG rsp, driver, model
    348406
    349407    CALL LINEOUT rsp, '* Installs the' driver 'PrinterPak driver.'
     
    360418    CALL LINEOUT rsp, 'ENDPRINTDEVICE'
    361419    CALL LINEOUT rsp, ''
    362     CALL LINEOUT rsp, '* Creates both a printer queue and a desktop object for this printer.'
    363     CALL LINEOUT rsp, '*'
    364     CALL LINEOUT rsp, 'ADDQUEUE'
    365     CALL LINEOUT rsp, '    NAME       =' queuename
    366     CALL LINEOUT rsp, '    COMMENT    =' printername
    367     CALL LINEOUT rsp, '    DRIVERNAME =' driver'.'model
    368     CALL LINEOUT rsp, '    PORT       =' portname
    369     CALL LINEOUT rsp, '    DEFINEQUEUEPROPS'
    370     CALL LINEOUT rsp, '        FORMNAME    =' page
    371     CALL LINEOUT rsp, '        ORIENTATION =' o9n
    372     CALL LINEOUT rsp, '    ENDQUEUEPROPS'
    373     CALL LINEOUT rsp, 'ENDQUEUE'
    374420    CALL LINEOUT rsp
    375421RETURN 1
Note: See TracChangeset for help on using the changeset viewer.