Index: trunk/jabberit_messenger/java_source/src/nu/fw/jeti/plugins/PluginsInfo.java
===================================================================
--- trunk/jabberit_messenger/java_source/src/nu/fw/jeti/plugins/PluginsInfo.java	(revision 1091)
+++ trunk/jabberit_messenger/java_source/src/nu/fw/jeti/plugins/PluginsInfo.java	(revision 1097)
@@ -25,17 +25,10 @@
 package nu.fw.jeti.plugins;
 
-import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.text.MessageFormat;
 import java.util.*;
-
-import javax.swing.UIManager;
 import javax.xml.parsers.SAXParser;
-
 import nu.fw.jeti.backend.Start;
-import nu.fw.jeti.backend.URLClassloader;
 import nu.fw.jeti.jabber.Backend;
 import nu.fw.jeti.util.I18N;
@@ -48,130 +41,32 @@
 public class PluginsInfo
 {
-	private static URLClassloader classLoader;//change back to private
+	private static Backend backend;
 	private static Map loadedPlugins = new HashMap();
 	public static Map loadedPreferencePanels = new HashMap();
-	private static Backend backend;
 	private static Map pluginInstances = new HashMap();
+	private static String pluginsJava;
 			
-	public PluginsInfo(Backend backend,SAXParser parser,Start start)
-	{
-		PluginsInfo.backend = backend;
-		
-		if( !Start.applet )
- 		{
-			classLoader = new URLClassloader(new URL[]{Start.programURL}, getClass().getClassLoader());
-			UIManager.put("ClassLoader", classLoader);
-		}		
-		new PluginData(parser);		
-		
-		
-//		nu.fw.jeti.plugins.xmppuri.Plugin.init(backend);
-//		loadedPlugins.put("xmpp",nu.fw.jeti.plugins.xmpp.Plugin.class);
-//		nu.fw.jeti.plugins.xmpp.Plugin.init(backend);
-
-//		loadedPlugins.put("compression",nu.fw.jeti.plugins.compression.Plugin.class);
-//		nu.fw.jeti.plugins.compression.Plugin.init(backend);
-//		loadedPreferencePanels.put("groupchatalerter",nu.fw.jeti.plugins.groupchatalerter.PrefPanel.class);
-		
-//		loadedPlugins.put("groupchatalerter",nu.fw.jeti.plugins.groupchatalerter.Plugin.class);
-//		nu.fw.jeti.plugins.groupchatalerter.Plugin.init(backend);
-//		nu.fw.jeti.plugins.groupchat.Plugin.init(backend);
-		
-		//new test.QueryServers(backend);
-//		
-//		nu.fw.jeti.plugins.pubsub.Plugin.init(backend);
-//		nu.fw.jeti.plugins.useractivity.Plugin.init(backend);
-//
-//		nu.fw.jeti.plugins.jingle.Plugin.init(backend);
-		
-		
-//		try
-//		{
-//			nu.fw.jeti.plugins.tts.Plugin.init(backend);
-//		}catch (Exception e){
-//			e.printStackTrace();
-//		}
-		
-//			nu.fw.jeti.plugins.vcard.Plugin.init(backend);
-		
-//		nu.fw.jeti.plugins.ichatavatars.Plugin.init(backend);
-//		loadedPlugins.put("ichatavatars", nu.fw.jeti.plugins.ichatavatars.Plugin.class);
-		
-	//	nu.fw.jeti.plugins.spell.Plugin.init(backend);
-	//	loadedPlugins.put("spell", nu.fw.jeti.plugins.spell.Plugin.class);
-	//	loadedPreferencePanels.put("spell",nu.fw.jeti.plugins.spell.PrefPanel.class);
-		
-	//	nu.fw.jeti.plugins.metaltheme.Plugin.init(backend);
-	//	loadedPreferencePanels.put("metaltheme",nu.fw.jeti.plugins.metaltheme.PrefPanel.class);
-		
-	//	nu.fw.jeti.plugins.filetransfer.Plugin.init(backend);
-	//	loadedPreferencePanels.put("filetransfer",nu.fw.jeti.plugins.filetransfer.PrefPanel.class);
-//		
-//			nu.fw.jeti.plugins.sound.Plugin.init(backend);
-//			loadedPreferencePanels.put("sound",nu.fw.jeti.plugins.sound.PrefPanel.class);
-//		
-	//	nu.fw.jeti.plugins.xhtml.Plugin.init(backend);
-	//	loadedPlugins.put("xhtml", nu.fw.jeti.plugins.xhtml.Plugin.class);
-			
-			//		}
-//		catch (Exception e)
-//		{
-//			// TOD Auto-generated catch block
-//			e.printStackTrace();
-//		}
-		
-//		nu.fw.jeti.plugins.search.Plugin.init(backend);
-		
-//		nu.fw.jeti.plugins.buddyspacemaps.Plugin.init(backend);
-		
-
-//		
-//		nu.fw.jeti.plugins.openpgp.Plugin.init(backend);
-//		loadedPlugins.put("openpgp", nu.fw.jeti.plugins.openpgp.Plugin.class);
-		
-		//nu.fw.jeti.plugins.translators.breezah.Plugin.init(backend);
-		
-			//new nu.fw.jeti.plugins.logtoserver.Plugin(backend);
-			//new nu.fw.jeti.plugins.servertolog.Plugin(backend);
-//	
-//		try
-//		{
-//			nu.fw.jeti.plugins.emoticons.Plugin.init(backend);
-//		} catch (IOException e)
-//		{
-//			e.printStackTrace();
-//		}
-//	loadedPlugins.put("emoticons", nu.fw.jeti.plugins.emoticons.Plugin.class);
-//	loadedPreferencePanels.put("emoticons",nu.fw.jeti.plugins.emoticons.PrefPanel.class);
-
-//		nu.fw.jeti.plugins.alertwindow.Plugin.init(backend);
-//		loadedPreferencePanels.put("alertwindow",nu.fw.jeti.plugins.alertwindow.PrefPanel.class);
-		
-		//start.LoadPlugins(urlString);
-		for (Iterator i = Preferences.getPlugins().iterator(); i.hasNext();)
-		{
-			Object[] temp = (Object[]) i.next();
-			if (temp[2] == null)continue; //missing plugin
-			if (((Boolean) temp[1]).booleanValue())
-			{
-				start.setSplashText((String) temp[0]);
-				loadPlugin((String) temp[0]);
-			}
-		}
-	}
-		
-	//translator hackje vervang door translator interfaces as in io
-	private static Translator translator;
-	
-	public static void setTranslator(Translator translator)
-	{
-		PluginsInfo.translator = translator;
-	}
-	
-	public static Translator getTranslator()
-	{
-		return translator;
-	}
-	
+	public PluginsInfo( Backend backend, Start start )
+	{
+		PluginsInfo.backend		= backend;
+		PluginsInfo.pluginsJava = nu.fw.jeti.applet.Jeti.JAVAPLUGINS;
+		
+		/**
+		 * Carregando plugins:
+		 * 
+		 * nu.fw.jeti.plugins.<NOME_do_Plugin>.Plugin.init( backend );
+		 * loadedPlugins.put("<NOME_do_Plugin>", nu.fw.jeti.plugins.<NOME_do_Plugin>.Plugin.class);
+		 * 
+		 * Exemplo : Plugin xhtml
+		 * nu.fw.jeti.plugins.xhtml.Plugin.init( backend );
+		 * loadedPlugins.put("xhtml", nu.fw.jeti.plugins.xhtml.Plugin.class);
+		 */
+		
+		String[] plugins = pluginsJava.split(",");	
+		
+		for(int i = 0 ; i < plugins.length; i++)
+			PluginsInfo.loadPlugin(plugins[i].toString());
+	}
+
 	public static boolean isPluginLoaded(String name)
 	{
@@ -179,93 +74,21 @@
 	}
 
-	public static void loadPlugin(String name)
-	{
-		Class loadedClass =null;
-		if (!Start.applet)
-		{//non applet version
-			URL url =null;// new URL[1];
-			try
-			{
-				//if (Start.programURL != null)
-					url = new URL(Start.programURL, "plugins/" + name + ".jar");
-				//else url = new URL(Start.localURL, "plugins/" + name + ".jar");
-			}
-			catch (MalformedURLException e)
-			{}
-			//System.out.println(url);
-			//URLClassLoader loader = new URLClassLoader(url, parentClassLoader);
-			classLoader.addURL(url); 
-			try
-			{
-				loadedClass = classLoader.loadClass("nu.fw.jeti.plugins." + name + ".Plugin");
-			}
-			catch (ClassNotFoundException e)
-			{
-				System.err.println(MessageFormat.format(I18N.gettext("main.error.{0}_plugin_not_found"), new Object[]{name}));
-				return;
-			}
-		}
-		else loadedClass = nu.fw.jeti.applet.Jeti.getPlugin(name);
-		
-		
-		try
-		{//init plugin
+	private static void loadPlugin(String name)
+	{
+		Class loadedClass = nu.fw.jeti.applet.Jeti.getPlugin(name);
+		
+		try
+		{
+			//Init plugin
 			Method m = loadedClass.getMethod("init",new Class[]{Backend.class});
 			m.invoke(null,new Object[]{backend});
-		}catch(Exception e)
+		}
+		catch(Exception e)
 		{
 			e.printStackTrace();
-            //System.err.println(MessageFormat.format(I18N.gettext("main.error.{0}_plugin_failed_to_load"), new Object[]{name}));
 			return;
 		}
 		
-		
-//		if (!loadOnFirstUse)
-//		{
-//			
-//			try
-//			{
-//				Constructor c = loadedClass.getConstructor(new Class[] { Class.forName("nu.fw.jeti.jabber.Backend")});
-//				addInstance(name, new WeakReference(c.newInstance(new Object[] { backend })));
-//			}
-//			catch (InvocationTargetException ie)
-//			{
-//				ie.printStackTrace();
-//				//System.out.println("Error while initializing " + name + " : " + ie.getCause().getMessage());
-//				return;
-//			}
-//			catch (Exception e2)
-//			{
-//				e2.printStackTrace();
-//				return;
-//			}
-//		}
-		
 		loadedPlugins.put(name, loadedClass);
-		if(!Start.applet)
-		{	
-			try
-			{
-				loadedPreferencePanels.put(name, classLoader.loadClass("nu.fw.jeti.plugins." + name + ".PrefPanel"));
-			}
-			catch (ClassNotFoundException e)
-			{
-                            // Do nothing
-			}
-		}
-		else nu.fw.jeti.applet.Jeti.getPrefPanel(name,loadedPreferencePanels);
-		//System.out.println(name + "loaded");
-	}
-	
-	public static void loadLibrary(String name)
-	{
-		URL url =null;
-		try
-		{
-			url = new URL(Start.programURL, "lib/" + name + ".jar");
-		}
-		catch (MalformedURLException e)
-		{}
-		classLoader.addURL(url);
 	}
 	
@@ -273,15 +96,24 @@
 	{
 		Class loadedClass = (Class)loadedPlugins.remove(name);
-                if (loadedClass == null) {
-                    return;
-                }
-		System.out.println("removing "+ name);
-		loadedPreferencePanels.remove(name);
+        
+		if (loadedClass == null)
+			return;
+
+        System.out.println(I18N.gettext("main.pluginsInfo.Plugin_removing") + " : " + name);
+		
+        loadedPreferencePanels.remove(name);
+        
 		List list = (List) pluginInstances.remove(name);
-		try
-		{//unload cleaning
+		
+		try
+		{
+			//unload cleaning
 			Method m = loadedClass.getMethod("unload",new Class[]{Backend.class});
 			m.invoke(null,new Object[]{backend});
-		}catch(NoSuchMethodException e){System.out.println(name + " has no remove");}
+		}
+		catch(NoSuchMethodException e)
+		{
+			System.out.println("ERRO : " + name + " " + I18N.gettext("main.pluginsInfo.has_no_remove"));
+		}
 		catch(Exception e)
 		{
@@ -289,13 +121,18 @@
 		}
 				
-		if (list == null) return;
+		if ( list == null)
+			return;
+		
 		for (Iterator i = list.iterator(); i.hasNext();)
-		{//unload loaded plugins
+		{	
+			//unload loaded plugins
 			Plugins plugin = (Plugins)((WeakReference)i.next()).get();
-			if (plugin !=null)plugin.unload();
-		}
-		System.out.println(name +" removed");
-	}
-	
+			
+			if ( plugin != null )
+				plugin.unload();
+		}
+		
+		System.out.println( "Removed plugin : " + name );
+	}
 	
 	/**
@@ -314,5 +151,9 @@
 				Method m = loadedClass.getMethod("getInstance",null);
 				o = m.invoke(null,null);
-			}catch(NoSuchMethodException e){System.out.println(name + " has no instance method");}
+			}
+			catch(NoSuchMethodException e)
+			{
+				System.out.println(name + " has no instance method");
+			}
 			catch(Exception e)
 			{
@@ -323,7 +164,7 @@
 		{
 			ie.printStackTrace();
-			//System.out.println("Error while initializing " + name + " : " + ie.getCause().getMessage());
 			return null;
 		}
+
 		return o;
 	}
@@ -332,4 +173,5 @@
 	{
 		Object o = null;
+		
 		try
 		{
@@ -340,7 +182,7 @@
 		{
 			ie.printStackTrace();
-			//System.out.println("Error while initializing " + name + " : " + ie.getCause().getMessage());
 			return null;
 		}
+		
 		return (Plugins) o;
 	}
@@ -349,4 +191,5 @@
 	{
 		List list = (List) pluginInstances.get(name);
+		
 		if (list == null)
 		{
@@ -354,4 +197,5 @@
 			pluginInstances.put(name, list);
 		}
+		
 		list.add(new WeakReference(object));
 	}
@@ -360,4 +204,5 @@
 	{
 		StringBuffer buffer = new StringBuffer();
+		
 		for(Iterator i = loadedPlugins.entrySet().iterator();i.hasNext();)
 		{
@@ -368,23 +213,28 @@
 				 text = (String) ((Class)entry.getValue()).getField("ABOUT").get(null);
 			}
-			catch (Exception e1)
-			{}
-			if(text!=null) buffer.append("\n - " + (String)entry.getKey() + '\n' + text);
-		 }
-		 return buffer.toString(); 
+			catch (Exception e1){}
+			
+			if( text != null)
+				buffer.append("\n - " + (String)entry.getKey() + '\n' + text);
+		}
+		 
+		return buffer.toString(); 
 	} 
 	
-	//remove plugins
+	// Remove plugins
 	public void exit()
 	{
-		String[] temp=new String[loadedPlugins.size()];
+		String[] temp = new String[loadedPlugins.size()];
 		loadedPlugins.keySet().toArray(temp);
+		
 		for(int i=0;i<temp.length;i++)
 		{
 			unloadPlugin(temp[i]);
 		}
-		System.out.println("plugins unloaded");
+		
+		System.out.println(I18N.gettext("main.pluginsInfo.plugins_unloaded"));
 	}
 }
+
 /*
  * Overrides for emacs
