summaryrefslogtreecommitdiff
path: root/client/statusbar.cc
diff options
context:
space:
mode:
authordeva <deva>2006-08-25 21:20:07 +0000
committerdeva <deva>2006-08-25 21:20:07 +0000
commit8196872e3b240ef93fc17dd3c05a7d97a8015d88 (patch)
treee531edeb1c7178a8e58170c84645ce8eb706624e /client/statusbar.cc
parent347b1d8ed3a4f780f3a5c0d57a04eab05ca517a2 (diff)
Rearranged the network and socket code.origin
Added status messages sent over the network using udp packets.
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);