Example #1
0
/**
 * Constraucts a Libertine application wrapper object.
 * @param[in] argc  The count of the number of command-line arguments.
 * @param[in] argv  A vector of command-line arguments.
 *
 * Sets up the Libertine application from the command-line arguments,
 * environment variables, and configurations files and displays the GUI.
 */
Libertine::
Libertine(int argc, char* argv[])
: QGuiApplication(argc, argv)
, main_qml_source_file_(find_main_qml_source_file())
{
  setApplicationName(LIBERTINE_APPLICATION_NAME);
  setApplicationVersion(LIBERTINE_VERSION);
  config_.reset(new LibertineConfig(*this));
  qmlRegisterType<ContainerConfig>("Libertine", 1, 0, "ContainerConfig");
  qmlRegisterType<ContainerManagerWorker>("Libertine", 1, 0, "ContainerManagerWorker");
  qmlRegisterType<PasswordHelper>("Libertine", 1, 0, "PasswordHelper");

  initialize_python();

  if (main_qml_source_file_.isEmpty())
  {
    qWarning() << "Can not locate " << s_main_QML_source_file;
  }

  containers_ = new ContainerConfigList(config_.data(), this);
  container_apps_ = new ContainerAppsList(containers_, this);
  password_helper_ = new PasswordHelper();

  initialize_view();
  view_.show();
}
Example #2
0
int zn_shell_exec(command *cmd)
{
  pid_t pid;
  int status = 0;
  char* arglist[MAX_ARG_LIST];
  char* appname = command_next_arg(cmd);
  char  path_buffer[FILENAME_MAX];
  arglist[0] = appname;
  bool wait_for_pid = true;
  
  if (*appname != '/') {
    appname = _find_file_in_path(path_buffer, appname);
    if (!appname) {
      display_err("%s not found\n", arglist[0]);
      return -1;
    }
  }

  int c = 1;

  while (c < MAX_ARG_LIST) {
    char* arg = (char*)command_next_arg(cmd);
    if (arg && strcmp(arg, "&") == 0) {
      wait_for_pid = false;
    } else {
      arglist[c++] = arg;
    }
    if (arg == NULL) break; /* break after writing null to term the list. */
  }

  /* Special shell view should be suspended until shell resumes. */
  close_view();

  switch(pid = fork()) {
  case -1:
    /* Fork failed! */
    fprintf(stderr, "Failed to execute.\n");
    break;
  case 0: 
    /* Child process */
    status = execve(appname, arglist, zn_env);
    /* If we got here, exec failed. TODO: Figure out why. */
    fprintf(stderr, "Failed to execute %s.\n", appname);
    exit(status);
  default:
    /* Parent */
    if (wait_for_pid) {
      if (waitpid(pid, &status, 0) < 0) {
	/* Wait for pid failed!! */
	fprintf(stderr, "System error tracking process %s\n", appname);
      }
      if ( !WIFEXITED(status)) {      
	fprintf(stderr, "Debug, system error -- exit failure?\n");
      }
    } else {
      printf("Started Process %d\n", pid);
    }

    initialize_view();

  }

  return status;
}