File indexing completed on 2024-04-21 04:54:18

0001 /*
0002     SPDX-FileCopyrightText: 2002 Rik Hemsley (rikkus) <rik@kde.org>
0003     SPDX-FileCopyrightText: 2002-2005 Benjamin C. Meyer <ben at meyerhome dot net>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KCDDB_CLIENT_H
0009 #define KCDDB_CLIENT_H
0010 
0011 #include "cdinfo.h"
0012 #include "kcddb.h"
0013 #include "config.h"
0014 
0015 #include <QObject>
0016 
0017 namespace KCDDB
0018 {
0019   class Lookup;
0020   class Submit;
0021 
0022   /**
0023    * Class used to obtain CDDB information about a CD
0024    *
0025    * Example:
0026    * <code>KCDDB::Client *cddb = new KCDDB::Client();
0027    * cddb->lookup(discSignature);
0028    * CDInfo info = cddb->lookupResponse().first();</code>
0029    */
0030   class KCDDB_EXPORT Client : public QObject
0031   {
0032     Q_OBJECT
0033 
0034     public:
0035 
0036       /**
0037        * Uses settings read from config.
0038        */
0039       Client();
0040 
0041       virtual ~Client();
0042 
0043       Config & config() const;
0044 
0045       /**
0046        * @return a list of CDDB entries that match the disc signature
0047        */
0048       CDInfoList lookupResponse() const;
0049 
0050       /**
0051        * Searches the database for entries matching the offset list.
0052        * Use lookupResponse() to get the results
0053        *
0054        * @param trackOffsetList A List of the start offsets of the tracks,
0055        * and the offset of the lead-out track at the end of the list
0056        *
0057        * @return if the results of the lookup: Success, NoRecordFound, etc
0058        */
0059       Result lookup(const TrackOffsetList &trackOffsetList);
0060       /**
0061        * @returns the results of trying to submit
0062        */
0063       Result submit(const CDInfo &cdInfo, const TrackOffsetList &trackOffsetList);
0064 
0065       /**
0066        * Stores the CD-information in the local cache
0067        */
0068       void store(const CDInfo &cdInfo, const TrackOffsetList &trackOffsetList);
0069 
0070       void setBlockingMode( bool );
0071       bool blockingMode() const;
0072 
0073     Q_SIGNALS:
0074       /**
0075        * emitted when not blocking and lookup() finished.
0076        */
0077       void finished( KCDDB::Result result );
0078 
0079     protected Q_SLOTS:
0080       /**
0081        * Called when the lookup is finished with the result
0082        */
0083       void slotFinished( KCDDB::Result result );
0084       /**
0085        * Called when the submit is finished with the result
0086        */
0087       void slotSubmitFinished( KCDDB::Result result );
0088 
0089     private:
0090       Result runPendingLookups();
0091 
0092       class Private;
0093       Private * const d;
0094   };
0095 }
0096 
0097 #endif // KCDDB_CLIENT_H
0098 // vim:tabstop=2:shiftwidth=2:expandtab:cinoptions=(s,U1,m1