summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2015-08-21 04:05:55 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2015-08-21 04:05:55 +0300
commitc8029a36924fdad89b2455746bfd771da723287f (patch)
treeecf981983d178176bd2e9619c7040c743c34d67d
parentc83c19a7d93ee77617c6e47bf0700346545b4611 (diff)
client-qt:
correct network thread termination downloads model skeleton filters model skeleton empty download info tabwindow main window layout initial server data requests (settings, modules, downloads) protocol: renamed most of ui_* messages to download_ui* as it more precise reworked ui related proto part added download related messages (should be sufficient for now) some work on event subscription part bit of work on module related messages added more top level messages (most of defined messages may be used now)
-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
-rw-r--r--protocol/udm.proto150
-rw-r--r--server/src/server_session.cpp6
11 files changed, 458 insertions, 47 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
diff --git a/protocol/udm.proto b/protocol/udm.proto
index 1ecb076..44f805c 100644
--- a/protocol/udm.proto
+++ b/protocol/udm.proto
@@ -32,26 +32,33 @@ enum MODULE_UI_ELEMENT_TYPE {
UI_GROUP = 5; //empty ui element to group children together in ui (tabs can be implemented using this type)
}
-message module_ui_element_info {
+message module_download_ui_element_info {
optional MODULE_UI_ELEMENT_TYPE type = 1 [default = UI_EMPTY];
- repeated module_ui_element_info children = 2;
+ repeated module_download_ui_element_info children = 2;
required string id = 3; //internal element id used to get element value (should be unique for every loaded module)
optional string name = 4 [default = "not set"]; //can be non unique
}
-message server_ui_element_data {
- required string id = 1; //should be unique for every loaded module
+
+message module_download_ui_element_data {
+ required string ui_id = 1; //should be unique for every loaded module
required string data = 2;
}
-message server_ui_data_reply {
+message module_download_ui_data {
+ repeated module_download_ui_element_data data = 1;
+ required string download_id = 2;
+}
+
+message server_download_ui_data_reply {
required string module_name = 1;
- repeated server_ui_element_data data = 2;
+ required module_download_ui_data data = 2;
}
-message client_ui_data_request {
+message client_download_ui_data_request {
required string module_name = 1;
- repeated string id = 2; //should be unique for for every loaded module
+ required string download_id = 2;
+ repeated string ui_id = 3; //should be unique for for every loaded module
}
@@ -61,36 +68,91 @@ message client_ui_data_request {
//ui subscriptions begin
-message ui_subscription_info_requiest {
- required string module_name = 1;
- repeated string id = 2;
+message download_ui_subscription_info {
+ optional client_download_ui_data_request download_ui_data = 1;
optional bool one_shot = 3 [default = false];
required int64 interval = 4;
}
-message ui_unsubscription_info {
- repeated string id = 1; //unsubscript from all updates for given id's
+message download_ui_unsubscription_info {
+ required string id = 1; //unsubscript from all updates for given id's
}
//ui subscriptions end
+//TODO: downloads related proto part
+
+//dowloads proto part begin
+
+message client_download_request {
+ required string id = 1;
+ optional bool with_content = 2 [default = false];
+}
+
+enum DOWNLOAD_CONTENT_ENTRY_TYPE {
+ DOWNLOAD_CONTENT_ENTRY_TYPE_FILE = 0;
+ DOWNLOAD_CONTENT_ENTRY_TYPE_DIRECTORY = 1;
+}
+
+message download_content_entry {
+ required string name = 1;
+ optional DOWNLOAD_CONTENT_ENTRY_TYPE type = 2 [default = DOWNLOAD_CONTENT_ENTRY_TYPE_FILE];
+ repeated download_content_entry children = 3;
+ optional int64 size = 4 [default = 0];
+}
+
+
+message download {
+ required string id = 1;
+ required string name = 2;
+ optional download_content_entry content = 3;
+ required int64 size = 4;
+ required int64 downloaded = 5;
+}
+
+message server_downloads_reply {
+ required download download = 1;
+}
+
+
+//downloads proto part end
+
// event subscription part begin
enum SUBSCRIPTION_TYPE {
SUBSCRIPTION_UI_CHANGE = 0;
SUBSCRIPTION_SETTING_CHANGE = 1;
}
-message event_subscription_info {
- repeated SUBSCRIPTION_TYPE type = 1; //subscript to one ore more event type
- optional ui_subscription_info_requiest ui_info = 2;
+message client_event_subscription_request {
+ required SUBSCRIPTION_TYPE type = 1;
+ required string module_name = 2;
+ optional download_ui_subscription_info download_ui_info = 3;
}
-message event_unsubscription_info {
- repeated SUBSCRIPTION_TYPE type = 1; //unsubscript from one ore more event type
- optional ui_unsubscription_info ui_info = 2;
+message client_event_unsubscription_request {
+ required SUBSCRIPTION_TYPE type = 1;
+ required string module_name = 2;
+ optional download_ui_unsubscription_info ui_info = 3;
}
+message server_event_subscription_reply {
+ required SUBSCRIPTION_TYPE type = 1;
+ required string module_name = 2;
+ optional download_ui_subscription_info ui_info = 3;
+
+ required bool status = 10;
+ optional string status_description = 11;
+}
+
+message server_event_unsubscription_reply {
+ required SUBSCRIPTION_TYPE type = 1;
+ required string module_name = 2;
+ optional download_ui_unsubscription_info ui_info = 3;
+
+ required bool status = 10;
+ optional string status_description = 11;
+}
//event subscription part end
@@ -117,17 +179,23 @@ message setting {
//settings common proto part end
-//TODO: settings transfer proto part (read, write, notifications ?)
//module related messages begin
+enum SERVER_MODULE_TYPE {
+ SERVER_MODULE_CORE = 0;
+ SERVER_MODULE_DOWNLOADER = 1;
+ SERVER_MODULE_METADATA_STORAGE = 2;
+}
+
message module_info
{
- required string name = 1; //unique (used as module id)
- required string version = 2;
- optional string decription = 3 [default = "no description specified"];
- repeated setting_info settings = 4; //may be ampty
- repeated module_ui_element_info ui = 5; //always complete here
+ required SERVER_MODULE_TYPE type = 1;
+ required string name = 2; //unique (used as module id)
+ required string version = 3;
+ optional string decription = 4 [default = "no description specified"];
+ repeated setting_info settings = 5; //may be ampty
+ repeated module_download_ui_element_info ui = 6; //always complete here
}
//module related messages end
@@ -142,12 +210,12 @@ enum PASSWD_HASH_TYPE {
HASH_SHA512 = 3;
}
-message client_auth_info {
+message client_auth_request {
required bytes password = 1;
optional PASSWD_HASH_TYPE hash_type = 2 [default = HASH_NONE];
}
-message server_auth_info {
+message server_auth_reply {
required bool status = 1; //true == success, false == error
optional string auth_token = 2; //must be set if no error
optional string error_description = 3; //readable description must be set on error
@@ -155,7 +223,7 @@ message server_auth_info {
//auth proto part end
-//TODO: datatransfer proto part
+//TODO: large datatransfer proto part
// it should be in separate connection
// it should be very simple
// it should have as small overhead as possible, better none at all
@@ -177,13 +245,21 @@ enum CLIENT_MSG_TYPE {
CLIENT_AUTH_REQUEST = 0;
CLIENT_DATA_TRANSFER_REQUEST = 1;
CLIENT_UI_DATA_REQUEST = 2;
+ CLIENT_MODULES_REQUEST = 3;
+ CLIENT_CORE_SETTINGS_REQUEST = 4;
+ CLIENT_SUBSCRIPTIONS_REQUEST = 5;
+ CLIENT_UNSUBSCRIPTIONS_REQUEST = 6;
+ CLIENT_DOWNLOADS_LIST_REQUEST = 7;
}
message client_msg {
required CLIENT_MSG_TYPE type = 1;
optional string auth_token = 2; //this must be set in all message type's except CLIENT_AUTH_REQUEST
- optional client_auth_info auth_info = 3;
- optional client_ui_data_request ui_data_request = 4;
+ optional client_auth_request auth_request = 3;
+ repeated client_download_ui_data_request download_ui_data_request = 4;
+ repeated client_event_subscription_request subscription_request = 5;
+ repeated client_event_unsubscription_request unsubscription_request = 6;
+ repeated client_download_request downloads_request = 7;
}
@@ -191,14 +267,24 @@ message client_msg {
enum SERVER_MSG_TYPE {
SERVER_AUTH_REPLY = 0;
SERVER_UI_DATA_REPLY = 1;
+ SERVER_MODULES_REPLY = 2;
+ SERVER_CORE_SETTINGS_REPLY = 3;
+ SERVER_SUBSCRIPTIONS_REPLY = 4;
+ SERVER_UNSUBSCRIPTIONS_REPLY = 5;
+ SERVER_DOWNLOADS_LIST_REPLY = 6;
}
message server_msg {
required SERVER_MSG_TYPE type = 1;
- optional server_ui_data_reply ui_data_reply = 2;
- optional server_auth_info auth_reply = 3;
+ optional server_download_ui_data_reply download_ui_data_reply = 2;
+ optional server_auth_reply auth_reply = 3;
+ repeated module_info server_modules_reply = 4;
+ optional module_info server_core_settings_reply = 5;
+ repeated server_event_subscription_reply subscription_reply = 6;
+ repeated server_event_unsubscription_reply unsubscription_reply = 7;
+ optional server_downloads_reply downloads = 8;
}
//top level messages end
diff --git a/server/src/server_session.cpp b/server/src/server_session.cpp
index d8c4f07..25e7820 100644
--- a/server/src/server_session.cpp
+++ b/server/src/server_session.cpp
@@ -130,11 +130,11 @@ void server_session::handle_command(client_msg *msg)
m.mutable_auth_reply()->set_status(true);
else
{
- switch(msg->auth_info().hash_type())
+ switch(msg->auth_request().hash_type())
{
case PASSWD_HASH_TYPE::HASH_NONE:
{
- if(msg->auth_info().password() != server_password)
+ if(msg->auth_request().password() != server_password)
{
m.mutable_auth_reply()->set_status(false);
m.mutable_auth_reply()->set_error_description("wrong password");
@@ -157,7 +157,7 @@ void server_session::handle_command(client_msg *msg)
{
unsigned char hash[64];
SHA512((unsigned char*)server_password.c_str(), server_password.length(), hash);
- if(msg->auth_info().password() != std::string((const char*)hash))
+ if(msg->auth_request().password() != std::string((const char*)hash))
{
m.mutable_auth_reply()->set_status(false);
m.mutable_auth_reply()->set_error_description("wrong password");