LCOV - code coverage report
Current view: top level - vcl/inc - cupsmgr.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 7 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_INC_CUPSMGR_HXX
      21             : #define INCLUDED_VCL_INC_CUPSMGR_HXX
      22             : 
      23             : #include "vcl/printerinfomanager.hxx"
      24             : #include "osl/module.h"
      25             : #include "osl/thread.h"
      26             : #include "osl/mutex.hxx"
      27             : 
      28             : namespace psp
      29             : {
      30             : 
      31             : class PPDParser;
      32             : 
      33             : struct FPtrHash
      34             : {
      35           0 :     size_t operator()(const FILE* pPtr) const
      36           0 :     { return reinterpret_cast<size_t>(pPtr); }
      37             : };
      38             : 
      39             : class CUPSManager : public PrinterInfoManager
      40             : {
      41             :     std::unordered_map< FILE*, OString, FPtrHash >         m_aSpoolFiles;
      42             :     int                                                    m_nDests;
      43             :     void*                                                  m_pDests;
      44             :     bool                                                   m_bNewDests;
      45             :     std::unordered_map< OUString, int, OUStringHash >      m_aCUPSDestMap;
      46             : 
      47             :     std::unordered_map< OUString, PPDContext, OUStringHash > m_aDefaultContexts;
      48             : 
      49             :     OString                                                m_aUser;
      50             :     /** this is a security risk, but the CUPS API demands
      51             :         to deliver a pointer to a static buffer containing
      52             :         the password, so this cannot be helped*/
      53             :     OString                                                m_aPassword;
      54             : 
      55             :     osl::Mutex                                                  m_aCUPSMutex;
      56             :     oslThread                                                   m_aDestThread;
      57             : 
      58             :     osl::Mutex                                                  m_aGetPPDMutex;
      59             :     bool                                                        m_bPPDThreadRunning;
      60             : 
      61           0 :     struct PendingJob
      62             :     {
      63             :         OUString printerName;
      64             :         OUString jobTitle;
      65             :         JobData jobData;
      66             :         bool banner;
      67             :         OUString faxNumber;
      68             :         OString file;
      69           0 :         PendingJob( const OUString& printerName_, const OUString& jobTitle_, const JobData& jobData_,
      70             :             bool banner_, const OUString& faxNumber_, const OString& file_ )
      71           0 :             : printerName( printerName_ ), jobTitle( jobTitle_ ), jobData( jobData_ ), banner( banner_ ), faxNumber( faxNumber_ ), file( file_ )
      72           0 :             {}
      73           0 :         PendingJob() : banner( false ) {}
      74             :     };
      75             :     std::list< PendingJob > pendingJobs;
      76             :     bool batchMode;
      77             : 
      78             :     CUPSManager();
      79             :     virtual ~CUPSManager();
      80             : 
      81             :     virtual void initialize() SAL_OVERRIDE;
      82             : 
      83             :     static void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, int& rNumOptions, void** rOptions );
      84             :     void runDests();
      85             :     OString threadedCupsGetPPD(const char* pPrinter);
      86             : 
      87             :     bool processPendingJobs();
      88             :     bool printJobs( const PendingJob& job, const std::vector< OString >& files );
      89             : public:
      90             :     static void runDestThread(void* pMgr);
      91             : 
      92             :     static CUPSManager* tryLoadCUPS();
      93             : 
      94             :     /// wraps cupsGetPPD, so unlink after use !
      95             :     const PPDParser* createCUPSParser( const OUString& rPrinter );
      96             : 
      97             :     const char* authenticateUser( const char* );
      98             : 
      99             :     virtual FILE* startSpool( const OUString& rPrinterName, bool bQuickCommand ) SAL_OVERRIDE;
     100             :     virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString& rFaxNumber ) SAL_OVERRIDE;
     101             :     virtual void setupJobContextData( JobData& rData ) SAL_OVERRIDE;
     102             : 
     103             :     virtual bool startBatchPrint() SAL_OVERRIDE;
     104             :     virtual bool flushBatchPrint() SAL_OVERRIDE;
     105             :     virtual bool supportsBatchPrint() const SAL_OVERRIDE;
     106             : 
     107             :     /// changes the info about a named printer
     108             :     virtual void changePrinterInfo( const OUString& rPrinter, const PrinterInfo& rNewInfo ) SAL_OVERRIDE;
     109             : 
     110             :     /// check if the printer configuration has changed
     111             :     virtual bool checkPrintersChanged( bool bWait ) SAL_OVERRIDE;
     112             : 
     113             :     // members for administration
     114             :     // disable for CUPS
     115             :     virtual bool addPrinter( const OUString& rPrinterName, const OUString& rDriverName ) SAL_OVERRIDE;
     116             :     virtual bool removePrinter( const OUString& rPrinterName, bool bCheckOnly = false ) SAL_OVERRIDE;
     117             :     virtual bool writePrinterConfig() SAL_OVERRIDE;
     118             :     virtual bool setDefaultPrinter( const OUString& rPrinterName ) SAL_OVERRIDE;
     119             : };
     120             : 
     121             : } // namespace psp
     122             : 
     123             : #endif
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11