File Source: InstallListener.java

         /* 
    P/P   *  Method: com.dmdirc.addons.addonbrowser.InstallListener__static_init
          */
     1  /*
     2   * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
     3   * 
     4   * Permission is hereby granted, free of charge, to any person obtaining a copy
     5   * of this software and associated documentation files (the "Software"), to deal
     6   * in the Software without restriction, including without limitation the rights
     7   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     8   * copies of the Software, and to permit persons to whom the Software is
     9   * furnished to do so, subject to the following conditions:
    10   * 
    11   * The above copyright notice and this permission notice shall be included in
    12   * all copies or substantial portions of the Software.
    13   * 
    14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    20   * SOFTWARE.
    21   */
    22  
    23  package com.dmdirc.addons.addonbrowser;
    24  
    25  import com.dmdirc.actions.ActionManager;
    26  import com.dmdirc.logger.ErrorLevel;
    27  import com.dmdirc.logger.Logger;
    28  import com.dmdirc.util.Downloader;
    29  
    30  import java.awt.event.ActionEvent;
    31  import java.awt.event.ActionListener;
    32  
    33  import java.io.File;
    34  import java.io.IOException;
    35  
    36  /**
    37   * Addon info install listener.
    38   */
    39  public class InstallListener implements ActionListener {
    40  
    41      /** Addon info. */
    42      private final AddonInfo info;
    43  
    44      /**
    45       * Instantiates a new install listener.
    46       * 
    47       * @param info Addoninfo to install
    48       */
             /* 
    P/P       *  Method: void com.dmdirc.addons.addonbrowser.InstallListener(AddonInfo)
              * 
              *  Postconditions:
              *    this.info == info
              *    init'ed(this.info)
              */
    49      public InstallListener(final AddonInfo info) {
    50          this.info = info;
    51      }
    52  
    53      /** 
    54       * {@inheritDoc}
    55       * 
    56       * @param e Action event
    57       */
    58      @Override
    59      public void actionPerformed(final ActionEvent e) {
    60          try {
                     /* 
    P/P               *  Method: void actionPerformed(ActionEvent)
                      * 
                      *  Preconditions:
                      *    (soft) com.dmdirc.addons.addonbrowser.InstallListener$1__static_init.new int[](InstallListener$1__static_init#1)[...] not in {2,3}
                      *    (soft) init'ed(com/dmdirc/Main.configdir)
                      *    (soft) this.info != null
                      *    (soft) this.info.type != null
                      * 
                      *  Presumptions:
                      *    com.dmdirc.addons.addonbrowser.AddonInfo_AddonType:ordinal(...)@67 in {0..2}
                      *    init'ed(com.dmdirc.logger.ErrorLevel.MEDIUM)
                      *    java.io.File:createTempFile(...)@61 != null
                      * 
                      *  Postconditions:
                      *    init'ed(com/dmdirc/Main.configdir)
                      *    possibly_updated(com/dmdirc/ServerManager.me)
                      *    java.lang.StringBuilder:toString(...)._tainted == 0
                      *    init'ed(new ArrayList(ServerManager#1) num objects)
                      *    init'ed(new ServerManager(getServerManager#1) num objects)
                      *    init'ed(new ServerManager(getServerManager#1).servers)
                      * 
                      *  Test Vectors:
                      *    com.dmdirc.addons.addonbrowser.InstallListener$1__static_init.new int[](InstallListener$1__static_init#1)[...]: {1}, {-231..0, 4..232-1}
                      */
    61              final File file = File.createTempFile("dmdirc-addon", ".tmp");
    62              file.deleteOnExit();
    63  
    64              Downloader.downloadPage("http://addons.dmdirc.com/addondownload/"
    65                      + info.getStableDownload(), file.getAbsolutePath());
    66  
                     /* 
    P/P               *  Method: com.dmdirc.addons.addonbrowser.InstallListener$1__static_init
                      * 
                      *  Preconditions:
                      *    (soft) init'ed(com.dmdirc.addons.addonbrowser.AddonInfo$AddonType__static_init.new AddonInfo$AddonType[](AddonInfo$AddonType__static_init#4)[...])
                      * 
                      *  Presumptions:
                      *    com.dmdirc.addons.addonbrowser.AddonInfo_AddonType:ordinal(...)@67 in {0..2}
                      * 
                      *  Postconditions:
                      *    new int[](InstallListener$1__static_init#1) num objects == 1
                      */
    67              switch (info.getType()) {
    68                  case TYPE_ACTION_PACK:
    69                      ActionManager.installActionPack(file.getAbsolutePath());
    70                      break;
    71                  case TYPE_PLUGIN:
    72                      throw new UnsupportedOperationException("Not supported yet");
    73                      //break;
    74                  case TYPE_THEME:
    75                      throw new UnsupportedOperationException("Not supported yet");
    76                      //break;
    77              }
    78          } catch (IOException ex) {
    79              Logger.userError(ErrorLevel.MEDIUM, "Unable to download addon: "
    80                      + ex.getMessage(), ex);
    81          }
    82      }
    83  }








SofCheck Inspector Build Version : 2.17854
InstallListener.java 2009-Jun-25 01:54:24
InstallListener.class 2009-Sep-02 17:04:14
InstallListener$1.class 2009-Sep-02 17:04:14