summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cprlisten.cc12
-rw-r--r--src/cprlisten.h4
-rw-r--r--src/cprquerydialog.cc7
-rw-r--r--src/cprquerydialog.h7
4 files changed, 21 insertions, 9 deletions
diff --git a/src/cprlisten.cc b/src/cprlisten.cc
index 9ecac86..62deede 100644
--- a/src/cprlisten.cc
+++ b/src/cprlisten.cc
@@ -34,8 +34,9 @@ using namespace std;
#define MAGIC_STOP_STRING "SHUTTHEFUCKUP"
-CPRListen::CPRListen(unsigned short port)
+CPRListen::CPRListen(Info *info, unsigned short port)
{
+ this->info = info;
this->port = port;
cpr = "N/A";
cprchanged = false;
@@ -54,12 +55,13 @@ void CPRListen::stop()
socket.connect("localhost", port);
socket.send_string(MAGIC_STOP_STRING);
} catch(Network_error &e) {
- cerr << "In stop(): " << e.error << endl;
+ info.error("In stop(): %s.", e.error.c_str());
}
}
void CPRListen::thread_main()
{
+ info.info("Listening for CPRs.");
while(running) {
try {
string newcpr;
@@ -74,15 +76,15 @@ void CPRListen::thread_main()
cprchanged = true;
cpr = newcpr;
mutex.unlock();
- // cerr << "Got CPR: " << cpr << endl;
+ info.info("Got CPR: %s.", cpr.c_str());
}
} catch(Network_error &e) {
- cerr << "In thread_main(): " << e.error << endl;
+ info.error("In thread_main(): %s.", e.error.c_str());
running = false;
}
}
- // cout << "fisk!" << endl;
+ info.info("Stopped listening for CPRs.");
}
bool CPRListen::cprChanged()
diff --git a/src/cprlisten.h b/src/cprlisten.h
index 5808aec..012fe4c 100644
--- a/src/cprlisten.h
+++ b/src/cprlisten.h
@@ -34,10 +34,11 @@
#include "mutex.h"
#include "aa_socket.h"
+#include "info.h"
class CPRListen: public Thread {
public:
- CPRListen(unsigned short port);
+ CPRListen(Info *info, unsigned short port);
~CPRListen();
bool cprChanged();
@@ -47,6 +48,7 @@ public:
void stop(); // Stops the call to listen
private:
+ Info *info;
volatile bool running;
AASocket *socket;
diff --git a/src/cprquerydialog.cc b/src/cprquerydialog.cc
index 552aeb6..19337a4 100644
--- a/src/cprquerydialog.cc
+++ b/src/cprquerydialog.cc
@@ -33,13 +33,15 @@
#include "cprquerydialog.h"
#include "miav_config.h"
-CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
+CPRQueryDialog::CPRQueryDialog(Info *info,
+ QLabel *lcpr,
QLabel *lname,
QWidget *parent,
const char *name,
QStatusBar *status)
: QDialog(parent, name, TRUE)
{
+ this->info = info;
setCaption(name);
// Load image
@@ -115,7 +117,7 @@ CPRQueryDialog::CPRQueryDialog(QLabel *lcpr,
this->move(175,150);
- listen = new CPRListen(config->readInt("cprlisten_port"));
+ listen = new CPRListen(info, config->readInt("cprlisten_port"));
listen_timer = new QTimer(this);
connect(listen_timer, SIGNAL(timeout()), SLOT(listen_timeout()));
listen->run();
@@ -377,6 +379,7 @@ void CPRQueryDialog::cprSocket_error(int errnum)
if(statusbar) statusbar->message(msg, 5000);
MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec();
+ //info->error(msg.c_str());
accept();
}
diff --git a/src/cprquerydialog.h b/src/cprquerydialog.h
index d9c7341..85b2659 100644
--- a/src/cprquerydialog.h
+++ b/src/cprquerydialog.h
@@ -88,10 +88,13 @@ using namespace std;
#include "cprlisten.h"
+#include "info.h"
+
class CPRQueryDialog : public QDialog {
Q_OBJECT
public:
- CPRQueryDialog(QLabel *lcpr,
+ CPRQueryDialog(Info *info,
+ QLabel *lcpr,
QLabel *lname,
QWidget * parent = 0,
const char * name = 0,
@@ -112,6 +115,8 @@ public slots:
private:
+ Info *info;
+
CPRListen *listen;
QTimer *listen_timer;