Skip to content

Commit

Permalink
Save network settings if they are defined in the main ini, update
Browse files Browse the repository at this point in the history
the documentation related to networking configuration.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Oct 9, 2013
1 parent cf0f4ef commit 96947ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/usb_moded-doc.txt
Expand Up @@ -100,7 +100,9 @@ The other settings and config dirs will be handled later in the appsync and dyna
(This is optional and can be compiled out)

There is also an optional network configuration. The default ip set for usb networking is 192.168.2.15
(for Meego/Nemo). However this can be configured by hand in the ini file also.
(for Meego/Nemo). However this can be configured by hand in the ini file also (optionally in a separate
ini file which is possible due to config file merging).

For example:

[network]
Expand Down
18 changes: 17 additions & 1 deletion src/usb_moded-config.c
Expand Up @@ -423,7 +423,7 @@ int conf_file_merge(void)
{
GDir *confdir;
struct stat fileinfo, dir;
const gchar *filename, *mode = 0;
const gchar *filename, *mode = 0, *ip = 0, *gateway = 0;
gchar *filename_full;
GString *keyfile_string = NULL;
GKeyFile *settingsfile;
Expand Down Expand Up @@ -482,6 +482,8 @@ int conf_file_merge(void)
/* store udev path (especially important for the upgrade path */
udev = find_udev_path();
#endif /* UDEV */
ip = get_conf_string(NETWORK_ENTRY, NETWORK_IP_KEY);
gateway = get_conf_string(NETWORK_ENTRY, NETWORK_GATEWAY_KEY);
continue;
}
/* load contents of file, if it fails skip to next one */
Expand Down Expand Up @@ -516,16 +518,30 @@ int conf_file_merge(void)
{
set_config_setting(UDEV_PATH_ENTRY, UDEV_PATH_KEY, udev);
}
/* check if no network data came from an ini file */
if( get_conf_string(NETWORK_ENTRY, NETWORK_IP_KEY))
goto cleanup;
if(ip)
set_network_setting(ip, NETWORK_IP_KEY);
if(gateway)
set_network_setting(gateway, NETWORK_GATEWAY_KEY);

#endif /* UDEV */
}
else
ret = 1;
cleanup:
if(mode)
free((void *)mode);
#ifdef UDEV
if(udev)
free((void *)udev);
#endif /* UDEV */
if(ip)
free((void *)ip);
if(gateway)
free((void *)gateway);

end:
g_dir_close(confdir);
return(ret);
Expand Down

0 comments on commit 96947ff

Please sign in to comment.