Basic openoffice.org control, and listening for new presentation documents, still...
[kworship.git] / unipresent / kpresenter1 / UpKpr1Dcop.h
blobe7f913b72b61afbefd18651f0ea6b3cc1236deae
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _UpKpr1Dcop_h_
21 #define _UpKpr1Dcop_h_
23 /**
24 * @file UpKpr1Dcop.h
25 * @brief DCOP interface using command line tool.
26 * @author James Hogan <james@albanarts.com>
29 #include <QStringList>
31 /// DCOP interface using command line tool.
32 class UpKpr1Dcop
34 public:
37 * Constructors + destructor
40 /// Default constructor.
41 UpKpr1Dcop();
43 /// Primary constructor.
44 UpKpr1Dcop(const UpKpr1Dcop& parent, QString interface);
46 /// Construct from dcop reference.
47 UpKpr1Dcop(QStringList reference);
49 /// Destructor.
50 virtual ~UpKpr1Dcop();
53 * Main interface
56 /// Find whether its valid.
57 bool isValid() const;
59 /// Get the dcop reference.
60 const QStringList& reference() const;
63 * Helper methods
66 /// Get the result of a dcop query on this interface.
67 QString eval(bool* const err = 0, QStringList tail = QStringList()) const;
69 /// Perform a dcop query on this interface.
70 QString eval(QStringList tail) const
72 return eval(0, tail);
75 /// Get the resulting list of strings from a dcop query
76 QStringList evalList(bool* const err = 0, QStringList tail = QStringList()) const;
78 /// Get the resulting integer from a dcop query
79 int evalInt(bool* const err, QStringList tail) const;
81 /// Get the resulting integer from a dcop query
82 int evalInt(QStringList tail, int defaultValue) const
84 bool err;
85 int result = evalInt(&err, tail);
86 return (err ? defaultValue : result);
89 /// Get a dcop reference from a string.
90 static UpKpr1Dcop dcopRefFromString(QString input);
92 /// Get a single dcop reference from a dcop query.
93 UpKpr1Dcop evalRef(QStringList tail) const;
95 /// Get a list of dcop references from a dcop query.
96 template <typename INTERFACE>
97 QList<INTERFACE> evalRefs(QStringList tail) const
99 bool error;
100 QStringList items = evalList(&error, tail);
101 QList<INTERFACE> results;
102 if (!error)
104 foreach (QString item, items)
106 UpKpr1Dcop ref = dcopRefFromString(item);
107 if (ref.isValid())
109 results << ref;
113 return results;
116 private:
119 * Variables
122 /// Is this reference valid?
123 bool m_valid;
125 /// DCOP reference.
126 QStringList m_reference;
130 #endif // _UpKpr1Dcop_h_