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).

Location:
trunk/gui/printer/cupswiz
Files:
4 edited

Legend:

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

    r12 r14  
    101101*/
    102102return
     103/*:VRX         CHK_CREATEPM_Click
     104*/
     105CHK_CREATEPM_Click: PROCEDURE
     106    set = VRGet( "CHK_CREATEPM", "Set" )
     107    CALL VRSet 'DT_PRESDRV',   'Enabled', set
     108    CALL VRSet 'DDCB_PRESDRV', 'Enabled', set
     109RETURN
     110
    103111/*:VRX         ConfirmAndCreate
    104112*/
     
    152160    IF globals.!prt_dev <> '' THEN
    153161        cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m' globals.!prt_dev
    154     ELSE
    155         cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m "'globals.!prt_ppd'"'
    156 
     162    ELSE IF globals.!mode == 2 THEN
     163        cups_cmd = cups_cmd '-v "'globals.!prt_port'" -P "'globals.!prt_ppd'"'
     164    ELSE DO
     165        PARSE VAR globals.!prt_ppd (globals.!cupsdir)'\share\cups\model\' model
     166        IF model == '' THEN model = globals.!prt_ppd
     167        cups_cmd = cups_cmd '-v "'globals.!prt_port'" -m "'model'"'
     168    END
    157169
    158170    CALL LINEOUT globals.!log1, 'Creating CUPS printer using:'
     
    215227        use_src  = VRParseFilePath( driver_path, 'DP')
    216228        use_desc = use_src'\PRDESC.LST'
    217         CALL CreateDriverList driver_path'\'prnt_drv'.DRV', use_desc
     229        CALL CreateDriverList driver_path, use_desc
    218230    END
    219231    ELSE DO
     
    248260    CALL RSPCreatePrinter rsp_file, prnt_drv, printer_model,,
    249261                          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     */
     266    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     */
    250271    result = ExecRINSTPRN( use_desc, use_drv, use_src, rsp_file )
    251 
    252272    IF result <> 0 THEN
    253273        CALL DeletePort port_name
     
    256276                       'The installed version of CUPS.PDR appears to be out of ',
    257277                       'date.  As a result, the desktop printer will not be ',
    258                        'useable until the desktop is restarted.',,
     278                       'usable until the desktop is restarted.',,
    259279                       'Port Driver Problem', 'W'
    260280    END
     
    315335DDCB_PROTOCOL_Change: PROCEDURE
    316336
    317     which = VRGet('DDCB_PROTOCOL', 'Selected')
     337    idx = VRGet('DDCB_PROTOCOL', 'Selected')
     338    which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
    318339    SELECT
    319340        WHEN which == 1 THEN DO     /* IPP */
     
    321342            show_user  = 1
    322343            show_pass  = 1
     344            CALL VRSet 'DT_SERVER',  'Caption', 'Printer or server address:'
     345            CALL VRSet 'DT_QUEUE',   'Caption', 'Printer queue name:'
     346            CALL VRSet 'DT_USERID',  'Caption', 'User ID:'
    323347        END
    324348        WHEN which == 2 THEN DO     /* SOCKET */
     
    326350            show_user  = 0
    327351            show_pass  = 0
     352            CALL VRSet 'DT_SERVER',  'Caption', 'Printer or server address:'
    328353        END
    329354        WHEN which == 3 THEN DO     /* LPD */
     
    331356            show_user  = 1
    332357            show_pass  = 0
    333             /* CALL VRSet 'DT_USERID', 'Caption', 'User ID (if required):' */
     358            CALL VRSet 'DT_SERVER',  'Caption', 'Printer or server address:'
     359            CALL VRSet 'DT_QUEUE',   'Caption', 'Printer queue name:'
     360            CALL VRSet 'DT_USERID',  'Caption', 'User ID (if required):'
    334361        END
    335362        WHEN which == 4 THEN DO     /* SMB */
     
    337364            show_user  = 1
    338365            show_pass  = 1
    339             /* CALL VRSet 'DT_QUEUE', 'Caption', 'Shared printer name:' */
     366            CALL VRSet 'DT_SERVER',  'Caption', 'Print server name:'
     367            CALL VRSet 'DT_QUEUE',  'Caption', 'Shared printer name:'
     368            CALL VRSet 'DT_USERID', 'Caption', 'User ID:'
    340369        END
    341370        OTHERWISE DO                /* CUPS */
     
    343372            show_user  = 0
    344373            show_pass  = 0
     374            CALL VRSet 'DT_SERVER',  'Caption', 'CUPS server name:'
     375            CALL VRSet 'DT_QUEUE',  'Caption',  'CUPS printer name:'
    345376        END
    346377    END
     
    390421
    391422    CALL VRSet 'DT_INFO', 'Caption', 'Looking for connected printers.  Please wait...'
    392     CALL VRMethod 'LB_SELECT', 'Clear'
    393423
    394424    lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe -v |rxqueue'
     425    snmp_cmd   = globals.!cupsdir'\lib\cups\backend\snmp.exe |rxqueue'
    395426
    396427    _od = DIRECTORY()
     
    398429    listqueue = RXQUEUE('CREATE')
    399430    defqueue  = RXQUEUE('SET', listqueue )
     431
     432    /* Use the SNMP backend to find network printers.  We do this in addition
     433     * to lpinfo because SNMP may provide the actual printer name.  We'll
     434     * merge this with the output of lpinfo in the next step.
     435     */
     436    ADDRESS CMD '@' snmp_cmd listqueue
     437    DO QUEUED()
     438        PARSE PULL line
     439        PARSE VAR line _type _uri '"'_identifier'"' .
     440        _uri = STRIP( _uri )
     441        _type = STRIP( _type )
     442        IF _uri == '' THEN ITERATE
     443        IF _type <> 'network' THEN ITERATE
     444        netnames._uri = _identifier
     445    END
    400446
    401447    ADDRESS CMD '@' lpinfo_cmd listqueue
     
    410456            ELSE _protocol = TRANSLATE( _protocol )
    411457            i = i + 1
    412             IF _queue == '' THEN _desc = '('_protocol')'
    413             ELSE _desc = _queue '('_protocol')'
    414             devices.i = 'Detected network printer' _desc 'at' _host
     458            IF _queue <> '' THEN _queue = '(queue '_queue')'
     459            IF SYMBOL('netnames._name') == 'VAR' THEN
     460                devices.i = 'Detected network printer ('_protocol') "'netnames._name'" at' _host _queue
     461            ELSE
     462                devices.i = 'Detected network printer ('_protocol') at' _host _queue
    415463        END
    416464        ELSE IF _type <> 'direct' THEN ITERATE
    417465        ELSE DO
     466            IF _name == 'hp' THEN ITERATE
    418467            i = i + 1
    419468            devices.i = 'Local printer:' _name
     
    443492    CALL VRSet 'DT_INFO', 'Caption', 'Getting list of supported printers.  Please wait...'
    444493
    445     lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe --exclude-schemes drv -m |rxqueue'
     494    lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe --exclude-schemes drv -m 2>&1 |rxqueue'
    446495
    447496    _od = DIRECTORY()
     
    504553    DO i = 1 TO models.0
    505554        PARSE VAR models.i _brand _model ' - CUPS+' _type
     555        IF _type == '' THEN DO
     556            PARSE VAR models.i _brand _model ',' _type
     557            IF WORD( _type, 1 ) == 'hpcups' THEN
     558                _type = 'HPLIP' /* SUBWORD( _type, 2 ) */
     559            ELSE IF ( _type == '') & ( LEFT( ppds.i, 3 ) == 'hp/') THEN
     560                _type = 'HPLIP'
     561        END
    506562        man = WORDPOS( _brand, makers )
    507563        IF man == 0 THEN ITERATE
     
    518574             * the regular driver by preference.
    519575             */
    520             IF ( manufacturers.man.!printers.count.!model == _model ) & ,
    521                ( manufacturers.man.!printers.count.!type  == _version ) THEN
    522             DO
    523                 IF ( WORD( _version, 1 ) == 'Gutenprint') & ( _flag == 'Simplified') THEN DO
    524                     manufacturers.man.!printers.count.!driver2 = manufacturers.man.!printers.count.!driver
    525                     manufacturers.man.!printers.count.!remark2 = manufacturers.man.!printers.count.!remark
    526                     manufacturers.man.!printers.count.!driver  = ppds.i
    527                     manufacturers.man.!printers.count.!remark  = 'Simplified'
     576            IF ( TRANSLATE( manufacturers.man.!printers.count.!model ) == TRANSLATE( _model )) THEN DO
     577                IF ( manufacturers.man.!printers.count.!type == _version ) THEN DO
     578                    IF ( WORD( _version, 1 ) == 'Gutenprint') & ( _flag == 'Simplified') THEN DO
     579                        manufacturers.man.!printers.count.!driver2 = manufacturers.man.!printers.count.!driver
     580                        manufacturers.man.!printers.count.!remark2 = manufacturers.man.!printers.count.!remark
     581                        manufacturers.man.!printers.count.!driver  = ppds.i
     582                        manufacturers.man.!printers.count.!remark  = 'Simplified'
     583                    END
     584                    ELSE DO
     585                        manufacturers.man.!printers.count.!driver2 = ppds.i
     586                        IF _flag == 'Simplified' THEN
     587                            manufacturers.man.!printers.count.!remark2 = 'Simplified'
     588                        ELSE
     589                            manufacturers.man.!printers.count.!remark2 = ''
     590                    END
     591                    ITERATE
    528592                END
    529                 ELSE DO
    530                     manufacturers.man.!printers.count.!driver2 = ppds.i
    531                     IF _flag == 'Simplified' THEN
    532                         manufacturers.man.!printers.count.!remark2 = 'Simplified'
    533                     ELSE
    534                         manufacturers.man.!printers.count.!remark2 = ''
    535                 END
    536                 ITERATE
    537593            END
    538594        END
     
    574630*/
    575631ImportPPD: PROCEDURE EXPOSE globals.
    576     /* Import a new PPD file into a PostScript PrinterPak driver.
     632    /* Import a new PPD file into a PostScript driver.
    577633     */
    578634    ARG driver, ppdfile
     
    777833    END
    778834
    779     IF mustcopy == 0 THEN DO
     835    /*IF mustcopy == 0 THEN DO*/
     836    IF pmdx <> '' THEN DO
    780837        /* If we're working out of the repository, we need to update the
    781838         * driver table in PRDESC.LST to add the new driver(s).
    782839         */
     840
    783841        CALL LINEOUT globals.!log1, 'Updating' globals.!prdesc 'with' newprinters.0 'new entries ...'
    784842        count = 0
     
    871929
    872930    IF \VRIsDir( globals.!cupsdir ) THEN DO
    873         CALL VRMessage VRWindow(), 'Please specify the path where CUPS is installed as follows:' ||,
    874                                    '0d0a0d0a'x || 'CUPSWIZ <cups-path>',,
    875                                    'Unknown or Invalid CUPS Path', 'E'
    876         EXIT
     931        IF TRANSLATE( globals.!cupsdir ) <> '/R' THEN
     932            CALL VRMessage VRWindow(),,
     933                           'CUPS could not be located.  If you wish to use ' ||,
     934                           'a local installation of CUPS, please specify '   ||,
     935                           'the path where CUPS is installed on the command '||,
     936                           'line to this program (e.g "CUPSWIZ F:\CUPS").'   ||,
     937                           '0d0a0d0a'x ||,
     938                           'Only remote CUPS queues will be available for '  ||,
     939                           'printers created in this session.  (To skip '    ||,
     940                           'this message in the future, start this program ' ||,
     941                           'with the /R parameter.)',,
     942                           'CUPS Path Not Found or Not Valid', 'E'
     943        globals.!cupsdir = ''
    877944    END
    878945
     
    9531020    CALL VRMethod 'LB_SELECT', 'AddStringList', 'models.',, 'ppds.'
    9541021    CALL VRSet    'LB_SELECT', 'Painting', 1
     1022/*    CALL VRSet 'LB_SELECT', 'Selected', 1 */
    9551023
    9561024RETURN
     
    9681036            IF selected == 0 THEN RETURN
    9691037            which = VRMethod('LB_SELECT', 'GetItemData', selected )
    970             IF which == '' THEN RETURN
    971             man = VRMethod('LB_BRAND', 'GetItemData', brand )
    972             IF man == '' THEN RETURN
    973 
    974             make  = manufacturers.man.!name
    975             model = manufacturers.man.!printers.which.!model
    976             driver = manufacturers.man.!printers.which.!type
    977             remark = manufacturers.man.!printers.which.!remark
    978             IF remark == '' THEN
    979                 type = ' ('driver')'
    980             ELSE
    981                 type = ' ('driver' - 'remark')'
    982 
    983             CALL VRSet 'WN_MAIN', 'StatusText', make model type
     1038            IF which <> '' THEN DO
     1039                man = VRMethod('LB_BRAND', 'GetItemData', brand )
     1040                IF man == '' THEN RETURN
     1041                make  = manufacturers.man.!name
     1042                model = manufacturers.man.!printers.which.!model
     1043                driver = manufacturers.man.!printers.which.!type
     1044                IF WORD( driver, 1 ) == 'hpcups' THEN driver = 'HPLIP'
     1045                remark = manufacturers.man.!printers.which.!remark
     1046                IF driver == '' THEN
     1047                    type = ''
     1048                ELSE IF remark == '' THEN
     1049                    type = ' ('driver')'
     1050                ELSE
     1051                    type = ' ('driver' - 'remark')'
     1052                CALL VRSet 'WN_MAIN', 'StatusText', make model type
     1053            END
    9841054        END
    9851055
     
    9871057    END
    9881058
     1059    CALL VRSet 'PB_NEXT', 'Enabled', 1
    9891060RETURN
    9901061
     
    9991070    /* Get CUPS paths.
    10001071     */
    1001     globals.!cupsdir = ''
    1002     cupsdrv = VRParseFilePath( me, 'D')
    1003     cupsdir = cupsdrv':\cups'
    1004 
    1005     globals.!cupsdir = cupsdir
     1072    PARSE VALUE VRGetIni('eCups', 'CUPS', 'USER') WITH cupsdrv '00'x
     1073    IF cupsdrv == '' THEN
     1074        cupsdrv = VRParseFilePath( me, 'D') || ':'
     1075    ELSE
     1076        cupsdrv = STRIP( cupsdrv, 'T', '\')
     1077    globals.!cupsdir = cupsdrv'\cups'
    10061078
    10071079    /* Get system paths.
     
    11121184*/
    11131185PB_NETOK_Click: PROCEDURE EXPOSE globals. port
    1114     which  = VRGet('DDCB_PROTOCOL', 'Selected')
     1186
     1187    idx = VRGet('DDCB_PROTOCOL', 'Selected')
     1188    which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
    11151189    server = STRIP( VRGet("EF_SERVER",   "Value"))
    11161190    pqueue = STRIP( VRGet("EF_QUEUE",    "Value"))
     
    11931267                globals.!prt_dev  = ''
    11941268                globals.!prt_nick = GetNameFromPPD( ppd )
     1269                IF globals.!prt_nick == '' THEN DO
     1270                    CALL VRMessage VRWindow(), 'Could not read printer name '||,
     1271                                               'from' ppd'.', 'Invalid PPD', 'E'
     1272                    RETURN
     1273                END
    11951274            END
    11961275            ELSE DO
     
    12161295                    globals.!prt_ppd  = TRANSLATE( globals.!cupsdir'/share/cups/model/'ppd, '\', '/')
    12171296                    globals.!prt_dev  = ''
    1218                     globals.!prt_nick = GetNameFromPPD( ppd )
     1297                    globals.!prt_nick = GetNameFromPPD( globals.!prt_ppd )
    12191298                END
    12201299            END
     
    13451424SetPage1: PROCEDURE EXPOSE globals. manufacturers.
    13461425
     1426    CALL VRSet 'PB_NEXT',  'Enabled', 0
    13471427    CALL VRSet 'LB_BRAND', 'Visible', 1
    13481428
     
    13561436    CALL VRSet 'GB_INFO',   'Visible', 0
    13571437
    1358     globals.!page = 1
     1438    globals.!page       = 1
     1439    globals.!prt_ppd    = ''
     1440    globals.!prt_dev    = ''
     1441    globals.!prt_nick   = ''
     1442    globals.!prt_port   = ''
     1443    globals.!remotecups = ''
     1444    globals.!prt_name   = ''
     1445    globals.!prt_loc    = ''
     1446    globals.!prt_info   = ''
     1447    globals.!os2driver  = ''
     1448
    13591449    CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
    1360     CALL GetCupsPrinters
    1361 
    13621450    CALL VRSet 'DT_INFO', 'Caption', 'Select your printer model.'
    13631451
    13641452    /* Populate the manufacturer list */
     1453    IF globals.!cupsdir == '' THEN DO
     1454        manufacturers.1.!name = '-- Custom --'
     1455        manufacturers.1.!printers.0 = 1
     1456        manufacturers.1.!printers.1.!model   = '-- Other printer (requires PPD) --'
     1457        manufacturers.1.!printers.1.!driver  = ''
     1458        manufacturers.1.!printers.1.!type    = ''
     1459        manufacturers.1.!printers.1.!remark  = '-- Other printer (requires PPD) --'
     1460        manufacturers.1.!printers.1.!driver2 = ''
     1461        manufacturers.1.!printers.1.!remark2 = ''
     1462        manufacturers.0 = 1
     1463    END
     1464    ELSE
     1465        CALL GetCupsPrinters
     1466
    13651467    CALL VRSet 'LB_BRAND',  'Painting', 0
    13661468    DO i = 1 TO manufacturers.0
     
    13731475    CALL VRSet 'LB_BRAND',  'Painting', 1
    13741476
    1375     CALL VRMethod 'LB_SELECT', 'SetFocus'
     1477    CALL VRMethod 'LB_BRAND', 'SetFocus'
     1478    CALL VRSet 'LB_BRAND', 'Selected', 1
    13761479    CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
    13771480
     
    13841487    globals.!page = 2
    13851488    CALL VRSet 'LB_BRAND', 'Visible', 0
     1489    CALL VRSet 'PB_NEXT',  'Enabled', 0
    13861490    CALL VRSet 'WN_MAIN', 'StatusText', 'Selected printer: ' globals.!prt_nick
    13871491
     
    13921496    CALL VRSet 'LB_SELECT', 'Width', lb_w
    13931497
     1498    CALL VRMethod 'LB_SELECT', 'Clear'
     1499
    13941500    CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
    1395     CALL GetCupsPorts
     1501    IF globals.!cupsdir == '' THEN DO
     1502        CALL VRMethod 'LB_SELECT', 'AddString', 'Network printer (manual configuration)',, ''
     1503        CALL VRSet    'LB_SELECT', 'Selected', 1
     1504    END
     1505    ELSE
     1506        CALL GetCupsPorts
    13961507    CALL VRMethod 'LB_SELECT', 'SetFocus'
    13971508    CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
     
    16191730SW_NETWORK_Init:
    16201731
     1732    IF globals.!cupsdir == '' THEN DO
     1733        protos.0 = 1
     1734        protos.1 = 'Existing CUPS printer (remote server)'
     1735        pnums.0 = 1
     1736        pnums.1 = 5
     1737    END
     1738    ELSE DO
     1739        protos.0 = 5
     1740        protos.1 = 'Internet Printing Protocol (IPP)'
     1741        protos.2 = 'AppSocket/JetDirect'
     1742        protos.3 = 'Line Printer Remote daemon (LPD)'
     1743        protos.4 = 'Windows/SMB network'
     1744        protos.5 = 'Existing CUPS printer'
     1745        pnums.0 = 5
     1746        pnums.1 = 1
     1747        pnums.2 = 2
     1748        pnums.3 = 3
     1749        pnums.4 = 4
     1750        pnums.5 = 5
     1751    END
     1752
     1753    CALL VRMethod 'DDCB_PROTOCOL', 'AddStringList', 'protos.',, 'pnums.'
    16211754    CALL VRSet 'DDCB_PROTOCOL', 'Selected', 1
    16221755
  • trunk/gui/printer/cupswiz/readme.1st

    r12 r14  
    11CUPSWIZ - prototype CUPS printer-creation wizard
    2 Test release 3
     2Version 0.95
    33
    44Make sure cupsport.exe is either in the current directory or in the PATH.
     
    77(e.g. "cupswiz f:\cups")
    88
    9 <path-to-cups> can be omitted if cupswiz.exe is on the same drive as CUPS.
     9<path-to-cups> can be omitted if cupswiz.exe is on the same drive as CUPS, or
     10if OS2.INI defines the CUPS path in the key "eCups" -> "CUPS".
    1011
    1112Requirements:
    1213 - CUPS, including ECUPS.DRV and CUPS.PDR, must be installed and working.
    1314   The CUPS daemon must be running. 
    14  - CUPS.PDR should have a bldlevel of 1.03 (February 2011) or later.  If
    15    not, the created WPS printer object will not work properly until the
    16    WPS is restarted.
     15 - CUPS.PDR should have a bldlevel of 1.03 (February 2011) or later.  If not,
     16   the created WPS printer object will not work properly until you reboot
     17   (possibly restarting the WPS will also work, but I'm not sure about that).
    1718 - GNU gzip.exe must be installed (somewhere on the PATH).
    1819 - RINSTPRN.EXE (included with OS/2 MCP/ACP & eComStation, not sure about
    19    earlier verions) must also be somewhere on the PATH.
     20   earlier versions) must also be somewhere on the PATH.
    2021 - VROBJ.DLL (included in eComStation or available on Hobbes) is required.
    2122
    2223Current limitations:
    2324 - The CUPS printer is always created with default job options.
    24  - If your %TMP% directory has spaces in the pathname, the program will
    25    almost certainly fail to work properly.  The same applies to your
    26    %LOGFILES% directory.
     25 - There is no way to go 'back'; if you need to go back and change a previous
     26   selection, you must cancel and start over.
     27 - The program has only been tested with Gutenprint, HPLIP, and (to a limited
     28   extent) foomatic-rip based printers.  Other drivers packages such as SpliX
     29   or foo2qpdl may work but this is not guaranteed.
     30 - If your %TMP% directory has spaces in the pathname, the program will almost
     31   certainly fail to work properly.  The same applies to your %LOGFILES%
     32   directory.
    2733 - No internationalization support (yet).
    2834 - No help or documentation.
  • trunk/gui/printer/cupswiz/todo

    r12 r14  
    11- Check to make sure CUPS.PDR is installed, and (offer to) install if missing.
    22- Ditto for gzip.exe, rinstprn.exe and cupsport.exe
    3 - Use OS2.INI eCups::CUPS ||'\cups' for cups path if found.
    4 - How to support total remote CUPS (i.e. no local CUPS install)?
    5 - Offer the option to show both simplified/expert drivers
     3- Offer the option to show both simplified/expert drivers.
     4- Allow setting at least some basic job options like paper/colour/quality.
     5- I18N support
     6- Is there a way to generate the PPD for driver import when using exe://?  e.g.
     7  get the saved PPD from the cups\etc\cups\ppd directory.
Note: See TracChangeset for help on using the changeset viewer.