1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cupsmgr.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _PSPRINT_CUPSMGR_HXX_
32 #define _PSPRINT_CUPSMGR_HXX_
34 #include "vcl/printerinfomanager.hxx"
35 #include "osl/module.h"
36 #include "osl/thread.h"
37 #include "osl/mutex.hxx"
47 size_t operator()(const FILE* pPtr
) const
48 { return (size_t)pPtr
; }
51 class CUPSManager
: public PrinterInfoManager
53 CUPSWrapper
* m_pCUPSWrapper
;
54 std::hash_map
< FILE*, rtl::OString
, FPtrHash
> m_aSpoolFiles
;
58 std::hash_map
< rtl::OUString
, int, rtl::OUStringHash
> m_aCUPSDestMap
;
60 std::hash_map
< rtl::OUString
, PPDContext
, rtl::OUStringHash
> m_aDefaultContexts
;
63 // this is a security risk, but the CUPS API demands
64 // to deliver a pointer to a static buffer containing
65 // the password, so this cannot be helped
66 rtl::OString m_aPassword
;
68 osl::Mutex m_aCUPSMutex
;
69 oslThread m_aDestThread
;
71 CUPSManager( CUPSWrapper
* );
72 virtual ~CUPSManager();
74 virtual void initialize();
76 void getOptionsFromDocumentSetup( const JobData
& rJob
, int& rNumOptions
, void** rOptions
) const;
80 static void runDestThread(void* pMgr
);
82 static CUPSManager
* tryLoadCUPS();
84 const PPDParser
* createCUPSParser( const rtl::OUString
& rPrinter
);
85 // wraps cupsGetPPD, so unlink after use !
87 const char* authenticateUser( const char* );
89 virtual FILE* startSpool( const rtl::OUString
& rPrinterName
, bool bQuickCommand
);
90 virtual int endSpool( const rtl::OUString
& rPrinterName
, const rtl::OUString
& rJobTitle
, FILE* pFile
, const JobData
& rDocumentJobData
);
91 virtual void setupJobContextData( JobData
& rData
);
93 // changes the info about a named printer
94 virtual void changePrinterInfo( const ::rtl::OUString
& rPrinter
, const PrinterInfo
& rNewInfo
);
96 // check if the printer configuration has changed
97 virtual bool checkPrintersChanged( bool bWait
);
99 // members for administration (->padmin)
101 virtual bool addPrinter( const rtl::OUString
& rPrinterName
, const ::rtl::OUString
& rDriverName
);
102 virtual bool removePrinter( const rtl::OUString
& rPrinterName
, bool bCheckOnly
= false );
103 virtual bool writePrinterConfig();
104 virtual bool setDefaultPrinter( const rtl::OUString
& rPrinterName
);
106 virtual bool addOrRemovePossible() const;