Exemple #1
0
  protected static DeviceImpl importFromBEncodedMapStatic(DeviceManagerImpl manager, Map map)
      throws IOException {
    String impl = ImportExportUtils.importString(map, "_impl");

    if (impl.startsWith(".")) {

      impl = MY_PACKAGE + impl;
    }

    try {
      Class<DeviceImpl> cla = (Class<DeviceImpl>) Class.forName(impl);

      Constructor<DeviceImpl> cons = cla.getDeclaredConstructor(DeviceManagerImpl.class, Map.class);

      cons.setAccessible(true);

      return (cons.newInstance(manager, map));

    } catch (Throwable e) {

      Debug.out("Can't construct device for " + impl, e);

      throw (new IOException("Construction failed: " + Debug.getNestedExceptionMessage(e)));
    }
  }
 public static void createTrial() {
   try {
     Licence[] trial = featman.createLicences(new String[] {"dvdburn_trial"});
   } catch (Throwable e) {
     String s = "Creating Trial: " + Debug.getNestedExceptionMessage(e);
     new MessageBoxShell("Trial Error", s).open(null);
     Logger.log(new LogAlert(true, s, e));
   }
 }
  protected void generateEvidence(IndentWriter writer) {
    writer.println(getPluginName());

    try {
      writer.indent();

      writer.println("id:" + getPluginID() + ",version:" + getPluginVersion());

      String user_dir = FileUtil.getUserFile("plugins").toString();
      String shared_dir = FileUtil.getApplicationFile("plugins").toString();

      String plugin_dir = getPluginDirectoryName();

      String type;
      boolean built_in = false;

      if (plugin_dir.startsWith(shared_dir)) {

        type = "shared";

      } else if (plugin_dir.startsWith(user_dir)) {

        type = "per-user";

      } else {

        built_in = true;

        type = "built-in";
      }

      PluginState ps = getPluginState();

      String info = getPluginconfig().getPluginStringParameter("plugin.info");

      writer.println(
          "type:"
              + type
              + ",enabled="
              + !ps.isDisabled()
              + ",load_at_start="
              + ps.isLoadedAtStartup()
              + ",operational="
              + ps.isOperational()
              + (info == null || info.length() == 0 ? "" : (",info=" + info)));

      if (ps.isOperational()) {

        Plugin plugin = getPlugin();

        if (plugin instanceof AEDiagnosticsEvidenceGenerator) {

          try {
            writer.indent();

            ((AEDiagnosticsEvidenceGenerator) plugin).generate(writer);

          } catch (Throwable e) {

            writer.println(
                "Failed to generate plugin-specific info: " + Debug.getNestedExceptionMessage(e));

          } finally {

            writer.exdent();
          }
        }
      } else {
        if (!built_in) {

          File dir = new File(plugin_dir);

          if (dir.exists()) {

            String[] files = dir.list();

            if (files != null) {

              String files_str = "";

              for (String f : files) {

                files_str += (files_str.length() == 0 ? "" : ", ") + f;
              }

              writer.println("    files: " + files_str);
            }
          }
        }
      }
    } finally {

      writer.exdent();
    }
  }
Exemple #4
0
  public TranscodeFileImpl allocateFile(
      TranscodeProfile profile, boolean no_xcode, DiskManagerFileInfo file, boolean for_job)
      throws TranscodeException {
    TranscodeFileImpl result = null;

    setError(KEY_FILE_ALLOC_ERROR, null);

    try {
      synchronized (this) {
        if (device_files == null) {

          loadDeviceFile();
        }

        String key =
            ByteFormatter.encodeString(file.getDownloadHash())
                + ":"
                + file.getIndex()
                + ":"
                + profile.getUID();

        if (device_files.containsKey(key)) {

          try {
            result = new TranscodeFileImpl(this, key, device_files);

          } catch (Throwable e) {

            device_files.remove(key);

            log("Failed to deserialise transcode file", e);
          }
        }

        if (result == null) {

          String ext = profile.getFileExtension();

          String target_file = file.getFile(true).getName();

          if (ext != null && !no_xcode) {

            int pos = target_file.lastIndexOf('.');

            if (pos != -1) {

              target_file = target_file.substring(0, pos);
            }

            target_file += ext;
          }

          target_file = allocateUniqueFileName(target_file);

          File output_file = getWorkingDirectory(true);

          if (!output_file.canWrite()) {

            throw (new TranscodeException(
                "Can't write to transcode folder '" + output_file.getAbsolutePath() + "'"));
          }

          output_file = new File(output_file.getAbsoluteFile(), target_file);

          result =
              new TranscodeFileImpl(
                  this, key, profile.getName(), device_files, output_file, for_job);

          result.setSourceFile(file);

          device_files_last_mod = SystemTime.getMonotonousTime();

          device_files_dirty = true;

        } else {

          result.setSourceFile(file);

          result.setProfileName(profile.getName());
        }
      }
    } catch (Throwable e) {

      setError(KEY_FILE_ALLOC_ERROR, Debug.getNestedExceptionMessage(e));

      throw (new TranscodeException("File allocation failed", e));
    }

    for (TranscodeTargetListener l : listeners) {

      try {
        l.fileAdded(result);

      } catch (Throwable e) {

        Debug.out(e);
      }
    }

    return (result);
  }