1/* This file is part of the KDE libraries
2 * Copyright (C) 1999-2000 Waldo Bastian <bastian@kde.org>
3 * Copyright (C) 2005-2009 David Faure <faure@kde.org>
4 * Copyright (C) 2008 Hamish Rodda <rodda@kde.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License version 2 as published by the Free Software Foundation;
9 *
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.
14 *
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.
19 **/
20
21#ifndef KSYCOCA_P_H
22#define KSYCOCA_P_H
23
24#include "ksycocafactory.h"
25#include <QStringList>
26class QFile;
27class QDataStream;
28class KSycocaAbstractDevice;
29
30class KSycocaPrivate
31{
32public:
33 KSycocaPrivate();
34 bool checkVersion();
35 bool openDatabase(bool openDummyIfNotFound=true);
36 enum BehaviorIfNotFound {
37 IfNotFoundDoNothing = 0,
38 IfNotFoundOpenDummy = 1,
39 IfNotFoundRecreate = 2
40 };
41 Q_DECLARE_FLAGS(BehaviorsIfNotFound, BehaviorIfNotFound)
42 bool checkDatabase(BehaviorsIfNotFound ifNotFound);
43 void closeDatabase();
44 void setStrategyFromString(const QString& strategy);
45 bool tryMmap();
46
47 KSycocaAbstractDevice* device();
48 QDataStream*& stream();
49
50 enum {
51 DatabaseNotOpen, // openDatabase must be called
52 NoDatabase, // not found, so we opened a dummy one instead
53 BadVersion, // it's opened, but it's not useable
54 DatabaseOK } databaseStatus;
55 bool readError;
56
57 quint32 timeStamp;
58 enum { StrategyMmap, StrategyMemFile, StrategyFile, StrategyDummyBuffer } m_sycocaStrategy;
59 QString m_databasePath;
60 QStringList changeList;
61 QString language;
62 quint32 updateSig;
63 QStringList allResourceDirs;
64
65 void addFactory(KSycocaFactory* factory) {
66 m_factories.append(factory);
67 }
68 KSycocaFactoryList* factories() { return &m_factories; }
69
70private:
71 KSycocaFactoryList m_factories;
72 size_t sycoca_size;
73 const char *sycoca_mmap;
74 QFile* m_mmapFile;
75 KSycocaAbstractDevice* m_device;
76};
77
78#endif /* KSYCOCA_P_H */
79
80