1 /* This file is part of the KDE libraries
2 
3    Copyright (c) 2001,2002 Carsten Pfeiffer <pfeiffer@kde.org>
4                  2007 Jos van den Oever <jos@vandenoever.info>
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 (LGPL) as published by the Free Software Foundation; either
9    version 2 of the License, or (at your option) any later version.
10 
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
15 
16    You should have received a copy of the GNU Library General Public License
17    along with this library; see the file COPYING.LIB.  If not, write to
18    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19    Boston, MA 02110-1301, USA.
20 */
21 #ifndef KFILEMETAINFO_H
22 #define KFILEMETAINFO_H
23 
24 #include "predicateproperties.h"
25 #include "kfilemetainfoitem.h"
26 #include <QList>
27 #include <QStringList>
28 #include <QUrl>
29 class QUrl;
30 
31 typedef QList<KFileMetaInfoItem> KFileMetaInfoItemList;
32 
33 class KFileMetaInfoGroupPrivate;
34 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KFileMetaInfoGroup
35 {
36 public:
37     KFileMetaInfoGroup();
38     KFileMetaInfoGroup(const KFileMetaInfoGroup &);
39     ~KFileMetaInfoGroup();
40     const KFileMetaInfoGroup &operator=(const KFileMetaInfoGroup &);
41     KFileMetaInfoItemList items() const;
42     const QString &name() const;
43     const QStringList &keys() const;
44 private:
45     QSharedDataPointer<KFileMetaInfoGroupPrivate> d;
46 };
47 
48 typedef QList<KFileMetaInfoGroup> KFileMetaInfoGroupList;
49 
50 class KFileMetaInfoPrivate;
51 /**
52  * KFileMetaInfo provides metadata extracted from a file or other resource.
53  *
54  * When instantiating an instance of this class, the metadata related to it
55  * will be retrieved and stored in the instance. The data can be inspected
56  * through KFileMetaInfoItem objects.
57  **/
58 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KFileMetaInfo
59 {
60 public:
61     /**
62      * This is used to specify what a KFileMetaInfo object should read, so
63      * you can specify if you want to read "expensive" items or not.
64      * This is like a preset which can be customized by passing additional
65      * parameters to constructors.
66      */
67     enum What {
68         Fastest       = 0x1,  /**< do the fastest possible read and omit all items
69                                  that might need a significantly longer time
70                                  than the others */
71 // Deprecated
72 //      DontCare      = 0x2,  ///< let the plugin decide what to read.
73 
74         TechnicalInfo = 0x4,  /**< extract technical details about the file, like
75                                  e.g. play time, resolution or a compressioni
76                                  type */
77         ContentInfo   = 0x8,  /**< read information about the content of the file
78                                  like comments or id3 tags */
79         ExternalSources = 0x10, /**<read external metadata sources such as
80                                  filesystem based extended attributes if
81                                  they are supported for the filesystem;
82                                  RDF storages etc */
83         Thumbnail     = 0x20, /**< only read the file's thumbnail, if it contains
84                                  one */
85 // Deprecated
86 //      Preferred     = 0x40,  ///< get at least the preferred items
87         LinkedData    = 0x80, //< extract linked/related files like html links, source #include etc
88         Everything    = 0xffff ///< read everything, even if it might take a while
89 
90     };
91     Q_DECLARE_FLAGS(WhatFlags, What)
92 
93     /**
94      * @brief Construct a KFileMetaInfo that contains metainformation about
95      * the resource pointed to by @p path.
96      *
97      * When w is not Everything, a limit of 64kbytes is imposed on the file size.
98      **/
99     KDELIBS4SUPPORT_DEPRECATED explicit KFileMetaInfo(const QString &path, const QString &mimetype = QString(),
100                            WhatFlags w = Everything);
101     /**
102      * @brief Construct a KFileMetaInfo that contains metainformation about
103      * the resource pointed to by @p url.
104      * @note that c'tor is not thread-safe
105      **/
106     KFileMetaInfo(const QUrl &url);
107     /**
108      * @brief Construct an empty, invalid KFileMetaInfo instance.
109      **/
110     KFileMetaInfo();
111     /**
112      * @brief Construct a KFileMetaInfo instance from another one.
113      **/
114     KFileMetaInfo(const KFileMetaInfo &);
115     /**
116      * @brief Destructor.
117      **/
118     ~KFileMetaInfo();
119     /**
120      * @brief Copy a KFileMetaInfo instance from another one.
121      **/
122     KFileMetaInfo &operator=(KFileMetaInfo const &kfmi);
123     /**
124      * @brief Save the changes made to this KFileMetaInfo instance.
125      */
126     bool applyChanges();
127     /**
128      * @brief Retrieve all the items.
129      **/
130     const QHash<QString, KFileMetaInfoItem> &items() const;
131     KFileMetaInfoItem &item(const QString &key);
132     const KFileMetaInfoItem &item(const QString &key) const;
133     bool isValid() const;
134     /**
135      * Deprecated
136      **/
137     QStringList preferredKeys() const;
138     /**
139      * Deprecated
140      **/
141     QStringList supportedKeys() const;
142     KDELIBS4SUPPORT_DEPRECATED_EXPORT friend QDataStream &operator >>(QDataStream &s, KFileMetaInfo &)
143     ;
144     KDELIBS4SUPPORT_DEPRECATED_EXPORT friend QDataStream &operator <<(QDataStream &s, const KFileMetaInfo &);
145     /**
146      * Deprecated
147      **/
148 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
149     KDELIBS4SUPPORT_DEPRECATED KFileMetaInfoGroupList preferredGroups() const;
150 #endif
151     /**
152      * Deprecated
153      **/
154 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
155     KDELIBS4SUPPORT_DEPRECATED KFileMetaInfoGroupList supportedGroups() const;
156 #endif
157     KFileMetaInfoGroupList groups() const;
158     QStringList keys() const;
159     QUrl url() const;
160 
161 private:
162     QSharedDataPointer<KFileMetaInfoPrivate> d;
163 };
164 
165 Q_DECLARE_OPERATORS_FOR_FLAGS(KFileMetaInfo::WhatFlags)
166 
167 #endif
168