summaryrefslogtreecommitdiff
path: root/navit/autoload/osso/osso.c
blob: 9c4eb9229c86a770dd9a2c7f000751183831d9e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <libosso.h>
#include <stdlib.h>
#include "debug.h"
#include "version.h"
#include "item.h"
#include "attr.h"
#include "navit.h"
#include "plugin.h"

osso_context_t *osso_context; 

static void  
navit_osso_display_on(struct navit *this_)  
{
    osso_return_t err;
    err=osso_display_blanking_pause(osso_context);
    dbg(1,"Unblank result: ", err == OSSO_OK ? "Ok" : (err == OSSO_ERROR ? "Error" : "Invalid context"));
}

static gboolean  
osso_cb_hw_state_idle(osso_hw_state_t *state)  
{
    dbg(0,"(inact=%d, save=%d, shut=%d, memlow=%d, state=%d)\n",  
    state->system_inactivity_ind,
    state->save_unsaved_data_ind, state->shutdown_ind,
    state->memory_low_ind, state->sig_device_mode_ind);

    if(state->shutdown_ind)  
    {
        /* we  are going  down, down,  down */
        //navit_destroy(global_navit);
        exit(1);
    }

    g_free(state);  

    return FALSE; 
}

/**
 * * Handle osso events  
 * * @param state Osso hardware state  
 * * @param  data ptr to private data  
 * * @returns nothing  
 **/
static void
osso_cb_hw_state(osso_hw_state_t *state, gpointer data)
{
    osso_hw_state_t *state_copy = g_new(osso_hw_state_t, 1);
    memcpy(state_copy, state, sizeof(osso_hw_state_t));
    g_idle_add((GSourceFunc)osso_cb_hw_state_idle, state_copy);
}


void
plugin_init(void) 
{
    dbg(1,"Installing osso context for org.navit_project.navit\n");  
    osso_context = osso_initialize("org.navit_project.navit",VERSION, TRUE, NULL);  
    if (osso_context == NULL) {  
	dbg(0, "error initiating osso context\n");  
    }  
    osso_hw_set_event_cb(osso_context, NULL, osso_cb_hw_state, NULL);  

    /* add callback to unblank screen on gps event */  
    //navit_add_callback(this_, callback_new_attr_0(callback_cast(plugin_osso_display_on), attr_unsuspend_));
}

void
plugin_deinit(void) 
{
    osso_deinitialize(osso_context); 
}