summaryrefslogtreecommitdiffstats
blob: 5bd4ffaa6f26c83aef9dc09cb258c93b75203287 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (c) 2012 Catalin Badea
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#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_;
}

void HistoryController::addMessage(const std::string& message, const JID& fromJID, const JID& toJID, bool isGroupChat, const boost::posix_time::ptime& timeStamp) {
	HistoryMessage historyMessage(message, fromJID, toJID, isGroupChat, timeStamp);
	localHistory_->addMessage(historyMessage);
	onNewMessage(historyMessage);
}

std::vector<HistoryMessage> HistoryController::getMessages(const JID& selfJID, const JID& contactJID, bool isGroupChat) const {
	return localHistory_->getMessages(selfJID, contactJID, isGroupChat);
}

void HistoryController::getAllContacts(const JID& selfJID, std::set<JID>& mucs, std::set<JID>& contacts) const {
	return localHistory_->getAllContacts(selfJID, mucs, contacts);
}

}