xref: /glogg/src/dbusexternalcom.h (revision e07da50a2e1900f7a64fbc97093e11798cdaefb4)
1557fb9d8SNicolas Bonnefon /*
2557fb9d8SNicolas Bonnefon  * Copyright (C) 2014 Nicolas Bonnefon and other contributors
3557fb9d8SNicolas Bonnefon  *
4557fb9d8SNicolas Bonnefon  * This file is part of glogg.
5557fb9d8SNicolas Bonnefon  *
6557fb9d8SNicolas Bonnefon  * glogg is free software: you can redistribute it and/or modify
7557fb9d8SNicolas Bonnefon  * it under the terms of the GNU General Public License as published by
8557fb9d8SNicolas Bonnefon  * the Free Software Foundation, either version 3 of the License, or
9557fb9d8SNicolas Bonnefon  * (at your option) any later version.
10557fb9d8SNicolas Bonnefon  *
11557fb9d8SNicolas Bonnefon  * glogg is distributed in the hope that it will be useful,
12557fb9d8SNicolas Bonnefon  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13557fb9d8SNicolas Bonnefon  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14557fb9d8SNicolas Bonnefon  * GNU General Public License for more details.
15557fb9d8SNicolas Bonnefon  *
16557fb9d8SNicolas Bonnefon  * You should have received a copy of the GNU General Public License
17557fb9d8SNicolas Bonnefon  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18557fb9d8SNicolas Bonnefon  */
19557fb9d8SNicolas Bonnefon 
20557fb9d8SNicolas Bonnefon #ifndef DBUSEXTERNALCOM_H
21557fb9d8SNicolas Bonnefon #define DBUSEXTERNALCOM_H
22557fb9d8SNicolas Bonnefon 
23557fb9d8SNicolas Bonnefon #include "externalcom.h"
24557fb9d8SNicolas Bonnefon 
25557fb9d8SNicolas Bonnefon #include <memory>
26557fb9d8SNicolas Bonnefon #include <QtDBus/QtDBus>
27557fb9d8SNicolas Bonnefon 
28557fb9d8SNicolas Bonnefon // An implementation of ExternalInstance using D-Bus via Qt
29557fb9d8SNicolas Bonnefon class DBusExternalInstance : public ExternalInstance {
30557fb9d8SNicolas Bonnefon   public:
31557fb9d8SNicolas Bonnefon     DBusExternalInstance();
32557fb9d8SNicolas Bonnefon     ~DBusExternalInstance() {}
33557fb9d8SNicolas Bonnefon 
34557fb9d8SNicolas Bonnefon     virtual void loadFile( const std::string& file_name ) const;
35*e07da50aSNicolas Bonnefon     virtual uint32_t getVersion() const;
36557fb9d8SNicolas Bonnefon 
37557fb9d8SNicolas Bonnefon   private:
38557fb9d8SNicolas Bonnefon     std::shared_ptr<QDBusInterface> dbusInterface_;
39557fb9d8SNicolas Bonnefon };
40557fb9d8SNicolas Bonnefon 
41557fb9d8SNicolas Bonnefon // An implementation of ExternalCommunicator using D-Bus via Qt
42557fb9d8SNicolas Bonnefon class DBusExternalCommunicator : public ExternalCommunicator
43557fb9d8SNicolas Bonnefon {
44557fb9d8SNicolas Bonnefon   public:
45557fb9d8SNicolas Bonnefon     // Constructor: initialise the D-Bus connection,
46557fb9d8SNicolas Bonnefon     // can throw if D-Bus is not available
47557fb9d8SNicolas Bonnefon     DBusExternalCommunicator();
48557fb9d8SNicolas Bonnefon     ~DBusExternalCommunicator() {}
49557fb9d8SNicolas Bonnefon 
50*e07da50aSNicolas Bonnefon     virtual void startListening();
51*e07da50aSNicolas Bonnefon 
52557fb9d8SNicolas Bonnefon     virtual ExternalInstance* otherInstance() const;
53557fb9d8SNicolas Bonnefon 
54557fb9d8SNicolas Bonnefon   signals:
55557fb9d8SNicolas Bonnefon     void loadFile( const std::string& file_name );
56557fb9d8SNicolas Bonnefon 
57557fb9d8SNicolas Bonnefon   public slots:
58*e07da50aSNicolas Bonnefon     virtual qint32 version() const;
59557fb9d8SNicolas Bonnefon 
60557fb9d8SNicolas Bonnefon   private:
61557fb9d8SNicolas Bonnefon };
62557fb9d8SNicolas Bonnefon 
63557fb9d8SNicolas Bonnefon #endif
64