Exemplo n.º 1
0
  /**
   * {@inheritDoc}
   *
   * @param e Action event
   */
  @Override
  public void actionPerformed(final ActionEvent e) {
    try {
      final File file = File.createTempFile("dmdirc-addon", ".tmp");
      file.deleteOnExit();

      Downloader.downloadPage(
          "http://addons.dmdirc.com/addondownload/" + info.getStableDownload(),
          file.getAbsolutePath());

      switch (info.getType()) {
        case TYPE_ACTION_PACK:
          ActionManager.installActionPack(file.getAbsolutePath());
          break;
        case TYPE_PLUGIN:
          throw new UnsupportedOperationException("Not supported yet");
          // break;
        case TYPE_THEME:
          throw new UnsupportedOperationException("Not supported yet");
          // break;
      }
    } catch (IOException ex) {
      Logger.userError(ErrorLevel.MEDIUM, "Unable to download addon: " + ex.getMessage(), ex);
    }
  }
Exemplo n.º 2
0
  /**
   * Extracts plugins bundled with DMDirc to the user's profile's plugin directory.
   *
   * @param prefix If non-null, only plugins whose file name starts with this prefix will be
   *     extracted.
   */
  public static void extractCorePlugins(final String prefix) {
    final Map<String, byte[]> resources =
        ResourceManager.getResourceManager().getResourcesStartingWithAsBytes("plugins");
    for (Map.Entry<String, byte[]> resource : resources.entrySet()) {
      try {
        final String resourceName =
            Main.getConfigDir() + "plugins" + resource.getKey().substring(7);

        if (prefix != null && !resource.getKey().substring(8).startsWith(prefix)) {
          continue;
        }

        final File newDir =
            new File(resourceName.substring(0, resourceName.lastIndexOf('/')) + "/");

        if (!newDir.exists()) {
          newDir.mkdirs();
        }

        final File newFile =
            new File(
                newDir,
                resourceName.substring(resourceName.lastIndexOf('/') + 1, resourceName.length()));

        if (!newFile.isDirectory()) {
          ResourceManager.getResourceManager().resourceToFile(resource.getValue(), newFile);
        }
      } catch (IOException ex) {
        Logger.userError(ErrorLevel.LOW, "Failed to extract plugins", ex);
      }
    }
  }
Exemplo n.º 3
0
 /**
  * Called when the input was a line of text that was not a command. This normally means it is sent
  * to the server/channel/user as-is, with no further processing.
  *
  * @param origin The window in which the command was typed
  * @param line The line input by the user
  */
 @Override
 protected void handleNonCommand(final InputWindow origin, final String line) {
   if (origin == null) {
     Logger.userError(ErrorLevel.MEDIUM, "Invalid global command: " + line);
   } else {
     origin.addLine("commandError", "Invalid global command: " + line);
   }
 }