1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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_
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.
37 * Constructors + destructor
40 /// Default constructor.
43 /// Primary constructor.
44 UpKpr1Dcop(const UpKpr1Dcop
& parent
, QString interface
);
46 /// Construct from dcop reference.
47 UpKpr1Dcop(QStringList reference
);
50 virtual ~UpKpr1Dcop();
56 /// Find whether its valid.
59 /// Get the dcop reference.
60 const QStringList
& reference() const;
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
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
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
100 QStringList items
= evalList(&error
, tail
);
101 QList
<INTERFACE
> results
;
104 foreach (QString item
, items
)
106 UpKpr1Dcop ref
= dcopRefFromString(item
);
122 /// Is this reference valid?
126 QStringList m_reference
;
130 #endif // _UpKpr1Dcop_h_