From c1c6aa099b4b553c6f83ea51812499f46caa14e1 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 19 Mar 2012 21:16:37 +0000 Subject: [PATCH] Pass results' QSharedPointers to reply slots instead of bare pointers --- src/podcasts/gpoddersearchpage.cpp | 18 +++++++-------- src/podcasts/gpoddersearchpage.h | 11 ++++------ src/podcasts/gpoddersync.cpp | 34 ++++++++++++++--------------- src/podcasts/gpoddersync.h | 21 +++++++----------- src/podcasts/gpoddertoptagspage.cpp | 18 +++++++-------- src/podcasts/gpoddertoptagspage.h | 11 ++++------ 6 files changed, 48 insertions(+), 65 deletions(-) diff --git a/src/podcasts/gpoddersearchpage.cpp b/src/podcasts/gpoddersearchpage.cpp index 632246cf4..bf9f430e6 100644 --- a/src/podcasts/gpoddersearchpage.cpp +++ b/src/podcasts/gpoddersearchpage.cpp @@ -22,8 +22,6 @@ #include "core/closure.h" #include "core/network.h" -#include - #include GPodderSearchPage::GPodderSearchPage(Application* app, QWidget* parent) @@ -46,17 +44,17 @@ void GPodderSearchPage::SearchClicked() { mygpo::PodcastListPtr list(api_->search(ui_->query->text())); NewClosure(list, SIGNAL(finished()), - this, SLOT(SearchFinished(mygpo::PodcastList*)), - list.data()); + this, SLOT(SearchFinished(mygpo::PodcastListPtr)), + list); NewClosure(list, SIGNAL(parseError()), - this, SLOT(SearchFailed(mygpo::PodcastList*)), - list.data()); + this, SLOT(SearchFailed(mygpo::PodcastListPtr)), + list); NewClosure(list, SIGNAL(requestError(QNetworkReply::NetworkError)), - this, SLOT(SearchFailed(mygpo::PodcastList*)), - list.data()); + this, SLOT(SearchFailed(mygpo::PodcastListPtr)), + list); } -void GPodderSearchPage::SearchFinished(mygpo::PodcastList* list) { +void GPodderSearchPage::SearchFinished(mygpo::PodcastListPtr list) { emit Busy(false); model()->clear(); @@ -69,7 +67,7 @@ void GPodderSearchPage::SearchFinished(mygpo::PodcastList* list) { } } -void GPodderSearchPage::SearchFailed(mygpo::PodcastList* list) { +void GPodderSearchPage::SearchFailed(mygpo::PodcastListPtr list) { emit Busy(false); model()->clear(); diff --git a/src/podcasts/gpoddersearchpage.h b/src/podcasts/gpoddersearchpage.h index 79c245120..02dc750a2 100644 --- a/src/podcasts/gpoddersearchpage.h +++ b/src/podcasts/gpoddersearchpage.h @@ -20,15 +20,12 @@ #include "addpodcastpage.h" +#include + class QNetworkAccessManager; class Ui_GPodderSearchPage; -namespace mygpo { - class ApiRequest; - class PodcastList; -} - class GPodderSearchPage : public AddPodcastPage { Q_OBJECT @@ -40,8 +37,8 @@ public: private slots: void SearchClicked(); - void SearchFinished(mygpo::PodcastList* list); - void SearchFailed(mygpo::PodcastList* list); + void SearchFinished(mygpo::PodcastListPtr list); + void SearchFailed(mygpo::PodcastListPtr list); private: Ui_GPodderSearchPage* ui_; diff --git a/src/podcasts/gpoddersync.cpp b/src/podcasts/gpoddersync.cpp index 08cdbb18b..e638c4976 100644 --- a/src/podcasts/gpoddersync.cpp +++ b/src/podcasts/gpoddersync.cpp @@ -26,8 +26,6 @@ #include "core/timeconstants.h" #include "core/utilities.h" -#include - #include #include #include @@ -153,21 +151,21 @@ void GPodderSync::GetUpdatesNow() { mygpo::DeviceUpdatesPtr reply(api_->deviceUpdates(username_, DeviceId(), timestamp)); NewClosure(reply, SIGNAL(finished()), - this, SLOT(DeviceUpdatesFinished(mygpo::DeviceUpdates*)), - reply.data()); + this, SLOT(DeviceUpdatesFinished(mygpo::DeviceUpdatesPtr)), + reply); NewClosure(reply, SIGNAL(parseError()), - this, SLOT(DeviceUpdatesFailed(mygpo::DeviceUpdates*)), - reply.data()); + this, SLOT(DeviceUpdatesFailed(mygpo::DeviceUpdatesPtr)), + reply); NewClosure(reply, SIGNAL(requestError(QNetworkReply::NetworkError)), - this, SLOT(DeviceUpdatesFailed(mygpo::DeviceUpdates*)), - reply.data()); + this, SLOT(DeviceUpdatesFailed(mygpo::DeviceUpdatesPtr)), + reply); } -void GPodderSync::DeviceUpdatesFailed(mygpo::DeviceUpdates* reply) { +void GPodderSync::DeviceUpdatesFailed(mygpo::DeviceUpdatesPtr reply) { qLog(Warning) << "Failed to get gpodder.net device updates"; } -void GPodderSync::DeviceUpdatesFinished(mygpo::DeviceUpdates* reply) { +void GPodderSync::DeviceUpdatesFinished(mygpo::DeviceUpdatesPtr reply) { // Remember episode actions for each podcast, so when we add a new podcast // we can apply the actions immediately. QMap > episodes_by_podcast; @@ -339,22 +337,22 @@ void GPodderSync::FlushUpdateQueue() { qLog(Info) << "Sending" << all_urls.count() << "changes to gpodder.net"; NewClosure(reply, SIGNAL(finished()), - this, SLOT(AddRemoveFinished(mygpo::AddRemoveResult*,QList)), - reply.data(), all_urls.toList()); + this, SLOT(AddRemoveFinished(mygpo::AddRemoveResultPtr,QList)), + reply, all_urls.toList()); NewClosure(reply, SIGNAL(parseError()), - this, SLOT(AddRemoveFailed(mygpo::AddRemoveResult*)), - reply.data()); + this, SLOT(AddRemoveFailed(mygpo::AddRemoveResultPtr)), + reply); NewClosure(reply, SIGNAL(requestError(QNetworkReply::NetworkError)), - this, SLOT(AddRemoveFailed(mygpo::AddRemoveResult*)), - reply.data()); + this, SLOT(AddRemoveFailed(mygpo::AddRemoveResultPtr)), + reply); } -void GPodderSync::AddRemoveFailed(mygpo::AddRemoveResult* reply) { +void GPodderSync::AddRemoveFailed(mygpo::AddRemoveResultPtr reply) { flushing_queue_ = false; qLog(Warning) << "Failed to update gpodder.net subscriptions"; } -void GPodderSync::AddRemoveFinished(mygpo::AddRemoveResult* reply, +void GPodderSync::AddRemoveFinished(mygpo::AddRemoveResultPtr reply, const QList& affected_urls) { flushing_queue_ = false; diff --git a/src/podcasts/gpoddersync.h b/src/podcasts/gpoddersync.h index 6de7904af..9ba6b1e6e 100644 --- a/src/podcasts/gpoddersync.h +++ b/src/podcasts/gpoddersync.h @@ -27,6 +27,8 @@ #include #include +#include + class Application; class Podcast; class PodcastBackend; @@ -37,13 +39,6 @@ class QNetworkAccessManager; class QNetworkReply; class QTimer; -namespace mygpo { - class AddRemoveResult; - class ApiRequest; - class DeviceUpdates; - class Episode; -} - class GPodderSync : public QObject { Q_OBJECT @@ -78,22 +73,22 @@ private slots: void LoginFinished(QNetworkReply* reply, const QString& username, const QString& password); - void DeviceUpdatesFinished(mygpo::DeviceUpdates* reply); - void DeviceUpdatesFailed(mygpo::DeviceUpdates* reply); + void DeviceUpdatesFinished(mygpo::DeviceUpdatesPtr reply); + void DeviceUpdatesFailed(mygpo::DeviceUpdatesPtr reply); void NewPodcastLoaded(PodcastUrlLoaderReply* reply, const QUrl& url, - const QList >& actions); + const QList& actions); - void ApplyActions(const QList >& actions, + void ApplyActions(const QList& actions, PodcastEpisodeList* episodes); void SubscriptionAdded(const Podcast& podcast); void SubscriptionRemoved(const Podcast& podcast); void FlushUpdateQueue(); - void AddRemoveFinished(mygpo::AddRemoveResult* reply, + void AddRemoveFinished(mygpo::AddRemoveResultPtr reply, const QList& affected_urls); - void AddRemoveFailed(mygpo::AddRemoveResult* reply); + void AddRemoveFailed(mygpo::AddRemoveResultPtr reply); private: void LoadQueue(); diff --git a/src/podcasts/gpoddertoptagspage.cpp b/src/podcasts/gpoddertoptagspage.cpp index 1634b5979..1fda03164 100644 --- a/src/podcasts/gpoddertoptagspage.cpp +++ b/src/podcasts/gpoddertoptagspage.cpp @@ -20,8 +20,6 @@ #include "core/closure.h" #include "core/network.h" -#include - #include const int GPodderTopTagsPage::kMaxTagCount = 100; @@ -51,18 +49,18 @@ void GPodderTopTagsPage::Show() { mygpo::TagListPtr tag_list(api_->topTags(kMaxTagCount)); NewClosure(tag_list, SIGNAL(finished()), - this, SLOT(TagListLoaded(mygpo::TagList*)), - tag_list.data()); + this, SLOT(TagListLoaded(mygpo::TagListPtr)), + tag_list); NewClosure(tag_list, SIGNAL(parseError()), - this, SLOT(TagListFailed(mygpo::TagList*)), - tag_list.data()); + this, SLOT(TagListFailed(mygpo::TagListPtr)), + tag_list); NewClosure(tag_list, SIGNAL(requestError(QNetworkReply::NetworkError)), - this, SLOT(TagListFailed(mygpo::TagList*)), - tag_list.data()); + this, SLOT(TagListFailed(mygpo::TagListPtr)), + tag_list); } } -void GPodderTopTagsPage::TagListLoaded(mygpo::TagList* tag_list) { +void GPodderTopTagsPage::TagListLoaded(mygpo::TagListPtr tag_list) { emit Busy(false); foreach (mygpo::TagPtr tag, tag_list->list()) { @@ -70,7 +68,7 @@ void GPodderTopTagsPage::TagListLoaded(mygpo::TagList* tag_list) { } } -void GPodderTopTagsPage::TagListFailed(mygpo::TagList* list) { +void GPodderTopTagsPage::TagListFailed(mygpo::TagListPtr list) { emit Busy(false); done_initial_load_ = false; diff --git a/src/podcasts/gpoddertoptagspage.h b/src/podcasts/gpoddertoptagspage.h index ed8702702..320297945 100644 --- a/src/podcasts/gpoddertoptagspage.h +++ b/src/podcasts/gpoddertoptagspage.h @@ -20,15 +20,12 @@ #include +#include + #include "addpodcastpage.h" class QNetworkAccessManager; -namespace mygpo { - class ApiRequest; - class TagList; -} - class GPodderTopTagsPage : public AddPodcastPage { Q_OBJECT @@ -42,8 +39,8 @@ public: virtual void Show(); private slots: - void TagListLoaded(mygpo::TagList* tag_list); - void TagListFailed(mygpo::TagList* tag_list); + void TagListLoaded(mygpo::TagListPtr tag_list); + void TagListFailed(mygpo::TagListPtr tag_list); private: QNetworkAccessManager* network_;