Commit 57e9dc29 authored by Philippe De Swert's avatar Philippe De Swert

* Improved udev support with configurable udev path

* Fix some configure.ac bugs
Signed-off-by: default avatarPhilippe De Swert <phdeswer@lumi.maa>
parent 4784aa47
...@@ -51,6 +51,14 @@ AC_ARG_ENABLE([nokia], AS_HELP_STRING([--enable-nokia], [Enable Nokia extra's @< ...@@ -51,6 +51,14 @@ AC_ARG_ENABLE([nokia], AS_HELP_STRING([--enable-nokia], [Enable Nokia extra's @<
esac],[nokia=false]) esac],[nokia=false])
AM_CONDITIONAL([NOKIA], [test x$nokia = xtrue]) 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@:>@]), AC_ARG_ENABLE([app_sync], AS_HELP_STRING([--enable-app-sync], [Enable application syncing @<:@default=false@:>@]),
[case "${enableval}" in [case "${enableval}" in
yes) app_sync=true ; CFLAGS="-DAPP_SYNC $CFLAGS" ;; yes) app_sync=true ; CFLAGS="-DAPP_SYNC $CFLAGS" ;;
...@@ -69,10 +77,10 @@ AM_CONDITIONAL([HAL], [test x$hal = xtrue]) ...@@ -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@:>@]), AC_ARG_ENABLE([udev], AS_HELP_STRING([--enable-udev], [Enable udev interface @<:@default=true@:>@]),
[case "${enableval}" in [case "${enableval}" in
yes) hal=true ; CFLAGS="-DUDEV -ludev $CFLAGS" ;; yes) udev=true ; CFLAGS="-DUDEV -ludev $CFLAGS" ;;
no) hal=false ;; no) udev=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-udev]) ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-udev]) ;;
esac],[hal=false]) esac],[udev=false])
AM_CONDITIONAL([UDEV], [test x$udev = xtrue]) AM_CONDITIONAL([UDEV], [test x$udev = xtrue])
......
usb-moded (0.34) unstable; urgency=low 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 * 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 -- Philippe De Swert <philippe.de-swert@nokia.com> Fri, 01 Apr 2011 13:22:51 +0300
......
...@@ -23,7 +23,7 @@ configure-stamp: ...@@ -23,7 +23,7 @@ configure-stamp:
dh_testdir dh_testdir
# Add here commands to configure the package. # Add here commands to configure the package.
if [ ! -x configure ]; then ./autogen.sh; fi 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 touch configure-stamp
......
...@@ -31,10 +31,14 @@ usb_moded_SOURCES = \ ...@@ -31,10 +31,14 @@ usb_moded_SOURCES = \
if HAL if HAL
usb_moded_SOURCES += \ usb_moded_SOURCES += \
usb_moded-hal.c usb_moded-hal.c
else if NOKIA endif
if BME
usb_moded_SOURCES += \ usb_moded_SOURCES += \
usb_moded-chargerdetection.c usb_moded-chargerdetection.c
else endif
if UDEV
usb_moded_SOURCES += \ usb_moded_SOURCES += \
usb_moded-udev.c usb_moded-udev.c
endif endif
......
...@@ -127,6 +127,41 @@ const char * find_alt_mount(void) ...@@ -127,6 +127,41 @@ const char * find_alt_mount(void)
return(ret); 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 #ifdef NOKIA
const char * find_cdrom_path(void) const char * find_cdrom_path(void)
{ {
......
...@@ -29,12 +29,18 @@ ...@@ -29,12 +29,18 @@
#define FS_SYNC_KEY "nofua" #define FS_SYNC_KEY "nofua"
#define ALT_MOUNT_ENTRY "altmount" #define ALT_MOUNT_ENTRY "altmount"
#define ALT_MOUNT_KEY "mount" #define ALT_MOUNT_KEY "mount"
#define UDEV_PATH_ENTRY "udev"
#define UDEV_PATH_KEY "path"
#define CDROM_PATH_ENTRY "cdrom" #define CDROM_PATH_ENTRY "cdrom"
#define CDROM_PATH_KEY "path" #define CDROM_PATH_KEY "path"
const char * find_mounts(void); const char * find_mounts(void);
int find_sync(void); int find_sync(void);
const char * find_alt_mount(void); const char * find_alt_mount(void);
#ifdef UDEV
const char * find_udev_path(void);
#endif
#ifdef NOKIA #ifdef NOKIA
const char * find_cdrom_path(void); const char * find_cdrom_path(void);
#endif #endif
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <glib.h> #include <glib.h>
#include "usb_moded-log.h" #include "usb_moded-log.h"
#include "usb_moded-config.h"
#include "usb_moded-hw-ab.h" #include "usb_moded-hw-ab.h"
#include "usb_moded.h" #include "usb_moded.h"
...@@ -24,6 +25,7 @@ gpointer monitor_udev(gpointer data) __attribute__ ((noreturn)); ...@@ -24,6 +25,7 @@ gpointer monitor_udev(gpointer data) __attribute__ ((noreturn));
gboolean hwal_init(void) gboolean hwal_init(void)
{ {
GThread * thread; GThread * thread;
const gchar *udev_path;
/* Create the udev object */ /* Create the udev object */
udev = udev_new(); udev = udev_new();
...@@ -32,7 +34,12 @@ gboolean hwal_init(void) ...@@ -32,7 +34,12 @@ gboolean hwal_init(void)
log_err("Can't create udev\n"); log_err("Can't create udev\n");
return 0; return 0;
} }
dev = udev_device_new_from_syspath(udev, "/sys/class/power_supply/usb");
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) if (!dev)
{ {
log_err("Unable to find /sys/class/power_supply/usb device."); log_err("Unable to find /sys/class/power_supply/usb device.");
......
...@@ -116,7 +116,7 @@ void set_usb_connected(gboolean connected) ...@@ -116,7 +116,7 @@ void set_usb_connected(gboolean connected)
usb_moded_mode_cleanup(get_usb_module()); usb_moded_mode_cleanup(get_usb_module());
usb_moded_send_signal(USB_DISCONNECTED); usb_moded_send_signal(USB_DISCONNECTED);
#ifdef NOKIA #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 #else
/* unload modules and general cleanup */ /* unload modules and general cleanup */
usb_moded_module_cleanup(get_usb_module()); usb_moded_module_cleanup(get_usb_module());
......
...@@ -5,6 +5,6 @@ libdir=${prefix}/lib ...@@ -5,6 +5,6 @@ libdir=${prefix}/lib
Name: usb_moded Name: usb_moded
Description: usb_moded defines for dbus and mode names Description: usb_moded defines for dbus and mode names
Version: @VERSION@ Version: @VERSION@
Requires: Requires: dbus-1
Libs: Libs:
Cflags: -I${includedir} Cflags: -I${includedir}
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