File indexing completed on 2024-05-05 16:08:28

0001 // -*- c++ -*-
0002 /*  This file is part of the KDE libraries
0003     Copyright (C) 2001 Rolf Magnus <ramagnus@kde.org>
0004     parts of this taken from previewjob.h
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Library General Public
0008     License as published by the Free Software Foundation version 2.0.
0009 
0010     This library is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013     Library General Public License for more details.
0014 
0015     You should have received a copy of the GNU Library General Public License
0016     along with this library; see the file COPYING.LIB.  If not, write to
0017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018     Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KIO_METAINFOJOB_H
0022 #define KIO_METAINFOJOB_H
0023 
0024 #include <kdelibs4support_export.h>
0025 #include <kio/job.h>
0026 #include <kfileitem.h>
0027 #include <kfilemetainfo.h>
0028 
0029 namespace KIO
0030 {
0031 class MetaInfoJobPrivate;
0032 /**
0033  * MetaInfoJob is a KIO Job to retrieve meta information from files.
0034  *
0035  * @short KIO Job to retrieve meta information from files.
0036  * @deprecated use Nepomuk or Strigi
0037  * Note: this job doesn't even work as before, KFileItem::setMetaInfo
0038  * doesn't exist anymore.
0039  */
0040 class KDELIBS4SUPPORT_DEPRECATED_EXPORT MetaInfoJob : public KIO::Job
0041 {
0042     Q_OBJECT
0043 public:
0044     /**
0045      * Creates a new MetaInfoJob.
0046      *  @param items   A list of KFileItems to get the metainfo for
0047      *  @param w       Flags which serve as a preset which can be customized
0048      *                 with other parameters.
0049      *  @param iocost  The allowed cost in terms of io to retrieve the
0050      *                 metainfo. The approximate maximum number of bytes to
0051      *                 be read is 10^iocost. Negative values mean that
0052      *                 there is no limit on the cost. 0 means that no fields
0053      *                 other than the required fields will be retrieved.
0054      *                 The default value of 3 means about 1024 bytes per
0055      *                 file may be read. This is merely a suggestion and not
0056      *                 a hard limit.
0057      *  @param cpucost The allowed cost in terms of cpu to determine the
0058      *                 information in the fields. The number mean the amount
0059      *                 of instructions allowed is 10^cpucost and is a suggestion only.
0060      *                 The default value of 6 means that about a million
0061      *                 instructions (10^6) are allowed. This is useful for
0062      *                 expensive fields like md5 or thumbnails.
0063      *  @param requiredfields The names of fields or groups of fields that should
0064      *                  be retrieved regardless of cost.
0065      *  @param requestedfields The names of fields or groups of fields that should
0066      *                  be retrieved first.
0067      */
0068     KDELIBS4SUPPORT_DEPRECATED explicit MetaInfoJob(const KFileItemList &items, KFileMetaInfo::WhatFlags w = KFileMetaInfo::Everything,
0069                          int iocost = 3, int cpucost = 6, const QStringList &requiredfields = QStringList(),
0070                          const QStringList &requestedfields = QStringList());
0071     ~MetaInfoJob() override;
0072 
0073     /**
0074      * Removes an item from metainfo extraction.
0075      *
0076      * @param item the item that should be removed from the queue
0077      */
0078     void removeItem(const KFileItem &item);
0079 
0080 Q_SIGNALS:
0081     /**
0082      * Emitted when the meta info for @p item has been successfully
0083      * retrieved.
0084     * @param item the KFileItem describing the fetched item
0085            */
0086     void gotMetaInfo(const KFileItem &item);
0087     /**
0088      * Emitted when metainfo for @p item could not be extracted,
0089      * either because a plugin for its MIME type does not
0090      * exist, or because something went wrong.
0091     * @param item the KFileItem of the file that failed
0092            */
0093     void failed(const KFileItem &item);
0094 
0095 protected:
0096     void getMetaInfo();
0097 
0098 protected Q_SLOTS:
0099     void slotResult(KJob *job) override;
0100 
0101 private Q_SLOTS:
0102     void start() override;
0103     void slotMetaInfo(KIO::Job *, const QByteArray &);
0104 
0105 private:
0106     void determineNextFile();
0107 //        void saveMetaInfo(const QByteArray info);
0108 
0109 private:
0110     Q_DECLARE_PRIVATE(MetaInfoJob)
0111     MetaInfoJobPrivate *d;
0112 };
0113 
0114 /**
0115  * Retrieves meta information for the given items.
0116  *
0117  * @param items files to get metainfo for
0118  * @return the MetaInfoJob to retrieve the items
0119  * @deprecated use strigi or KFileMetaInfo
0120  */
0121 KDELIBS4SUPPORT_DEPRECATED_EXPORT MetaInfoJob *fileMetaInfo(const KFileItemList &items);
0122 
0123 /**
0124  * Retrieves meta information for the given items.
0125  *
0126  * @param items files to get metainfo for
0127  * @return the MetaInfoJob to retrieve the items
0128  * @deprecated use strigi or KFileMetaInfo
0129  */
0130 KDELIBS4SUPPORT_DEPRECATED_EXPORT MetaInfoJob *fileMetaInfo(const QList<QUrl> &items);
0131 }
0132 
0133 #endif