Commit 5feb37d8 authored by Philippe De Swert's avatar Philippe De Swert

Add dbus method to query network settings.

Signed-off-by: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent e4afe4c2
......@@ -16,9 +16,15 @@
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="set_config"/>
<deny own="com.meego.usb_moded"/>
<allow send_destination="com.meego.usb_moded"
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="get_modes"/>
<deny own="com.meego.usb_moded"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="net_config"/>
<deny own="com.meego.usb_moded"/>
<allow send_destination="com.meego.usb_moded"
send_interface="com.meego.usb_moded" send_member="get_net_config"/>
<deny own="com.meego.usb_moded"/>
</policy>
</busconfig>
......@@ -18,7 +18,7 @@
02110-1301 USA
*/
/*
* Gets information from Gconf/ini file for the usb modes
* Gets/sets information for the usb modes from dbus
*/
/*============================================================================= */
......@@ -26,3 +26,4 @@
const char * get_mode_setting(void);
int set_mode_setting(const char *mode);
int set_network_setting(const char *config, const char *setting);
const char *get_network_setting(const char *config);
......@@ -383,6 +383,31 @@ int set_network_setting(const char *config, const char *setting)
return(!ret);
}
const char * get_network_setting(const char *config)
{
const char * ret = 0;
if(!strcmp(config, NETWORK_IP_KEY))
{
ret = get_network_ip();
if(!ret)
ret = strdup("192.168.2.15");
}
else if(!strcmp(config, NETWORK_INTERFACE_KEY))
{
ret = get_network_interface();
if(!ret)
ret = strdup("usb0");
}
else if(!strcmp(config, NETWORK_GATEWAY_KEY))
return(get_network_gateway());
else
/* no matching keys, return error */
return(NULL);
return(ret);
}
int conf_file_merge(void)
{
GDir *confdir;
......
......@@ -137,7 +137,7 @@ error_reply:
reply = dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, member);
else
{
/* error checking is done when setting the GConf key */
/* error checking is done when setting configuration */
if(!set_network_setting(config, setting))
{
if((reply = dbus_message_new_method_return(msg)))
......@@ -148,6 +148,29 @@ error_reply:
}
dbus_error_free(&err);
}
else if(!strcmp(member, USB_MODE_NETWORK_GET))
{
char *config = 0;
const char *setting = 0;
DBusError err = DBUS_ERROR_INIT;
if(!dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &config, DBUS_TYPE_INVALID))
{
reply = dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, member);
}
else
{
setting = get_network_setting(config);
if(setting)
{
if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &config, DBUS_TYPE_STRING, &setting, DBUS_TYPE_INVALID);
free((void *)setting);
}
else
reply = dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, config);
}
}
else if(!strcmp(member, USB_MODE_CONFIG_GET))
{
const char *config = get_mode_setting();
......
......@@ -40,6 +40,7 @@
#define USB_MODE_STATE_SET "set_mode" /* set a mode (only works when connected) */
#define USB_MODE_CONFIG_SET "set_config" /* set the mode that needs to be activated in the config file */
#define USB_MODE_NETWORK_SET "net_config" /* set the network config in the config file */
#define USB_MODE_NETWORK_GET "get_net_config" /* get the network config from the config file */
/* state definitions for signals and method parameters */
#define USB_CONNECTED "USB connected"
......
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