//# 0 errors, 141 messages
//#
/*
    //#WindowsMediaSourcePlugin.java:1:1: class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
 * 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.mediasource_windows;

import com.dmdirc.Main;
import com.dmdirc.addons.nowplaying.MediaSource;
import com.dmdirc.addons.nowplaying.MediaSourceManager;
import com.dmdirc.logger.ErrorLevel;
import com.dmdirc.logger.Logger;
import com.dmdirc.plugins.Plugin;
import com.dmdirc.plugins.PluginInfo;
import com.dmdirc.plugins.PluginManager;
import com.dmdirc.util.resourcemanager.ResourceManager;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.io.File;
import java.io.IOException;

import com.dmdirc.installer.StreamReader;
/**
 * Manages all Windows based media sources.
 */
public class WindowsMediaSourcePlugin extends Plugin implements MediaSourceManager {
	/** Media sources. */
	private final List<MediaSource> sources;
	/** Files dir */
	private static final String filesDir  = Main.getConfigDir() + "plugins/windowsmediasource_files/";
    //#WindowsMediaSourcePlugin.java:50: method: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init
    //#WindowsMediaSourcePlugin.java:50: Warning: method not available - call not analyzed
    //#    call on String com.dmdirc.Main:getConfigDir()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init
    //#    unanalyzed callee: String com.dmdirc.Main:getConfigDir()
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): "plugins.windowsmediasource_files."._tainted
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Descendant_Table[com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin]
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.extractFiles(Lcom/dmdirc/util/resourcemanager/ResourceManager;Ljava/io/File;Ljava/lang/String;)V
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.getSources()Ljava/util/List;
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.onLoad()V
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.onUnload()V
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): com/dmdirc/addons/nowplaying/MediaSourceManager.__Descendant_Table[com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin]
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): filesDir
    //#output(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): java.lang.StringBuilder:toString(...)._tainted
    //#new obj(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): java.lang.StringBuilder:toString(...)
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): "plugins.windowsmediasource_files."._tainted == 0
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): java.lang.StringBuilder:toString(...)._tainted == 0
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Descendant_Table[com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin] == &__Dispatch_Table
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): com/dmdirc/addons/nowplaying/MediaSourceManager.__Descendant_Table[com/dmdirc/addons/mediasource_windows/WindowsMediaSourcePlugin] == &__Dispatch_Table
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.extractFiles(Lcom/dmdirc/util/resourcemanager/ResourceManager;Ljava/io/File;Ljava/lang/String;)V == &extractFiles
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.getSources()Ljava/util/List; == &getSources
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.onLoad()V == &onLoad
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): __Dispatch_Table.onUnload()V == &onUnload
    //#post(com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init): filesDir == &java.lang.StringBuilder:toString(...)
    //#WindowsMediaSourcePlugin.java:50: end of method: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin__static_init

	/**
	 * Creates a new instance of DcopMediaSourcePlugin.
	 */
	public WindowsMediaSourcePlugin() {
		super();
    //#WindowsMediaSourcePlugin.java:56: method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()
    //#WindowsMediaSourcePlugin.java:56: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.plugins.Plugin()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()
    //#    unanalyzed callee: void com.dmdirc.plugins.Plugin()
    //#input(void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()): this
    //#output(void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()): new ArrayList(WindowsMediaSourcePlugin#1) num objects
    //#output(void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()): this.sources
    //#new obj(void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()): new ArrayList(WindowsMediaSourcePlugin#1)
    //#post(void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()): this.sources == &new ArrayList(WindowsMediaSourcePlugin#1)
    //#post(void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()): new ArrayList(WindowsMediaSourcePlugin#1) num objects == 1
		sources = new ArrayList<MediaSource>();
		sources.add(new DllSource("Winamp", true));
		sources.add(new DllSource("iTunes", false));
	}
    //#WindowsMediaSourcePlugin.java:60: end of method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin()
	
	/** {@inheritDoc} */
	@Override
	public List<MediaSource> getSources() {
		return sources;
    //#WindowsMediaSourcePlugin.java:65: method: List com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.getSources()
    //#input(List getSources()): this
    //#input(List getSources()): this.sources
    //#output(List getSources()): return_value
    //#post(List getSources()): return_value == this.sources
    //#post(List getSources()): init'ed(return_value)
    //#WindowsMediaSourcePlugin.java:65: end of method: List com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.getSources()
	}
	
	/**
	 * Get the output from GetMediaInfo.exe for the given player and method
	 *
	 * @param player Player to ask about
	 * @param method Method to call
	 * @return a MediaInfoOutput with the results
	 */
	protected static MediaInfoOutput getOutput(final String player, final String method) {
		try {
			final Process myProcess = Runtime.getRuntime().exec(new String[]{filesDir+"GetMediaInfo.exe", player, method});
    //#WindowsMediaSourcePlugin.java:77: method: MediaInfoOutput com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.getOutput(String, String)
    //#input(MediaInfoOutput getOutput(String, String)): "GetMediaInfo.exe"._tainted
    //#input(MediaInfoOutput getOutput(String, String)): filesDir
    //#input(MediaInfoOutput getOutput(String, String)): method
    //#input(MediaInfoOutput getOutput(String, String)): player
    //#output(MediaInfoOutput getOutput(String, String)): java.lang.StringBuffer:toString(...)._tainted
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6) num objects
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6).__Tag
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6).exitCode
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6).output
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7) num objects
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7).__Tag
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7).exitCode
    //#output(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7).output
    //#output(MediaInfoOutput getOutput(String, String)): return_value
    //#new obj(MediaInfoOutput getOutput(String, String)): java.lang.StringBuffer:toString(...)
    //#new obj(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6)
    //#new obj(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7)
    //#presumption(MediaInfoOutput getOutput(String, String)): java.lang.Runtime:exec(...)@77 != null
    //#presumption(MediaInfoOutput getOutput(String, String)): java.lang.Runtime:getRuntime(...)@77 != null
    //#post(MediaInfoOutput getOutput(String, String)): java.lang.StringBuffer:toString(...)._tainted == 0
    //#post(MediaInfoOutput getOutput(String, String)): return_value in Addr_Set{&new MediaInfoOutput(getOutput#6),&new MediaInfoOutput(getOutput#7)}
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6) num objects <= 1
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6).__Tag == com/dmdirc/addons/mediasource_windows/MediaInfoOutput
    //#post(MediaInfoOutput getOutput(String, String)): init'ed(new MediaInfoOutput(getOutput#6).exitCode)
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#6).output == &java.lang.StringBuffer:toString(...)
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7) num objects <= 1
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7).__Tag == com/dmdirc/addons/mediasource_windows/MediaInfoOutput
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7).exitCode == -1
    //#post(MediaInfoOutput getOutput(String, String)): new MediaInfoOutput(getOutput#7).output == &"Error executing GetMediaInfo.exe"
			final StringBuffer data = new StringBuffer();
			new StreamReader(myProcess.getErrorStream()).start();
    //#WindowsMediaSourcePlugin.java:79: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.installer.StreamReader(InputStream)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: MediaInfoOutput getOutput(String, String)
    //#    unanalyzed callee: void com.dmdirc.installer.StreamReader(InputStream)
    //#WindowsMediaSourcePlugin.java:79: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.installer.StreamReader:start()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: MediaInfoOutput getOutput(String, String)
    //#    unanalyzed callee: void com.dmdirc.installer.StreamReader:start()
			new StreamReader(myProcess.getInputStream(), data).start();
    //#WindowsMediaSourcePlugin.java:80: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.installer.StreamReader(InputStream, StringBuffer)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: MediaInfoOutput getOutput(String, String)
    //#    unanalyzed callee: void com.dmdirc.installer.StreamReader(InputStream, StringBuffer)
    //#WindowsMediaSourcePlugin.java:80: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.installer.StreamReader:start()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: MediaInfoOutput getOutput(String, String)
    //#    unanalyzed callee: void com.dmdirc.installer.StreamReader:start()
			try {
				myProcess.waitFor();
			} catch (InterruptedException e) { }
			
			return new MediaInfoOutput(myProcess.exitValue(),data.toString());
		} catch (SecurityException e) {
		} catch (IOException e) {
		}
		
		return new MediaInfoOutput(-1, "Error executing GetMediaInfo.exe");
    //#WindowsMediaSourcePlugin.java:90: end of method: MediaInfoOutput com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.getOutput(String, String)
	}
	
	/**
	 * Use the given resource manager to extract files ending with the given suffix
	 *
	 * @param res ResourceManager
	 * @param newDir Directory to extract to.
	 * @param suffix Suffix to extract
	 */
	private void extractFiles(final ResourceManager res, final File newDir, final String suffix) {
		final Map<String, byte[]> resources = res.getResourcesEndingWithAsBytes(suffix);
    //#WindowsMediaSourcePlugin.java:101: method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.extractFiles(ResourceManager, File, String)
    //#WindowsMediaSourcePlugin.java:101: Warning: method not available - call not analyzed
    //#    call on Map com.dmdirc.util.resourcemanager.ResourceManager:getResourcesEndingWithAsBytes(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void extractFiles(ResourceManager, File, String)
    //#    unanalyzed callee: Map com.dmdirc.util.resourcemanager.ResourceManager:getResourcesEndingWithAsBytes(String)
    //#input(void extractFiles(ResourceManager, File, String)): "Failed to extract "._tainted
    //#input(void extractFiles(ResourceManager, File, String)): "s for windowsmediasource: "._tainted
    //#input(void extractFiles(ResourceManager, File, String)): com.dmdirc.logger.ErrorLevel.LOW
    //#input(void extractFiles(ResourceManager, File, String)): newDir
    //#input(void extractFiles(ResourceManager, File, String)): res
    //#input(void extractFiles(ResourceManager, File, String)): suffix
    //#input(void extractFiles(ResourceManager, File, String)): suffix._tainted
    //#pre[2] (void extractFiles(ResourceManager, File, String)): res != null
    //#presumption(void extractFiles(ResourceManager, File, String)): init'ed(com.dmdirc.logger.ErrorLevel.LOW)
    //#presumption(void extractFiles(ResourceManager, File, String)): com.dmdirc.util.resourcemanager.ResourceManager:getResourceManager(...)@111 != null
    //#presumption(void extractFiles(ResourceManager, File, String)): com.dmdirc.util.resourcemanager.ResourceManager:getResourcesEndingWithAsBytes(...)@101 != null
    //#presumption(void extractFiles(ResourceManager, File, String)): java.util.Iterator:next(...)@102 != null
    //#presumption(void extractFiles(ResourceManager, File, String)): java.util.Map:entrySet(...)@102 != null
    //#presumption(void extractFiles(ResourceManager, File, String)): java.util.Map_Entry:getKey(...)@104 != null
    //#test_vector(void extractFiles(ResourceManager, File, String)): java.io.File:exists(...)@110: {0}, {1}
    //#test_vector(void extractFiles(ResourceManager, File, String)): java.io.File:isDirectory(...)@109: {1}, {0}
    //#test_vector(void extractFiles(ResourceManager, File, String)): java.util.Iterator:hasNext(...)@102: {0}, {1}
		for (Entry<String, byte[]> resource : resources.entrySet()) {
			try {
				final String key = resource.getKey();
				final String resourceName = key.substring(key.lastIndexOf('/'), key.length());

				final File newFile = new File(newDir, resourceName);

				if (!newFile.isDirectory()) {
					if (newFile.exists()) { newFile.delete(); }
					ResourceManager.getResourceManager().resourceToFile(resource.getValue(), newFile);
    //#WindowsMediaSourcePlugin.java:111: Warning: method not available - call not analyzed
    //#    call on ResourceManager com.dmdirc.util.resourcemanager.ResourceManager:getResourceManager()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void extractFiles(ResourceManager, File, String)
    //#    unanalyzed callee: ResourceManager com.dmdirc.util.resourcemanager.ResourceManager:getResourceManager()
    //#WindowsMediaSourcePlugin.java:111: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.util.resourcemanager.ResourceManager:resourceToFile(byte[], File)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void extractFiles(ResourceManager, File, String)
    //#    unanalyzed callee: void com.dmdirc.util.resourcemanager.ResourceManager:resourceToFile(byte[], File)
				}
			} catch (IOException ex) {
				Logger.userError(ErrorLevel.LOW, "Failed to extract "+suffix+"s for windowsmediasource: "+ex.getMessage(), ex);
    //#WindowsMediaSourcePlugin.java:114: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void extractFiles(ResourceManager, File, String)
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String, Throwable)
			}
		}
	}
    //#WindowsMediaSourcePlugin.java:117: end of method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.extractFiles(ResourceManager, File, String)
	
	/** {@inheritDoc} */
	@Override
	public void onLoad() {
		// Extract GetMediaInfo.exe and required DLLs
		final PluginInfo pi = PluginManager.getPluginManager().getPluginInfoByName("windowsmediasource");
    //#WindowsMediaSourcePlugin.java:123: method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.onLoad()
    //#WindowsMediaSourcePlugin.java:123: Warning: method not available - call not analyzed
    //#    call on PluginManager com.dmdirc.plugins.PluginManager:getPluginManager()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void onLoad()
    //#    unanalyzed callee: PluginManager com.dmdirc.plugins.PluginManager:getPluginManager()
    //#WindowsMediaSourcePlugin.java:123: Warning: method not available - call not analyzed
    //#    call on PluginInfo com.dmdirc.plugins.PluginManager:getPluginInfoByName(String)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void onLoad()
    //#    unanalyzed callee: PluginInfo com.dmdirc.plugins.PluginManager:getPluginInfoByName(String)
    //#input(void onLoad()): ".dll"._tainted
    //#input(void onLoad()): ".exe"._tainted
    //#input(void onLoad()): "Failed to extract "._tainted
    //#input(void onLoad()): "Unable to open ResourceManager for windowsmediasource: "._tainted
    //#input(void onLoad()): "s for windowsmediasource: "._tainted
    //#input(void onLoad()): com.dmdirc.logger.ErrorLevel.LOW
    //#input(void onLoad()): filesDir
    //#input(void onLoad()): this
    //#presumption(void onLoad()): init'ed(com.dmdirc.logger.ErrorLevel.LOW)
    //#presumption(void onLoad()): com.dmdirc.plugins.PluginInfo:getResourceManager(...)@130 != null
    //#presumption(void onLoad()): com.dmdirc.plugins.PluginManager:getPluginManager(...)@123 != null
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void onLoad()): Effects-of-calling:com.dmdirc.util.resourcemanager.ResourceManager:getResourcesEndingWithAsBytes
    //#unanalyzed(void onLoad()): Effects-of-calling:java.util.Map:entrySet
    //#unanalyzed(void onLoad()): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(void onLoad()): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void onLoad()): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void onLoad()): Effects-of-calling:java.util.Map$Entry:getKey
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.String:lastIndexOf
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.String:length
    //#unanalyzed(void onLoad()): Effects-of-calling:java.lang.String:substring
    //#unanalyzed(void onLoad()): Effects-of-calling:java.io.File
    //#unanalyzed(void onLoad()): Effects-of-calling:java.io.File:isDirectory
    //#unanalyzed(void onLoad()): Effects-of-calling:java.io.File:exists
    //#unanalyzed(void onLoad()): Effects-of-calling:java.io.File:delete
    //#unanalyzed(void onLoad()): Effects-of-calling:com.dmdirc.util.resourcemanager.ResourceManager:getResourceManager
    //#unanalyzed(void onLoad()): Effects-of-calling:java.util.Map$Entry:getValue
    //#unanalyzed(void onLoad()): Effects-of-calling:com.dmdirc.util.resourcemanager.ResourceManager:resourceToFile
    //#unanalyzed(void onLoad()): Effects-of-calling:java.io.IOException:getMessage
    //#unanalyzed(void onLoad()): Effects-of-calling:com.dmdirc.logger.Logger:userError
    //#test_vector(void onLoad()): com.dmdirc.plugins.PluginManager:getPluginInfoByName(...)@123: Inverse{null}, Addr_Set{null}
    //#test_vector(void onLoad()): java.io.File:exists(...)@134: {1}, {0}
		
		// This shouldn't actually happen, but check to make sure.
		if (pi == null) { return; }
		
		// Now get the RM
		try {
			final ResourceManager res = pi.getResourceManager();
    //#WindowsMediaSourcePlugin.java:130: Warning: method not available - call not analyzed
    //#    call on ResourceManager com.dmdirc.plugins.PluginInfo:getResourceManager()
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void onLoad()
    //#    unanalyzed callee: ResourceManager com.dmdirc.plugins.PluginInfo:getResourceManager()
			
			// Make sure our files dir exists
			final File newDir = new File(filesDir);
			if (!newDir.exists()) {
				newDir.mkdirs();
			}
		
			// Now extract the .dlls and .exe
			extractFiles(res, newDir, ".dll");
			extractFiles(res, newDir, ".exe");
		} catch (IOException ioe) {
			Logger.userError(ErrorLevel.LOW, "Unable to open ResourceManager for windowsmediasource: "+ioe.getMessage(), ioe);
    //#WindowsMediaSourcePlugin.java:142: Warning: method not available - call not analyzed
    //#    call on void com.dmdirc.logger.Logger:userError(ErrorLevel, String, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
    //#    method: void onLoad()
    //#    unanalyzed callee: void com.dmdirc.logger.Logger:userError(ErrorLevel, String, Throwable)
		}
	}
    //#WindowsMediaSourcePlugin.java:144: end of method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.onLoad()
	
	/** {@inheritDoc} */
	@Override
	public void onUnload() { /* Do Nothing */ }
    //#WindowsMediaSourcePlugin.java:148: method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.onUnload()
    //#WindowsMediaSourcePlugin.java:148: end of method: void com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin.onUnload()
}
    //#WindowsMediaSourcePlugin.java:: end of class: com.dmdirc.addons.mediasource_windows.WindowsMediaSourcePlugin
