/** Handle addition of UPowerd device object */ static gboolean xup_device_added_cb(DBusMessage *const msg) { DBusError err = DBUS_ERROR_INIT; const char *path = 0; if( !dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &path, DBUS_TYPE_INVALID) ) { mce_log(LL_ERR, "%s: %s", err.name, err.message); goto EXIT; } mce_log(LL_DEBUG, "dev = %s", path); xup_properties_get_all(path); EXIT: dbus_error_free(&err); return TRUE; }
/** * Init function for the mce-modules component * * @return TRUE on success, FALSE on failure */ gboolean mce_modules_init(void) { gchar **modlist = NULL; gsize length; gchar *path = NULL; /* Get the module path */ path = mce_conf_get_string(MCE_CONF_MODULES_GROUP, MCE_CONF_MODULES_PATH, DEFAULT_MCE_MODULE_PATH); /* Get the list modules to load */ modlist = mce_conf_get_string_list(MCE_CONF_MODULES_GROUP, MCE_CONF_MODULES_MODULES, &length); if (modlist != NULL) { gint i; for (i = 0; modlist[i]; i++) { GModule *module; gchar *tmp = mce_modules_build_path(path, modlist[i]); mce_log(LL_INFO, "Loading module: %s from %s", modlist[i], path); if ((module = g_module_open(tmp, 0)) != NULL) { /* XXX: check dependencies, conflicts, et al */ modules = g_slist_prepend(modules, module); } else { const char *err = g_module_error(); mce_log(LL_ERR, "%s", err ?: "unknown error"); mce_log(LL_ERR, "Failed to load module: %s; skipping", modlist[i]); } g_free(tmp); } g_strfreev(modlist); }
/** * Send the call state and type * * @param method_call A DBusMessage to reply to; * pass NULL to send a signal instead * @param call_state A string representation of an alternate state * to send instead of the real call state * @param call_type A string representation of an alternate type * to send instead of the real call type * @return TRUE on success, FALSE on failure */ static gboolean send_call_state(DBusMessage *const method_call, const gchar *const call_state, const gchar *const call_type) { DBusMessage *msg = NULL; gboolean status = FALSE; const gchar *sstate; const gchar *stype; /* Allow spoofing */ if (call_state != NULL) sstate = call_state; else sstate = call_state_repr(datapipe_get_gint(call_state_pipe)); if (call_type != NULL) stype = call_type; else stype = call_type_repr(datapipe_get_gint(call_type_pipe)); /* If method_call is set, send a reply, * otherwise, send a signal */ if (method_call != NULL) { msg = dbus_new_method_reply(method_call); } else { /* sig_call_state_ind */ msg = dbus_new_signal(MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_CALL_STATE_SIG); } /* Append the call state and call type */ if (dbus_message_append_args(msg, DBUS_TYPE_STRING, &sstate, DBUS_TYPE_STRING, &stype, DBUS_TYPE_INVALID) == FALSE) { mce_log(LL_CRIT, "Failed to append %sarguments to D-Bus message " "for %s.%s", method_call ? "reply " : "", method_call ? MCE_REQUEST_IF : MCE_SIGNAL_IF, method_call ? MCE_CALL_STATE_GET : MCE_CALL_STATE_SIG); dbus_message_unref(msg); goto EXIT; } /* Send the message */ status = dbus_send_message(msg); EXIT: return status; }
/** Handle reply to asynchronous connman properties query * * @param pc State data for asynchronous D-Bus method call * @param user_data (not used) */ static void xconnman_get_properties_cb(DBusPendingCall *pc, void *user_data) { (void)user_data; DBusMessage *rsp = 0; DBusError err = DBUS_ERROR_INIT; const char *key = 0; dbus_any_t val = DBUS_ANY_INIT; int vtype; DBusMessageIter miter, aiter, diter, viter; if( !(rsp = dbus_pending_call_steal_reply(pc)) ) goto EXIT; if( dbus_set_error_from_message(&err, rsp) ) { mce_log(LL_WARN, "%s: %s", err.name, err.message); goto EXIT; } if( !dbus_message_iter_init(rsp, &miter) ) goto EXIT; if( dbus_message_iter_get_arg_type(&miter) != DBUS_TYPE_ARRAY ) goto EXIT; dbus_message_iter_recurse(&miter, &aiter); while( dbus_message_iter_get_arg_type(&aiter) == DBUS_TYPE_DICT_ENTRY ) { dbus_message_iter_recurse(&aiter, &diter); dbus_message_iter_next(&aiter); if( dbus_message_iter_get_arg_type(&diter) != DBUS_TYPE_STRING ) goto EXIT; dbus_message_iter_get_basic(&diter, &key); dbus_message_iter_next(&diter); if( dbus_message_iter_get_arg_type(&diter) != DBUS_TYPE_VARIANT ) goto EXIT; dbus_message_iter_recurse(&diter, &viter); vtype = dbus_message_iter_get_arg_type(&viter); if( !dbus_type_is_basic(vtype) ) continue; dbus_message_iter_get_basic(&viter, &val); xconnman_property_changed(key, vtype, &val); } EXIT: if( rsp ) dbus_message_unref(rsp); dbus_error_free(&err); }
/** D-Bus callback for the MCE_CPU_KEEPALIVE_PERIOD_REQ method call * * @param msg The D-Bus message * * @return TRUE on success, FALSE on failure */ static gboolean cka_dbus_handle_period_cb(DBusMessage *const msg) { gboolean success = FALSE; DBusError err = DBUS_ERROR_INIT; const char *sender = 0; const char *session_id = 0; if( !(sender = dbus_message_get_sender(msg)) ) { goto EXIT; } mce_log(LL_NOTICE, "got keepalive period query from %s", mce_dbus_get_name_owner_ident(sender)); if( !dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &session_id, DBUS_TYPE_INVALID) ) { // initial dbus interface did not include session_id string if( strcmp(err.name, DBUS_ERROR_INVALID_ARGS) ) { mce_log(LL_WARN, "%s: %s", err.name, err.message); goto EXIT; } session_id = SESSION_ID_INITIAL; mce_log(LL_DEBUG, "sender did not supply session_id string; using '%s'", session_id); } cka_clients_add_session(sender, session_id); success = cka_dbusutil_reply_int(msg, MCE_CPU_KEEPALIVE_SUGGESTED_PERIOD_S); EXIT: dbus_error_free(&err); return success; }
/** * Send an inactivity status reply or signal * * @param method_call A DBusMessage to reply to; * pass NULL to send an inactivity status signal instead * @return TRUE on success, FALSE on failure */ static gboolean send_inactivity_status(DBusMessage *const method_call) { DBusMessage *msg = NULL; gboolean status = FALSE; mce_log(LL_DEBUG, "Sending inactivity status: %s", device_inactive ? "inactive" : "active"); /* If method_call is set, send a reply, * otherwise, send a signal */ if (method_call != NULL) { msg = dbus_new_method_reply(method_call); } else { /* system_inactivity_ind */ msg = dbus_new_signal(MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_INACTIVITY_SIG); } /* Append the inactivity status */ if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &device_inactive, DBUS_TYPE_INVALID) == FALSE) { mce_log(LL_CRIT, "Failed to append %sargument to D-Bus message " "for %s.%s", method_call ? "reply " : "", method_call ? MCE_REQUEST_IF : MCE_SIGNAL_IF, method_call ? MCE_INACTIVITY_STATUS_GET : MCE_INACTIVITY_SIG); dbus_message_unref(msg); goto EXIT; } /* Send the message */ status = dbus_send_message(msg); EXIT: return status; }
/** * Send the PSM state * * @param method_call A DBusMessage to reply to; * pass NULL to send a signal instead * @return TRUE on success, FALSE on failure */ static gboolean send_psm_state(DBusMessage *const method_call) { DBusMessage *msg = NULL; gboolean status = FALSE; mce_log(LL_DEBUG, "Sending PSM state: %s", active_power_saving_mode ? "TRUE" : "FALSE"); /* If method_call is set, send a reply, * otherwise, send a signal */ if (method_call != NULL) { msg = dbus_new_method_reply(method_call); } else { /* psm_state_ind */ msg = dbus_new_signal(MCE_SIGNAL_PATH, MCE_SIGNAL_IF, MCE_PSM_STATE_SIG); } /* Append the power saving mode */ if (dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &active_power_saving_mode, DBUS_TYPE_INVALID) == FALSE) { mce_log(LL_CRIT, "Failed to append %sargument to D-Bus message " "for %s.%s", method_call ? "reply " : "", method_call ? MCE_REQUEST_IF : MCE_SIGNAL_IF, method_call ? MCE_PSM_STATE_GET : MCE_PSM_STATE_SIG); dbus_message_unref(msg); goto EXIT; } /* Send the message */ status = dbus_send_message(msg); EXIT: return status; }
/** * Install alarm D-Bus service monitor callback. * * @param sender sender D-Bus address */ static void setup_alarm_dbus_monitor(const gchar* sender) { mce_log(LL_DEBUG, "adding dbus monitor for: '%s'" ,sender); /* No need to check return value, if it does not succeed, not much * we can do / fall back to */ mce_dbus_owner_monitor_add(sender, alarm_owner_monitor_dbus_cb, &alarm_owner_monitor_list, ALARM_MAX_MONITORED); }
static int convert_log(struct mc_info *mi) { struct mcinfo_common *mic = NULL; struct mcinfo_global *mc_global; struct mcinfo_bank *mc_bank; struct mce m; unsigned int i; bool found = false; x86_mcinfo_lookup(mic, mi, MC_TYPE_GLOBAL); if (mic == NULL) { printk(KERN_ERR "DOM0_MCE_LOG: global data is NULL\n"); return -1; } mce_setup(&m); mc_global = (struct mcinfo_global*)mic; m.mcgstatus = mc_global->mc_gstatus; m.apicid = mc_global->mc_apicid; for (i = 0; i < ncpus; i++) if (g_physinfo[i].mc_apicid == m.apicid) { found = true; break; } WARN_ON_ONCE(!found); m.socketid = g_physinfo[i].mc_chipid; m.cpu = m.extcpu = g_physinfo[i].mc_cpunr; m.cpuvendor = (__u8)g_physinfo[i].mc_vendor; x86_mcinfo_lookup(mic, mi, MC_TYPE_BANK); do { if (mic == NULL || mic->size == 0) break; if (mic->type == MC_TYPE_BANK) { mc_bank = (struct mcinfo_bank*)mic; m.misc = mc_bank->mc_misc; m.status = mc_bank->mc_status; m.addr = mc_bank->mc_addr; m.tsc = mc_bank->mc_tsc; m.bank = mc_bank->mc_bank; printk(KERN_DEBUG "[CPU%d, BANK%d, addr %llx, state %llx]\n", m.bank, m.cpu, m.addr, m.status); /*log this record*/ mce_log(&m); } mic = x86_mcinfo_next(mic); }while (1); return 0; }
/** * Request normal shutdown */ void request_normal_shutdown(void) { /* Set up the message */ DSM_MSGTYPE_SHUTDOWN_REQ msg = DSME_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ); /* Send the message */ mce_dsme_send(&msg); mce_log(LL_DEBUG, "DSM_MSGTYPE_SHUTDOWN_REQ (DSME_NORMAL_SHUTDOWN) " "sent to DSME"); }
/** Handle reply to async UPower device enumeration query */ static void xup_enumerate_devices_cb(DBusPendingCall *pc, void *aptr) { (void)aptr; bool res = false; DBusError err = DBUS_ERROR_INIT; DBusMessage *rsp = 0; char **vec = 0; int cnt = 0; if( !(rsp = dbus_pending_call_steal_reply(pc)) ) goto EXIT; if( dbus_set_error_from_message(&err, rsp) ) { mce_log(LL_ERR, "%s: %s", err.name, err.message); goto EXIT; } if( !dbus_message_get_args(rsp, &err, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &vec, &cnt, DBUS_TYPE_INVALID) ) { mce_log(LL_ERR, "%s: %s", err.name, err.message); goto EXIT; } for( int i = 0; i < cnt; ++i ) { mce_log(LL_DEBUG, "[%d] '%s'", i, vec[i]); xup_properties_get_all(vec[i]); } res = true; EXIT: if( !res ) mce_log(LL_WARN, "failed to parse reply"); dbus_free_string_array(vec); if( rsp ) dbus_message_unref(rsp); dbus_error_free(&err); }
/** Restore the radio states from persistant storage */ static void mrs_restore_radio_states(void) { static const char online_file[] = MCE_ONLINE_RADIO_STATES_PATH; static const char offline_file[] = MCE_OFFLINE_RADIO_STATES_PATH; /* Apply configured defaults */ active_radio_states = saved_radio_states = mrs_get_default_radio_states(); /* FIXME: old maemo backup/restore handling - can be removed? */ if( mce_are_settings_locked() ) { if( mce_unlock_settings() ) mce_log(LL_INFO, "Removed stale settings lockfile"); else mce_log(LL_ERR, "Failed to remove settings lockfile; %m"); } /* The files get generated by mce on 1st bootup. Skip the * read attempt and associated diagnostic logging if the * files do not exist */ if( access(online_file, F_OK) == -1 && errno == ENOENT ) goto EXIT; gulong online_states = 0; gulong offline_states = 0; if( mce_read_number_string_from_file(online_file, &online_states, NULL, TRUE, TRUE) ) active_radio_states = (guint)online_states; if( mce_read_number_string_from_file(offline_file, &offline_states, NULL, TRUE, TRUE) ) saved_radio_states = (guint)offline_states; EXIT: mce_log(LL_DEBUG, "active_radio_states: %s", radio_states_repr(active_radio_states)); mce_log(LL_DEBUG, "saved_radio_states: %s", radio_states_repr(saved_radio_states)); return; }
/** * D-Bus callback for the get color profile method call * * @param msg The D-Bus message * @return TRUE */ static gboolean color_profile_get_req_dbus_cb(DBusMessage *const msg) { mce_log(LL_DEBUG, "Received get color profile request"); if( dbus_message_get_no_reply(msg) ) goto EXIT; send_current_color_profile(msg); EXIT: return TRUE; }
/** Exit function for the memnotify plugin * * @param module (not used) */ void g_module_unload(GModule *module) { (void)module; mce_log(LL_DEBUG, "unloading memnotify plugin"); memnotify_gconf_quit(); memnotify_dbus_quit(); memnotify_dev_close_all(); return; }
/** * Register to DSME process watchdog */ static void dsme_init_processwd(void) { /* Set up the message */ DSM_MSGTYPE_PROCESSWD_CREATE msg = DSME_MSG_INIT(DSM_MSGTYPE_PROCESSWD_CREATE); msg.pid = getpid(); /* Send the message */ mce_dsme_send(&msg); mce_log(LL_DEBUG, "DSM_MSGTYPE_PROCESSWD_CREATE sent to DSME"); }
/** Cancel end of cpu-keepalive timer */ static void cka_state_reset(void) { if( cka_state_timer_id != 0 ) { mce_log(LL_DEBUG, "cpu-keepalive timeout canceled"); g_source_remove(cka_state_timer_id), cka_state_timer_id = 0; } cka_state_set(false); }
/** Create oFono modem tracking object * * @param name D-Bus object path * * @return object pointer */ static ofono_modem_t * ofono_modem_create(const char *path) { ofono_modem_t *self = calloc(1, sizeof *self); self->name = g_strdup(path); self->probed = false; self->emergency = false; mce_log(LL_DEBUG, "modem=%s", self->name); return self; }
/** Finish a keepalive session * * @param self session object * @param now current time */ static void cka_session_finish(cka_session_t *self, tick_t now) { tick_t dur = now - self->ses_started; if( dur > KEEPALIVE_SESSION_WARN_LIMIT_MS ) { mce_log(LL_CRIT, "long session lasted %"PRId64" ms; id=%u/%s %s", dur, self->ses_unique, self->ses_session, cka_client_identify(self->ses_client)); } else { mce_log(LL_DEVEL, "session lasted %"PRId64" ms; id=%u/%s %s", dur, self->ses_unique, self->ses_session, cka_client_identify(self->ses_client)); } self->ses_finished = true; }
/** Set the radio states * * @param states The raw radio states * @param mask The raw radio states mask */ static void mrs_modify_radio_states(const guint states, const guint mask) { mce_log(LL_DEBUG, "states: %s", radio_states_change_repr(states ^ mask, states)); guint prev = active_radio_states; /* Deal with master bit changes first */ if( (mask & MCE_RADIO_STATE_MASTER) && ((active_radio_states ^ states) & MCE_RADIO_STATE_MASTER) ) { if( active_radio_states & MCE_RADIO_STATE_MASTER ) { /* Master disable: save & clear state */ saved_radio_states = active_radio_states; active_radio_states = 0; } else { /* Master enable: resture saved state */ active_radio_states = saved_radio_states; } } /* Then update active features bits */ active_radio_states = (active_radio_states & ~mask) | (states & mask); /* Immediate actions on state change */ if( prev != active_radio_states ) { mce_log(LL_DEBUG, "active_radio_states: %s", radio_states_change_repr(prev, active_radio_states)); /* Update persistent values */ mrs_save_radio_states(); /* Broadcast changes */ mrs_dbus_send_radio_states(NULL); } /* Do datapipe & connman sync from idle callback */ mrs_schedule_radio_state_sync(); }
/** Open memonotify device node and install io watch for it */ static bool memnotify_dev_open(memnotify_level_t lev) { bool res = false; if( !memnotify_dev[lev].mnd_in_use ) goto EXIT; if( (memnotify_dev[lev].mnd_fd = open(memnotify_dev_path, O_RDWR)) == -1 ) { mce_log(LL_ERR, "could not open: %s: %m", memnotify_dev_path); goto EXIT; } memnotify_dev[lev].mnd_rx_id = memnotify_iowatch_add(memnotify_dev[lev].mnd_fd, false, G_IO_IN, memnotify_dev_rx_cb, GINT_TO_POINTER(lev)); if( !memnotify_dev[lev].mnd_rx_id ) { mce_log(LL_ERR, "could add iowatch: %s", memnotify_dev_path); goto EXIT; } if( !memnotify_dev_get_status(lev, &memnotify_state) ) goto EXIT; res = true; memnotify_status_update_level(); EXIT: // all or nothing if( !res ) memnotify_dev_close(lev); return res; }
/** GConf callback for memnotify related settings * * @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 memnotify_gconf_cb(GConfClient *const gcc, const guint id, GConfEntry *const entry, gpointer const data) { const GConfValue *gcv = gconf_entry_get_value(entry); (void)gcc; (void)data; /* Key is unset */ if (gcv == NULL) { mce_log(LL_DEBUG, "GConf Key `%s' has been unset", gconf_entry_get_key(entry)); goto EXIT; } if( id == memnotify_gconf_warning_used_id ) { gint old = memnotify_limit[MEMNOTIFY_LEVEL_WARNING].mnl_used; gint val = gconf_value_get_int(gcv); if( old != val ) { mce_log(LL_DEBUG, "memnotify.warning.used: %d -> %d", old, val); memnotify_limit[MEMNOTIFY_LEVEL_WARNING].mnl_used = val; memnotify_status_update_triggers(); } } else if( id == memnotify_gconf_warning_active_id ) { gint old = memnotify_limit[MEMNOTIFY_LEVEL_WARNING].mnl_active; gint val = gconf_value_get_int(gcv); if( old != val ) { mce_log(LL_DEBUG, "memnotify.warning.active: %d -> %d", old, val); memnotify_limit[MEMNOTIFY_LEVEL_WARNING].mnl_active = val; memnotify_status_update_triggers(); } } else if( id == memnotify_gconf_critical_used_id ) { gint old = memnotify_limit[MEMNOTIFY_LEVEL_CRITICAL].mnl_used; gint val = gconf_value_get_int(gcv); if( old != val ) { mce_log(LL_DEBUG, "memnotify.critical.used: %d -> %d", old, val); memnotify_limit[MEMNOTIFY_LEVEL_CRITICAL].mnl_used = val; memnotify_status_update_triggers(); } } else if( id == memnotify_gconf_critical_active_id ) { gint old = memnotify_limit[MEMNOTIFY_LEVEL_CRITICAL].mnl_active; gint val = gconf_value_get_int(gcv); if( old != val ) { mce_log(LL_DEBUG, "memnotify.critical.active: %d -> %d", old, val); memnotify_limit[MEMNOTIFY_LEVEL_CRITICAL].mnl_active = val; memnotify_status_update_triggers(); } } else { mce_log(LL_WARN, "Spurious GConf value received; confused!"); } EXIT: return; }
/** * Signal handler * * @param signr Signal type */ static void signal_handler(const gint signr) { switch (signr) { case SIGUSR1: /* switch to debug verbosity */ mce_log_set_verbosity(LL_DEBUG); mce_log(LL_DEBUG, "switching to DEBUG verbosity level"); break; case SIGUSR2: /* switch to normal verbosity */ mce_log_set_verbosity(LL_DEBUG); mce_log(LL_DEBUG, "switching to WARNING verbosity level"); mce_log_set_verbosity(LL_WARN); break; case SIGHUP: /* Possibly for re-reading configuration? */ break; case SIGINT: case SIGQUIT: case SIGTERM: /* Just die if we somehow get here without having a mainloop */ if( !mainloop ) { mce_exit_via_signal(signr); } /* Terminate mainloop */ mce_quit_mainloop(); break; case SIGPIPE: break; default: /* Should never happen */ break; } }
const gchar *g_module_check_init(GModule *module) { (void)module; /* Config from ini-files */ dbltap_ctrl_path = mce_conf_get_string(MCE_CONF_DOUBLETAP_GROUP, MCE_CONF_DOUBLETAP_CONTROL_PATH, NULL); dbltap_enable_val = mce_conf_get_string(MCE_CONF_DOUBLETAP_GROUP, MCE_CONF_DOUBLETAP_ENABLE_VALUE, "1"); dbltap_disable_val = mce_conf_get_string(MCE_CONF_DOUBLETAP_GROUP, MCE_CONF_DOUBLETAP_DISABLE_VALUE, "0"); if( !dbltap_ctrl_path || !dbltap_enable_val || !dbltap_disable_val ) { mce_log(LL_NOTICE, "no double tap wakeup controls defined"); goto EXIT; } dbltap_probe_sleep_mode_controls(); /* Runtime configuration settings */ mce_gconf_notifier_add(MCE_GCONF_DOUBLETAP_PATH, MCE_GCONF_DOUBLETAP_MODE, dbltap_mode_gconf_cb, &dbltap_mode_gconf_id); gint mode = DBLTAP_ENABLE_DEFAULT; mce_gconf_get_int(MCE_GCONF_DOUBLETAP_MODE, &mode); dbltap_mode = mode; /* Append triggers/filters to datapipes */ append_output_trigger_to_datapipe(&proximity_sensor_pipe, dbltap_proximity_trigger); append_output_trigger_to_datapipe(&proximity_blank_pipe, dbltap_proximity_blank_trigger); append_output_trigger_to_datapipe(&lid_cover_policy_pipe, dbltap_lid_cover_policy_trigger); /* Get initial state of datapipes */ dbltap_ps_state = datapipe_get_gint(proximity_sensor_pipe); dbltap_ps_blank = datapipe_get_gint(proximity_blank_pipe); dbltap_lid_cover_policy = datapipe_get_gint(lid_cover_policy_pipe); /* enable/disable double tap wakeups based on initial conditions */ dbltap_rethink(); EXIT: return NULL; }
/** * Logic for long key press * * @return TRUE on success, FALSE on failure */ static gboolean handle_longpress(void) { system_state_t state = datapipe_get_gint(system_state_pipe); alarm_ui_state_t alarm_ui_state = datapipe_get_gint(alarm_ui_state_pipe); submode_t submode = mce_get_submode_int32(); gboolean status = TRUE; /* Ignore keypress if the alarm UI is visible */ if ((alarm_ui_state == MCE_ALARM_UI_VISIBLE_INT32) || (alarm_ui_state == MCE_ALARM_UI_RINGING_INT32)) goto EXIT; /* Ignore if we're already shutting down/rebooting */ switch (state) { case MCE_STATE_SHUTDOWN: case MCE_STATE_REBOOT: status = FALSE; break; case MCE_STATE_ACTDEAD: request_powerup(); break; case MCE_STATE_USER: /* If softoff is enabled, wake up * Otherwise, perform long press action */ if ((submode & MCE_SOFTOFF_SUBMODE)) { request_soft_poweron(); } else { generic_powerkey_handler(longpressaction, longpresssignal); } break; default: /* If no special cases are needed, * just do a regular shutdown */ mce_log(LL_WARN, "Requesting shutdown; state: %d", state); request_normal_shutdown(); break; } EXIT: return status; }
/** Handle call_state_pipe notifications * * @param data (not used) */ static void mia_datapipe_call_state_cb(gconstpointer data) { call_state_t prev = call_state; call_state = GPOINTER_TO_INT(data); if( call_state == prev ) goto EXIT; mce_log(LL_DEBUG, "call_state = %s", call_state_repr(call_state)); EXIT: return; }
/** Handle submode_pipe notifications * * @param data The submode stored in a pointer */ static void mia_datapipe_submode_cb(gconstpointer data) { submode_t prev = submode; submode = GPOINTER_TO_INT(data); if( submode == prev ) goto EXIT; mce_log(LL_DEBUG, "submode = %d", submode); EXIT: return; }
const gchar *g_module_check_init(GModule *module) { (void)module; /* If we fail to restore the radio states, default to offline */ if( !restore_radio_states(&active_radio_states, &radio_states) && !restore_default_radio_states(&active_radio_states, &radio_states) ) { active_radio_states = radio_states = 0; } mce_log(LL_DEBUG, "active_radio_states: %lx, radio_states: %lx", active_radio_states, radio_states); /* Append triggers/filters to datapipes */ append_output_trigger_to_datapipe(&master_radio_pipe, master_radio_trigger); /* get_radio_states */ if (mce_dbus_handler_add(MCE_REQUEST_IF, MCE_RADIO_STATES_GET, NULL, DBUS_MESSAGE_TYPE_METHOD_CALL, get_radio_states_dbus_cb) == NULL) goto EXIT; /* req_radio_states_change */ if (mce_dbus_handler_add(MCE_REQUEST_IF, MCE_RADIO_STATES_CHANGE_REQ, NULL, DBUS_MESSAGE_TYPE_METHOD_CALL, req_radio_states_change_dbus_cb) == NULL) goto EXIT; if( !xconnman_init() ) mce_log(LL_WARN, "failed to set up connman mirroring"); EXIT: return NULL; }
/** Load ALS ramps into filtering state * * @param self ALS filtering state data */ static void als_filter_load_config(als_filter_t *self) { als_filter_init(self); char grp[64]; snprintf(grp, sizeof grp, "Brightness%s", self->id); if( !mce_conf_has_group(grp) ) { mce_log(LL_WARN, "[%s]: als config missing", grp); goto EXIT; } for( self->profiles = 0; self->profiles < ALS_PROFILE_COUNT; ++self->profiles ) { if( !als_filter_load_profile(self, grp, self->profiles) ) break; } if( self->profiles < 1 ) mce_log(LL_WARN, "[%s]: als config broken", grp); EXIT: return; }
/** * Set an string GConf key to the specified value * * @param key The GConf key to set the value of * @param value The value to set the key to * @return TRUE on success, FALSE on failure */ gboolean mce_gconf_set_string(const gchar *const key, const gchar *const value) { gboolean status = FALSE; if( gconf_disabled ) { mce_log(LL_DEBUG, "blocked %s = \"%s\"", key, value); goto EXIT; } if (gconf_client_set_string(gconf_client, key, value, NULL) == FALSE) { mce_log(LL_WARN, "Failed to write %s to GConf", key); goto EXIT; } /* synchronise if possible, ignore errors */ gconf_client_suggest_sync(gconf_client, NULL); status = TRUE; EXIT: return status; }
/** * Create a new D-Bus method call reply, with proper error checking * will exit the mainloop if an error occurs * * @param message The DBusMessage to reply to * @return A new DBusMessage */ DBusMessage *dbus_new_method_reply(DBusMessage *const message) { DBusMessage *msg; if ((msg = dbus_message_new_method_return(message)) == NULL) { mce_log(LL_CRIT, "No memory for new reply!"); // FIXME: this is not how one should exit from mainloop mce_quit_mainloop(); exit(EXIT_FAILURE); } return msg; }