summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoanna Hulboj <joanna.hulboj@isode.com>2017-03-13 21:51:04 (GMT)
committerKevin Smith <kevin.smith@isode.com>2017-05-04 10:34:00 (GMT)
commitcfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1 (patch)
treefb2564927189eb1cc8e28ac82fd96f6161b54d31 /Swiften
parentdc70dbb6af039fba8f7a1cece8db4bb119deaabd (diff)
downloadswift-cfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1.zip
swift-cfea60eda7f3ce5fa10ed92c50c19fc1ee264eb1.tar.bz2
Fix recent chat entries being incorrectly displayed
Recent chat entries were displayed as a randomly generated numbers instead of impromptus (if invitees were offline). Title displayed in the Recent Chat List for MUC is now based on both the occupants and invitees. To do that a collection with all the invitees is being stored (new) along the occupants (existing). Test-Information: From Swift menu choose Actions, Start Chat... Add some offline contacts to the List of Participants and press Finish. Recent chat entry will have correct name (combined of contact names). Change-Id: Ie076165e8dbb493aa261cc49ca3ab1e0c1c542a8
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/Algorithm.h8
-rw-r--r--Swiften/Client/DummyStanzaChannel.h14
2 files changed, 18 insertions, 4 deletions
diff --git a/Swiften/Base/Algorithm.h b/Swiften/Base/Algorithm.h
index c481aa8..108dbe3 100644
--- a/Swiften/Base/Algorithm.h
+++ b/Swiften/Base/Algorithm.h
@@ -125,31 +125,39 @@ namespace Swift {
/*
* Functors
*/
template<typename K, typename V>
class PairFirstEquals {
public:
PairFirstEquals(const K& value) : value(value) {
}
bool operator()(const std::pair<K,V>& pair) const {
return pair.first == value;
}
private:
K value;
};
template<typename K, typename V>
class PairSecondEquals {
public:
PairSecondEquals(const V& value) : value(value) {
}
bool operator()(const std::pair<K,V>& pair) const {
return pair.second == value;
}
private:
V value;
};
+
+ template <typename Map>
+ bool key_compare(Map const& lhs, Map const& rhs) {
+
+ auto pred = [](decltype(*lhs.begin()) a, decltype(a) b) { return a.first == b.first; };
+
+ return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), pred);
+ }
}
diff --git a/Swiften/Client/DummyStanzaChannel.h b/Swiften/Client/DummyStanzaChannel.h
index fc2f05b..4cc0f7e 100644
--- a/Swiften/Client/DummyStanzaChannel.h
+++ b/Swiften/Client/DummyStanzaChannel.h
@@ -1,99 +1,105 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <vector>
#include <Swiften/Client/StanzaChannel.h>
namespace Swift {
class DummyStanzaChannel : public StanzaChannel {
public:
- DummyStanzaChannel() : available_(true) {}
+ DummyStanzaChannel() {}
virtual void sendStanza(std::shared_ptr<Stanza> stanza) {
sentStanzas.push_back(stanza);
}
void setAvailable(bool available) {
available_ = available;
onAvailableChanged(available);
}
virtual void sendIQ(std::shared_ptr<IQ> iq) {
sentStanzas.push_back(iq);
}
virtual void sendMessage(std::shared_ptr<Message> message) {
sentStanzas.push_back(message);
}
virtual void sendPresence(std::shared_ptr<Presence> presence) {
sentStanzas.push_back(presence);
}
virtual std::string getNewIQID() {
- return "test-id";
+ std::string id = "test-id";
+ if (uniqueIDs_) {
+ id += "-" + std::to_string(idCounter_++);
+ }
+ return id;
}
virtual bool isAvailable() const {
return available_;
}
virtual bool getStreamManagementEnabled() const {
return false;
}
template<typename T> bool isRequestAtIndex(size_t index, const JID& jid, IQ::Type type) {
if (index >= sentStanzas.size()) {
return false;
}
std::shared_ptr<IQ> iqStanza = std::dynamic_pointer_cast<IQ>(sentStanzas[index]);
return iqStanza && iqStanza->getType() == type && iqStanza->getTo() == jid && iqStanza->getPayload<T>();
}
bool isResultAtIndex(size_t index, const std::string& id) {
if (index >= sentStanzas.size()) {
return false;
}
std::shared_ptr<IQ> iqStanza = std::dynamic_pointer_cast<IQ>(sentStanzas[index]);
return iqStanza && iqStanza->getType() == IQ::Result && iqStanza->getID() == id;
}
bool isErrorAtIndex(size_t index, const std::string& id) {
if (index >= sentStanzas.size()) {
return false;
}
std::shared_ptr<IQ> iqStanza = std::dynamic_pointer_cast<IQ>(sentStanzas[index]);
return iqStanza && iqStanza->getType() == IQ::Error && iqStanza->getID() == id;
}
template<typename T> std::shared_ptr<T> getStanzaAtIndex(size_t index) {
if (sentStanzas.size() <= index) {
return std::shared_ptr<T>();
}
return std::dynamic_pointer_cast<T>(sentStanzas[index]);
}
template<typename T> size_t countSentStanzaOfType() {
size_t count = 0;
for (auto& stanza : sentStanzas) {
if (std::dynamic_pointer_cast<T>(stanza)) {
count++;
}
}
return count;
}
std::vector<Certificate::ref> getPeerCertificateChain() const {
return std::vector<Certificate::ref>();
}
std::vector<std::shared_ptr<Stanza> > sentStanzas;
- bool available_;
+ bool available_ = true;
+ bool uniqueIDs_ = false;
+ unsigned int idCounter_ = 0;
};
}