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_gconf_notifier_add(MCE_GCONF_PROXIMITY_PATH, MCE_GCONF_PROXIMITY_PS_ENABLED_PATH, use_ps_conf_cb, &use_ps_conf_id); mce_gconf_get_bool(MCE_GCONF_PROXIMITY_PS_ENABLED_PATH, &use_ps_conf_value); /* enable/disable sensor based on initial conditions */ update_proximity_monitor(); return NULL; }
/** 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; }
/** 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( id != use_ps_conf_id ) { mce_log(LL_WARN, "Spurious GConf value received; confused!"); goto EXIT; } if( !(gcv = gconf_entry_get_value(entry)) ) { // config removed -> use proximity sensor use_ps_conf_value = TRUE; } else { use_ps_conf_value = gconf_value_get_bool(gcv); } update_proximity_monitor(); EXIT: return; }
/** Handle submode change * * @param data The submode stored in a pointer */ static void submode_trigger(gconstpointer data) { submode = GPOINTER_TO_INT(data); update_proximity_monitor(); }
/** * Handle display state change * * @param data The display state stored in a pointer */ static void display_state_trigger(gconstpointer data) { display_state = GPOINTER_TO_INT(data); update_proximity_monitor(); }
/** * Handle alarm ui state change * * @param data The alarm state stored in a pointer */ static void alarm_ui_state_trigger(gconstpointer const data) { alarm_ui_state = GPOINTER_TO_INT(data); update_proximity_monitor(); }