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 INFOXMLBACKEND_H 00023 #define INFOXMLBACKEND_H 00024 00025 #include <QFileSystemWatcher> 00026 #include <QStringList> 00027 #include <QObject> 00028 #include <QFileInfo> 00029 #include <QString> 00030 #include <QHash> 00031 #include "infobackend.h" 00032 #include "infokeydata.h" 00033 #include "contextproviderinfo.h" 00034 #include "assoctree.h" 00035 00036 class InfoXmlBackend : public InfoBackend 00037 { 00038 Q_OBJECT 00039 00040 public: 00041 explicit InfoXmlBackend(QObject *parent = 0); 00042 ~InfoXmlBackend(); 00043 00044 virtual QString name() const; 00045 virtual QStringList listKeys() const; 00046 virtual QString docForKey(QString key) const; 00047 virtual bool keyDeclared(QString key) const; 00048 virtual bool keyDeprecated(QString key) const; 00049 virtual const QList<ContextProviderInfo> providersForKey(QString key) const; 00050 virtual ContextTypeInfo typeInfoForKey(QString key) const; 00051 00052 static QString registryPath(); 00053 static QString coreDeclPath(); 00054 00055 private Q_SLOTS: 00056 void onDirectoryChanged(const QString &path); 00057 void onFileChanged(const QString &path); 00058 00059 private: 00060 QFileSystemWatcher *watcher; 00061 QHash <QString, InfoKeyData> keyDataHash; 00062 QHash <QString, QList<ContextProviderInfo> > keyProvidersHash; 00063 int countOfFilesInLastParse; 00064 00065 void regenerateKeyDataList(); 00066 void readKeyDataFromXml(const QString &path); 00067 void parseKey(const AssocTree &keyTree, const AssocTree &providerTree); 00068 }; 00069 00070 #endif // INFOXMLBACKEND_H