diff options
author | Jo Asplin <jo.asplin@nokia.com> | 2012-05-18 10:08:30 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-24 11:51:56 +0200 |
commit | cf751d47e98e460c47888de59206b88bf40db4f1 (patch) | |
tree | e254ac4a640b61afba0ae3a6dee8bb424a8145e9 | |
parent | 9ffc22e53ef409e01b98fbc0a89726fbb2ae8ece (diff) |
Prevent talking to oneself
Talking to oneself currently causes the history command to
behave incorrectly, essentially because the following query
expression is not restrictive enough in this case:
... [?to=%self | to=%friend][?from=%self | from=%friend] ...
One way of fixing this would be to have the history command
issue a separate query for each "direction", and then sort the
final result chronologically in the client before reporting.
For now, simply prevent talking to oneself altogether.
Change-Id: I1d554293b878aa6b164002c08fb8d8994f227322
Reviewed-by: Kevin Simons <kevin.simons@nokia.com>
-rw-r--r-- | examples/client/chat/chatclient.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/examples/client/chat/chatclient.cpp b/examples/client/chat/chatclient.cpp index b9110ad..a9764a1 100644 --- a/examples/client/chat/chatclient.cpp +++ b/examples/client/chat/chatclient.cpp @@ -156,6 +156,10 @@ void ChatClient::message(const QStringList &args) message.insert(QLatin1String("_type"), QLatin1String("ChatMessage")); message.insert(QLatin1String("from"), m_username); message.insert(QLatin1String("to"), messageArgs.takeFirst()); + if (message.value(QLatin1String("from")) == message.value(QLatin1String("to"))) { + fprintf(stderr, "Talking to oneself is not supported\n"); + return; + } message.insert(QLatin1String("message"), messageArgs.join(QLatin1String(" "))); message.insert(QLatin1String("time"), QDateTime::currentDateTime().toString("ddMMyyyy hh:mm:ss")); |