diff --git a/include/linphone/utils/paths.h b/include/linphone/utils/paths.h index da968f719..70deea899 100644 --- a/include/linphone/utils/paths.h +++ b/include/linphone/utils/paths.h @@ -28,13 +28,14 @@ LINPHONE_BEGIN_NAMESPACE +class PlatformHelper; namespace Paths { enum Type { Data, Config }; - LINPHONE_PUBLIC const std::string &getPath(Type type, void *context); + LINPHONE_PUBLIC const std::string &getPath(Type type, PlatformHelper *platformHelper); } LINPHONE_END_NAMESPACE diff --git a/src/core/core.cpp b/src/core/core.cpp index 96bc6a01c..bf9dfa3c0 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -24,8 +24,11 @@ #include "core-p.h" #include "db/main-db.h" #include "linphone/core.h" +#include "linphone/utils/paths.h" #include "object/object-p.h" +#include "private.h" + #include "core.h" // ============================================================================= @@ -47,8 +50,8 @@ Core::Core (LinphoneCore *cCore) : Object(*new CorePrivate) { : MainDb::Sqlite3; d->mainDb.connect(backend, uri); } else { - // TODO - // d->mainDb.connect(MainDb::Sqlite3, linphone_factory_get_writable_dir()/linphone.db); + string path = Paths::getPath(Paths::Data, static_cast(cCore->platform_helper)); + //d->mainDb.connect(MainDb::Sqlite3, linphone_factory_get_writable_dir()/linphone.db); } } diff --git a/src/utils/paths/paths-android.cpp b/src/utils/paths/paths-android.cpp index f5601cba0..bce2b600e 100644 --- a/src/utils/paths/paths-android.cpp +++ b/src/utils/paths/paths-android.cpp @@ -19,6 +19,7 @@ #include +#include "private.h" #include "linphone/utils/utils.h" #include "paths-android.h" @@ -28,13 +29,21 @@ LINPHONE_BEGIN_NAMESPACE const std::string &SysPaths::getDataPath (void *context) { - //TODO. - return Utils::getEmptyConstRefObject(); + if (!context) { + return Utils::getEmptyConstRefObject(); + } + + AndroidPlatformHelper *helper = static_cast(context); + return helper->getDataPath(); } const std::string &SysPaths::getConfigPath (void *context) { - //TODO. - return Utils::getEmptyConstRefObject(); + if (!context) { + return Utils::getEmptyConstRefObject(); + } + + AndroidPlatformHelper *helper = static_cast(context); + return helper->getConfigPath(); } LINPHONE_END_NAMESPACE diff --git a/src/utils/paths/paths-android.h b/src/utils/paths/paths-android.h index 7cd7efd91..7822cc993 100644 --- a/src/utils/paths/paths-android.h +++ b/src/utils/paths/paths-android.h @@ -28,9 +28,10 @@ LINPHONE_BEGIN_NAMESPACE +class PlatformHelper; namespace SysPaths { - LINPHONE_PUBLIC const std::string &getDataPath (void *context); - LINPHONE_PUBLIC const std::string &getConfigPath (void *context); + LINPHONE_PUBLIC const std::string &getDataPath (PlatformHelper *platformHelper); + LINPHONE_PUBLIC const std::string &getConfigPath (PlatformHelper *platformHelper); } LINPHONE_END_NAMESPACE diff --git a/src/utils/paths/paths-apple.h b/src/utils/paths/paths-apple.h index db0cd35ff..4cb7fe237 100644 --- a/src/utils/paths/paths-apple.h +++ b/src/utils/paths/paths-apple.h @@ -28,9 +28,10 @@ LINPHONE_BEGIN_NAMESPACE +class PlatformHelper; namespace SysPaths { - LINPHONE_PUBLIC const std::string &getDataPath (void *context); - LINPHONE_PUBLIC const std::string &getConfigPath (void *context); + LINPHONE_PUBLIC const std::string &getDataPath (PlatformHelper *platformHelper); + LINPHONE_PUBLIC const std::string &getConfigPath (PlatformHelper *platformHelper); } LINPHONE_END_NAMESPACE diff --git a/src/utils/paths/paths-apple.mm b/src/utils/paths/paths-apple.mm index a9f65b248..62be4965f 100644 --- a/src/utils/paths/paths-apple.mm +++ b/src/utils/paths/paths-apple.mm @@ -19,6 +19,7 @@ #import "linphone/utils/utils.h" +#include "private.h" #import "paths-apple.h" #ifdef __OBJC__ @@ -29,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE -const std::string &SysPaths::getDataPath (void *context) { +const std::string &SysPaths::getDataPath (PlatformHelper *platformHelper) { #ifdef __OBJC__ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *writablePath = [paths objectAtIndex:0]; @@ -40,7 +41,7 @@ const std::string &SysPaths::getDataPath (void *context) { return Utils::getEmptyConstRefObject(); } -const std::string &SysPaths::getConfigPath (void *context) { +const std::string &SysPaths::getConfigPath (PlatformHelper *platformHelper) { #ifdef __OBJC__ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *configPath = [paths objectAtIndex:0]; diff --git a/src/utils/paths/paths-linux.cpp b/src/utils/paths/paths-linux.cpp index 11f47d29c..9e79c8d6f 100644 --- a/src/utils/paths/paths-linux.cpp +++ b/src/utils/paths/paths-linux.cpp @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "private.h" #include "linphone/utils/utils.h" #include "paths-linux.h" @@ -25,12 +26,12 @@ LINPHONE_BEGIN_NAMESPACE -const std::string &SysPaths::getDataPath (void *context) { +const std::string &SysPaths::getDataPath (PlatformHelper *platformHelper) { //TODO. return Utils::getEmptyConstRefObject(); } -const std::string &SysPaths::getConfigPath (void *context) { +const std::string &SysPaths::getConfigPath (PlatformHelper *platformHelper) { //TODO. return Utils::getEmptyConstRefObject(); } diff --git a/src/utils/paths/paths-linux.h b/src/utils/paths/paths-linux.h index 85a1f284e..6e4780d41 100644 --- a/src/utils/paths/paths-linux.h +++ b/src/utils/paths/paths-linux.h @@ -28,9 +28,10 @@ LINPHONE_BEGIN_NAMESPACE +class PlatformHelper; namespace SysPaths { - LINPHONE_PUBLIC const std::string &getDataPath (void *context); - LINPHONE_PUBLIC const std::string &getConfigPath (void *context); + LINPHONE_PUBLIC const std::string &getDataPath (PlatformHelper *platformHelper); + LINPHONE_PUBLIC const std::string &getConfigPath (PlatformHelper *platformHelper); } LINPHONE_END_NAMESPACE diff --git a/src/utils/paths/paths-windows.cpp b/src/utils/paths/paths-windows.cpp index fc6ec22f3..9ad20b968 100644 --- a/src/utils/paths/paths-windows.cpp +++ b/src/utils/paths/paths-windows.cpp @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "private.h" #include "linphone/utils/utils.h" #include "paths-windows.h" @@ -25,12 +26,12 @@ LINPHONE_BEGIN_NAMESPACE -const std::string &SysPaths::getDataPath (void *context) { +const std::string &SysPaths::getDataPath (PlatformHelper *platformHelper) { //TODO. return Utils::getEmptyConstRefObject(); } -const std::string &SysPaths::getConfigPath (void *context) { +const std::string &SysPaths::getConfigPath (PlatformHelper *platformHelper) { //TODO. return Utils::getEmptyConstRefObject(); } diff --git a/src/utils/paths/paths-windows.h b/src/utils/paths/paths-windows.h index b67b65e7a..f0f9b387a 100644 --- a/src/utils/paths/paths-windows.h +++ b/src/utils/paths/paths-windows.h @@ -28,9 +28,10 @@ LINPHONE_BEGIN_NAMESPACE +class PlatformHelper; namespace SysPaths { - LINPHONE_PUBLIC const std::string &getDataPath (void *context); - LINPHONE_PUBLIC const std::string &getConfigPath (void *context); + LINPHONE_PUBLIC const std::string &getDataPath (PlatformHelper *platformHelper); + LINPHONE_PUBLIC const std::string &getConfigPath (PlatformHelper *platformHelper); } LINPHONE_END_NAMESPACE diff --git a/src/utils/paths/paths.cpp b/src/utils/paths/paths.cpp index e3a937fff..16e652547 100644 --- a/src/utils/paths/paths.cpp +++ b/src/utils/paths/paths.cpp @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "private.h" #include "linphone/utils/paths.h" #ifdef __APPLE__ @@ -37,13 +38,13 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE -const string &Paths::getPath (Paths::Type type, void *context) { +const string &Paths::getPath (Paths::Type type, PlatformHelper *platformHelper) { switch (type) { case Data: - return SysPaths::getDataPath(context); + return SysPaths::getDataPath(platformHelper); case Config: default: - return SysPaths::getConfigPath(context); + return SysPaths::getConfigPath(platformHelper); } }