Exemplo n.º 1
0
static int delayed_shutdown_fn(void* unused)
{
  DSM_MSGTYPE_SHUTDOWN msg = DSME_MSG_INIT(DSM_MSGTYPE_SHUTDOWN);
  msg.runlevel = state2runlevel(current_state);
  broadcast_internally(&msg);

  return 0; /* stop the interval */
}
Exemplo n.º 2
0
static void get_state(const DsmeDbusMessage* request, DsmeDbusMessage** reply)
{
    // first create a reply and append it to the list of yet unsent replies
    state_replies = g_slist_append(state_replies, dsme_dbus_reply_new(request));

    // then proxy the query to the internal message queue
    DSM_MSGTYPE_STATE_QUERY query = DSME_MSG_INIT(DSM_MSGTYPE_STATE_QUERY);
    broadcast_internally(&query);
}
Exemplo n.º 3
0
static void send_emergency_call_status(bool ongoing)
{
    DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE msg =
      DSME_MSG_INIT(DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE);

    msg.ongoing = ongoing;

    broadcast_internally(&msg);
}
Exemplo n.º 4
0
static void subscribe_to_wakeup(void)
{
    DSM_MSGTYPE_WAIT msg = DSME_MSG_INIT(DSM_MSGTYPE_WAIT);
    msg.req.mintime = 24;
    msg.req.maxtime = 30;
    msg.req.pid     = 0;
    msg.data        = 0;

    broadcast_internally(&msg);
}
Exemplo n.º 5
0
static void req_reboot(const DsmeDbusMessage* request, DsmeDbusMessage** reply)
{
  char* sender = dsme_dbus_endpoint_name(request);
  dsme_log(LOG_CRIT,
           "reboot request received over D-Bus from %s",
           sender ? sender : "(unknown)");
  free(sender);

  DSM_MSGTYPE_REBOOT_REQ req = DSME_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);
  broadcast_internally(&req);
}
Exemplo n.º 6
0
static void req_powerup(const DsmeDbusMessage* request, DsmeDbusMessage** reply)
{
  char* sender = dsme_dbus_endpoint_name(request);
  dsme_log(LOG_NOTICE,
           "powerup request received over D-Bus from %s",
           sender ? sender : "(unknown)");
  free(sender);

  DSM_MSGTYPE_POWERUP_REQ req = DSME_MSG_INIT(DSM_MSGTYPE_POWERUP_REQ);
  broadcast_internally(&req);
}
Exemplo n.º 7
0
static void send_usb_status(bool mounted_to_pc)
{
    DSM_MSGTYPE_SET_USB_STATE msg = DSME_MSG_INIT(DSM_MSGTYPE_SET_USB_STATE);

    msg.mounted_to_pc = mounted_to_pc;

    dsme_log(LOG_DEBUG,
             "usbtracker: broadcasting usb state:%s mounted to PC",
             msg.mounted_to_pc ? "" : " not");
    broadcast_internally(&msg);
}
Exemplo n.º 8
0
void module_init(module_t* handle)
{
  /* get dsme version so that we can report it over D-Bus if asked to */
  DSM_MSGTYPE_GET_VERSION req = DSME_MSG_INIT(DSM_MSGTYPE_GET_VERSION);
  broadcast_internally(&req);

  /* Do not connect to D-Bus; it is probably not started yet.
   * Instead, wait for DSM_MSGTYPE_DBUS_CONNECT.
   */

  dsme_log(LOG_DEBUG, "libdbusproxy.so loaded");
}
Exemplo n.º 9
0
static void send_charger_status(bool charger_state)
{
    DSM_MSGTYPE_SET_CHARGER_STATE msg = DSME_MSG_INIT(DSM_MSGTYPE_SET_CHARGER_STATE);

    msg.connected = charger_state;

    dsme_log(LOG_DEBUG,
             "usbtracker: broadcasting usb charger state:%s connected",
             msg.connected ? "" : " not");

    broadcast_internally(&msg);
}
Exemplo n.º 10
0
static void poweron_update_cb(void)
{
  // update cal data without forcing write
  pot_update_cal(in_user_mode, false);

  // schedule the next update wakeup
  DSM_MSGTYPE_WAIT msg = DSME_MSG_INIT(DSM_MSGTYPE_WAIT);
  msg.req.mintime = 10;
  msg.req.maxtime = 60;
  msg.req.pid     = 0;
  msg.data        = 0;

  broadcast_internally(&msg);
}
Exemplo n.º 11
0
static DBusHandlerResult
dsme_dbus_filter(DBusConnection *con, DBusMessage *msg, void *aptr)
{
    FILE* f;

    if( dbus_message_is_signal(msg, DBUS_INTERFACE_LOCAL, "Disconnected") ) {
      dsme_log(LOG_CRIT, "Disconnected from system bus; rebooting");
      /* mark failure and request reboot */
      if ((f = fopen(DBUS_FAILED_FILE, "w+")) != NULL)
	  fclose(f);
      DSM_MSGTYPE_REBOOT_REQ req = DSME_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);
      broadcast_internally(&req);
    }
    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
Exemplo n.º 12
0
static void enter_malf(const char* reason,
                       const char* component,
                       const char* details)
{
  char* malf_details   = details ? strdup(details) : 0;
  DSM_MSGTYPE_ENTER_MALF malf = DSME_MSG_INIT(DSM_MSGTYPE_ENTER_MALF);
  malf.reason          = strcmp(reason, "HARDWARE") ? DSME_MALF_SOFTWARE
                                                    : DSME_MALF_HARDWARE;
  malf.component       = strdup(component);

  if (malf_details) {
      broadcast_internally_with_extra(&malf,
                                      strlen(malf_details) + 1,
                                      malf_details);
  } else {
      broadcast_internally(&malf);
  }
}
Exemplo n.º 13
0
static gboolean emit_heartbeat_message(GIOChannel*  source,
                                       GIOCondition condition,
                                       gpointer     data)
{
    // handle errors
    if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {
        // the wd process has probably died; remove the watch & quit
        dsme_log(LOG_CRIT, "heartbeat: I/O error or HUP, terminating");
        dsme_main_loop_quit(EXIT_FAILURE);
        return false;
    }

    // first read the byte that woke us up
    ssize_t bytes_read;
    char    c;
    while ((bytes_read = read(STDIN_FILENO, &c, 1)) == -1 &&
           errno == EINTR)
    {
        // EMPTY LOOP
    }

    if (bytes_read == 1) {
        // got a ping from the wd process; respond with a pong
        ssize_t bytes_written;
        while ((bytes_written = write(STDOUT_FILENO, "*", 1)) == -1 &&
               (errno == EINTR))
        {
            // EMPTY LOOP
        }

        // send the heartbeat message
        const DSM_MSGTYPE_HEARTBEAT beat = DSME_MSG_INIT(DSM_MSGTYPE_HEARTBEAT);
        broadcast_internally(&beat);
        //dsme_log(LOG_DEBUG, "heartbeat");
        return true;
    } else {
        // got an EOF (or a read error); remove the watch
        dsme_log(LOG_DEBUG, "heartbeat: read() EOF or failure");
        return false;
    }
}
Exemplo n.º 14
0
/** Broadcast charger-is-connected status changes within DSME
 */
static void
send_charger_status(bool charger_connected)
{
    /* Initialize to value that does not match any boolean value */
    static int prev = -1;

    if( prev == charger_connected )
        goto cleanup;

    DSM_MSGTYPE_SET_CHARGER_STATE msg = DSME_MSG_INIT(DSM_MSGTYPE_SET_CHARGER_STATE);

    prev = msg.connected = charger_connected;

    dsme_log(LOG_DEBUG, PFIX"broadcasting usb charger state:%s connected",
             msg.connected ? "" : " not");

    broadcast_internally(&msg);

cleanup:

    return;
}
Exemplo n.º 15
0
/** Broadcast mounted-over-usb-cable status changes within DSME
 */
static void
send_usb_status(bool mounted_to_pc)
{
    /* Initialize to value that does not match any boolean value */
    static int prev = -1;

    if( prev == mounted_to_pc )
        goto cleanup;

    DSM_MSGTYPE_SET_USB_STATE msg = DSME_MSG_INIT(DSM_MSGTYPE_SET_USB_STATE);

    prev = msg.mounted_to_pc = mounted_to_pc;

    dsme_log(LOG_DEBUG, PFIX"broadcasting usb state:%s mounted to PC",
             msg.mounted_to_pc ? "" : " not");

    broadcast_internally(&msg);

cleanup:

    return;
}
Exemplo n.º 16
0
static void change_runlevel(dsme_state_t state)
{
  DSM_MSGTYPE_CHANGE_RUNLEVEL msg = DSME_MSG_INIT(DSM_MSGTYPE_CHANGE_RUNLEVEL);
  msg.runlevel = state2runlevel(state);
  broadcast_internally(&msg);
}