Add broadcasting to Vreen.
This commit is contained in:
parent
793dfe3676
commit
fd263d60fe
|
@ -210,6 +210,29 @@ IntReply *AudioProvider::removeFromLibrary(int aid, int oid)
|
|||
return reply;
|
||||
}
|
||||
|
||||
IdListReply *AudioProvider::setBroadcast(int aid, int oid, const IdList &targetIds)
|
||||
{
|
||||
Q_D(AudioProvider);
|
||||
|
||||
QVariantMap args;
|
||||
args.insert("audio", QString("%1_%2").arg(oid).arg(aid));
|
||||
args.insert("target_ids", join(targetIds));
|
||||
|
||||
auto reply = d->client->request<IdListReply>("audio.setBroadcast", args, ReplyPrivate::handleIdList);
|
||||
return reply;
|
||||
}
|
||||
|
||||
IdListReply *AudioProvider::resetBroadcast(const IdList &targetIds)
|
||||
{
|
||||
Q_D(AudioProvider);
|
||||
|
||||
QVariantMap args;
|
||||
args.insert("audio","");
|
||||
args.insert("target_ids", join(targetIds));
|
||||
auto reply = d->client->request<IdListReply>("audio.setBroadcast", args, ReplyPrivate::handleIdList);
|
||||
return reply;
|
||||
}
|
||||
|
||||
AudioItemListReply *AudioProvider::getAudiosByIds(const QString &ids)
|
||||
{
|
||||
Q_D(AudioProvider);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define VK_AUDIO_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include "vk_global.h"
|
||||
#include "audioitem.h"
|
||||
#include "abstractlistmodel.h"
|
||||
#include "reply.h"
|
||||
|
@ -35,6 +36,7 @@ namespace Vreen {
|
|||
class Client;
|
||||
typedef ReplyBase<AudioItemList> AudioItemListReply;
|
||||
typedef ReplyBase<AudioAlbumItemList> AudioAlbumItemListReply;
|
||||
typedef ReplyBase<QList<int>> IdListReply;
|
||||
|
||||
class AudioProviderPrivate;
|
||||
class VK_SHARED_EXPORT AudioProvider : public QObject
|
||||
|
@ -60,6 +62,8 @@ public:
|
|||
IntReply *getCount(int oid = 0);
|
||||
IntReply *addToLibrary(int aid, int oid, int gid = 0);
|
||||
IntReply *removeFromLibrary(int aid, int oid);
|
||||
IdListReply *setBroadcast(int aid, int oid, const IdList& targetIds);
|
||||
IdListReply *resetBroadcast(const IdList& targetIds);
|
||||
protected:
|
||||
QScopedPointer<AudioProviderPrivate> d_ptr;
|
||||
};
|
||||
|
|
|
@ -122,6 +122,16 @@ void ReplyPrivate::_q_network_reply_error(QNetworkReply::NetworkError code)
|
|||
emit q->resultReady(response);
|
||||
}
|
||||
|
||||
QVariant ReplyPrivate::handleIdList(const QVariant &response)
|
||||
{
|
||||
IdList ids;
|
||||
auto list = response.toList();
|
||||
foreach (auto item, list) {
|
||||
ids.append(item.toInt());
|
||||
}
|
||||
return QVariant::fromValue(ids);
|
||||
}
|
||||
|
||||
|
||||
QVariant MessageListHandler::operator()(const QVariant &response)
|
||||
{
|
||||
|
|
|
@ -50,15 +50,16 @@ public:
|
|||
void _q_reply_finished();
|
||||
void _q_network_reply_error(QNetworkReply::NetworkError);
|
||||
|
||||
static QVariant handleInt(const QVariant &response) { return response.toInt(); }
|
||||
static QVariant handleInt(const QVariant &response) { return response.toInt(); }
|
||||
static QVariant handleIdList(const QVariant& response);
|
||||
};
|
||||
|
||||
|
||||
struct MessageListHandler {
|
||||
MessageListHandler(int clientId) : clientId(clientId) {}
|
||||
QVariant operator()(const QVariant &response);
|
||||
MessageListHandler(int clientId) : clientId(clientId) {}
|
||||
QVariant operator()(const QVariant &response);
|
||||
|
||||
int clientId;
|
||||
int clientId;
|
||||
};
|
||||
|
||||
} //namespace Vreen
|
||||
|
|
Loading…
Reference in New Issue