File indexing completed on 2025-01-19 04:24:27
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz> * 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 IPODPARSETRACKSJOB_H 0018 #define IPODPARSETRACKSJOB_H 0019 0020 #include "core/meta/forward_declarations.h" 0021 0022 #include <ThreadWeaver/Job> 0023 0024 class IpodCollection; 0025 0026 /** 0027 * A job designed to parse iPod tracks and playlists in a thread so that main thread is 0028 * not blocked with it. It is guaranteed by IpodCollection that is doesn't destroy itself 0029 * while this job is alive. Memory management of this job is up to the caller of it. 0030 */ 0031 class IpodParseTracksJob : public QObject, public ThreadWeaver::Job 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 explicit IpodParseTracksJob( IpodCollection *collection ); 0037 0038 public Q_SLOTS: 0039 /** 0040 * Aborts the job as soon as it is safely possible 0041 */ 0042 void abort(); 0043 0044 protected: 0045 void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; 0046 void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; 0047 void run(ThreadWeaver::JobPointer self = QSharedPointer<ThreadWeaver::Job>(), ThreadWeaver::Thread *thread = nullptr) override; 0048 0049 Q_SIGNALS: 0050 // signals for progress operation: 0051 void incrementProgress(); 0052 void endProgressOperation( QObject *obj ); 0053 void totalSteps( int steps ); // not used, defined to keep QObject::connect warning quiet 0054 0055 /** This signal is emitted when this job is being processed by a thread. */ 0056 void started(ThreadWeaver::JobPointer); 0057 /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ 0058 void done(ThreadWeaver::JobPointer); 0059 /** This job has failed. 0060 * This signal is emitted when success() returns false after the job is executed. */ 0061 void failed(ThreadWeaver::JobPointer); 0062 0063 private: 0064 /** 0065 * Go through iPod playlists and create Amarok playlists for them. 0066 * 0067 * @param staleTracks list of track from iTunes database whose associated file 0068 * no longer exists 0069 * @param knownPaths a set of absolute local paths of all track from iTunes 0070 * database; used for orphaned tracks detection 0071 */ 0072 void parsePlaylists( const Meta::TrackList &staleTracks, 0073 const QSet<QString> &knownPaths ); 0074 Meta::TrackList findOrphanedTracks( const QSet<QString> &knownPaths ); 0075 0076 IpodCollection *m_coll; 0077 bool m_aborted; 0078 }; 0079 0080 #endif // IPODPARSETRACKSJOB_H