diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/AccountController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/AccountController.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferProgressInfo.cpp | 8 | ||||
-rw-r--r-- | Swift/Controllers/FileTransfer/FileTransferProgressInfo.h | 13 | ||||
-rw-r--r-- | Swift/Controllers/Roster/LeastCommonSubsequence.h | 4 | ||||
-rw-r--r-- | Swift/Controllers/Roster/TableRoster.cpp | 25 | ||||
-rw-r--r-- | Swift/Controllers/Storages/CertificateFileStorage.cpp | 13 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.cpp | 6 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.h | 5 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.cpp | 6 |
10 files changed, 47 insertions, 37 deletions
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 @@ -405,3 +405,3 @@ void AccountController::handleConnected() { -void AccountController::handleEventQueueLengthChange(int count) { +void AccountController::handleEventQueueLengthChange(size_t count) { dock_->setNumberOfPendingMessages(count); 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 @@ -113,3 +113,3 @@ namespace Swift { 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); 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 @@ -7,3 +7,3 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2018 Isode Limited. * All rights reserved. @@ -20,3 +20,3 @@ 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); @@ -24,5 +24,5 @@ FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeByte -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); 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 @@ -7,3 +7,3 @@ /* - * Copyright (c) 2016 Isode Limited. + * Copyright (c) 2016-2018 Isode Limited. * All rights reserved. @@ -14,3 +14,4 @@ -#include <boost/cstdint.hpp> +#include <cstddef> + #include <boost/signals2.hpp> @@ -21,6 +22,6 @@ class FileTransferProgressInfo { public: - FileTransferProgressInfo(boost::uintmax_t completeBytes); + FileTransferProgressInfo(size_t completeBytes); public: - void setBytesProcessed(int processedBytes); + void setBytesProcessed(size_t processedBytes); @@ -30,4 +31,4 @@ public: 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,3 +1,3 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. @@ -34,3 +34,3 @@ namespace Swift { 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)]); } 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,3 +1,3 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. @@ -134,11 +134,16 @@ void TableRoster::handleUpdateTimerTick() { 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 + } } 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 @@ -52,6 +52,11 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { } - 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; + } } 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,3 +1,3 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. @@ -53,3 +53,3 @@ void EventController::handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEve sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); - onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); + onEventQueueLengthChange(events_.size()); onEventQueueEventAdded(sourceEvent); @@ -64,3 +64,3 @@ void EventController::handleEventConcluded(std::shared_ptr<StanzaEvent> event) { events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); - onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); + onEventQueueLengthChange(events_.size()); } 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,3 +1,3 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. @@ -8,2 +8,3 @@ +#include <cstddef> #include <memory> @@ -24,3 +25,3 @@ namespace Swift { 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; 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,3 +1,3 @@ /* - * Copyright (c) 2010-2017 Isode Limited. + * Copyright (c) 2010-2018 Isode Limited. * All rights reserved. @@ -9,4 +9,2 @@ -#include <boost/numeric/conversion/cast.hpp> - #include <QFocusEvent> @@ -50,3 +48,3 @@ void QtWebView::keyPressEvent(QKeyEvent* event) { event->isAutoRepeat(), - boost::numeric_cast<unsigned short>(event->count())); + event->count()); QWebView::keyPressEvent(translatedEvent); |