xref: /glogg/src/dbusexternalcom.h (revision 557fb9d8925f3772c017d921d356ab742ec51021)
1*557fb9d8SNicolas Bonnefon /*
2*557fb9d8SNicolas Bonnefon  * Copyright (C) 2014 Nicolas Bonnefon and other contributors
3*557fb9d8SNicolas Bonnefon  *
4*557fb9d8SNicolas Bonnefon  * This file is part of glogg.
5*557fb9d8SNicolas Bonnefon  *
6*557fb9d8SNicolas Bonnefon  * glogg is free software: you can redistribute it and/or modify
7*557fb9d8SNicolas Bonnefon  * it under the terms of the GNU General Public License as published by
8*557fb9d8SNicolas Bonnefon  * the Free Software Foundation, either version 3 of the License, or
9*557fb9d8SNicolas Bonnefon  * (at your option) any later version.
10*557fb9d8SNicolas Bonnefon  *
11*557fb9d8SNicolas Bonnefon  * glogg is distributed in the hope that it will be useful,
12*557fb9d8SNicolas Bonnefon  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*557fb9d8SNicolas Bonnefon  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*557fb9d8SNicolas Bonnefon  * GNU General Public License for more details.
15*557fb9d8SNicolas Bonnefon  *
16*557fb9d8SNicolas Bonnefon  * You should have received a copy of the GNU General Public License
17*557fb9d8SNicolas Bonnefon  * along with glogg.  If not, see <http://www.gnu.org/licenses/>.
18*557fb9d8SNicolas Bonnefon  */
19*557fb9d8SNicolas Bonnefon 
20*557fb9d8SNicolas Bonnefon #ifndef DBUSEXTERNALCOM_H
21*557fb9d8SNicolas Bonnefon #define DBUSEXTERNALCOM_H
22*557fb9d8SNicolas Bonnefon 
23*557fb9d8SNicolas Bonnefon #include "externalcom.h"
24*557fb9d8SNicolas Bonnefon 
25*557fb9d8SNicolas Bonnefon #include <memory>
26*557fb9d8SNicolas Bonnefon #include <QtDBus/QtDBus>
27*557fb9d8SNicolas Bonnefon 
28*557fb9d8SNicolas Bonnefon // An implementation of ExternalInstance using D-Bus via Qt
29*557fb9d8SNicolas Bonnefon class DBusExternalInstance : public ExternalInstance {
30*557fb9d8SNicolas Bonnefon   public:
31*557fb9d8SNicolas Bonnefon     DBusExternalInstance();
32*557fb9d8SNicolas Bonnefon     ~DBusExternalInstance() {}
33*557fb9d8SNicolas Bonnefon 
34*557fb9d8SNicolas Bonnefon     virtual void loadFile( const std::string& file_name ) const;
35*557fb9d8SNicolas Bonnefon 
36*557fb9d8SNicolas Bonnefon   private:
37*557fb9d8SNicolas Bonnefon     std::shared_ptr<QDBusInterface> dbusInterface_;
38*557fb9d8SNicolas Bonnefon };
39*557fb9d8SNicolas Bonnefon 
40*557fb9d8SNicolas Bonnefon // An implementation of ExternalCommunicator using D-Bus via Qt
41*557fb9d8SNicolas Bonnefon class DBusExternalCommunicator : public ExternalCommunicator
42*557fb9d8SNicolas Bonnefon {
43*557fb9d8SNicolas Bonnefon   public:
44*557fb9d8SNicolas Bonnefon     // Constructor: initialise the D-Bus connection,
45*557fb9d8SNicolas Bonnefon     // can throw if D-Bus is not available
46*557fb9d8SNicolas Bonnefon     DBusExternalCommunicator();
47*557fb9d8SNicolas Bonnefon     ~DBusExternalCommunicator() {}
48*557fb9d8SNicolas Bonnefon 
49*557fb9d8SNicolas Bonnefon     virtual ExternalInstance* otherInstance() const;
50*557fb9d8SNicolas Bonnefon 
51*557fb9d8SNicolas Bonnefon   signals:
52*557fb9d8SNicolas Bonnefon     void loadFile( const std::string& file_name );
53*557fb9d8SNicolas Bonnefon 
54*557fb9d8SNicolas Bonnefon   public slots:
55*557fb9d8SNicolas Bonnefon     QString version() const;
56*557fb9d8SNicolas Bonnefon 
57*557fb9d8SNicolas Bonnefon   private:
58*557fb9d8SNicolas Bonnefon };
59*557fb9d8SNicolas Bonnefon 
60*557fb9d8SNicolas Bonnefon #endif
61