Commit 6467c770 authored by Ronan's avatar Ronan

feat(MainDb): supports getHistory and getHistoryRange

parent 84ef68eb
......@@ -906,16 +906,10 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
}
list<shared_ptr<EventLog>> MainDb::getHistory (const string &peerAddress, int nLast, FilterMask mask) const {
if (!isConnected()) {
lWarning() << "Unable to get history. Not connected.";
return list<shared_ptr<EventLog>>();
}
// TODO.
return list<shared_ptr<EventLog>>();
return getHistoryRange(peerAddress, 0, nLast - 1, mask);
}
list<shared_ptr<EventLog>> MainDb::getHistory (
list<shared_ptr<EventLog>> MainDb::getHistoryRange (
const string &peerAddress,
int begin,
int end,
......@@ -1228,7 +1222,7 @@ shared_ptr<ChatRoom> MainDb::findChatRoom (const string &peerAddress) const {
return list<shared_ptr<EventLog>>();
}
list<shared_ptr<EventLog>> MainDb::getHistory (const string &, int, int, FilterMask) const {
list<shared_ptr<EventLog>> MainDb::getHistoryRange (const string &, int, int, FilterMask) const {
return list<shared_ptr<EventLog>>();
}
......
......@@ -61,7 +61,7 @@ public:
int nLast,
FilterMask mask = NoFilter
) const;
std::list<std::shared_ptr<EventLog>> getHistory (
std::list<std::shared_ptr<EventLog>> getHistoryRange (
const std::string &peerAddress,
int begin,
int end,
......
......@@ -68,17 +68,29 @@ static void get_history () {
MainDb mainDb;
BC_ASSERT_TRUE(mainDb.connect(MainDb::Sqlite3, getDatabasePath()));
BC_ASSERT_EQUAL(
mainDb.getHistory("sip:test-39@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceChatMessageFilter).size(),
mainDb.getHistoryRange("sip:test-39@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceChatMessageFilter).size(),
3,
int,
"%d"
);
BC_ASSERT_EQUAL(
mainDb.getHistory("sip:test-7@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceCallFilter).size(),
mainDb.getHistoryRange("sip:test-7@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceCallFilter).size(),
0,
int,
"%d"
);
BC_ASSERT_EQUAL(
mainDb.getHistoryRange("sip:test-1@sip.linphone.org", 0, -1, MainDb::Filter::ConferenceChatMessageFilter).size(),
862,
int,
"%d"
);
BC_ASSERT_EQUAL(
mainDb.getHistory("sip:test-1@sip.linphone.org", 100, MainDb::Filter::ConferenceChatMessageFilter).size(),
100,
int,
"%d"
);
}
test_t main_db_tests[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment