summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Chat/ChatControllerBase.cpp5
-rw-r--r--Swift/Controllers/HistoryController.cpp27
-rw-r--r--Swift/Controllers/HistoryController.h5
-rw-r--r--Swift/Controllers/HistoryViewController.cpp16
-rw-r--r--Swift/Controllers/HistoryViewController.h4
-rw-r--r--Swift/Controllers/MainController.cpp2
-rw-r--r--Swift/Controllers/UIInterfaces/HistoryWindow.h3
7 files changed, 45 insertions, 17 deletions
diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp
index f17e7c4..388f2c4 100644
--- a/Swift/Controllers/Chat/ChatControllerBase.cpp
+++ b/Swift/Controllers/Chat/ChatControllerBase.cpp
@@ -148,7 +148,7 @@ void ChatControllerBase::handleSendMessageRequest(const std::string &body, bool
onActivity(message->getBody());
// log message
- historyController_->addMessage(getBaseJID(), selfJID_, toJID_, body, now);
+ historyController_->addMessage(getBaseJID(), selfJID_, std::string("me"), body, now);
}
void ChatControllerBase::handleSecurityLabelsCatalogResponse(boost::shared_ptr<SecurityLabelsCatalog> catalog, ErrorPayload::ref error) {
@@ -255,8 +255,7 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m
}
else {
lastMessagesUIID_[from] = addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), label, std::string(avatarManager_->getAvatarPath(from).string()), timeStamp);
- // void HistoryController::addMessage(const JID& baseJID, const JID& fromJID, const JID& toJID, std::string messageBody, boost::posix_time::ptime timeStamp) {
- historyController_->addMessage(getBaseJID(), from, message->getTo(), body, timeStamp);
+ historyController_->addMessage(getBaseJID(), from, senderDisplayNameFromMessage(from), body, timeStamp);
}
}
chatWindow_->show();
diff --git a/Swift/Controllers/HistoryController.cpp b/Swift/Controllers/HistoryController.cpp
index a19e321..c82892a 100644
--- a/Swift/Controllers/HistoryController.cpp
+++ b/Swift/Controllers/HistoryController.cpp
@@ -6,19 +6,26 @@
#include <Swift/Controllers/HistoryController.h>
#include <Swiften/History/SQLiteHistoryManager.h>
+#include <Swiften/History/HistoryMessage.h>
namespace Swift {
- HistoryController::HistoryController() : remoteArchiveSupported_(false) {
- std::string file("testDB.db");
- localHistory_ = new SQLiteHistoryManager(file);
- }
- HistoryController::~HistoryController() {
- delete localHistory_;
- }
+HistoryController::HistoryController() : remoteArchiveSupported_(false) {
+ std::string file("testDB.db");
+ localHistory_ = new SQLiteHistoryManager(file);
+}
+
+HistoryController::~HistoryController() {
+ delete localHistory_;
+}
- void HistoryController::addMessage(const JID& baseJID, const JID& fromJID, const JID& toJID, std::string messageBody, boost::posix_time::ptime timeStamp) {
- std::cout << baseJID << " " << fromJID << " " << toJID << " " << messageBody << " " << to_simple_string(timeStamp);
- }
+void HistoryController::addMessage(const JID& baseJID, const JID& fromJID, const std::string& displayNick, const std::string& messageBody, boost::posix_time::ptime timeStamp) {
+ HistoryMessage message(messageBody, baseJID, fromJID, displayNick, timeStamp);
+ localHistory_->addMessage(message);
+}
+
+std::vector<HistoryMessage> HistoryController::getMessages() const {
+ return localHistory_->getMessages();
+}
}
diff --git a/Swift/Controllers/HistoryController.h b/Swift/Controllers/HistoryController.h
index 9949c19..6ead3f1 100644
--- a/Swift/Controllers/HistoryController.h
+++ b/Swift/Controllers/HistoryController.h
@@ -8,9 +8,11 @@
#include <Swiften/JID/JID.h>
#include <boost/date_time/posix_time/posix_time.hpp>
+#include <vector>
namespace Swift {
class HistoryManager;
+ class HistoryMessage;
class JID;
class HistoryController {
@@ -18,7 +20,8 @@ namespace Swift {
HistoryController();
~HistoryController();
- void addMessage(const JID& baseJID, const JID& fromJID, const JID& toJID, std::string messageBody, boost::posix_time::ptime timeStamp);
+ void addMessage(const JID& baseJID, const JID& fromJID, const std::string& displayNick, const std::string& messageBody, boost::posix_time::ptime timeStamp);
+ std::vector<HistoryMessage> getMessages() const;
private:
HistoryManager* localHistory_;
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index cbfa687..1061e78 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -8,10 +8,19 @@
#include <Swift/Controllers/UIInterfaces/HistoryWindowFactory.h>
#include <Swift/Controllers/UIEvents/RequestHistoryUIEvent.h>
+#include <Swift/Controllers/HistoryController.h>
+#include <Swiften/History/HistoryMessage.h>
namespace Swift {
-HistoryViewController::HistoryViewController(UIEventStream* uiEventStream, HistoryWindowFactory* historyWindowFactory) : uiEventStream_(uiEventStream), historyWindowFactory_(historyWindowFactory), historyWindow_(NULL) {
+HistoryViewController::HistoryViewController(
+ UIEventStream* uiEventStream,
+ HistoryController* historyController,
+ HistoryWindowFactory* historyWindowFactory) :
+ uiEventStream_(uiEventStream),
+ historyController_(historyController),
+ historyWindowFactory_(historyWindowFactory),
+ historyWindow_(NULL) {
uiEventStream_->onUIEvent.connect(boost::bind(&HistoryViewController::handleUIEvent, this, _1));
}
@@ -37,6 +46,11 @@ void HistoryViewController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
roster_->addContact(medvedev, medvedev, "Dmitri Medvedev", "Recent", "");
roster_->addContact(kev, kev, "Kev", "Recent", "");
}
+
+ std::vector<HistoryMessage> messages = historyController_->getMessages();
+ for (std::vector<HistoryMessage>::iterator it = messages.begin(); it != messages.end(); it++) {
+ historyWindow_->addMessage(*it);
+ }
historyWindow_->activate();
}
}
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index 08e6324..f64dd35 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -16,10 +16,11 @@ namespace Swift {
class HistoryWindowFactory;
class HistoryWindow;
class Roster;
+ class HistoryController;
class HistoryViewController {
public:
- HistoryViewController(UIEventStream* uiEventStream, HistoryWindowFactory* historyWindowFactory);
+ HistoryViewController(UIEventStream* uiEventStream, HistoryController* historyController, HistoryWindowFactory* historyWindowFactory);
~HistoryViewController();
private:
@@ -27,6 +28,7 @@ namespace Swift {
private:
UIEventStream* uiEventStream_;
+ HistoryController* historyController_;
HistoryWindowFactory* historyWindowFactory_;
HistoryWindow* historyWindow_;
Roster* roster_;
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 793e72f..e894aed 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -172,7 +172,7 @@ MainController::MainController(
xmlConsoleController_ = new XMLConsoleController(uiEventStream_, uiFactory_);
historyController_ = new HistoryController();
- historyViewController_ = new HistoryViewController(uiEventStream_, uiFactory_);
+ historyViewController_ = new HistoryViewController(uiEventStream_, historyController_, uiFactory_);
fileTransferListController_ = new FileTransferListController(uiEventStream_, uiFactory_);
diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h
index 713f986..9ec79e2 100644
--- a/Swift/Controllers/UIInterfaces/HistoryWindow.h
+++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h
@@ -9,11 +9,14 @@
#include <Swift/Controllers/Roster/Roster.h>
namespace Swift {
+ class HistoryMessage;
+
class HistoryWindow {
public:
virtual ~HistoryWindow() {};
virtual void activate() = 0;
virtual void setRosterModel(Roster*) = 0;
+ virtual void addMessage(const HistoryMessage& message) = 0;
};
}