void MusicRadioPlayListThread::startToDownload(const QString &id) { m_manager = new QNetworkAccessManager(this); QNetworkRequest request; request.setUrl(QUrl(playListUrl + id)); #ifndef QT_NO_SSL connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); M_LOGGER_INFO(QString("MusicRadioPlayListThread Support ssl: %1").arg(QSslSocket::supportsSsl())); QSslConfiguration sslConfig = request.sslConfiguration(); sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone); request.setSslConfiguration(sslConfig); #endif if(m_cookJar) { m_manager->setCookieJar(m_cookJar); m_cookJar->setParent(nullptr); } m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(replyError(QNetworkReply::NetworkError))); }
bool MusicUserModel::addUser(const QString &uid, const QString &pwd, const QString &mail) { setTable("MusicUser"); select(); insertRow(0); setData(index(0, fieldIndex("USERID")), uid); setData(index(0, fieldIndex("PASSWD")), userPasswordEncryption(pwd)); setData(index(0, fieldIndex("EMAIL")), mail); setData(index(0, fieldIndex("USERNAME")), uid); setData(index(0, fieldIndex("LOGINTIME")), 0); database().transaction(); if(submitAll()) { database().commit(); M_LOGGER_INFO("submit successfully"); return true; } else { M_LOGGER_INFO("submit failed"); database().rollback(); return false; } }
void MusicApplicationObject::winEvent(MSG *msg, long *) { # endif if(msg->message == WM_DEVICECHANGE) { PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)msg->lParam; switch(msg->wParam) { case DBT_DEVICETYPESPECIFIC: break; case DBT_DEVICEARRIVAL: if(lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) { PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; if (lpdbv->dbcv_flags == 0) { DWORD unitmask = lpdbv ->dbcv_unitmask; int i; for(i = 0; i < 26; ++i) { if(unitmask & 0x1) break; unitmask = unitmask >> 1; } QString dev((char)(i + 'A')); M_LOGGER_INFO(QString("USB_Arrived and The USBDisk is: %1").arg(dev)); M_SETTING_PTR->setValue(MusicSettingManager::MobileDevicePathChoiced, dev + ":/"); delete m_mobileDevices; m_mobileDevices = new MusicMobileDevicesWidget; m_mobileDevices->show(); } }
void MusicDownLoadQueryKWThread::startToPage(int offset) { if(!m_manager) { return; } M_LOGGER_INFO(QString("%1 startToPage %2").arg(getClassName()).arg(offset)); deleteAll(); QUrl musicUrl = MusicUtils::Algorithm::mdII(KW_SONG_SEARCH_URL, false) .arg(m_searchText).arg(offset).arg(m_pageSize); m_interrupt = true; m_pageTotal = 0; m_pageIndex = offset; QNetworkRequest request; request.setUrl(musicUrl); request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", MusicUtils::Algorithm::mdII(KW_UA_URL_1, ALG_UA_KEY, false).toUtf8()); setSslConfiguration(&request); m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(replyError(QNetworkReply::NetworkError))); }
void MusicDataDownloadThread::downLoadFinished() { if(!m_file) { deleteAll(); return; } m_timer.stop(); m_file->flush(); m_file->close(); QVariant redirectionTarget = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if(m_reply->error()) { m_file->remove(); } else if(!redirectionTarget.isNull()) { m_redirection = true; m_reply->deleteLater(); m_file->open(QIODevice::WriteOnly); m_file->resize(0); startRequest(m_reply->url().resolved(redirectionTarget.toUrl())); return; } else { emit downLoadDataChanged("Data"); M_LOGGER_INFO("data download has finished!"); } deleteAll(); }
MusicAudioRecorderCore::MusicAudioRecorderCore(QObject *parent) : QObject(parent) { m_mpAudioInputFile = nullptr; m_mpAudioOutputFile = nullptr; m_mpOutputFile = new QFile(this); m_mpOutputFile->setFileName( RECORD_FILE ); m_mFormatFile.setSampleSize(16); m_mFormatFile.setSampleType(QAudioFormat::SignedInt); m_mFormatFile.setByteOrder(QAudioFormat::LittleEndian); m_mFormatFile.setCodec("audio/pcm"); QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice()); if(!info.isFormatSupported(m_mFormatFile)) { M_LOGGER_WARN("input default mFormatFile not supported try to use nearest"); m_mFormatFile = info.nearestFormat(m_mFormatFile); } QAudioDeviceInfo info1(QAudioDeviceInfo::defaultOutputDevice()); if(!info1.isFormatSupported(m_mFormatFile)) { M_LOGGER_WARN("output default mFormatFile not supported - trying to use nearest"); M_LOGGER_WARN("output no support input mFormatFile."); } if(m_mFormatFile.sampleSize() != 16) { M_LOGGER_INFO(QString("audio device doesn't support 16 bit support %d bit samples, example cannot run %1") .arg(m_mFormatFile.sampleSize())); } }
MusicIdentifySongsThread::MusicIdentifySongsThread(QObject *parent) : MusicNetworkAbstract(parent) { m_manager = new QNetworkAccessManager(this); #ifndef QT_NO_SSL connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); M_LOGGER_INFO(QString("%1 Support ssl: %2").arg(getClassName()).arg(QSslSocket::supportsSsl())); #endif }
void MusicKGSongSuggestThread::downLoadFinished() { if(!m_reply || !m_manager) { deleteAll(); return; } M_LOGGER_INFO(QString("%1 downLoadFinished").arg(getClassName())); m_items.clear(); m_interrupt = false; if(m_reply->error() == QNetworkReply::NoError) { QByteArray bytes = m_reply->readAll(); QJson::Parser parser; bool ok; QVariant data = parser.parse(bytes, &ok); if(ok) { QVariantMap value = data.toMap(); if(value["error_code"].toInt() == 0 && value.contains("data")) { QVariantList datas = value["data"].toList(); foreach(const QVariant &var, datas) { if(m_interrupt) return; if(var.isNull()) { continue; } value = var.toMap(); if(value["LableName"].toString().isEmpty()) { foreach(const QVariant &var, value["RecordDatas"].toList()) { if(m_interrupt) return; if(var.isNull()) { continue; } value = var.toMap(); MusicResultsItem item; item.m_name = value["HintInfo"].toString(); m_items << item; } } break; } }
void MusicKGSongCommentsThread::downLoadFinished() { if(!m_reply) { deleteAll(); return; } M_LOGGER_INFO(QString("%1 downLoadFinished").arg(getClassName())); m_interrupt = false; if(m_reply->error() == QNetworkReply::NoError) { QByteArray bytes = m_reply->readAll(); QJson::Parser parser; bool ok; QVariant data = parser.parse(bytes, &ok); if(ok) { QVariantMap value = data.toMap(); if(value["err_code"].toInt() == 0) { m_pageTotal = value["count"].toLongLong(); QVariantList comments = value["list"].toList(); foreach(const QVariant &comm, comments) { if(comm.isNull()) { continue; } if(m_interrupt) return; MusicResultsItem comment; value = comm.toMap(); comment.m_playCount = QString::number(value["like"].toMap()["count"].toLongLong()); comment.m_updateTime = QString::number(QDateTime::fromString(value["addtime"].toString(), "yyyy-MM-dd hh:mm:ss").toMSecsSinceEpoch()); comment.m_description = value["content"].toString(); comment.m_nickName = value["user_name"].toString(); comment.m_coverUrl = value["user_pic"].toString(); emit createSearchedItem(comment); } } }
void MusicDownLoadQueryKWThread::startToSearch(QueryType type, const QString &text) { if(!m_manager) { return; } M_LOGGER_INFO(QString("%1 startToSearch %2").arg(getClassName()).arg(text)); m_currentType = type; m_searchText = text.trimmed(); emit clearAllItems(); m_musicSongInfos.clear(); startToPage(0); }
void MusicKGSongCommentsThread::startToSearch(const QString &name) { M_LOGGER_INFO(QString("%1 startToSearch %2").arg(getClassName()).arg(name)); MusicSemaphoreLoop loop; MusicDownLoadQueryKGThread *d = new MusicDownLoadQueryKGThread(this); d->setQueryAllRecords(false); d->setQuerySimplify(true); d->startToSearch(MusicDownLoadQueryThreadAbstract::MusicQuery, name); connect(d, SIGNAL(downLoadDataChanged(QString)), &loop, SLOT(quit())); loop.exec(); m_rawData["songID"].clear(); if(!d->isEmpty()) { m_rawData["songID"] = d->getMusicSongInfos().first().m_songId; startToPage(0); } }
void MusicSourceDownloadThread::startToDownload(const QString &url) { m_manager = new QNetworkAccessManager(this); QNetworkRequest request; request.setUrl(url); #ifndef QT_NO_SSL connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); M_LOGGER_INFO(QString("%1 Support ssl: %2").arg(getClassName()).arg(QSslSocket::supportsSsl())); QSslConfiguration sslConfig = request.sslConfiguration(); sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone); request.setSslConfiguration(sslConfig); #endif m_reply = m_manager->get( request ); connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished())); }
void MusicKWDiscoverListThread::downLoadFinished() { if(!m_reply) { deleteAll(); return; } M_LOGGER_INFO(QString("%1 downLoadFinished").arg(getClassName())); m_interrupt = false; if(m_reply->error() == QNetworkReply::NoError) { QByteArray bytes = m_reply->readAll(); QJson::Parser parser; bool ok; QVariant data = parser.parse(bytes, &ok); if(ok) { QVariantMap value = data.toMap(); if(value.contains("musiclist")) { QVariantList datas = value["musiclist"].toList(); int where = datas.count(); where = (where > 0) ? qrand()%where : 0; int counter = 0; foreach(const QVariant &var, datas) { if(m_interrupt) return; if((where != counter++) || var.isNull()) { continue; } QVariantMap value = var.toMap(); m_toplistInfo = QString("%1 - %2").arg(value["artist"].toString()) .arg(value["name"].toString()); } } }
void MusicTranslationThread::startToTranslation(TranslationType from, TranslationType to, const QString &data) { m_manager = new QNetworkAccessManager(this); QNetworkRequest request; request.setUrl( TRANSLATION_URL.arg(mapTypeFromEnumToString(from)) .arg(data).arg(mapTypeFromEnumToString(to)) ); #ifndef QT_NO_SSL connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); M_LOGGER_INFO(QString("%1 Support ssl: %2").arg(getClassName()).arg(QSslSocket::supportsSsl())); QSslConfiguration sslConfig = request.sslConfiguration(); sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone); request.setSslConfiguration(sslConfig); #endif m_reply = m_manager->get( request ); connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished())); }
void MusicXMArtistSimilarThread::downLoadFinished() { if(!m_reply || !m_manager) { deleteAll(); return; } M_LOGGER_INFO(QString("%1 downLoadFinished").arg(getClassName())); m_interrupt = false; if(m_reply->error() == QNetworkReply::NoError) { QByteArray bytes = m_reply->readAll(); QJson::Parser parser; bool ok; QVariant data = parser.parse(bytes, &ok); if(ok) { QVariantList datas = data.toList(); foreach(const QVariant &var, datas) { if(m_interrupt) return; if(var.isNull()) { continue; } QVariantMap value = var.toMap(); MusicResultsItem info; info.m_id = value["artist_id"].toString(); info.m_coverUrl = value["artist_logo"].toString(); info.m_name = value["name"].toString(); info.m_updateTime.clear(); emit createSimilarItem(info); } } }
void MusicDataDownloadThread::startToDownload() { if( !m_file->exists() || m_file->size() < 4 ) { if( m_file->open(QIODevice::WriteOnly) ) { m_manager = new QNetworkAccessManager(this); #ifndef QT_NO_SSL connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); M_LOGGER_INFO(QString("MusicDataDownloadThread Support ssl: %1").arg(QSslSocket::supportsSsl())); #endif startRequest(m_url); } else { M_LOGGER_ERROR("The data file create failed"); emit downLoadDataChanged("The data file create failed"); deleteAll(); } } }
void MusicXMArtistSimilarThread::startToSearch(const QString &text) { if(!m_manager) { return; } M_LOGGER_INFO(QString("%1 startToSearch %2").arg(getClassName()).arg(text)); QUrl musicUrl = MusicUtils::Algorithm::mdII(XM_AR_SIM_URL, false).arg(text); deleteAll(); m_interrupt = true; QNetworkRequest request; request.setUrl(musicUrl); request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", MusicUtils::Algorithm::mdII(XM_UA_URL_1, ALG_UA_KEY, false).toUtf8()); setSslConfiguration(&request); m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(replyError(QNetworkReply::NetworkError))); }
void MusicDownLoadQueryXMAlbumThread::startToSingleSearch(const QString &artist) { if(!m_manager) { return; } M_LOGGER_INFO(QString("%1 startToSingleSearch %2").arg(getClassName()).arg(artist)); deleteAll(); m_interrupt = true; QNetworkRequest request; if(!m_manager || m_stateCode != MusicNetworkAbstract::Init) return; makeTokenQueryUrl(&request, MusicUtils::Algorithm::mdII(XM_AR_ALBUM_DATA_URL, false).arg(artist), MusicUtils::Algorithm::mdII(XM_AR_ALBUM_URL, false)); if(!m_manager || m_stateCode != MusicNetworkAbstract::Init) return; setSslConfiguration(&request); QNetworkReply *reply = m_manager->get(request); connect(reply, SIGNAL(finished()), SLOT(singleDownLoadFinished())); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(replyError(QNetworkReply::NetworkError))); }
void MusicKWDiscoverListThread::startToSearch() { if(!m_manager) { return; } M_LOGGER_INFO(QString("%1 startToSearch").arg(getClassName())); m_toplistInfo.clear(); QUrl musicUrl = MusicUtils::Algorithm::mdII(KW_SONG_TOPLIST_URL, false).arg(16); deleteAll(); m_interrupt = true; QNetworkRequest request; request.setUrl(musicUrl); request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); request.setRawHeader("User-Agent", MusicUtils::Algorithm::mdII(KW_UA_URL_1, ALG_UA_KEY, false).toUtf8()); setSslConfiguration(&request); m_reply = m_manager->get(request); connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished())); connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(replyError(QNetworkReply::NetworkError))); }
void MusicDownLoadQueryXMAlbumThread::downLoadFinished() { if(!m_reply || !m_manager) { deleteAll(); return; } M_LOGGER_INFO(QString("%1 downLoadFinished").arg(getClassName())); emit clearAllItems(); m_musicSongInfos.clear(); m_interrupt = false; if(m_reply->error() == QNetworkReply::NoError) { QByteArray bytes = m_reply->readAll(); QJson::Parser parser; bool ok; QVariant data = parser.parse(bytes, &ok); if(ok) { QVariantMap value = data.toMap(); if(value.contains("data")) { value = value["data"].toMap(); value = value["data"].toMap(); value = value["albumDetail"].toMap(); bool albumFlag = false; MusicResultsItem info; info.m_coverUrl = value["albumLogo"].toString(); info.m_description = value["albumName"].toString() + STRING_SPLITER + value["language"].toString() + STRING_SPLITER + value["company"].toString() + STRING_SPLITER + QDateTime::fromMSecsSinceEpoch(value["gmtPublish"].toULongLong()).toString("yyyy-MM-dd"); //////////////////////////////////////////////////////////// QVariantList datas = value["songs"].toList(); foreach(const QVariant &var, datas) { if(var.isNull()) { continue; } value = var.toMap(); MusicObject::MusicSongInformation musicInfo; musicInfo.m_singerName = MusicUtils::String::illegalCharactersReplaced(value["artistName"].toString()); musicInfo.m_songName = MusicUtils::String::illegalCharactersReplaced(value["songName"].toString()); musicInfo.m_timeLength = MusicTime::msecTime2LabelJustified(value["length"].toInt()); musicInfo.m_songId = value["songId"].toString(); musicInfo.m_albumId = value["albumId"].toString(); musicInfo.m_artistId = value["artistId"].toString(); musicInfo.m_albumName = MusicUtils::String::illegalCharactersReplaced(value["albumName"].toString()); musicInfo.m_smallPicUrl = value["albumLogo"].toString(); if(m_interrupt || !m_manager || m_stateCode != MusicNetworkAbstract::Init) return; readFromMusicSongAttribute(&musicInfo, value["listenFiles"], m_searchQuality, m_queryAllRecords); if(m_interrupt || !m_manager || m_stateCode != MusicNetworkAbstract::Init) return; if(musicInfo.m_songAttrs.isEmpty()) { continue; } //////////////////////////////////////////////////////////// if(!albumFlag) { albumFlag = true; info.m_id = musicInfo.m_albumId; info.m_name = musicInfo.m_singerName; emit createAlbumInfoItem(info); } //////////////////////////////////////////////////////////// MusicSearchedItem item; item.m_songName = musicInfo.m_songName; item.m_singerName = musicInfo.m_singerName; item.m_albumName = musicInfo.m_albumName; item.m_time = musicInfo.m_timeLength; item.m_type = mapQueryServerString(); emit createSearchedItem(item); m_musicSongInfos << musicInfo; } } }
void MusicDownLoadQueryKWThread::downLoadFinished() { if(!m_reply || !m_manager) { deleteAll(); return; } M_LOGGER_INFO(QString("%1 downLoadFinished").arg(getClassName())); m_interrupt = false; if(m_reply->error() == QNetworkReply::NoError) { QByteArray bytes = m_reply->readAll();///Get all the data obtained by request QJson::Parser parser; bool ok; QVariant data = parser.parse(bytes.replace("'", "\""), &ok); if(ok) { QVariantMap value = data.toMap(); if(value.contains("abslist")) { m_pageTotal = value["TOTAL"].toInt(); QVariantList datas = value["abslist"].toList(); foreach(const QVariant &var, datas) { if(var.isNull()) { continue; } value = var.toMap(); MusicObject::MusicSongInformation musicInfo; musicInfo.m_singerName = MusicUtils::String::illegalCharactersReplaced(value["ARTIST"].toString()); musicInfo.m_songName = MusicUtils::String::illegalCharactersReplaced(value["SONGNAME"].toString()); musicInfo.m_timeLength = MusicTime::msecTime2LabelJustified(value["DURATION"].toInt()*1000); musicInfo.m_songId = value["MUSICRID"].toString().replace("MUSIC_", ""); musicInfo.m_artistId = value["ARTISTID"].toString(); musicInfo.m_albumId = value["ALBUMID"].toString(); if(!m_querySimplify) { musicInfo.m_albumName = MusicUtils::String::illegalCharactersReplaced(value["ALBUM"].toString()); if(m_interrupt || !m_manager || m_stateCode != MusicNetworkAbstract::Init) return; readFromMusicSongPic(&musicInfo); if(m_interrupt || !m_manager || m_stateCode != MusicNetworkAbstract::Init) return; musicInfo.m_lrcUrl = MusicUtils::Algorithm::mdII(KW_SONG_LRC_URL, false).arg(musicInfo.m_songId); ///music normal songs urls readFromMusicSongAttribute(&musicInfo, value["FORMATS"].toString(), m_searchQuality, m_queryAllRecords); if(m_interrupt || !m_manager || m_stateCode != MusicNetworkAbstract::Init) return; if(musicInfo.m_songAttrs.isEmpty()) { continue; } //////////////////////////////////////////////////////////// if(!findUrlFileSize(&musicInfo.m_songAttrs)) return; //////////////////////////////////////////////////////////// MusicSearchedItem item; item.m_songName = musicInfo.m_songName; item.m_singerName = musicInfo.m_singerName; item.m_albumName = musicInfo.m_albumName; item.m_time = musicInfo.m_timeLength; item.m_type = mapQueryServerString(); emit createSearchedItem(item); } m_musicSongInfos << musicInfo; } } }