00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _TelepathyQt4_cli_readiness_helper_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_readiness_helper_h_HEADER_GUARD_
00024
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028
00029 #include <TelepathyQt4/Client/Feature>
00030
00031 #include <QMap>
00032 #include <QSet>
00033 #include <QStringList>
00034
00035 class QDBusError;
00036
00037 namespace Telepathy
00038 {
00039 namespace Client
00040 {
00041
00042 class DBusProxy;
00043 class PendingReady;
00044
00045 class ReadinessHelper : public QObject
00046 {
00047 Q_OBJECT
00048
00049 public:
00050 typedef void (*IntrospectFunc)(void *data);
00051
00052 struct Introspectable {
00053 public:
00054 Introspectable()
00055 : introspectFunc(0),
00056 introspectFuncData(0)
00057 {
00058 }
00059
00060 Introspectable(const QSet<uint> &makesSenseForStatuses,
00061 const Features &dependsOnFeatures,
00062 const QStringList &dependsOnInterfaces,
00063 IntrospectFunc introspectFunc,
00064 void *introspectFuncData,
00065 bool critical = false)
00066 : makesSenseForStatuses(makesSenseForStatuses),
00067 dependsOnFeatures(dependsOnFeatures),
00068 dependsOnInterfaces(dependsOnInterfaces),
00069 introspectFunc(introspectFunc),
00070 introspectFuncData(introspectFuncData),
00071 critical(critical)
00072 {
00073 }
00074
00075 private:
00076 friend class ReadinessHelper;
00077
00078 QSet<uint> makesSenseForStatuses;
00079 Features dependsOnFeatures;
00080 QStringList dependsOnInterfaces;
00081 IntrospectFunc introspectFunc;
00082 void *introspectFuncData;
00083 bool critical;
00084 };
00085 typedef QMap<Feature, Introspectable> Introspectables;
00086
00087 ReadinessHelper(QObject *object,
00088 uint currentStatus = 0,
00089 const Introspectables &introspectables = Introspectables(),
00090 QObject *parent = 0);
00091 ~ReadinessHelper();
00092
00093 void addIntrospectables(const Introspectables &introspectables);
00094
00095 uint currentStatus() const;
00096 void setCurrentStatus(uint currentStatus);
00097
00098 QStringList interfaces() const;
00099 void setInterfaces(const QStringList &interfaces);
00100
00101 Features requestedFeatures() const;
00102 Features actualFeatures() const;
00103 Features missingFeatures() const;
00104
00105 bool isReady(const Feature &feature,
00106 QString *errorName = 0, QString *errorMessage = 0) const;
00107 bool isReady(const Features &features,
00108 QString *errorName = 0, QString *errorMessage = 0) const;
00109 PendingReady *becomeReady(const Features &requestedFeatures);
00110
00111 void setIntrospectCompleted(const Feature &feature, bool success,
00112 const QString &errorName = QString(),
00113 const QString &errorMessage = QString());
00114 void setIntrospectCompleted(const Feature &feature, bool success,
00115 const QDBusError &error);
00116
00117 Q_SIGNALS:
00118 void statusReady(uint status);
00119
00120 private Q_SLOTS:
00121 void iterateIntrospection();
00122
00123 void onProxyInvalidated(Telepathy::Client::DBusProxy *proxy,
00124 const QString &errorName, const QString &errorMessage);
00125
00126 private:
00127 struct Private;
00128 friend struct Private;
00129 Private *mPriv;
00130 };
00131
00132 }
00133 }
00134
00135 #endif