--- maemo-mapper-1.1/src/maemo-mapper.c	2006-07-09 19:25:18.000000000 +0200
+++ maemo-mapper-1.1-aw-1/src/maemo-mapper.c	2006-07-28 21:50:23.000000000 +0200
@@ -182,6 +182,7 @@
 #define GCONF_KEY_SHOWVELVEC GCONF_KEY_PREFIX"/show_velocity_vector"
 #define GCONF_KEY_ENABLE_GPS GCONF_KEY_PREFIX"/enable_gps"
 #define GCONF_KEY_ROUTE_LOCATIONS GCONF_KEY_PREFIX"/route_locations"
+#define GCONF_KEY_DISCONNECT_ON_COVER "/system/osso/connectivity/IAP/disconnect_on_cover"
 
 #define XML_DATE_FORMAT "%FT%T"
 
@@ -4821,6 +4822,7 @@
 osso_cb_hw_state(osso_hw_state_t *state, gpointer data)
 {
     static gboolean _must_save_data = FALSE;
+    static gboolean _must_switch_off = TRUE;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     if(state->system_inactivity_ind)
@@ -4829,9 +4831,26 @@
             _must_save_data = FALSE;
         else if(_conn_state > RCVR_OFF)
         {
-            set_conn_state(RCVR_OFF);
-            rcvr_disconnect();
-            track_add(0, FALSE);
+            GConfClient *gconf_client = gconf_client_get_default();
+	    if (gconf_client)
+	    {
+		    GConfValue *value=gconf_client_get(gconf_client, GCONF_KEY_DISCONNECT_ON_COVER, NULL);
+		    if (value)
+		    {
+			    if (gconf_value_get_bool(value))
+				    _must_switch_off=TRUE;
+			    else
+				    _must_switch_off=FALSE;
+			    gconf_value_free(value);
+		    }
+		    g_object_unref(gconf_client);
+	    }
+	    if (_must_switch_off)
+	    {
+		set_conn_state(RCVR_OFF);
+            	rcvr_disconnect();
+            	track_add(0, FALSE);
+	    }
             /* Pretend the autoroute is in progress to avoid download. */
             if(_autoroute_data.enabled)
                 _autoroute_data.in_progress = TRUE;

