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_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/Feature>
00030 
00031 #include <QMap>
00032 #include <QSet>
00033 #include <QStringList>
00034 
00035 class QDBusError;
00036 
00037 namespace Tp
00038 {
00039 
00040 class DBusProxy;
00041 class PendingOperation;
00042 class PendingReady;
00043 
00044 class ReadinessHelper : public QObject
00045 {
00046     Q_OBJECT
00047 
00048 public:
00049     typedef void (*IntrospectFunc)(void *data);
00050 
00051     struct Introspectable {
00052     public:
00053         Introspectable()
00054             : introspectFunc(0),
00055               introspectFuncData(0)
00056         {
00057         }
00058 
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             : makesSenseForStatuses(makesSenseForStatuses),
00066               dependsOnFeatures(dependsOnFeatures),
00067               dependsOnInterfaces(dependsOnInterfaces),
00068               introspectFunc(introspectFunc),
00069               introspectFuncData(introspectFuncData),
00070               critical(critical)
00071         {
00072         }
00073 
00074     private:
00075         friend class ReadinessHelper;
00076 
00077         QSet<uint> makesSenseForStatuses;
00078         Features dependsOnFeatures;
00079         QStringList dependsOnInterfaces;
00080         IntrospectFunc introspectFunc;
00081         void *introspectFuncData;
00082         bool critical;
00083     };
00084     typedef QMap<Feature, Introspectable> Introspectables;
00085 
00086     ReadinessHelper(QObject *object,
00087             uint currentStatus = 0,
00088             const Introspectables &introspectables = Introspectables(),
00089             QObject *parent = 0);
00090     ~ReadinessHelper();
00091 
00092     void addIntrospectables(const Introspectables &introspectables);
00093 
00094     uint currentStatus() const;
00095     void setCurrentStatus(uint currentStatus);
00096 
00097     QStringList interfaces() const;
00098     void setInterfaces(const QStringList &interfaces);
00099 
00100     Features requestedFeatures() const;
00101     Features actualFeatures() const;
00102     Features missingFeatures() const;
00103 
00104     bool isReady(const Feature &feature,
00105             QString *errorName = 0, QString *errorMessage = 0) const;
00106     bool isReady(const Features &features,
00107             QString *errorName = 0, QString *errorMessage = 0) const;
00108     PendingReady *becomeReady(const Features &requestedFeatures);
00109 
00110     void setIntrospectCompleted(const Feature &feature, bool success,
00111             const QString &errorName = QString(),
00112             const QString &errorMessage = QString());
00113     void setIntrospectCompleted(const Feature &feature, bool success,
00114             const QDBusError &error);
00115 
00116 Q_SIGNALS:
00117     void statusReady(uint status);
00118 
00119 private Q_SLOTS:
00120     void iterateIntrospection();
00121 
00122     void onProxyInvalidated(Tp::DBusProxy *proxy,
00123         const QString &errorName, const QString &errorMessage);
00124     void onOperationFinished(Tp::PendingOperation *op);
00125     void onOperationDestroyed(QObject *obj);
00126 
00127 private:
00128     struct Private;
00129     friend struct Private;
00130     Private *mPriv;
00131 };
00132 
00133 } // Tp
00134 
00135 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.1.8