Ticket #282: p282-r3313.patch

File p282-r3313.patch, 5.1 KB (added by https://www.google.com/accounts/o8/id?id=aitoawkf0frlp4x3vjbz-vqlc-bpyhbdworle10, 21 months ago)
  • navit/Makefile.am

     
    2626AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit 
    2727BUILT_SOURCES = version.h navit_config.h 
    2828 
     29if USE_OSSO 
     30    AM_CPPFLAGS += @LIBOSSO_CFLAGS@ 
     31endif 
     32 
    2933if BIN_NAVIT 
    3034  bin_PROGRAMS = navit 
    3135endif 
     
    4246  lib@LIBNAVIT@_la_LIBADD += -Lsupport/libc -lsupport_libc 
    4347endif 
    4448 
     49if USE_OSSO 
     50    lib@LIBNAVIT@_la_LIBADD += @LIBOSSO_LIBS@ 
     51endif  
     52 
    4553pkgdata_DATA = navit.xml 
    4654 
    4755EXTRA_DIST = navit_shipped.xml navit.dtd 
     
    121129  navit_LDADD += -lgdi32 -lcomctl32 -lwinmm 
    122130endif 
    123131 
     132if USE_OSSO 
     133    navit_LDADD += @LIBOSSO_CFLAGS@ 
     134endif 
    124135 
    125136resource.rsc: $(top_srcdir)/navit/gui/win32/resources/resource.rc 
    126137        $(WINDRES) -I $(top_srcdir)/navit/gui/win32/resources $(top_srcdir)/navit/gui/win32/resources/resource.rc resource.rsc 
  • navit/navit.c

     
    6363#include "sunriset.h" 
    6464#include "bookmarks.h" 
    6565 
     66#ifdef HAVE_OSSO 
     67#include "libosso.h" 
     68#endif 
     69 
    6670/** 
    6771 * @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 
    6872 * @{ 
     
    142146        int flags; 
    143147                 /* 1=No graphics ok */ 
    144148                 /* 2=No gui ok */ 
     149#ifdef HAVE_OSSO 
     150        osso_context_t *osso_context;  
     151#endif 
    145152}; 
    146153 
    147154struct gui *main_loop_gui; 
     
    702709        {"fmt_coordinates",command_cast(navit_cmd_fmt_coordinates)}, 
    703710}; 
    704711         
     712#ifdef HAVE_OSSO 
     713static void  
     714navit_osso_display_on(struct navit *this_)  
     715{  
     716    osso_return_t err;  
     717    err=osso_display_blanking_pause(this_->osso_context);  
     718    dbg(1,"Unblank result: ", err == OSSO_OK ? "Ok" : (err == OSSO_ERROR ? "Error" : "Invalid context"));  
     719} 
    705720 
     721static gboolean  
     722osso_cb_hw_state_idle(osso_hw_state_t *state)  
     723{  
     724    dbg(0,"(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)\n",  
     725            state->system_inactivity_ind,  
     726            state->save_unsaved_data_ind, state->shutdown_ind,  
     727            state->memory_low_ind, state->sig_device_mode_ind);  
     728 
     729    if(state->shutdown_ind)  
     730    {  
     731        /* we  are going  down, down,  down */  
     732        navit_destroy(global_navit);  
     733        exit(1);  
     734    }  
     735 
     736    g_free(state);  
     737 
     738    return FALSE; 
     739}  
     740 
     741/**  
     742 * * Handle osso events  
     743 * * @param state Osso hardware state  
     744 * * @param  data ptr to private data  
     745 * * @returns nothing  
     746 **/  
     747static void  
     748osso_cb_hw_state(osso_hw_state_t *state, gpointer data)  
     749{  
     750    osso_hw_state_t *state_copy = g_new(osso_hw_state_t, 1);  
     751    memcpy(state_copy, state, sizeof(osso_hw_state_t));  
     752    g_idle_add((GSourceFunc)osso_cb_hw_state_idle, state_copy);  
     753}  
     754#endif /* HAVE_OSSO */ 
     755 
    706756struct navit * 
    707757navit_new(struct attr *parent, struct attr **attrs) 
    708758{ 
     
    753803        command_add_table(this_->attr_cbl, commands, sizeof(commands)/sizeof(struct command_table), this_); 
    754804 
    755805        this_->messages = messagelist_new(attrs); 
    756          
     806 
     807#ifdef HAVE_OSSO 
     808        dbg(1,"Installing osso context for org.navit_project.navit\n");  
     809        this_->osso_context = osso_initialize("org.navit_project.navit",VERSION, TRUE, NULL);  
     810        if(this_->osso_context == NULL) {  
     811            dbg(0, "error initiating osso context\n");  
     812        }  
     813        osso_hw_set_event_cb(this_->osso_context, NULL, osso_cb_hw_state, NULL);  
     814         
     815        /* add callback to unblank screen on gps event */  
     816        navit_add_callback(this_, callback_new_attr_1(callback_cast(navit_osso_display_on), attr_position_coord_geo, this_));  
     817#endif /* HAVE_OSSO */ 
     818 
    757819        return this_; 
    758820} 
    759821 
     
    23242386void 
    23252387navit_destroy(struct navit *this_) 
    23262388{ 
     2389 
     2390#ifdef HAVE_OSSO 
     2391        osso_deinitialize(this_->osso_context); 
     2392#endif /* HAVE_OSSO */ 
     2393 
    23272394        /* TODO: destroy objects contained in this_ */ 
    23282395        if (this_->vehicle) 
    23292396                vehicle_destroy(this_->vehicle->vehicle); 
  • configure.in

     
    218218                ], [ 
    219219                AC_MSG_RESULT(no) 
    220220        ]) 
     221        PKG_CHECK_MODULES(LIBOSSO, libosso, [  
     222                AC_DEFINE(HAVE_OSSO, 1, [Have the osso library])  
     223                AC_SUBST(OSSO_CFLAGS)  
     224                AC_SUBST(OSSO_LIBS)  
     225                enable_osso=yes 
     226                ], [  
     227                enable_osso=no 
     228                AC_MSG_RESULT(no)  
     229        ]) 
    221230        if test x"${enable_hildon}" = xyes ; then 
    222231                AC_DEFINE(USE_HILDON, 1, [Build with maemo/hildon support]) 
    223232                AC_SUBST(HILDON_CFLAGS) 
     
    225234        fi 
    226235fi 
    227236AM_CONDITIONAL(USE_HILDON, test "${enable_hildon}" = "xyes") 
     237AM_CONDITIONAL(USE_OSSO, [ test "$enable_osso" = "yes" ]) 
    228238 
    229239AC_ARG_ENABLE(garmin, [  --disable-garmin             disable garmin support], USE_GARMIN=$enableval, USE_GARMIN=yes) 
    230240