Commit 8b51263c authored by Benjamin REIS's avatar Benjamin REIS

pass platformHelper to Paths functions

parent ddf3fe65
......@@ -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
......
......@@ -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<PlatformHelper *>(cCore->platform_helper));
//d->mainDb.connect(MainDb::Sqlite3, linphone_factory_get_writable_dir()/linphone.db);
}
}
......
......@@ -19,6 +19,7 @@
#include <jni.h>
#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<std::string>();
if (!context) {
return Utils::getEmptyConstRefObject<std::string>();
}
AndroidPlatformHelper *helper = static_cast<AndroidPlatformHelper>(context);
return helper->getDataPath();
}
const std::string &SysPaths::getConfigPath (void *context) {
//TODO.
return Utils::getEmptyConstRefObject<std::string>();
if (!context) {
return Utils::getEmptyConstRefObject<std::string>();
}
AndroidPlatformHelper *helper = static_cast<AndroidPlatformHelper>(context);
return helper->getConfigPath();
}
LINPHONE_END_NAMESPACE
......@@ -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
......
......@@ -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
......
......@@ -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<std::string>();
}
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];
......
......@@ -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<std::string>();
}
const std::string &SysPaths::getConfigPath (void *context) {
const std::string &SysPaths::getConfigPath (PlatformHelper *platformHelper) {
//TODO.
return Utils::getEmptyConstRefObject<std::string>();
}
......
......@@ -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
......
......@@ -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<std::string>();
}
const std::string &SysPaths::getConfigPath (void *context) {
const std::string &SysPaths::getConfigPath (PlatformHelper *platformHelper) {
//TODO.
return Utils::getEmptyConstRefObject<std::string>();
}
......
......@@ -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
......
......@@ -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);
}
}
......
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