diff --git a/pokerth_game.pro b/pokerth_game.pro
index b3337e79..e55395c7 100644
--- a/pokerth_game.pro
+++ b/pokerth_game.pro
@@ -210,7 +210,8 @@ HEADERS += src/engine/game.h \
src/gui/qt/gametable/mycashlabel.h \
src/gui/qt/sound/soundevents.h \
src/gui/qt/mymessagebox/mymessagebox.h \
- src/gui/qt/logfiledialog/logfiledialog.h
+ src/gui/qt/logfiledialog/logfiledialog.h \
+ src/gui/qt/logfiledialog/callback.h
!gui_800x480 {
FORMS += src/gui/qt/gametable.ui \
@@ -287,7 +288,8 @@ SOURCES += src/pokerth.cpp \
src/gui/qt/gametable/mycashlabel.cpp \
src/gui/qt/sound/soundevents.cpp \
src/gui/qt/mymessagebox/mymessagebox.cpp \
- src/gui/qt/logfiledialog/logfiledialog.cpp
+ src/gui/qt/logfiledialog/logfiledialog.cpp \
+ src/gui/qt/logfiledialog/callback.cpp
TRANSLATIONS = ts/pokerth_af.ts \
ts/pokerth_bg.ts \
ts/pokerth_zhcn.ts \
diff --git a/src/gui/qt/logfiledialog.ui b/src/gui/qt/logfiledialog.ui
index 84176c2c..31452b7a 100644
--- a/src/gui/qt/logfiledialog.ui
+++ b/src/gui/qt/logfiledialog.ui
@@ -14,6 +14,85 @@
Dialog
+ -
+
+
-
+
+
+ Export as HTML
+
+
+
+ :/gfx/text-html.png:/gfx/text-html.png
+
+
+
+ -
+
+
+ Export as txt
+
+
+
+ :/gfx/text-plain.png:/gfx/text-plain.png
+
+
+
+ -
+
+
+ Save as ...
+
+
+
+ :/gfx/filesave.png:/gfx/filesave.png
+
+
+
+ -
+
+
+ Delete
+
+
+
+ :/gfx/editdelete.png:/gfx/editdelete.png
+
+
+
+
+
+ -
+
+
-
+
+
+ Preview:
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
-
-
@@ -81,89 +160,21 @@
- -
-
-
-
-
-
- Preview:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
-
- -
-
-
-
-
-
- Export as HTML
-
-
-
- :/gfx/text-html.png:/gfx/text-html.png
-
-
-
- -
-
-
- Export as txt
-
-
-
- :/gfx/text-plain.png:/gfx/text-plain.png
-
-
-
- -
-
-
- Save as ...
-
-
-
- :/gfx/filesave.png:/gfx/filesave.png
-
-
-
- -
-
-
- Delete
-
-
-
- :/gfx/editdelete.png:/gfx/editdelete.png
-
-
-
-
-
- -
+
-
Qt::Horizontal
- -
-
-
- Qt::Horizontal
+
-
+
+
+ Analyse Logfile ...
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+ :/gfx/view-statistics.png:/gfx/view-statistics.png
diff --git a/src/gui/qt/logfiledialog/callback.cpp b/src/gui/qt/logfiledialog/callback.cpp
new file mode 100644
index 00000000..086c2dcc
--- /dev/null
+++ b/src/gui/qt/logfiledialog/callback.cpp
@@ -0,0 +1,19 @@
+#include "callback.h"
+
+Callback::Callback()
+{
+
+}
+
+
+size_t
+Callback::writeCallback(char* buf, size_t size, size_t nmemb, void* up)
+{
+ data = "";
+
+ for (int c = 0; c
-class LogUploadCallback
+class Callback
{
public:
- LogUploadCallback();
+ Callback();
size_t writeCallback(char* buf, size_t size, size_t nmemb, void* up);
+
std::string getData() { return data; }
private:
@@ -17,4 +18,4 @@ private:
};
-#endif // LOGUPLOADCALLBACK_H
+#endif // CALLBACK_H
diff --git a/src/gui/qt/logfiledialog/logfiledialog.cpp b/src/gui/qt/logfiledialog/logfiledialog.cpp
index 5aac2f43..432ade26 100644
--- a/src/gui/qt/logfiledialog/logfiledialog.cpp
+++ b/src/gui/qt/logfiledialog/logfiledialog.cpp
@@ -22,18 +22,21 @@
#include "guilog.h"
#include "configfile.h"
#include "mymessagebox.h"
+#include "callback.h"
+#include "curl/curl.h"
LogFileDialog::LogFileDialog(QWidget *parent, ConfigFile *c) :
QDialog(parent), myConfig(c),
ui(new Ui::LogFileDialog)
{
- ui->setupUi(this);
+ ui->setupUi(this);
connect( ui->pushButton_deleteLog, SIGNAL(clicked()), this, SLOT (deleteLogFile()));
connect( ui->pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml()));
connect( ui->pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt()));
connect( ui->pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs()));
connect( ui->treeWidget_logFiles, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showLogFilePreview()));
+ connect( ui->pushButton_analyseLogfile, SIGNAL(clicked()), this, SLOT (uploadFile()));
}
LogFileDialog::~LogFileDialog()
@@ -167,3 +170,61 @@ void LogFileDialog::keyPressEvent ( QKeyEvent * event )
}
}
}
+
+
+Callback* curl_writedata = new Callback();
+void writeCallback(char* buf, size_t size, size_t nmemb, void* up)
+{
+ curl_writedata->writeCallback(buf, size, nmemb, up);
+}
+
+void LogFileDialog::uploadFile()
+{
+ QTreeWidgetItem* selectedItem = ui->treeWidget_logFiles->currentItem();
+
+ if(selectedItem) {
+ file.setFileName(selectedItem->data(0, Qt::UserRole).toString());
+
+ CURL *curl;
+ CURLcode res;
+
+ struct curl_httppost* post = NULL;
+ struct curl_httppost* last = NULL;
+
+ curl = curl_easy_init();
+
+ if(curl) {
+
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "pdb_file",
+ CURLFORM_FILE, file.fileName().toStdString().c_str(),
+ CURLFORM_END);
+
+ curl_easy_setopt(curl, CURLOPT_URL, "http://pokerth.net/floty_upload/upload.php");
+ curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback);
+
+ res = curl_easy_perform(curl);
+
+ if(res) {
+ qDebug() << "curl_easy_perform failed: " << res << endl;
+ }
+
+ id = QString(curl_writedata->getData().data()).trimmed();
+
+ curl_formfree(post);
+
+ if(id.length() == 40 && !id.contains("ERROR")) {
+
+ qDebug() << id << endl;
+ QDesktopServices::openUrl(QUrl("http://logfile-analysis.pokerth.net/?ID="+id));
+
+ } else {
+ qDebug() << QString::fromStdString(curl_writedata->getData()) << endl;
+ }
+ } else {
+ qDebug() << "curl_easy_init failed\n" << endl;
+ }
+ }
+
+}
diff --git a/src/gui/qt/logfiledialog/logfiledialog.h b/src/gui/qt/logfiledialog/logfiledialog.h
index 7ba586a4..2ef2c929 100644
--- a/src/gui/qt/logfiledialog/logfiledialog.h
+++ b/src/gui/qt/logfiledialog/logfiledialog.h
@@ -20,7 +20,7 @@
#define LOGFILEDIALOG_H
#include
-
+#include
namespace Ui {
class LogFileDialog;
@@ -29,6 +29,7 @@ namespace Ui {
class guiLog;
class ConfigFile;
+class Callback;
class LogFileDialog : public QDialog
{
@@ -48,12 +49,17 @@ public slots:
void exportLogToTxt();
void saveLogFileAs();
void showLogFilePreview();
- void keyPressEvent ( QKeyEvent * event );
+ void keyPressEvent ( QKeyEvent * event );
+ void uploadFile();
-private:
+private:
ConfigFile *myConfig;
guiLog *myGuiLog;
- Ui::LogFileDialog *ui;
+ Ui::LogFileDialog *ui;
+ int writer(char *data, size_t size, size_t nmemb,std::string *buffer);
+ QFile file;
+ QString id;
+
};
#endif // LOGFILEDIALOG_H
diff --git a/src/gui/qt/logfiledialog/loguploadcallback.cpp b/src/gui/qt/logfiledialog/loguploadcallback.cpp
deleted file mode 100644
index 60c8533b..00000000
--- a/src/gui/qt/logfiledialog/loguploadcallback.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*****************************************************************************
- * PokerTH - The open source texas holdem engine *
- * Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
- * *
- * This program is free software: you can redistribute it and/or modify *
- * it under the terms of the GNU Affero General Public License as *
- * published by the Free Software Foundation, either version 3 of the *
- * License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU Affero General Public License for more details. *
- * *
- * You should have received a copy of the GNU Affero General Public License *
- * along with this program. If not, see . *
- *****************************************************************************/
-
-#include "loguploadcallback.h"
-
-LogUploadCallback::LogUploadCallback()
-{
-
-}
-
-size_t
-LogUploadCallback::writeCallback(char* buf, size_t size, size_t nmemb, void* up)
-{
- data = "";
-
- for (int c = 0; c