//# 0 errors, 54 messages
//#
/*
    //#AudioCommand.java:1:1: class: com.dmdirc.addons.audio.AudioCommand
    //#AudioCommand.java:1:1: method: com.dmdirc.addons.audio.AudioCommand.com.dmdirc.addons.audio.AudioCommand__static_init
 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.dmdirc.addons.audio;

import com.dmdirc.commandparser.CommandArguments;
import com.dmdirc.commandparser.CommandManager;
import com.dmdirc.commandparser.commands.GlobalCommand;
import com.dmdirc.ui.interfaces.InputWindow;

import java.io.File;

/**
 * The Audio Command allows playing of audio files.
 *
 * @author Shane "Dataforce" Mc Cormack
 */
public final class AudioCommand extends GlobalCommand {

	/**
	 * Creates a new instance of LoggingCommand.
	 */
	public AudioCommand() {
		super();
    //#AudioCommand.java:43: method: void com.dmdirc.addons.audio.AudioCommand.com.dmdirc.addons.audio.AudioCommand()
    //#AudioCommand.java:43: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.commandparser.commands.GlobalCommand()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.audio.AudioCommand
    //#    method: void com.dmdirc.addons.audio.AudioCommand()
    //#    unanalyzed callee: void com.dmdirc.commandparser.commands.GlobalCommand()
    //#input(void com.dmdirc.addons.audio.AudioCommand()): this
		CommandManager.registerCommand(this);
    //#AudioCommand.java:44: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.commandparser.CommandManager:registerCommand(Command)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.audio.AudioCommand
    //#    method: void com.dmdirc.addons.audio.AudioCommand()
    //#    unanalyzed callee: void com.dmdirc.commandparser.CommandManager:registerCommand(Command)
	}
    //#AudioCommand.java:45: end of method: void com.dmdirc.addons.audio.AudioCommand.com.dmdirc.addons.audio.AudioCommand()
		
	/** {@inheritDoc} */
    @Override
	public void execute(final InputWindow origin, final boolean isSilent,
            final CommandArguments args) {
		final String filename = args.getArgumentsAsString();
    //#AudioCommand.java:51: method: void com.dmdirc.addons.audio.AudioCommand.execute(InputWindow, bool, CommandArguments)
    //#AudioCommand.java:51: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.commandparser.CommandArguments:getArgumentsAsString()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.audio.AudioCommand
    //#    method: void execute(InputWindow, bool, CommandArguments)
    //#    unanalyzed callee: String com.dmdirc.commandparser.CommandArguments:getArgumentsAsString()
    //#input(void execute(InputWindow, bool, CommandArguments)): args
    //#input(void execute(InputWindow, bool, CommandArguments)): com/dmdirc/addons/audio/AudioPlayer$AudioType.INVALID
    //#input(void execute(InputWindow, bool, CommandArguments)): com/dmdirc/addons/audio/AudioPlayer$AudioType.WAV
    //#input(void execute(InputWindow, bool, CommandArguments)): isSilent
    //#input(void execute(InputWindow, bool, CommandArguments)): origin
    //#input(void execute(InputWindow, bool, CommandArguments)): this
    //#pre[1] (void execute(InputWindow, bool, CommandArguments)): args != null
    //#unanalyzed(void execute(InputWindow, bool, CommandArguments)): Effects-of-calling:javax.sound.sampled.AudioSystem:getAudioInputStream
    //#unanalyzed(void execute(InputWindow, bool, CommandArguments)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void execute(InputWindow, bool, CommandArguments)): Effects-of-calling:java.lang.Thread
    //#unanalyzed(void execute(InputWindow, bool, CommandArguments)): Effects-of-calling:java.lang.Thread:start
    //#test_vector(void execute(InputWindow, bool, CommandArguments)): java.io.File:exists(...)@53: {0}, {1}
		final File file = new File(filename);
		if (file.exists()) {
			if (AudioPlayer.isValid(file)) {
				new AudioPlayer(file).play();
			} else {
				sendLine(origin, isSilent, FORMAT_ERROR, "Invalid file type");
    //#AudioCommand.java:57: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.audio.AudioCommand:sendLine(InputWindow, bool, String, Object[])
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.audio.AudioCommand
    //#    method: void execute(InputWindow, bool, CommandArguments)
    //#    unanalyzed callee: void com.dmdirc.addons.audio.AudioCommand:sendLine(InputWindow, bool, String, Object[])
			}
		} else {
			sendLine(origin, isSilent, FORMAT_ERROR, "File does not exist");
    //#AudioCommand.java:60: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.audio.AudioCommand:sendLine(InputWindow, bool, String, Object[])
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.audio.AudioCommand
    //#    method: void execute(InputWindow, bool, CommandArguments)
    //#    unanalyzed callee: void com.dmdirc.addons.audio.AudioCommand:sendLine(InputWindow, bool, String, Object[])
		}
	}
    //#AudioCommand.java:62: end of method: void com.dmdirc.addons.audio.AudioCommand.execute(InputWindow, bool, CommandArguments)

	/**
	 * Returns this command's name.
	 *
	 * @return The name of this command
	 */
    @Override
	public String getName() { return "audio"; }
    //#AudioCommand.java:70: method: String com.dmdirc.addons.audio.AudioCommand.getName()
    //#output(String getName()): return_value
    //#post(String getName()): return_value == &"audio"
    //#AudioCommand.java:70: end of method: String com.dmdirc.addons.audio.AudioCommand.getName()
	
	/**
	 * Returns whether or not this command should be shown in help messages.
	 *
	 * @return True iff the command should be shown, false otherwise
	 */
    @Override
	public boolean showInHelp() { return true; }
    //#AudioCommand.java:78: method: bool com.dmdirc.addons.audio.AudioCommand.showInHelp()
    //#output(bool showInHelp()): return_value
    //#post(bool showInHelp()): return_value == 1
    //#AudioCommand.java:78: end of method: bool com.dmdirc.addons.audio.AudioCommand.showInHelp()
	
	/**
	 * Returns a string representing the help message for this command.
	 *
	 * @return the help message for this command
	 */
    @Override
	public String getHelp() { return this.getName() + " <file>"; }
    //#AudioCommand.java:86: method: String com.dmdirc.addons.audio.AudioCommand.getHelp()
    //#input(String getHelp()): " <file>"._tainted
    //#input(String getHelp()): "audio"._tainted
    //#input(String getHelp()): this
    //#output(String getHelp()): java.lang.StringBuilder:toString(...)._tainted
    //#output(String getHelp()): return_value
    //#new obj(String getHelp()): java.lang.StringBuilder:toString(...)
    //#post(String getHelp()): java.lang.StringBuilder:toString(...)._tainted == 0
    //#post(String getHelp()): return_value == &java.lang.StringBuilder:toString(...)
    //#AudioCommand.java:86: end of method: String com.dmdirc.addons.audio.AudioCommand.getHelp()
	
}

    //#output(com.dmdirc.addons.audio.AudioCommand__static_init): __Descendant_Table[com/dmdirc/addons/audio/AudioCommand]
    //#output(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.execute(Lcom/dmdirc/ui/interfaces/InputWindow;ZLcom/dmdirc/commandparser/CommandArguments;)V
    //#output(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.getHelp()Ljava/lang/String;
    //#output(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.showInHelp()Z
    //#post(com.dmdirc.addons.audio.AudioCommand__static_init): __Descendant_Table[com/dmdirc/addons/audio/AudioCommand] == &__Dispatch_Table
    //#post(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.execute(Lcom/dmdirc/ui/interfaces/InputWindow;ZLcom/dmdirc/commandparser/CommandArguments;)V == &execute
    //#post(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.getHelp()Ljava/lang/String; == &getHelp
    //#post(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(com.dmdirc.addons.audio.AudioCommand__static_init): __Dispatch_Table.showInHelp()Z == &showInHelp
    //#AudioCommand.java:: end of method: com.dmdirc.addons.audio.AudioCommand.com.dmdirc.addons.audio.AudioCommand__static_init
    //#AudioCommand.java:: end of class: com.dmdirc.addons.audio.AudioCommand
