mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
feat(MainDb): basix fetch of chatrooms
This commit is contained in:
parent
639792b0e7
commit
a0e041ec1e
3 changed files with 34 additions and 24 deletions
|
|
@ -41,9 +41,10 @@ public:
|
|||
std::string getDataPath() const;
|
||||
std::string getConfigPath() const;
|
||||
|
||||
const std::list<std::shared_ptr<ChatRoom>> &getChatRooms () const;
|
||||
|
||||
std::shared_ptr<ChatRoom> createClientGroupChatRoom (const std::string &subject);
|
||||
std::shared_ptr<ChatRoom> getOrCreateChatRoom (const std::string &peerAddress, bool isRtt = false) const;
|
||||
const std::list<std::shared_ptr<ChatRoom>> &getChatRooms () const;
|
||||
|
||||
private:
|
||||
L_DECLARE_PRIVATE(Core);
|
||||
|
|
|
|||
|
|
@ -1004,37 +1004,51 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
list<shared_ptr<ChatRoom>> MainDb::getChatRooms () const {
|
||||
list<shared_ptr<ChatRoom>> chatRooms;
|
||||
// TODO.
|
||||
return chatRooms;
|
||||
}
|
||||
static const string query = "SELECT value, creation_date, last_update_date, capabilities, subject, last_notify_id"
|
||||
" FROM chat_room, sip_address"
|
||||
" WHERE peer_sip_address_id = id";
|
||||
|
||||
shared_ptr<ChatRoom> MainDb::findChatRoom (const string &peerAddress) const {
|
||||
L_D();
|
||||
|
||||
// TODO: Use core cache.
|
||||
list<shared_ptr<ChatRoom>> chatRooms;
|
||||
|
||||
L_BEGIN_LOG_EXCEPTION
|
||||
|
||||
soci::session *session = d->dbSession.getBackendSession<soci::session>();
|
||||
|
||||
tm creationDate;
|
||||
tm lastUpdateDate;
|
||||
int capabilities;
|
||||
string subject;
|
||||
soci::rowset<soci::row> rows = (session->prepare << query);
|
||||
for (const auto &row : rows) {
|
||||
string sipAddress = row.get<string>(0);
|
||||
tm creationDate = row.get<tm>(1);
|
||||
tm lastUpdateDate = row.get<tm>(2);
|
||||
int capabilities = row.get<int>(3);
|
||||
string subject = row.get<string>(4);
|
||||
unsigned int lastNotifyId = row.get<unsigned int>(5);
|
||||
|
||||
*session << "SELECT creation_date, last_update_date, capabilities, subject "
|
||||
" FROM chat_room"
|
||||
" WHERE peer_sip_address_id = ("
|
||||
" SELECT id from sip_address WHERE value = :peerAddress"
|
||||
" )", soci::use(peerAddress), soci::into(creationDate), soci::into(lastUpdateDate),
|
||||
soci::use(capabilities), soci::use(subject);
|
||||
(void)sipAddress;
|
||||
(void)creationDate;
|
||||
(void)lastUpdateDate;
|
||||
(void)capabilities;
|
||||
(void)subject;
|
||||
(void)lastNotifyId;
|
||||
|
||||
// TODO.
|
||||
if (capabilities & static_cast<int>(ChatRoom::Capabilities::Basic)) {
|
||||
if (capabilities & static_cast<int>(ChatRoom::Capabilities::RealTimeText)) {
|
||||
// TODO.
|
||||
continue;
|
||||
}
|
||||
// TODO.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (capabilities & static_cast<int>(ChatRoom::Capabilities::Conference)) {
|
||||
// TODO.
|
||||
}
|
||||
}
|
||||
|
||||
L_END_LOG_EXCEPTION
|
||||
|
||||
return shared_ptr<ChatRoom>();
|
||||
return chatRooms;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -1228,10 +1242,6 @@ shared_ptr<ChatRoom> MainDb::findChatRoom (const string &peerAddress) const {
|
|||
|
||||
void MainDb::cleanHistory (const string &, FilterMask) {}
|
||||
|
||||
shared_ptr<ChatRoom> MainDb::findChatRoom (const string &) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MainDb::import (Backend, const string &) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ public:
|
|||
|
||||
// ChatRooms.
|
||||
std::list<std::shared_ptr<ChatRoom>> getChatRooms () const;
|
||||
std::shared_ptr<ChatRoom> findChatRoom (const std::string &peerAddress) const;
|
||||
|
||||
// Import legacy messages from old db.
|
||||
bool import (Backend backend, const std::string ¶meters) override;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue