private void exportParameters() {
    synchronized (exported_parameters) {
      if (!exported_parameters_dirty) {

        return;
      }

      exported_parameters_dirty = false;

      try {
        TreeMap<String, String> tm = new TreeMap<String, String>();

        Set<String> exported_keys = new HashSet<String>();

        for (String[] entry : exported_parameters.values()) {

          String key = entry[0];
          String value = entry[1];

          exported_keys.add(key);

          if (value != null) {

            tm.put(key, value);
          }
        }

        for (Map.Entry<String, String> entry : imported_parameters.entrySet()) {

          String key = entry.getKey();

          if (!exported_keys.contains(key)) {

            tm.put(key, entry.getValue());
          }
        }

        File parent_dir = new File(SystemProperties.getUserPath());

        File props = new File(parent_dir, "exported_params.properties");

        PrintWriter pw =
            new PrintWriter(new OutputStreamWriter(new FileOutputStream(props), "UTF-8"));

        try {
          for (Map.Entry<String, String> entry : tm.entrySet()) {

            pw.println(entry.getKey() + "=" + entry.getValue());
          }

        } finally {

          pw.close();
        }
      } catch (Throwable e) {

        e.printStackTrace();
      }
    }
  }
示例#2
0
  protected String allocateUniqueFileName(String str) {
    Set<String> name_set = new HashSet<String>();

    for (Map<String, ?> entry : device_files.values()) {

      try {
        name_set.add(
            new File(ImportExportUtils.importString(entry, TranscodeFileImpl.KEY_FILE)).getName());

      } catch (Throwable e) {

        Debug.out(e);
      }
    }

    for (int i = 0; i < 1024; i++) {

      String test_name = i == 0 ? str : (i + "_" + str);

      if (!name_set.contains(test_name)) {

        str = test_name;

        break;
      }
    }

    return (str);
  }
  public Set<String> getAutoInstallPluginIDs() {
    Set<String> result = new HashSet<String>();

    Map m = getMostRecentVersionCheckData();

    if (m != null) {

      byte[] x = (byte[]) m.get("autoinstall_pids");

      if (x != null) {

        String str = new String(x);

        String latest = COConfigurationManager.getStringParameter("vc.autoinstall_pids.latest", "");

        if (!str.equals(latest)) {

          byte[] sig = (byte[]) m.get("autoinstall_pids_sig");

          if (sig == null) {

            Debug.out("autoinstall plugins sig missing");

            return (result);
          }

          try {
            AEVerifier.verifyData(str, sig);

            COConfigurationManager.setParameter("vc.autoinstall_pids.latest", str);

          } catch (Throwable e) {

            return (result);
          }
        }

        String[] bits = str.split(",");

        for (String b : bits) {

          b = b.trim();

          if (b.length() > 0) {

            result.add(b);
          }
        }
      }
    }

    return (result);
  }
  protected void fireInitComplete(PluginListener listener) {
    synchronized (init_complete_fired_set) {
      if (init_complete_fired_set.contains(listener)) {

        return;
      }

      init_complete_fired_set.add(listener);
    }

    try {
      listener.initializationComplete();
    } catch (Exception e) {
      Debug.out(e);
    }
  }