summaryrefslogtreecommitdiff
path: root/client-qt/udm-client-qt
diff options
context:
space:
mode:
Diffstat (limited to 'client-qt/udm-client-qt')
-rw-r--r--client-qt/udm-client-qt/client_session.cpp16
-rw-r--r--client-qt/udm-client-qt/connect_widget.cpp3
-rw-r--r--client-qt/udm-client-qt/downloads_model.cpp67
-rw-r--r--client-qt/udm-client-qt/downloads_model.h47
-rw-r--r--client-qt/udm-client-qt/filters_model.cpp62
-rw-r--r--client-qt/udm-client-qt/filters_model.h45
-rw-r--r--client-qt/udm-client-qt/udm-client-qt.pro8
-rw-r--r--client-qt/udm-client-qt/udm_main.cpp89
-rw-r--r--client-qt/udm-client-qt/udm_main.h12
9 files changed, 337 insertions, 12 deletions
diff --git a/client-qt/udm-client-qt/client_session.cpp b/client-qt/udm-client-qt/client_session.cpp
index 45e93b9..9cb951c 100644
--- a/client-qt/udm-client-qt/client_session.cpp
+++ b/client-qt/udm-client-qt/client_session.cpp
@@ -26,7 +26,7 @@
#include <QMetaType>
Q_DECLARE_METATYPE(server_msg);
-int shit = qRegisterMetaType <server_msg> ("server_msg");
+int server_msg_metatype__useless_id = qRegisterMetaType <server_msg> ("server_msg");
std::shared_ptr<char*> pack_data(const std::string &buf, int *size_)
{
@@ -221,11 +221,11 @@ void client_session::handle_connect(const boost::system::error_code &e)
{
emit client_connected(true, QString::fromUtf8(e.message().c_str()));
//TODO: something better ?
- {// for now hust send auth request message
+ {// for now just send auth request message
client_msg msg;
msg.set_type(CLIENT_MSG_TYPE::CLIENT_AUTH_REQUEST);
- msg.mutable_auth_info()->set_hash_type(PASSWD_HASH_TYPE::HASH_SHA512);
- msg.mutable_auth_info()->set_password(password_sha512.data());
+ msg.mutable_auth_request()->set_hash_type(PASSWD_HASH_TYPE::HASH_SHA512);
+ msg.mutable_auth_request()->set_password(password_sha512.data());
send_message(msg);
}
//listen for messages from server
@@ -305,11 +305,11 @@ void client_session::handle_write(const boost::system::error_code& error)
client_session::~client_session()
{
//TODO: correct thread termination, reimplement
- io_service_.stop();
+// io_service_.stop();
delete socket_;
- boost::asio::io_service *s = &io_service_;
- delete s;
- //emit terminate_thread();
+// boost::asio::io_service *s = &io_service_;
+// delete s;
+ emit terminate_thread();
}
/*boost::asio::io_service &client_session::io_service()
diff --git a/client-qt/udm-client-qt/connect_widget.cpp b/client-qt/udm-client-qt/connect_widget.cpp
index 2c35ea2..ee17b3c 100644
--- a/client-qt/udm-client-qt/connect_widget.cpp
+++ b/client-qt/udm-client-qt/connect_widget.cpp
@@ -33,8 +33,9 @@
connect_widget::connect_widget(QWidget *parent) : QWidget(parent)
{
edit_host = new QLineEdit(this), edit_port = new QLineEdit(this), edit_passwd = new QLineEdit(this);
+ edit_host->setText("127.0.0.1");
edit_port->setInputMask("D0000");
- edit_port->setText("1");
+ edit_port->setText("6613");
edit_passwd->setEchoMode(QLineEdit::Password);
lbl_host = new QLabel(tr("host") + ":", this);
lbl_port = new QLabel(tr("port") + ":", this);
diff --git a/client-qt/udm-client-qt/downloads_model.cpp b/client-qt/udm-client-qt/downloads_model.cpp
new file mode 100644
index 0000000..2dadc0f
--- /dev/null
+++ b/client-qt/udm-client-qt/downloads_model.cpp
@@ -0,0 +1,67 @@
+/*
+ Copyright © 2015 Gluzskiy Alexandr (sss)
+
+ This file is part of Unknown Download Manager (UDM).
+
+ UDM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ UDM 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with UDM. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "downloads_model.h"
+
+downloads_model::downloads_model(QObject *parent)
+{
+
+}
+
+int downloads_model::rowCount(const QModelIndex &parent) const
+{
+ return 0;
+}
+
+QVariant downloads_model::data(const QModelIndex &index, int role) const
+{
+ if(!index.isValid())
+ return QVariant();
+}
+
+QVariant downloads_model::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ return QVariant();
+}
+
+int downloads_model::columnCount ( const QModelIndex & parent) const
+{
+ return 1;
+}
+
+bool downloads_model::insertRows(int position, int rows, const QModelIndex &index)
+{
+ beginInsertRows(QModelIndex(), position, position+rows-1);
+ endInsertRows();
+ return true;
+}
+
+bool downloads_model::removeRows(int position, int rows, const QModelIndex &index)
+{
+ beginRemoveRows(QModelIndex(), position, position+rows-1);
+ endRemoveRows();
+ return true;
+}
+
+void downloads_model::sort ( int column, Qt::SortOrder order)
+{
+
+}
diff --git a/client-qt/udm-client-qt/downloads_model.h b/client-qt/udm-client-qt/downloads_model.h
new file mode 100644
index 0000000..5a27e90
--- /dev/null
+++ b/client-qt/udm-client-qt/downloads_model.h
@@ -0,0 +1,47 @@
+/*
+ Copyright © 2015 Gluzskiy Alexandr (sss)
+
+ This file is part of Unknown Download Manager (UDM).
+
+ UDM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ UDM 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with UDM. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+
+#ifndef DOWNLOADS_MODEL_H
+#define DOWNLOADS_MODEL_H
+
+#include <QAbstractItemModel>
+
+class downloads_model : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ downloads_model(QObject *parent = 0);
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ void sort ( int column, Qt::SortOrder order = Qt::AscendingOrder );
+
+
+signals:
+
+public slots:
+};
+
+#endif // DOWNLOADS_MODEL_H
diff --git a/client-qt/udm-client-qt/filters_model.cpp b/client-qt/udm-client-qt/filters_model.cpp
new file mode 100644
index 0000000..d69a4be
--- /dev/null
+++ b/client-qt/udm-client-qt/filters_model.cpp
@@ -0,0 +1,62 @@
+/*
+ Copyright © 2015 Gluzskiy Alexandr (sss)
+
+ This file is part of Unknown Download Manager (UDM).
+
+ UDM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ UDM 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with UDM. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "filters_model.h"
+
+
+
+filters_model::filters_model(QObject *parent)
+{
+
+}
+
+int filters_model::columnCount(const QModelIndex &parent) const
+{
+ return 1;
+}
+
+QVariant filters_model::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+ if(role != Qt::DisplayRole)
+ return QVariant();
+}
+
+QModelIndex filters_model::index(int row, int column, const QModelIndex& parent) const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+}
+
+QModelIndex filters_model::parent(const QModelIndex& index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+}
+
+int filters_model::rowCount(const QModelIndex& parent) const
+{
+ if (parent.column() > 0)
+ return 0;
+ return 0;
+
+}
diff --git a/client-qt/udm-client-qt/filters_model.h b/client-qt/udm-client-qt/filters_model.h
new file mode 100644
index 0000000..e22abee
--- /dev/null
+++ b/client-qt/udm-client-qt/filters_model.h
@@ -0,0 +1,45 @@
+/*
+ Copyright © 2015 Gluzskiy Alexandr (sss)
+
+ This file is part of Unknown Download Manager (UDM).
+
+ UDM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ UDM 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with UDM. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef FILTERS_MODEL_H
+#define FILTERS_MODEL_H
+
+#include <QAbstractItemModel>
+
+class filters_model : public QAbstractTableModel
+{
+ Q_OBJECT
+public:
+ filters_model(QObject *parent = 0);
+ virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
+ virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+
+ virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
+ virtual QModelIndex parent(const QModelIndex& index) const;
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
+
+
+signals:
+
+public slots:
+};
+
+#endif // FILTERS_MODEL_H
diff --git a/client-qt/udm-client-qt/udm-client-qt.pro b/client-qt/udm-client-qt/udm-client-qt.pro
index 3a7be9a..d64ebe4 100644
--- a/client-qt/udm-client-qt/udm-client-qt.pro
+++ b/client-qt/udm-client-qt/udm-client-qt.pro
@@ -39,8 +39,12 @@ SOURCES += main.cpp\
udm_main.cpp \
client_session.cpp \
connect_widget.cpp \
- ../../protocol/udm.pb.cc
+ ../../protocol/udm.pb.cc \
+ downloads_model.cpp \
+ filters_model.cpp
HEADERS += udm_main.h \
client_session.h \
- connect_widget.h
+ connect_widget.h \
+ downloads_model.h \
+ filters_model.h
diff --git a/client-qt/udm-client-qt/udm_main.cpp b/client-qt/udm-client-qt/udm_main.cpp
index 0089a45..17744aa 100644
--- a/client-qt/udm-client-qt/udm_main.cpp
+++ b/client-qt/udm-client-qt/udm_main.cpp
@@ -25,14 +25,25 @@
#include <QMessageBox>
#include <QStatusBar>
#include <QLabel>
+#include <QTableView>
+#include <QTreeView>
+#include <QTabWidget>
+#include <QHeaderView>
+#include <QSplitter>
+#include <QStackedLayout>
#include "connect_widget.h"
#include "client_session.h"
+#include "downloads_model.h"
+#include "filters_model.h"
udm_main::udm_main(QWidget *parent)
: QMainWindow(parent)
{
+ io_service_ = nullptr;
+ thread_client_session = nullptr;
+ //session = nullptr;
auto menu_main = this->menuBar()->addMenu(tr("Main"));
auto action_connect = menu_main->addAction(tr("Connect"));
connect(action_connect, SIGNAL(triggered()), this, SLOT(show_connect_widget()));
@@ -41,10 +52,55 @@ udm_main::udm_main(QWidget *parent)
lbl_state = new QLabel;
lbl_state->setText(tr("State") + ": " + tr("Offline"));
this->statusBar()->addPermanentWidget(lbl_state);
+
+ tbl_downloads = new QTableView;
+ tbl_downloads->setShowGrid(false);
+ mdl_downloads = new downloads_model;
+ tbl_downloads->setModel(mdl_downloads);
+ tbl_downloads->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tbl_downloads->setSortingEnabled(true);
+ tbl_downloads->horizontalHeader()->setHighlightSections(false);
+ tbl_downloads->horizontalHeader()->setMovable(true);
+ tbl_downloads->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
+ tbl_downloads->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+
+ tree_filters = new QTreeView;
+ mdl_filters = new filters_model;
+ tree_filters->setModel(mdl_filters);
+ tree_filters->header()->hide();
+ tree_filters->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ tree_filters->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tree_filters->setIndentation(10);
+
+ spl_hor = new QSplitter(Qt::Horizontal);
+ spl_hor->addWidget(tree_filters);
+ spl_hor->addWidget(tbl_downloads);
+
+ spl_hor->setStretchFactor(0, 2);
+ spl_hor->setStretchFactor(1, 10);
+
+ tabs_info = new QTabWidget;
+
+
+
+
+ spl_vert = new QSplitter(Qt::Vertical);
+ spl_vert->addWidget(spl_hor);
+ spl_vert->addWidget(tabs_info);
+
+ spl_vert->setStretchFactor(0, 3);
+ spl_vert->setStretchFactor(1, 1);
+ setCentralWidget(spl_vert);
+
}
udm_main::~udm_main()
{
+ if(thread_client_session)
+ {
+ thread_client_session->quit();
+ delete thread_client_session;
+ }
//TODO: clear all remaining data
}
@@ -59,15 +115,30 @@ void udm_main::show_connect_widget()
void udm_main::client_pre_connect_init()
{
+ if(thread_client_session)
+ {
+ delete thread_client_session;
+ thread_client_session = nullptr;
+ }
thread_client_session = new QThread(this);
+ if(io_service_)
+ {
+ delete io_service_;
+ io_service_ = nullptr;
+ }
io_service_ = new boost::asio::io_service;
+/* if(session) //crashing
+ {
+ delete session;
+ session = nullptr;
+ } */
session = new client_session(0, io_service_); //parent must be 0 here
connect(session, SIGNAL(server_message_received(server_msg)), this, SLOT(server_message_received(server_msg)));
connect(session, SIGNAL(client_connected(bool,QString)), this, SLOT(client_connected(bool,QString)));
}
void udm_main::client_connect_finalize()
{
- //connect(session, SIGNAL(terminate_thread()), thread_client_session, SLOT(terminate()));
+ connect(session, SIGNAL(terminate_thread()), thread_client_session, SLOT(quit()));
session->moveToThread(thread_client_session);
thread_client_session->start();
}
@@ -99,6 +170,22 @@ void udm_main::server_message_received(server_msg msg)
auth_token = msg.auth_reply().auth_token().c_str();
//TODO: update client status
lbl_state->setText(tr("State") + ": " + tr("Connected") + ", " + tr("Authenticated"));
+ //request modules and settings here
+ {
+ client_msg msg;
+ msg.set_type(CLIENT_MSG_TYPE::CLIENT_CORE_SETTINGS_REQUEST);
+ session->send_message(msg);
+ }
+ {
+ client_msg msg;
+ msg.set_type(CLIENT_MSG_TYPE::CLIENT_MODULES_REQUEST);
+ session->send_message(msg);
+ }
+ {
+ client_msg msg;
+ msg.set_type(CLIENT_MSG_TYPE::CLIENT_DOWNLOADS_LIST_REQUEST);
+ session->send_message(msg);
+ }
}
else
{
diff --git a/client-qt/udm-client-qt/udm_main.h b/client-qt/udm-client-qt/udm_main.h
index 8861403..9d56822 100644
--- a/client-qt/udm-client-qt/udm_main.h
+++ b/client-qt/udm-client-qt/udm_main.h
@@ -29,6 +29,12 @@
class client_session;
class QLabel;
+class QTableView;
+class QTreeView;
+class QTabWidget;
+class downloads_model;
+class filters_model;
+class QSplitter;
namespace boost {
namespace asio {
@@ -63,6 +69,12 @@ private:
boost::asio::io_service *io_service_;
QString auth_token;
QLabel *lbl_state;
+ QTableView *tbl_downloads;
+ QTreeView *tree_filters;
+ QTabWidget *tabs_info;
+ downloads_model *mdl_downloads;
+ filters_model *mdl_filters;
+ QSplitter *spl_hor, *spl_vert;
};
#endif // UDM_MAIN_H