TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
musicnetworkoperator.cpp
Go to the documentation of this file.
1 #include "musicnetworkoperator.h"
3 
4 static constexpr const char *IP_CHECK_URL = "ZlhkcnFzd1RabVhCZXNWM1pnbk5hT1ErL2RpMUNjK0hYQ3FXUHdCOVNGSlpDU2ZmNTZnekhHUlo3WkwrUWhtQXljNitUcjJmZ0RId004OFc5QlVibjhvRGlRSzY3QXlVbmZHNFV3bkhZdGZMU2JTZ3lJTkNhOGZJUlNhcmlBUmcvRUVrQWc9PQ==";
5 
7  : QObject(parent)
8 {
9 
10 }
11 
13 {
15  connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(downLoadFinished(QByteArray)));
17 }
18 
19 void MusicNetworkOperator::downLoadFinished(const QByteArray &bytes)
20 {
21  QString line;
22  if(bytes.isEmpty())
23  {
24  TTK_ERROR_STREAM("Input byte data is empty");
25  }
26  else
27  {
28  QJson::Parser json;
29  bool ok = false;
30  const QVariant &data = json.parse(bytes, &ok);
31  if(ok)
32  {
33  QVariantMap value = data.toMap();
34  if(value.contains("result"))
35  {
36  value = value["result"].toMap();
37  line = value["operators"].toString();
38  }
39  }
40  }
41 
42  Q_EMIT queryNetworkOperatorFinished(line);
43  deleteLater();
44 }
void queryNetworkOperatorFinished(const QString &name)
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 startToRequest(const QString &url)
static constexpr const char * IP_CHECK_URL
MusicNetworkOperator(QObject *parent=nullptr)
Main class used to convert JSON data to QVariant objects.
Definition: parser.h:40
void downLoadFinished(const QByteArray &bytes)
#define TTK_ERROR_STREAM(msg)
Definition: ttklogger.h:69
TTK_MODULE_EXPORT QString mdII(const QString &data, bool encode)