Ticket #282: diff-1

File diff-1, 11.5 KB (added by Gerritv, 12 years ago)

code changes

Line 
1Index: gui/internal/gui_internal.c
2===================================================================
3--- gui/internal/gui_internal.c (revision 1968)
4+++ gui/internal/gui_internal.c (working copy)
5@@ -2624,8 +2624,14 @@
6 static void
7 gui_internal_cmd_fullscreen(struct gui_priv *this, struct widget *wm, void *data)
8 {
9+       /* called from UI menu or from OSD button */
10+
11        this->fullscreen=!this->fullscreen;
12        this->win->fullscreen(this->win, this->fullscreen);
13+#ifdef HAVE_OSSO
14+       /* let navit know what state of fullscreen  mode is */
15+       navit_osso_fullscreen(this->nav, this->fullscreen);
16+#endif
17 }
18 
19 static void
20Index: attr.c
21===================================================================
22--- attr.c      (revision 1968)
23+++ attr.c      (working copy)
24@@ -42,12 +42,15 @@
25 #undef ATTR2
26 #undef ATTR
27 };
28-
29+/**
30+ * * Determine if this is a valid name
31+ * * @param name The name  to  find
32+ * * @returns attr  Attr struct or empty Attr struct if not found
33+ * */
34 enum attr_type
35 attr_from_name(const char *name)
36 {
37        int i;
38-
39        for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
40                if (! strcmp(attr_names[i].name, name))
41                        return attr_names[i].attr;
42@@ -59,7 +62,6 @@
43 attr_to_name(enum attr_type attr)
44 {
45        int i;
46-
47        for (i=0 ; i < sizeof(attr_names)/sizeof(struct attr_name) ; i++) {
48                if (attr_names[i].attr == attr)
49                        return attr_names[i].name;
50Index: graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
51===================================================================
52--- graphics/gtk_drawing_area/graphics_gtk_drawing_area.c       (revision 1968)
53+++ graphics/gtk_drawing_area/graphics_gtk_drawing_area.c       (working copy)
54@@ -324,7 +324,10 @@
55        struct font_freetype_text *t;
56 
57        if (! font)
58+       {
59+               dbg(0,"no font, returning\n");
60                return;
61+       }
62 #if 0 /* Temporarily disabled because it destroys text rendering of overlays and in gui internal in some places */
63        /*
64         This needs an improvement, no one checks if the strings are visible
65@@ -735,10 +738,16 @@
66                key[1]='\0';
67                break;
68        case GDK_Book:
69+#ifdef USE_HILDON
70+       case GDK_F7:
71+#endif
72                key[0]=NAVIT_KEY_ZOOM_IN;
73                key[1]='\0';
74                break;
75        case GDK_Calendar:
76+#ifdef USE_HILDON
77+       case GDK_F8:
78+#endif
79                key[0]=NAVIT_KEY_ZOOM_OUT;
80                key[1]='\0';
81                break;
82Index: xpm/Makefile.am
83===================================================================
84--- xpm/Makefile.am     (revision 1968)
85+++ xpm/Makefile.am     (working copy)
86@@ -214,8 +214,13 @@
87 endif
88 
89 DESKTOPFILEdir=$(datadir)/applications
90+if USE_HILDON
91+DESKTOPFILE_DATA = desktop_icons/navit.desktop, desktop_icons/org.navit-project.Navit.service
92+else
93 DESKTOPFILE_DATA = desktop_icons/navit.desktop
94+endif
95 
96 ICON128dir=$(datadir)/icons/hicolor/128x128/apps
97 ICON128_DATA = desktop_icons/128x128/navit.png
98 
99Index: navit.c
100===================================================================
101--- navit.c     (revision 1968)
102+++ navit.c     (working copy)
103@@ -29,6 +29,9 @@
104 #include "config.h"
105 #include "debug.h"
106 #include "navit.h"
107+#ifdef HAVE_OSSO
108+#include "libosso.h"
109+#endif
110 #include "callback.h"
111 #include "gui.h"
112 #include "item.h"
113@@ -131,8 +134,15 @@
114        int use_mousewheel;
115        GHashTable *commands;
116        struct callback *resize_callback,*button_callback,*motion_callback;
117+#ifdef HAVE_OSSO
118+       osso_context_t *osso_context;
119+       gboolean fullscreen;    // True=fullscreen
120+       int screen_unblank; // 0=never, 1=GPS event, 2=fullscreen
121+#endif
122 };
123 
124+struct navit *global_navit;
125+
126 struct gui *main_loop_gui;
127 
128 struct attr_iter {
129@@ -505,7 +515,96 @@
130        long scale=transform_get_scale(this_->trans)*factor;
131        navit_scale(this_, scale, p);
132 }
133+#ifdef HAVE_OSSO
134+/**
135+ * Remember state of Fullscreen
136+ *
137+ * @param navit our context
138+ * @param fullscreen indicates whether we have full screen
139+ * @returns nothing
140+ */
141+void
142+navit_osso_fullscreen(struct navit *this_, int fullscreen)
143+{
144+       dbg(2,"setting fullscreen to %s\n", fullscreen == 0 ? "no":"yes");
145+       this_->fullscreen = (fullscreen == 1);
146+}
147 
148+/**
149+ * * Tell osso to unblank the screen
150+ * *
151+ * * @param navit our context
152+ * * @returns nothing
153+ **/
154+void
155+navit_osso_display_on(struct navit *this_)
156+{
157+       dbg(2,"unblank screen: fs=%d, unblank on: %d\n", this_->fullscreen, this_->screen_unblank);
158+       switch (this_->screen_unblank) {
159+       case 0: // never
160+               break;
161+       case 1: // GPS event
162+       case 2: // fullscreen
163+               if (this_->fullscreen)
164+               {
165+                       osso_display_state_on(this_->osso_context);
166+                       osso_display_blanking_pause(this_->osso_context);
167+               }
168+               break;
169+       default:
170+               break;
171+       }
172+}
173+/**
174+ * * Act on Osso event
175+ * * @param state The oss  hardware state
176+ * * @returns FALSE
177+ * */
178+static gboolean
179+osso_cb_hw_state_idle(osso_hw_state_t *state)
180+{
181+    dbg(0,"%s(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)\n",
182+            state->system_inactivity_ind,
183+            state->save_unsaved_data_ind, state->shutdown_ind,
184+            state->memory_low_ind, state->sig_device_mode_ind);
185+
186+    if(state->shutdown_ind)
187+    {
188+       /* we  are going  down, down,  down */
189+        navit_destroy(global_navit);
190+        exit(1);
191+    }
192+/* figure this out later
193+    if(state->save_unsaved_data_ind)
194+    {
195+    // save all our data, if any
196+    }
197+
198+    if(state->memory_low_ind)
199+    {
200+    // do something to reduce memory needs
201+    }
202+*/
203+    g_free(state);
204+
205+    return FALSE;
206+}
207+#endif
208+
209+/**
210+ * * Handle osso events
211+ * * @param state Osso hardware state
212+ * * @param  data ptr to private data
213+ * * @returns nothing
214+ **/
215+static void
216+osso_cb_hw_state(osso_hw_state_t *state, gpointer data)
217+{
218+     osso_hw_state_t *state_copy = g_new(osso_hw_state_t, 1);
219+     memcpy(state_copy, state, sizeof(osso_hw_state_t));
220+     g_idle_add((GSourceFunc)osso_cb_hw_state_idle, state_copy);
221+ }
222+
223 struct navit *
224 navit_new(struct attr *parent, struct attr **attrs)
225 {
226@@ -535,6 +634,7 @@
227 
228        this_->bookmarks_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
229 
230+       // set meaningful configuration defaults
231        this_->cursor_flag=1;
232        this_->orientation=-1;
233        this_->tracking_flag=1;
234@@ -544,6 +644,9 @@
235        this_->last_moved = 0;
236        this_->center_timeout = 10;
237        this_->use_mousewheel = 1;
238+#ifdef HAVE_OSSO
239+       this_->screen_unblank = 2;      // 2=fullscreen
240+#endif
241        for (;*attrs; attrs++) {
242                switch((*attrs)->type) {
243@@ -577,6 +678,15 @@
244                case attr_timeout:
245                        this_->center_timeout = (*attrs)->u.num;
246                        break;
247+                       // screen  unblank for Nokia N8x0
248+               case attr_screen_unblank:
249+                       if (!strcmp((*attrs)->u.str,"GPS"))
250+                               this_->screen_unblank = 1;
251+                       if (!strcmp((*attrs)->u.str, "fullscreen"))
252+                               this_->screen_unblank  = 2;
253+                       /* otherwise leave at never (0) */
254+                       dbg(1,"screen_unblank set to %d\n",this_->screen_unblank);
255+                       break;
256                default:
257                        dbg(0, "Unexpected attribute %x\n",(*attrs)->type);
258                        break;
259@@ -910,8 +1020,6 @@
260        callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
261 }
262 
263-struct navit *global_navit;
264-
265 static void
266 navit_add_bookmarks_from_file(struct navit *this_)
267 {
268@@ -1260,6 +1368,20 @@
269        navit_window_items_new(this_);
270 #endif
271        callback_list_call_attr_1(this_->attr_cbl, attr_navit, this_);
272+
273+#ifdef HAVE_OSSO
274+      dbg(1,"Installing osso context for org.navit-project.navit\n");
275+      this_->osso_context = osso_initialize("org.navit-project.navit",
276+                 VERSION, TRUE, NULL);
277+      if(this_->osso_context == NULL) {
278+                dbg(0, "error initiating osso context\n");
279+      }
280+      osso_hw_set_event_cb(this_->osso_context, NULL, osso_cb_hw_state, NULL);
281+     
282+      /* add callback to unblank screen on gps event */
283+      navit_add_callback(this_, callback_new_attr_1(callback_cast(navit_osso_display_on), attr_position_coord_geo, this_));
284+#endif
285+
286        this_->ready|=1;
287        if (this_->ready == 3)
288                navit_draw(this_);
289@@ -1729,7 +1851,6 @@
290        int border=16;
291        int route_path_set=0;
292        int recenter = 1; // indicates if we should recenter the map
293-
294        profile(0,NULL);
295        if (this_->ready != 3) {
296                profile(0,"return 1\n");
297@@ -2028,6 +2150,10 @@
298 void
299 navit_destroy(struct navit *this_)
300 {
301+#ifdef HAVE_OSSO
302+       dbg(1,"Disconnecting from osso\n");
303+       osso_deinitialize(this_->osso_context);
304+#endif
305        /* TODO: destroy objects contained in this_ */
306        if (this_->vehicle)
307                vehicle_destroy(this_->vehicle->vehicle);
308Index: navit.h
309===================================================================
310--- navit.h     (revision 1968)
311+++ navit.h     (working copy)
312@@ -58,6 +58,10 @@
313 void navit_ignore_graphics_events(struct navit *this_, int ignore);
314 int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback);
315 void navit_handle_motion(struct navit *this_, struct point *p);
316+#ifdef HAVE_OSSO
317+void navit_osso_display_on(struct navit *this_);
318+void navit_osso_fullscreen(struct navit *this_, int fullscreen);
319+#endif
320 void navit_zoom_in(struct navit *this_, int factor, struct point *p);
321 void navit_zoom_out(struct navit *this_, int factor, struct point *p);
322 struct navit *navit_new(struct attr *parent, struct attr **attrs);
323Index: xmlconfig.c
324===================================================================
325--- xmlconfig.c (revision 1968)
326+++ xmlconfig.c (working copy)
327@@ -103,7 +103,6 @@
328        int count=0;
329        struct attr **ret;
330        static int fixme_count;
331-
332        while (*attribute_name) {
333                count++;
334                attribute_name++;
335@@ -113,6 +112,8 @@
336        count=0;
337        while (*attribute_name) {
338                name=*attribute_name;
339+               dbg(2,"Attribute Name is %s Value is %s\n",name, *attribute_value);
340+               /*  do  fixups if there are any */
341                if (fixme) {
342                        char **attr_fixme=fixme->attr_fixme;
343                        while (attr_fixme[0]) {
344Index: Makefile.am
345===================================================================
346--- Makefile.am (revision 1968)
347+++ Makefile.am (working copy)
348@@ -9,7 +9,7 @@
349   SUBDIRS += fonts
350 endif
351 
352-AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
353+AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @OSSO_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
354 BUILT_SOURCES = version.h
355 if BUILD_SAMPLEMAP
356   BUILT_SOURCES += osm2navit$(EXEEXT)
357@@ -35,7 +35,7 @@
358        navit_nls.h
359 
360 navit_SOURCES = start.c
361-navit_LDADD = libnavit.la @NAVIT_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib
362+navit_LDADD = libnavit.la @NAVIT_LIBS@ @OSSO_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib
363 
364 osm2navit_CPPFLAGS = $(AM_CPPFLAGS) @ZLIB_CFLAGS@ @POSTGRESQL_CFLAGS@
365 osm2navit_SOURCES = osm2navit.c
366Index: attr_def.h
367===================================================================
368--- attr_def.h  (revision 1968)
369+++ attr_def.h  (working copy)
370@@ -17,6 +17,14 @@
371  * Boston, MA  02110-1301, USA.
372  */
373 
374+/* NOTE!!!!
375+ * when adding attrs, ensure that you do so within the labelled range
376+ * according to the data type of your attr value.
377+ * e.g. if adding an attr with text value,
378+ * Consider your self warned, otherwise expect attr_new_from_text
379+ * to reach end of switch :-)
380+ */
381+
382 /* prototypes */
383 
384 /* common */
385@@ -32,6 +40,7 @@
386 ATTR2(0x0001ffff,type_item_end)
387 
388 ATTR2(0x00020000,type_int_begin)
389+/* int values only in this range */
390 ATTR(h)
391 ATTR(id)
392 ATTR(flags)
393@@ -93,7 +102,7 @@
394 ATTR(osd_configuration)
395 ATTR(columns)
396 ATTR2(0x00028000,type_boolean_begin)
397-/* boolean */
398+/* boolean values only in this range */
399 ATTR(overwrite)
400 ATTR(active)
401 ATTR(cursor)
402@@ -124,6 +133,7 @@
403 ATTR(night_mode)
404 ATTR2(0x0002ffff,type_int_end)
405 ATTR2(0x00030000,type_string_begin)
406+/* string values only in this range */
407 ATTR(type)
408 ATTR(label)
409 ATTR(data)
410@@ -179,8 +189,10 @@
411 ATTR(icon_src)
412 ATTR(position_time_iso8601)
413 ATTR(house_number)
414+ATTR(screen_unblank)   /*  for N8x0 */
415 ATTR2(0x0003ffff,type_string_end)
416 ATTR2(0x00040000,type_special_begin)
417+/* special values only in this range */
418 ATTR(order)
419 ATTR(item_type)
420 ATTR(item_types)