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 | |||
| @@ -403,7 +403,7 @@ void AccountController::handleConnected() { | |||
| 403 | adHocManager_->setOnline(true); | 403 | adHocManager_->setOnline(true); |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | void AccountController::handleEventQueueLengthChange(int count) { | 406 | void AccountController::handleEventQueueLengthChange(size_t count) { |
| 407 | dock_->setNumberOfPendingMessages(count); | 407 | dock_->setNumberOfPendingMessages(count); |
| 408 | } | 408 | } |
| 409 | 409 | ||
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 | |||
| @@ -111,7 +111,7 @@ namespace Swift { | |||
| 111 | void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); | 111 | void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); |
| 112 | void handleDisconnected(const boost::optional<ClientError>& error); | 112 | void handleDisconnected(const boost::optional<ClientError>& error); |
| 113 | void handleServerDiscoInfoResponse(std::shared_ptr<DiscoInfo>, ErrorPayload::ref); | 113 | void handleServerDiscoInfoResponse(std::shared_ptr<DiscoInfo>, ErrorPayload::ref); |
| 114 | void handleEventQueueLengthChange(int count); | 114 | void handleEventQueueLengthChange(size_t count); |
| 115 | void handleVCardReceived(const JID& j, VCard::ref vCard); | 115 | void handleVCardReceived(const JID& j, VCard::ref vCard); |
| 116 | void handleSettingChanged(const std::string& settingPath); | 116 | void handleSettingChanged(const std::string& settingPath); |
| 117 | void handlePurgeSavedLoginRequest(const std::string& username); | 117 | void handlePurgeSavedLoginRequest(const std::string& username); |
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 | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (c) 2016 Isode Limited. | 8 | * Copyright (c) 2016-2018 Isode Limited. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * See the COPYING file for more information. | 10 | * See the COPYING file for more information. |
| 11 | */ | 11 | */ |
| @@ -18,13 +18,13 @@ | |||
| 18 | 18 | ||
| 19 | namespace Swift { | 19 | namespace Swift { |
| 20 | 20 | ||
| 21 | FileTransferProgressInfo::FileTransferProgressInfo(boost::uintmax_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { | 21 | FileTransferProgressInfo::FileTransferProgressInfo(size_t completeBytes) : completeBytes(completeBytes), completedBytes(0), percentage(0) { |
| 22 | onProgressPercentage(0); | 22 | onProgressPercentage(0); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void FileTransferProgressInfo::setBytesProcessed(int processedBytes) { | 25 | void FileTransferProgressInfo::setBytesProcessed(size_t processedBytes) { |
| 26 | int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); | 26 | int oldPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); |
| 27 | completedBytes += boost::numeric_cast<boost::uintmax_t>(processedBytes); | 27 | completedBytes += processedBytes; |
| 28 | int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); | 28 | int newPercentage = int(double(completedBytes) / double(completeBytes) * 100.0); |
| 29 | if (oldPercentage != newPercentage) { | 29 | if (oldPercentage != newPercentage) { |
| 30 | onProgressPercentage(newPercentage); | 30 | onProgressPercentage(newPercentage); |
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 | |||
| @@ -5,31 +5,32 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (c) 2016 Isode Limited. | 8 | * Copyright (c) 2016-2018 Isode Limited. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * See the COPYING file for more information. | 10 | * See the COPYING file for more information. |
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #pragma once | 13 | #pragma once |
| 14 | 14 | ||
| 15 | #include <boost/cstdint.hpp> | 15 | #include <cstddef> |
| 16 | |||
| 16 | #include <boost/signals2.hpp> | 17 | #include <boost/signals2.hpp> |
| 17 | 18 | ||
| 18 | namespace Swift { | 19 | namespace Swift { |
| 19 | 20 | ||
| 20 | class FileTransferProgressInfo { | 21 | class FileTransferProgressInfo { |
| 21 | public: | 22 | public: |
| 22 | FileTransferProgressInfo(boost::uintmax_t completeBytes); | 23 | FileTransferProgressInfo(size_t completeBytes); |
| 23 | 24 | ||
| 24 | public: | 25 | public: |
| 25 | void setBytesProcessed(int processedBytes); | 26 | void setBytesProcessed(size_t processedBytes); |
| 26 | 27 | ||
| 27 | int getPercentage() const; | 28 | int getPercentage() const; |
| 28 | boost::signals2::signal<void (int)> onProgressPercentage; | 29 | boost::signals2::signal<void (int)> onProgressPercentage; |
| 29 | 30 | ||
| 30 | private: | 31 | private: |
| 31 | boost::uintmax_t completeBytes; | 32 | size_t completeBytes; |
| 32 | boost::uintmax_t completedBytes; | 33 | size_t completedBytes; |
| 33 | int percentage; | 34 | int percentage; |
| 34 | }; | 35 | }; |
| 35 | 36 | ||
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,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2011-2016 Isode Limited. | 2 | * Copyright (c) 2011-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 | */ |
| @@ -32,7 +32,7 @@ namespace Swift { | |||
| 32 | Predicate predicate; | 32 | Predicate predicate; |
| 33 | for (size_t i = 1; i < width; ++i) { | 33 | for (size_t i = 1; i < width; ++i) { |
| 34 | for (size_t j = 1; j < height; ++j) { | 34 | for (size_t j = 1; j < height; ++j) { |
| 35 | 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)]); | 35 | 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)]); |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | } | 38 | } |
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,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2011-2016 Isode Limited. | 2 | * Copyright (c) 2011-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 | */ |
| @@ -132,15 +132,20 @@ void TableRoster::handleUpdateTimerTick() { | |||
| 132 | std::vector<size_t> itemRemoves; | 132 | std::vector<size_t> itemRemoves; |
| 133 | std::vector<size_t> itemInserts; | 133 | std::vector<size_t> itemInserts; |
| 134 | computeIndexDiff<Item, ItemEquals, ItemNeedsUpdate >(sections[sectionUpdates[i]].items, newSections[sectionPostUpdates[i]].items, itemUpdates, itemPostUpdates, itemRemoves, itemInserts); | 134 | computeIndexDiff<Item, ItemEquals, ItemNeedsUpdate >(sections[sectionUpdates[i]].items, newSections[sectionPostUpdates[i]].items, itemUpdates, itemPostUpdates, itemRemoves, itemInserts); |
| 135 | size_t end = update.insertedRows.size(); | 135 | try { |
| 136 | update.insertedRows.resize(update.insertedRows.size() + itemInserts.size()); | 136 | size_t end = update.insertedRows.size(); |
| 137 | std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); | 137 | update.insertedRows.resize(update.insertedRows.size() + itemInserts.size()); |
| 138 | end = update.deletedRows.size(); | 138 | std::transform(itemInserts.begin(), itemInserts.end(), update.insertedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); |
| 139 | update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size()); | 139 | end = update.deletedRows.size(); |
| 140 | std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i])); | 140 | update.deletedRows.resize(update.deletedRows.size() + itemRemoves.size()); |
| 141 | end = update.updatedRows.size(); | 141 | std::transform(itemRemoves.begin(), itemRemoves.end(), update.deletedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionUpdates[i])); |
| 142 | update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size()); | 142 | end = update.updatedRows.size(); |
| 143 | std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); | 143 | update.updatedRows.resize(update.updatedRows.size() + itemUpdates.size()); |
| 144 | std::transform(itemUpdates.begin(), itemUpdates.end(), update.updatedRows.begin() + boost::numeric_cast<long long>(end), CreateIndexForSection(sectionPostUpdates[i])); | ||
| 145 | } | ||
| 146 | catch (const boost::numeric::bad_numeric_cast&) { | ||
| 147 | // If any container claims it has more than long long max items, we have bigger issues, so letting this pass | ||
| 148 | } | ||
| 144 | } | 149 | } |
| 145 | 150 | ||
| 146 | // Switch the old model with the new | 151 | // Switch the old model with the new |
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 | |||
| @@ -50,10 +50,15 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { | |||
| 50 | std::cerr << "ERROR: " << e.what() << std::endl; | 50 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out); | 53 | try { |
| 54 | ByteArray data = certificate->toDER(); | 54 | boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out); |
| 55 | file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size())); | 55 | ByteArray data = certificate->toDER(); |
| 56 | file.close(); | 56 | file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size())); |
| 57 | file.close(); | ||
| 58 | } | ||
| 59 | catch (...) { | ||
| 60 | SWIFT_LOG(warning) << "Failed to store certificate to " << certificatePath << std::endl; | ||
| 61 | } | ||
| 57 | } | 62 | } |
| 58 | 63 | ||
| 59 | boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { | 64 | boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { |
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,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 | */ |
| @@ -51,7 +51,7 @@ void EventController::handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEve | |||
| 51 | if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent || mucInviteEvent || incomingFileTransferEvent) { | 51 | if ((messageEvent && messageEvent->isReadable()) || subscriptionEvent || errorEvent || mucInviteEvent || incomingFileTransferEvent) { |
| 52 | events_.push_back(sourceEvent); | 52 | events_.push_back(sourceEvent); |
| 53 | sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); | 53 | sourceEvent->onConclusion.connect(boost::bind(&EventController::handleEventConcluded, this, sourceEvent)); |
| 54 | onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); | 54 | onEventQueueLengthChange(events_.size()); |
| 55 | onEventQueueEventAdded(sourceEvent); | 55 | onEventQueueEventAdded(sourceEvent); |
| 56 | if (sourceEvent->getConcluded()) { | 56 | if (sourceEvent->getConcluded()) { |
| 57 | handleEventConcluded(sourceEvent); | 57 | handleEventConcluded(sourceEvent); |
| @@ -62,7 +62,7 @@ void EventController::handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEve | |||
| 62 | void EventController::handleEventConcluded(std::shared_ptr<StanzaEvent> event) { | 62 | void EventController::handleEventConcluded(std::shared_ptr<StanzaEvent> event) { |
| 63 | event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); | 63 | event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); |
| 64 | events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); | 64 | events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); |
| 65 | onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); | 65 | onEventQueueLengthChange(events_.size()); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | void EventController::disconnectAll() { | 68 | void EventController::disconnectAll() { |
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,11 +1,12 @@ | |||
| 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 | */ |
| 6 | 6 | ||
| 7 | #pragma once | 7 | #pragma once |
| 8 | 8 | ||
| 9 | #include <cstddef> | ||
| 9 | #include <memory> | 10 | #include <memory> |
| 10 | #include <vector> | 11 | #include <vector> |
| 11 | 12 | ||
| @@ -22,7 +23,7 @@ namespace Swift { | |||
| 22 | ~EventController(); | 23 | ~EventController(); |
| 23 | 24 | ||
| 24 | void handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEvent); | 25 | void handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEvent); |
| 25 | boost::signals2::signal<void (int)> onEventQueueLengthChange; | 26 | boost::signals2::signal<void (size_t)> onEventQueueLengthChange; |
| 26 | boost::signals2::signal<void (std::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; | 27 | boost::signals2::signal<void (std::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; |
| 27 | const EventList& getEvents() const {return events_;} | 28 | const EventList& getEvents() const {return events_;} |
| 28 | void disconnectAll(); | 29 | void disconnectAll(); |
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,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 | */ |
| @@ -7,8 +7,6 @@ | |||
| 7 | 7 | ||
| 8 | #include <Swift/QtUI/QtWebView.h> | 8 | #include <Swift/QtUI/QtWebView.h> |
| 9 | 9 | ||
| 10 | #include <boost/numeric/conversion/cast.hpp> | ||
| 11 | |||
| 12 | #include <QFocusEvent> | 10 | #include <QFocusEvent> |
| 13 | #include <QKeyEvent> | 11 | #include <QKeyEvent> |
| 14 | #include <QKeySequence> | 12 | #include <QKeySequence> |
| @@ -48,7 +46,7 @@ void QtWebView::keyPressEvent(QKeyEvent* event) { | |||
| 48 | modifiers, | 46 | modifiers, |
| 49 | event->text(), | 47 | event->text(), |
| 50 | event->isAutoRepeat(), | 48 | event->isAutoRepeat(), |
| 51 | boost::numeric_cast<unsigned short>(event->count())); | 49 | event->count()); |
| 52 | QWebView::keyPressEvent(translatedEvent); | 50 | QWebView::keyPressEvent(translatedEvent); |
| 53 | delete translatedEvent; | 51 | delete translatedEvent; |
| 54 | } | 52 | } |
Swift