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     void forceCurrentStatus(uint currentStatus);
00087 
00088     QStringList interfaces() const;
00089     void setInterfaces(const QStringList &interfaces);
00090 
00091     Features requestedFeatures() const;
00092     Features actualFeatures() const;
00093     Features missingFeatures() const;
00094 
00095     bool isReady(const Feature &feature,
00096             QString *errorName = 0, QString *errorMessage = 0) const;
00097     bool isReady(const Features &features,
00098             QString *errorName = 0, QString *errorMessage = 0) const;
00099     PendingReady *becomeReady(const Features &requestedFeatures);
00100 
00101     void setIntrospectCompleted(const Feature &feature, bool success,
00102             const QString &errorName = QString(),
00103             const QString &errorMessage = QString());
00104     void setIntrospectCompleted(const Feature &feature, bool success,
00105             const QDBusError &error);
00106 
00107 Q_SIGNALS:
00108     void statusReady(uint status);
00109 
00110 private Q_SLOTS:
00111     void iterateIntrospection();
00112 
00113     void onProxyInvalidated(Tp::DBusProxy *proxy,
00114         const QString &errorName, const QString &errorMessage);
00115     void onOperationFinished(Tp::PendingOperation *op);
00116     void onOperationDestroyed(QObject *obj);
00117 
00118 private:
00119     struct Private;
00120     friend struct Private;
00121     Private *mPriv;
00122 };
00123 
00124 } // Tp
00125 
00126 #endif


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