From kde-commits Thu Mar 31 21:06:33 2011 From: Laszlo Papp Date: Thu, 31 Mar 2011 21:06:33 +0000 To: kde-commits Subject: =?utf-8?q?=5Bgluon=5D_player=3A_Start_the_fully_dropping_and_rew?= Message-Id: <20110331210633.36975A60A9 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=130160563700464 Git commit c00b216acdef3ff0ab23a600c2c847b535e28a3f by Laszlo Papp. Committed on 01/04/2011 at 00:16. Pushed by lpapp into branch 'master'. Start the fully dropping and rewriting the gamedownloadmanager code. M +54 -0 player/lib/atticamanager.cpp M +16 -10 player/lib/atticamanager.h D +0 -85 player/lib/gamedownloadmanager.cpp D +0 -53 player/lib/gamedownloadmanager.h M +12 -4 player/touch/Details.qml http://commits.kde.org/gluon/c00b216acdef3ff0ab23a600c2c847b535e28a3f diff --git a/player/lib/atticamanager.cpp b/player/lib/atticamanager.cpp index a095f75..4db067d 100644 --- a/player/lib/atticamanager.cpp +++ b/player/lib/atticamanager.cpp @@ -20,6 +20,11 @@ #include "atticamanager.h" +#include +#include + +#include + using namespace GluonPlayer; GLUON_DEFINE_SINGLETON(AtticaManager) @@ -55,10 +60,59 @@ void AtticaManager::providersUpdated() } else { + emit gotProvider(); } } } +bool AtticaManager::downloadGame ( const QString &id ) +{ + if (isDownloading) + { + return false; + } + + isDownloading = true; + m_currentId = id; + if( AtticaManager::instance()->isProviderValid() ) + { + requestContent(); + } + else + { + connect( this, SIGNAL( gotProvider() ), SLOT( requestContent() ) ); + } + + return true; +} + +void AtticaManager::requestContent() +{ + if( isProviderValid() ) + { + Attica::ItemJob *job = provider().requestContent(m_currentId); + connect( job, SIGNAL( finished( Attica::BaseJob* ) ), SLOT( processFetchedGameDetails( Attica::BaseJob* ) ) ); + job->start(); + } + else + { + qDebug() << "No providers found."; + } +} + +void AtticaManager::processFetchedGameDetails(Attica::BaseJob* job) +{ + Attica::ItemJob *contentJob = static_cast *>( job ); + if( contentJob->metadata().error() == Attica::Metadata::NoError ) + { + qDebug() << "It should be downloaded " << contentJob->result().downloadUrlDescription(1).link(); + } + else + { + qDebug() << "Could not fetch information"; + } +} + #include "atticamanager.moc" diff --git a/player/lib/atticamanager.h b/player/lib/atticamanager.h index 142edfa..8c186d6 100644 --- a/player/lib/atticamanager.h +++ b/player/lib/atticamanager.h @@ -21,7 +21,7 @@ #ifndef ATTICAMANAGER_H #define ATTICAMANAGER_H -#include "core/singleton.h" +#include #include @@ -53,17 +53,12 @@ namespace GluonPlayer */ Attica::Provider provider(); - private: - friend class GluonCore::Singleton; - AtticaManager(); - ~AtticaManager(); - Q_DISABLE_COPY( AtticaManager ) + bool downloadGame( const QString &id ); - Attica::ProviderManager m_manager; - Attica::Provider m_provider; - - private slots: + protected slots: void providersUpdated(); + void requestContent(); + void processFetchedGameDetails( Attica::BaseJob* job ); signals: /** @@ -74,6 +69,17 @@ namespace GluonPlayer * signal which is emitted when provider failed to loaded */ void failedToFetchProvider(); + + private: + friend class GluonCore::Singleton; + AtticaManager(); + ~AtticaManager(); + Q_DISABLE_COPY( AtticaManager ) + + Attica::ProviderManager m_manager; + Attica::Provider m_provider; + bool isDownloading; + QString m_currentId; }; } diff --git a/player/lib/gamedownloadmanager.cpp b/player/lib/gamedownloadmanager.cpp deleted file mode 100644 index d25258e..0000000 --- a/player/lib/gamedownloadmanager.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************** - * This file is part of the Gluon Development Platform - * Copyright (C) 2011 Shantanu Tushar - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "gamedownloadmanager.h" - -#include "atticamanager.h" - -#include - -using namespace GluonPlayer; - -GLUON_DEFINE_SINGLETON(GameDownloadManager) - -GameDownloadManager::GameDownloadManager() - : alreadyDownloading(false) -{ -} - -bool GameDownloadManager::addDownload ( const QString &id ) -{ - if (alreadyDownloading) - { - return false; - } - - alreadyDownloading = true; - m_id = id; - if( AtticaManager::instance()->isProviderValid() ) - { - providersUpdated(); - } - else - { - connect( AtticaManager::instance(), SIGNAL( gotProvider() ), SLOT( providersUpdated() ) ); - } - - return true; -} - -void GameDownloadManager::providersUpdated() -{ - if( AtticaManager::instance()->isProviderValid() ) - { - Attica::ItemJob *job = - AtticaManager::instance()->provider().requestContent(m_id); - connect( job, SIGNAL( finished( Attica::BaseJob* ) ), SLOT( processFetchedGameDetails( Attica::BaseJob* ) ) ); - job->start(); - } - else - { - qDebug() << "No providers found."; - } -} - -void GameDownloadManager::processFetchedGameDetails(Attica::BaseJob* job) -{ - Attica::ItemJob *contentJob = static_cast *>( job ); - if( contentJob->metadata().error() == Attica::Metadata::NoError ) - { - qDebug() << "WE SHOULD DOWNLOAD " << contentJob->result().downloadUrlDescription(1).link(); - } - else - { - qDebug() << "Could not fetch information"; - } -} - -#include "gamedownloadmanager.moc" diff --git a/player/lib/gamedownloadmanager.h b/player/lib/gamedownloadmanager.h deleted file mode 100644 index cd8f25d..0000000 --- a/player/lib/gamedownloadmanager.h +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************** - * This file is part of the Gluon Development Platform - * Copyright (C) 2011 Shantanu Tushar - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef GLUONPLAYER_GAMEDOWNLOADMANAGER_H -#define GLUONPLAYER_GAMEDOWNLOADMANAGER_H - -#include "gluon_player_export.h" -#include - -#include -#include - -#include -#include - -namespace GluonPlayer -{ - class GLUON_PLAYER_EXPORT GameDownloadManager : public GluonCore::Singleton - { - Q_OBJECT - public: - GameDownloadManager(); - bool addDownload ( const QString &id ); - - protected slots: - void providersUpdated(); - void processFetchedGameDetails ( Attica::BaseJob* job ); - - private: - bool alreadyDownloading; - QString m_id; - }; - -} - -#endif // GLUONPLAYER_GAMEDOWNLOADMANAGER_H diff --git a/player/touch/Details.qml b/player/touch/Details.qml index b17ec36..d72923c 100644 --- a/player/touch/Details.qml +++ b/player/touch/Details.qml @@ -96,7 +96,9 @@ Rectangle { margins: 5; } - onClicked: console.log("this doesn't do anything yet..."); + onClicked: { + console.log("this doesn't do anything yet..."); + } } Button { @@ -111,7 +113,9 @@ Rectangle { margins: 5; } - onClicked: console.log("this doesn't do anything yet..."); + onClicked: { + console.log("this doesn't do anything yet..."); + } } Button { @@ -127,7 +131,9 @@ Rectangle { margins: 5; } - onClicked: console.log("this doesn't do anything yet..."); + onClicked: { + console.log("this doesn't do anything yet..."); + } } Button { @@ -161,7 +167,9 @@ Rectangle { margins: 5; } - onClicked: console.log("this doesn't do anything yet..."); + onClicked: { + console.log("this doesn't do anything yet..."); + } } Text {