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 INFOCDBBACKEND_H 00023 #define INFOCDBBACKEND_H 00024 00025 #include <QFileSystemWatcher> 00026 #include <QStringList> 00027 #include <QObject> 00028 #include <QString> 00029 #include "cdbreader.h" 00030 #include "infobackend.h" 00031 #include "contextproviderinfo.h" 00032 00033 class InfoCdbBackend : public InfoBackend 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 explicit InfoCdbBackend(QObject *parent = 0); 00039 ~InfoCdbBackend(); 00040 virtual QString name() const; 00041 virtual QStringList listKeys() const; 00042 virtual QString docForKey(QString key) const; 00043 virtual bool keyDeclared(QString key) const; 00044 virtual bool keyDeprecated(QString key) const; 00045 virtual const QList<ContextProviderInfo> providersForKey(QString key) const; 00046 virtual ContextTypeInfo typeInfoForKey(QString key) const; 00047 00048 static QString databaseDirectory(); 00049 static QString databasePath(); 00050 static bool databaseExists(); 00051 00052 private: 00053 QFileSystemWatcher *watcher; 00054 CDBReader reader; 00055 bool databaseCompatible; 00056 quint64 lastInode; 00057 void watch(); 00058 static QStringList variantListToStringList(const QVariantList &l); 00059 void checkCompatibility(); 00060 00061 private Q_SLOTS: 00062 void onDatabaseDirectoryChanged(const QString &path); 00063 }; 00064 00065 #endif // INFOCDBBACKEND_H