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>
42 #include <gdk/gdkkeysyms.h>
43 #include <dbus/dbus-glib.h>
44 #include <libgnomevfs/gnome-vfs.h>
45 #include <curl/multi.h>
46 #include <gconf/gconf-client.h>
50 #include "hildon-mapper.h"
53 #include "mapper-types.h"
60 #include "ui-common.h"
64 gfloat UNITS_CONVERT[] = {1.85200,1.15077945,1.f,};
66 GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = {
67 {0, 0x0000, 0x0000, 0xc000}
68 , /* COLORABLE_MARK */
69 {0, 0x6000, 0x6000, 0xf800}
70 , /* COLORABLE_MARK_VELOCITY */
71 {0, 0x8000, 0x8000, 0x8000}
72 , /* COLORABLE_MARK_OLD */
73 {0, 0xe000, 0x0000, 0x0000}
74 , /* COLORABLE_TRACK */
75 {0, 0xa000, 0x0000, 0x0000}
76 , /* COLORABLE_TRACK_MARK */
77 {0, 0x7000, 0x0000, 0x0000}
78 , /* COLORABLE_TRACK_BREAK */
79 {0, 0x0000, 0xa000, 0x0000}
80 , /* COLORABLE_ROUTE */
81 {0, 0x0000, 0x8000, 0x0000}
82 , /* COLORABLE_ROUTE_WAY */
83 {0, 0x0000, 0x6000, 0x0000}
84 , /* COLORABLE_ROUTE_BREAK */
85 {0, 0xa000, 0x0000, 0xa000} /* COLORABLE_POI */
90 * Save state and destroy all non-UI elements created by this program in
91 * preparation for exiting.
93 void mapper_destroy(void)
95 printf("%s()\n", __PRETTY_FUNCTION__);
98 g_source_remove(_curl_sid);
104 /* _program and widgets have already been destroyed. */
109 MACRO_PATH_FREE(_track);
110 MACRO_PATH_FREE(_route);
116 gint num_transfers, num_msgs;
118 /* First, remove all downloads from _pui_tree. */
119 g_tree_destroy(_pui_tree);
121 /* Finish up all downloads. */
122 while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(_curl_multi, &num_transfers) || num_transfers) {
123 /* XXX: should inform the user why it's taking so damn long... */
126 /* Close all finished files. */
127 while ((msg = curl_multi_info_read(_curl_multi, &num_msgs))) {
128 if (msg->msg == CURLMSG_DONE) {
129 /* This is a map download. */
130 ProgressUpdateInfo *pui = g_hash_table_lookup(_pui_by_easy, msg->easy_handle);
131 g_queue_push_head(_curl_easy_queue, msg->easy_handle);
132 g_hash_table_remove(_pui_by_easy, msg->easy_handle);
134 curl_multi_remove_handle(_curl_multi, msg->easy_handle);
138 while ((curr = g_queue_pop_tail(_curl_easy_queue)))
139 curl_easy_cleanup(curr);
141 curl_multi_cleanup(_curl_multi);
144 g_queue_free(_curl_easy_queue);
145 g_tree_destroy(_downloading_tree);
146 g_hash_table_destroy(_pui_by_easy);
149 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
152 void set_var_defaults(void)
154 _conn_state = RCVR_OFF;
157 gint mapper_osso_init(void)
160 /* Initialize _osso. */
161 _osso = osso_initialize("org.tal.mapper", VERSION, TRUE, NULL);
163 g_printerr("osso_initialize failed.\n");
170 gint mapper_osso_cb_init(void)
173 if (OSSO_OK != osso_rpc_set_default_cb_f(_osso, dbus_cb_default, NULL)) {
174 g_printerr("osso_rpc_set_default_cb_f failed.\n");
181 void timezone_init(void)
187 localtime_r(&time1, &time2);
188 _gmtoffset = time2.tm_gmtoff;
191 gint main(gint argc, gchar * argv[])
193 printf("%s()\n", __PRETTY_FUNCTION__);
195 /* Initialize localization. */
196 setlocale(LC_ALL, "");
197 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
198 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
199 textdomain(GETTEXT_PACKAGE);
204 if (mapper_osso_init()!=0)
208 gst_init(&argc, &argv);
209 gtk_init(&argc, &argv);
210 gconf_init(argc, argv, NULL);
212 curl_global_init(CURL_GLOBAL_NOTHING);
215 mapper_init(argc, argv);
217 if (mapper_osso_cb_init()!=0)
223 osso_deinitialize(_osso);
225 vprintf("%s(): return\n", __PRETTY_FUNCTION__);