bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / unx / cpdmgr.hxx
blob6449355a1501d390b0d6fffa745e4fc52abdafa3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_UNX_CPDMGR_HXX
21 #define INCLUDED_VCL_INC_UNX_CPDMGR_HXX
23 #include <config_dbus.h>
24 #include <config_gio.h>
26 #if ENABLE_DBUS && ENABLE_GIO
27 #include <gio/gio.h>
28 #else
29 typedef struct _GDBusProxy GDBusProxy;
30 typedef struct _GDBusConnection GDBusConnection;
31 #endif
33 #include <printerinfomanager.hxx>
34 #include "cupsmgr.hxx"
36 #define BACKEND_DIR "/usr/share/print-backends"
37 #define FRONTEND_INTERFACE "/usr/share/dbus-1/interfaces/org.openprinting.Frontend.xml"
38 #define BACKEND_INTERFACE "/usr/share/dbus-1/interfaces/org.openprinting.Backend.xml"
40 namespace psp
43 class PPDParser;
45 struct CPDPrinter
47 const char* id;
48 const char* name;
49 const char* info;
50 const char* location;
51 const char* make_and_model;
52 const char* printer_state;
53 const char* backend_name;
54 bool is_accepting_jobs;
55 GDBusProxy* backend;
58 class CPDManager : public PrinterInfoManager
60 #if ENABLE_DBUS && ENABLE_GIO
61 GDBusConnection * m_pConnection = nullptr;
62 bool m_aPrintersChanged = true;
63 std::vector<std::pair<std::string, gchar*>> m_tBackends;
64 std::unordered_map< std::string, GDBusProxy * > m_pBackends;
65 std::unordered_map< FILE*, OString, FPtrHash > m_aSpoolFiles;
66 std::unordered_map< OUString, CPDPrinter * > m_aCPDDestMap;
67 std::unordered_map< OUString, PPDContext > m_aDefaultContexts;
68 #endif
69 CPDManager();
70 // Function called when CPDManager is destroyed
71 virtual ~CPDManager() override;
73 virtual void initialize() override;
75 #if ENABLE_DBUS && ENABLE_GIO
76 static void onNameAcquired(GDBusConnection *connection, const gchar* name, gpointer user_data);
77 static void onNameLost (GDBusConnection *, const gchar *name, gpointer);
78 static void printerAdded (GDBusConnection *connection,
79 const gchar *sender_name,
80 const gchar *object_path,
81 const gchar *interface_name,
82 const gchar *signal_name,
83 GVariant *parameters,
84 gpointer user_data);
85 static void printerRemoved (GDBusConnection *connection,
86 const gchar *sender_name,
87 const gchar *object_path,
88 const gchar *interface_name,
89 const gchar *signal_name,
90 GVariant *parameters,
91 gpointer user_data);
93 static void getOptionsFromDocumentSetup( const JobData& rJob, bool bBanner, const OString& rJobName, int& rNumOptions, GVariant **arr );
94 #endif
96 public:
97 #if ENABLE_DBUS && ENABLE_GIO
98 // Functions involved in initialization
99 GDBusProxy* getProxy(const std::string& target);
100 void addBackend( std::pair< std::string, GDBusProxy * > pair );
101 void addTempBackend(const std::pair<std::string, gchar*>& pair);
102 std::vector<std::pair<std::string, gchar*>> const & getTempBackends() const;
103 void addNewPrinter( const OUString&, const OUString&, CPDPrinter * );
104 #endif
106 // Create CPDManager
107 static CPDManager* tryLoadCPD();
109 // Create a PPDParser for CPD Printers
110 const PPDParser* createCPDParser( const OUString& rPrinter );
112 // Functions related to printing
113 virtual FILE* startSpool( const OUString& rPrinterName, bool bQuickCommand ) override;
114 virtual bool endSpool( const OUString& rPrinterName, const OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData, bool bBanner, const OUString& rFaxNumber ) override;
115 virtual void setupJobContextData( JobData& rData ) override;
117 // check if the printer configuration has changed
118 virtual bool checkPrintersChanged( bool bWait ) override;
121 } // namespace psp
123 #endif
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */