Home · All Classes · All Namespaces · Modules · Functions · Files
readiness-helper.h
00001 
00023 #ifndef _TelepathyQt_readiness_helper_h_HEADER_GUARD_
00024 #define _TelepathyQt_readiness_helper_h_HEADER_GUARD_
00025 
00026 #ifndef IN_TP_QT_HEADER
00027 #error IN_TP_QT_HEADER
00028 #endif
00029 
00030 #include <TelepathyQt/Feature>
00031 
00032 #include <QMap>
00033 #include <QSet>
00034 #include <QSharedDataPointer>
00035 #include <QStringList>
00036 #include <QObject>
00037 
00038 class QDBusError;
00039 
00040 namespace Tp
00041 {
00042 
00043 class DBusProxy;
00044 class PendingOperation;
00045 class PendingReady;
00046 class RefCounted;
00047 
00048 class TP_QT_EXPORT ReadinessHelper : public QObject
00049 {
00050     Q_OBJECT
00051     Q_DISABLE_COPY(ReadinessHelper)
00052 
00053 public:
00054     typedef void (*IntrospectFunc)(void *data);
00055 
00056     struct Introspectable {
00057     public:
00058         Introspectable();
00059         Introspectable(const QSet<uint> &makesSenseForStatuses,
00060                 const Features &dependsOnFeatures,
00061                 const QStringList &dependsOnInterfaces,
00062                 IntrospectFunc introspectFunc,
00063                 void *introspectFuncData,
00064                 bool critical = false);
00065         Introspectable(const Introspectable &other);
00066         ~Introspectable();
00067 
00068         Introspectable &operator=(const Introspectable &other);
00069 
00070     private:
00071         friend class ReadinessHelper;
00072 
00073         struct Private;
00074         friend struct Private;
00075         QSharedDataPointer<Private> mPriv;
00076     };
00077     typedef QMap<Feature, Introspectable> Introspectables;
00078 
00079     ReadinessHelper(RefCounted *object,
00080             uint currentStatus = 0,
00081             const Introspectables &introspectables = Introspectables(),
00082             QObject *parent = 0);
00083     ReadinessHelper(DBusProxy *proxy,
00084             uint currentStatus = 0,
00085             const Introspectables &introspectables = Introspectables(),
00086             QObject *parent = 0);
00087     ~ReadinessHelper();
00088 
00089     void addIntrospectables(const Introspectables &introspectables);
00090 
00091     uint currentStatus() const;
00092     void setCurrentStatus(uint currentStatus);
00093     void forceCurrentStatus(uint currentStatus);
00094 
00095     QStringList interfaces() const;
00096     void setInterfaces(const QStringList &interfaces);
00097 
00098     Features requestedFeatures() const;
00099     Features actualFeatures() const;
00100     Features missingFeatures() const;
00101 
00102     bool isReady(const Feature &feature,
00103             QString *errorName = 0, QString *errorMessage = 0) const;
00104     bool isReady(const Features &features,
00105             QString *errorName = 0, QString *errorMessage = 0) const;
00106     PendingReady *becomeReady(const Features &requestedFeatures);
00107 
00108     void setIntrospectCompleted(const Feature &feature, bool success,
00109             const QString &errorName = QString(),
00110             const QString &errorMessage = QString());
00111     void setIntrospectCompleted(const Feature &feature, bool success,
00112             const QDBusError &error);
00113 
00114 Q_SIGNALS:
00115     void statusReady(uint status);
00116 
00117 private Q_SLOTS:
00118     TP_QT_NO_EXPORT void iterateIntrospection();
00119 
00120     TP_QT_NO_EXPORT void onProxyInvalidated(Tp::DBusProxy *proxy,
00121         const QString &errorName, const QString &errorMessage);
00122 
00123 private:
00124     struct Private;
00125     friend struct Private;
00126     Private *mPriv;
00127 };
00128 
00129 } // Tp
00130 
00131 #endif


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.6.1