00001 /* 00002 * Copyright (C) 2008 Nokia Corporation. 00003 * 00004 * Contact: Marius Vollmer <marius.vollmer@nokia.com> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * version 2.1 as published by the Free Software Foundation. 00009 * 00010 * This library is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00018 * 02110-1301 USA 00019 * 00020 */ 00021 00022 #ifndef INFOBACKEND_H 00023 #define INFOBACKEND_H 00024 00025 #include <QVariant> 00026 #include <QStringList> 00027 #include <QObject> 00028 #include "contextproviderinfo.h" 00029 #include "contexttypeinfo.h" 00030 00031 #define BACKEND_COMPATIBILITY_NAMESPACE "http://contextkit.freedesktop.org/Provider" 00032 00033 class InfoBackend : public QObject 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 00039 static InfoBackend* instance(const QString &backendName = ""); 00040 static void destroyInstance(); 00041 00043 virtual QString name() const = 0; 00044 00046 virtual QStringList listKeys() const = 0; 00047 00049 virtual ContextTypeInfo typeInfoForKey(QString key) const = 0; 00050 00052 virtual QString docForKey(QString key) const = 0; 00053 00055 virtual bool keyDeclared(QString key) const = 0; 00056 00058 virtual bool keyDeprecated(QString key) const = 0; 00059 00061 virtual const QList<ContextProviderInfo> providersForKey(QString key) const = 0; 00062 00063 Q_SIGNALS: 00065 void keysChanged(const QStringList& currentKeys); 00066 00068 void keysAdded(const QStringList& newKeys); 00069 00071 void keysRemoved(const QStringList& removedKeys); 00072 00074 void keyChanged(const QString& key); 00075 00077 void listChanged(); 00078 00079 protected: 00080 virtual void connectNotify(const char *signal); 00081 virtual void disconnectNotify(const char *signal); 00082 00083 private: 00084 int connectCount; 00085 00086 InfoBackend(QObject *parent = 0); 00087 00089 InfoBackend(const InfoBackend&); 00090 00091 void checkAndEmitKeysAdded(const QStringList ¤tKeys, const QStringList &oldKeys); 00092 void checkAndEmitKeysRemoved(const QStringList ¤tKeys, const QStringList &oldKeys); 00093 void checkAndEmitKeyChanged(const QStringList ¤tKeys, const QStringList &oldKeys); 00094 00096 InfoBackend& operator=(const InfoBackend&); 00097 00098 static InfoBackend* backendInstance; 00099 00100 friend class InfoXmlBackend; 00101 friend class InfoCdbBackend; 00102 friend class InfoTestBackend; 00103 friend class InfoXmlBackendUnitTest; 00104 friend class InfoCdbBackendUnitTest; 00105 friend class InfoBackendUnitTest; 00106 00107 }; 00108 00109 #endif // INFOBACKEND_H