2 * This file is part of maemo-mapper
4 * Copyright (C) 2006-2007 John Costigan.
6 * POI and GPS-Info code originally written by Cezary Jackiewicz.
8 * Default map data provided by http://www.openstreetmap.org/
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #define _(String) gettext(String)
38 #include <glib/gstdio.h>
44 #include <gdk/gdkkeysyms.h>
45 #include <dbus/dbus-glib.h>
46 #include <libgnomevfs/gnome-vfs.h>
47 #include <curl/multi.h>
48 #include <gconf/gconf-client.h>
52 #include "hildon-mapper.h"
55 #include "mapper-types.h"
62 #include "ui-common.h"
68 gfloat UNITS_CONVERT[] = {1.85200,1.15077945,1.f,};
70 GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = {
71 {0, 0x0000, 0x0000, 0xc000}
72 , /* COLORABLE_MARK */
73 {0, 0x6000, 0x6000, 0xf800}
74 , /* COLORABLE_MARK_VELOCITY */
75 {0, 0x8000, 0x8000, 0x8000}
76 , /* COLORABLE_MARK_OLD */
77 {0, 0xe000, 0x0000, 0x0000}
78 , /* COLORABLE_TRACK */
79 {0, 0xa000, 0x0000, 0x0000}
80 , /* COLORABLE_TRACK_MARK */
81 {0, 0x7000, 0x0000, 0x0000}
82 , /* COLORABLE_TRACK_BREAK */
83 {0, 0x0000, 0xa000, 0x0000}
84 , /* COLORABLE_ROUTE */
85 {0, 0x0000, 0x8000, 0x0000}
86 , /* COLORABLE_ROUTE_WAY */
87 {0, 0x0000, 0x6000, 0x0000}
88 , /* COLORABLE_ROUTE_BREAK */
89 {0, 0xa000, 0x0000, 0xa000} /* COLORABLE_POI */
94 * Save state and destroy all non-UI elements created by this program in
95 * preparation for exiting.
97 void mapper_destroy(void)
99 printf("%s()\n", __PRETTY_FUNCTION__);
102 g_source_remove(_curl_sid);
108 /* _program and widgets have already been destroyed. */
113 MACRO_PATH_FREE(_track);
114 MACRO_PATH_FREE(_route);
120 gint num_transfers, num_msgs;
122 /* First, remove all downloads from _pui_tree. */
123 g_tree_destroy(_pui_tree);
125 /* Finish up all downloads. */
126 while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(_curl_multi, &num_transfers) || num_transfers) {
127 /* XXX: should inform the user why it's taking so damn long... */
130 /* Close all finished files. */
131 while ((msg = curl_multi_info_read(_curl_multi, &num_msgs))) {
132 if (msg->msg == CURLMSG_DONE) {
133 /* This is a map download. */
134 ProgressUpdateInfo *pui = g_hash_table_lookup(_pui_by_easy, msg->easy_handle);
135 g_queue_push_head(_curl_easy_queue, msg->easy_handle);
136 g_hash_table_remove(_pui_by_easy, msg->easy_handle);
138 curl_multi_remove_handle(_curl_multi, msg->easy_handle);
142 while ((curr = g_queue_pop_tail(_curl_easy_queue)))
143 curl_easy_cleanup(curr);
145 curl_multi_cleanup(_curl_multi);
148 g_queue_free(_curl_easy_queue);
149 g_tree_destroy(_downloading_tree);
150 g_hash_table_destroy(_pui_by_easy);
153 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
156 void set_var_defaults(void)
158 _conn_state = RCVR_OFF;
161 gint mapper_osso_init(void)
164 /* Initialize _osso. */
165 _osso = osso_initialize("org.tal.mapper", VERSION, TRUE, NULL);
167 g_printerr("osso_initialize failed.\n");
174 gint mapper_osso_cb_init(void)
177 if (OSSO_OK != osso_rpc_set_default_cb_f(_osso, dbus_cb_default, NULL)) {
178 g_printerr("osso_rpc_set_default_cb_f failed.\n");
185 void timezone_init(void)
191 localtime_r(&time1, &time2);
192 _gmtoffset = time2.tm_gmtoff;
195 gint main(gint argc, gchar * argv[])
197 printf("%s()\n", __PRETTY_FUNCTION__);
199 /* Initialize localization. */
200 setlocale(LC_ALL, "");
201 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
202 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
203 textdomain(GETTEXT_PACKAGE);
208 if (mapper_osso_init()!=0)
213 gst_init(&argc, &argv);
216 gtk_init(&argc, &argv);
217 gconf_init(argc, argv, NULL);
219 curl_global_init(CURL_GLOBAL_NOTHING);
222 mapper_init(argc, argv);
224 if (mapper_osso_cb_init()!=0)
233 osso_deinitialize(_osso);
235 vprintf("%s(): return\n", __PRETTY_FUNCTION__);