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


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.6.5