[maemo-commits] [maemo-commits] r16330 - projects/haf/trunk/ke-recv/src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Oct 3 13:46:56 EEST 2008
Author: kihamala
Date: 2008-10-03 13:46:55 +0300 (Fri, 03 Oct 2008)
New Revision: 16330

Modified:
   projects/haf/trunk/ke-recv/src/events.c
   projects/haf/trunk/ke-recv/src/ke-recv.c
Log:
re-enable memory card cover & add proper handling of get_prop_bool() errors


Modified: projects/haf/trunk/ke-recv/src/events.c
===================================================================
--- projects/haf/trunk/ke-recv/src/events.c	2008-10-03 10:16:33 UTC (rev 16329)
+++ projects/haf/trunk/ke-recv/src/events.c	2008-10-03 10:46:55 UTC (rev 16330)
@@ -1014,7 +1014,8 @@
                         }
                         break;
                 case E_PLUGGED:
-                        if (get_cable_peripheral() && !device_locked) {
+                        if (!ignore_cable && get_cable_peripheral()
+                            && !device_locked) {
                                 possibly_turn_swap_off(NO_DIALOG, mmc);
                                 if (!unmount_volumes(&mmc->volumes)) {
                                         ret = 0;
@@ -1024,7 +1025,7 @@
                         }
                         break;
                 case E_DETACHED:
-                        if (get_cable_peripheral()) {
+                        if (!ignore_cable && get_cable_peripheral()) {
                                 unshare_usb_shared_card(mmc);
                                 init_mmc_volumes(mmc);
                                 update_mmc_label(mmc);

Modified: projects/haf/trunk/ke-recv/src/ke-recv.c
===================================================================
--- projects/haf/trunk/ke-recv/src/ke-recv.c	2008-10-03 10:16:33 UTC (rev 16329)
+++ projects/haf/trunk/ke-recv/src/ke-recv.c	2008-10-03 10:46:55 UTC (rev 16330)
@@ -1167,8 +1167,9 @@
         if (dbus_error_is_set(&error)) {
                 ULOG_ERR_F("D-Bus error: %s", error.message);
                 dbus_error_free(&error);
+                return -1;
         }
-        return prop;
+        return prop ? 1 : 0;
 }
 
 int get_prop_int(const char *udi, const char *property)
@@ -1280,12 +1281,14 @@
         if (camera_out_udi != NULL) {
                 state = get_prop_bool(camera_out_udi,
                                       "button.state.value");
-                inform_camera_out(state);
+                if (state != -1)
+                        inform_camera_out(state);
         }
         if (camera_turned_udi != NULL) {
                 state = get_prop_bool(camera_turned_udi,
                                       "button.state.value");
-                inform_camera_turned_out(state);
+                if (state != -1)
+                        inform_camera_turned_out(state);
         }
 }
 
@@ -1297,7 +1300,8 @@
                 state = get_prop_bool(slide_keyboard_udi,
                                       "button.state.value");
         }
-        inform_slide_keyboard(state);
+        if (state != -1)
+                inform_slide_keyboard(state);
 }
 
 static int get_storage(const char *udi, char **storage_parent,
@@ -1525,13 +1529,12 @@
                 int state;
                 state = get_prop_bool(mmc->cover_udi,
                                       "button.state.value");
-                /* FIXME: enable this code when/if the covers start working.
                 if (state) {
+                        /* this case also if get_prop_bool() failed */
                         mmc->state = S_COVER_CLOSED;
                 } else {
                         mmc->state = S_COVER_OPEN;
                 }
-                */
                 mmc->state = S_COVER_CLOSED;
         }
 
@@ -1760,6 +1763,10 @@
                 }
 
                 val = get_prop_bool(udi, "button.state.value");
+                if (val == -1) {
+                        ULOG_ERR_F("failed to read button.state.value");
+                        return;
+                }
 
                 if (slide_keyboard_udi != NULL
                     && strcmp(slide_keyboard_udi, udi) == 0) {
@@ -1862,7 +1869,7 @@
 
         l->corrupt = 0;
 
-        if (get_prop_bool(l->udi, "volume.is_partition")) {
+        if (get_prop_bool(l->udi, "volume.is_partition") == 1) {
                 l->volume_number = get_prop_int(l->udi,
                                                 "volume.partition.number");
         } else {
@@ -1975,7 +1982,7 @@
         int mounted;
         /* check if someone else has already mounted it */
         mounted = get_prop_bool(v->udi, "volume.is_mounted");
-        if (mounted) {
+        if (mounted == 1) {
                 ULOG_INFO_F("%s is already mounted by someone",
                             v->dev_name);
                 /* it's mounted, so not corrupted */
@@ -2598,7 +2605,7 @@
                                         int mounted;
                                         mounted = get_prop_bool(l->udi,
                                                       "volume.is_mounted");
-                                        if (mounted) {
+                                        if (mounted == 1) {
                                                 mount_point = l->mountpoint;
                                                 goto exit_loops;
                                         }


More information about the maemo-commits mailing list