summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-05-26 16:05:56 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-05-27 14:45:33 (GMT)
commit4e1089eb6efc0488fd020f95cabad63db67c228c (patch)
tree9a71b3d565ca398eac1ede964ff9205088c50635
parent402d37b3b6cc9cd4a03bc4290d204b4977dbc1d4 (diff)
downloadswift-4e1089eb6efc0488fd020f95cabad63db67c228c.zip
swift-4e1089eb6efc0488fd020f95cabad63db67c228c.tar.bz2
Add presence to manually added contacts in 'Start Chat…' dialog
This fixes a bug where manually added contacts, i.e. the user entered the address and hit the 'Add to list' button, were missing the correct presence in the contacts list in the 'Start Chat…" dialog. Test-Information: Tested on OS X 10.11.5 with Qt 5.4.2. Tested adding a roster member via the drop down suggestion and via manually entering the JID and clicking the 'Add to list' button. In both cases the correct presence was shown. Added a test verifying that empty JIDS are invalid. Change-Id: Idb18e4ad2b5c0afb48461796f64e8f11f02a24fd
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.cpp10
-rw-r--r--Swiften/JID/UnitTest/JIDTest.cpp6
2 files changed, 14 insertions, 2 deletions
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
index ebf05b7..434da38 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp
@@ -164,15 +164,21 @@ void QtUserSearchWindow::handleContactSuggestionRequested(const QString& text) {
}
void QtUserSearchWindow::addContact() {
- if (!!firstMultiJIDPage_->jid_->getContact()) {
- contactVector_.push_back(firstMultiJIDPage_->jid_->getContact());
+ auto contactToAdd = firstMultiJIDPage_->jid_->getContact();
+ if (!!contactToAdd) {
+ contactVector_.push_back(contactToAdd);
firstMultiJIDPage_->jid_->clear();
}
+
firstMultiJIDPage_->contactList_->setList(contactVector_);
firstMultiJIDPage_->emitCompletenessCheck();
if (type_ == ChatToContact) {
firstMultiJIDPage_->groupBox->setEnabled(supportsImpromptu_ ? 1 : (contactVector_.size() < 1));
}
+
+ if (!!contactToAdd && contactToAdd->jid.isValid() && contactToAdd->statusType == StatusShow::None) {
+ onJIDUpdateRequested({contactToAdd->jid});
+ }
}
void QtUserSearchWindow::setWarning(const boost::optional<std::string>& message) {
diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp
index ffe28a1..432e7cb 100644
--- a/Swiften/JID/UnitTest/JIDTest.cpp
+++ b/Swiften/JID/UnitTest/JIDTest.cpp
@@ -15,6 +15,7 @@ class JIDTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(JIDTest);
CPPUNIT_TEST(testConstructorWithString);
+ CPPUNIT_TEST(testConstructorWithString_Empty);
CPPUNIT_TEST(testConstructorWithString_NoResource);
CPPUNIT_TEST(testConstructorWithString_NoNode);
CPPUNIT_TEST(testConstructorWithString_EmptyResource);
@@ -76,6 +77,11 @@ class JIDTest : public CppUnit::TestFixture
CPPUNIT_ASSERT(testling.isValid());
}
+ void testConstructorWithString_Empty() {
+ JID testling("");
+ CPPUNIT_ASSERT_EQUAL(false, testling.isValid());
+ }
+
void testConstructorWithString_NoResource() {
JID testling("foo@bar");