From 4e1089eb6efc0488fd020f95cabad63db67c228c Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Thu, 26 May 2016 18:05:56 +0200 Subject: =?UTF-8?q?Add=20presence=20to=20manually=20added=20contacts=20in?= =?UTF-8?q?=20'Start=20Chat=E2=80=A6'=20dialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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& 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"); -- cgit v0.10.2-6-g49f6