Changeset 30


Ignore:
Timestamp:
Apr 17, 2013, 4:50:23 AM (12 years ago)
Author:
Alex Taylor
Message:

Try to auto-detect CUPS queue names when 'existing CUPS printer' is selected.

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

Legend:

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

    r27 r30  
    112112        IF cups_pdr == '' THEN DO
    113113            CALL VRMessage VRWindow(),,
    114                            NLSGetMessage( 78, globals.!bootdrv'\OS2\DLL\CUPS.PDR'),,    /*  78: The required program %1 is not installed... */ 
     114                           NLSGetMessage( 78, globals.!bootdrv'\OS2\DLL\CUPS.PDR'),,    /*  78: The required program %1 is not installed... */
    115115                           NLSGetMessage( 79 ), 'E'                                     /*  79: Missing File */
    116             CALL Quit 
     116            CALL Quit
    117117        END
    118118        ELSE CALL VRSetIni('PM_PORT_DRIVER', 'CUPS', cups_pdr, 'System')
    119119    END
    120120
    121     /* Make sure \TCPIP\BIN\CUPSLPR.EXE (required by CUPS.PDR) is installed. 
     121    /* Make sure \TCPIP\BIN\CUPSLPR.EXE (required by CUPS.PDR) is installed.
    122122     */
    123123    tcpipbin = SysSearchPath('PATH', 'inetd.exe')
    124124    IF tcpipbin <> '' THEN
    125125        tcpipbin = VRParseFileName( tcpipbin, 'DP')
    126     ELSE 
     126    ELSE
    127127        tcpipbin = globals.!bootdrv'\TCPIP\BIN'
    128128    IF \VRFileExists( tcpipbin'\cupslpr.exe') & (SysSearchPath('PATH', 'cupslpr.exe') == '') THEN DO
     
    130130                       NLSGetMessage( 78, 'CUPSLPR.EXE'),,
    131131                       NLSGetMessage( 79 ), 'E'
    132         CALL Quit 
     132        CALL Quit
    133133    END
    134134
     
    136136     */
    137137    gzip_exe = SysSearchPath('PATH', 'gzip.exe')
    138     IF gzip_exe == '' THEN gzip_exe = STREAM( DIRECTORY() || '\gzip.exe', 'C', 'QUERY EXISTS') 
     138    IF gzip_exe == '' THEN gzip_exe = STREAM( DIRECTORY() || '\gzip.exe', 'C', 'QUERY EXISTS')
    139139    IF gzip_exe == '' THEN DO
    140140        CALL VRMessage VRWindow(), NLSGetMessage( 78, 'GZIP.EXE'), NLSGetMessage( 79 ), 'E'
    141         CALL Quit 
     141        CALL Quit
    142142    END
    143143
     
    145145     */
    146146    port_exe = SysSearchPath('PATH', 'cupsport.exe')
    147     IF port_exe == '' THEN port_exe = STREAM( DIRECTORY() || '\cupsport.exe', 'C', 'QUERY EXISTS') 
     147    IF port_exe == '' THEN port_exe = STREAM( DIRECTORY() || '\cupsport.exe', 'C', 'QUERY EXISTS')
    148148    IF port_exe == '' THEN DO
    149149        CALL VRMessage VRWindow(), NLSGetMessage( 78, 'CUPSPORT.EXE'), NLSGetMessage( 79 ), 'E'
    150         CALL Quit 
     150        CALL Quit
    151151    END
    152152
     
    154154     */
    155155    prntobj_exe = SysSearchPath('PATH', 'prntobj.exe')
    156     IF prntobj_exe == '' THEN prntobj_exe = STREAM( DIRECTORY() || '\prntobj.exe', 'C', 'QUERY EXISTS') 
     156    IF prntobj_exe == '' THEN prntobj_exe = STREAM( DIRECTORY() || '\prntobj.exe', 'C', 'QUERY EXISTS')
    157157    IF prntobj_exe == '' THEN DO
    158158        CALL VRMessage VRWindow(), NLSGetMessage( 78, 'PRNTOBJ.EXE'), NLSGetMessage( 79 ), 'E'
    159         CALL Quit 
     159        CALL Quit
    160160    END
    161161
     
    294294    END
    295295
    296     /* Create a new CUPS port. 
     296    /* Create a new CUPS port.
    297297     */
    298298    port_ok = AddPort_CUPS( port_name, host, printer )
     
    418418            show_user  = 1
    419419            show_pass  = 1
     420            show_pick  = 0
    420421            server_caption = 82          /* 82: Printer or server address: */
    421422            queue_caption  = 84          /* 84: Printer queue name: */
     
    426427            show_user  = 0
    427428            show_pass  = 0
     429            show_pick  = 0
    428430            server_caption = 82          /* 82: Printer or server address: */
    429431            queue_caption  = 84          /* 84: Printer queue name: */
     
    434436            show_user  = 1
    435437            show_pass  = 0
     438            show_pick  = 0
    436439            server_caption = 82          /* 82: Printer or server address: */
    437440            queue_caption  = 84          /* 84: Printer queue name: */
     
    442445            show_user  = 1
    443446            show_pass  = 1
     447            show_pick  = 0
    444448            server_caption = 83          /* 83: Print server name: */
    445449            queue_caption  = 85          /* 85: Shared printer name: */
     
    447451        END
    448452        OTHERWISE DO                /* CUPS */
    449             show_queue = 1
     453            show_queue = 0
    450454            show_user  = 0
    451455            show_pass  = 0
     456            show_pick  = 1
    452457            server_caption = 88          /* 88: CUPS server name: */
    453458            queue_caption  = 89          /* 89: CUPS printer name: */
     
    460465    r = NLSSetText('DT_USERID', 'Caption', userid_caption )
    461466
    462     CALL VRSet 'DT_QUEUE',    'Visible', show_queue
    463     CALL VRSet 'EF_QUEUE',    'Visible', show_queue
    464     CALL VRSet 'DT_USERID',   'Visible', show_user
    465     CALL VRSet 'EF_USERID',   'Visible', show_user
    466     CALL VRSet 'DT_PASSWORD', 'Visible', show_pass
    467     CALL VRSet 'EF_PASSWORD', 'Visible', show_pass
    468 
     467    CALL VRSet 'DT_QUEUE',       'Visible', show_queue | show_pick
     468    CALL VRSet 'EF_QUEUE',       'Visible', show_queue
     469    CALL VRSet 'DT_USERID',      'Visible', show_user
     470    CALL VRSet 'EF_USERID',      'Visible', show_user
     471    CALL VRSet 'DT_PASSWORD',    'Visible', show_pass
     472    CALL VRSet 'EF_PASSWORD',    'Visible', show_pass
     473    CALL VRSet 'DDCB_CUPSQUEUES','Visible', show_pick
     474
     475RETURN
     476
     477/*:VRX         EF_SERVER_LostFocus
     478*/
     479EF_SERVER_LostFocus: PROCEDURE EXPOSE globals.
     480
     481    idx = VRGet('DDCB_PROTOCOL', 'Selected')
     482    which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
     483    IF which <> 5 THEN RETURN
     484
     485    CALL VRMethod 'DDCB_CUPSQUEUES', 'Clear'
     486    server = STRIP( VRGet("EF_SERVER", "Value"))
     487    IF server == '' THEN RETURN
     488
     489    IF GetCupsQueues( server ) == 0 THEN RETURN
     490    CALL VRMethod 'DDCB_CUPSQUEUES', 'AddStringList', 'cupsdest.'
    469491RETURN
    470492
     
    505527    CALL NLSSetText 'DT_INFO', 'Caption', 30        /* 30: Looking for connected printers.  Please wait... */
    506528
    507     lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe -v |rxqueue'
    508     snmp_cmd   = globals.!cupsdir'\lib\cups\backend\snmp.exe |rxqueue'
     529    lpinfo_cmd = globals.!cupsdir'\sbin\lpinfo.exe -v 2>&1 |rxqueue'
     530    snmp_cmd   = globals.!cupsdir'\lib\cups\backend\snmp.exe 2>&1 |rxqueue'
    509531
    510532    _od = DIRECTORY()
     
    703725RETURN
    704726
     727/*:VRX         GetCupsQueues
     728*/
     729GetCupsQueues: PROCEDURE EXPOSE globals. cupsdest.
     730    ARG hostaddr
     731
     732    /* Try to find lpstat.exe */
     733    lpstat_exe = STREAM( globals.!cupsdir'\bin\lpstat.exe', 'C', 'QUERY EXISTS')
     734    IF lpstat_exe == '' THEN lpstat_exe = STREAM( globals.!mydir'\lpstat.exe', 'C', 'QUERY EXISTS')
     735    IF lpstat_exe == '' THEN lpstat_exe = STREAM( DIRECTORY()'\lpstat.exe', 'C', 'QUERY EXISTS')
     736    IF lpstat_exe == '' THEN lpstat_exe = SysSearchPath('PATH', 'lpstat.exe')
     737    IF lpstat_exe == '' THEN RETURN 0
     738
     739    sq = RXQUEUE('CREATE')
     740    oq = RXQUEUE('SET', sq )
     741
     742    CALL VRSet VRWindow(), 'Pointer', 'WAIT'
     743    ADDRESS CMD '@'lpstat_exe '-h' hostaddr '-p -c 2>&1 |rxqueue' sq
     744    CALL VRSet VRWindow(), 'Pointer', '<default>'
     745
     746    _count = 0
     747    DO QUEUED()
     748        PARSE PULL _info
     749        IF _info == '' THEN ITERATE
     750        IF _info == 'lpstat: Connection refused' THEN LEAVE
     751        IF WORD( _info, 1 ) == 'printer' THEN
     752            PARSE VAR _info 'printer' _qname .
     753        ELSE IF WORD( info, 1 ) == 'class' THEN
     754            PARSE VAR _info 'class' _qname .
     755        ELSE ITERATE
     756        IF _qname == '' THEN ITERATE
     757        _count = _count + 1
     758        cupsdest._count = _qname
     759    END
     760    CALL RXQUEUE 'DELETE', sq
     761    CALL RXQUEUE 'SET', oq
     762
     763    cupsdest.0 = _count
     764
     765RETURN _count
     766
    705767/*:VRX         Halt
    706768*/
     
    12851347    idx = VRGet('DDCB_PROTOCOL', 'Selected')
    12861348    which = VRMethod('DDCB_PROTOCOL', 'GetItemData', idx )
    1287     server = STRIP( VRGet("EF_SERVER",   "Value"))
    1288     pqueue = STRIP( VRGet("EF_QUEUE",    "Value"))
    1289     userid = STRIP( VRGet("EF_USERID",   "Value"))
    1290     passwd = STRIP( VRGet("EF_PASSWORD", "Value"))
     1349    server = STRIP( VRGet("EF_SERVER",      "Value"))
     1350    pqueue = STRIP( VRGet("EF_QUEUE",       "Value"))
     1351    cqueue = STRIP( VRGet("DDCB_CUPSQUEUE", "Value"))
     1352    userid = STRIP( VRGet("EF_USERID",      "Value"))
     1353    passwd = STRIP( VRGet("EF_PASSWORD",    "Value"))
    12911354
    12921355    invalid = 0
     
    13251388            uri = uri || server'/'pqueue
    13261389        END
    1327         OTHERWISE DO
    1328             IF server == '' | pqueue == '' THEN invalid = 1
     1390        OTHERWISE DO                /* Existing CUPS */
     1391            IF server == '' | cqueue == '' THEN invalid = 1
    13291392            ELSE DO
    1330                 globals.!remotecups = server pqueue
     1393                globals.!remotecups = server cqueue
    13311394                uri = ''
    13321395            END
     
    17321795    CALL NLSSetText 'SW_ABOUT',  'Caption', 10                                          /* 10: Product Information */
    17331796    CALL NLSSetText 'DT_ABOUT1', 'Caption', 11                                          /* 11: eCups Printer Install Utility */
    1734     CALL NLSSetText 'DT_ABOUT2', 'Caption', 12, '1.01'                                  /* 12: Version %1 */
     1797    CALL NLSSetText 'DT_ABOUT2', 'Caption', 12, '1.02'                                  /* 12: Version %1 */
    17351798    CALL NLSSetText 'DT_ABOUT3', 'Caption', 13, '2010, 2013'                            /* 13: (C) %1 Alex Taylor */
    17361799    CALL NLSSetText 'PB_ABOUT',  'Caption', 2                                           /* 10: Product Information */
  • TabularUnified trunk/gui/printer/cupswiz/readme.1st

    r24 r30  
    11CUPSWIZ - CUPS printer-creation wizard
    2 Version 1.01
     2Version 1.02
    33
    44  This program is simple graphical front-end for creating CUPS-based printers
     
    7272
    7373  1. Place CUPSWIZ.EXE into a suitable directory. 
    74   2. Place CUPSPORT.EXE either in the same directory as CUPSWIZ.EXE, or else
    75      in a directory on the PATH.
     74  2. Place CUPSPORT.EXE and PRNTOBJ.EXE either in the same directory as
     75     CUPSWIZ.EXE, or else in a directory on the PATH.
    7676
    7777
Note: See TracChangeset for help on using the changeset viewer.