Changeset 37 for trunk/gui


Ignore:
Timestamp:
May 3, 2013, 8:16:28 PM (12 years ago)
Author:
Alex Taylor
Message:

Various updates to printer manager.

Location:
trunk/gui/printer/manager
Files:
2 edited

Legend:

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

    r33 r37  
    119119        globals.!programs.!gzip = STREAM( globals.!mydir'\gzip.exe', 'C', 'QUERY EXISTS')
    120120
     121    IF globals.!hascups THEN DO
     122        globals.!programs.!lpadmin   = STREAM( globals.!cupsdir'\sbin\lpadmin.exe',  'C', 'QUERY EXISTS')
     123        globals.!programs.!lpinfo    = STREAM( globals.!cupsdir'\sbin\lpinfo.exe',   'C', 'QUERY EXISTS')
     124        globals.!programs.!lpoptions = STREAM( globals.!cupsdir'\bin\lpoptions.exe', 'C', 'QUERY EXISTS')
     125        globals.!programs.!lpstat    = STREAM( globals.!cupsdir'\bin\lpstat.exe',    'C', 'QUERY EXISTS')
     126    END
     127
    121128RETURN
    122129
     
    188195    CALL PrinterOpen VRInfo("Record")
    189196RETURN
     197
     198/*:VRX         CupsDeletePrinter
     199*/
     200CupsDeletePrinter: PROCEDURE EXPOSE globals.
     201    PARSE ARG _host, _dest
     202
     203    IF TRANSLATE( _host ) <> 'LOCALHOST' THEN
     204        del_cmd = globals.!programs.!lpadmin '-h' _host '-d' _dest
     205    ELSE
     206        del_cmd = globals.!programs.!lpadmin '-d' _dest
     207    CALL LINEOUT globals.!log1, 'Delete CUPS destination' _dest' with:'  del_cmd
     208
     209    nq = RXQUEUE('CREATE')
     210    oq = RXQUEUE('SET', nq )
     211    ADDRESS CMD '@' del_cmd '2>&1 | RXQUEUE' nq
     212    DO QUEUED()
     213        PARSE PULL _output
     214        CALL LINEOUT globals.!log2, _output
     215        IF LEFT( _output, 8 ) == 'Password' & RIGHT( STRIP( _output ), 1 ) == '?' THEN DO
     216            CALL SysSleep 1
     217            CALL CHAROUT, '0d0a'x
     218        END
     219    END
     220    CALL RXQUEUE 'SET',    oq
     221    CALL RXQUEUE 'DELETE', nq
     222/*
     223    ADDRESS CMD '@' del_cmd '2>&1 >>' globals.!log2
     224*/
     225
     226    CALL LINEOUT globals.!log2, ''
     227    CALL LINEOUT globals.!log2
     228    CALL LINEOUT globals.!log1, ''
     229
     230RETURN rc
    190231
    191232/*:VRX         DriverAdd
     
    673714RETURN
    674715
     716/*:VRX         InitMessageLog
     717*/
     718/* Initialize the message logfile.  Unlike the error log, which is cleared and
     719 * recreated every time the program starts, the message log is appended to
     720 * until it reaches 100kB in size.  If the message log is larger than 100kB when
     721 * this function is called, it is renamed (with '~' appended to the  name) and
     722 * a new message log is started.
     723 */
     724InitMessageLog: PROCEDURE EXPOSE globals.
     725
     726    logsize = STREAM( globals.!log1, 'C', 'QUERY SIZE')
     727    IF ( logsize <> '') & ( logsize > 102400 ) THEN DO
     728        CALL VRCopyFile globals.!log1, globals.!log1 || '~'
     729        CALL VRDeleteFile globals.!log1
     730    END
     731
     732    datestr = DATE('L') TIME('N')
     733    CALL LINEOUT globals.!log1, '--[' datestr ']' ||,
     734                 COPIES('-', 73 - LENGTH( datestr ))
     735RETURN
     736
    675737/*:VRX         LoadSettings
    676738*/
    677739LoadSettings: PROCEDURE EXPOSE globals.
    678740
    679     globals.!version = '0.21'
     741    globals.!version = '0.3'
    680742    globals.!copyright = '2013'
    681743
     
    692754        cupsdrv = STRIP( cupsdrv, 'T', '\')
    693755    globals.!cupsdir = cupsdrv'\cups'
    694 
    695     /** TODO Identify if CUPS and/or CUPS.PDR is installed */
    696     globals.!hascups = 1
     756    globals.!hascups = VRIsDir( globals.!cupsdir )
    697757
    698758    /* Get system paths.
     
    711771        globals.!logdir = globals.!mydir
    712772
    713     globals.!log1 = globals.!logdir'\printmgr.l1'
    714     globals.!log2 = globals.!logdir'\printmgr.l2'
     773    globals.!log1 = globals.!logdir'\printman.l1'
     774    globals.!log2 = globals.!logdir'\printman.l2'
     775    CALL InitMessageLog
     776    IF VRFileExists( globals.!log2 ) THEN
     777        CALL VRDeleteFile globals.!log2
     778
    715779
    716780    /* Get printer-related paths.
     
    9441008        od = DIRECTORY()
    9451009        CALL DIRECTORY _workdir
    946         IF ppd_file <> '' & VRFileExists( ppd_file ) THEN 
     1010        IF ppd_file <> '' & VRFileExists( ppd_file ) THEN
    9471011            _parms = _parms ppd_file
    9481012        ADDRESS CMD 'start' cupswiz _parms
    9491013        CALL DIRECTORY od
     1014        CALL Quit
    9501015    END
    9511016
     
    9571022
    9581023    ok = OpenPrinterTemplate('WPRPrinter')
     1024    CALL Quit
    9591025
    9601026RETURN ok
     
    9651031
    9661032    ok = OpenPrinterTemplate('WPPrinter')
     1033    CALL Quit
    9671034
    9681035RETURN ok
     
    14041471        record = recs.1
    14051472    END
     1473    CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
    14061474
    14071475    success = 0
    14081476    _title = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!title )
    14091477    _queue = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!queue )
     1478    _port  = VRMethod('CN_PRINTERS', 'GetFieldData', record, globals.!hcfPrinters.!port )
     1479
    14101480    _btns.0 = 2
    14111481    _btns.1 = NLSGetMessage( 14 )
     
    14141484    IF _confirm == 1 THEN DO
    14151485        success = RPUPrinterDelete( _queue )
    1416     END
    1417 
    1418     CALL VRMethod 'CN_PRINTERS', 'SetRecordAttr', record, 'Source', 0
     1486        CALL RPUPortInfo _port, 'port.'
     1487        IF port.!driver == 'CUPS' THEN DO
     1488            /* If this corresponds to a locally-defined CUPS queue, offer to
     1489             * to delete that as well.
     1490             */
     1491            cups_prnt = RPUPortQuery('CUPS', _port )
     1492            IF cups_prnt <> '' & ( LENGTH( cups_prnt ) == 130 ) THEN DO
     1493                PARSE VAR cups_prnt 1 _cups_host 66 _cups_queue
     1494                PARSE VAR _cups_host cups_host '00'x .
     1495                PARSE VAR _cups_queue cups_queue '00'x .
     1496                IF ( TRANSLATE( cups_host ) == 'LOCALHOST') | cups_host = '127.0.0.1' THEN DO
     1497                    _confirm = VRMessage('WN_MAIN', NLSGetMessage( 204, _title, cups_queue, _port ),,
     1498                                          NLSGetMessage( 200 ), 'Q', '_btns.', 2, 2 )
     1499                    IF _confirm == 1 THEN DO
     1500                        success = CupsDeletePrinter( cups_host, cups_queue )
     1501                        IF success == 0 THEN
     1502                            CALL RPUPortDelete _port
     1503                        ELSE
     1504                            CALL VRMessage 'WN_MAIN', NLSGetMessage( 251, cups_queue, success ), NLSGetMessage( 18 ), 'E'
     1505                    END
     1506                END
     1507            END
     1508        END
     1509    END
     1510
     1511    CALL RefreshPrinters
     1512
    14191513RETURN success
    14201514
  • trunk/gui/printer/manager/printm_en.txt

    r33 r37  
    2020PTM0016I: Operation Successful
    2121PTM0017I: Continue
    22 PTM0018?:
     22PTM0018I: Operation Failed
    2323PTM0019?:
    2424; ------- [20-99]: Menus
     
    216216PTM0202I: Delete port %1?
    217217PTM0203I: Delete driver "%1"?
    218 PTM0204?:
     218PTM0204I: Printer "%1" points to the local CUPS queue "%2" via port %3.  Delete this CUPS queue and port as well?
    219219PTM0205I: Add a new port of type %1?
    220220PTM0206?:
     
    252252PTM0238I: The PPD has been imported.
    253253PTM0239?:
     254PTM0240?:
     255PTM0241?:
     256PTM0242?:
     257PTM0243?:
     258PTM0244?:
     259PTM0245?:
     260PTM0246?:
     261PTM0247?:
     262PTM0248?:
     263PTM0249?:
     264; CUPS errors
     265PTM0250I: The CUPS printer %1 could not be created (CUPS return code %2).
     266PTM0251I: The CUPS printer %1 could not be deleted (CUPS return code %2).
     267PTM0252?:
     268PTM0253?:
     269PTM0254?:
     270PTM0255?:
     271PTM0256?:
     272PTM0257?:
     273PTM0258?:
     274PTM0259?:
    254275
     276
     277
Note: See TracChangeset for help on using the changeset viewer.