Commit 2554770f authored by Philippe De Swert's avatar Philippe De Swert

* Do not check for default gateway anymore. Network config

  has been fixed. Fixes: NB#246401
* Echo "" to the lun to disable  mass-storage exports instead of 0
* Some code clean-up
* Stop using a thread for udev to avoid thread-locking in dbus.  Patch by Simon McVittie.
Signed-off-by: default avatarPhilippe De Swert <phdeswer@lumi.maa>
parent cf696486
AC_INIT([usb_moded], [0.35])
AC_INIT([usb_moded], [0.36])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_CONFIG_HEADER([config.h])
......
usb-moded (0.36) unstable; urgency=low
* Do not check for default gateway anymore. Network config
has been fixed. Fixes: NB#246401
* Echo "" to the lun to disable mass-storage exports instead of 0
-- Philippe De Swert <philippe.de-swert@nokia.com> Tue, 19 Apr 2011 15:04:43 +0300
usb-moded (0.35) unstable; urgency=low
* Some code clean-up
* Stop using a thread for udev to avoid thread-locking in dbus.
Patch by Simon McVittie. Fixes: NB#247014
* Have g_nokia support for N900 on Meego
* Increase mass-storage file export timeout to make sure autoplay keeps working
on Windows(tm)
-- Philippe De Swert <philippe.de-swert@nokia.com> Fri, 15 Apr 2011 16:30:08 +0300
-- Philippe De Swert <philippe.de-swert@nokia.com> Tue, 19 Apr 2011 12:29:58 +0300
usb-moded (0.34) unstable; urgency=low
......
......@@ -32,9 +32,6 @@
#include "usb_moded-appsync-dbus.h"
#include "usb_moded-appsync-dbus-private.h"
#include "usb_moded-log.h"
#ifdef NOKIA
#include "usb_moded-modesetting.h"
#endif
static struct list_elem *read_file(const gchar *filename);
......
......@@ -31,209 +31,118 @@
#include "usb_moded-config.h"
#include "usb_moded-log.h"
static int get_conf_int(const gchar *entry, const gchar *key);
static const char * get_conf_string(const gchar *entry, const gchar *key);
const char *find_mounts(void)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
const char *ret = NULL, *tmp_char;
const char *ret = NULL;
settingsfile = g_key_file_new();
test = g_key_file_load_from_file(settingsfile, FS_MOUNT_CONFIG_FILE, G_KEY_FILE_NONE, NULL);
if(!test)
ret = get_conf_string(FS_MOUNT_ENTRY, FS_MOUNT_KEY);
if(ret == NULL)
{
ret = g_strdup(FS_MOUNT_DEFAULT);
log_debug("Module parameter string = %s\n", ret);
g_key_file_free(settingsfile);
return(ret);
log_debug("Default mount = %s\n", ret);
}
keys = g_key_file_get_keys (settingsfile, FS_MOUNT_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, FS_MOUNT_KEY))
{
tmp_char = g_key_file_get_string(settingsfile, FS_MOUNT_ENTRY, *keys, NULL);
if(tmp_char)
{
ret = g_strdup(tmp_char);
log_debug("Module parameter string = %s\n", ret);
}
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
}
int find_sync(void)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
int ret = 0;
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("Sync is default = %d\n", ret);
g_key_file_free(settingsfile);
return(ret);
}
keys = g_key_file_get_keys (settingsfile, FS_SYNC_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, FS_SYNC_KEY))
{
ret = g_key_file_get_integer(settingsfile, FS_SYNC_ENTRY, *keys, NULL);
log_debug("key value = %d\n", ret);
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
return(get_conf_int(FS_SYNC_ENTRY, FS_SYNC_KEY));
}
const char * find_alt_mount(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("Keyfile unavailable no fallback mount.");
g_key_file_free(settingsfile);
return(ret);
}
keys = g_key_file_get_keys (settingsfile, ALT_MOUNT_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, ALT_MOUNT_KEY))
{
tmp_char = g_key_file_get_string(settingsfile, ALT_MOUNT_ENTRY, *keys, NULL);
if(tmp_char)
{
ret = g_strdup(tmp_char);
log_debug("Alternate mount = %s\n", ret);
}
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
return(get_conf_string(ALT_MOUNT_ENTRY, ALT_MOUNT_KEY));
}
#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 udev path.\n");
g_key_file_free(settingsfile);
return(ret);
}
keys = g_key_file_get_keys (settingsfile, UDEV_PATH_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
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("udev path value = %s\n", tmp_char);
ret = g_strdup(tmp_char);
}
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
return(get_conf_string(UDEV_PATH_ENTRY, UDEV_PATH_KEY));
}
#endif /* UDEV */
#ifdef NOKIA
const char * find_cdrom_path(void)
{
return(get_conf_string(CDROM_ENTRY, CDROM_PATH_KEY));
}
int find_cdrom_timeout(void)
{
return(get_conf_int(CDROM_ENTRY, CDROM_TIMEOUT_KEY));
}
#endif /* NOKIA */
static int get_conf_int(const gchar *entry, const gchar *key)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
const char *ret = NULL, *tmp_char;
int ret = 0;
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");
log_debug("no conffile\n");
g_key_file_free(settingsfile);
return(ret);
}
keys = g_key_file_get_keys (settingsfile, CDROM_ENTRY, NULL, NULL);
keys = g_key_file_get_keys (settingsfile, entry, NULL, NULL);
if(keys == NULL)
return ret;
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, CDROM_PATH_KEY))
{
tmp_char = g_key_file_get_string(settingsfile, CDROM_ENTRY, *keys, NULL);
if(tmp_char)
{
log_debug("cdrom key value = %s\n", tmp_char);
ret = g_strdup(tmp_char);
}
}
keys++;
if(!strcmp(*keys, key))
{
ret = g_key_file_get_integer(settingsfile, entry, *keys, NULL);
log_debug("%s key value = %d\n", key, ret);
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
}
int find_cdrom_timeout(void)
static const char * get_conf_string(const gchar *entry, const gchar *key)
{
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
int ret = 0;
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 conffile\n");
log_debug("No conffile.\n");
g_key_file_free(settingsfile);
return(ret);
}
keys = g_key_file_get_keys (settingsfile, CDROM_ENTRY, NULL, NULL);
keys = g_key_file_get_keys (settingsfile, entry, NULL, NULL);
if(keys == NULL)
return ret;
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, CDROM_TIMEOUT_KEY))
{
ret = g_key_file_get_integer(settingsfile, CDROM_ENTRY, *keys, NULL);
log_debug("key value = %d\n", ret);
}
keys++;
if(!strcmp(*keys, key))
{
tmp_char = g_key_file_get_string(settingsfile, entry, *keys, NULL);
if(tmp_char)
{
log_debug("key %s value = %s\n", key, tmp_char);
ret = g_strdup(tmp_char);
}
}
keys++;
}
g_key_file_free(settingsfile);
return(ret);
}
#endif /* NOKIA */
......@@ -201,6 +201,8 @@ gboolean usb_moded_dbus_init(void)
dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error);
*/
dbus_threads_init_default();
/* Connect D-Bus to the mainloop */
dbus_connection_setup_with_g_main(dbus_connection_sys, NULL);
......
......@@ -155,7 +155,6 @@ umount: command = g_strconcat("mount | grep ", mounts[i], NULL);
#ifdef N900
int set_ovi_suite_mode(GList *applist)
{
int net = 0;
#ifdef NOKIA
int timeout = 1;
#endif /* NOKIA */
......@@ -171,9 +170,7 @@ int set_ovi_suite_mode(GList *applist)
system("echo 1 > /sys/devices/platform/musb_hdrc/gadget/softconnect");
#endif /* APP_SYNC */
/* bring network interface up in case no other network is up */
net = system("route | grep default");
if(net)
net = system("ifdown usb0 ; ifup usb0");
system("ifdown usb0 ; ifup usb0");
#ifdef NOKIA
/* timeout for exporting CDROM image */
......@@ -199,7 +196,7 @@ gboolean export_cdrom(gpointer data)
}
if(access(path, F_OK) == 0)
{
command = g_strconcat("echo ", path, " > /sys/devices/platform/musb_hdrc/gadget/gadget-lun%d/file", NULL);
command = g_strconcat("echo ", path, " > /sys/devices/platform/musb_hdrc/gadget/gadget-lun0/file", NULL);
system(command);
}
else
......@@ -264,7 +261,7 @@ int usb_moded_mode_cleanup(const char *module)
}
}
sprintf(command2, "echo 0 > /sys/devices/platform/musb_hdrc/gadget/gadget-lun%d/file", i);
sprintf(command2, "echo "" > /sys/devices/platform/musb_hdrc/gadget/gadget-lun%d/file", i);
log_debug("usb lun = %s inactive\n", command2);
system(command2);
}
......
......@@ -15,18 +15,20 @@
#include "usb_moded.h"
/* global variables */
struct udev *udev;
struct udev_monitor *mon;
struct udev_device *dev;
static struct udev *udev;
static struct udev_monitor *mon;
static GIOChannel *iochannel;
static guint watch_id;
/* static function definitions */
gpointer monitor_udev(gpointer data) __attribute__ ((noreturn));
static gboolean monitor_udev(GIOChannel *iochannel G_GNUC_UNUSED, GIOCondition cond,
gpointer data G_GNUC_UNUSED);
static void udev_parse(struct udev_device *dev);
gboolean hwal_init(void)
{
GThread * thread;
const gchar *udev_path = NULL;
struct udev_device *dev;
/* Create the udev object */
udev = udev_new();
......@@ -58,21 +60,26 @@ gboolean hwal_init(void)
/* check if we are already connected */
udev_parse(dev);
thread = g_thread_create(monitor_udev, NULL, FALSE, NULL);
iochannel = g_io_channel_unix_new(udev_monitor_get_fd(mon));
/* default is UTF-8, set it to binary */
g_io_channel_set_encoding(iochannel, NULL, NULL);
/* set it to unbuffered, since we will be bypassing the GIOChannel for reads */
g_io_channel_set_buffered(iochannel, FALSE);
if(thread)
return 1;
else
{
log_debug("thread not created succesfully\n");
return 0;
}
watch_id = g_io_add_watch(iochannel, G_IO_IN, monitor_udev, NULL);
return TRUE;
}
gpointer monitor_udev(gpointer data)
static gboolean monitor_udev(GIOChannel *iochannel G_GNUC_UNUSED, GIOCondition cond,
gpointer data G_GNUC_UNUSED)
{
while(1)
struct udev_device *dev;
if(cond & G_IO_IN)
{
/* This normally blocks but G_IO_IN indicates that we can read */
dev = udev_monitor_receive_device (mon);
if (dev)
{
......@@ -82,10 +89,16 @@ gpointer monitor_udev(gpointer data)
}
}
}
/* keep watching */
return TRUE;
}
void hwal_cleanup(void)
{
g_source_remove(watch_id);
watch_id = 0;
g_io_channel_unref(iochannel);
iochannel = NULL;
udev_monitor_unref(mon);
udev_unref(udev);
}
......
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