the event data is now downloaded from the fanny-server

This commit is contained in:
Dorian Zedler 2018-12-30 20:56:26 +01:00
parent ae7d59f9ec
commit 689f2dd2ae
2 changed files with 31 additions and 4 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<manifest package="com.itsblue.flgvertretungtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.9.2" android:versionCode="11" android:installLocation="auto">
<manifest package="com.itsblue.flgvertretungtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.9.3" android:versionCode="12" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="fannyapp" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.itsblue.flgvertretung.MainActivity" android:label="fannyapp" android:screenOrientation="unspecified" android:launchMode="singleTop">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.itsblue.flgvertretung.MainActivity" android:label="fannyapp_alpha" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

View file

@ -227,7 +227,7 @@ float ServerConn::getProgress()
int ServerConn::getEvents(QString day){
/*
this->progress = 0;
ReturnData_t ret; //this is a custom type to store the returned data
// Call the webservice
@ -252,10 +252,37 @@ int ServerConn::getEvents(QString day){
//get the status code
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
this->progress = 1;
*/
this->progress = 0;
// Create request
QNetworkRequest request;
request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/" + day + ".txt" ) );
// Pack in credentials
QString concatenatedCredentials = this->username + ":" + this->password;
QByteArray data = concatenatedCredentials.toLocal8Bit().toBase64();
QString headerData = "Basic " + data;
request.setRawHeader( "Authorization", headerData.toLocal8Bit() );
QUrlQuery pdata;
// Send request and connect all possible signals
QNetworkReply*reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
//QNetworkReply*reply = networkManager->get( request );
connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
this, SLOT(updateProgress(qint64, qint64)));
QEventLoop loop;
loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
loop.exec();
this->progress = 1;
int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if(status_code != 200){
// if the request didn't result in a success, clear the old events, as they are probaply incorrect and return the error code
this->m_events.clear();
return(status_code.toInt());
return(status_code);
}
QString eventString = reply->readAll();