/** * Update the proximity monitoring */ static void update_proximity_monitor(void) { static gboolean old_enable = FALSE; /* Default to keeping the proximity sensor always enabled. */ gboolean enable = TRUE; if( !use_ps_conf_value ) { enable = FALSE; if( ps_acts_as_lid ) report_lid_input(COVER_UNDEF); else report_proximity(COVER_OPEN); } if( old_enable == enable ) goto EXIT; if( (old_enable = enable) ) { enable_proximity_monitor(); } else { disable_proximity_monitor(); } EXIT: return; }
/** * Update the proximity monitoring */ static void update_proximity_monitor(void) { static gboolean old_enable = FALSE; gboolean enable = FALSE; gboolean fake_open = FALSE; /* Default to keeping the proximity sensor always enabled. */ enable = TRUE; if( !use_ps_conf_value ) { fake_open = TRUE; enable = FALSE; } if( old_enable == enable ) goto EXIT; if( (old_enable = enable) ) { enable_proximity_monitor(); } else { disable_proximity_monitor(); } EXIT: if( !enable && fake_open ) report_proximity(COVER_OPEN); }
/** * I/O monitor callback for the proximity sensor (sensorfw) * * @param covered proximity sensor covered */ static void ps_sensorfw_iomon_cb(bool covered) { cover_state_t proximity_sensor_state = COVER_UNDEF; if( covered ) proximity_sensor_state = COVER_CLOSED; else proximity_sensor_state = COVER_OPEN; report_proximity(proximity_sensor_state); return; }
/** GConf callback for use proximity sensor setting * * @param gcc (not used) * @param id Connection ID from gconf_client_notify_add() * @param entry The modified GConf entry * @param data (not used) */ static void use_ps_conf_cb(GConfClient *const gcc, const guint id, GConfEntry *const entry, gpointer const data) { (void)gcc; (void)data; const GConfValue *gcv; if( !(gcv = gconf_entry_get_value(entry)) ) { mce_log(LL_WARN, "GConf value removed; confused!"); goto EXIT; } if( id == use_ps_conf_id ) { gboolean old = use_ps_conf_value; use_ps_conf_value = gconf_value_get_bool(gcv); if( use_ps_conf_value == old ) goto EXIT; } else if( id == ps_acts_as_lid_conf_id ) { gboolean old = ps_acts_as_lid; ps_acts_as_lid = gconf_value_get_bool(gcv); if( ps_acts_as_lid == old ) goto EXIT; if( ps_acts_as_lid ) { // ps is lid now -> set ps to open state report_proximity(COVER_OPEN); } else { // ps is ps again -> invalidate lid state report_lid_input(COVER_UNDEF); } } else { mce_log(LL_WARN, "Spurious GConf value received; confused!"); goto EXIT; } update_proximity_monitor(); EXIT: return; }
const gchar *g_module_check_init(GModule *module) { (void)module; /* Get initial state of datapipes */ call_state = datapipe_get_gint(call_state_pipe); alarm_ui_state = datapipe_get_gint(alarm_ui_state_pipe); display_state = display_state_get(); submode = datapipe_get_gint(submode_pipe); /* Append triggers/filters to datapipes */ append_input_trigger_to_datapipe(&call_state_pipe, call_state_trigger); append_input_trigger_to_datapipe(&alarm_ui_state_pipe, alarm_ui_state_trigger); append_output_trigger_to_datapipe(&display_state_pipe, display_state_trigger); append_output_trigger_to_datapipe(&submode_pipe, submode_trigger); /* PS enabled setting */ mce_setting_track_bool(MCE_SETTING_PROXIMITY_PS_ENABLED, &use_ps_conf_value, MCE_DEFAULT_PROXIMITY_PS_ENABLED, use_ps_conf_cb, &use_ps_conf_id); /* PS acts as LID sensor */ mce_setting_track_bool(MCE_SETTING_PROXIMITY_PS_ACTS_AS_LID, &ps_acts_as_lid, MCE_DEFAULT_PROXIMITY_PS_ACTS_AS_LID, use_ps_conf_cb, &ps_acts_as_lid_conf_id); /* If the proximity sensor input is used for toggling * lid state, we must take care not to leave proximity * tracking to covered state. */ if( ps_acts_as_lid ) report_proximity(COVER_OPEN); /* enable/disable sensor based on initial conditions */ update_proximity_monitor(); return NULL; }