Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Improved udev support with configurable udev path
* Fix some configure.ac bugs
Signed-off-by: Philippe De Swert <phdeswer@lumi.maa>
  • Loading branch information
Philippe De Swert committed Apr 7, 2011
1 parent 4784aa4 commit 57e9dc2
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 9 deletions.
14 changes: 11 additions & 3 deletions configure.ac
Expand Up @@ -51,6 +51,14 @@ AC_ARG_ENABLE([nokia], AS_HELP_STRING([--enable-nokia], [Enable Nokia extra's @<
esac],[nokia=false])
AM_CONDITIONAL([NOKIA], [test x$nokia = xtrue])

AC_ARG_ENABLE([bme], AS_HELP_STRING([--enable-bme], [Enable Nokia bme cable connection interface @<:@default=false@:>@]),
[case "${enableval}" in
yes) bme=true ; CFLAGS="-DBME $CFLAGS" ;;
no) bme=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-bme]) ;;
esac],[bme=false])
AM_CONDITIONAL([BME], [test x$bme = xtrue])

AC_ARG_ENABLE([app_sync], AS_HELP_STRING([--enable-app-sync], [Enable application syncing @<:@default=false@:>@]),
[case "${enableval}" in
yes) app_sync=true ; CFLAGS="-DAPP_SYNC $CFLAGS" ;;
Expand All @@ -69,10 +77,10 @@ AM_CONDITIONAL([HAL], [test x$hal = xtrue])

AC_ARG_ENABLE([udev], AS_HELP_STRING([--enable-udev], [Enable udev interface @<:@default=true@:>@]),
[case "${enableval}" in
yes) hal=true ; CFLAGS="-DUDEV -ludev $CFLAGS" ;;
no) hal=false ;;
yes) udev=true ; CFLAGS="-DUDEV -ludev $CFLAGS" ;;
no) udev=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-udev]) ;;
esac],[hal=false])
esac],[udev=false])
AM_CONDITIONAL([UDEV], [test x$udev = xtrue])


Expand Down
4 changes: 3 additions & 1 deletion debian/changelog
@@ -1,7 +1,9 @@
usb-moded (0.34) unstable; urgency=low

* Delay unloading a bit more (5s instead of 3). Fixes: NB#225492
* Delay unloading a bit more (8s instead of 3). Fixes: NB#225492
* Fixes for USB autoplay. Fixes: NB#220474
* Added cdrom emulation support.
* Added udev option for cable detection

-- Philippe De Swert <philippe.de-swert@nokia.com> Fri, 01 Apr 2011 13:22:51 +0300

Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Expand Up @@ -23,7 +23,7 @@ configure-stamp:
dh_testdir
# Add here commands to configure the package.
if [ ! -x configure ]; then ./autogen.sh; fi
./configure --prefix=/usr --enable-nokia --enable-app-sync
./configure --prefix=/usr --enable-nokia --enable-app-sync --enable-bme

touch configure-stamp

Expand Down
8 changes: 6 additions & 2 deletions src/Makefile.am
Expand Up @@ -31,10 +31,14 @@ usb_moded_SOURCES = \
if HAL
usb_moded_SOURCES += \
usb_moded-hal.c
else if NOKIA
endif

if BME
usb_moded_SOURCES += \
usb_moded-chargerdetection.c
else
endif

if UDEV
usb_moded_SOURCES += \
usb_moded-udev.c
endif
Expand Down
35 changes: 35 additions & 0 deletions src/usb_moded-config.c
Expand Up @@ -127,6 +127,41 @@ const char * find_alt_mount(void)
return(ret);
}

#ifdef UDEV
const char * find_udev_path(void)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
const char *ret = NULL, *tmp_char;

settingsfile = g_key_file_new();
test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL);
if(!test)
{
log_debug("No cdrom path.\n");
g_key_file_free(settingsfile);
return(ret);
}
keys = g_key_file_get_keys (settingsfile, UDEV_PATH_ENTRY, NULL, NULL);
while (*keys != NULL)
{
if(!strcmp(*keys, UDEV_PATH_KEY))
{
tmp_char = g_key_file_get_string(settingsfile, UDEV_PATH_ENTRY, *keys, NULL);
if(tmp_char)
{
log_debug("cdrom key value = %s\n", tmp_char);
ret = g_strdup(tmp_char);
}
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
}
#endif /* UDEV */

#ifdef NOKIA
const char * find_cdrom_path(void)
{
Expand Down
6 changes: 6 additions & 0 deletions src/usb_moded-config.h
Expand Up @@ -29,12 +29,18 @@
#define FS_SYNC_KEY "nofua"
#define ALT_MOUNT_ENTRY "altmount"
#define ALT_MOUNT_KEY "mount"
#define UDEV_PATH_ENTRY "udev"
#define UDEV_PATH_KEY "path"
#define CDROM_PATH_ENTRY "cdrom"
#define CDROM_PATH_KEY "path"

const char * find_mounts(void);
int find_sync(void);
const char * find_alt_mount(void);
#ifdef UDEV
const char * find_udev_path(void);
#endif

#ifdef NOKIA
const char * find_cdrom_path(void);
#endif
7 changes: 7 additions & 0 deletions src/usb_moded-udev.c
Expand Up @@ -10,6 +10,7 @@
#include <glib.h>

#include "usb_moded-log.h"
#include "usb_moded-config.h"
#include "usb_moded-hw-ab.h"
#include "usb_moded.h"

Expand All @@ -24,6 +25,7 @@ gpointer monitor_udev(gpointer data) __attribute__ ((noreturn));
gboolean hwal_init(void)
{
GThread * thread;
const gchar *udev_path;

/* Create the udev object */
udev = udev_new();
Expand All @@ -32,6 +34,11 @@ gboolean hwal_init(void)
log_err("Can't create udev\n");
return 0;
}

udev_path = find_udev_path();
if(udev_path)
dev = udev_device_new_from_syspath(udev, udev_path);
else
dev = udev_device_new_from_syspath(udev, "/sys/class/power_supply/usb");
if (!dev)
{
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded.c
Expand Up @@ -116,7 +116,7 @@ void set_usb_connected(gboolean connected)
usb_moded_mode_cleanup(get_usb_module());
usb_moded_send_signal(USB_DISCONNECTED);
#ifdef NOKIA
timeout_source = g_timeout_add_seconds(5, usb_module_timeout_cleanup, NULL);
timeout_source = g_timeout_add_seconds(8, usb_module_timeout_cleanup, NULL);
#else
/* unload modules and general cleanup */
usb_moded_module_cleanup(get_usb_module());
Expand Down
2 changes: 1 addition & 1 deletion usb_moded.pc.in
Expand Up @@ -5,6 +5,6 @@ libdir=${prefix}/lib
Name: usb_moded
Description: usb_moded defines for dbus and mode names
Version: @VERSION@
Requires:
Requires: dbus-1
Libs:
Cflags: -I${includedir}

0 comments on commit 57e9dc2

Please sign in to comment.