* next bunch of updates unreleased now at svn rev 2947
[navit-package] / debian / patches / screen_unblank.patch
1 Index: navit/configure.in
2 ===================================================================
3 --- navit.orig/configure.in     2010-02-05 00:57:22.000000000 +0100
4 +++ navit/configure.in  2010-02-05 00:58:19.127738212 +0100
5 @@ -211,6 +211,13 @@
6                 ], [
7                 AC_MSG_RESULT(no)
8         ])
9 +       PKG_CHECK_MODULES(LIBOSSO, libosso, [
10 +               AC_DEFINE(HAVE_OSSO, 1, [Have the osso library])
11 +               AC_SUBST(OSSO_CFLAGS)
12 +               AC_SUBST(OSSO_LIBS)
13 +               ], [
14 +               AC_MSG_RESULT(no)
15 +       ])
16         if test x"${enable_hildon}" = xyes ; then
17                 AC_DEFINE(USE_HILDON, 1, [Build with maemo/hildon support])
18                 AC_SUBST(HILDON_CFLAGS)
19 Index: navit/navit/Makefile.am
20 ===================================================================
21 --- navit.orig/navit/Makefile.am        2010-02-05 00:57:22.000000000 +0100
22 +++ navit/navit/Makefile.am     2010-02-05 00:58:19.148160706 +0100
23 @@ -18,7 +18,7 @@
24  endif
25  
26  
27 -AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
28 +AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @LIBOSSO_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
29  BUILT_SOURCES = version.h navit_config.h
30  
31  if BIN_NAVIT
32 @@ -88,7 +88,7 @@
33  
34  else
35  navit_SOURCES = start.c
36 -navit_LDADD = libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib
37 +navit_LDADD = libnavit.la @NAVIT_LIBS@ @WORDEXP_LIBS@ @LIBOSSO_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib
38  
39  endif
40  
41 Index: navit/navit/attr_def.h
42 ===================================================================
43 --- navit.orig/navit/attr_def.h 2010-02-05 00:55:56.000000000 +0100
44 +++ navit/navit/attr_def.h      2010-02-05 00:58:19.150834975 +0100
45 @@ -274,6 +274,7 @@
46  ATTR(filter)
47  ATTR(daylayout)
48  ATTR(nightlayout)
49 +ATTR(screen_unblank)   /*  for N8x0 */
50  ATTR(xml_text)
51  ATTR(layout_name)
52  ATTR(user_name)
53 Index: navit/navit/gui/internal/gui_internal.c
54 ===================================================================
55 --- navit.orig/navit/gui/internal/gui_internal.c        2010-02-05 00:46:35.000000000 +0100
56 +++ navit/navit/gui/internal/gui_internal.c     2010-02-05 00:58:19.150834975 +0100
57 @@ -4369,6 +4369,9 @@
58                         graphics_draw_mode(this->gra, draw_mode_end);
59                         this->win->fullscreen(this->win, attr->u.num > 0);
60                         graphics_draw_mode(this->gra, draw_mode_begin);
61 +#ifdef HAVE_OSSO
62 +                       navit_osso_fullscreen(this->nav, attr->u.num > 0);
63 +#endif
64                 }
65                 this->fullscreen=attr->u.num;
66                 return 1;
67 Index: navit/navit/navit.h
68 ===================================================================
69 --- navit.orig/navit/navit.h    2010-02-05 00:41:18.000000000 +0100
70 +++ navit/navit/navit.h 2010-02-05 00:58:19.150834975 +0100
71 @@ -61,6 +61,10 @@
72  void navit_ignore_graphics_events(struct navit *this_, int ignore);
73  int navit_handle_button(struct navit *this_, int pressed, int button, struct point *p, struct callback *popup_callback);
74  void navit_handle_motion(struct navit *this_, struct point *p);
75 +#ifdef HAVE_OSSO
76 +void navit_osso_display_on(struct navit *this_);
77 +void navit_osso_fullscreen(struct navit *this_, int fullscreen);
78 +#endif
79  void navit_zoom_in(struct navit *this_, int factor, struct point *p);
80  void navit_zoom_out(struct navit *this_, int factor, struct point *p);
81  struct navit *navit_new(struct attr *parent, struct attr **attrs);
82 Index: navit/navit/xpm/Makefile.am
83 ===================================================================
84 --- navit.orig/navit/xpm/Makefile.am    2010-02-05 00:55:56.000000000 +0100
85 +++ navit/navit/xpm/Makefile.am 2010-02-05 00:59:52.957318625 +0100
86 @@ -214,7 +214,12 @@
87  
88  if !SUPPORT_WIN32
89    DESKTOPFILEdir=$(datadir)/applications
90 +
91 +if USE_HILDON
92 +  DESKTOPFILE_DATA = desktop_icons/navit.desktop, desktop_icons/org.navit-project.Navit.service
93 +else
94    DESKTOPFILE_DATA = desktop_icons/navit.desktop
95 +endif
96  
97    ICON128dir=$(datadir)/icons/hicolor/128x128/apps
98    ICON128_DATA = desktop_icons/128x128/navit.png
99 Index: navit/navit/navit.c
100 ===================================================================
101 --- navit.orig/navit/navit.c    2010-02-05 00:46:22.368648992 +0100
102 +++ navit/navit/navit.c 2010-02-05 00:58:19.150834975 +0100
103 @@ -61,7 +61,9 @@
104  #include "messages.h"
105  #include "vehicleprofile.h"
106  #include "sunriset.h"
107 -
108 +#ifdef HAVE_OSSO
109 +#include "libosso.h"
110 +#endif
111  /**
112   * @defgroup navit the navit core instance. navit is the object containing nearly everything: A set of maps, one or more vehicle, a graphics object for rendering the map, a gui object for displaying the user interface, a route object, a navigation object and so on. Be warned that it is theoretically possible to have more than one navit object
113   * @{
114 @@ -138,8 +140,15 @@
115         int prevTs;
116         int graphics_flags;
117         int zoom_min, zoom_max;
118 +#ifdef HAVE_OSSO
119 +       osso_context_t *osso_context;
120 +       gboolean fullscreen;    // True=fullscreen
121 +       int screen_unblank; // 0=never, 1=GPS event, 2=fullscreen
122 +#endif
123  };
124  
125 +struct navit *global_navit;
126 +
127  struct gui *main_loop_gui;
128  
129  struct attr_iter {
130 @@ -160,6 +169,102 @@
131  static void navit_cmd_announcer_toggle(struct navit *this_);
132  static void navit_set_vehicle(struct navit *this_, struct navit_vehicle *nv);
133  
134 +#ifdef HAVE_OSSO
135 +/**
136 + * Remember state of Fullscreen
137 + *
138 + * @param navit our context
139 + * @param fullscreen indicates whether we have full screen
140 + * @returns nothing
141 + */
142 +void
143 +navit_osso_fullscreen(struct navit *this_, int fullscreen)
144 +{
145 +       dbg(2,"setting fullscreen to %s\n", fullscreen == 0 ? "no":"yes");
146 +       this_->fullscreen = (fullscreen == 1);
147 +}
148 +
149 +/**
150 + * * Tell osso to unblank the screen
151 + * *
152 + * * @param navit our context
153 + * * @returns nothing
154 + **/
155 +void
156 +navit_osso_display_on(struct navit *this_)
157 +{
158 +       osso_return_t err;
159 +       dbg(2,"unblank screen: fs=%d, unblank on: %d\n", this_->fullscreen, this_->screen_unblank);
160 +        switch (this_->screen_unblank) {
161 +        case 0: // never
162 +               break;
163 +        case 1: // GPS event
164 +               //osso_display_state_on(this_->osso_context);
165 +               err=osso_display_blanking_pause(this_->osso_context);
166 +               dbg(1,"Unblank result: ", err == OSSO_OK ? "Ok" : (err == OSSO_ERROR ? "Error" : "Invalid context"));
167 +               break;
168 +        case 2: // fullscreen
169 +               if (this_->fullscreen) {
170 +                       //osso_display_state_on(this_->osso_context);
171 +                       err=osso_display_blanking_pause(this_->osso_context);
172 +                      dbg(1,"Unblank result: ", err == OSSO_OK ? "Ok" : (err == OSSO_ERROR ? "Error" : "Invalid context"));
173 +               }
174 +               break;
175 +        default:
176 +               break;
177 +        }
178 +}
179 +/**
180 + * * Act on Osso event
181 + * * @param state The oss  hardware state
182 + * * @returns FALSE
183 + * */
184 +static gboolean
185 +osso_cb_hw_state_idle(osso_hw_state_t *state)
186 +{
187 +    dbg(0,"(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)\n",
188 +            state->system_inactivity_ind,
189 +            state->save_unsaved_data_ind, state->shutdown_ind,
190 +            state->memory_low_ind, state->sig_device_mode_ind);
191 +
192 +    if(state->shutdown_ind)
193 +    {
194 +       /* we  are going  down, down,  down */
195 +        navit_destroy(global_navit);
196 +        exit(1);
197 +    }
198 +/* figure this out later
199 +    if(state->save_unsaved_data_ind)
200 +    {
201 +    // save all our data, if any
202 +    }
203 +
204 +    if(state->memory_low_ind)
205 +    {
206 +    // do something to reduce memory needs
207 +    }
208 +*/
209 +    g_free(state);
210 +
211 +    return FALSE;
212 +}
213 +
214 +/**
215 + * * Handle osso events
216 + * * @param state Osso hardware state
217 + * * @param  data ptr to private data
218 + * * @returns nothing
219 + **/
220 +static void
221 +osso_cb_hw_state(osso_hw_state_t *state, gpointer data)
222 +{
223 +     osso_hw_state_t *state_copy = g_new(osso_hw_state_t, 1);
224 +     memcpy(state_copy, state, sizeof(osso_hw_state_t));
225 +     g_idle_add((GSourceFunc)osso_cb_hw_state_idle, state_copy);
226 +}
227 +#endif
228 +
229 +
230  void
231  navit_add_mapset(struct navit *this_, struct mapset *ms)
232  {
233 @@ -681,6 +786,10 @@
234         
235         this_->prevTs=0;
236  
237 +#ifdef HAVE_OSSO
238 +       this_->screen_unblank = 1;      // 1=GPS
239 +#endif
240 +
241         transform_setup(this_->trans, &center, zoom, (this_->orientation != -1) ? this_->orientation : 0);
242         for (;*attrs; attrs++) {
243                 navit_set_attr_do(this_, *attrs, 1);
244 @@ -1031,8 +1140,6 @@
245         callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map);
246  }
247  
248 -struct navit *global_navit;
249 -
250  static void
251  navit_add_bookmarks_from_file(struct navit *this_)
252  {
253 @@ -1395,6 +1502,19 @@
254         navit_window_items_new(this_);
255  #endif
256  
257 +#ifdef HAVE_OSSO
258 +      dbg(1,"Installing osso context for org.navit-project.navit\n");
259 +      this_->osso_context = osso_initialize("org.navit-project.navit",
260 +                 VERSION, TRUE, NULL);
261 +      if(this_->osso_context == NULL) {
262 +                dbg(0, "error initiating osso context\n");
263 +      }
264 +      osso_hw_set_event_cb(this_->osso_context, NULL, osso_cb_hw_state, NULL);
265 +
266 +      /* add callback to unblank screen on gps event */
267 +      navit_add_callback(this_, callback_new_attr_1(callback_cast(navit_osso_display_on), attr_position_coord_geo, this_));
268 +#endif
269 +
270         messagelist_init(this_->messages);
271  
272         navit_set_cursors(this_);
273 @@ -1746,6 +1866,14 @@
274                 attr_updated=(this_->center_timeout != attr->u.num);
275                 this_->center_timeout = attr->u.num;
276                 break;
277 +       // screen  unblank for Nokia N8x0
278 +       case attr_screen_unblank:
279 +                if (!strcmp(attr->u.str,"GPS"))
280 +                   this_->screen_unblank = 1;
281 +                if (!strcmp(attr->u.str, "fullscreen"))
282 +                   this_->screen_unblank  = 2;
283 +                dbg(1,"screen_unblank set to %d\n",this_->screen_unblank);
284 +                break;
285         case attr_tracking:
286                 attr_updated=(this_->tracking_flag != !!attr->u.num);
287                 this_->tracking_flag=!!attr->u.num;
288 @@ -2448,6 +2576,12 @@
289  void
290  navit_destroy(struct navit *this_)
291  {
292 +
293 +#ifdef HAVE_OSSO
294 +       dbg(1,"Disconnecting from osso\n");
295 +       osso_deinitialize(this_->osso_context);
296 +#endif
297 +
298         /* TODO: destroy objects contained in this_ */
299         if (this_->vehicle)
300                 vehicle_destroy(this_->vehicle->vehicle);