diff options
| -rw-r--r-- | BuildTools/SCons/Tools/textfile.py | 2 | ||||
| -rw-r--r-- | BuildTools/SCons/Version.py | 191 | ||||
| -rw-r--r-- | Swift/ChangeLog.md | 12 | ||||
| -rw-r--r-- | Swift/Packaging/Debian/changelog.debian-unstable | 18 | ||||
| -rw-r--r-- | Swift/Packaging/Debian/debian/copyright | 2 | ||||
| -rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.h | 3 | ||||
| -rw-r--r-- | Swiften/ChangeLog.md | 6 | ||||
| -rw-r--r-- | Swiften/VCards/UnitTest/VCardManagerTest.cpp | 127 | ||||
| -rw-r--r-- | Swiften/VCards/VCardManager.cpp | 5 |
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 | |||
| @@ -63,7 +63,7 @@ def _do_subst(node, subs): | |||
| 63 | then all instances of %VERSION% in the file will be replaced with | 63 | then all instances of %VERSION% in the file will be replaced with |
| 64 | 1.2345 and so forth. | 64 | 1.2345 and so forth. |
| 65 | """ | 65 | """ |
| 66 | contents = node.get_text_contents() | 66 | contents = node.get_contents().decode('utf-8') |
| 67 | if not subs: return contents | 67 | if not subs: return contents |
| 68 | for (k,v) in subs: | 68 | for (k,v) in subs: |
| 69 | contents = re.sub(k, v, contents) | 69 | contents = re.sub(k, v, contents) |
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,4 +1,4 @@ | |||
| 1 | import subprocess, os, datetime, re, os.path | 1 | import subprocess, os, datetime, re, os.path, sys, unittest |
| 2 | 2 | ||
| 3 | def getGitBuildVersion(root, project) : | 3 | def getGitBuildVersion(root, project) : |
| 4 | tag = git("describe --tags --exact --match \"" + project + "-*\"", root) | 4 | tag = git("describe --tags --exact --match \"" + project + "-*\"", root) |
| @@ -6,7 +6,7 @@ def getGitBuildVersion(root, project) : | |||
| 6 | return tag.rstrip()[len(project)+1:] | 6 | return tag.rstrip()[len(project)+1:] |
| 7 | tag = git("describe --tags --match \"" + project + "-*\"", root) | 7 | tag = git("describe --tags --match \"" + project + "-*\"", root) |
| 8 | if tag : | 8 | if tag : |
| 9 | m = re.match(project + "-(.*)-(.*)-(.*)", tag.decode('utf-8')) | 9 | m = re.match(project + "-(.*)-(.*)-(.*)", tag) |
| 10 | if m : | 10 | if m : |
| 11 | return m.group(1) + "-dev" + m.group(2) | 11 | return m.group(1) + "-dev" + m.group(2) |
| 12 | return None | 12 | return None |
| @@ -37,32 +37,165 @@ def getBuildVersion(root, project) : | |||
| 37 | 37 | ||
| 38 | return datetime.date.today().strftime("%Y%m%d") | 38 | return datetime.date.today().strftime("%Y%m%d") |
| 39 | 39 | ||
| 40 | def convertToWindowsVersion(version) : | 40 | # The following conversion allows us to use version tags the format: |
| 41 | version_match = re.match("(\d+)\.(\d+)(.*)", version.decode('utf-8')) | 41 | # major.0 |
| 42 | major = version_match and int(version_match.group(1)) or 0 | 42 | # major.0.(0 to 9) |
| 43 | minor = version_match and int(version_match.group(2)) or 0 | 43 | # |
| 44 | if version_match and len(version_match.group(3)) == 0 : | 44 | # Either from above followed by: |
| 45 | patch = 60000 | 45 | # alpha(0 to 4) |
| 46 | else : | 46 | # beta(0 to 6) |
| 47 | match = re.match("^beta(\d+)(.*)", version_match.group(3)) | 47 | # rc(1 to 11) |
| 48 | build_string = "" | 48 | # |
| 49 | if match : | 49 | # Followed by an optional -dev(1-65535) for off tag builds. |
| 50 | patch = 1000*int(match.group(1)) | 50 | def convertToWindowsVersion(version): |
| 51 | build_string = match.group(2) | 51 | 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) |
| 52 | else : | 52 | assert(match) |
| 53 | rc_match = re.match("^rc(\d+)(.*)", version_match.group(3)) | 53 | major, minor, patch = (0, 0, 0) |
| 54 | if rc_match : | ||
| 55 | patch = 10000*int(rc_match.group(1)) | ||
| 56 | build_string = rc_match.group(2) | ||
| 57 | else : | ||
| 58 | patch = 0 | ||
| 59 | alpha_match = re.match("^alpha(.*)", version_match.group(3)) | ||
| 60 | if alpha_match : | ||
| 61 | build_string = alpha_match.group(1) | ||
| 62 | |||
| 63 | if len(build_string) > 0 : | ||
| 64 | build_match = re.match("^-dev(\d+)", build_string) | ||
| 65 | if build_match : | ||
| 66 | patch += int(build_match.group(1)) | ||
| 67 | 54 | ||
| 55 | groups = match.groupdict() | ||
| 56 | assert(groups['major']) | ||
| 57 | major = int(groups['major']) | ||
| 58 | |||
| 59 | if groups['minor']: | ||
| 60 | assert(int(groups['minor']) == 0) | ||
| 61 | |||
| 62 | if groups['patch']: | ||
| 63 | assert(0 <= int(groups['patch']) <= 9) | ||
| 64 | minor = int(groups['patch']) * 25 | ||
| 65 | |||
| 66 | stage = groups["stage"] | ||
| 67 | if stage: | ||
| 68 | stageNumber = groups['stage_number'] | ||
| 69 | if not stageNumber or stageNumber == "": | ||
| 70 | stageNumber = 0 | ||
| 71 | else: | ||
| 72 | stageNumber = int(stageNumber) | ||
| 73 | |||
| 74 | if stage == "alpha": | ||
| 75 | assert(0 <= stageNumber <= 4) | ||
| 76 | minor = 1 + stageNumber | ||
| 77 | elif stage == "beta": | ||
| 78 | assert(0 <= stageNumber <= 6) | ||
| 79 | minor = 6 + stageNumber | ||
| 80 | elif stage == "rc": | ||
| 81 | assert(1 <= stageNumber <= 11) | ||
| 82 | minor = 12 + stageNumber | ||
| 83 | else: | ||
| 84 | assert(False) | ||
| 85 | else: | ||
| 86 | minor = minor + 24 | ||
| 87 | |||
| 88 | if groups['dev']: | ||
| 89 | patch = 1 + int(groups['dev']) | ||
| 90 | |||
| 91 | # The following constraints are set by Windows Installer framework | ||
| 92 | assert(0 <= major <= 255) | ||
| 93 | assert(0 <= minor <= 255) | ||
| 94 | assert(0 <= patch <= 65535) | ||
| 68 | return (major, minor, patch) | 95 | return (major, minor, patch) |
| 96 | |||
| 97 | # Test Windows version mapping scheme | ||
| 98 | class convertToWindowsVersionTest(unittest.TestCase): | ||
| 99 | def testWindowsVersionsAreDescending(self): | ||
| 100 | versionStringsWithOldVersions = [ | ||
| 101 | ("5.0rc11", None), | ||
| 102 | ("5.0rc1", None), | ||
| 103 | ("5.0beta6", None), | ||
| 104 | ("5.0alpha4", None), | ||
| 105 | ("5.0alpha2", None), | ||
| 106 | ("5.0alpha", None), | ||
| 107 | ("4.0.9", None), | ||
| 108 | ("4.0.1", None), | ||
| 109 | ("4.0", (4, 0, 60000)), | ||
| 110 | ("4.0rc6", (4, 0, 60000)), | ||
| 111 | ("4.0rc5", (4, 0, 50000)), | ||
| 112 | ("4.0rc4", (4, 0, 40000)), | ||
| 113 | ("4.0rc3", (4, 0, 30000)), | ||
| 114 | ('4.0rc2-dev34', (4, 0, 20034)), | ||
| 115 | ('4.0rc2-dev33', (4, 0, 20033)), | ||
| 116 | ('4.0rc2-dev31', (4, 0, 20031)), | ||
| 117 | ('4.0rc2-dev30', (4, 0, 20030)), | ||
| 118 | ('4.0rc2-dev29', (4, 0, 20029)), | ||
| 119 | ('4.0rc2-dev27', (4, 0, 20027)), | ||
| 120 | ('4.0rc2-dev39', (4, 0, 20039)), | ||
| 121 | ('4.0rc2', (4, 0, 20000)), | ||
| 122 | ('4.0rc1', (4, 0, 10000)), | ||
| 123 | ('4.0beta2-dev203', (4, 0, 2203)), | ||
| 124 | ('4.0beta2-dev195', (4, 0, 2195)), | ||
| 125 | ('4.0beta2-dev177', (4, 0, 2177)), | ||
| 126 | ('4.0beta2-dev171', (4, 0, 2171)), | ||
| 127 | ('4.0beta2-dev154', (4, 0, 2154)), | ||
| 128 | ('4.0beta2-dev150', (4, 0, 2150)), | ||
| 129 | ('4.0beta2-dev142', (4, 0, 2142)), | ||
| 130 | ('4.0beta2-dev140', (4, 0, 2140)), | ||
| 131 | ('4.0beta2-dev133', (4, 0, 2133)), | ||
| 132 | ('4.0beta2-dev118', (4, 0, 2118)), | ||
| 133 | ('4.0beta2-dev112', (4, 0, 2112)), | ||
| 134 | ('4.0beta2-dev93', (4, 0, 2093)), | ||
| 135 | ('4.0beta2-dev80', (4, 0, 2080)), | ||
| 136 | ('4.0beta2-dev72', (4, 0, 2072)), | ||
| 137 | ('4.0beta2-dev57', (4, 0, 2057)), | ||
| 138 | ('4.0beta2-dev44', (4, 0, 2044)), | ||
| 139 | ('4.0beta2-dev38', (4, 0, 2038)), | ||
| 140 | ('4.0beta2-dev29', (4, 0, 2029)), | ||
| 141 | ('4.0beta2-dev15', (4, 0, 2015)), | ||
| 142 | ('4.0beta2', (4, 0, 2000)), | ||
| 143 | ('4.0beta1', (4, 0, 1000)), | ||
| 144 | ('4.0alpha-dev80', (4, 0, 80)), | ||
| 145 | ('4.0alpha-dev50', (4, 0, 50)), | ||
| 146 | ('4.0alpha-dev43', (4, 0, 43)), | ||
| 147 | ('4.0alpha-dev21', (4, 0, 21)), | ||
| 148 | ('3.0', (3, 0, 60000)), | ||
| 149 | ('3.0rc3', (3, 0, 30000)), | ||
| 150 | ('3.0rc2', (3, 0, 20000)), | ||
| 151 | ('3.0rc1', (3, 0, 10000)), | ||
| 152 | ('3.0beta2-dev124', (3, 0, 2124)), | ||
| 153 | ('3.0beta2-dev81', (3, 0, 2081)), | ||
| 154 | ('3.0beta2-dev50', (3, 0, 2050)), | ||
| 155 | ('3.0beta2-dev44', (3, 0, 2044)), | ||
| 156 | ('3.0beta2-dev40', (3, 0, 2040)), | ||
| 157 | ('3.0beta2-dev26', (3, 0, 2026)), | ||
| 158 | ('3.0beta2', (3, 0, 2000)), | ||
| 159 | ('3.0beta1', (3, 0, 1000)), | ||
| 160 | ('3.0alpha-dev529', (3, 0, 529)), | ||
| 161 | ('3.0alpha-dev528', (3, 0, 528)), | ||
| 162 | ('3.0alpha-dev526', (3, 0, 526)), | ||
| 163 | ('3.0alpha-dev524', (3, 0, 524)), | ||
| 164 | ('3.0alpha-dev515', (3, 0, 515)), | ||
| 165 | ] | ||
| 166 | windowsVersionMapping = list(map(lambda (x,y): (x, convertToWindowsVersion(x)), versionStringsWithOldVersions)) | ||
| 167 | |||
| 168 | def testThatBetaIsHigherThanAlpha(self): | ||
| 169 | self.assertTrue(convertToWindowsVersion("3.0beta0") > convertToWindowsVersion("3.0alpha0")) | ||
| 170 | self.assertTrue(convertToWindowsVersion("3.0beta6") > convertToWindowsVersion("3.0alpha1")) | ||
| 171 | self.assertTrue(convertToWindowsVersion("3.0beta6") > convertToWindowsVersion("3.0alpha4")) | ||
| 172 | |||
| 173 | def testThatRcIsHigherThanAlphaAndBeta(self): | ||
| 174 | self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0alpha0")) | ||
| 175 | self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0alpha4")) | ||
| 176 | self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0alpha0")) | ||
| 177 | self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0alpha4")) | ||
| 178 | self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0beta0")) | ||
| 179 | self.assertTrue(convertToWindowsVersion("3.0rc11") > convertToWindowsVersion("3.0beta6")) | ||
| 180 | self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0beta0")) | ||
| 181 | self.assertTrue(convertToWindowsVersion("3.0rc1") > convertToWindowsVersion("3.0beta6")) | ||
| 182 | |||
| 183 | def testThatStableIsHigherThanAlphaAndBetaAndRc(self): | ||
| 184 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha0")) | ||
| 185 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha4")) | ||
| 186 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha0")) | ||
| 187 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0alpha4")) | ||
| 188 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0beta0")) | ||
| 189 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0beta6")) | ||
| 190 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0rc1")) | ||
| 191 | self.assertTrue(convertToWindowsVersion("3.0") > convertToWindowsVersion("3.0rc11")) | ||
| 192 | |||
| 193 | if __name__ == '__main__': | ||
| 194 | if len(sys.argv) == 1: | ||
| 195 | unittest.main() | ||
| 196 | elif len(sys.argv) == 2: | ||
| 197 | print convertToWindowsVersion(sys.argv[1]) | ||
| 198 | sys.exit(0) | ||
| 199 | else: | ||
| 200 | print "Error: Simply run the script without arguments or pass a single argument." | ||
| 201 | 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,3 +1,15 @@ | |||
| 1 | 4.0.3 (2019-01-03) | ||
| 2 | ------------------ | ||
| 3 | - Fix handling of empty bookmark responses | ||
| 4 | |||
| 5 | 4.0.2 (2018-04-05) | ||
| 6 | ------------------ | ||
| 7 | - Fix versioning issue in Windows Installer process | ||
| 8 | |||
| 9 | 4.0.1 (2018-03-28) | ||
| 10 | ------------------ | ||
| 11 | - Allow setting vCard on servers that do not return an empty vCard on fresh accounts | ||
| 12 | |||
| 1 | 4.0 (2018-03-20) | 13 | 4.0 (2018-03-20) |
| 2 | ---------------- | 14 | ---------------- |
| 3 | - New chat theme including a new font | 15 | - New chat theme including a new font |
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,3 +1,21 @@ | |||
| 1 | swift-im (4.0.3-1) UNRELEASED; urgency=medium | ||
| 2 | |||
| 3 | * New chat theme including a new font | ||
| 4 | * Support for message carbons (XEP-0280) | ||
| 5 | * Enabled trellis mode as a default feature, allowing several tiled chats windows to be shown at once | ||
| 6 | * Redesigned keyword highlighting | ||
| 7 | * Improve date formatting | ||
| 8 | * Fix Last Message Correction in multi client scenarios | ||
| 9 | * Fix UI layout issue for translations that require right-to-left (RTL) layout | ||
| 10 | * Fix UX issues in trellis mode | ||
| 11 | * Improvements to font size handling in the chat theme | ||
| 12 | * Add AppImage for Linux 64-bit as a supported platform | ||
| 13 | * Improved spell checker support on Linux | ||
| 14 | * Allow setting vCard on servers that do not return an empty vCard on fresh accounts | ||
| 15 | * And assorted smaller features and usability enhancements. Closes: 840151, 889062 | ||
| 16 | |||
| 17 | -- Kevin Smith <kevin@kismith.co.uk> Thu, 03 Jan 2019 13:59:07 +0100 | ||
| 18 | |||
| 1 | swift-im (3.0.4-1) unstable; urgency=low | 19 | swift-im (3.0.4-1) unstable; urgency=low |
| 2 | 20 | ||
| 3 | * New upstream release | 21 | * New upstream release |
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 | |||
| @@ -3,7 +3,7 @@ with help from Olly Betts <olly@survex.com>. | |||
| 3 | 3 | ||
| 4 | The upstream sources were obtained from http://swift.im. | 4 | The upstream sources were obtained from http://swift.im. |
| 5 | 5 | ||
| 6 | Copyright (C) 2010-2016 Isode Limited. | 6 | Copyright (C) 2010-2019 Isode Limited. |
| 7 | Licensed under the GNU General Public License. | 7 | Licensed under the GNU General Public License. |
| 8 | See /usr/share/common-licenses/GPL-3 for the full license. | 8 | See /usr/share/common-licenses/GPL-3 for the full license. |
| 9 | 9 | ||
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,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2017 Isode Limited. | 2 | * Copyright (c) 2010-2018 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <set> | 9 | #include <set> |
| 10 | 10 | ||
| 11 | #include <QAbstractItemModel> | ||
| 11 | #include <QWizard> | 12 | #include <QWizard> |
| 12 | 13 | ||
| 13 | #include <Swift/Controllers/UIInterfaces/UserSearchWindow.h> | 14 | #include <Swift/Controllers/UIInterfaces/UserSearchWindow.h> |
diff --git a/Swiften/ChangeLog.md b/Swiften/ChangeLog.md index a656292..60355b4 100644 --- a/Swiften/ChangeLog.md +++ b/Swiften/ChangeLog.md | |||
| @@ -2,7 +2,11 @@ | |||
| 2 | ------------- | 2 | ------------- |
| 3 | - Update build system from scons 2.4.0 to 3.0.1 | 3 | - Update build system from scons 2.4.0 to 3.0.1 |
| 4 | 4 | ||
| 5 | 4.0 (2017-03-20) | 5 | 4.0.1 (2018-03-28) |
| 6 | ------------------ | ||
| 7 | - Fix handling errors when fetching own vCard | ||
| 8 | |||
| 9 | 4.0 (2018-03-20) | ||
| 6 | ---------------- | 10 | ---------------- |
| 7 | - Moved code-base to C++11 | 11 | - Moved code-base to C++11 |
| 8 | - Use C++11 threading instead of Boost.Thread library | 12 | - Use C++11 threading instead of Boost.Thread library |
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,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2016 Isode Limited. | 2 | * Copyright (c) 2010-2018 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -31,7 +31,17 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 31 | CPPUNIT_TEST(testRequest_Error); | 31 | CPPUNIT_TEST(testRequest_Error); |
| 32 | CPPUNIT_TEST(testRequest_VCardAlreadyRequested); | 32 | CPPUNIT_TEST(testRequest_VCardAlreadyRequested); |
| 33 | CPPUNIT_TEST(testRequest_AfterPreviousRequest); | 33 | CPPUNIT_TEST(testRequest_AfterPreviousRequest); |
| 34 | CPPUNIT_TEST(testRequestOwnVCard); | 34 | |
| 35 | CPPUNIT_TEST(testRequestVCard_ReturnFullVCard); | ||
| 36 | CPPUNIT_TEST(testRequestVCard_ReturnEmptyVCard); | ||
| 37 | CPPUNIT_TEST(testRequestVCard_ReturnItemNotFoundError); | ||
| 38 | CPPUNIT_TEST(testRequestVCard_ReturnFeatureNotImplementedError); | ||
| 39 | |||
| 40 | CPPUNIT_TEST(testRequestOwnVCard_ReturnFullVCard); | ||
| 41 | CPPUNIT_TEST(testRequestOwnVCard_ReturnEmptyVCard); | ||
| 42 | CPPUNIT_TEST(testRequestOwnVCard_ReturnItemNotFoundError); | ||
| 43 | CPPUNIT_TEST(testRequestOwnVCard_ReturnFeatureNotImplementedError); | ||
| 44 | |||
| 35 | CPPUNIT_TEST(testCreateSetVCardRequest); | 45 | CPPUNIT_TEST(testCreateSetVCardRequest); |
| 36 | CPPUNIT_TEST(testCreateSetVCardRequest_Error); | 46 | CPPUNIT_TEST(testCreateSetVCardRequest_Error); |
| 37 | CPPUNIT_TEST_SUITE_END(); | 47 | CPPUNIT_TEST_SUITE_END(); |
| @@ -54,7 +64,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 54 | } | 64 | } |
| 55 | 65 | ||
| 56 | void testGet_NewVCardRequestsVCard() { | 66 | void testGet_NewVCardRequestsVCard() { |
| 57 | std::shared_ptr<VCardManager> testling = createManager(); | 67 | auto testling = createManager(); |
| 58 | VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz")); | 68 | VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz")); |
| 59 | 69 | ||
| 60 | CPPUNIT_ASSERT(!result); | 70 | CPPUNIT_ASSERT(!result); |
| @@ -63,7 +73,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 63 | } | 73 | } |
| 64 | 74 | ||
| 65 | void testGet_ExistingVCard() { | 75 | void testGet_ExistingVCard() { |
| 66 | std::shared_ptr<VCardManager> testling = createManager(); | 76 | auto testling = createManager(); |
| 67 | VCard::ref vcard(new VCard()); | 77 | VCard::ref vcard(new VCard()); |
| 68 | vcard->setFullName("Foo Bar"); | 78 | vcard->setFullName("Foo Bar"); |
| 69 | vcardStorage->setVCard(JID("foo@bar.com/baz"), vcard); | 79 | vcardStorage->setVCard(JID("foo@bar.com/baz"), vcard); |
| @@ -75,7 +85,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 75 | } | 85 | } |
| 76 | 86 | ||
| 77 | void testRequest_RequestsVCard() { | 87 | void testRequest_RequestsVCard() { |
| 78 | std::shared_ptr<VCardManager> testling = createManager(); | 88 | auto testling = createManager(); |
| 79 | testling->requestVCard(JID("foo@bar.com/baz")); | 89 | testling->requestVCard(JID("foo@bar.com/baz")); |
| 80 | 90 | ||
| 81 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | 91 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); |
| @@ -83,7 +93,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 83 | } | 93 | } |
| 84 | 94 | ||
| 85 | void testRequest_ReceiveEmitsNotification() { | 95 | void testRequest_ReceiveEmitsNotification() { |
| 86 | std::shared_ptr<VCardManager> testling = createManager(); | 96 | auto testling = createManager(); |
| 87 | testling->requestVCard(JID("foo@bar.com/baz")); | 97 | testling->requestVCard(JID("foo@bar.com/baz")); |
| 88 | stanzaChannel->onIQReceived(createVCardResult()); | 98 | stanzaChannel->onIQReceived(createVCardResult()); |
| 89 | 99 | ||
| @@ -96,7 +106,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 96 | } | 106 | } |
| 97 | 107 | ||
| 98 | void testRequest_Error() { | 108 | void testRequest_Error() { |
| 99 | std::shared_ptr<VCardManager> testling = createManager(); | 109 | auto testling = createManager(); |
| 100 | testling->requestVCard(JID("foo@bar.com/baz")); | 110 | testling->requestVCard(JID("foo@bar.com/baz")); |
| 101 | stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID())); | 111 | stanzaChannel->onIQReceived(IQ::createError(JID("baz@fum.com/foo"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID())); |
| 102 | 112 | ||
| @@ -105,7 +115,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 105 | } | 115 | } |
| 106 | 116 | ||
| 107 | void testRequest_VCardAlreadyRequested() { | 117 | void testRequest_VCardAlreadyRequested() { |
| 108 | std::shared_ptr<VCardManager> testling = createManager(); | 118 | auto testling = createManager(); |
| 109 | testling->requestVCard(JID("foo@bar.com/baz")); | 119 | testling->requestVCard(JID("foo@bar.com/baz")); |
| 110 | VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz")); | 120 | VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz")); |
| 111 | 121 | ||
| @@ -114,7 +124,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 114 | } | 124 | } |
| 115 | 125 | ||
| 116 | void testRequest_AfterPreviousRequest() { | 126 | void testRequest_AfterPreviousRequest() { |
| 117 | std::shared_ptr<VCardManager> testling = createManager(); | 127 | auto testling = createManager(); |
| 118 | testling->requestVCard(JID("foo@bar.com/baz")); | 128 | testling->requestVCard(JID("foo@bar.com/baz")); |
| 119 | stanzaChannel->onIQReceived(createVCardResult()); | 129 | stanzaChannel->onIQReceived(createVCardResult()); |
| 120 | testling->requestVCard(JID("foo@bar.com/baz")); | 130 | testling->requestVCard(JID("foo@bar.com/baz")); |
| @@ -123,8 +133,60 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 123 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(1, JID("foo@bar.com/baz"), IQ::Get)); | 133 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(1, JID("foo@bar.com/baz"), IQ::Get)); |
| 124 | } | 134 | } |
| 125 | 135 | ||
| 126 | void testRequestOwnVCard() { | 136 | void testRequestVCard_ReturnFullVCard() { |
| 127 | std::shared_ptr<VCardManager> testling = createManager(); | 137 | auto testling = createManager(); |
| 138 | testling->requestVCard(JID("foo@bar.com/baz")); | ||
| 139 | stanzaChannel->onIQReceived(createVCardResult()); | ||
| 140 | |||
| 141 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 142 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get)); | ||
| 143 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); | ||
| 144 | CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), changes[0].first); | ||
| 145 | CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), changes[0].second->getFullName()); | ||
| 146 | CPPUNIT_ASSERT_EQUAL(false, changes[0].second->isEmpty()); | ||
| 147 | } | ||
| 148 | |||
| 149 | void testRequestVCard_ReturnEmptyVCard() { | ||
| 150 | auto testling = createManager(); | ||
| 151 | testling->requestVCard(JID("foo@bar.com/baz")); | ||
| 152 | stanzaChannel->onIQReceived([&](){ | ||
| 153 | auto vcard = std::make_shared<VCard>(); | ||
| 154 | return IQ::createResult(JID("foo@bar.com/baz"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), vcard); | ||
| 155 | }()); | ||
| 156 | |||
| 157 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 158 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get)); | ||
| 159 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); | ||
| 160 | CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty()); | ||
| 161 | } | ||
| 162 | |||
| 163 | void testRequestVCard_ReturnItemNotFoundError() { | ||
| 164 | auto testling = createManager(); | ||
| 165 | testling->requestVCard(JID("foo@bar.com/baz")); | ||
| 166 | stanzaChannel->onIQReceived([&](){ | ||
| 167 | return IQ::createError(JID("foo@bar.com/baz"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::ItemNotFound); | ||
| 168 | }()); | ||
| 169 | |||
| 170 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 171 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get)); | ||
| 172 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); | ||
| 173 | CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty()); | ||
| 174 | } | ||
| 175 | |||
| 176 | void testRequestVCard_ReturnFeatureNotImplementedError() { | ||
| 177 | auto testling = createManager(); | ||
| 178 | testling->requestVCard(JID("foo@bar.com/baz")); | ||
| 179 | stanzaChannel->onIQReceived([&](){ | ||
| 180 | return IQ::createError(JID("foo@bar.com/baz"), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::FeatureNotImplemented); | ||
| 181 | }()); | ||
| 182 | |||
| 183 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 184 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID("foo@bar.com/baz"), IQ::Get)); | ||
| 185 | CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size())); | ||
| 186 | } | ||
| 187 | |||
| 188 | void testRequestOwnVCard_ReturnFullVCard() { | ||
| 189 | auto testling = createManager(); | ||
| 128 | testling->requestVCard(ownJID); | 190 | testling->requestVCard(ownJID); |
| 129 | stanzaChannel->onIQReceived(createOwnVCardResult()); | 191 | stanzaChannel->onIQReceived(createOwnVCardResult()); |
| 130 | 192 | ||
| @@ -139,8 +201,47 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 139 | CPPUNIT_ASSERT_EQUAL(std::string("Myself"), ownChanges[0]->getFullName()); | 201 | CPPUNIT_ASSERT_EQUAL(std::string("Myself"), ownChanges[0]->getFullName()); |
| 140 | } | 202 | } |
| 141 | 203 | ||
| 204 | void testRequestOwnVCard_ReturnEmptyVCard() { | ||
| 205 | auto testling = createManager(); | ||
| 206 | testling->requestVCard(ownJID); | ||
| 207 | stanzaChannel->onIQReceived([&](){ | ||
| 208 | auto vcard = std::make_shared<VCard>(); | ||
| 209 | return IQ::createResult(JID(), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), vcard); | ||
| 210 | }()); | ||
| 211 | |||
| 212 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 213 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get)); | ||
| 214 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); | ||
| 215 | CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty()); | ||
| 216 | } | ||
| 217 | |||
| 218 | void testRequestOwnVCard_ReturnItemNotFoundError() { | ||
| 219 | auto testling = createManager(); | ||
| 220 | testling->requestVCard(ownJID); | ||
| 221 | stanzaChannel->onIQReceived([&](){ | ||
| 222 | return IQ::createError(JID(), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::ItemNotFound); | ||
| 223 | }()); | ||
| 224 | |||
| 225 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 226 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get)); | ||
| 227 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); | ||
| 228 | CPPUNIT_ASSERT_EQUAL(true, changes[0].second->isEmpty()); | ||
| 229 | } | ||
| 230 | |||
| 231 | void testRequestOwnVCard_ReturnFeatureNotImplementedError() { | ||
| 232 | auto testling = createManager(); | ||
| 233 | testling->requestVCard(ownJID); | ||
| 234 | stanzaChannel->onIQReceived([&](){ | ||
| 235 | return IQ::createError(JID(), stanzaChannel->sentStanzas[0]->getTo(), stanzaChannel->sentStanzas[0]->getID(), ErrorPayload::FeatureNotImplemented); | ||
| 236 | }()); | ||
| 237 | |||
| 238 | CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); | ||
| 239 | CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get)); | ||
| 240 | CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(changes.size())); | ||
| 241 | } | ||
| 242 | |||
| 142 | void testCreateSetVCardRequest() { | 243 | void testCreateSetVCardRequest() { |
| 143 | std::shared_ptr<VCardManager> testling = createManager(); | 244 | auto testling = createManager(); |
| 144 | VCard::ref vcard = std::make_shared<VCard>(); | 245 | VCard::ref vcard = std::make_shared<VCard>(); |
| 145 | vcard->setFullName("New Name"); | 246 | vcard->setFullName("New Name"); |
| 146 | SetVCardRequest::ref request = testling->createSetVCardRequest(vcard); | 247 | SetVCardRequest::ref request = testling->createSetVCardRequest(vcard); |
| @@ -154,7 +255,7 @@ class VCardManagerTest : public CppUnit::TestFixture { | |||
| 154 | } | 255 | } |
| 155 | 256 | ||
| 156 | void testCreateSetVCardRequest_Error() { | 257 | void testCreateSetVCardRequest_Error() { |
| 157 | std::shared_ptr<VCardManager> testling = createManager(); | 258 | auto testling = createManager(); |
| 158 | VCard::ref vcard = std::make_shared<VCard>(); | 259 | VCard::ref vcard = std::make_shared<VCard>(); |
| 159 | vcard->setFullName("New Name"); | 260 | vcard->setFullName("New Name"); |
| 160 | SetVCardRequest::ref request = testling->createSetVCardRequest(vcard); | 261 | SetVCardRequest::ref request = testling->createSetVCardRequest(vcard); |
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,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010-2016 Isode Limited. | 2 | * Copyright (c) 2010-2018 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| @@ -50,10 +50,9 @@ void VCardManager::requestOwnVCard() { | |||
| 50 | requestVCard(JID()); | 50 | requestVCard(JID()); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | |||
| 54 | void VCardManager::handleVCardReceived(const JID& actualJID, VCard::ref vcard, ErrorPayload::ref error) { | 53 | void VCardManager::handleVCardReceived(const JID& actualJID, VCard::ref vcard, ErrorPayload::ref error) { |
| 55 | requestedVCards.erase(actualJID); | 54 | requestedVCards.erase(actualJID); |
| 56 | if (!error) { | 55 | if (!error || (error && error->getCondition() == ErrorPayload::ItemNotFound)) { |
| 57 | if (!vcard) { | 56 | if (!vcard) { |
| 58 | vcard = VCard::ref(new VCard()); | 57 | vcard = VCard::ref(new VCard()); |
| 59 | } | 58 | } |
Swift