Changeset 9 for trunk/gui/printer


Ignore:
Timestamp:
Oct 31, 2011, 5:06:48 AM (14 years ago)
Author:
Alex Taylor
Message:

Handle dynamic-PPD printers.

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

Legend:

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

    r8 r9  
    150150    IF globals.!prt_loc <> '' THEN
    151151        cups_cmd = cups_cmd '-L "'globals.!prt_loc'"'
    152     cups_cmd = cups_cmd '-v "'globals.!prt_port'" -P "'globals.!prt_ppd'"'
     152    IF globals.!prt_dev <> '' THEN
     153        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
    153157
    154158    CALL LINEOUT globals.!log1, 'Creating CUPS printer using:'
     
    195199     */
    196200    copied_driver = 0
    197     driver_path = GetDriverSource( driver )
     201    driver_path = GetDriverSource( prnt_drv )
    198202
    199203    IF ( pmdx <> '') & ( globals.!prdrv <> '') & ( globals.!prdesc <> '') THEN DO
     
    249253        CALL DeletePort port_name
    250254    ELSE IF port_ok == 1 THEN DO
    251         CALL VRMessage VRWindow(), 
     255        CALL VRMessage VRWindow(),
    252256                       'The installed version of CUPS.PDR appears to be out of ',
    253257                       'date.  As a result, the desktop printer will not be ',
    254                        'useable until the desktop is restarted.',, 
     258                       'useable until the desktop is restarted.',,
    255259                       'Port Driver Problem', 'W'
    256260    END
     
    289293        END
    290294        ELSE IF PrinterExistsInDRV('ECUPS', globals.!prt_nick ) == 0 THEN DO
    291             ok = ImportPPD('ECUPS', globals.!prt_ppd )
    292             IF ok <> 0 THEN DO
    293                 CALL LINEOUT globals.!log1, 'PPD import failed:' ok
    294                 RETURN 1                /** RC=1  PPD import failed **/
     295            IF globals.!prt_ppd == '' THEN
     296                CALL PromptForPMName
     297            ELSE DO
     298                ok = ImportPPD('ECUPS', globals.!prt_ppd )
     299                IF ok <> 0 THEN DO
     300                    CALL LINEOUT globals.!log1, 'PPD import failed:' ok
     301                    RETURN 1                /** RC=1  PPD import failed **/
     302                END
    295303            END
    296304        END
     
    351359
    352360    od = DIRECTORY()
    353     CALL DIRECTORY src 
     361    CALL DIRECTORY src
    354362    rinstprn_cmd = 'rinstprn /DSC:'dsc '/DRV:'drv' /S:'src                    ,
    355363                   '/T:'globals.!bootdrv '/L1:'globals.!logdir'\rinstprn.log' ,
     
    394402        PARSE PULL line
    395403        PARSE VAR line _type _name
    396         IF _type <> 'direct' THEN ITERATE
    397404        IF _name == '' THEN ITERATE
    398         i = i + 1
    399         devices.i = 'Local printer:' _name
    400         ports.i   = _name
     405        IF _type == 'network' & POS('://', _name ) > 0 THEN DO
     406            PARSE VAR _name _protocol '://' _host '/' _queue
     407            IF _protocol == 'socket' THEN _protocol = 'AppSocket'
     408            ELSE _protocol = TRANSLATE( _protocol )
     409            i = i + 1
     410            IF _queue == '' THEN _desc = '('_protocol')'
     411            ELSE _desc = _queue '('_protocol')'
     412            devices.i = 'Detected network printer' _desc 'at' _host
     413        END
     414        ELSE IF _type <> 'direct' THEN ITERATE
     415        ELSE DO
     416            i = i + 1
     417            devices.i = 'Local printer:' _name
     418        END
     419        ports.i = _name
    401420    END
    402421    devices.0 = i
     
    408427    CALL VRSet    'LB_SELECT', 'Painting', 0
    409428    CALL VRMethod 'LB_SELECT', 'AddStringList', 'devices.',, 'ports.'
    410     CALL VRMethod 'LB_SELECT', 'AddString', 'Network printer',, ''
     429    CALL VRMethod 'LB_SELECT', 'AddString', 'Network printer (manual configuration)',, ''
    411430    CALL VRSet    'LB_SELECT', 'Selected', 1
    412431    CALL VRSet    'LB_SELECT', 'Painting', 1
     
    439458            PARSE VAR line _ppd '.ppd ' _name
    440459            _ppd = _ppd'.ppd'
     460        END
     461        IF _name == '' THEN DO
     462            PARSE VAR line _ppd _name
    441463        END
    442464        IF _name <> '' THEN DO
     
    904926RETURN
    905927
     928/*:VRX         PB_MODELCANCEL_Click
     929*/
     930PB_MODELCANCEL_Click:
     931    CALL SW_MODEL_Close
     932    globals.!prt_nick = 'Generic PostScript Printer'
     933RETURN
     934
     935/*:VRX         PB_MODELOK_Click
     936*/
     937PB_MODELOK_Click:
     938    globals.!prt_nick = VRGet( "LB_OS2MODELS", "SelectedString" )
     939    CALL SW_MODEL_Close
     940RETURN
     941
    906942/*:VRX         PB_NETCANCEL_Click
    907943*/
     
    9861022                globals.!mode = 2   /* Mode 2: user-selected PPD file */
    9871023                ppd = VRFileDialog( VRWindow(), 'Select PPD', 'O', '*.ppd')
     1024                IF ppd == '' THEN RETURN
     1025                globals.!prt_ppd  = ppd
     1026                globals.!prt_dev  = ''
     1027                globals.!prt_nick = GetNameFromPPD( ppd )
    9881028            END
    9891029            ELSE DO
    9901030                globals.!mode = 1   /* Mode 1: CUPS-included model */
    991                 ppd = TRANSLATE( globals.!cupsdir'/share/cups/model/'ppd, '\', '/')
     1031                IF POS('exe://', ppd ) > 0 THEN DO
     1032                    globals.!prt_ppd  = ''
     1033                    globals.!prt_dev  = ppd
     1034                    sel_name = VRMethod('LB_SELECT', 'GetString', selected )
     1035                    PARSE VAR sel_name _nick ' - CUPS' .
     1036                    IF _nick == '' THEN
     1037                        globals.!prt_nick = STRIP( sel_name )
     1038                    ELSE
     1039                        globals.!prt_nick = STRIP( _nick )
     1040                END
     1041                ELSE DO
     1042                    globals.!prt_ppd  = TRANSLATE( globals.!cupsdir'/share/cups/model/'ppd, '\', '/')
     1043                    globals.!prt_dev  = ''
     1044                    globals.!prt_nick = GetNameFromPPD( ppd )
     1045                END
    9921046            END
    993             IF ppd == '' THEN RETURN
    994             globals.!prt_ppd = ppd
    995             globals.!prt_nick = GetNameFromPPD( ppd )
    9961047            globals.!remotecups = ''
    9971048
     
    10011052            ELSE
    10021053                CALL LINEOUT globals.!log1, 'Starting printer install for built-in model:'
    1003             CALL LINEOUT globals.!log1, ' - PPD file:  ' globals.!prt_ppd
    1004             CALL LINEOUT globals.!log1, ' - Model name:' globals.!prt_nick
     1054            IF globals.!prt_dev <> '' THEN
     1055                CALL LINEOUT globals.!log1, ' - Device name:' globals.!prt_dev
     1056            ELSE
     1057                CALL LINEOUT globals.!log1, ' - PPD file:   ' globals.!prt_ppd
     1058            CALL LINEOUT globals.!log1, ' - Model name: ' globals.!prt_nick
    10051059            CALL LINEOUT globals.!log1, ''
    10061060
     
    10511105            END
    10521106
     1107            /* TODO support other drivers
     1108             */
     1109            globals.!os2driver = 'ECUPS'
     1110
    10531111            CALL ConfirmAndCreate
    10541112        END
    10551113
    10561114        WHEN globals.!page == 4 THEN DO
    1057             CALL VRSet 'PB_NEXT', 'Caption', 'Next >'
     1115            CALL VRSet 'PB_NEXT',     'Caption', 'Next >'
     1116            CALL VRSet 'EF_NAME',     'Value', ''
     1117            CALL VRSet 'EF_LOCATION', 'Value', ''
     1118            CALL VRSet 'EF_DESC',     'Value', ''
    10581119            CALL SetPage1
    10591120        END
     
    10611122        OTHERWISE NOP
    10621123    END
     1124
     1125RETURN
     1126
     1127/*:VRX         PromptForPMName
     1128*/
     1129PromptForPMName: PROCEDURE EXPOSE globals. models. best
     1130    best = MatchPrinterModel( globals.!os2driver, globals.!prt_nick )
     1131
     1132    IF models.0 == 0 THEN DO
     1133        /* No similar models were found in the list of supported printers.
     1134         * Just use the generic PS driver.
     1135         */
     1136        CALL VRMessage VRWindow(),,
     1137                       'The printer "'globals.!prt_nick'" does not appear to' ,
     1138                       'be supported by the' globals.!os2driver 'driver, and' ,
     1139                       'no similar models were found.  The generic PostScript',
     1140                       'driver will be used for application support.',,
     1141                       'Printer Name Not Found', 'E'
     1142        globals.!prt_nick = 'Generic PostScript Printer'
     1143        RETURN
     1144    END
     1145
     1146    CALL VRLoadSecondary 'SW_MODEL', 'W'
    10631147
    10641148RETURN
     
    11621246
    11631247    IF globals.!remotecups <> '' THEN DO
    1164         /* An existing CUPS printer was indicated.  This means we're not 
     1248        /* An existing CUPS printer was indicated.  This means we're not
    11651249         * creating a CUPS printer, but only a PM printer object (and port)
    1166          * that points to it. 
     1250         * that points to it.
    11671251         */
    11681252        CALL VRSet 'DT_CREATE', 'Caption', 'Ready to create printer object with the following parameters.'
     
    11941278RETURN
    11951279
    1196 /*:VRX         SW_NETWORK_Close
    1197 */
    1198 SW_NETWORK_Close:
    1199     call SW_NETWORK_Fini
    1200 return
    1201 
    1202 /*:VRX         SW_NETWORK_Create
    1203 */
    1204 SW_NETWORK_Create:
    1205     call SW_NETWORK_Init
    1206 return
    1207 
    1208 /*:VRX         SW_NETWORK_Fini
    1209 */
    1210 SW_NETWORK_Fini:
     1280/*:VRX         SW_MODEL_Close
     1281*/
     1282SW_MODEL_Close:
     1283    call SW_MODEL_Fini
     1284return
     1285
     1286/*:VRX         SW_MODEL_Create
     1287*/
     1288SW_MODEL_Create:
     1289    call SW_MODEL_Init
     1290return
     1291
     1292/*:VRX         SW_MODEL_Fini
     1293*/
     1294SW_MODEL_Fini:
     1295
     1296    CALL VRSet 'WN_MAIN', 'Pointer', 'WAIT'
     1297
    12111298    window = VRInfo( "Window" )
    12121299    call VRDestroy window
    12131300    drop window
    12141301return
    1215 /*:VRX         SW_NETWORK_Init
    1216 */
    1217 SW_NETWORK_Init:
    1218 
    1219     CALL VRSet 'DDCB_PROTOCOL', 'Selected', 1
     1302/*:VRX         SW_MODEL_Init
     1303*/
     1304SW_MODEL_Init:
     1305
     1306    /* We should have a list of suggested printer models whose names at least
     1307     * partially match the requested model, sorted in order with the closest
     1308     * match at the top.
     1309     */
     1310    ok = VRMethod( "LB_OS2MODELS", "AddStringList", "models.",  )
     1311    IF best > 0 THEN
     1312        CALL VRSet 'LP_OS2MODELS', 'Selected', best
     1313
     1314    CALL VRSet 'DT_MODEL1', 'Caption',,
     1315               'The printer "'globals.!prt_nick'" could not be found in the'  ,
     1316               globals.!os2driver'.DRV driver under that name.  Please choose',
     1317               'the model of printer which will be reported to applications.'
     1318
     1319    CALL VRSet 'WN_MAIN', 'Pointer', '<default>'
    12201320
    12211321    window = VRInfo( "Object" )
     
    12261326    end
    12271327    drop window
     1328
     1329RETURN
     1330
     1331/*:VRX         SW_NETWORK_Close
     1332*/
     1333SW_NETWORK_Close:
     1334    call SW_NETWORK_Fini
     1335return
     1336
     1337/*:VRX         SW_NETWORK_Create
     1338*/
     1339SW_NETWORK_Create:
     1340    call SW_NETWORK_Init
     1341return
     1342
     1343/*:VRX         SW_NETWORK_Fini
     1344*/
     1345SW_NETWORK_Fini:
     1346    window = VRInfo( "Window" )
     1347    call VRDestroy window
     1348    drop window
     1349return
     1350/*:VRX         SW_NETWORK_Init
     1351*/
     1352SW_NETWORK_Init:
     1353
     1354    CALL VRSet 'DDCB_PROTOCOL', 'Selected', 1
     1355
     1356    window = VRInfo( "Object" )
     1357    if( \VRIsChildOf( window, "Notebook" ) ) then do
     1358        call VRMethod window, "CenterWindow"
     1359        call VRSet window, "Visible", 1
     1360        call VRMethod window, "Activate"
     1361    end
     1362    drop window
    12281363return
    12291364
  • trunk/gui/printer/cupswiz/readme.1st

    r8 r9  
    11CUPSWIZ - prototype CUPS printer-creation wizard
    2 Test release 1
     2Test release 2
    33
    44Make sure cupsport.exe is either in the current directory or in the PATH.
     
    2121
    2222Current limitations:
    23  - CUPS _must_ be installed locally.  You can create a printer on a remote
    24    CUPS system, but this requires the use of CUPS tools which need to be
    25    present on the system the wizard runs on.
    2623 - The CUPS printer is always created with default job options.
    2724 - Currently only ECUPS.DRV is supported (not ECUPS-HP.DRV).
  • trunk/gui/printer/cupswiz/todo

    r8 r9  
    11- Check to make sure CUPS.PDR is installed, and (offer to) install if missing.
    2 - Ditto for gzip, rinstprn and cupsport.exe
     2- Ditto for gzip.exe, rinstprn.exe and cupsport.exe
    33- Split first-page printer list into manufacturer-model lists.
    44- Check if (mode 1) printer is HP-LIP and use ECUPS-HP instead.
Note: See TracChangeset for help on using the changeset viewer.