Commit e765c72b authored by spiiroin's avatar spiiroin

[dyn-config] Rename mode_list_elem_t to modedata_t

The important part is that these structures contain mode data, not
that they are also held in lists - make the naming reflect this.

Also rename related functions accordingly.

No functional changes.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 73b72100
......@@ -468,7 +468,7 @@ int common_valid_mode(const char *mode)
whitelist_array = g_strsplit(whitelist_value, ",", 0);
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) ) {
mode_list_elem_t *data = iter->data;
modedata_t *data = iter->data;
if( strcmp(mode, data->mode_name) )
continue;
......@@ -525,7 +525,7 @@ gchar *common_get_mode_list(mode_list_type_t type)
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{
mode_list_elem_t *data = iter->data;
modedata_t *data = iter->data;
/* skip items in the hidden list */
if (common_mode_in_list(data->mode_name, hidden_modes_array))
......
......@@ -622,7 +622,7 @@ char * config_get_network_setting(const char *config)
LOG_REGISTER_CONTEXT;
char * ret = 0;
mode_list_elem_t *data;
modedata_t *data;
if(!strcmp(config, NETWORK_IP_KEY))
{
......
......@@ -325,7 +325,7 @@ void control_select_usb_mode(void)
log_err("Diagnostic mode is not configured!");
}
else {
mode_list_elem_t *data = iter->data;
modedata_t *data = iter->data;
log_debug("Entering diagnostic mode!");
control_set_usb_mode(data->mode_name);
}
......
......@@ -1034,11 +1034,11 @@ umdbus_append_mode_details(DBusMessage *msg, const char *mode_name)
{
LOG_REGISTER_CONTEXT;
const mode_list_elem_t *data = 0;
const modedata_t *data = 0;
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{
const mode_list_elem_t *iter_data = iter->data;
const modedata_t *iter_data = iter->data;
if( g_strcmp0(iter_data->mode_name, mode_name) )
continue;
data = iter_data;
......
......@@ -37,20 +37,25 @@
* ========================================================================= */
/* ------------------------------------------------------------------------- *
* UTILITY
* MODEDATA
* ------------------------------------------------------------------------- */
void dynconfig_free_list_item(mode_list_elem_t *list_item);
void dynconfig_free_mode_list(GList *modelist);
static gint dynconfig_compare_modes (gconstpointer a, gconstpointer b);
GList *dynconfig_read_mode_list(int diag);
static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename);
void modedata_free (modedata_t *list_item);
static gint modedata_sort_cb(gconstpointer a, gconstpointer b);
static modedata_t *modedata_load (const gchar *filename);
/* ------------------------------------------------------------------------- *
* MODELIST
* ------------------------------------------------------------------------- */
void modelist_free(GList *modelist);
GList *modelist_load(int diag);
/* ========================================================================= *
* Functions
* ========================================================================= */
void dynconfig_free_list_item(mode_list_elem_t *list_item)
void modedata_free(modedata_t *list_item)
{
LOG_REGISTER_CONTEXT;
......@@ -78,36 +83,36 @@ void dynconfig_free_list_item(mode_list_elem_t *list_item)
}
}
void dynconfig_free_mode_list(GList *modelist)
void modelist_free(GList *modelist)
{
LOG_REGISTER_CONTEXT;
if(modelist)
{
g_list_foreach(modelist, (GFunc) dynconfig_free_list_item, NULL);
g_list_foreach(modelist, (GFunc) modedata_free, NULL);
g_list_free(modelist);
modelist = 0;
}
}
static gint dynconfig_compare_modes(gconstpointer a, gconstpointer b)
static gint modedata_sort_cb(gconstpointer a, gconstpointer b)
{
LOG_REGISTER_CONTEXT;
mode_list_elem_t *aa = (mode_list_elem_t *)a;
mode_list_elem_t *bb = (mode_list_elem_t *)b;
modedata_t *aa = (modedata_t *)a;
modedata_t *bb = (modedata_t *)b;
return g_strcmp0(aa->mode_name, bb->mode_name);
}
GList *dynconfig_read_mode_list(int diag)
GList *modelist_load(int diag)
{
LOG_REGISTER_CONTEXT;
GDir *confdir;
GList *modelist = NULL;
const gchar *dirname;
mode_list_elem_t *list_item;
modedata_t *list_item;
gchar *full_filename = NULL;
if(diag)
......@@ -123,7 +128,7 @@ GList *dynconfig_read_mode_list(int diag)
full_filename = g_strconcat(DIAG_DIR_PATH, "/", dirname, NULL);
else
full_filename = g_strconcat(MODE_DIR_PATH, "/", dirname, NULL);
list_item = dynconfig_read_mode_file(full_filename);
list_item = modedata_load(full_filename);
/* free full_filename immediately as we do not use it anymore */
free(full_filename);
if(list_item)
......@@ -134,17 +139,17 @@ GList *dynconfig_read_mode_list(int diag)
else
log_debug("Mode confdir open failed or file is incomplete/invalid.\n");
modelist = g_list_sort (modelist, dynconfig_compare_modes);
modelist = g_list_sort (modelist, modedata_sort_cb);
return modelist;
}
static mode_list_elem_t *dynconfig_read_mode_file(const gchar *filename)
static modedata_t *modedata_load(const gchar *filename)
{
LOG_REGISTER_CONTEXT;
bool success = false;
GKeyFile *settingsfile = g_key_file_new();
mode_list_elem_t *list_item = NULL;
modedata_t *list_item = NULL;
if( !g_key_file_load_from_file(settingsfile, filename, G_KEY_FILE_NONE, NULL) ) {
log_err("%s: can't read mode configuration file", filename);
......@@ -225,7 +230,7 @@ EXIT:
g_key_file_free(settingsfile);
if( !success )
dynconfig_free_list_item(list_item), list_item = 0;
modedata_free(list_item), list_item = 0;
return list_item;
}
......@@ -93,7 +93,7 @@
/**
* Struct keeping all the data needed for the definition of a dynamic mode
*/
typedef struct mode_list_elem_t
typedef struct modedata_t
{
char *mode_name; /**< Mode name */
char *mode_module; /**< Needed module for given mode */
......@@ -119,18 +119,23 @@ typedef struct mode_list_elem_t
# ifdef CONNMAN
char* connman_tethering; /**< Connman's tethering technology path */
# endif
} mode_list_elem_t;
} modedata_t;
/* ========================================================================= *
* Prototypes
* ========================================================================= */
/* ------------------------------------------------------------------------- *
* UTILITY
* MODEDATA
* ------------------------------------------------------------------------- */
void dynconfig_free_list_item(mode_list_elem_t *list_item);
void dynconfig_free_mode_list(GList *modelist);
GList *dynconfig_read_mode_list(int diag);
void modedata_free(modedata_t *list_item);
/* ------------------------------------------------------------------------- *
* MODELIST
* ------------------------------------------------------------------------- */
void modelist_free(GList *modelist);
GList *modelist_load(int diag);
#endif /* USB_MODED_DYN_CONFIG_H_ */
......@@ -79,8 +79,8 @@ bool modesetting_unmount (const char *mount
static gchar *modesetting_mountdev (const char *mountpoint);
static void modesetting_free_storage_info (storage_info_t *info);
static storage_info_t *modesetting_get_storage_info (size_t *pcount);
static bool modesetting_enter_mass_storage_mode (mode_list_elem_t *data);
static int modesetting_leave_mass_storage_mode (mode_list_elem_t *data);
static bool modesetting_enter_mass_storage_mode (modedata_t *data);
static int modesetting_leave_mass_storage_mode (modedata_t *data);
static void modesetting_report_mass_storage_blocker(const char *mountpoint, int try);
bool modesetting_enter_dynamic_mode (void);
void modesetting_leave_dynamic_mode (void);
......@@ -426,7 +426,7 @@ EXIT:
return *pcount = count, info;
}
static bool modesetting_enter_mass_storage_mode(mode_list_elem_t *data)
static bool modesetting_enter_mass_storage_mode(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -564,7 +564,7 @@ EXIT:
return ack;
}
static int modesetting_leave_mass_storage_mode(mode_list_elem_t *data)
static int modesetting_leave_mass_storage_mode(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -704,7 +704,7 @@ bool modesetting_enter_dynamic_mode(void)
bool ack = false;
mode_list_elem_t *data;
modedata_t *data;
log_debug("DYNAMIC MODE: SETUP");
......@@ -856,7 +856,7 @@ void modesetting_leave_dynamic_mode(void)
log_debug("DYNAMIC MODE: CLEANUP");
mode_list_elem_t *data;
modedata_t *data;
data = worker_get_usb_mode_data();
......
......@@ -79,14 +79,14 @@ typedef struct ipforward_data_t
static void network_free_ipforward_data (ipforward_data_t *ipforward);
static int network_check_interface (char *interface);
static char *network_get_interface (mode_list_elem_t *data);
static int network_set_usb_ip_forward (mode_list_elem_t *data, ipforward_data_t *ipforward);
static char *network_get_interface (modedata_t *data);
static int network_set_usb_ip_forward (modedata_t *data, ipforward_data_t *ipforward);
static void network_clean_usb_ip_forward(void);
static int network_checklink (void);
static int network_write_udhcpd_conf (ipforward_data_t *ipforward, mode_list_elem_t *data);
int network_set_up_dhcpd (mode_list_elem_t *data);
int network_up (mode_list_elem_t *data);
int network_down (mode_list_elem_t *data);
static int network_write_udhcpd_conf (ipforward_data_t *ipforward, modedata_t *data);
int network_set_up_dhcpd (modedata_t *data);
int network_up (modedata_t *data);
int network_down (modedata_t *data);
int network_update (void);
/* ------------------------------------------------------------------------- *
......@@ -157,7 +157,7 @@ static int network_check_interface(char *interface)
return ret;
}
static char* network_get_interface(mode_list_elem_t *data)
static char* network_get_interface(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -194,7 +194,7 @@ static char* network_get_interface(mode_list_elem_t *data)
* Turn on ip forwarding on the usb interface
* @return: 0 on success, 1 on failure
*/
static int network_set_usb_ip_forward(mode_list_elem_t *data, ipforward_data_t *ipforward)
static int network_set_usb_ip_forward(modedata_t *data, ipforward_data_t *ipforward)
{
LOG_REGISTER_CONTEXT;
......@@ -389,7 +389,7 @@ static int network_checklink(void)
* Write udhcpd.conf
* @ipforward : NULL if we want a simple config, otherwise include dns info etc...
*/
static int network_write_udhcpd_conf(ipforward_data_t *ipforward, mode_list_elem_t *data)
static int network_write_udhcpd_conf(ipforward_data_t *ipforward, modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -964,7 +964,7 @@ static int connman_reset_state(void)
/**
* Write out /etc/udhcpd.conf conf so the config is available when it gets started
*/
int network_set_up_dhcpd(mode_list_elem_t *data)
int network_set_up_dhcpd(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -1048,7 +1048,7 @@ static int append_variant(DBusMessageIter *iter, const char *property,
* Activate the network interface
*
*/
int network_up(mode_list_elem_t *data)
int network_up(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -1216,7 +1216,7 @@ int network_up(mode_list_elem_t *data)
* Deactivate the network interface
*
*/
int network_down(mode_list_elem_t *data)
int network_down(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -1295,7 +1295,7 @@ int network_update(void)
LOG_REGISTER_CONTEXT;
if( control_get_cable_state() == CABLE_STATE_PC_CONNECTED ) {
mode_list_elem_t *data = worker_get_usb_mode_data();
modedata_t *data = worker_get_usb_mode_data();
if( data && data->network ) {
network_down(data);
network_up(data);
......
......@@ -45,9 +45,9 @@ gboolean connman_set_tethering(const char *path, gboolean on);
* NETWORK
* ------------------------------------------------------------------------- */
int network_set_up_dhcpd(mode_list_elem_t *data);
int network_up (mode_list_elem_t *data);
int network_down (mode_list_elem_t *data);
int network_set_up_dhcpd(modedata_t *data);
int network_up (modedata_t *data);
int network_down (modedata_t *data);
int network_update (void);
#endif /* USB_MODED_NETWORK_H_ */
......@@ -60,8 +60,8 @@ static bool worker_switch_to_charging (void);
const char *worker_get_kernel_module (void);
bool worker_set_kernel_module (const char *module);
void worker_clear_kernel_module (void);
mode_list_elem_t *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (mode_list_elem_t *data);
modedata_t *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (modedata_t *data);
static const char *worker_get_activated_mode_locked(void);
static bool worker_set_activated_mode_locked(const char *mode);
static const char *worker_get_requested_mode_locked(void);
......@@ -391,26 +391,26 @@ void worker_clear_kernel_module(void)
* ------------------------------------------------------------------------- */
/** Contains the mode data */
static mode_list_elem_t *worker_mode_data = NULL;
static modedata_t *worker_mode_data = NULL;
/** get the usb mode data
*
* @return a pointer to the usb mode data
*
*/
mode_list_elem_t *worker_get_usb_mode_data(void)
modedata_t *worker_get_usb_mode_data(void)
{
LOG_REGISTER_CONTEXT;
return worker_mode_data;
}
/** set the mode_list_elem_t data
/** set the modedata_t data
*
* @param data mode_list_element pointer
*
*/
void worker_set_usb_mode_data(mode_list_elem_t *data)
void worker_set_usb_mode_data(modedata_t *data)
{
LOG_REGISTER_CONTEXT;
......@@ -588,7 +588,7 @@ worker_switch_to_mode(const char *mode)
/* go through all the dynamic modes if the modelist exists*/
for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{
mode_list_elem_t *data = iter->data;
modedata_t *data = iter->data;
if( strcmp(mode, data->mode_name) )
continue;
......
......@@ -40,17 +40,17 @@
* WORKER
* ------------------------------------------------------------------------- */
bool worker_bailing_out (void);
const char *worker_get_kernel_module (void);
bool worker_set_kernel_module (const char *module);
void worker_clear_kernel_module (void);
mode_list_elem_t *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (mode_list_elem_t *data);
void worker_request_hardware_mode(const char *mode);
void worker_clear_hardware_mode (void);
void worker_switch_to_mode (const char *mode);
bool worker_init (void);
void worker_quit (void);
void worker_wakeup (void);
bool worker_bailing_out (void);
const char *worker_get_kernel_module (void);
bool worker_set_kernel_module (const char *module);
void worker_clear_kernel_module (void);
modedata_t *worker_get_usb_mode_data (void);
void worker_set_usb_mode_data (modedata_t *data);
void worker_request_hardware_mode(const char *mode);
void worker_clear_hardware_mode (void);
void worker_switch_to_mode (const char *mode);
bool worker_init (void);
void worker_quit (void);
void worker_wakeup (void);
#endif /* USB_MODED_WORKER_H_ */
......@@ -173,7 +173,7 @@ usbmoded_load_modelist(void)
if( !usbmoded_modelist ) {
log_notice("load modelist");
usbmoded_modelist = dynconfig_read_mode_list(usbmoded_get_diag_mode());
usbmoded_modelist = modelist_load(usbmoded_get_diag_mode());
}
}
......@@ -184,7 +184,7 @@ usbmoded_free_modelist(void)
if( usbmoded_modelist ) {
log_notice("free modelist");
dynconfig_free_mode_list(usbmoded_modelist),
modelist_free(usbmoded_modelist),
usbmoded_modelist = 0;
}
}
......
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