From 58c94c8672021502dfea6056c89c0072d6b9de46 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 18 Oct 2017 10:45:04 +0200 Subject: [PATCH] feat(Core): database access in progress --- src/CMakeLists.txt | 1 + src/core/core.cpp | 33 +++++++++++++++++++++++++++------ src/core/core.h | 13 +++++++++---- src/db/main-db.cpp | 8 ++++++++ src/db/main-db.h | 1 + 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6f00397b..2e6c4a00b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,6 +79,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES conference/session/port-config.h content/content-type.h content/content.h + core/core-p.h core/core.h db/abstract/abstract-db-p.h db/abstract/abstract-db.h diff --git a/src/core/core.cpp b/src/core/core.cpp index ff9975e27..fe3e79218 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -17,21 +17,42 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + +#include "address/address.h" +#include "chat/chat-room/basic-chat-room.h" +#include "core-p.h" +#include "db/main-db.h" #include "object/object-p.h" #include "core.h" // ============================================================================= -LINPHONE_BEGIN_NAMESPACE +using namespace std; -class CorePrivate : public ObjectPrivate { -public: - // TODO. -}; +LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- -Core::Core (CorePrivate &p) : Object(p) {} +Core::Core () : Object(*new CorePrivate) {} + +// ----------------------------------------------------------------------------- + +shared_ptr Core::createClientGroupChatRoom (const string &subject) { + // TODO. + return shared_ptr(); +} + +shared_ptr Core::getOrCreateChatRoom (const string &peerAddress, bool isRtt) const { + return shared_ptr(); +} + +const list> &Core::getChatRooms () const { + L_D(); + return d->chatRooms; +} + +// ----------------------------------------------------------------------------- LINPHONE_END_NAMESPACE diff --git a/src/core/core.h b/src/core/core.h index 025c60d22..88251aea5 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -20,21 +20,26 @@ #ifndef _CORE_H_ #define _CORE_H_ -#include "object/object.h" +#include + +#include "chat/chat-room/chat-room.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE +class ChatRoom; class CorePrivate; class LINPHONE_PUBLIC Core : public Object { public: - // Nothing for the moment. + Core (); + + std::shared_ptr createClientGroupChatRoom (const std::string &subject); + std::shared_ptr getOrCreateChatRoom (const std::string &peerAddress, bool isRtt = false) const; + const std::list> &getChatRooms () const; private: - explicit Core (CorePrivate &p); - L_DECLARE_PRIVATE(Core); L_DISABLE_COPY(Core); }; diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index 5376a8f87..191932e60 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -854,6 +854,12 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {} // ----------------------------------------------------------------------------- +list> MainDb::getChatRooms () const { + list> chatRooms; + // TODO. + return chatRooms; +} + shared_ptr MainDb::findChatRoom (const string &peerAddress) const { L_D(); @@ -875,6 +881,8 @@ shared_ptr MainDb::findChatRoom (const string &peerAddress) const { " )", soci::use(peerAddress), soci::into(creationDate), soci::into(lastUpdateDate), soci::use(capabilities), soci::use(subject); + // TODO. + L_END_LOG_EXCEPTION return shared_ptr(); diff --git a/src/db/main-db.h b/src/db/main-db.h index 1cc262bc1..ae1dfe40f 100644 --- a/src/db/main-db.h +++ b/src/db/main-db.h @@ -70,6 +70,7 @@ public: void cleanHistory (const std::string &peerAddress = "", FilterMask mask = NoFilter); // ChatRooms. + std::list> getChatRooms () const; std::shared_ptr findChatRoom (const std::string &peerAddress) const; // Import legacy messages from old db.