summaryrefslogtreecommitdiff
path: root/client/statusbar.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/statusbar.cc')
-rw-r--r--client/statusbar.cc50
1 files changed, 36 insertions, 14 deletions
diff --git a/client/statusbar.cc b/client/statusbar.cc
index 1e25ebe..e49d45a 100644
--- a/client/statusbar.cc
+++ b/client/statusbar.cc
@@ -26,8 +26,21 @@
*/
#include "statusbar.h"
+#include "configuration.h"
+
+#include "info.h"
+
StatusBar::StatusBar(QWidget *parent, Decoder *decoder): QStatusBar(parent)
{
+ if(MIaV::config->get("server_addr", &ip))
+ MIaV::info->error("Could not read the symbol [server_addr] from the conf file!");
+
+ if(MIaV::config->get("server_port", &port))
+ MIaV::info->error("Could not read the symbol [server_port] from the conf file!");
+
+ // socket.setPort(port);
+ // socket.setAddress(ip);
+
this->decoder = decoder;
diskspace = new QProgressBar(this);
@@ -59,15 +72,23 @@ StatusBar::StatusBar(QWidget *parent, Decoder *decoder): QStatusBar(parent)
startTimer(100);
}
+#define UNKNOWN 0
void StatusBar::timerEvent(QTimerEvent *event)
{
- Status s = decoder->status();
+ UDPSocket socket(port, ip);
+
+ status_request_t request;
+ status_t status;
+ if(socket.write(&request, sizeof(request))==-1) fprintf(stderr, "ERROR! WRITE %s\n", socket.error().c_str());
+ if(socket.read(&status, sizeof(status))==-1) fprintf(stderr, "ERROR! READ %s\n", socket.error().c_str());
+
+ std::vector<thread_status_t> s = decoder->status();
QString statusmsg;
- if(s.queue_sizes.size() > 0) {
- for(int cnt = 0; cnt < s.queue_sizes.size(); cnt++) {
+ if(s.size() > 0) {
+ for(int cnt = 0; cnt < s.size(); cnt++) {
QString next;
- next.sprintf("[%d]", s.queue_sizes[cnt]);
+ next.sprintf("[%d]", s[cnt].queuelen);
statusmsg.prepend(next);
}
statusmsg.prepend("Queue: ");
@@ -77,24 +98,25 @@ void StatusBar::timerEvent(QTimerEvent *event)
}
QString dummy;
- if(s.server_ping_ms != UNKNOWN) ping->setText(dummy.sprintf("ping %d ms", s.server_ping_ms));
- else ping->setText("ping N/A");
-
- if(s.server_fps != -1) fps->setText(dummy.sprintf("fps %.2f", s.server_fps));
+ if(s.size() && s[0].fps != -1) fps->setText(dummy.sprintf("fps %.2f", s[0].fps));
else fps->setText("fps N/A");
- if(s.server_diskspace_max != UNKNOWN) {
- diskspace->setRange(0, s.server_diskspace_max);
- diskspace->setValue(s.server_diskspace);
+ /*
+ if(s.server_ping_ms != UNKNOWN) ping->setText(dummy.sprintf("ping %d ms", s.server_ping_ms));
+ else ping->setText("ping N/A");
+ */
+ if(status.diskspace_max != UNKNOWN) {
+ diskspace->setRange(0, status.diskspace_max);
+ diskspace->setValue(status.diskspace);
diskspace->setEnabled(true);
} else {
diskspace->setRange(0, 0);
diskspace->setEnabled(false);
}
- if(s.server_load_max != UNKNOWN) {
- load->setRange(0, s.server_load_max);
- load->setValue(s.server_load);
+ if(status.load_max != UNKNOWN) {
+ load->setRange(0, status.load_max);
+ load->setValue(status.load);
load->setEnabled(true);
} else {
load->setRange(0, 0);