diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-14 12:31:13 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-14 12:31:13 +0300 |
commit | 1d6ced38a89547aaf2cc3745876360f0e5086474 (patch) | |
tree | bbc627e26fb759884d8aefd4a789805a98beec31 /client-qt/udm-client-qt/udm_main.cpp | |
parent | b8dd66d71676603dc3081b1de07f2e76732737bd (diff) |
protocol:
added module field to client_download_add_request as required
server:
small handle_command redesign to avoid crashes
client-qt:
implemented all basic features of download add widget (working now, tested)
Diffstat (limited to 'client-qt/udm-client-qt/udm_main.cpp')
-rw-r--r-- | client-qt/udm-client-qt/udm_main.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/client-qt/udm-client-qt/udm_main.cpp b/client-qt/udm-client-qt/udm_main.cpp index ca5b397..e6ba87c 100644 --- a/client-qt/udm-client-qt/udm_main.cpp +++ b/client-qt/udm-client-qt/udm_main.cpp @@ -121,6 +121,7 @@ void udm_main::client_pre_connect_init() { if(thread_client_session) { + thread_client_session->quit(); delete thread_client_session; thread_client_session = nullptr; } @@ -173,7 +174,7 @@ void udm_main::server_message_received(server_msg msg) if(msg.auth_reply().status()) { auth_token = msg.auth_reply().auth_token(); - //TODO: update client status + btn_add->setEnabled(true); //we can add downloads now lbl_state->setText(tr("State") + ": " + tr("Connected") + ", " + tr("Authenticated")); //request modules and settings here { @@ -231,12 +232,16 @@ void udm_main::server_message_received(server_msg msg) void udm_main::create_buttons() { btn_start = new QPushButton(this); + btn_start->setEnabled(false); connect(btn_start, SIGNAL(clicked(bool)), this, SLOT(btn_start_clicked())); btn_stop = new QPushButton(this); + btn_stop->setEnabled(false); connect(btn_stop, SIGNAL(clicked(bool)), this, SLOT(btn_stop_clicked())); btn_del = new QPushButton(this); + btn_del->setEnabled(false); connect(btn_del, SIGNAL(clicked(bool)), this, SLOT(btn_del_clicked())); btn_add = new QPushButton(this); + btn_add->setEnabled(false); connect(btn_add, SIGNAL(clicked(bool)), this, SLOT(btn_add_clicked())); button_bar = new QToolBar(this); button_bar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -276,10 +281,29 @@ void udm_main::btn_stop_clicked() void udm_main::btn_add_clicked() { download_add_widget *w = new download_add_widget(modules); - //TODO: connect slots/signals here + connect(w, SIGNAL(got_download_settings(std::string, std::map<int,std::string>)), this, SLOT(got_download_settings(std::string, std::map<int,std::string>))); w->show(); } +void udm_main::got_download_settings(std::string module_name, std::map<int, std::string> settings) +{ + if(!settings.empty()) + { + client_msg msg; + msg.set_auth_token(auth_token); + msg.set_type(CLIENT_MSG_TYPE::CLIENT_DOWNLOAD_ADD); + client_download_add_request *r = msg.mutable_download_add_request(); + r->set_module_name(module_name); + for(auto i : settings) + { + int_string_pair *p = r->add_params(); + p->set_id(i.first); + p->set_value(i.second); + } + session->send_message(msg); + } +} + void udm_main::btn_del_clicked() { @@ -294,6 +318,10 @@ void udm_main::client_connected(bool success, QString error_text) msg.setText(tr("client connection error with error:") + error_text); msg.exec(); lbl_state->setText(tr("State") + ": " + tr("Connection error")); + btn_add->setEnabled(false); + btn_del->setEnabled(false); + btn_start->setEnabled(false); + btn_stop->setEnabled(false); } else { @@ -306,5 +334,9 @@ void udm_main::client_connected(bool success, QString error_text) void udm_main::client_disconnected() { + btn_add->setEnabled(false); + btn_del->setEnabled(false); + btn_start->setEnabled(false); + btn_stop->setEnabled(false); lbl_state->setText(tr("State") + ": " + tr("Disconnected")); } |