diff options
21 files changed, 84 insertions, 62 deletions
@@ -78,9 +78,10 @@ compile_commands.json /Debug/ /Release/ *.VC.db *.VC.VC.opendb *.sln *.vcxproj *.vcxproj.filters *.vcxproj.user *.sdf +tags diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore index aca6fe1..ef95cc1 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore @@ -1,5 +1,6 @@ EchoBot? +EchoBot0x *.cpp.xml *.h.xml EchoComponent Swiften.cpp diff --git a/SwifTools/Dock/Dock.h b/SwifTools/Dock/Dock.h index 6120445..362aabc 100644 --- a/SwifTools/Dock/Dock.h +++ b/SwifTools/Dock/Dock.h @@ -1,18 +1,20 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <cstddef> + namespace Swift { class Dock { public: virtual ~Dock(); - virtual void setNumberOfPendingMessages(int i) = 0; + virtual void setNumberOfPendingMessages(size_t i) = 0; }; } diff --git a/SwifTools/Dock/MacOSXDock.h b/SwifTools/Dock/MacOSXDock.h index 6b33506..ef85a88 100644 --- a/SwifTools/Dock/MacOSXDock.h +++ b/SwifTools/Dock/MacOSXDock.h @@ -1,21 +1,21 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <SwifTools/Dock/Dock.h> namespace Swift { class CocoaApplication; class MacOSXDock : public Dock { public: MacOSXDock(CocoaApplication* application); - virtual void setNumberOfPendingMessages(int i); + virtual void setNumberOfPendingMessages(size_t i); }; } diff --git a/SwifTools/Dock/MacOSXDock.mm b/SwifTools/Dock/MacOSXDock.mm index 5c7207c..3935ac0 100644 --- a/SwifTools/Dock/MacOSXDock.mm +++ b/SwifTools/Dock/MacOSXDock.mm @@ -1,29 +1,29 @@ /* - * Copyright (c) 2015-2016 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/Dock/MacOSXDock.h> #include <boost/lexical_cast.hpp> #include <AppKit/AppKit.h> #include <Cocoa/Cocoa.h> #include <Swiften/Base/String.h> namespace Swift { MacOSXDock::MacOSXDock(CocoaApplication*) { } -void MacOSXDock::setNumberOfPendingMessages(int i) { +void MacOSXDock::setNumberOfPendingMessages(size_t i) { std::string label(i > 0 ? boost::lexical_cast<std::string>(i) : ""); NSString *labelString = [[NSString alloc] initWithUTF8String: label.c_str()]; [[NSApp dockTile] setBadgeLabel: labelString]; [labelString release]; [NSApp requestUserAttention: NSInformationalRequest]; } } diff --git a/SwifTools/Dock/NullDock.h b/SwifTools/Dock/NullDock.h index 9f3c554..137ba03 100644 --- a/SwifTools/Dock/NullDock.h +++ b/SwifTools/Dock/NullDock.h @@ -1,19 +1,21 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <cstddef> + #include <SwifTools/Dock/Dock.h> namespace Swift { class NullDock : public Dock { public: NullDock() {} - virtual void setNumberOfPendingMessages(int) { + virtual void setNumberOfPendingMessages(size_t) { } }; } diff --git a/SwifTools/Dock/WindowsDock.h b/SwifTools/Dock/WindowsDock.h index fc10a48..f9a9dae 100644 --- a/SwifTools/Dock/WindowsDock.h +++ b/SwifTools/Dock/WindowsDock.h @@ -1,30 +1,30 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <boost/lexical_cast.hpp> #include <QSystemTrayIcon> #include <SwifTools/Dock/Dock.h> #include <SwifTools/Notifier/Notifier.h> namespace Swift { class WindowsDock : public Dock { public: WindowsDock(QSystemTrayIcon* tray, Notifier* notifier) : tray(tray), notifier(notifier) {} - virtual void setNumberOfPendingMessages(int i) { + virtual void setNumberOfPendingMessages(size_t i) { if (notifier->isAvailable()) { return; } if (i > 0) { std::string message = boost::lexical_cast<std::string>(i) + " new message"; if (i > 1) { message += "s"; } diff --git a/SwifTools/Idle/MacOSXIdleQuerier.cpp b/SwifTools/Idle/MacOSXIdleQuerier.cpp index 6d6780b..89fa050 100644 --- a/SwifTools/Idle/MacOSXIdleQuerier.cpp +++ b/SwifTools/Idle/MacOSXIdleQuerier.cpp @@ -1,21 +1,23 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/Idle/MacOSXIdleQuerier.h> #pragma GCC diagnostic ignored "-Wold-style-cast" #include <cassert> #include <iostream> +#include <limits> + #include <boost/numeric/conversion/cast.hpp> #include <CoreFoundation/CoreFoundation.h> namespace Swift { MacOSXIdleQuerier::MacOSXIdleQuerier() : ioService(0) { mach_port_t masterPort; IOMasterPort(MACH_PORT_NULL, &masterPort); ioService = IOServiceGetMatchingService(masterPort, IOServiceMatching("IOHIDSystem")); @@ -23,13 +25,18 @@ MacOSXIdleQuerier::MacOSXIdleQuerier() : ioService(0) { } int MacOSXIdleQuerier::getIdleTimeSeconds() { CFTypeRef property = IORegistryEntryCreateCFProperty(ioService, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0); uint64_t idle = 0; bool result = CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle); assert(result); (void) result; CFRelease(property); - return boost::numeric_cast<int>(idle / 1000000000); + try { + return boost::numeric_cast<int>(idle / 1000000000); + } + catch (const boost::numeric::bad_numeric_cast&) { + return std::numeric_limits<int>::max(); + } } } diff --git a/SwifTools/SpellParser.cpp b/SwifTools/SpellParser.cpp index 5bafa6e..e449b45 100644 --- a/SwifTools/SpellParser.cpp +++ b/SwifTools/SpellParser.cpp @@ -1,27 +1,26 @@ /* * Copyright (c) 2011-2013 Vlad Voicu * Licensed under the Simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <SwifTools/SpellParser.h> #include <string> #include <boost/bind.hpp> -#include <boost/numeric/conversion/cast.hpp> #include <boost/ref.hpp> #include <boost/spirit/include/lex_lexertl.hpp> namespace lex = boost::spirit::lex; namespace Swift { template <typename Lexer> struct word_count_tokens : lex::lexer<Lexer> @@ -41,26 +40,26 @@ struct word_count_tokens : lex::lexer<Lexer> struct counter { typedef bool result_type; // the function operator gets called for each of the matched tokens template <typename Token> bool operator()(Token const& t, PositionPairList& wordPositions, std::size_t& position) const { switch (t.id()) { case ID_WWW: - position += boost::numeric_cast<size_t>(t.value().size()); + position += static_cast<std::size_t>(t.value().size()); break; case ID_HTTP: - position += boost::numeric_cast<size_t>(t.value().size()); + position += static_cast<std::size_t>(t.value().size()); break; case ID_WORD: // matched a word - wordPositions.push_back(boost::tuples::make_tuple(position, position + boost::numeric_cast<size_t>(t.value().size()))); - position += boost::numeric_cast<size_t>(t.value().size()); + wordPositions.push_back(boost::tuples::make_tuple(position, position + static_cast<std::size_t>(t.value().size()))); + position += static_cast<std::size_t>(t.value().size()); break; case ID_CHAR: // match a simple char ++position; break; } return true; // always continue to tokenize } }; diff --git a/Swift/Controllers/AccountController.cpp b/Swift/Controllers/AccountController.cpp index ec914a6..27655c0 100644 --- a/Swift/Controllers/AccountController.cpp +++ b/Swift/Controllers/AccountController.cpp @@ -397,19 +397,19 @@ void AccountController::handleConnected() { /* Send presence later to catch all the incoming presences. */ sendPresence(statusTracker_->getNextPresence()); /* Enable chats last of all, so rejoining MUCs has the right sent presence */ assert(chatsManager_); chatsManager_->setOnline(true); adHocManager_->setOnline(true); } -void AccountController::handleEventQueueLengthChange(int count) { +void AccountController::handleEventQueueLengthChange(size_t count) { dock_->setNumberOfPendingMessages(count); } void AccountController::reconnectAfterError() { if (reconnectTimer_) { reconnectTimer_->stop(); } performLoginFromCachedCredentials(); } diff --git a/Swift/Controllers/AccountController.h b/Swift/Controllers/AccountController.h index 774aa8b..4a31645 100644 --- a/Swift/Controllers/AccountController.h +++ b/Swift/Controllers/AccountController.h @@ -105,19 +105,19 @@ namespace Swift { private: void resetClient(); void handleConnected(); void handleLoginRequest(const std::string& username, const std::string& password, const std::string& certificatePath, CertificateWithKey::ref certificate, const ClientOptions& options, bool remember, bool loginAutomatically); void handleCancelLoginRequest(); void handleQuitRequest(); void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); void handleDisconnected(const boost::optional<ClientError>& error); void handleServerDiscoInfoResponse(std::shared_ptr<DiscoInfo>, ErrorPayload::ref); - void handleEventQueueLengthChange(int count); + void handleEventQueueLengthChange(size_t count); void handleVCardReceived(const JID& j, VCard::ref vCard); void handleSettingChanged(const std::string& settingPath); void handlePurgeSavedLoginRequest(const std::string& username); void sendPresence(std::shared_ptr<Presence> presence); void handleInputIdleChanged(bool); void handleShowCertificateRequest(); void logout(); void signOut(); void setReconnectTimer(); diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp index b073017..eddace9 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp @@ -1,36 +1,36 @@ /* * Copyright (c) 2011 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/FileTransfer/FileTransferProgressInfo.h> #include <boost/numeric/conversion/cast.hpp> #include <Swiften/Base/Log.h> namespace Swift { -FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { +FileTransferProgressInfo::FileTransferProgressInfo(size_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { onProgressPercentage(0); } -void FileTransferProgressInfo::setBytesProcessed(int processedBytes) { +void FileTransferProgressInfo::setBytesProcessed(size_t processedBytes) { int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); - completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes); + completedBytes += processedBytes; int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); if (oldPercentage != newPercentage) { onProgressPercentage(newPercentage); } percentage = newPercentage; } int FileTransferProgressInfo::getPercentage() const { return percentage; diff --git a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h index 5fb955c..869ceba 100644 --- a/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h +++ b/Swift/Controllers/FileTransfer/FileTransferProgressInfo.h @@ -1,36 +1,37 @@ /* * Copyright (c) 2011 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/cstdint.hpp> +#include <cstddef> + #include <boost/signals2.hpp> namespace Swift { class FileTransferProgressInfo { public: - FileTransferProgressInfo(boost::uintmax_t completeBytes); + FileTransferProgressInfo(size_t completeBytes); public: - void setBytesProcessed(int processedBytes); + void setBytesProcessed(size_t processedBytes); int getPercentage() const; boost::signals2::signal<void (int)> onProgressPercentage; private: - boost::uintmax_t completeBytes; - boost::uintmax_t completedBytes; + size_t completeBytes; + size_t completedBytes; int percentage; }; } diff --git a/Swift/Controllers/Roster/LeastCommonSubsequence.h b/Swift/Controllers/Roster/LeastCommonSubsequence.h index 8daa20c..7988ee7 100644 --- a/Swift/Controllers/Roster/LeastCommonSubsequence.h +++ b/Swift/Controllers/Roster/LeastCommonSubsequence.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <vector> #include <boost/numeric/conversion/cast.hpp> @@ -26,19 +26,19 @@ namespace Swift { } for (size_t j = 0; j < height; ++j) { result[j*width] = 0; } // Compute the LCS lengths for subsets Predicate predicate; for (size_t i = 1; i < width; ++i) { for (size_t j = 1; j < height; ++j) { - result[i + j*width] = predicate(*(xBegin + boost::numeric_cast<long long>(i)-1), *(yBegin + boost::numeric_cast<long long >(j)-1)) ? result[(i-1) + (j-1)*width] + 1 : std::max(result[i + (j-1)*width], result[i-1 + (j*width)]); + result[i + j*width] = predicate(*(xBegin + static_cast<long long>(i)-1), *(yBegin + static_cast<long long>(j)-1)) ? result[(i-1) + (j-1)*width] + 1 : std::max(result[i + (j-1)*width], result[i-1 + (j*width)]); } } } } template<typename X, typename InsertRemovePredicate, typename UpdatePredicate> void computeIndexDiff(const std::vector<X>& x, const std::vector<X>& y, std::vector<size_t>& updates, std::vector<size_t>& postUpdates, std::vector<size_t>& removes, std::vector<size_t>& inserts) { InsertRemovePredicate insertRemovePredicate; UpdatePredicate updatePredicate; diff --git a/Swift/Controllers/Roster/TableRoster.cpp b/Swift/Controllers/Roster/TableRoster.cpp index 713f390..01bf4a6 100644 --- a/Swift/Controllers/Roster/TableRoster.cpp +++ b/Swift/Controllers/Roster/TableRoster.cpp @@ -1,11 +1,11 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/Controllers/Roster/TableRoster.h> #include <algorithm> #include <cassert> @@ -126,27 +126,32 @@ void TableRoster::handleUpdateTimerTick() { assert(sectionUpdates.size() == sectionPostUpdates.size()); for (size_t i = 0; i < sectionUpdates.size(); ++i) { assert(sectionUpdates[i] < sections.size()); assert(sectionPostUpdates[i] < newSections.size()); std::vector<size_t> itemUpdates; std::vector<size_t> itemPostUpdates; std::vector<size_t> itemRemoves; std::vector<size_t> itemInserts; computeIndexDiff<Item, ItemEquals, ItemNeedsUpdate >(sections[sectionUpdates[i]].items, newSections[sectionPostUpdates[i]].items, itemUpdates, itemPostUpdates, itemRemoves, itemInserts); - size_t end = update.insertedRows.size(); - update.insertedRows.resize(update.insertedRows.size() + itemInserts.size()); - std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); - end = update.deletedRows.size(); - update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size()); - std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i])); - end = update.updatedRows.size(); - update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size()); - std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); + try { + size_t end = update.insertedRows.size(); + update.insertedRows.resize(update.insertedRows.size() + itemInserts.size()); + std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); + end = update.deletedRows.size(); + update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size()); + std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i])); + end = update.updatedRows.size(); + update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size()); + std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); + } + catch (const boost::numeric::bad_numeric_cast&) { + // If any container claims it has more than long long max items, we have bigger issues, so letting this pass + } } // Switch the old model with the new sections.swap(newSections); /* std::cerr << "-S: "; for (size_t i = 0; i < update.deletedSections.size(); ++i) { std::cerr << update.deletedSections[i] << " "; diff --git a/Swift/Controllers/Storages/CertificateFileStorage.cpp b/Swift/Controllers/Storages/CertificateFileStorage.cpp index 8ba7d12..2e1343f 100644 --- a/Swift/Controllers/Storages/CertificateFileStorage.cpp +++ b/Swift/Controllers/Storages/CertificateFileStorage.cpp @@ -44,20 +44,25 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { boost::filesystem::path certificatePath = getCertificatePath(certificate); if (!boost::filesystem::exists(certificatePath.parent_path())) { try { boost::filesystem::create_directories(certificatePath.parent_path()); } catch (const boost::filesystem::filesystem_error& e) { std::cerr << "ERROR: " << e.what() << std::endl; } } - boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out); - ByteArray data = certificate->toDER(); - file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size())); - file.close(); + try { + boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out); + ByteArray data = certificate->toDER(); + file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size())); + file.close(); + } + catch (...) { + SWIFT_LOG(warning) << "Failed to store certificate to " << certificatePath << std::endl; + } } boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { return path / Hexify::hexify(crypto->getSHA1Hash(certificate->toDER())); } } diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp index f8fb192..0e9429d 100644 --- a/Swift/Controllers/XMPPEvents/EventController.cpp +++ b/Swift/Controllers/XMPPEvents/EventController.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 <Swift/Controllers/XMPPEvents/EventController.h> #include <algorithm> #include <boost/bind.hpp> @@ -45,30 +45,30 @@ void EventController::handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEve existingEvent->conclude(); } } } } if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent || mucInviteEvent || incomingFileTransferEvent) { events_.push_back(sourceEvent); sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); - onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); + onEventQueueLengthChange(events_.size()); onEventQueueEventAdded(sourceEvent); if (sourceEvent->getConcluded()) { handleEventConcluded(sourceEvent); } } } void EventController::handleEventConcluded(std::shared_ptr<StanzaEvent> event) { event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); - onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); + onEventQueueLengthChange(events_.size()); } void EventController::disconnectAll() { onEventQueueLengthChange.disconnect_all_slots(); onEventQueueEventAdded.disconnect_all_slots(); } void EventController::clear() { events_.clear(); diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h index 8a095d9..5b746e4 100644 --- a/Swift/Controllers/XMPPEvents/EventController.h +++ b/Swift/Controllers/XMPPEvents/EventController.h @@ -1,34 +1,35 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <cstddef> #include <memory> #include <vector> #include <boost/signals2.hpp> #include <Swift/Controllers/XMPPEvents/MessageEvent.h> #include <Swift/Controllers/XMPPEvents/StanzaEvent.h> namespace Swift { typedef std::vector<std::shared_ptr<StanzaEvent> > EventList; class EventController { public: EventController(); ~EventController(); void handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEvent); - boost::signals2::signal<void (int)> onEventQueueLengthChange; + boost::signals2::signal<void (size_t)> onEventQueueLengthChange; boost::signals2::signal<void (std::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; const EventList& getEvents() const {return events_;} void disconnectAll(); void clear(); private: void handleEventConcluded(std::shared_ptr<StanzaEvent> event); EventList events_; }; diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp index 967be1a..24636ed 100644 --- a/Swift/QtUI/QtWebView.cpp +++ b/Swift/QtUI/QtWebView.cpp @@ -1,20 +1,18 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtWebView.h> -#include <boost/numeric/conversion/cast.hpp> - #include <QFocusEvent> #include <QKeyEvent> #include <QKeySequence> #include <QMenu> #include <Swiften/Base/Log.h> namespace Swift { QtWebView::QtWebView(QWidget* parent) : QWebView(parent), fontSizeIsMinimal(false) { @@ -42,19 +40,19 @@ void QtWebView::keyPressEvent(QKeyEvent* event) { } if (modifiers == Qt::ShiftModifier && (key == Qt::Key_PageUp || key == Qt::Key_PageDown)) { modifiers = Qt::NoModifier; } QKeyEvent* translatedEvent = new QKeyEvent(QEvent::KeyPress, key, modifiers, event->text(), event->isAutoRepeat(), - boost::numeric_cast<unsigned short>(event->count())); + event->count()); QWebView::keyPressEvent(translatedEvent); delete translatedEvent; } void QtWebView::dragEnterEvent(QDragEnterEvent*) { } void QtWebView::setFontSizeIsMinimal(bool minimum) { diff --git a/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp b/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp index fa07052..ef3a9b3 100644 --- a/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp +++ b/Swiften/SASL/UnitTest/WindowsServicePrincipalNameTest.cpp @@ -1,11 +1,11 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <cppunit/extensions/HelperMacros.h> #include <Swiften/SASL/WindowsServicePrincipalName.h> using namespace Swift; @@ -91,28 +91,28 @@ class WindowsServicePrincipalNameTest : public CppUnit::TestFixture { } catch (std::runtime_error) { /* expected */ } } void testInstancePort() { WindowsServicePrincipalName spn("adlon.isode.net"); spn.setInstanceName("mlink.adlon.isode.net"); - spn.setInstancePort(6222); - CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net:6222/adlon.isode.net")); + spn.setInstancePort(55222); + CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net:55222/adlon.isode.net")); spn.setInstancePort(0); CPPUNIT_ASSERT_EQUAL(spn.toString(), std::string("xmpp/mlink.adlon.isode.net/adlon.isode.net")); WindowsServicePrincipalName spn2("mlink.adlon.isode.net"); - spn2.setInstancePort(6222); - CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net:6222")); + spn2.setInstancePort(55222); + CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net:55222")); spn2.setInstancePort(0); CPPUNIT_ASSERT_EQUAL(spn2.toString(), std::string("xmpp/mlink.adlon.isode.net")); } void testReferrer() { WindowsServicePrincipalName spn("127.0.0.1"); spn.setReferrer("referrer.net"); diff --git a/Swiften/SASL/WindowsServicePrincipalName.h b/Swiften/SASL/WindowsServicePrincipalName.h index 4c9f557..2e4e5c4 100644 --- a/Swiften/SASL/WindowsServicePrincipalName.h +++ b/Swiften/SASL/WindowsServicePrincipalName.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include <string> #include <Windows.h> @@ -43,19 +43,19 @@ namespace Swift { /* * This sets a non-default port for the service. Note * that the default value is 0 which indicates the * default port for the service. So if the XMPP service * is using the default port of 5222 for client * connections, then do not set the port to 5222 but let * it remain 0 to indicate that the default port is * used. */ - void setInstancePort(short int instancePort) { instancePort_ = instancePort; } + void setInstancePort(unsigned short instancePort) { instancePort_ = instancePort; } /* * This follows the rules of SPN creation on Windows and * returns the SPN string constructed from the set * values. */ std::string toString(); private: |
Swift