TelepathyQt4: readiness-helper.h Source File

| Home · All Classes · All Namespaces · Modules · Functions · Files

# readiness-helper.h

    00001 /*
    00002  * This file is part of TelepathyQt4
    00003  *
    00004  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
    00005  * Copyright (C) 2009 Nokia Corporation
    00006  *
    00007  * This library is free software; you can redistribute it and/or
    00008  * modify it under the terms of the GNU Lesser General Public
    00009  * License as published by the Free Software Foundation; either
    00010  * version 2.1 of the License, or (at your option) any later version.
    00011  *
    00012  * This library is distributed in the hope that it will be useful,
    00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015  * Lesser General Public License for more details.
    00016  *
    00017  * You should have received a copy of the GNU Lesser General Public
    00018  * License along with this library; if not, write to the Free Software
    00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00020  */
    00021
    00022 #ifndef _TelepathyQt4_readiness_helper_h_HEADER_GUARD_
    00023 #define _TelepathyQt4_readiness_helper_h_HEADER_GUARD_
    00024
    00025 #ifndef IN_TELEPATHY_QT4_HEADER
    00026 #error IN_TELEPATHY_QT4_HEADER
    00027 #endif
    00028
    00029 #include <TelepathyQt4/Feature>
    00030
    00031 #include <QMap>
    00032 #include <QSet>
    00033 #include <QSharedDataPointer>
    00034 #include <QStringList>
    00035
    00036 class QDBusError;
    00037
    00038 namespace Tp
    00039 {
    00040
    00041 class DBusProxy;
    00042 class PendingOperation;
    00043 class PendingReady;
    00044
    00045 class TELEPATHY_QT4_EXPORT ReadinessHelper : public QObject
    00046 {
    00047     Q_OBJECT
    00048     Q_DISABLE_COPY(ReadinessHelper)
    00049
    00050 public:
    00051     typedef void (*IntrospectFunc)(void *data);
    00052
    00053     struct Introspectable {
    00054     public:
    00055         Introspectable();
    00056         Introspectable(const QSet<uint> &makesSenseForStatuses,
    00057                 const Features &dependsOnFeatures,
    00058                 const QStringList &dependsOnInterfaces,
    00059                 IntrospectFunc introspectFunc,
    00060                 void *introspectFuncData,
    00061                 bool critical = false);
    00062         Introspectable(const Introspectable &other);
    00063         ~Introspectable();
    00064
    00065         Introspectable &operator=(const Introspectable &other);
    00066
    00067     private:
    00068         friend class ReadinessHelper;
    00069
    00070         struct Private;
    00071         friend struct Private;
    00072         QSharedDataPointer<Private> mPriv;
    00073     };
    00074     typedef QMap<Feature, Introspectable> Introspectables;
    00075
    00076     ReadinessHelper(QObject *object,
    00077             uint currentStatus = 0,
    00078             const Introspectables &introspectables = Introspectables(),
    00079             QObject *parent = 0);
    00080     ~ReadinessHelper();
    00081
    00082     void addIntrospectables(const Introspectables &introspectables);
    00083
    00084     uint currentStatus() const;
    00085     void setCurrentStatus(uint currentStatus);
    00086
    00087     QStringList interfaces() const;
    00088     void setInterfaces(const QStringList &interfaces);
    00089
    00090     Features requestedFeatures() const;
    00091     Features actualFeatures() const;
    00092     Features missingFeatures() const;
    00093
    00094     bool isReady(const Feature &feature,
    00095             QString *errorName = 0, QString *errorMessage = 0) const;
    00096     bool isReady(const Features &features,
    00097             QString *errorName = 0, QString *errorMessage = 0) const;
    00098     PendingReady *becomeReady(const Features &requestedFeatures);
    00099
    00100     void setIntrospectCompleted(const Feature &feature, bool success,
    00101             const QString &errorName = QString(),
    00102             const QString &errorMessage = QString());
    00103     void setIntrospectCompleted(const Feature &feature, bool success,
    00104             const QDBusError &error);
    00105
    00106 Q_SIGNALS:
    00107     void statusReady(uint status);
    00108
    00109 private Q_SLOTS:
    00110     void iterateIntrospection();
    00111
    00112     void onProxyInvalidated(Tp::DBusProxy *proxy,
    00113         const QString &errorName, const QString &errorMessage);
    00114     void onOperationFinished(Tp::PendingOperation *op);
    00115     void onOperationDestroyed(QObject *obj);
    00116
    00117 private:
    00118     struct Private;
    00119     friend struct Private;
    00120     Private *mPriv;
    00121 };
    00122
    00123 } // Tp
    00124
    00125 #endif