summaryrefslogtreecommitdiff
path: root/client/praxisd.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-10-19 10:47:42 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-10-19 10:47:42 +0200
commit158aadf2a79a109f56866f2cc2da1d16ca4051a7 (patch)
tree21cb3f4f7e096f3fc798e66ec3a162c694b9465a /client/praxisd.cc
parent611f9ce04145d9934dc3c8dc451f0a38721f89dc (diff)
Make error handling for sync connection.
Diffstat (limited to 'client/praxisd.cc')
-rw-r--r--client/praxisd.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/client/praxisd.cc b/client/praxisd.cc
index 740825e..5a0d88e 100644
--- a/client/praxisd.cc
+++ b/client/praxisd.cc
@@ -295,14 +295,25 @@ PraxisdSync::PraxisdSync(QString host, unsigned short int port)
{
this->host = host;
this->port = port;
+ this->running = true;
start();
}
+PraxisdSync::~PraxisdSync()
+{
+ this->running = false;
+ wsem.release();
+ wait();
+}
+
void PraxisdSync::run()
{
Praxisd praxisd(host, port);
+ connect(&praxisd, SIGNAL(networkError(QString)),
+ this, SLOT(networkError(QString)), Qt::DirectConnection);
+
connect(&praxisd, SIGNAL(gotCaveList(CaveVector)),
this, SLOT(gotCaveList(CaveVector)), Qt::DirectConnection);
@@ -314,7 +325,13 @@ void PraxisdSync::run()
while(true) {
wsem.acquire();
+
+ // Reset error state
+ error = false;
+ errorStr = "";
+ if(this->running == false) break;
+
switch(request_type) {
case Praxisd::journal:
break;
@@ -333,6 +350,26 @@ void PraxisdSync::run()
exec();
}
+
+ rsem.release();
+}
+
+bool PraxisdSync::hasError()
+{
+ return error;
+}
+
+QString PraxisdSync::errorString()
+{
+ return errorStr;
+}
+
+void PraxisdSync::networkError(QString err)
+{
+ error = true;
+ errorStr = err;
+ rsem.release();
+ quit();
}
void PraxisdSync::gotCaveList(CaveVector cl)