summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-12-22 21:00:48 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-12-22 21:15:38 (GMT)
commit308ff634379e73a0c8668ffb0593d23f95b4dfa5 (patch)
tree21b0dd5fd9cbd90e141fd32449e298b65a40e04c /Swift/Controllers/PreviousStatusStore.cpp
parent333136df0bf355ef3ae3566f12bbdaf2795bcdaf (diff)
downloadswift-308ff634379e73a0c8668ffb0593d23f95b4dfa5.zip
swift-308ff634379e73a0c8668ffb0593d23f95b4dfa5.tar.bz2
Add a PreviousStatusStore.
Diffstat (limited to 'Swift/Controllers/PreviousStatusStore.cpp')
-rw-r--r--Swift/Controllers/PreviousStatusStore.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp
new file mode 100644
index 0000000..42f2124
--- /dev/null
+++ b/Swift/Controllers/PreviousStatusStore.cpp
@@ -0,0 +1,47 @@
+#include "PreviousStatusStore.h"
+
+#include "Swiften/Base/foreach.h"
+
+namespace Swift {
+
+PreviousStatusStore::PreviousStatusStore() {
+
+}
+
+PreviousStatusStore::~PreviousStatusStore() {
+
+}
+
+void PreviousStatusStore::addStatus(StatusShow::Type status, const String& message) {
+ //FIXME: remove old entries
+ store_.push_back(TypeStringPair(status, message));
+}
+
+std::vector<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const String& message) {
+ std::vector<TypeStringPair> suggestions;
+ suggestions.push_back(TypeStringPair(status, message));
+ return suggestions;
+}
+
+std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const String& message) {
+ std::vector<TypeStringPair> suggestions;
+ foreach (TypeStringPair status, store_) {
+ if (status.second == message) {
+ suggestions.clear();
+ suggestions.push_back(status);
+ break;
+ } else if (status.second.contains(message)) {
+ suggestions.push_back(status);
+ }
+ }
+ if (suggestions.size() == 0) {
+ TypeStringPair suggestion(StatusShow::Online, message);
+ suggestions.push_back(suggestion);
+ }
+ if (suggestions.size() == 1) {
+ suggestions = exactMatchSuggestions(suggestions[0].first, suggestions[0].second);
+ }
+ return suggestions;
+}
+
+}