summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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 018bda7a..88235c97 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") {