Skip to content

Commit ab04997

Browse files
committed
add flush cache on server button
1 parent c381a62 commit ab04997

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

mainwindow.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QString>
2424
#include <settingkeys.h>
2525
#include <serverconnection.h>
26+
#include "urls.h"
2627

2728
#define FILENAME_COL 0
2829
#define TRACKING_ID_COL 1
@@ -56,6 +57,9 @@ MainWindow::MainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::MainWind
5657
button = ui->centralWidget->findChild<QPushButton*>("pushButton");
5758
connect(button, SIGNAL (released()), this, SLOT (importFile()));
5859

60+
flushCacheButton = ui->centralWidget->findChild<QPushButton*>("flushCacheButton");
61+
connect(flushCacheButton, SIGNAL (released()), this, SLOT (flushServerCacheRequest()));
62+
5963
/* table ui */
6064
tw = ui->centralWidget->findChild<QTableWidget*>("tableWidget");
6165

@@ -390,11 +394,19 @@ void MainWindow::submitFileSlot(QString filename){
390394
qDebug("Request submission requested");
391395
}
392396

397+
void MainWindow::flushServerCacheRequest(){
398+
connect(serverConnection->getNetworkManager(), SIGNAL(finished(QNetworkReply*)), this,
399+
SLOT(requestFinished(QNetworkReply*)), Qt::UniqueConnection);
400+
qDebug("Req server flush");
401+
serverConnection->flushCache();
402+
}
403+
393404
void MainWindow::requestFinished(QNetworkReply *reply){
394405

395406
QString submitUrl = serverConnection->buildURLFromLocation(mySettings->value(SETTING_LOC_SUBMIT));
396407
QString statusRequestUrl = serverConnection->buildURLFromLocation(mySettings->value(SETTING_LOC_STATE));
397408
QString requestTranscriptUrl = serverConnection->buildURLFromLocation(mySettings->value(SETTING_LOC_TRANSCRIPT));
409+
QString flushCacheUrl = serverConnection->buildURLFromLocation(QString(FLUSH_SERVER_CACHE));
398410

399411
if(QString::compare(reply->url().toString(), submitUrl) == 0){
400412
addTrackingToList(reply);
@@ -403,6 +415,9 @@ void MainWindow::requestFinished(QNetworkReply *reply){
403415
}else if (reply->url().toString().startsWith(requestTranscriptUrl)) {
404416
qDebug("Saving transcript");
405417
saveTranscript(reply);
418+
}else if (reply->url().toString().startsWith(flushCacheUrl)) {
419+
showNotification("Server um Cache-Löschung gebeten.");
420+
qDebug("CacheFlushed");
406421
}else{
407422
qDebug("URL-Response: %s", qUtf8Printable(reply->url().toString()));
408423
qFatal("Unexpected responding URL");

mainwindow.h

+2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ private slots:
3030
void appyConfigChanges();
3131
void openAboutWindow();
3232
void openSpeechConfigWindow();
33+
void flushServerCacheRequest();
3334
private:
3435
Ui::MainWindow *ui;
3536
QTableWidget *tw;
3637
QPushButton *button;
38+
QPushButton *flushCacheButton;
3739
QAction *standardsMenu;
3840
QSettings *mySettings;
3941
ServerConnection *serverConnection;

mainwindow.ui

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
<item row="1" column="0">
2626
<widget class="QTableWidget" name="tableWidget"/>
2727
</item>
28+
<item row="2" column="0">
29+
<widget class="QPushButton" name="flushCacheButton">
30+
<property name="text">
31+
<string>Server Cache Leeren</string>
32+
</property>
33+
</widget>
34+
</item>
2835
</layout>
2936
</widget>
3037
<widget class="QMenuBar" name="menuBar">

0 commit comments

Comments
 (0)