1 /* This file is part of the KDE libraries
2 * Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License version 2 as published by the Free Software Foundation;
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public License
14 * along with this library; see the file COPYING.LIB. If not, write to
15 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
22 #include <kdecore_export.h>
23 #include <ksycocatype.h>
25 #include <QtCore/QObject>
26 #include <QtCore/QStringList>
30 class KSycocaFactoryList
;
34 * Executable name of the kbuildsycoca program
36 #define KBUILDSYCOCA_EXENAME "kbuildsycoca4"
40 * Read-only SYstem COnfiguration CAche
42 class KDECORE_EXPORT KSycoca
: public QObject
45 //Q_CLASSINFO("D-Bus Interface", "org.kde.KSycoca")
52 explicit KSycoca( bool /* buildDatabase */ );
57 * @see absoluteFilePath()
59 typedef enum { LocalDatabase
, GlobalDatabase
} DatabaseType
;
67 * Get or create the only instance of KSycoca (read-only)
69 static KSycoca
*self();
74 * @return the compiled-in version, i.e. the one used when writing a new ksycoca
79 * @return true if the ksycoca database is available
80 * This is usually the case, except if KDE isn't installed yet,
81 * or before kded is started.
83 static bool isAvailable();
86 * @internal - called by factories in read-only mode
87 * This is how factories get a stream to an entry
89 QDataStream
*findEntry(int offset
, KSycocaType
&type
);
91 * @internal - called by factories in read-only mode
93 QDataStream
*findFactory( KSycocaFactoryId id
);
95 * @internal - returns kfsstnd stored inside database
97 QString
kfsstnd_prefixes();
99 * @internal - returns absolute file path of the database
101 * for global database type the database is searched under
102 * the 'services' install path.
103 * Otherwise, the value from the environment variable KDESYCOCA
104 * is returned if set. If not set the path is build based on
105 * KStandardDirs cache save location.
107 static QString
absoluteFilePath(DatabaseType type
=LocalDatabase
);
109 * @internal - returns language stored inside database
114 * @internal - returns timestamp of database
116 * The database contains all changes made _before_ this time and
117 * _might_ contain changes made after that.
122 * @internal - returns update signature of database
124 * Signature that keeps track of changes to
125 * $KDEDIR/share/services/update_ksycoca
127 * Touching this file causes the database to be recreated
130 quint32
updateSignature();
133 * @internal - returns all directories with information
134 * stored inside sycoca.
136 QStringList
allResourceDirs();
139 * @internal - add a factory
141 void addFactory( KSycocaFactory
* );
145 * @return true if building (i.e. if a KBuildSycoca);
147 virtual bool isBuilding();
150 * @internal - disables launching of kbuildsycoca
152 void disableAutoRebuild();
155 * When you receive a "databaseChanged" signal, you can query here if
156 * a change has occurred in a specific resource type.
157 * @see KStandardDirs for the various resource types.
159 static bool isChanged(const char *type
);
162 * A read error occurs.
164 static void flagError();
167 * Returns read error status and clears flag.
169 static bool readError();
173 * internal function for receiving kded/kbuildsycoca's signal, when the sycoca file changes
175 void notifyDatabaseChanged(const QStringList
&);
179 * Connect to this to get notified when the database changes
180 * (Usually apps showing icons do a 'refresh' to take into account the new mimetypes)
182 void databaseChanged(); // KDE5 TODO: pass const QStringList& changedList here, remove isChanged()
185 KSycocaFactoryList
* factories();
187 // @internal used by kbuildsycoca
191 Q_DISABLE_COPY(KSycoca
)
192 friend class KSycocaPrivate
;
193 KSycocaPrivate
* const d
;