Skip to content

Commit

Permalink
[usb-moded] Report dynamic mode setting failure
Browse files Browse the repository at this point in the history
Make sure failures for setting modes are reported to UI layers.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Jan 27, 2014
1 parent 8144269 commit ec8860f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/usb_moded-dbus.h
Expand Up @@ -52,6 +52,7 @@
#define RE_MOUNT_FAILED "mount_failed"
#define CHARGER_CONNECTED "charger_connected"
#define CHARGER_DISCONNECTED "charger_disconnected"
#define MODE_SETTING_FAILED "mode_setting_failed"

/* errors */
#define UMOUNT_ERROR "Unmounting filesystem failed. Exporting impossible"
Expand Down
11 changes: 7 additions & 4 deletions src/usb_moded-modesetting.c
Expand Up @@ -376,11 +376,12 @@ int set_dynamic_mode(void)
{

struct mode_list_elem *data;
int ret = 1;

data = get_usb_mode_data();

if(!data)
return 1;
return(ret);

if(data->mass_storage)
{
Expand All @@ -392,7 +393,7 @@ int set_dynamic_mode(void)
if(activate_sync(data->mode_name)) /* returns 1 on error */
{
log_debug("Appsync failure");
return(1);
return(ret);
}
#endif
/* make sure things are disabled before changing functionality */
Expand Down Expand Up @@ -442,12 +443,14 @@ int set_dynamic_mode(void)
/* Needs to be called before application post synching so
that the dhcp server has the right config */
if(data->nat || data->dhcp_server)
usb_network_set_up_dhcpd(data);
ret = usb_network_set_up_dhcpd(data);

if(data->appsync)
activate_sync_post(data->mode_name);

return(0);
if(ret)
usb_moded_send_error_signal(MODE_SETTING_FAILED);
return(ret);
}

void unset_dynamic_mode(void)
Expand Down
4 changes: 3 additions & 1 deletion src/usb_moded-network.c
Expand Up @@ -447,6 +447,7 @@ static int connman_get_connection_data(struct ipforward_data *ipforward)
int usb_network_set_up_dhcpd(struct mode_list_elem *data)
{
struct ipforward_data *ipforward = NULL;
int ret = 1;

/* Set up nat info only if it is required */
if(data->nat)
Expand All @@ -469,12 +470,13 @@ int usb_network_set_up_dhcpd(struct mode_list_elem *data)

if(data->nat)
set_usb_ip_forward(data, ipforward);
ret = 0;


end:
/* the function checks if ipforward is NULL or not */
free_ipforward_data(ipforward);
return(0);
return(ret);
}

/**
Expand Down

0 comments on commit ec8860f

Please sign in to comment.