Logo Search packages:      
Sourcecode: ladish version File versions  Download package

ladish_app_handle ladish_app_supervisor_add ( ladish_app_supervisor_handle  supervisor_handle,
const char *  name,
uuid_t  uuid,
bool  autorun,
const char *  command,
bool  terminal,
uint8_t  level 
)

Add app. Apps are added in stopped state

Parameters:
[in]supervisor_handlesupervisor object handle
[in]nameName of the app
[in]uuidOptional uuid of the app. If NULL, new uuid will be generated.
[in]autorunwhether to start the app when ladish_app_supervisor_autorun() is called
[in]commandCommandline that is used to start the app
[in]terminalWhether the app is started in terminal
[in]levelThe level that app was started in
Returns:
app handle on success; NULL on failure; the app handle is owned by the app supervisor object

Definition at line 250 of file app_supervisor.c.

References LADISH_APP_STATE_STOPPED.

{
  struct ladish_app * app_ptr;
  dbus_bool_t running;

  app_ptr = malloc(sizeof(struct ladish_app));
  if (app_ptr == NULL)
  {
    log_error("malloc of struct ladish_app failed");
    return NULL;
  }

  app_ptr->name = strdup(name);
  if (app_ptr->name == NULL)
  {
    log_error("strdup() failed for app name");
    free(app_ptr);
    return NULL;
  }

  app_ptr->commandline = strdup(command);
  if (app_ptr->commandline == NULL)
  {
    log_error("strdup() failed for app commandline");
    free(app_ptr->name);
    free(app_ptr);
    return NULL;
  }

  app_ptr->terminal = terminal;
  app_ptr->level = level;
  app_ptr->pid = 0;
  app_ptr->pgrp = 0;
  app_ptr->firstborn_pid = 0;
  app_ptr->firstborn_pgrp = 0;
  app_ptr->firstborn_refcount = 0;

  app_ptr->id = supervisor_ptr->next_id++;
  if (uuid == NULL || uuid_is_null(uuid))
  {
    uuid_generate(app_ptr->uuid);
  }
  else
  {
    uuid_copy(app_ptr->uuid, uuid);
  }

  app_ptr->zombie = false;
  app_ptr->state = LADISH_APP_STATE_STOPPED;
  app_ptr->autorun = autorun;
  list_add_tail(&app_ptr->siblings, &supervisor_ptr->applist);

  supervisor_ptr->version++;

  running = false;
  dbus_signal_emit(
    g_dbus_connection,
    supervisor_ptr->opath,
    IFACE_APP_SUPERVISOR,
    "AppAdded",
    "ttsbby",
    &supervisor_ptr->version,
    &app_ptr->id,
    &app_ptr->name,
    &running,
    &terminal,
    &app_ptr->level);

  return (ladish_app_handle)app_ptr;
}

Generated by  Doxygen 1.6.0   Back to index