//# 0 errors, 58 messages
//#
/*
    //#DcopCommand.java:1:1: class: com.dmdirc.addons.dcop.DcopCommand
    //#DcopCommand.java:1:1: method: com.dmdirc.addons.dcop.DcopCommand.com.dmdirc.addons.dcop.DcopCommand__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.dcop;

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

import java.util.List;

/**
 * The dcop command retrieves information from a dcop application.
 * @author chris
 */
public final class DcopCommand extends ServerCommand {
    
    /**
     * Creates a new instance of DcopCommand.
     */
    public DcopCommand() {
        super();
    //#DcopCommand.java:43: method: void com.dmdirc.addons.dcop.DcopCommand.com.dmdirc.addons.dcop.DcopCommand()
    //#DcopCommand.java:43: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.commandparser.commands.ServerCommand()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.dcop.DcopCommand
    //#    method: void com.dmdirc.addons.dcop.DcopCommand()
    //#    unanalyzed callee: void com.dmdirc.commandparser.commands.ServerCommand()
    //#input(void com.dmdirc.addons.dcop.DcopCommand()): this
        
        CommandManager.registerCommand(this);
    //#DcopCommand.java:45: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.commandparser.CommandManager:registerCommand(Command)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.dcop.DcopCommand
    //#    method: void com.dmdirc.addons.dcop.DcopCommand()
    //#    unanalyzed callee: void com.dmdirc.commandparser.CommandManager:registerCommand(Command)
    }
    //#DcopCommand.java:46: end of method: void com.dmdirc.addons.dcop.DcopCommand.com.dmdirc.addons.dcop.DcopCommand()

    /** {@inheritDoc} */
    @Override
    public void execute(final InputWindow origin, final Server server,
            final boolean isSilent, final CommandArguments args) {
        if (args.getArguments().length != 3) {
    //#DcopCommand.java:52: method: void com.dmdirc.addons.dcop.DcopCommand.execute(InputWindow, Server, bool, CommandArguments)
    //#DcopCommand.java:52: Warning: method not available - call not analyzed
    //#    call on String[] com.dmdirc.commandparser.CommandArguments:getArguments()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.dcop.DcopCommand
    //#    method: void execute(InputWindow, Server, bool, CommandArguments)
    //#    unanalyzed callee: String[] com.dmdirc.commandparser.CommandArguments:getArguments()
    //#input(void execute(InputWindow, Server, bool, CommandArguments)): "dcop "._tainted
    //#input(void execute(InputWindow, Server, bool, CommandArguments)): args
    //#input(void execute(InputWindow, Server, bool, CommandArguments)): isSilent
    //#input(void execute(InputWindow, Server, bool, CommandArguments)): origin
    //#input(void execute(InputWindow, Server, bool, CommandArguments)): this
    //#pre[1] (void execute(InputWindow, Server, bool, CommandArguments)): args != null
    //#presumption(void execute(InputWindow, Server, bool, CommandArguments)): com.dmdirc.commandparser.CommandArguments:getArguments(...)@52 != null
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.util.ArrayList
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.lang.Runtime:getRuntime
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.lang.Runtime:exec
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.lang.Process:getInputStream
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.io.InputStreamReader
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.io.BufferedReader
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.io.BufferedReader:readLine
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.util.ArrayList:add
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.io.InputStreamReader:close
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.io.BufferedReader:close
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.lang.Process:destroy
    //#unanalyzed(void execute(InputWindow, Server, bool, CommandArguments)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#test_vector(void execute(InputWindow, Server, bool, CommandArguments)): com.dmdirc.commandparser.CommandArguments:getArguments(...).length@52: {3}, {0..2, 4..+Inf}
    //#test_vector(void execute(InputWindow, Server, bool, CommandArguments)): java.util.Iterator:hasNext(...)@58: {0}, {1}
            showUsage(origin, isSilent, "dcop", "<app> <object> <function>");
    //#DcopCommand.java:53: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.dcop.DcopCommand:showUsage(InputWindow, bool, String, String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.dcop.DcopCommand
    //#    method: void execute(InputWindow, Server, bool, CommandArguments)
    //#    unanalyzed callee: void com.dmdirc.addons.dcop.DcopCommand:showUsage(InputWindow, bool, String, String)
            return;
        }
        
        final List<String> res = DcopPlugin.getDcopResult("dcop " + args.getArgumentsAsString());
    //#DcopCommand.java:57: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.commandparser.CommandArguments:getArgumentsAsString()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.dcop.DcopCommand
    //#    method: void execute(InputWindow, Server, bool, CommandArguments)
    //#    unanalyzed callee: String com.dmdirc.commandparser.CommandArguments:getArgumentsAsString()
        for (String line : res) {
            sendLine(origin, isSilent, FORMAT_OUTPUT, line);
    //#DcopCommand.java:59: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.addons.dcop.DcopCommand:sendLine(InputWindow, bool, String, Object[])
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.dcop.DcopCommand
    //#    method: void execute(InputWindow, Server, bool, CommandArguments)
    //#    unanalyzed callee: void com.dmdirc.addons.dcop.DcopCommand:sendLine(InputWindow, bool, String, Object[])
        }
    }
    //#DcopCommand.java:61: end of method: void com.dmdirc.addons.dcop.DcopCommand.execute(InputWindow, Server, bool, CommandArguments)
    
    
    /** {@inheritDoc} */
    @Override
    public String getName() {
        return "dcop";
    //#DcopCommand.java:67: method: String com.dmdirc.addons.dcop.DcopCommand.getName()
    //#output(String getName()): return_value
    //#post(String getName()): return_value == &"dcop"
    //#DcopCommand.java:67: end of method: String com.dmdirc.addons.dcop.DcopCommand.getName()
    }
    
    /** {@inheritDoc} */
    @Override
    public boolean showInHelp() {
        return true;
    //#DcopCommand.java:73: method: bool com.dmdirc.addons.dcop.DcopCommand.showInHelp()
    //#output(bool showInHelp()): return_value
    //#post(bool showInHelp()): return_value == 1
    //#DcopCommand.java:73: end of method: bool com.dmdirc.addons.dcop.DcopCommand.showInHelp()
    }
    
    /** {@inheritDoc} */
    @Override
    public String getHelp() {
        return "dcop <app> <object> <function> - retrieves information from a DCOP aplication";
    //#DcopCommand.java:79: method: String com.dmdirc.addons.dcop.DcopCommand.getHelp()
    //#output(String getHelp()): return_value
    //#post(String getHelp()): return_value == &"dcop <app> <object> <function> - retrieves information from a DCOP aplication"
    //#DcopCommand.java:79: end of method: String com.dmdirc.addons.dcop.DcopCommand.getHelp()
    }
    
}
    //#output(com.dmdirc.addons.dcop.DcopCommand__static_init): __Descendant_Table[com/dmdirc/addons/dcop/DcopCommand]
    //#output(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.execute(Lcom/dmdirc/ui/interfaces/InputWindow;Lcom/dmdirc/Server;ZLcom/dmdirc/commandparser/CommandArguments;)V
    //#output(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.getHelp()Ljava/lang/String;
    //#output(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.showInHelp()Z
    //#post(com.dmdirc.addons.dcop.DcopCommand__static_init): __Descendant_Table[com/dmdirc/addons/dcop/DcopCommand] == &__Dispatch_Table
    //#post(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.execute(Lcom/dmdirc/ui/interfaces/InputWindow;Lcom/dmdirc/Server;ZLcom/dmdirc/commandparser/CommandArguments;)V == &execute
    //#post(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.getHelp()Ljava/lang/String; == &getHelp
    //#post(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(com.dmdirc.addons.dcop.DcopCommand__static_init): __Dispatch_Table.showInHelp()Z == &showInHelp
    //#DcopCommand.java:: end of method: com.dmdirc.addons.dcop.DcopCommand.com.dmdirc.addons.dcop.DcopCommand__static_init
    //#DcopCommand.java:: end of class: com.dmdirc.addons.dcop.DcopCommand
