]> err.no Git - mapper/blobdiff - src/maemo-osso.c
Add header and cast properly.
[mapper] / src / maemo-osso.c
index 646b086a0bbddfedfcdd2d87e41264f82557ed2d..9f6354bfdf35388822f1dfa4cc6a0f952541278e 100644 (file)
+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ * Copyright (C) 2006-2007 John Costigan.
+ *
+ * POI and GPS-Info code originally written by Cezary Jackiewicz.
+ *
+ * Default map data provided by http://www.openstreetmap.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
 /* 
  * Maemo hardware specific functions 
  */
 
 #include <config.h>
 
-#define _GNU_SOURCE
-
 #include <glib.h>
+#include <gtk/gtk.h>
 
-#ifdef WITH_HILDON
-
+#ifdef WITH_OSSO
 #include <libosso.h>
-#include <osso-helplib.h>
-#include <osso-ic-dbus.h>
+
+#ifdef WITH_OSSO_IC
 #include <osso-ic.h>
+#include <osso-ic-dbus.h>
+#endif
+
+#include "map.h"
+#include "map-download.h"
+#include "route.h"
+#include "mapper-types.h"
+#include "gps.h"
+#include "settings-gconf.h"
+#include "settings.h"
+#include "config-gconf.h"
+#include "ui-common.h"
 
-void osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
+gint
+dbus_cb_default(const gchar *interface, const gchar *method, GArray *arguments, gpointer data, osso_rpc_t *retval)
 {
-       static gboolean _must_save_data = FALSE;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+if(!strcmp(method, "top_application"))
+       gtk_idle_add((GSourceFunc)window_present, NULL);
+retval->type = DBUS_TYPE_INVALID;
 
-       if (state->system_inactivity_ind) {
-               if (_must_save_data)
-                       _must_save_data = FALSE;
-               else {
-                       if (_conn_state > RCVR_OFF) {
-                               GConfClient *gconf_client =
-                                   gconf_client_get_default();
-                               if (!gconf_client
-                                   || gconf_client_get_bool(gconf_client,
-                                                            GCONF_KEY_DISCONNECT_ON_COVER,
-                                                            NULL)) {
-                                       gconf_client_clear_cache(gconf_client);
-                                       g_object_unref(gconf_client);
-                                       set_conn_state(RCVR_OFF);
-                                       rcvr_disconnect();
-                                       track_add(0, FALSE);
-                                       /* Pretend autoroute is in progress to avoid download. */
-                                       if (_autoroute_data.enabled)
-                                               _autoroute_data.in_progress = TRUE;
-                               }
-                       }
-                       if (_curl_sid) {
-                               g_source_remove(_curl_sid);
-                               _curl_sid = 0;
+return OSSO_OK;
+}
+
+void
+osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
+{
+static gboolean _must_save_data = FALSE;
+
+if (state->system_inactivity_ind) {
+       if (_must_save_data)
+               _must_save_data = FALSE;
+       else {
+               if (_gps->io.conn > RCVR_OFF) {
+                       if (gconf_client_get_bool(gconf_client, GCONF_KEY_DISCONNECT_ON_COVER, NULL)) {
+                               gconf_client_clear_cache(gconf_client);
+                               gps_conn_set_state(_gps, RCVR_OFF);
+                               gps_disconnect(_gps);
+                               track_add(NULL);
+                               /* Pretend autoroute is in progress to avoid download. */
+                               if (_autoroute_data.enabled)
+                                       _autoroute_data.in_progress = TRUE;
                        }
                }
-       } else if (state->save_unsaved_data_ind) {
-               config_save();
-               _must_save_data = TRUE;
-       } else if (state->memory_low_ind) {
-               /* Drop any memory we can.. */
-       } else {
-               if (_conn_state == RCVR_OFF && _enable_gps) {
-                       set_conn_state(RCVR_DOWN);
-                       rcvr_connect_later();
-                       if (_autoroute_data.enabled)
-                               _autoroute_data.in_progress = TRUE;
+               if (_curl_sid) {
+                       g_source_remove(_curl_sid);
+                       _curl_sid = 0;
                }
-
-               /* Start curl in case there are downloads pending. */
-               if (_iap_connected && !_curl_sid)
-                       _curl_sid = g_timeout_add(100,
-                                                 (GSourceFunc)
-                                                 curl_download_timeout, NULL);
+       }
+} else if (state->save_unsaved_data_ind) {
+       config_save();
+       _must_save_data = TRUE;
+} else if (state->memory_low_ind) {
+       poi_icon_hash_clear();
+} else {
+       if (_gps->io.conn == RCVR_OFF && _enable_gps) {
+               gps_conn_set_state(_gps, RCVR_DOWN);
+               gps_connect_later(_gps);
+               if (_autoroute_data.enabled)
+                       _autoroute_data.in_progress = TRUE;
        }
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+       /* Start curl in case there are downloads pending. */
+       if (iap_is_connected() && !_curl_sid)
+               _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
+}
 }
 
 #else
 
-void osso_cb_hw_state(void *state, gpointer data)
+void 
+osso_cb_hw_state(void *state, gpointer data)
 {
 }