File indexing completed on 2024-06-02 04:51:58

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Casey Link <unnamedrambler@gmail.com>                             *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef TRACKFORURLWORKER_H
0018 #define TRACKFORURLWORKER_H
0019 
0020 #include "core/amarokcore_export.h"
0021 #include "core/support/Amarok.h"
0022 #include "core/meta/forward_declarations.h"
0023 
0024 #include <QUrl>
0025 
0026 #include <ThreadWeaver/Job>
0027 
0028 namespace Amarok
0029 {
0030 /**
0031  * Derive from this class and implement the run() method to set mTrack.
0032  * @author Casey Link
0033  */
0034 class AMAROKCORE_EXPORT TrackForUrlWorker : public QObject, public ThreadWeaver::Job
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit TrackForUrlWorker( const QUrl &url );
0039     explicit TrackForUrlWorker( const QString &url );
0040     ~TrackForUrlWorker() override;
0041 
0042     void run(ThreadWeaver::JobPointer self = QSharedPointer<ThreadWeaver::Job>(), ThreadWeaver::Thread *thread = nullptr) override = 0;
0043 
0044 Q_SIGNALS:
0045     void finishedLookup( const Meta::TrackPtr &track );
0046 
0047     /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */
0048     void done(ThreadWeaver::JobPointer);
0049     /** This job has failed. */
0050     void failed(ThreadWeaver::JobPointer);
0051     /** This signal is emitted when this job is being processed by a thread. */
0052     void started(ThreadWeaver::JobPointer);
0053 
0054 protected:
0055     QUrl m_url;
0056     Meta::TrackPtr m_track;
0057 
0058 private Q_SLOTS:
0059     void completeJob();
0060 };
0061 
0062 }
0063 #endif // TRACKFORURLWORKER_H