summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2019-01-15 10:53:33 (GMT)
committerTobias Markmann <tm@ayena.de>2019-01-15 10:55:04 (GMT)
commite618ab44aa09d6b69b08b14d43ee9ff2dd6abb0e (patch)
tree8e84092fba2f6a01b75b8cf313208aa2c8897216
parent6f6ad903d9e248f59bddedb3ab4cae41a7d8bec0 (diff)
parent6874d64ed2684d83cb3e340f58f6c8c5089aa857 (diff)
downloadswift-e618ab44aa09d6b69b08b14d43ee9ff2dd6abb0e.zip
swift-e618ab44aa09d6b69b08b14d43ee9ff2dd6abb0e.tar.bz2
Merge tag 'swift-4.x' into master
* branch 'swift-4.x': Update for Debian Don't crash on missing bookmark result Add missing include for QAbstractItemModel Update Debian changelog Fix convertToWindowsVersion() function to handle more RCs Fix error response handling when requesting VCards Test-Information: ./scons test=all succeeded on macOS 10.14.2. Change-Id: I99d20a8b0e1b0be501fbbe95adebbff15f510184
-rw-r--r--BuildTools/SCons/Tools/textfile.py2
-rw-r--r--BuildTools/SCons/Version.py191
-rw-r--r--Swift/ChangeLog.md12
-rw-r--r--Swift/Packaging/Debian/changelog.debian-unstable18
-rw-r--r--Swift/Packaging/Debian/debian/copyright2
-rw-r--r--Swift/QtUI/UserSearch/QtUserSearchWindow.h3
-rw-r--r--Swiften/ChangeLog.md6
-rw-r--r--Swiften/VCards/UnitTest/VCardManagerTest.cpp127
-rw-r--r--Swiften/VCards/VCardManager.cpp5
9 files changed, 317 insertions, 49 deletions
diff --git a/BuildTools/SCons/Tools/textfile.py b/BuildTools/SCons/Tools/textfile.py
index 02fc54a..73105ad 100644
--- a/BuildTools/SCons/Tools/textfile.py
+++ b/BuildTools/SCons/Tools/textfile.py
@@ -57,19 +57,19 @@ from SCons.Util import is_String, is_Sequence, is_Dict
def _do_subst(node, subs):
"""
Fetch the node contents and replace all instances of the keys with
their values. For example, if subs is
{'%VERSION%': '1.2345', '%BASE%': 'MyProg', '%prefix%': '/bin'},
then all instances of %VERSION% in the file will be replaced with
1.2345 and so forth.
"""
- contents = node.get_text_contents()
+ contents = node.get_contents().decode('utf-8')
if not subs: return contents
for (k,v) in subs:
contents = re.sub(k, v, contents)
return contents
def _action(target, source, env):
# prepare the line separator
linesep = env['LINESEPARATOR']
if linesep is None:
diff --git a/BuildTools/SCons/Version.py b/BuildTools/SCons/Version.py
index b69cdca..001374a 100644
--- a/BuildTools/SCons/Version.py
+++ b/BuildTools/SCons/Version.py
@@ -1,18 +1,18 @@
-import subprocess, os, datetime, re, os.path
+import subprocess, os, datetime, re, os.path, sys, unittest
def getGitBuildVersion(root, project) :
tag = git("describe --tags --exact --match \"" + project + "-*\"", root)
if tag :
return tag.rstrip()[len(project)+1:]
tag = git("describe --tags --match \"" + project + "-*\"", root)
if tag :
- m = re.match(project + "-(.*)-(.*)-(.*)", tag.decode('utf-8'))
+ m = re.match(project + "-(.*)-(.*)-(.*)", tag)
if m :
return m.group(1) + "-dev" + m.group(2)
return None
def git(cmd, root) :
full_cmd = "git " + cmd
p = subprocess.Popen(full_cmd, cwd=root, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=(os.name != "nt"))
gitVersion = p.stdout.read()
# error = p.stderr.read()
@@ -31,38 +31,171 @@ def getBuildVersion(root, project) :
f.close()
return version
gitVersion = getGitBuildVersion(root, project)
if gitVersion :
return gitVersion
return datetime.date.today().strftime("%Y%m%d")
-def convertToWindowsVersion(version) :
- version_match = re.match("(\d+)\.(\d+)(.*)", version.decode('utf-8'))
- major = version_match and int(version_match.group(1)) or 0
- minor = version_match and int(version_match.group(2)) or 0
- if version_match and len(version_match.group(3)) == 0 :
- patch = 60000
- else :
- match = re.match("^beta(\d+)(.*)", version_match.group(3))
- build_string = ""
- if match :
- patch = 1000*int(match.group(1))
- build_string = match.group(2)
- else :
- rc_match = re.match("^rc(\d+)(.*)", version_match.group(3))
- if rc_match :
- patch = 10000*int(rc_match.group(1))
- build_string = rc_match.group(2)
- else :
- patch = 0
- alpha_match = re.match("^alpha(.*)", version_match.group(3))
- if alpha_match :
- build_string = alpha_match.group(1)
-
- if len(build_string) > 0 :
- build_match = re.match("^-dev(\d+)", build_string)
- if build_match :
- patch += int(build_match.group(1))
+# The following conversion allows us to use version tags the format:
+# major.0
+# major.0.(0 to 9)
+#
+# Either from above followed by:
+# alpha(0 to 4)
+# beta(0 to 6)
+# rc(1 to 11)
+#
+# Followed by an optional -dev(1-65535) for off tag builds.
+def convertToWindowsVersion(version):
+ match = re.match(r"(?P<major>\d+)\.(?P<minor>\d+)\.?(?P<patch>\d+)?(?:(?P<stage>rc|beta|alpha)(?P<stage_number>\d+)?)?(?:-dev(?P<dev>\d+))?", version)
+ assert(match)
+ major, minor, patch = (0, 0, 0)
+ groups = match.groupdict()
+ assert(groups['major'])
+ major = int(groups['major'])
+
+ if groups['minor']:
+ assert(int(groups['minor']) == 0)
+
+ if groups['patch']:
+ assert(0 <= int(groups['patch']) <= 9)
+ minor = int(groups['patch']) * 25
+
+ stage = groups["stage"]
+ if stage:
+ stageNumber = groups['stage_number']
+ if not stageNumber or stageNumber == "":
+ stageNumber = 0
+ else:
+ stageNumber = int(stageNumber)
+
+ if stage == "alpha":
+ assert(0 <= stageNumber <= 4)
+ minor = 1 + stageNumber
+ elif stage == "beta":
+ assert(0 <= stageNumber <= 6)
+ minor = 6 + stageNumber
+ elif stage == "rc":
+ assert(1 <= stageNumber <= 11)
+ minor = 12 + stageNumber
+ else:
+ assert(False)
+ else:
+ minor = minor + 24
+
+ if groups['dev']:
+ patch = 1 + int(groups['dev'])
+
+ # The following constraints are set by Windows Installer framework
+ assert(0 <= major <= 255)
+ assert(0 <= minor <= 255)
+ assert(0 <= patch <= 65535)
return (major, minor, patch)
+
+# Test Windows version mapping scheme
+class convertToWindowsVersionTest(unittest.TestCase):
+ def testWindowsVersionsAreDescending(self):
+ versionStringsWithOldVersions = [
+ ("5.0rc11", None),
+ ("5.0rc1", None),
+ ("5.0beta6", None),
+ ("5.0alpha4", None),
+ ("5.0alpha2", None),
+ ("5.0alpha", None),
+ ("4.0.9", None),
+ ("4.0.1", None),
+ ("4.0", (4, 0, 60000)),
+ ("4.0rc6", (4, 0, 60000)),
+ ("4.0rc5", (4, 0, 50000)),
+ ("4.0rc4", (4, 0, 40000)),
+ ("4.0rc3", (4, 0, 30000)),
+ ('4.0rc2-dev34', (4, 0, 20034)),
+ ('4.0rc2-dev33', (4, 0, 20033)),
+ ('4.0rc2-dev31', (4, 0, 20031)),
+ ('4.0rc2-dev30', (4, 0, 20030)),
+ ('4.0rc2-dev29', (4, 0, 20029)),
+ ('4.0rc2-dev27', (4, 0, 20027)),
+ ('4.0rc2-dev39', (4, 0, 20039)),
+ ('4.0rc2', (4, 0, 20000)),
+ ('4.0rc1', (4, 0, 10000)),
+ ('4.0beta2-dev203', (4, 0, 2203)),
+ ('4.0beta2-dev195', (4, 0, 2195)),
+ ('4.0beta2-dev177', (4, 0, 2177)),
+ ('4.0beta2-dev171', (4, 0, 2171)),
+ ('4.0beta2-dev154', (4, 0, 2154)),
+ ('4.0beta2-dev150', (4, 0, 2150)),
+ ('4.0beta2-dev142', (4, 0, 2142)),
+ ('4.0beta2-dev140', (4, 0, 2140)),
+ ('4.0beta2-dev133', (4, 0, 2133)),
+ ('4.0beta2-dev118', (4, 0, 2118)),
+ ('4.0beta2-dev112', (4, 0, 2112)),
+ ('4.0beta2-dev93', (4, 0, 2093)),
+ ('4.0beta2-dev80', (4, 0, 2080)),
+ ('4.0beta2-dev72', (4, 0, 2072)),
+ ('4.0beta2-dev57', (4, 0, 2057)),
+ ('4.0beta2-dev44', (4, 0, 2044)),
+ ('4.0beta2-dev38', (4, 0, 2038)),
+ ('4.0beta2-dev29', (4, 0, 2029)),
+ ('4.0beta2-dev15', (4, 0, 2015)),
+ ('4.0beta2', (4, 0, 2000)),
+ ('4.0beta1', (4, 0, 1000)),
+ ('4.0alpha-dev80', (4, 0, 80)),
+ ('4.0alpha-dev50', (4, 0, 50)),
+ ('4.0alpha-dev43', (4, 0, 43)),
+ ('4.0alpha-dev21', (4, 0, 21)),
+ ('3.0', (3, 0, 60000)),
+ ('3.0rc3', (3, 0, 30000)),
+ ('3.0rc2', (3, 0, 20000)),
+ ('3.0rc1', (3, 0, 10000)),
+ ('3.0beta2-dev124', (3, 0, 2124)),
+ ('3.0beta2-dev81', (3, 0, 2081)),
+ ('3.0beta2-dev50', (3, 0, 2050)),
+ ('3.0beta2-dev44', (3, 0, 2044)),
+ ('3.0beta2-dev40', (3, 0, 2040)),
+ ('3.0beta2-dev26', (3, 0, 2026)),
+ ('3.0beta2', (3, 0, 2000)),
+ ('3.0beta1', (3, 0, 1000)),
+ ('3.0alpha-dev529', (3, 0, 529)),
+ ('3.0alpha-dev528', (3, 0, 528)),
+ ('3.0alpha-dev526', (3, 0, 526)),
+ ('3.0alpha-dev524', (3, 0, 524)),
+ ('3.0alpha-dev515', (3, 0, 515)),
+ ]
+ windowsVersionMapping = list(map(lambda (x,y): (x, convertToWindowsVersion(x)), versionStringsWithOldVersions))
+
+ def testThatBetaIsHigherThanAlpha(self):
+ self.assertTrue(convertToWindowsVersion("3.0beta0") > convertToWindowsVersion("3.0alpha0"))
+ self.assertTrue(convertToWindowsVersion("3.0beta6") > convertToWindowsVersion("3.0alpha1"))
+ self.assertTrue(convertToWindowsVersion("3.0beta6") > convertToWindowsVersion("3.0alpha4"))
+
+ def testThatRcIsHigherThanAlphaAndBeta(self):
+ self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0alpha0"))
+ self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0alpha4"))
+ self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0alpha0"))
+ self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0alpha4"))
+ self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0beta0"))
+ self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0beta6"))
+ self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0beta0"))
+ self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0beta6"))
+
+ def testThatStableIsHigherThanAlphaAndBetaAndRc(self):
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha0"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha4"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha0"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha4"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0beta0"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0beta6"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0rc1"))
+ self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0rc11"))
+
+if __name__ == '__main__':
+ if len(sys.argv) == 1:
+ unittest.main()
+ elif len(sys.argv) == 2:
+ print convertToWindowsVersion(sys.argv[1])
+ sys.exit(0)
+ else:
+ print "Error: Simply run the script without arguments or pass a single argument."
+ sys.exit(-1)
diff --git a/Swift/ChangeLog.md b/Swift/ChangeLog.md
index a00f41c..9152b50 100644
--- a/Swift/ChangeLog.md
+++ b/Swift/ChangeLog.md
@@ -1,9 +1,21 @@
+4.0.3 (2019-01-03)
+------------------
+- Fix handling of empty bookmark responses
+
+4.0.2 (2018-04-05)
+------------------
+- Fix versioning issue in Windows Installer process
+
+4.0.1 (2018-03-28)
+------------------
+- Allow setting vCard on servers that do not return an empty vCard on fresh accounts
+
4.0 (2018-03-20)
----------------
- New chat theme including a new font
- Support for message carbons (XEP-0280)
- Enabled trellis mode as a default feature, allowing several tiled chats windows to be shown at once
- Redesigned keyword highlighting
- Improve date formatting
- Fix Last Message Correction in multi client scenarios
- Fix UI layout issue for translations that require right-to-left (RTL) layout
diff --git a/Swift/Packaging/Debian/changelog.debian-unstable b/Swift/Packaging/Debian/changelog.debian-unstable
index ca9ffec..f2bf2c5 100644
--- a/Swift/Packaging/Debian/changelog.debian-unstable
+++ b/Swift/Packaging/Debian/changelog.debian-unstable
@@ -1,9 +1,27 @@
+swift-im (4.0.3-1) UNRELEASED; urgency=medium
+
+ * New chat theme including a new font
+ * Support for message carbons (XEP-0280)
+ * Enabled trellis mode as a default feature, allowing several tiled chats windows to be shown at once
+ * Redesigned keyword highlighting
+ * Improve date formatting
+ * Fix Last Message Correction in multi client scenarios
+ * Fix UI layout issue for translations that require right-to-left (RTL) layout
+ * Fix UX issues in trellis mode
+ * Improvements to font size handling in the chat theme
+ * Add AppImage for Linux 64-bit as a supported platform
+ * Improved spell checker support on Linux
+ * Allow setting vCard on servers that do not return an empty vCard on fresh accounts
+ * And assorted smaller features and usability enhancements. Closes: 840151, 889062
+
+ -- Kevin Smith <kevin@kismith.co.uk> Thu, 03 Jan 2019 13:59:07 +0100
+
swift-im (3.0.4-1) unstable; urgency=low
* New upstream release
* Allow compiling with newer boosts. Closes: 810839, 822131
* Switch to Qt5 instead of Qt4. Closes: 784532, 745807
* Fix some platform detection in build system. Closes: 757554
* Rewrite rules file with dh sequencer.
* Drop -dbg package.
diff --git a/Swift/Packaging/Debian/debian/copyright b/Swift/Packaging/Debian/debian/copyright
index a0c2c79..9219930 100644
--- a/Swift/Packaging/Debian/debian/copyright
+++ b/Swift/Packaging/Debian/debian/copyright
@@ -1,15 +1,15 @@
This package was debianized by the Swift project <packages@swift.im>,
with help from Olly Betts <olly@survex.com>.
The upstream sources were obtained from http://swift.im.
-Copyright (C) 2010-2016 Isode Limited.
+Copyright (C) 2010-2019 Isode Limited.
Licensed under the GNU General Public License.
See /usr/share/common-licenses/GPL-3 for the full license.
This software is subject to the OpenSSL license exception.
Additional permission under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or combining
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.h b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
index d487a91..f67712e 100644
--- a/Swift/QtUI/UserSearch/QtUserSearchWindow.h
+++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.h
@@ -1,19 +1,20 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <set>
+#include <QAbstractItemModel>
#include <QWizard>
#include <Swift/Controllers/UIInterfaces/UserSearchWindow.h>
#include <Swift/QtUI/UserSearch/ui_QtUserSearchWizard.h>
namespace Swift {
class UserSearchModel;
class UserSearchDelegate;
diff --git a/Swiften/ChangeLog.md b/Swiften/ChangeLog.md
index a656292..60355b4 100644
--- a/Swiften/ChangeLog.md
+++ b/Swiften/ChangeLog.md
@@ -1,14 +1,18 @@
5-in-progress
-------------
- Update build system from scons 2.4.0 to 3.0.1
-4.0 (2017-03-20)
+4.0.1 (2018-03-28)
+------------------
+- Fix handling errors when fetching own vCard
+
+4.0 (2018-03-20)
----------------
- Moved code-base to C++11
- Use C++11 threading instead of Boost.Thread library
- Use C++11 smart pointers instead of Boost's
- Migrated from Boost.Signals to Boost.Signals2
- Build without warnings on our CI platforms
- General cleanup like remove of superflous files and #include statements. This means header files that previously were included implictly need to be explicitly included now
- Support IPv6 addresses in URLs
- Handle sessions being closed by the server
diff --git a/Swiften/VCards/UnitTest/VCardManagerTest.cpp b/Swiften/VCards/UnitTest/VCardManagerTest.cpp
index 3d5338d..669c3ff 100644
--- a/Swiften/VCards/UnitTest/VCardManagerTest.cpp
+++ b/Swiften/VCards/UnitTest/VCardManagerTest.cpp
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <memory>
#include <vector>
#include <boost/bind.hpp>
@@ -25,19 +25,29 @@ using namespace Swift;
class VCardManagerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(VCardManagerTest);
CPPUNIT_TEST(testGet_NewVCardRequestsVCard);
CPPUNIT_TEST(testGet_ExistingVCard);
CPPUNIT_TEST(testRequest_RequestsVCard);
CPPUNIT_TEST(testRequest_ReceiveEmitsNotification);
CPPUNIT_TEST(testRequest_Error);
CPPUNIT_TEST(testRequest_VCardAlreadyRequested);
CPPUNIT_TEST(testRequest_AfterPreviousRequest);
- CPPUNIT_TEST(testRequestOwnVCard);
+
+ CPPUNIT_TEST(testRequestVCard_ReturnFullVCard);
+ CPPUNIT_TEST(testRequestVCard_ReturnEmptyVCard);
+ CPPUNIT_TEST(testRequestVCard_ReturnItemNotFoundError);
+ CPPUNIT_TEST(testRequestVCard_ReturnFeatureNotImplementedError);
+
+ CPPUNIT_TEST(testRequestOwnVCard_ReturnFullVCard);
+ CPPUNIT_TEST(testRequestOwnVCard_ReturnEmptyVCard);
+ CPPUNIT_TEST(testRequestOwnVCard_ReturnItemNotFoundError);
+ CPPUNIT_TEST(testRequestOwnVCard_ReturnFeatureNotImplementedError);
+
CPPUNIT_TEST(testCreateSetVCardRequest);
CPPUNIT_TEST(testCreateSetVCardRequest_Error);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
changes.clear();
ownChanges.clear();
ownJID = JID("baz@fum.com/dum");
@@ -48,119 +58,210 @@ class VCardManagerTest : public CppUnit::TestFixture {
}
void tearDown() {
delete vcardStorage;
delete iqRouter;
delete stanzaChannel;
}
void testGet_NewVCardRequestsVCard() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz"));
CPPUNIT_ASSERT(!result);
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get));
}
void testGet_ExistingVCard() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
VCard::ref vcard(new VCard());
vcard->setFullName("Foo Bar");
vcardStorage->setVCard(JID("foo@bar.com/baz"), vcard);
VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz"));
CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), result->getFullName());
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel->sentStanzas.size()));
}
void testRequest_RequestsVCard() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
testling->requestVCard(JID("foo@bar.com/baz"));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get));
}
void testRequest_ReceiveEmitsNotification() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
testling->requestVCard(JID("foo@bar.com/baz"));
stanzaChannel->onIQReceived(createVCardResult());
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), changes[0].first);
CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), changes[0].second->getFullName());
CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), vcardStorage->getVCard(JID("foo@bar.com/baz"))->getFullName());
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(ownChanges.size()));
}
void testRequest_Error() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
testling->requestVCard(JID("foo@bar.com/baz"));
stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID()));
// On error, cached vCards should not be changed.
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size()));
}
void testRequest_VCardAlreadyRequested() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
testling->requestVCard(JID("foo@bar.com/baz"));
VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz"));
CPPUNIT_ASSERT(!result);
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
}
void testRequest_AfterPreviousRequest() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
testling->requestVCard(JID("foo@bar.com/baz"));
stanzaChannel->onIQReceived(createVCardResult());
testling->requestVCard(JID("foo@bar.com/baz"));
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(stanzaChannel->sentStanzas.size()));
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(1, JID("foo@bar.com/baz"), IQ::Get));
}
- void testRequestOwnVCard() {
- std::shared_ptr<VCardManager> testling = createManager();
+ void testRequestVCard_ReturnFullVCard() {
+ auto testling = createManager();
+ testling->requestVCard(JID("foo@bar.com/baz"));
+ stanzaChannel->onIQReceived(createVCardResult());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), changes[0].first);
+ CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), changes[0].second->getFullName());
+ CPPUNIT_ASSERT_EQUAL(false, changes[0].second->isEmpty());
+ }
+
+ void testRequestVCard_ReturnEmptyVCard() {
+ auto testling = createManager();
+ testling->requestVCard(JID("foo@bar.com/baz"));
+ stanzaChannel->onIQReceived([&](){
+ auto vcard = std::make_shared<VCard>();
+ return IQ::createResult(JID("foo@bar.com/baz"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), vcard);
+ }());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty());
+ }
+
+ void testRequestVCard_ReturnItemNotFoundError() {
+ auto testling = createManager();
+ testling->requestVCard(JID("foo@bar.com/baz"));
+ stanzaChannel->onIQReceived([&](){
+ return IQ::createError(JID("foo@bar.com/baz"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::ItemNotFound);
+ }());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty());
+ }
+
+ void testRequestVCard_ReturnFeatureNotImplementedError() {
+ auto testling = createManager();
+ testling->requestVCard(JID("foo@bar.com/baz"));
+ stanzaChannel->onIQReceived([&](){
+ return IQ::createError(JID("foo@bar.com/baz"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::FeatureNotImplemented);
+ }());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size()));
+ }
+
+ void testRequestOwnVCard_ReturnFullVCard() {
+ auto testling = createManager();
testling->requestVCard(ownJID);
stanzaChannel->onIQReceived(createOwnVCardResult());
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get));
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
CPPUNIT_ASSERT_EQUAL(ownJID.toBare(), changes[0].first);
CPPUNIT_ASSERT_EQUAL(std::string("Myself"), changes[0].second->getFullName());
CPPUNIT_ASSERT_EQUAL(std::string("Myself"), vcardStorage->getVCard(ownJID.toBare())->getFullName());
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(ownChanges.size()));
CPPUNIT_ASSERT_EQUAL(std::string("Myself"), ownChanges[0]->getFullName());
}
+ void testRequestOwnVCard_ReturnEmptyVCard() {
+ auto testling = createManager();
+ testling->requestVCard(ownJID);
+ stanzaChannel->onIQReceived([&](){
+ auto vcard = std::make_shared<VCard>();
+ return IQ::createResult(JID(), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), vcard);
+ }());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty());
+ }
+
+ void testRequestOwnVCard_ReturnItemNotFoundError() {
+ auto testling = createManager();
+ testling->requestVCard(ownJID);
+ stanzaChannel->onIQReceived([&](){
+ return IQ::createError(JID(), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::ItemNotFound);
+ }());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
+ CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty());
+ }
+
+ void testRequestOwnVCard_ReturnFeatureNotImplementedError() {
+ auto testling = createManager();
+ testling->requestVCard(ownJID);
+ stanzaChannel->onIQReceived([&](){
+ return IQ::createError(JID(), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::FeatureNotImplemented);
+ }());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
+ CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get));
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size()));
+ }
+
void testCreateSetVCardRequest() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
VCard::ref vcard = std::make_shared<VCard>();
vcard->setFullName("New Name");
SetVCardRequest::ref request = testling->createSetVCardRequest(vcard);
request->send();
stanzaChannel->onIQReceived(createSetVCardResult());
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size()));
CPPUNIT_ASSERT_EQUAL(ownJID.toBare(), changes[0].first);
CPPUNIT_ASSERT_EQUAL(std::string("New Name"), changes[0].second->getFullName());
}
void testCreateSetVCardRequest_Error() {
- std::shared_ptr<VCardManager> testling = createManager();
+ auto testling = createManager();
VCard::ref vcard = std::make_shared<VCard>();
vcard->setFullName("New Name");
SetVCardRequest::ref request = testling->createSetVCardRequest(vcard);
request->send();
stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getID()));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size()));
}
diff --git a/Swiften/VCards/VCardManager.cpp b/Swiften/VCards/VCardManager.cpp
index 95b96fa..9423702 100644
--- a/Swiften/VCards/VCardManager.cpp
+++ b/Swiften/VCards/VCardManager.cpp
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/VCards/VCardManager.h>
#include <boost/bind.hpp>
#include <Swiften/Base/Log.h>
@@ -44,22 +44,21 @@ void VCardManager::requestVCard(const JID& requestedJID) {
request->onResponse.connect(boost::bind(&VCardManager::handleVCardReceived, this, jid, _1, _2));
request->send();
requestedVCards.insert(jid);
}
void VCardManager::requestOwnVCard() {
requestVCard(JID());
}
-
void VCardManager::handleVCardReceived(const JID& actualJID, VCard::ref vcard, ErrorPayload::ref error) {
requestedVCards.erase(actualJID);
- if (!error) {
+ if (!error || (error && error->getCondition() == ErrorPayload::ItemNotFound)) {
if (!vcard) {
vcard = VCard::ref(new VCard());
}
JID jid = actualJID.isValid() ? actualJID : ownJID.toBare();
setVCard(jid, vcard);
}
else {
onVCardRetrievalError(actualJID, error);
}