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


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.5.8