Exemplo n.º 1
0
void ProjectHandlerTest::initTestCase()
{
    QStandardPaths::enableTestMode(true);

    QString projectTestPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
    Q_ASSERT(!projectTestPath.isEmpty());

    if (!projectTestPath.endsWith(QLatin1Char('/'))) {
        projectTestPath += QLatin1Char('/');
    }

    const QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QLatin1Char('/');

    m_testPackagePath = projectTestPath + testPackage;
    m_externalTestPackagePath = tempPath + externalTestPackage;

    removeConfig();
}
Exemplo n.º 2
0
int
main(int argc, char** argv)
{
  if (argc == 1) {
    fprintf(stderr, "Usage: %s (save|load|add|delete|rename|select|list|statusbar|toggle_statusbar|checkupdate|set_checkupdate) [params]\n", argv[0]);
    return 1;
  }

  bool isSuccess = false;

  if (strcmp(argv[1], "select") == 0) {
    if (argc < 3) {
      fprintf(stderr, "Usage: %s select index\n", argv[0]);
      goto finish;
    }
    int index = atoi(argv[2]);
    isSuccess = setSelectedIndex(index);

  } else if (strcmp(argv[1], "add") == 0) {
    isSuccess = appendConfig();

  } else if (strcmp(argv[1], "delete") == 0) {
    if (argc < 3) {
      fprintf(stderr, "Usage: %s delete index\n", argv[0]);
      goto finish;
    }
    int index = atoi(argv[2]);
    isSuccess = removeConfig(index);

  } else if (strcmp(argv[1], "rename") == 0) {
    // sysctl_ctl rename "index" "newname"
    if (argc < 4) {
      fprintf(stderr, "Usage: %s rename index newname\n", argv[0]);
      goto finish;
    }
    int index = atoi(argv[2]);
    char buf[512];
    snprintf(buf, sizeof(buf), "%s", argv[3]);
    stripString(buf, sizeof(buf));
    if (buf[0] == '\0') {
      snprintf(buf, sizeof(buf), "(null)");
    }
    isSuccess = renameConfig(index, buf);

  } else if (strcmp(argv[1], "list") == 0) {
    outputConfigList();
    return 0;

  } else if (strcmp(argv[1], "statusbar") == 0) {
    printf("%ld\n", getValue(CFSTR("isStatusbarEnable")));
    return 0;

  } else if (strcmp(argv[1], "toggle_statusbar") == 0) {
    CFStringRef name = CFSTR("isStatusbarEnable");
    CFIndex value = getValue(name);
    isSuccess = setValue(name, ! value);

  } else if (strcmp(argv[1], "checkupdate") == 0) {
    printf("%ld\n", getValue(CFSTR("isCheckUpdate")));
    return 0;

  } else if (strcmp(argv[1], "set_checkupdate") == 0) {
    if (argc < 3) {
      fprintf(stderr, "Usage: %s set_checkupdate value\n", argv[0]);
      goto finish;
    }

    CFStringRef name = CFSTR("isCheckUpdate");
    CFIndex value = atoi(argv[2]);
    isSuccess = setValue(name, value);

  } else if ((strcmp(argv[1], "save") == 0) || (strcmp(argv[1], "load") == 0)) {
    CFIndex value = getSelectedIndex();
    CFStringRef identify = getIdentify(value);

    const char* targetFiles[] = {
      "/Library/org.pqrs/KeyRemap4MacBook/prefpane/checkbox.xml",
      "/Library/org.pqrs/KeyRemap4MacBook/prefpane/number.xml",
      NULL,
    };
    if (strcmp(argv[1], "save") == 0) {
      isSuccess = saveToFile(targetFiles, identify);
    }
    if (strcmp(argv[1], "load") == 0) {
      system("/Library/org.pqrs/KeyRemap4MacBook/bin/KeyRemap4MacBook_sysctl_reset");
      isSuccess = loadFromFile(targetFiles, identify);
    }
  }

  CFPreferencesAppSynchronize(applicationID);

finish:
  if (isSuccess) {
    fprintf(stderr, "[DONE]\n");
  } else {
    fprintf(stderr, "[ERROR]\n");
  }

  return 0;
}
Exemplo n.º 3
0
void ProjectHandlerTest::cleanupTestCase()
{
    QDir(m_testPackagePath).removeRecursively();
    QDir(m_externalTestPackagePath).removeRecursively();
    removeConfig();
}
Exemplo n.º 4
0
void BtsSpawnClient::procStarted()
{
	emit clientStarted();
	QTimer::singleShot(10000, this, SLOT(removeConfig()));
}