summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Simons <kevin.simons@nokia.com>2012-03-26 09:15:19 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-26 18:30:48 +0200
commita3f84f262af945ac44e95902d8256662575bbef2 (patch)
tree9b33533af554e11577c3a823f8e91ca42cc047cc
parent49627eb8eb26748dfe461a7fec609f3f2c5ad22c (diff)
Add support for historical notifications to jsondb-client
Change-Id: Ia626c4a9a0088d8628becd6a5ea4639505ab4b77 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
-rw-r--r--tools/jsondb-client/client.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/jsondb-client/client.cpp b/tools/jsondb-client/client.cpp
index 018bda7..88235c9 100644
--- a/tools/jsondb-client/client.cpp
+++ b/tools/jsondb-client/client.cpp
@@ -53,8 +53,7 @@
QT_USE_NAMESPACE
-const char* InputThread::commands[] = { "changesSince",
- "create {\"",
+const char* InputThread::commands[] = { "create {\"",
"help",
"load",
"notify create [?",
@@ -404,8 +403,7 @@ void Client::usage()
<< " remove [partition:<name>] OBJECT" << std::endl
<< " remove [partition:<name>] STRING [limit]" << std::endl
<< " query [partition:<name>] STRING [limit]" << std::endl
- << " notify [partition:<name>] ACTIONS QUERY" << std::endl
- << " changesSince [partition:<name>] STATENUMBER [type1 type2 ...]" << std::endl
+ << " notify [partition:<name>] ACTIONS QUERY [starting-state]" << std::endl
<< " load FILE1 FILE2 ..." << std::endl
<< " help" << std::endl
<< " quit" << std::endl
@@ -419,7 +417,9 @@ void Client::usage()
<< " query [?_type=\"duck\"]" << std::endl
<< " remove {\"_uuid\": \"{18c9d905-5860-464e-a6dd-951464e366de}\", \"_version\": \"1-134f23dbb2\"}" << std::endl
<< " remove [?_type=\"duck\"]" << std::endl
- << " notify create,remove [?_type=\"duck\"]" << std::endl;
+ << " notify create,remove [?_type=\"duck\"]" << std::endl
+ << " notify create,remove [?_type=\"duck\"] 53" << std::endl;
+
QString usageInfo = QString::fromStdString(out.str());
InputThread::print(usageInfo);
@@ -500,13 +500,28 @@ bool Client::processCommand(const QString &command)
}
actions |= action;
}
+
+ int startingState = 0;
QString query = rest.mid(s+1).trimmed();
+ if (!query.endsWith(']')) {
+ bool ok;
+ int index = query.lastIndexOf(' ');
+ int state = query.right(query.length() - index).trimmed().toInt(&ok);
+ if (ok)
+ startingState = state;
+ query = query.left(index);
+ }
+
if (mDebug)
qDebug() << "Creating notification:" << alist << ":" << query;
+
QtJsonDb::QJsonDbWatcher *watcher = new QtJsonDb::QJsonDbWatcher(this);
watcher->setPartition(partition);
watcher->setQuery(query);
watcher->setWatchedActions(actions);
+ if (startingState != 0)
+ watcher->setInitialStateNumber(startingState);
+
connect(watcher, SIGNAL(notificationsAvailable(int)), this, SLOT(onNotificationsAvailable(int)));
connect(watcher, SIGNAL(statusChanged(QtJsonDb::QJsonDbWatcher::Status)),
this, SLOT(onNotificationStatusChanged(QtJsonDb::QJsonDbWatcher::Status)));
@@ -558,8 +573,6 @@ bool Client::processCommand(const QString &command)
filenames[i] = filename.mid(1, filename.size()-2);
}
loadFiles(filenames);
- } else if (cmd == "changesSince") {
- qWarning() << "Not yet supported";
} else if (cmd == "connect") {
mConnection->connectToServer();
} else if (cmd == "disconnect") {