mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-06 22:24:04 +01:00
Pass results' QSharedPointers to reply slots instead of bare pointers
This commit is contained in:
parent
e4ae4b6df5
commit
c1c6aa099b
@ -22,8 +22,6 @@
|
||||
#include "core/closure.h"
|
||||
#include "core/network.h"
|
||||
|
||||
#include <ApiRequest.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
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();
|
||||
|
@ -20,15 +20,12 @@
|
||||
|
||||
#include "addpodcastpage.h"
|
||||
|
||||
#include <ApiRequest.h>
|
||||
|
||||
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_;
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include "core/timeconstants.h"
|
||||
#include "core/utilities.h"
|
||||
|
||||
#include <ApiRequest.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QHostInfo>
|
||||
#include <QNetworkAccessManager>
|
||||
@ -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<QUrl, QList<mygpo::EpisodePtr> > 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<QUrl>)),
|
||||
reply.data(), all_urls.toList());
|
||||
this, SLOT(AddRemoveFinished(mygpo::AddRemoveResultPtr,QList<QUrl>)),
|
||||
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<QUrl>& affected_urls) {
|
||||
flushing_queue_ = false;
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <QSharedPointer>
|
||||
#include <QUrl>
|
||||
|
||||
#include <ApiRequest.h>
|
||||
|
||||
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<QSharedPointer<mygpo::Episode> >& actions);
|
||||
const QList<mygpo::EpisodePtr>& actions);
|
||||
|
||||
void ApplyActions(const QList<QSharedPointer<mygpo::Episode> >& actions,
|
||||
void ApplyActions(const QList<mygpo::EpisodePtr>& 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<QUrl>& affected_urls);
|
||||
void AddRemoveFailed(mygpo::AddRemoveResult* reply);
|
||||
void AddRemoveFailed(mygpo::AddRemoveResultPtr reply);
|
||||
|
||||
private:
|
||||
void LoadQueue();
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include "core/closure.h"
|
||||
#include "core/network.h"
|
||||
|
||||
#include <ApiRequest.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
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;
|
||||
|
||||
|
@ -20,15 +20,12 @@
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <ApiRequest.h>
|
||||
|
||||
#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_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user