Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ofono] Added __ofono_set_config_dir() function
Allows to make configuration directory configurable.
Also, useful for unit tests.
  • Loading branch information
monich committed Dec 26, 2019
1 parent 08f8555 commit 93ff644
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 6 additions & 2 deletions ofono/drivers/ril/ril_plugin.c
Expand Up @@ -30,6 +30,7 @@

#include "sailfish_manager.h"

#include <ofono/storage.h>
#include <ofono/watch.h>

#include <grilio_transport.h>
Expand Down Expand Up @@ -62,7 +63,7 @@

#define RIL_SUB_SIZE 4

#define RILMODEM_CONF_FILE CONFIGDIR "/ril_subscription.conf"
#define RILMODEM_CONF_FILE "ril_subscription.conf"
#define RILMODEM_DEFAULT_IDENTITY "radio:radio"
#define RILMODEM_DEFAULT_SOCK "/dev/socket/rild"
#define RILMODEM_DEFAULT_SOCK2 "/dev/socket/rild2"
Expand Down Expand Up @@ -2069,12 +2070,15 @@ static guint ril_plugin_manager_start(ril_plugin *plugin)
{
struct ril_plugin_settings *ps = &plugin->settings;
guint start_timeout = 0;
char* config_file = g_build_filename(ofono_config_dir(),
RILMODEM_CONF_FILE, NULL);

DBG("");
GASSERT(!plugin->start_timeout_id);
plugin->slots = ril_plugin_load_config(RILMODEM_CONF_FILE, ps);
plugin->slots = ril_plugin_load_config(config_file, ps);
plugin->data_manager = ril_data_manager_new(ps->dm_flags);
ril_plugin_init_slots(plugin);
g_free(config_file);

ofono_modem_driver_register(&ril_modem_driver);
ofono_sim_driver_register(&ril_sim_driver);
Expand Down
2 changes: 2 additions & 0 deletions ofono/src/ofono.h
Expand Up @@ -684,3 +684,5 @@ int mnclength(int mcc, int mnc);
#include <ofono/netmon.h>
#include <ofono/lte.h>
#include <ofono/ims.h>

void __ofono_set_config_dir(const char *dir);
12 changes: 11 additions & 1 deletion ofono/src/storage.c
Expand Up @@ -3,6 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
* Copyright (C) 2015-2019 Jolla Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
Expand Down Expand Up @@ -36,10 +37,19 @@
#include <glib.h>

#include "storage.h"
#include "ofono.h"

static char* config_dir = NULL;

void __ofono_set_config_dir(const char *dir)
{
g_free(config_dir);
config_dir = g_strdup(dir);
}

const char *ofono_config_dir(void)
{
return CONFIGDIR;
return config_dir ? config_dir : CONFIGDIR;
}

const char *ofono_storage_dir(void)
Expand Down

0 comments on commit 93ff644

Please sign in to comment.