Navigation Menu

Skip to content

Commit

Permalink
Remove sync mode, fix modelist construction, prepping for usb_moded_next
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed May 27, 2013
1 parent 20e7878 commit 69180d8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 52 deletions.
8 changes: 0 additions & 8 deletions configure.ac
Expand Up @@ -78,14 +78,6 @@ AC_ARG_ENABLE([app_sync], AS_HELP_STRING([--enable-app-sync], [Enable applicatio
esac],[app_sync=false])
AM_CONDITIONAL([APP_SYNC], [test x$app_sync = xtrue])

AC_ARG_ENABLE([dynamic_modes], AS_HELP_STRING([--enable-dynamic-modes], [Enable adding modes with ini files @<:@default=false@:>@]),
[case "${enableval}" in
yes) dynamic_modes=true ; CFLAGS="-DDYN_MODE $CFLAGS" ;;
no) dynamic_modes=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-dynamic-modes]) ;;
esac],[dynamic_modes=false])
AM_CONDITIONAL([DYN_MODE], [test x$dynamic_modes = xtrue])

AC_ARG_ENABLE([hal], AS_HELP_STRING([--enable-hal], [Enable deprecated hal interface (use --disable-udev also) @<:@default=false@:>@]),
[case "${enableval}" in
yes) hal=true ; CFLAGS="-DHAL -I/usr/include/hal -lhal $CFLAGS" ;;
Expand Down
10 changes: 3 additions & 7 deletions src/Makefile.am
Expand Up @@ -29,7 +29,9 @@ usb_moded_SOURCES = \
usb_moded-modesetting.c \
usb_moded-modesetting.h \
usb_moded-mac.c \
usb_moded-mac.h
usb_moded-mac.h \
usb_moded-dyn-config.c \
usb_moded-dyn-config.h

if !ANDROID
usb_moded_SOURCES += \
Expand Down Expand Up @@ -82,12 +84,6 @@ usb_moded_SOURCES += \
usb_moded-upstart.c
endif

if DYN_MODE
usb_moded_SOURCES += \
usb_moded-dyn-config.c \
usb_moded-dyn-config.h
endif

usb_moded_util_CPPFLAGS = \
$(USB_MODED_CFLAGS)

Expand Down
6 changes: 4 additions & 2 deletions src/usb_moded-dbus.c
Expand Up @@ -158,13 +158,15 @@ 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_INVALID);
free((void *)config);
}
else if(!strcmp(member, USB_MODE_LIST))
{
const char *mode_list = get_mode_list();
gchar *mode_list = get_mode_list();

if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &mode_list, DBUS_TYPE_INVALID);
dbus_message_append_args (reply, DBUS_TYPE_STRING, (const char *) &mode_list, DBUS_TYPE_INVALID);
g_free(mode_list);
}
else if(!strcmp(member, USB_MODE_RESCUE_OFF))
{
Expand Down
4 changes: 3 additions & 1 deletion src/usb_moded-modes.h
Expand Up @@ -30,4 +30,6 @@
#define MODE_MTP "mtp_mode"
#define MODE_CHARGER "dedicated_charger"

char *get_mode_list(void);
/* due to the use of the modelist these functions are defined in usb_moded.c */
gchar *get_mode_list(void);
int valid_mode(const char *mode);
7 changes: 4 additions & 3 deletions src/usb_moded-modesetting.c
Expand Up @@ -280,15 +280,17 @@ int set_ovi_suite_mode(void)
#endif /* N900 */
#endif /* ANDROID */

#ifdef DYN_MODE
int set_dynamic_mode(struct mode_list_elem *data)
{
char command[256];
#ifdef APP_SYNC
if(data->appsync)
activate_sync(data->mode_name);
#endif
if(data->network)
{
#ifdef DEBIAN
char command[256];

g_snprintf(command, 256, "ifdown %s ; ifup %s", data->network_interface, data->network_interface);
system(command);
#else
Expand All @@ -299,7 +301,6 @@ int set_dynamic_mode(struct mode_list_elem *data)

return(0);
}
#endif /* DYN_MODE */

#ifdef NOKIA
gboolean export_cdrom(gpointer data)
Expand Down
40 changes: 10 additions & 30 deletions src/usb_moded.c
Expand Up @@ -68,9 +68,7 @@ guint charging_timeout = 0;
gboolean special_mode = FALSE;
guint timeout_source = 0;
#endif /* NOKIA */
#ifdef DYN_SYNC
static GList *modelist;
#endif /* DYN_SYNC */

/* static helper functions */
static gboolean set_disconnected(gpointer data);
Expand Down Expand Up @@ -252,18 +250,7 @@ void set_usb_mode(const char *mode)
/* set return to 1 to be sure to error out if no matching mode is found either */
int ret=1, net=0;

if(!strcmp(mode, MODE_MASS_STORAGE))
{

check_module_state(MODULE_MASS_STORAGE);
/* now proceed to set the mode correctly */
set_usb_module(MODULE_MASS_STORAGE);
ret = usb_moded_load_module(MODULE_MASS_STORAGE);
if(!ret)
ret = set_mass_storage_mode();
goto end;
}
else if(!strcmp(mode, MODE_CHARGING))
if(!strcmp(mode, MODE_CHARGING))
{
check_module_state(MODULE_MASS_STORAGE);
/* for charging we use a fake file_storage (blame USB certification for this insanity */
Expand All @@ -272,6 +259,7 @@ void set_usb_mode(const char *mode)
ret = usb_moded_load_module(MODULE_CHARGING);
goto end;
}
<<<<<<< HEAD
else if(!strcmp(mode, MODE_DEVELOPER))
{
check_module_state(MODULE_DEVELOPER);
Expand Down Expand Up @@ -307,7 +295,6 @@ else if(!strcmp(mode, MODE_DEVELOPER))
ret = 0;
}

#ifdef DYN_MODE
/* go through all the dynamic modes if the modelist exists*/
if(modelist)
{
Expand All @@ -325,7 +312,6 @@ else if(!strcmp(mode, MODE_DEVELOPER))
}
}
}
#endif /* DYN_MODE */

end:
/* if ret != 0 then usb_module loading failed */
Expand Down Expand Up @@ -354,7 +340,6 @@ int valid_mode(const char *mode)
!strcmp(MODE_DEVELOPER,mode) || !strcmp(MODE_MTP,mode))
return(0);
else
#ifdef DYN_MODE
{
/* check dynamic modes */
if(modelist)
Expand All @@ -369,7 +354,6 @@ int valid_mode(const char *mode)
}
}
}
#endif /* DYN_MODE */
return(1);

}
Expand All @@ -379,17 +363,18 @@ int valid_mode(const char *mode)
* @return a comma-separated list of modes (MODE_ASK not included as it is not a real mode)
*
*/
char *get_mode_list(void)
gchar *get_mode_list(void)
{

char *modelist;
GString *modelist_str;

modelist_str = g_string_new(NULL);

#ifdef N900
asprintf(&modelist, "%s, %s, %s, %s, %s", MODE_MASS_STORAGE, MODE_OVI_SUITE, MODE_CHARGING, MODE_DEVELOPER, MODE_MTP);
asprintf(&modelist_str->str, "%s, %s, %s, %s, %s", MODE_MASS_STORAGE, MODE_OVI_SUITE, MODE_CHARGING, MODE_DEVELOPER, MODE_MTP);
#else
asprintf(&modelist, "%s, %s, %s, %s", MODE_MASS_STORAGE, MODE_CHARGING, MODE_DEVELOPER, MODE_MTP);
asprintf(&modelist_str->str, "%s, %s, %s, %s", MODE_MASS_STORAGE, MODE_CHARGING, MODE_DEVELOPER, MODE_MTP);
#endif /* N900 */
#ifdef DYN_MODE
{
/* check dynamic modes */
if(modelist)
Expand All @@ -399,14 +384,11 @@ char *get_mode_list(void)
for( iter = modelist; iter; iter = g_list_next(iter) )
{
struct mode_list_elem *data = iter->data;
/* TODO : concat correctly the mode names
strconcat(modelist, data->mode_name);
*/
modelist_str = g_string_append(modelist_str, data->mode_name);
}
}
}
#endif /* DYN_MODE */
return modelist;
return(g_string_free(modelist_str, FALSE));
}

/** get the usb mode
Expand Down Expand Up @@ -500,9 +482,7 @@ static void usb_moded_init(void)
#ifdef APP_SYNC
readlist();
#endif /* APP_SYNC */
#ifdef DYN_MODE
modelist = read_mode_list();
#endif /* DYN_MODE */

#ifdef UDEV
if(check_trigger())
Expand Down
1 change: 0 additions & 1 deletion src/usb_moded.h
Expand Up @@ -54,7 +54,6 @@ typedef struct usb_mode
void set_usb_connected(gboolean connected);
void set_usb_connected_state(void);
void set_usb_mode(const char *mode);
int valid_mode(const char *mode);
const char * get_usb_mode(void);
void set_usb_module(const char *module);
const char * get_usb_module(void);
Expand Down

0 comments on commit 69180d8

Please sign in to comment.