Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / runtime / nepomuk / strigiconfigfile.h
bloba9af44c74f1bd7758c17391a1abfecafee150c8c
1 /*
2 * This file is part of the Nepomuk KDE project.
3 * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef _NEPOMUK_STRIGI_CONFIG_H_
22 #define _NEPOMUK_STRIGI_CONFIG_H_
24 #include <QtCore/QObject>
25 #include <QtCore/QStringList>
27 class QDomElement;
28 class QTextStream;
30 namespace Nepomuk {
31 /**
32 * Parser and writer class for Strigidaemon config
33 * files.
35 * The default Strigi config file can be found at
36 * ~/.strigi/daemon.conf.
38 class StrigiConfigFile : public QObject
40 Q_OBJECT
42 public:
43 StrigiConfigFile();
44 StrigiConfigFile( const QString& filename );
45 ~StrigiConfigFile();
47 void setFilename( const QString& filename );
49 bool load();
50 bool save();
52 /**
53 * A Strigi repository. Normally there is only one.
55 class Repository {
56 public:
57 QString name() const { return m_name; }
58 QString type() const { return m_type; }
59 QString indexDir() const { return m_indexDir; }
60 bool writeable() const { return m_writeable; }
61 QString urlBase() const { return m_urlBase; }
62 QStringList indexedDirectories() const { return m_indexedDirectories; }
63 int pollingInterval() const { return m_pollingInterval; }
65 bool isValid() const { return !m_type.isEmpty(); }
67 void setType( const QString& type ) { m_type = type; }
68 void setName( const QString& name ) { m_name = name; }
69 void setIndexDir( const QString& dir ) { m_indexDir = dir; }
70 void setWriteable( bool writeable ) { m_writeable = writeable; }
71 void setUrlBase( const QString& urlBase ) { m_urlBase = urlBase; }
72 void addIndexedDirectory( const QString& dir ) { m_indexedDirectories << dir; }
73 void setIndexedDirectories( const QStringList& dirs ) { m_indexedDirectories = dirs; }
74 void setPollingInterval( int pollingInterval ) { m_pollingInterval = pollingInterval; }
76 private:
77 QString m_name;
78 QString m_type;
79 QString m_indexDir;
80 bool m_writeable;
81 QString m_urlBase;
82 QStringList m_indexedDirectories;
83 int m_pollingInterval;
86 bool useDBus() const;
87 QStringList excludeFilters() const;
88 QStringList includeFilters() const;
89 QList<Repository> repositories() const;
91 /**
92 * In most cases (or even always) there is only
93 * one repository. This method will return the
94 * first repository in the list or create a default
95 * one and insert it if the list is empty.
97 * This will also create default filters if none are
98 * specified AND no repository is configured.
100 Repository& defaultRepository();
101 const Repository& defaultRepository() const;
104 * ~/.strigi/daemon.conf
106 static QString defaultStrigiConfigFilePath();
108 public Q_SLOTS:
109 void reset();
111 void setUseDBus( bool b );
112 void setExcludeFilters( const QStringList& filters );
113 void addExcludeFilter( const QString& filter );
114 void setIncludeFilters( const QStringList& filters );
115 void addInludeFilter( const QString& filter );
116 void setRepositories( const QList<Repository>& repos );
117 void addRepository( const Repository& repo );
119 private:
120 bool readConfig( const QDomElement& );
121 Repository readRepositoryConfig( const QDomElement& );
122 bool readFilterConfig( const QDomElement& filterElement );
124 QString m_filename;
126 bool m_useDBus;
127 QStringList m_excludeFilters;
128 QStringList m_includeFilters;
129 QList<Repository> m_repositories;
133 QTextStream& operator<<( QTextStream& s, const Nepomuk::StrigiConfigFile& scf );
135 #endif