1 /**************************************************************************************** 2 * Copyright (c) 2010 Sergey Ivanov <123kash@gmail.com> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef MUSICDNSXMLPARSER_H 18 #define MUSICDNSXMLPARSER_H 19 20 #include <QDomDocument> 21 #include <QStringList> 22 23 #include <ThreadWeaver/Job> 24 25 class MusicDNSXmlParser : public QObject, public ThreadWeaver::Job 26 { 27 Q_OBJECT 28 public: 29 explicit MusicDNSXmlParser(QString &doc ); 30 void run(ThreadWeaver::JobPointer self = QSharedPointer<ThreadWeaver::Job>(), ThreadWeaver::Thread *thread = 0) override; 31 QStringList puid(); 32 33 private: 34 void parseElement( const QDomElement &e ); 35 void parseChildren( const QDomElement &e ); 36 37 void parseTrack( const QDomElement &e ); 38 39 void parsePUIDList( const QDomElement &e ); 40 void parsePUID( const QDomElement &e ); 41 42 QDomDocument m_doc; 43 QStringList m_puid; 44 45 Q_SIGNALS: 46 /** This signal is emitted when this job is being processed by a thread. */ 47 void started(ThreadWeaver::JobPointer); 48 /** This signal is emitted when the job has been finished (no matter if it succeeded or not). */ 49 void done(ThreadWeaver::JobPointer); 50 /** This job has failed. 51 * This signal is emitted when success() returns false after the job is executed. */ 52 void failed(ThreadWeaver::JobPointer); 53 54 protected: 55 void defaultBegin(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; 56 void defaultEnd(const ThreadWeaver::JobPointer& job, ThreadWeaver::Thread *thread) override; 57 58 }; 59 60 #endif // MUSICDNSXMLPARSER_H 61