summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/cprquerydialog.cc24
-rw-r--r--client/cprquerydialog.h8
-rw-r--r--client/dv1394.cc2
-rw-r--r--client/dvfile.h2
-rw-r--r--client/historywidget.cc2
-rw-r--r--client/info_gui.cc5
-rw-r--r--client/mainwindow.cc5
-rw-r--r--client/messagebox.cc14
-rw-r--r--client/miav_client.cc7
-rw-r--r--client/networksender.cc54
-rw-r--r--client/networksender.h12
-rw-r--r--client/videowidget.cc1
12 files changed, 86 insertions, 50 deletions
diff --git a/client/cprquerydialog.cc b/client/cprquerydialog.cc
index 0a88b43..fc19015 100644
--- a/client/cprquerydialog.cc
+++ b/client/cprquerydialog.cc
@@ -28,7 +28,8 @@
#include "messagebox.h"
#include "cprquerydialog.h"
-#include "miav_config.h"
+#include "configuration.h"
+#include "info.h"
CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
QLabel *lname,
@@ -49,9 +50,12 @@ CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
statusbar = status;
//Read configuration
- CPR_HOST = MIaV::config->readString("cpr_host");
- CPR_PORT = MIaV::config->readInt("cpr_port");
- CPR_TIMEOUT = MIaV::config->readInt("cpr_timeout");
+ if(MIaV::config->get("cpr_host", &cpr_host))
+ MIaV::info->error("Could not read the symbol [cpr_host] from the config file.");
+ if(MIaV::config->get("cpr_port", &cpr_port))
+ MIaV::info->error("Could not read the symbol [cpr_port] from the config file.");
+ if(MIaV::config->get("cpr_timeout", &cpr_timeout))
+ MIaV::info->error("Could not read the symbol [cpr_timeout] from the config file.");
cpr[0] = '\0';
internalCpr[0] = '\0';
@@ -113,7 +117,11 @@ CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
this->move(175,150);
- listen = new CPRListen(MIaV::config->readInt("cprlisten_port"));
+ int cprlisten_port;
+ if(MIaV::config->get("cprlisten_port", &cprlisten_port))
+ MIaV::info->error("Could not read the symbol [cprlisten_port] from the config file.");
+
+ listen = new CPRListen(cprlisten_port);
listen_timer = new QTimer(this);
connect(listen_timer, SIGNAL(timeout()), SLOT(listen_timeout()));
listen->run();
@@ -137,7 +145,7 @@ CPRQueryDialog::~CPRQueryDialog()
void CPRQueryDialog::listen_timeout()
{
- string newcpr;
+ std::string newcpr;
if(listen->cprChanged()) {
char newcpr_buf[32];
newcpr = listen->getCpr();
@@ -290,8 +298,8 @@ void CPRQueryDialog::verifycpr(char *cpr)
break;
}
} else {
- cprSocket->connectToHost(CPR_HOST->c_str(), CPR_PORT);
- timer->start(CPR_TIMEOUT);
+ cprSocket->connectToHost(cpr_host.c_str(), cpr_port);
+ timer->start(cpr_timeout);
// accept();
}
}
diff --git a/client/cprquerydialog.h b/client/cprquerydialog.h
index 34e4078..5828f0e 100644
--- a/client/cprquerydialog.h
+++ b/client/cprquerydialog.h
@@ -64,8 +64,6 @@
#include <QStatusBar>
#include <string>
-using namespace std;
-
#include "messagebox.h"
@@ -112,9 +110,9 @@ private:
int test_cpr(const char *s);
/*Configuration*/
- string *CPR_HOST;
- int CPR_PORT;
- int CPR_TIMEOUT;
+ std::string cpr_host;
+ int cpr_port;
+ int cpr_timeout;
signals:
void bbs_clicked();
diff --git a/client/dv1394.cc b/client/dv1394.cc
index 7dac7b3..055825d 100644
--- a/client/dv1394.cc
+++ b/client/dv1394.cc
@@ -97,7 +97,7 @@ static int raw_reader( raw1394handle_t handle, int channel, size_t length, quadl
break;
default: // we can't handle any other data
- break;
+ break;
}
}
return 0;
diff --git a/client/dvfile.h b/client/dvfile.h
index 8a45044..ce0fb82 100644
--- a/client/dvfile.h
+++ b/client/dvfile.h
@@ -46,7 +46,7 @@ public:
Frame *readFrame();
private:
- long long last_frame;
+ long long unsigned int last_frame;
FILE* fp;
};
diff --git a/client/historywidget.cc b/client/historywidget.cc
index aff783a..6d1ff5b 100644
--- a/client/historywidget.cc
+++ b/client/historywidget.cc
@@ -26,8 +26,6 @@
*/
#include "historywidget.h"
-#include "miav_config.h"
-
#include <QResizeEvent>
HistoryWidget::HistoryWidget(QPixmap *pixmap)
diff --git a/client/info_gui.cc b/client/info_gui.cc
index aec658d..8d80f97 100644
--- a/client/info_gui.cc
+++ b/client/info_gui.cc
@@ -30,7 +30,7 @@
#include <stdarg.h>
#include <time.h>
-#include "miav_config.h"
+#include "configuration.h"
bool InfoEventHandler::eventFilter( QObject *o, QEvent *e )
{
@@ -51,7 +51,8 @@ bool InfoEventHandler::eventFilter( QObject *o, QEvent *e )
InfoGui::InfoGui(): Info()
{
- log_filename = *(MIaV::config->readString("client_log_file"));
+ if(MIaV::config->get("client_log_file", &log_filename))
+ fprintf(stderr, "Could not read symbol [client_log_file] from the conf file!\n");
InfoEventHandler *eventhandler = new InfoEventHandler();
qApp->installEventFilter( eventhandler );
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index 79d6b7e..8882d28 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -26,7 +26,10 @@
*/
#include "mainwindow.h"
#include "info.h"
-#include "miav_config.h"
+
+//#include "miav_config.h"
+#include "configuration.h"
+
#include "splashscreen.h"
#include "aboutwindow.h"
diff --git a/client/messagebox.cc b/client/messagebox.cc
index 80f902d..b2dcb87 100644
--- a/client/messagebox.cc
+++ b/client/messagebox.cc
@@ -25,7 +25,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "messagebox.h"
-#include "miav_config.h"
+
+#include "configuration.h"
#define INCH_IN_CM 2
#define BUTTON_HEIGHT 1
@@ -43,9 +44,16 @@ MessageBox::MessageBox(QWidget* parent,
msg_icon icon)
: QDialog(parent)
{
- int resolution_w = MIaV::config->readInt("pixel_width");
+ int resolution_w;
+ if(MIaV::config->get("pixel_width", &resolution_w))
+ resolution_w = 1024; // fallback!
+
//int resolution_h = config->readInt("pixel_height");
- unit = ((float)resolution_w / MIaV::config->readFloat("screensize")) / INCH_IN_CM;
+ double screensize;
+ if(MIaV::config->get("screensize", &screensize))
+ screensize = 17.0; // fallback!
+
+ unit = ((float)resolution_w / screensize) / INCH_IN_CM;
setModal(true);
setWindowTitle(name);
diff --git a/client/miav_client.cc b/client/miav_client.cc
index 787859f..d8dfc78 100644
--- a/client/miav_client.cc
+++ b/client/miav_client.cc
@@ -28,8 +28,11 @@
#include <QApplication>
+#include "configuration.h"
+
#include "mainwindow.h"
-#include "miav_config.h"
+//#include "miav_config.h"
+
#include "info_gui.h"
// The threads
@@ -41,7 +44,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- MiavConfig config(ETC"/miav.conf");
+ Configuration config(ETC"/miav.conf");
MIaV::initConfig(&config);
InfoGui info;
diff --git a/client/networksender.cc b/client/networksender.cc
index b43dcc8..e51fbe3 100644
--- a/client/networksender.cc
+++ b/client/networksender.cc
@@ -25,18 +25,26 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "networksender.h"
+#include "status.h"
+#include "configuration.h"
#include "info.h"
#include <util.h>
NetworkSender::NetworkSender(QString cpr)
{
- ip = "127.0.0.1";
- port = 6666;
+ if(MIaV::config->get("server_addr", &ip))
+ MIaV::info->error("Could not read the symbol [server_addr] from the donf file!");
+
+ if(MIaV::config->get("server_port", &port))
+ MIaV::info->error("Could not read the symbol [server_port] from the donf file!");
// Connect
- // sleep(1);
+ socket = new Socket(port);
+ socket->sconnect((char*)ip.c_str());
+ network = new Network(socket);
+
server_diskspace = 0xffffffff;
server_diskspace_max = 0xffffffff;
server_load = 0xffffffff;
@@ -51,12 +59,12 @@ NetworkSender::NetworkSender(QString cpr)
NetworkSender::~NetworkSender()
{
+ sleep(1); // FIXME: This is needed to prevent a crash!
+
// Disconnect
- sleep_1_frame();
- sleep_1_frame();
- sleep_1_frame();
- sleep_1_frame();
-
+ delete network;
+ delete socket;
+
fprintf(stderr, "Disconnect [%p]\n", this);
}
@@ -88,6 +96,8 @@ unsigned int NetworkSender::queueSize()
void NetworkSender::run()
{
+ setPriority(QThread::IdlePriority);
+
fprintf(stderr, " Run %p\n", this);
while(running) {
@@ -99,26 +109,26 @@ void NetworkSender::run()
mutex.unlock();
if(frame) {
- // TODO: Send it over the network
- sleep_1_frame();
- sleep_1_frame();
- sleep_1_frame();
- sleep_1_frame();
+ // Send the frame over the network
+ network->sendFrame(frame);
if(frame->vframe) delete frame->vframe;
if(frame->aframe) delete frame->aframe;
delete frame;
- // TODO: Read status from network
+ // Status status;
+ // network->recvStatus(&status);
+
// Set status
statusmutex.lock();
- server_diskspace_max = 1000000;
- if(server_diskspace == 0xffffffff) server_diskspace = server_diskspace_max;
- server_diskspace -= (int)(((double)rand() / (double)RAND_MAX) * 10.0);
-
- server_load = 90 + (int)(((double)rand() / (double)RAND_MAX) * 10.0);
- server_load_max = 100;
- server_ping_ms = (int)(((double)rand() / (double)RAND_MAX) * 100);
- server_fps = 25.0;
+ server_diskspace_max = 0;//status.diskspace_max;
+ server_diskspace = 0;//status.server_diskspace;
+ server_load = 0;//status.load;
+ server_load_max = 0;//status.load_max;
+
+ // TODO: Calculate these values.
+ server_ping_ms = 0;
+ server_fps = 0;
+
statusmutex.unlock();
}
}
diff --git a/client/networksender.h b/client/networksender.h
index 71ce7e7..589004b 100644
--- a/client/networksender.h
+++ b/client/networksender.h
@@ -37,6 +37,11 @@
#include "status.h"
+#include "socket.h"
+#include "network.h"
+
+#include <string>
+
class NetworkSender : public QThread
{
public:
@@ -52,8 +57,11 @@ public:
void getServerStatus(Status *status);
private:
- QString ip;
- unsigned short port;
+ Socket *socket;
+ Network *network;
+
+ std::string ip;
+ int port;
volatile bool running;
diff --git a/client/videowidget.cc b/client/videowidget.cc
index f679a3a..d9e7cd2 100644
--- a/client/videowidget.cc
+++ b/client/videowidget.cc
@@ -25,7 +25,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "videowidget.h"
-#include "miav_config.h"
#include <QMoveEvent>
#include <QResizeEvent>