Skip to content

Commit

Permalink
[usb-moded] When network settings are updated, apply the configuratio…
Browse files Browse the repository at this point in the history
…n when connected.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Oct 24, 2013
1 parent ff249d1 commit eda2a3f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/usb_moded-dbus.c
Expand Up @@ -34,6 +34,7 @@
#include "usb_moded.h"
#include "usb_moded-modes.h"
#include "usb_moded-config-private.h"
#include "usb_moded-network.h"
#include "usb_moded-log.h"

static DBusConnection *dbus_connection_sys = NULL;
Expand Down Expand Up @@ -143,6 +144,7 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
{
if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &config, DBUS_TYPE_STRING, &setting, DBUS_TYPE_INVALID);
usb_network_update();
}
else
reply = dbus_message_new_error(msg, DBUS_ERROR_INVALID_ARGS, config);
Expand Down
24 changes: 24 additions & 0 deletions src/usb_moded-network.c
Expand Up @@ -30,6 +30,7 @@

#include <glib.h>

#include "usb_moded.h"
#include "usb_moded-network.h"
#include "usb_moded-config.h"
#include "usb_moded-log.h"
Expand Down Expand Up @@ -161,3 +162,26 @@ int usb_network_down(struct mode_list_elem *data)
return(0);
#endif /* CONNMAN */
}

/**
* Update the network interface with the new setting if connected.
*
*/
int usb_network_update(void)
{
struct mode_list_elem * data;

if(!get_usb_connection_state())
return(0);

data = get_usb_mode_data();
if(data->network)
{
usb_network_down(data);
usb_network_up(data);
return(0);
}
else
return(0);

}
1 change: 1 addition & 0 deletions src/usb_moded-network.h
Expand Up @@ -26,3 +26,4 @@

int usb_network_up(struct mode_list_elem *data);
int usb_network_down(struct mode_list_elem *data);
int usb_network_update(void);

0 comments on commit eda2a3f

Please sign in to comment.