merge the formfield patch from ooo-build
[ooovba.git] / vcl / inc / cupsmgr.hxx
blobe20694b3f9313ae3ebe05f0c1a69bd9b4db6bb69
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cupsmgr.hxx,v $
10 * $Revision: 1.11 $
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"
39 namespace psp
42 class CUPSWrapper;
43 class PPDParser;
45 struct FPtrHash
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;
55 int m_nDests;
56 void* m_pDests;
57 bool m_bNewDests;
58 std::hash_map< rtl::OUString, int, rtl::OUStringHash > m_aCUPSDestMap;
60 std::hash_map< rtl::OUString, PPDContext, rtl::OUStringHash > m_aDefaultContexts;
62 rtl::OString m_aUser;
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;
77 void runDests();
78 public:
79 // public for stub
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)
100 // disable for CUPS
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;
109 } // namespace psp
111 #endif