TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicsourceupdaterequest.cpp
Go to the documentation of this file.
3 
4 #include "qsync/qsyncutils.h"
5 
6 static constexpr const char *OS_VERSION_URL = "version";
7 
9  : QObject(parent)
10 {
11 
12 }
13 
15 {
17  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
19 }
20 
22 {
23  return m_rawData["version"].toString();
24 }
25 
27 {
28  return m_rawData["data"].toString();
29 }
30 
32 {
33  const QString &v = version();
34  if(v.isEmpty())
35  {
36  return true;
37  }
38  else
39  {
40  return TTK_VERSION_STR == v;
41  }
42 }
43 
44 void MusicSourceUpdateRequest::downLoadFinished(const QByteArray &bytes)
45 {
46  if(bytes.isEmpty())
47  {
48  TTK_ERROR_STREAM("Input byte data is empty");
49  }
50  else
51  {
52  QJson::Parser json;
53  bool ok = false;
54  const QVariant &data = json.parse(bytes, &ok);
55  if(!ok)
56  {
57  return;
58  }
59 
60  m_rawData = data.toMap();
61  Q_EMIT downLoadDataChanged({});
62  }
63 }
static constexpr const char * OS_VERSION_URL
void downLoadFinished(const QByteArray &bytes)
The class of the data source download request.
QVariant parse(QIODevice *io, bool *ok=0)
Read JSON string from the I/O Device and converts it to a QVariant object.
Definition: parser.cpp:69
void downLoadDataChanged(const QString &bytes)
#define TTK_VERSION_STR
Definition: ttkversion.h:171
void startToRequest(const QString &url)
Main class used to convert JSON data to QVariant objects.
Definition: parser.h:40
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:69
MusicSourceUpdateRequest(QObject *parent=nullptr)
static QString makeDataBucketUrl()
Definition: qsyncutils.cpp:90