diff --git a/player_gui.cpp b/player_gui.cpp index f20dd66..0ad35a6 100644 --- a/player_gui.cpp +++ b/player_gui.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include player_gui::player_gui(QWidget *parent) : QMainWindow(parent), @@ -100,27 +100,34 @@ size_t player_gui::write_data(void *ptr, size_t size, size_t nmemb, void *stream return written; } int player_gui::sender_holen(void){ - CURL *curl; - FILE *file; - CURLcode res; - curl_global_init(CURL_GLOBAL_ALL); - curl = curl_easy_init(); - if(curl){ - QString url = "http://" + ip + "/channels.m3u"; - std::string urls = url.toStdString(); - const char *cstr = urls.c_str(); - curl_easy_setopt(curl, CURLOPT_URL, cstr); - file = fopen("channels.m3u", "wb"); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, this->write_data); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); - res = curl_easy_perform(curl); - if(res != CURLE_OK) - fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); - else - std::cout << "Sender holen und in channels.m3u speichern..." << std::endl; - curl_easy_cleanup(curl); - } - fclose(file); + + manager = new QNetworkAccessManager(); + + QString url = "http://" + ip + "/channels.m3u"; + QNetworkRequest request(url); + QNetworkReply *reply = manager->get(request); + + connect(reply, &QNetworkReply::finished, [=]() { + if(reply->error() == QNetworkReply::NoError) + { + QByteArray response = reply->readAll(); + std::string Daten = response.toStdString(); + std::cout << Daten << std::endl; + // do something with the data... + FILE *file = fopen("channels.m3u", "wb"); + if (file!=NULL) + { + std::fputs(response,file); + } + fclose(file); + } + else // handle error + { + ui->statusbar->showMessage(reply->errorString().toUtf8().constData()); + std::cout << reply->errorString().toUtf8().constData() << std::endl; + } + }); + return 0; } int player_gui::sender_laden(void){ diff --git a/player_gui.h b/player_gui.h index 7153754..a25ab3e 100644 --- a/player_gui.h +++ b/player_gui.h @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace Ui { @@ -38,6 +39,7 @@ private: QString Name[10000]; QString URL[10000]; QString ip; + QNetworkAccessManager *manager; QFrame *videoWidget; libvlc_instance_t * inst; libvlc_media_player_t *mp=0; diff --git a/vlc-vdr.pro b/vlc-vdr.pro index b58ee38..cee039b 100644 --- a/vlc-vdr.pro +++ b/vlc-vdr.pro @@ -1,19 +1,22 @@ +QT += \ + core \ + gui \ + widgets \ + network -QT += core gui +CONFIG += \ + c++11 \ + static -greaterThan(QT_MAJOR_VERSION, 4) : QT += widgets +LIBS += \ + -lvlc -SOURCES += \ - main.cpp \ - player_gui.cpp +SOURCES += \ + main.cpp \ + player_gui.cpp -LIBS += -lcurl -lvlc -DEFINES += CURL_STATICLIB VLC_STATICLIB +HEADERS += \ + player_gui.h -HEADERS += \ - player_gui.h - -#CONFIG+= static - -FORMS += \ - player_gui.ui +FORMS += \ + player_gui.ui