summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-11-26 16:20:07 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-30 22:07:30 +0100
commitf0a35a7d1f98877a11152ce2586e96789f1cec09 (patch)
tree0d45d2db6cd1d1d633de75622c7f9faed24c5ea6 /tools
parent6c1d37c21143a1cf3234e7298ba9be9b28ab6827 (diff)
Polished JsonDbClient behavior
Made the connection to the qtjsondb server completely transparent for users of the api - i.e. if there is no jsondb daemon running at this time, all requests (create/update/remove/query commands) will be queued in JsonDbClient and sent to the server when that becomes available. At the same time, JsonDbClient tries to connect to the server every 5 seconds if the connection was dropped for any reason (e.g. imaging qtjsondb crashes and is restarting itself - with this patch that will be transparent to users and requests will be reset after qtjsondb is back online) Change-Id: If3683c5c1fbac672c481ac3aeecf8e7a251c9211 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/jsondb-client/client.cpp21
-rw-r--r--tools/jsondb-client/client.h1
2 files changed, 17 insertions, 5 deletions
diff --git a/tools/jsondb-client/client.cpp b/tools/jsondb-client/client.cpp
index 4bad275..4105ff2 100644
--- a/tools/jsondb-client/client.cpp
+++ b/tools/jsondb-client/client.cpp
@@ -241,11 +241,11 @@ bool Client::connectToServer()
this, SLOT(error(int,int,QString)));
connect(mConnection, SIGNAL(notified(QString,QVariant,QString)),
this, SLOT(notified(QString,QVariant,QString)));
+ connect(mConnection, SIGNAL(statusChanged()), this, SLOT(statusChanged()));
+
+ if (!mConnection->isConnected())
+ qCritical() << "Not connected to the server yet... retrying";
- if (!mConnection->isConnected()) {
- qCritical() << "Unable to connect to server";
- return false;
- }
return true;
}
@@ -260,7 +260,6 @@ void Client::interactiveMode()
void Client::disconnected()
{
qCritical() << "Lost connection to the server";
- QCoreApplication::exit(0);
}
void Client::notified(const QString &notify_uuid, const QVariant &object, const QString &action)
@@ -277,6 +276,18 @@ void Client::notified(const QString &notify_uuid, const QVariant &object, const
QCoreApplication::exit(0); // Non-interactive mode just stops
}
+void Client::statusChanged()
+{
+ switch (mConnection->status()) {
+ case JsonDbClient::Ready:
+ qCritical() << "Connected to the server";
+ break;
+ case JsonDbClient::Error:
+ qCritical() << "Cannot connect to the server";
+ break;
+ }
+}
+
void Client::response(int id, const QVariant &msg)
{
Q_UNUSED(id);
diff --git a/tools/jsondb-client/client.h b/tools/jsondb-client/client.h
index 3346b4e..e18c805 100644
--- a/tools/jsondb-client/client.h
+++ b/tools/jsondb-client/client.h
@@ -97,6 +97,7 @@ protected slots:
void response(int, const QVariant &map);
void error(int id, int code, const QString &message);
void notified(const QString &notify_uuid, const QVariant &object, const QString &action);
+ void statusChanged();
signals:
void requestsProcessed();