"Fossies" - the Fresh Open Source Software Archive

Member "MP3Diags-unstable-1.5.01/src/MusicBrainzDownloader.cpp" (10 Feb 2019, 20668 Bytes) of package /linux/privat/MP3Diags-unstable-1.5.01.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "MusicBrainzDownloader.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.3.04_vs_1.5.01.

    1 /***************************************************************************
    2  *   MP3 Diags - diagnosis, repairs and tag editing for MP3 files          *
    3  *                                                                         *
    4  *   Copyright (C) 2009 by Marian Ciobanu                                  *
    5  *   ciobi@inbox.com                                                       *
    6  *                                                                         *
    7  *   This program is free software; you can redistribute it and/or modify  *
    8  *   it under the terms of the GNU General Public License version 2 as     *
    9  *   published by the Free Software Foundation.                            *
   10  *                                                                         *
   11  *   This program is distributed in the hope that it will be useful,       *
   12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   14  *   GNU General Public License for more details.                          *
   15  *                                                                         *
   16  *   You should have received a copy of the GNU General Public License     *
   17  *   along with this program; if not, write to the                         *
   18  *   Free Software Foundation, Inc.,                                       *
   19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
   20  ***************************************************************************/
   21 
   22 
   23 #include  "QHttp"
   24 #include  <QDesktopServices>
   25 
   26 #ifndef WIN32
   27     #include  <sys/time.h>
   28 #else
   29     #include  <windows.h>
   30 #endif
   31 
   32 #include  <QDateTime>
   33 
   34 #include  "MusicBrainzDownloader.h"
   35 
   36 #include  "Helpers.h"
   37 #include  "SimpleSaxHandler.h"
   38 #include  "StoredSettings.h"
   39 
   40 
   41 
   42 using namespace std;
   43 using namespace pearl;
   44 
   45 #if 1
   46 using namespace MusicBrainz;
   47 
   48 namespace MusicBrainz
   49 {
   50 
   51 /*
   52     metadata
   53         release-list
   54             release
   55                 track-list
   56 */
   57 struct SearchXmlHandler : public SimpleSaxHandler<SearchXmlHandler>
   58 {
   59     SearchXmlHandler(MusicBrainzDownloader& dlg) : SimpleSaxHandler<SearchXmlHandler>("metadata"), m_dlg(dlg)
   60     {
   61         Node& meta (getRoot()); meta.onStart = &SearchXmlHandler::onMetaStart;
   62             Node& relList (makeNode(meta, "release-list"));
   63                 Node& rel (makeNode(relList, "release")); rel.onStart = &SearchXmlHandler::onRelStart;
   64                     Node& trackList (makeNode(rel, "track-list")); trackList.onStart = &SearchXmlHandler::onTrackListStart;
   65     }
   66 
   67 private:
   68     MusicBrainzDownloader& m_dlg;
   69 
   70     void onMetaStart(const QXmlAttributes& /*attrs*/)
   71     {
   72         m_dlg.m_nLastLoadedPage = 0;
   73     }
   74 
   75     void onRelStart(const QXmlAttributes& attrs)
   76     {
   77         m_dlg.m_vAlbums.push_back(MusicBrainzAlbumInfo());
   78         m_dlg.m_vAlbums.back().m_strId = convStr(attrs.value("id"));
   79     }
   80 
   81     void onTrackListStart(const QXmlAttributes& attrs)
   82     {
   83         m_dlg.m_vAlbums.back().m_nTrackCount = attrs.value("count").toInt();
   84     }
   85 };
   86 
   87 
   88 /*
   89     metadata
   90         release
   91             title
   92             asin
   93             artist
   94                 name
   95             release-event-list
   96                 event
   97             track-list
   98                 track
   99                     title
  100                     artist
  101                         name
  102             relation-list
  103                 relation
  104 */
  105 struct AlbumXmlHandler : public SimpleSaxHandler<AlbumXmlHandler>
  106 {
  107     AlbumXmlHandler(MusicBrainzAlbumInfo& albumInfo) : SimpleSaxHandler<AlbumXmlHandler>("metadata"), m_albumInfo(albumInfo), m_bTargetIsUrl(false)
  108     {
  109         Node& meta (getRoot()); meta.onEnd = &AlbumXmlHandler::onMetaEnd;
  110             Node& rel (makeNode(meta, "release")); rel.onStart = &AlbumXmlHandler::onRelStart;
  111                 Node& albTitle (makeNode(rel, "title")); albTitle.onChar = &AlbumXmlHandler::onAlbTitleChar;
  112                 Node& asin (makeNode(rel, "asin")); asin.onChar = &AlbumXmlHandler::onAsinChar;
  113                 Node& albArtist (makeNode(rel, "artist"));
  114                     Node& albArtistName (makeNode(albArtist, "name")); albArtistName.onChar = &AlbumXmlHandler::onAlbArtistNameChar;
  115                 Node& albRelEvents (makeNode(rel, "release-event-list"));
  116                     Node& albEvent (makeNode(albRelEvents, "event")); albEvent.onStart = &AlbumXmlHandler::onAlbEventStart;
  117                 Node& albTrackList (makeNode(rel, "track-list"));
  118                     Node& track (makeNode(albTrackList, "track")); track.onStart = &AlbumXmlHandler::onTrackStart;
  119                         Node& trackTitle (makeNode(track, "title")); trackTitle.onChar = &AlbumXmlHandler::onTrackTitleChar;
  120                         Node& trackArtist (makeNode(track, "artist"));
  121                             Node& trackArtistName (makeNode(trackArtist, "name")); trackArtistName.onChar = &AlbumXmlHandler::onTrackArtistName;
  122                 Node& relationList (makeNode(rel, "relation-list")); relationList.onStart = &AlbumXmlHandler::onRelationListStart;
  123                     Node& relation (makeNode(relationList, "relation")); relation.onStart = &AlbumXmlHandler::onRelationStart;
  124 
  125         m_albumInfo.m_eVarArtists = AlbumInfo::VA_SINGLE;
  126     }
  127 
  128 private:
  129     MusicBrainzAlbumInfo& m_albumInfo;
  130     bool m_bTargetIsUrl;
  131 
  132     void onRelStart(const QXmlAttributes& attrs)
  133     {
  134         CB_ASSERT (m_albumInfo.m_strId == convStr(attrs.value("id")));
  135     }
  136 
  137     void onAlbEventStart(const QXmlAttributes& attrs)
  138     {
  139         string strDate (convStr(attrs.value("date")));
  140         if (!strDate.empty())
  141         {
  142             m_albumInfo.m_strReleased = m_albumInfo.m_strReleased.empty() ? strDate : min(m_albumInfo.m_strReleased, strDate);
  143         }
  144 
  145         string strFormat (convStr(attrs.value("format")));
  146         if (!strFormat.empty() && string::npos == m_albumInfo.m_strFormat.find(strFormat))
  147         {
  148             addIfMissing(m_albumInfo.m_strFormat, strFormat);
  149         }
  150     }
  151 
  152     void onTrackStart(const QXmlAttributes&)
  153     {
  154         m_albumInfo.m_vTracks.push_back(TrackInfo());
  155         char a [10];
  156         sprintf(a, "%d", cSize(m_albumInfo.m_vTracks));
  157         m_albumInfo.m_vTracks.back().m_strPos = a;
  158     }
  159 
  160     void onRelationListStart(const QXmlAttributes& attrs)
  161     {
  162         m_bTargetIsUrl = "Url" == attrs.value("target-type");
  163     }
  164 
  165     void onRelationStart(const QXmlAttributes& attrs)
  166     {
  167         if (m_bTargetIsUrl)
  168         {
  169             QString qstrType (attrs.value("type"));
  170             if ("AmazonAsin" == qstrType)
  171             {
  172                 m_albumInfo.m_strAmazonLink = convStr(attrs.value("target"));
  173             }
  174             else if ("CoverArtLink" == qstrType)
  175             {
  176                 string strUrl (convStr(attrs.value("target")));
  177                 if (beginsWith(strUrl, "http://"))
  178                 {
  179                     m_albumInfo.m_vstrImageNames.push_back(strUrl);
  180                 }
  181                 else
  182                 { //ttt2 perhaps tell the user
  183                     qDebug("Unsupported image link");
  184                 }
  185             }
  186         }
  187     }
  188 
  189 
  190     void onMetaEnd()
  191     {
  192         m_albumInfo.m_vpImages.resize(m_albumInfo.m_vstrImageNames.size());
  193         m_albumInfo.m_vstrImageInfo.resize(m_albumInfo.m_vstrImageNames.size());
  194         if (m_albumInfo.m_strAmazonLink.empty() && !m_albumInfo.m_strAsin.empty())
  195         {
  196             m_albumInfo.m_strAmazonLink = "http://www.amazon.com/gp/product/" + m_albumInfo.m_strAsin;
  197         }
  198 
  199         for (int i = 0, n = cSize(m_albumInfo.m_vTracks); i < n; ++i)
  200         {
  201             TrackInfo& t (m_albumInfo.m_vTracks[i]);
  202             addList(t.m_strArtist, m_albumInfo.m_strArtist);
  203         }
  204     }
  205 
  206     void onAlbTitleChar(const string& s)
  207     {
  208         m_albumInfo.m_strTitle = s;
  209     }
  210 
  211     void onAsinChar(const string& s)
  212     {
  213         m_albumInfo.m_strAsin = s;
  214         m_albumInfo.m_vstrImageNames.push_back("http://images.amazon.com/images/P/" + s + ".01.LZZZZZZZ.jpg"); // ttt2 "01" is country code for US, perhaps try others //ttt2 perhaps check for duplicates
  215     }
  216 
  217     void onAlbArtistNameChar(const string& s)
  218     {
  219         if (0 == convStr(s).compare("VaRiOuS Artists", Qt::CaseInsensitive))
  220         {
  221             m_albumInfo.m_eVarArtists = AlbumInfo::VA_VARIOUS;
  222         }
  223         else
  224         {
  225             m_albumInfo.m_strArtist = s;
  226         }
  227     }
  228 
  229     void onTrackTitleChar(const string& s)
  230     {
  231         m_albumInfo.m_vTracks.back().m_strTitle = s;
  232     }
  233 
  234     void onTrackArtistName(const string& s)
  235     {
  236         m_albumInfo.m_vTracks.back().m_strArtist = s;
  237     }
  238 };
  239 
  240 
  241 /*override*/ void MusicBrainzAlbumInfo::copyTo(AlbumInfo& dest)
  242 {
  243 
  244     dest.m_strTitle = m_strTitle;
  245     //dest.m_strArtist = m_strArtist;
  246     //dest.m_strComposer; // !!! missing
  247     //dest.m_strFormat = m_strFormat; // CD, tape, ...
  248     //dest.m_strGenre = m_strGenre; // !!! missing
  249     dest.m_strReleased = m_strReleased;
  250     //dest.m_strNotes; // !!! missing
  251     dest.m_vTracks = m_vTracks;
  252     dest.m_eVarArtists = m_eVarArtists;
  253 
  254     dest.m_strSourceName = MusicBrainzDownloader::SOURCE_NAME; // Discogs, MusicBrainz, ... ; needed by MainFormDlgImpl;
  255     //dest.m_imageInfo; // !!! not set
  256 }
  257 
  258 
  259 } // namespace MusicBrainz
  260 
  261 
  262 
  263 //=============================================================================================================================
  264 //=============================================================================================================================
  265 //=============================================================================================================================
  266 
  267 
  268 /*override*/ void MusicBrainzDownloader::saveSize()
  269 {
  270     m_settings.saveMusicBrainzSettings(width(), height());
  271 }
  272 
  273 
  274 /*static*/ const char* MusicBrainzDownloader::SOURCE_NAME ("MusicBrainz");
  275 
  276 
  277 
  278 MusicBrainzDownloader::MusicBrainzDownloader(QWidget* pParent, SessionSettings& settings, bool bSaveResults) : AlbumInfoDownloaderDlgImpl(pParent, settings, bSaveResults), m_nLastReqTime(0)
  279 {
  280     setWindowTitle(tr("Download album data from MusicBrainz.org"));
  281 
  282     int nWidth, nHeight;
  283     m_settings.loadMusicBrainzSettings(nWidth, nHeight);
  284     if (nWidth > 400 && nHeight > 400) { resize(nWidth, nHeight); }
  285 
  286     m_pViewAtAmazonL->setText(getAmazonText());
  287 
  288     m_pGenreE->hide(); m_pGenreL->hide();
  289     m_pAlbumNotesM->hide();
  290 
  291     m_pVolumeL->hide(); m_pVolumeCbB->hide();
  292 
  293     m_pStyleL->hide(); m_pStyleCbB->hide();
  294 
  295     m_pImgSizeL->setMinimumHeight(m_pImgSizeL->height()*2);
  296 
  297     m_pQHttp->setHost("musicbrainz.org");
  298     m_pImageQHttp = new QHttp (this);
  299 
  300     m_pModel = new WebDwnldModel(*this, *m_pTrackListG); // !!! in a way these would make sense to be in the base constructor, but that would cause calls to pure virtual methods
  301     m_pTrackListG->setModel(m_pModel);
  302 
  303     connect(m_pImageQHttp, SIGNAL(requestFinished(int, bool)), this, SLOT(onRequestFinished(int, bool)));
  304 
  305     connect(m_pSearchB, SIGNAL(clicked()), this, SLOT(on_m_pSearchB_clicked()));
  306 
  307     connect(m_pViewAtAmazonL, SIGNAL(linkActivated(const QString&)), this, SLOT(onAmazonLinkActivated(const QString&)));
  308 }
  309 
  310 
  311 MusicBrainzDownloader::~MusicBrainzDownloader()
  312 {
  313     resetNavigation(); // !!! not in base class, because it calls virtual method resetNavigation()
  314     clear();
  315 }
  316 
  317 void MusicBrainzDownloader::clear()
  318 {
  319 LAST_STEP("MusicBrainzDownloader::clear");
  320     clearPtrContainer(m_vpImages);
  321     m_vAlbums.clear();
  322 }
  323 
  324 
  325 
  326 
  327 /*override*/ bool MusicBrainzDownloader::initSearch(const std::string& strArtist, const std::string& strAlbum)
  328 {
  329 LAST_STEP("MusicBrainzDownloader::initSearch");
  330     m_pSrchArtistE->setText(convStr((removeParentheses(strArtist))));
  331     m_pSrchAlbumE->setText(convStr((removeParentheses(strAlbum))));
  332     return !strArtist.empty() || !strAlbum.empty();
  333 }
  334 
  335 
  336 
  337 
  338 /*override*/ std::string MusicBrainzDownloader::createQuery()
  339 {
  340 LAST_STEP("MusicBrainzDownloader::createQuery");
  341     string s ("/ws/1/release/?type=xml&artist=" + replaceSymbols(convStr(m_pSrchArtistE->text())) + "&title=" + replaceSymbols(convStr(m_pSrchAlbumE->text())));
  342     //qDebug("qry: %s", s.c_str());
  343     if (m_pMatchCountCkB->isChecked())
  344     {
  345         s += convStr(QString("&count=%1").arg(m_nExpectedTracks));
  346     }
  347     /*for (string::size_type i = 0; i < s.size(); ++i)
  348     {
  349         if (' ' == s[i])
  350         {
  351             s[i] = '+';
  352         }
  353     }*/
  354     //s = "/ws/1/release/?type=xml&artist=Beatles&title=Help";
  355     return s;
  356 }
  357 
  358 
  359 void MusicBrainzDownloader::delay()
  360 {
  361     long long t (getTime());
  362     long long nDiff (t - m_nLastReqTime);
  363     //qDebug("crt: %lld, prev: %lld, diff: %lld", t, m_nLastReqTime, t - m_nLastReqTime);
  364     if (nDiff < 1000)
  365     {
  366         if (nDiff < 0) { nDiff = 0; }
  367         int nWait (999 - (int)nDiff);
  368         //qDebug("   wait: %d", nWait);
  369         addNote(tr("waiting %1ms").arg(nWait + 100));
  370 
  371         //ttt1 perhaps use PausableThread::usleep()
  372 #ifndef WIN32
  373         timespec ts;
  374         ts.tv_sec = 0;
  375         ts.tv_nsec = 100000000; // 0.1s, to be sure
  376         nanosleep(&ts, 0);
  377         ts.tv_nsec = nWait*1000000;
  378         nanosleep(&ts, 0);
  379 #else
  380         Sleep(nWait + 100);
  381 #endif
  382         //qDebug("waiting %d", nWait);
  383     }
  384 
  385     m_nLastReqTime = t;
  386 }
  387 
  388 
  389 long long MusicBrainzDownloader::getTime() // time in milliseconds
  390 {
  391     QDateTime t (QDateTime::currentDateTime());
  392     long long nRes (t.toTime_t()); //ttt3 32bit
  393     nRes *= 1000;
  394     nRes += t.time().msec();
  395     return nRes;
  396 #if 0
  397     qDebug("t1 %lld", nRes);
  398 #ifndef WIN32
  399     timeval tv;
  400     gettimeofday(&tv, 0);
  401 qDebug("t2 %lld", tv.tv_sec*1000LL + tv.tv_usec/1000);
  402     return tv.tv_sec*1000LL + tv.tv_usec/1000;
  403 #else
  404     QDateTime t (QDateTime::currentDateTime());
  405     return t.toTime_t(); //ttt3 32bit
  406 #endif
  407 #endif
  408 }
  409 
  410 //==========================================================================================================================
  411 //==========================================================================================================================
  412 //==========================================================================================================================
  413 
  414 void MusicBrainzDownloader::on_m_pSearchB_clicked()
  415 {
  416 LAST_STEP("MusicBrainzDownloader::on_m_pSearchB_clicked");
  417     clear();
  418     search();
  419 }
  420 
  421 
  422 
  423 
  424 
  425 //==========================================================================================================================
  426 //==========================================================================================================================
  427 //==========================================================================================================================
  428 
  429 
  430 void MusicBrainzDownloader::loadNextPage()
  431 {
  432 LAST_STEP("MusicBrainzDownloader::loadNextPage");
  433     CB_ASSERT (!m_pQHttp->hasPendingRequests());
  434     CB_ASSERT (!m_pImageQHttp->hasPendingRequests());
  435 
  436     ++m_nLastLoadedPage;
  437     CB_ASSERT (m_nLastLoadedPage <= m_nTotalPages - 1);
  438 
  439     //m_eState = NEXT;
  440     setWaiting(SEARCH);
  441     //char a [20];
  442     //sprintf(a, "&page=%d", m_nLastLoadedPage + 1);
  443     //string s (m_strQuery + a);
  444 
  445     QHttpRequestHeader header ("GET", convStr(m_strQuery));
  446     //header.setValue("Host", "www.musicbrainz.org");
  447     header.setValue("Host", "musicbrainz.org");
  448     //header.setValue("Accept-Encoding", "gzip");
  449     delay();
  450     //qDebug("--------------\npath %s", header.path().toUtf8().constData());
  451     //qDebug("qry %s", m_strQuery.c_str());
  452     m_pQHttp->request(header);
  453     //cout << "sent search " << m_pQHttp->request(header) << " for page " << (m_nLastLoadedPage + 1) << endl;
  454 }
  455 
  456 
  457 //ttt2 see if it is possible for a track to have its own genre
  458 
  459 QString MusicBrainzDownloader::getAmazonText() const
  460 {
  461 LAST_STEP("MusicBrainzDownloader::getAmazonText");
  462     if (m_nCrtAlbum < 0 || m_nCrtAlbum >= cSize(m_vAlbums))
  463     {
  464         return AlbumInfoDownloaderDlgImpl::tr(NOT_FOUND_AT_AMAZON);
  465     }
  466 
  467     const MusicBrainzAlbumInfo& album (m_vAlbums[m_nCrtAlbum]);
  468     if (album.m_strAmazonLink.empty())
  469     {
  470         return AlbumInfoDownloaderDlgImpl::tr(NOT_FOUND_AT_AMAZON);
  471     }
  472     else
  473     {
  474         return tr("<a href=\"%1\">view at amazon.com</a>").arg(album.m_strAmazonLink.c_str());
  475     }
  476 }
  477 
  478 void MusicBrainzDownloader::onAmazonLinkActivated(const QString& qstrLink) // !!! it's possible to set openExternalLinks on a QLabel to open links automatically, but this leaves an ugly frame around the text, with it right side missing; also, manual handling is needed to open a built-in browser;
  479 {
  480 LAST_STEP("MusicBrainzDownloader::onAmazonLinkActivated");
  481     m_pViewAtAmazonL->setText("qq"); // !!! the text needs to CHANGE to make the frame disappear
  482     m_pViewAtAmazonL->setText(getAmazonText());
  483 
  484     QDesktopServices::openUrl(qstrLink);
  485 }
  486 
  487 
  488 
  489 void MusicBrainzDownloader::reloadGui()
  490 {
  491 LAST_STEP("MusicBrainzDownloader::reloadGui");
  492     AlbumInfoDownloaderDlgImpl::reloadGui();
  493     m_pViewAtAmazonL->setText(getAmazonText());
  494 }
  495 
  496 
  497 void MusicBrainzDownloader::requestAlbum(int nAlbum)
  498 {
  499 LAST_STEP("MusicBrainzDownloader::requestAlbum");
  500     //CB_ASSERT (!m_pQHttp->hasPendingRequests() && !m_pImageQHttp->hasPendingRequests());  // ttt1 triggered: https://sourceforge.net/apps/mantisbt/mp3diags/view.php?id=36 ?? perhaps might happen when MB returns errors ; see also DiscogsDownloader::requestAlbum
  501     CB_ASSERT (!m_pQHttp->hasPendingRequests());
  502     CB_ASSERT (!m_pImageQHttp->hasPendingRequests());
  503 
  504     m_nLoadingAlbum = nAlbum;
  505     setWaiting(ALBUM);
  506     //string s ("/release/" + m_vAlbums[nAlbum].m_strId + "?f=xml&api_key=f51e9c8f6c");
  507     string s ("/ws/1/release/" + m_vAlbums[nAlbum].m_strId + "?type=xml&inc=tracks+artist+release-events+url-rels");
  508 
  509     QHttpRequestHeader header ("GET", convStr(s));
  510     header.setValue("Host", "musicbrainz.org");
  511     //header.setValue("Accept-Encoding", "gzip");
  512     delay();
  513     m_pQHttp->request(header);
  514     //cout << "sent album " << m_vAlbums[nAlbum].m_strId << " - " << m_pQHttp->request(header) << endl;
  515     addNote(AlbumInfoDownloaderDlgImpl::tr("getting album info ..."));
  516 }
  517 
  518 
  519 
  520 void MusicBrainzDownloader::requestImage(int nAlbum, int nImage)
  521 {
  522 LAST_STEP("MusicBrainzDownloader::requestImage");
  523     CB_ASSERT (!m_pQHttp->hasPendingRequests());
  524     CB_ASSERT (!m_pImageQHttp->hasPendingRequests());
  525 
  526     m_nLoadingAlbum = nAlbum;
  527     m_nLoadingImage = nImage;
  528     setWaiting(IMAGE);
  529     const string& strUrl (m_vAlbums[nAlbum].m_vstrImageNames[nImage]);
  530     setImageType(strUrl);
  531 
  532     QUrl url (convStr(strUrl));
  533     m_pImageQHttp->setHost(url.host());
  534 
  535     delay(); // probably not needed, because doesn't seem that MusicBrainz would want to store images
  536     //connect(m_pImageQHttp, SIGNAL(requestFinished(int, bool)), this, SLOT(onRequestFinished(int, bool)));
  537     //qDebug("host: %s, path: %s", url.host().toLatin1().constData(), url.path().toLatin1().constData());
  538     //qDebug("%s", strUrl.c_str());
  539     m_pImageQHttp->get(url.path());
  540 
  541     addNote(AlbumInfoDownloaderDlgImpl::tr("getting image ..."));
  542 }
  543 
  544 
  545 //==========================================================================================================================
  546 //==========================================================================================================================
  547 //==========================================================================================================================
  548 
  549 
  550 /*override*/ QHttp* MusicBrainzDownloader::getWaitingHttp()
  551 {
  552 LAST_STEP("MusicBrainzDownloader::getWaitingHttp");
  553     return IMAGE == m_eWaiting ? m_pImageQHttp : m_pQHttp;
  554 }
  555 
  556 /*override*/ void MusicBrainzDownloader::resetNavigation()
  557 {
  558 LAST_STEP("MusicBrainzDownloader::resetNavigation");
  559     m_pImageQHttp->clearPendingRequests();
  560     AlbumInfoDownloaderDlgImpl::resetNavigation();
  561 }
  562 
  563 
  564 /*override*/ WebAlbumInfoBase& MusicBrainzDownloader::album(int i)
  565 {
  566     return m_vAlbums.at(i);
  567 }
  568 
  569 /*override*/ int MusicBrainzDownloader::getAlbumCount() const
  570 {
  571     return cSize(m_vAlbums);
  572 }
  573 
  574 
  575 /*override*/ QXmlDefaultHandler* MusicBrainzDownloader::getSearchXmlHandler()
  576 {
  577     return new SearchXmlHandler(*this);
  578 }
  579 
  580 /*override*/ QXmlDefaultHandler* MusicBrainzDownloader::getAlbumXmlHandler(int nAlbum)
  581 {
  582     //return new AlbumXmlHandler(m_vAlbums.at(nAlbum));
  583     return new AlbumXmlHandler(m_vAlbums.at(nAlbum));
  584 }
  585 
  586 
  587 /*override*/ const WebAlbumInfoBase* MusicBrainzDownloader::getCrtAlbum() const // returns 0 if there's no album
  588 {
  589     if (m_nCrtAlbum < 0 || m_nCrtAlbum >= cSize(m_vAlbums)) { return 0; }
  590     return &m_vAlbums[m_nCrtAlbum];
  591 }
  592 
  593 
  594 
  595 
  596 
  597 /*
  598 
  599 
  600 */
  601 
  602 
  603 //ttt2 perhaps look at Last.fm for more pictures (see Cover Fetcher for AmaroK 1.4; a brief look at the API seems to indicate that a generic "search" is not possible)
  604 
  605 
  606 //ttt2 detect Qt 4.4 and use QWebView
  607 #endif
  608 
  609