1 | /* This file is part of the KDE project |
2 | Copyright (C) 1999, 2007 David Faure <faure@kde.org> |
3 | 1999 Waldo Bastian <bastian@kde.org> |
4 | |
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. |
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 KDED_KBUILD_SERVICE_FACTORY_H |
22 | #define KDED_KBUILD_SERVICE_FACTORY_H |
23 | |
24 | #include <QtCore/QStringList> |
25 | |
26 | #include "kmimeassociations.h" |
27 | #include <kmimetype.h> |
28 | #include <kservicefactory.h> |
29 | // We export the services to the service group factory! |
30 | class KBuildServiceGroupFactory; |
31 | class KBuildMimeTypeFactory; |
32 | |
33 | /** |
34 | * Service factory for building ksycoca |
35 | * @internal |
36 | */ |
37 | class KBuildServiceFactory : public KServiceFactory |
38 | { |
39 | public: |
40 | /** |
41 | * Create factory |
42 | */ |
43 | KBuildServiceFactory( KSycocaFactory *serviceTypeFactory, |
44 | KBuildMimeTypeFactory *mimeTypeFactory, |
45 | KBuildServiceGroupFactory *serviceGroupFactory ); |
46 | |
47 | virtual ~KBuildServiceFactory(); |
48 | |
49 | /// Reimplemented from KServiceFactory |
50 | virtual KService::Ptr findServiceByDesktopName(const QString &name); |
51 | /// Reimplemented from KServiceFactory |
52 | virtual KService::Ptr findServiceByDesktopPath(const QString &name); |
53 | /// Reimplemented from KServiceFactory |
54 | virtual KService::Ptr (const QString &); |
55 | |
56 | /** |
57 | * Construct a KService from a config file. |
58 | */ |
59 | virtual KSycocaEntry * createEntry(const QString &file, const char *resource) const; |
60 | |
61 | virtual KService * createEntry( int ) const { assert(0); return 0; } |
62 | |
63 | /** |
64 | * Add a new entry. |
65 | */ |
66 | virtual void addEntry(const KSycocaEntry::Ptr& newEntry); |
67 | |
68 | /** |
69 | * Write out service specific index files. |
70 | */ |
71 | virtual void save(QDataStream &str); |
72 | |
73 | /** |
74 | * Write out header information |
75 | * |
76 | * Don't forget to call the parent first when you override |
77 | * this function. |
78 | */ |
79 | virtual void (QDataStream &str); |
80 | |
81 | /** |
82 | * Returns all resource types for this service factory |
83 | */ |
84 | static QStringList resourceTypes(); |
85 | |
86 | void postProcessServices(); |
87 | |
88 | private: |
89 | void populateServiceTypes(); |
90 | void saveOfferList(QDataStream &str); |
91 | void collectInheritedServices(); |
92 | void collectInheritedServices(const QString& mime, QSet<QString>& visitedMimes); |
93 | |
94 | QHash<QString, KService::Ptr> m_nameMemoryHash; // m_nameDict is not useable while building ksycoca |
95 | QHash<QString, KService::Ptr> m_relNameMemoryHash; // m_relNameDict is not useable while building ksycoca |
96 | QHash<QString, KService::Ptr> ; // m_menuIdDict is not useable while building ksycoca |
97 | QSet<KSycocaEntry::Ptr> m_dupeDict; |
98 | |
99 | KOfferHash m_offerHash; |
100 | |
101 | KSycocaFactory *m_serviceTypeFactory; |
102 | KBuildMimeTypeFactory *m_mimeTypeFactory; |
103 | KBuildServiceGroupFactory *m_serviceGroupFactory; |
104 | }; |
105 | |
106 | #endif |
107 | |