23 #ifndef _TelepathyQt_method_invocation_context_h_HEADER_GUARD_
24 #define _TelepathyQt_method_invocation_context_h_HEADER_GUARD_
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 namespace MethodInvocationContextTypes
46 typename T1,
typename T2,
typename T3,
typename T4,
47 typename T5,
typename T6,
typename T7,
typename T8>
50 typedef Select<Index - 1, T2, T3, T4, T5, T6, T7, T8, Nil> Next;
51 typedef typename Next::Type Type;
53 template<
typename T1,
typename T2,
typename T3,
typename T4,
54 typename T5,
typename T6,
typename T7,
typename T8>
55 struct Select<0, T1, T2, T3, T4, T5, T6, T7, T8>
60 template<
typename T1,
typename T2,
typename T3,
typename T4,
61 typename T5,
typename T6,
typename T7,
typename T8>
64 typedef ForEach<T2, T3, T4, T5, T6, T7, T8, Nil> Next;
65 enum { Total = Next::Total + 1 };
68 struct ForEach<Nil, Nil, Nil, Nil, Nil, Nil, Nil, Nil>
77 template<
typename T1 = MethodInvocationContextTypes::Nil,
typename T2 = MethodInvocationContextTypes::Nil,
78 typename T3 = MethodInvocationContextTypes::Nil,
typename T4 = MethodInvocationContextTypes::Nil,
79 typename T5 = MethodInvocationContextTypes::Nil,
typename T6 = MethodInvocationContextTypes::Nil,
80 typename T7 = MethodInvocationContextTypes::Nil,
typename T8 = MethodInvocationContextTypes::Nil>
83 #ifndef DOXYGEN_SHOULD_SKIP_THIS
85 struct Select : MethodInvocationContextTypes::Select<Index, T1, T2, T3, T4, T5, T6, T7, T8>
89 typedef MethodInvocationContextTypes::ForEach<T1, T2, T3, T4, T5, T6, T7, T8> ForEach;
90 enum { Count = ForEach::Total };
95 : mBus(bus), mMessage(message), mFinished(false)
97 mMessage.setDelayedReply(
true);
108 bool isError()
const {
return !mErrorName.isEmpty(); }
112 void setFinished(
const T1 &t1 = T1(),
const T2 &t2 = T2(),
const T3 &t3 = T3(),
113 const T4 &t4 = T4(),
const T5 &t5 = T5(),
const T6 &t6 = T6(),
114 const T7 &t7 = T7(),
const T8 &t8 = T8())
122 setReplyValue(0, qVariantFromValue(t1));
123 setReplyValue(1, qVariantFromValue(t2));
124 setReplyValue(2, qVariantFromValue(t3));
125 setReplyValue(3, qVariantFromValue(t4));
126 setReplyValue(4, qVariantFromValue(t5));
127 setReplyValue(5, qVariantFromValue(t6));
128 setReplyValue(6, qVariantFromValue(t7));
129 setReplyValue(7, qVariantFromValue(t8));
131 if (mReply.isEmpty()) {
132 mBus.send(mMessage.createReply());
134 mBus.send(mMessage.createReply(mReply));
148 if (errorName.isEmpty()) {
149 mErrorName = QLatin1String(
"org.freedesktop.Telepathy.Qt.ErrorHandlingError");
155 mBus.send(mMessage.createErrorReply(mErrorName, mErrorMessage));
159 template<
int Index>
inline
162 Q_ASSERT(Index >= 0 && Index < Count);
163 return qdbus_cast<
typename Select<Index>::Type>(mReply.value(Index));
172 void setReplyValue(
int index, const QVariant &value)
174 if (index >= Count) {
177 mReply.insert(index, value);
180 QDBusConnection mBus;
181 QDBusMessage mMessage;
183 QList<QVariant> mReply;
185 QString mErrorMessage;
190 Q_DECLARE_METATYPE(Tp::MethodInvocationContextTypes::Nil)
The MethodInvocationContext class provides a way for the service implementation to respond to method ...
Definition: method-invocation-context.h:81
bool isFinished() const
Definition: method-invocation-context.h:107
void setFinishedWithError(const QString &errorName, const QString &errorMessage)
Definition: method-invocation-context.h:139
void setFinished(const T1 &t1=T1(), const T2 &t2=T2(), const T3 &t3=T3(), const T4 &t4=T4(), const T5 &t5=T5(), const T6 &t6=T6(), const T7 &t7=T7(), const T8 &t8=T8())
Definition: method-invocation-context.h:112
virtual void onFinished()
Definition: method-invocation-context.h:167
The RefCounted class is a base class for shared objects used by SharedPtr.
Definition: shared-ptr.h:42
Select< Index >::Type argumentAt() const
Definition: method-invocation-context.h:160
QString errorMessage() const
Definition: method-invocation-context.h:110
MethodInvocationContext(const QDBusConnection &bus, const QDBusMessage &message)
Definition: method-invocation-context.h:94
QString errorName() const
Definition: method-invocation-context.h:109
bool isError() const
Definition: method-invocation-context.h:108
virtual ~MethodInvocationContext()
Definition: method-invocation-context.h:100