[maemo-commits] [maemo-commits] r17506 - in projects/haf/trunk/ke-recv: debian src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Feb 24 16:41:52 EET 2009
Author: kihamala
Date: 2009-02-24 16:41:46 +0200 (Tue, 24 Feb 2009)
New Revision: 17506

Modified:
   projects/haf/trunk/ke-recv/debian/changelog
   projects/haf/trunk/ke-recv/src/ke-recv.c
   projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh
Log:
fixes for USB stuhv


Modified: projects/haf/trunk/ke-recv/debian/changelog
===================================================================
--- projects/haf/trunk/ke-recv/debian/changelog	2009-02-24 11:51:13 UTC (rev 17505)
+++ projects/haf/trunk/ke-recv/debian/changelog	2009-02-24 14:41:46 UTC (rev 17506)
@@ -20,6 +20,10 @@
   * Add max. retry limit to init_usb_cable_status(), give up after retrying 100
     times.
   * Remove automatically generated files from SVN.
+  * Fix problem with determining the UDI for USB cable, it was resorting to a
+    unusable default value.
+  * Handle "UNDEFINED" value for 'usb_device.mode' when switching modules and
+    the USB cable is connected.
 
  -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>  Tue, 24 Feb 2009 08:25:34 +0200
 

Modified: projects/haf/trunk/ke-recv/src/ke-recv.c
===================================================================
--- projects/haf/trunk/ke-recv/src/ke-recv.c	2009-02-24 11:51:13 UTC (rev 17505)
+++ projects/haf/trunk/ke-recv/src/ke-recv.c	2009-02-24 14:41:46 UTC (rev 17506)
@@ -3,7 +3,7 @@
 
   This file is part of ke-recv.
 
-  Copyright (C) 2004-2008 Nokia Corporation. All rights reserved.
+  Copyright (C) 2004-2009 Nokia Corporation. All rights reserved.
 
   Author: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>
 
@@ -36,8 +36,6 @@
 #define FDO_OBJECT_PATH "/org/freedesktop/Notifications"
 #define FDO_INTERFACE "org.freedesktop.Notifications"
 #define USB_DOMAIN "hildon-status-bar-usb"
-#define DEFAULT_USB_CABLE_UDI \
-        "/org/freedesktop/Hal/devices/usb_device_0_0_musb_hdrc"
 #define DESKTOP_SVC "com.nokia.hildon-desktop"
 
 #define FREMANTLE_MODE 1
@@ -100,6 +98,7 @@
 static int mount_usb_volumes(void);
 static storage_info_t *storage_from_list(const char *udi);
 static mmc_info_t *mmc_from_dev_name(const char *dev);
+static void get_usb_cable_udi();
 
 static void set_usb_mode_key(const char *mode)
 {
@@ -1639,6 +1638,10 @@
         } else if (strcmp(prop, "b_idle") == 0 ||
                    strcmp(prop, "a_idle") == 0) {
                 ret = S_CABLE_DETACHED;
+        } else if (strcmp(prop, "UNDEFINED") == 0) {
+                ULOG_ERR_F("'usb_device.mode' is UNDEFINED, not changing"
+                           " the state");
+                ret = usb_state;
         } else {
                 ULOG_ERR_F("unknown USB cable type '%s'", prop);
                 ret = S_CABLE_DETACHED;
@@ -1648,6 +1651,25 @@
         return ret;
 }
 
+static void get_usb_cable_udi()
+{
+        char **list;
+        int num_devices = 0;
+        DBusError error;
+
+        dbus_error_init(&error);
+
+        /* figure out USB cable and mode */
+        list = libhal_manager_find_device_string_match(hal_ctx,
+                 "button.type", "usb.cable", &num_devices, &error);
+        if (list != NULL && num_devices >= 1) {
+                usb_cable_udi = strdup(list[0]);
+        } else {
+                ULOG_ERR_F("coudn't find USB cable indicator");
+        } 
+        libhal_free_string_array(list);
+}
+
 static void read_config()
 {
         int num_hosts = 0, num_devices = 0, i;
@@ -1707,24 +1729,10 @@
         } 
         libhal_free_string_array(list);
 
-        /* figure out USB cable and mode */
-        list = libhal_manager_find_device_string_match(hal_ctx,
-                 "button.type", "usb.cable", &num_devices, &error);
-        if (list != NULL && num_devices == 1) {
-                usb_cable_udi = strdup(list[0]);
-        } else {
-                ULOG_ERR_F("coudn't find USB cable indicator, using "
-                           DEFAULT_USB_CABLE_UDI);
-                usb_cable_udi = DEFAULT_USB_CABLE_UDI;
-        } 
-        libhal_free_string_array(list);
+        get_usb_cable_udi();
 
         if (usb_cable_udi != NULL) {
                 init_usb_cable_status((void*)1);
-        } else {
-                usb_state = S_CABLE_DETACHED;
-                inform_usb_cable_attached(FALSE);
-                set_usb_mode_key("idle");
         }
 }
 
@@ -1782,6 +1790,12 @@
                 return FALSE;
         }
 
+        if (usb_cable_udi == NULL) {
+                get_usb_cable_udi();
+                if (usb_cable_udi)
+                        add_prop_watch(usb_cable_udi);
+        }
+
         usb_state = get_usb_state();
         if (usb_state == S_INVALID_USB_STATE) {
                 if (--retry_times > 0) {
@@ -3145,7 +3159,8 @@
         add_prop_watch(camera_turned_udi);
         */
         add_prop_watch(slide_keyboard_udi);
-        add_prop_watch(usb_cable_udi);
+        if (usb_cable_udi)
+                add_prop_watch(usb_cable_udi);
 
         if (!libhal_ctx_set_device_added(hal_ctx, device_added)) {
                 ULOG_CRIT_L("libhal_ctx_set_device_added failed");
@@ -3185,8 +3200,7 @@
          * (needs rechecking and possibly fixing hildon-desktop) */
         desktop_started = TRUE;
 
-        if (usb_state != S_INVALID_USB_STATE  /* valid USB state is required */
-            && (desktop_started || first_boot)) {
+        if (usb_state != S_INVALID_USB_STATE) {
                 /* initialise GConf keys and possibly mount or USB-share */
                 if (int_mmc_enabled) {
                         handle_event(E_INIT_CARD, &int_mmc, NULL);

Modified: projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh
===================================================================
--- projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh	2009-02-24 11:51:13 UTC (rev 17505)
+++ projects/haf/trunk/ke-recv/src/osso-usb-mass-storage-disable.sh	2009-02-24 14:41:46 UTC (rev 17506)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # This file is part of ke-recv
 #
-# Copyright (C) 2004-2006 Nokia Corporation. All rights reserved.
+# Copyright (C) 2004-2009 Nokia Corporation. All rights reserved.
 #
 # Contact: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com>
 #
@@ -30,8 +30,6 @@
   exit 0
 fi
 
-initctl emit G_FILE_STORAGE_REMOVE
-
 GADGETPATH='/sys/devices/platform/musb_hdrc/gadget'
 LUN0='gadget-lun0'
 LUN1='gadget-lun1'


More information about the maemo-commits mailing list