diff options
Diffstat (limited to 'Swift/Controllers')
| -rw-r--r-- | Swift/Controllers/HistoryController.cpp | 9 | ||||
| -rw-r--r-- | Swift/Controllers/Roster/ItemOperations/SetMUC.h | 3 | ||||
| -rw-r--r-- | Swift/Controllers/Storages/FileStorages.cpp | 4 | ||||
| -rw-r--r-- | Swift/Controllers/WhiteboardManager.cpp | 4 |
4 files changed, 14 insertions, 6 deletions
diff --git a/Swift/Controllers/HistoryController.cpp b/Swift/Controllers/HistoryController.cpp index d730236..5732382 100644 --- a/Swift/Controllers/HistoryController.cpp +++ b/Swift/Controllers/HistoryController.cpp @@ -1,49 +1,56 @@ /* * Copyright (c) 2012 Catalin Badea * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2014 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + + #include <Swift/Controllers/HistoryController.h> #include <Swiften/History/HistoryStorage.h> #include <Swiften/History/HistoryMessage.h> #include <boost/date_time/c_local_time_adjustor.hpp> namespace Swift { -HistoryController::HistoryController(HistoryStorage* localHistoryStorage) : localHistory_(localHistoryStorage) { +HistoryController::HistoryController(HistoryStorage* localHistoryStorage) : localHistory_(localHistoryStorage), remoteArchiveSupported_(false) { } HistoryController::~HistoryController() { } void HistoryController::addMessage(const std::string& message, const JID& fromJID, const JID& toJID, HistoryMessage::Type type, const boost::posix_time::ptime& timeStamp) { // note: using localtime timestamps boost::posix_time::ptime localTime = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(timeStamp); int offset = (localTime - timeStamp).hours(); HistoryMessage historyMessage(message, fromJID, toJID, type, localTime, offset); localHistory_->addMessage(historyMessage); onNewMessage(historyMessage); } std::vector<HistoryMessage> HistoryController::getMessagesFromDate(const JID& selfJID, const JID& contactJID, HistoryMessage::Type type, const boost::gregorian::date& date) const { return localHistory_->getMessagesFromDate(selfJID, contactJID, type, date); } std::vector<HistoryMessage> HistoryController::getMUCContext(const JID& selfJID, const JID& mucJID, const boost::posix_time::ptime& timeStamp) const { boost::posix_time::ptime localTime = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(timeStamp); return getMessagesFromDate(selfJID, mucJID, HistoryMessage::Groupchat, localTime.date()); } std::vector<HistoryMessage> HistoryController::getMessagesFromPreviousDate(const JID& selfJID, const JID& contactJID, HistoryMessage::Type type, const boost::gregorian::date& date) const { return localHistory_->getMessagesFromPreviousDate(selfJID, contactJID, type, date); } std::vector<HistoryMessage> HistoryController::getMessagesFromNextDate(const JID& selfJID, const JID& contactJID, HistoryMessage::Type type, const boost::gregorian::date& date) const { return localHistory_->getMessagesFromNextDate(selfJID, contactJID, type, date); } ContactsMap HistoryController::getContacts(const JID& selfJID, HistoryMessage::Type type, const std::string& keyword) const { return localHistory_->getContacts(selfJID, type, keyword); diff --git a/Swift/Controllers/Roster/ItemOperations/SetMUC.h b/Swift/Controllers/Roster/ItemOperations/SetMUC.h index de40e04..598e5f5 100644 --- a/Swift/Controllers/Roster/ItemOperations/SetMUC.h +++ b/Swift/Controllers/Roster/ItemOperations/SetMUC.h @@ -1,39 +1,38 @@ /* - * Copyright (c) 2013 Kevin Smith and Remko Tronçon + * Copyright (c) 2013-2014 Kevin Smith and Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include <Swiften/JID/JID.h> #include <Swift/Controllers/Roster/ItemOperations/RosterItemOperation.h> #include <Swift/Controllers/Roster/ContactRosterItem.h> namespace Swift { class RosterItem; class SetMUC : public RosterItemOperation { public: SetMUC(const JID& jid, const MUCOccupant::Role& role, const MUCOccupant::Affiliation& affiliation) : RosterItemOperation(true, jid), jid_(jid), mucRole_(role), mucAffiliation_(affiliation) { } virtual void operator() (RosterItem* item) const { ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item); if (contact && contact->getJID().equals(jid_, JID::WithResource)) { contact->setMUCRole(mucRole_); contact->setMUCAffiliation(mucAffiliation_); } } private: JID jid_; - bool mucParticipant_; MUCOccupant::Role mucRole_; MUCOccupant::Affiliation mucAffiliation_; }; } diff --git a/Swift/Controllers/Storages/FileStorages.cpp b/Swift/Controllers/Storages/FileStorages.cpp index 52a5e00..e1b681f 100644 --- a/Swift/Controllers/Storages/FileStorages.cpp +++ b/Swift/Controllers/Storages/FileStorages.cpp @@ -1,62 +1,62 @@ /* * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include "Swift/Controllers/Storages/FileStorages.h" #include "Swift/Controllers/Storages/VCardFileStorage.h" #include "Swift/Controllers/Storages/AvatarFileStorage.h" #include "Swift/Controllers/Storages/CapsFileStorage.h" #include "Swift/Controllers/Storages/RosterFileStorage.h" #include <Swiften/History/SQLiteHistoryStorage.h> #include <Swiften/Base/Path.h> namespace Swift { FileStorages::FileStorages(const boost::filesystem::path& baseDir, const JID& jid, CryptoProvider* crypto) { boost::filesystem::path profile = stringToPath(jid.toBare()); vcardStorage = new VCardFileStorage(baseDir / profile / "vcards", crypto); capsStorage = new CapsFileStorage(baseDir / "caps"); avatarStorage = new AvatarFileStorage(baseDir / "avatars", baseDir / profile / "avatars", crypto); rosterStorage = new RosterFileStorage(baseDir / profile / "roster.xml"); #ifdef SWIFT_EXPERIMENTAL_HISTORY historyStorage = new SQLiteHistoryStorage(baseDir / "history.db"); +#else + historyStorage = NULL; #endif } FileStorages::~FileStorages() { delete rosterStorage; delete avatarStorage; delete capsStorage; delete vcardStorage; -#ifdef SWIFT_EXPERIMENTAL_HISTORY delete historyStorage; -#endif } VCardStorage* FileStorages::getVCardStorage() const { return vcardStorage; } CapsStorage* FileStorages::getCapsStorage() const { return capsStorage; } AvatarStorage* FileStorages::getAvatarStorage() const { return avatarStorage; } RosterStorage* FileStorages::getRosterStorage() const { return rosterStorage; } HistoryStorage* FileStorages::getHistoryStorage() const { #ifdef SWIFT_EXPERIMENTAL_HISTORY return historyStorage; #else return NULL; #endif } } diff --git a/Swift/Controllers/WhiteboardManager.cpp b/Swift/Controllers/WhiteboardManager.cpp index 50aba6f..d8d89eb 100644 --- a/Swift/Controllers/WhiteboardManager.cpp +++ b/Swift/Controllers/WhiteboardManager.cpp @@ -93,44 +93,46 @@ namespace Swift { } onSessionRequest(session->getTo(), true); } void WhiteboardManager::cancelSession(const JID& from) { WhiteboardSession::ref session = whiteboardSessionManager_->getSession(from); if (session) { session->cancel(); } } void WhiteboardManager::handleIncomingSession(IncomingWhiteboardSession::ref session) { session->onSessionTerminated.connect(boost::bind(&WhiteboardManager::handleSessionTerminate, this, _1)); session->onRequestAccepted.connect(boost::bind(&WhiteboardManager::handleSessionAccept, this, _1)); WhiteboardWindow* window = findWhiteboardWindow(session->getTo()); if (window == NULL) { createNewWhiteboardWindow(session->getTo(), session); } else { window->setSession(session); } onSessionRequest(session->getTo(), false); } void WhiteboardManager::handleSessionTerminate(const JID& contact) { onSessionTerminate(contact); } void WhiteboardManager::handleSessionCancel(const JID& contact) { onSessionTerminate(contact); } void WhiteboardManager::handleSessionAccept(const JID& contact) { WhiteboardWindow* window = findWhiteboardWindow(contact); - window->show(); + if (window != NULL) { + window->show(); + } onRequestAccepted(contact); } void WhiteboardManager::handleRequestReject(const JID& contact) { onRequestRejected(contact); } } |
Swift