Browse Source

Fixes issue 1488: PluginInfo should look for "persistent" not "persistant"


git-svn-id: http://svn.dmdirc.com/trunk@4419 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Shane Mc Cormack 16 years ago
parent
commit
078e4953c3

+ 2
- 2
src/com/dmdirc/addons/dcc/plugin.info View File

6
 nicename=DCC Plugin
6
 nicename=DCC Plugin
7
 minversion=0
7
 minversion=0
8
 require-ui=com.dmdirc.ui.swing
8
 require-ui=com.dmdirc.ui.swing
9
-persistant-com.dmdirc.addons.dcc.actions.DCCActions=true
10
-persistant-com.dmdirc.addons.dcc.actions.DCCEvents=true
9
+persistent-com.dmdirc.addons.dcc.actions.DCCActions=true
10
+persistent-com.dmdirc.addons.dcc.actions.DCCEvents=true
11
 addonid=23
11
 addonid=23

+ 2
- 2
src/com/dmdirc/addons/nowplaying/plugin.info View File

5
 name=nowplaying
5
 name=nowplaying
6
 nicename=Now Playing Plugin
6
 nicename=Now Playing Plugin
7
 minversion=0
7
 minversion=0
8
-persistant-com.dmdirc.addons.nowplaying.MediaSource=true
9
-persistant-com.dmdirc.addons.nowplaying.MediaSourceManager=true
8
+persistent-com.dmdirc.addons.nowplaying.MediaSource=true
9
+persistent-com.dmdirc.addons.nowplaying.MediaSourceManager=true
10
 addonid=8
10
 addonid=8

+ 3
- 3
src/com/dmdirc/addons/timeplugin/plugin.info View File

5
 name=timeplugin
5
 name=timeplugin
6
 nicename=Time Plugin
6
 nicename=Time Plugin
7
 minversion=0
7
 minversion=0
8
-persistant-com.dmdirc.addons.timeplugin.TimeActionMetaType=true
9
-persistant-com.dmdirc.addons.timeplugin.TimeActionMetaType$1=true
10
-persistant-com.dmdirc.addons.timeplugin.TimeActionType=true
8
+persistent-com.dmdirc.addons.timeplugin.TimeActionMetaType=true
9
+persistent-com.dmdirc.addons.timeplugin.TimeActionMetaType$1=true
10
+persistent-com.dmdirc.addons.timeplugin.TimeActionType=true
11
 addonid=6
11
 addonid=6

+ 2
- 2
src/com/dmdirc/addons/userlevel/plugin.info View File

7
 minversion=0
7
 minversion=0
8
 addonid=21
8
 addonid=21
9
 
9
 
10
-persistant-com.dmdirc.addons.userlevel.AccessLevelComponent=true
11
-persistant-com.dmdirc.addons.userlevel.ChannelAccessLevelComponent=tre
10
+persistent-com.dmdirc.addons.userlevel.AccessLevelComponent=true
11
+persistent-com.dmdirc.addons.userlevel.ChannelAccessLevelComponent=tre

+ 2
- 2
src/com/dmdirc/plugins/GlobalClassLoader.java View File

32
 import java.util.Map;
32
 import java.util.Map;
33
 
33
 
34
 /**
34
 /**
35
- * This classloader knows about plugins and is used to store persistant classes.
35
+ * This classloader knows about plugins and is used to store persistent classes.
36
  */
36
  */
37
 public final class GlobalClassLoader extends ClassLoader {
37
 public final class GlobalClassLoader extends ClassLoader {
38
 
38
 
83
 	 * @throws ClassNotFoundException if the class to be loaded could not be found.
83
 	 * @throws ClassNotFoundException if the class to be loaded could not be found.
84
 	 */
84
 	 */
85
 	public Class<?> loadClass(final String name, final PluginInfo pi) throws ClassNotFoundException {
85
 	public Class<?> loadClass(final String name, final PluginInfo pi) throws ClassNotFoundException {
86
-		for (String classname : pi.getPersistantClasses()) {
86
+		for (String classname : pi.getPersistentClasses()) {
87
 			if (!resourcesList.containsKey(classname)) {
87
 			if (!resourcesList.containsKey(classname)) {
88
 				resourcesList.put(classname, pi.getFullFilename());
88
 				resourcesList.put(classname, pi.getFullFilename());
89
 			}
89
 			}

+ 3
- 3
src/com/dmdirc/plugins/PluginClassLoader.java View File

86
 
86
 
87
 		final String fileName = name.replace('.', '/')+".class";
87
 		final String fileName = name.replace('.', '/')+".class";
88
 		try {
88
 		try {
89
-			if (pluginInfo.isPersistant(name) || !res.resourceExists(fileName)) {
90
-				if (!pluginInfo.isPersistant(name) && askGlobal) {
89
+			if (pluginInfo.isPersistent(name) || !res.resourceExists(fileName)) {
90
+				if (!pluginInfo.isPersistent(name) && askGlobal) {
91
 					return GlobalClassLoader.getGlobalClassLoader().loadClass(name);
91
 					return GlobalClassLoader.getGlobalClassLoader().loadClass(name);
92
 				} else {
92
 				} else {
93
 					// Try to load class from previous load.
93
 					// Try to load class from previous load.
118
 		}
118
 		}
119
 		
119
 		
120
 		try {
120
 		try {
121
-			if (pluginInfo.isPersistant(name)) {
121
+			if (pluginInfo.isPersistent(name)) {
122
 				GlobalClassLoader.getGlobalClassLoader().defineClass(name, data);
122
 				GlobalClassLoader.getGlobalClassLoader().defineClass(name, data);
123
 			} else {
123
 			} else {
124
 				loadedClass = defineClass(name, data, 0, data.length);
124
 				loadedClass = defineClass(name, data, 0, data.length);

+ 42
- 30
src/com/dmdirc/plugins/PluginInfo.java View File

66
 	
66
 	
67
 	/** Last Error Message. */
67
 	/** Last Error Message. */
68
 	private String lastError = "No Error";
68
 	private String lastError = "No Error";
69
+	
70
+	/** Are we trying to load? */
71
+	private boolean isLoading = false;
69
 
72
 
70
 	/**
73
 	/**
71
 	 * Create a new PluginInfo.
74
 	 * Create a new PluginInfo.
166
 				}
169
 				}
167
 			}
170
 			}
168
 
171
 
169
-			if (isPersistant() && loadAll()) { loadEntirePlugin(); }
172
+			if (isPersistent() && loadAll()) { loadEntirePlugin(); }
170
 		} else {
173
 		} else {
171
 			lastError = "One or more requirements not met ("+requirementsError+")";
174
 			lastError = "One or more requirements not met ("+requirementsError+")";
172
 			throw new PluginException("Plugin "+filename+" was not loaded. "+lastError);
175
 			throw new PluginException("Plugin "+filename+" was not loaded. "+lastError);
572
 	 * Load the plugin files.
575
 	 * Load the plugin files.
573
 	 */
576
 	 */
574
 	public void loadPlugin() {
577
 	public void loadPlugin() {
578
+		System.out.println("["+getName()+"] loadPlugin called");
575
 		if (isTempLoaded()) {
579
 		if (isTempLoaded()) {
576
 			tempLoaded = false;
580
 			tempLoaded = false;
581
+			System.out.println("["+getName()+"] temp -> full");
582
+			System.out.println("["+getName()+"] loadingRequirements");
577
 			loadRequired();
583
 			loadRequired();
584
+			System.out.println("["+getName()+"] calling onLoad");
578
 			plugin.onLoad();
585
 			plugin.onLoad();
586
+			System.out.println("["+getName()+"] onLoad Result: "+lastError);
579
 		} else {
587
 		} else {
580
-			if (isLoaded() || metaData == null) {
581
-				lastError = "Not Loading: ("+isLoaded()+"||"+(metaData == null)+")";
588
+			if (isLoaded() || metaData == null || isLoading) {
589
+				lastError = "Not Loading: ("+isLoaded()+"||"+(metaData == null)+"||"+isLoading+")";
590
+				System.out.println("["+getName()+"] loadPlugin failed: "+lastError);
582
 				return;
591
 				return;
583
 			}
592
 			}
584
-			
593
+			isLoading = true;
594
+			System.out.println("["+getName()+"] loadingRequirements");
585
 			loadRequired();
595
 			loadRequired();
586
-			
596
+			System.out.println("["+getName()+"] loading Main class");
587
 			loadClass(getMainClass());
597
 			loadClass(getMainClass());
598
+			System.out.println("["+getName()+"] load Result: "+lastError);
588
 			if (isLoaded()) {
599
 			if (isLoaded()) {
589
 				ActionManager.processEvent(CoreActionType.PLUGIN_LOADED, null, this);
600
 				ActionManager.processEvent(CoreActionType.PLUGIN_LOADED, null, this);
590
 			}
601
 			}
602
+			isLoading = false;
591
 		}
603
 		}
592
 	}
604
 	}
593
 
605
 
667
 	 * Unload the plugin if possible.
679
 	 * Unload the plugin if possible.
668
 	 */
680
 	 */
669
 	public void unloadPlugin() {
681
 	public void unloadPlugin() {
670
-		if (!isPersistant() && (isLoaded() || isTempLoaded())) {
682
+		if (!isPersistent() && (isLoaded() || isTempLoaded())) {
671
 			if (!isTempLoaded()) {
683
 			if (!isTempLoaded()) {
672
 				try {
684
 				try {
673
 					plugin.onUnload();
685
 					plugin.onUnload();
761
 	}
773
 	}
762
 
774
 
763
 	/**
775
 	/**
764
-	 * Is this a persistant plugin?
776
+	 * Is this a persistent plugin?
765
 	 *
777
 	 *
766
-	 * @return true if persistant, else false
778
+	 * @return true if persistent, else false
767
 	 */
779
 	 */
768
-	public boolean isPersistant() {
769
-		final String persistance = metaData.getProperty("persistant","no");
770
-		return persistance.equalsIgnoreCase("true") || persistance.equalsIgnoreCase("yes");
780
+	public boolean isPersistent() {
781
+		final String persistence = metaData.getProperty("persistent","no");
782
+		return persistence.equalsIgnoreCase("true") || persistence.equalsIgnoreCase("yes");
771
 	}
783
 	}
772
 
784
 
773
 	/**
785
 	/**
774
-	 * Does this plugin contain any persistant classes?
786
+	 * Does this plugin contain any persistent classes?
775
 	 *
787
 	 *
776
-	 * @return true if this plugin contains any persistant classes, else false
788
+	 * @return true if this plugin contains any persistent classes, else false
777
 	 */
789
 	 */
778
-	public boolean hasPersistant() {
779
-		final String persistance = metaData.getProperty("persistant","no");
780
-		if (persistance.equalsIgnoreCase("true")) {
790
+	public boolean hasPersistent() {
791
+		final String persistence = metaData.getProperty("persistent","no");
792
+		if (persistence.equalsIgnoreCase("true")) {
781
 			return true;
793
 			return true;
782
 		} else {
794
 		} else {
783
 			for (Object keyObject : metaData.keySet()) {
795
 			for (Object keyObject : metaData.keySet()) {
784
-				if (keyObject.toString().toLowerCase().startsWith("persistant-")) {
796
+				if (keyObject.toString().toLowerCase().startsWith("persistent-")) {
785
 					return true;
797
 					return true;
786
 				}
798
 				}
787
 			}
799
 			}
790
 	}
802
 	}
791
 
803
 
792
 	/**
804
 	/**
793
-	 * Get a list of all persistant classes in this plugin
805
+	 * Get a list of all persistent classes in this plugin
794
 	 *
806
 	 *
795
-	 * @return List of all persistant classes in this plugin
807
+	 * @return List of all persistent classes in this plugin
796
 	 */
808
 	 */
797
-	public List<String> getPersistantClasses() {
809
+	public List<String> getPersistentClasses() {
798
 		final List<String> result = new ArrayList<String>();
810
 		final List<String> result = new ArrayList<String>();
799
-		final String persistance = metaData.getProperty("persistant","no");
800
-		if (persistance.equalsIgnoreCase("true")) {
811
+		final String persistence = metaData.getProperty("persistent","no");
812
+		if (persistence.equalsIgnoreCase("true")) {
801
 			try {
813
 			try {
802
 				ResourceManager res = getResourceManager();
814
 				ResourceManager res = getResourceManager();
803
 
815
 
811
 			}
823
 			}
812
 		} else {
824
 		} else {
813
 			for (Object keyObject : metaData.keySet()) {
825
 			for (Object keyObject : metaData.keySet()) {
814
-				if (keyObject.toString().toLowerCase().startsWith("persistant-")) {
826
+				if (keyObject.toString().toLowerCase().startsWith("persistent-")) {
815
 					result.add(keyObject.toString().substring(11));
827
 					result.add(keyObject.toString().substring(11));
816
 				}
828
 				}
817
 			}
829
 			}
820
 	}
832
 	}
821
 
833
 
822
 	/**
834
 	/**
823
-	 * Is this a persistant class?
835
+	 * Is this a persistent class?
824
 	 *
836
 	 *
825
-	 * @param classname class to check persistance of
826
-	 * @return true if file (or whole plugin) is persistant, else false
837
+	 * @param classname class to check persistence of
838
+	 * @return true if file (or whole plugin) is persistent, else false
827
 	 */
839
 	 */
828
-	public boolean isPersistant(final String classname) {
829
-		if (isPersistant()) {
840
+	public boolean isPersistent(final String classname) {
841
+		if (isPersistent()) {
830
 			return true;
842
 			return true;
831
 		} else {
843
 		} else {
832
-			final String persistance = metaData.getProperty("persistant-"+classname,"no");
833
-			return persistance.equalsIgnoreCase("true") || persistance.equalsIgnoreCase("yes");
844
+			final String persistence = metaData.getProperty("persistent-"+classname,"no");
845
+			return persistence.equalsIgnoreCase("true") || persistence.equalsIgnoreCase("yes");
834
 		}
846
 		}
835
 	}
847
 	}
836
 
848
 

+ 1
- 1
src/com/dmdirc/ui/swing/components/pluginpanel/PluginPanel.java View File

195
                 toggleButton.setEnabled(true);
195
                 toggleButton.setEnabled(true);
196
                 
196
                 
197
                 if (pluginInfo.getState()) {
197
                 if (pluginInfo.getState()) {
198
-                    if (pluginInfo.getPluginInfo().isPersistant()) {
198
+                    if (pluginInfo.getPluginInfo().isPersistent()) {
199
                         toggleButton.setEnabled(false);
199
                         toggleButton.setEnabled(false);
200
                     }
200
                     }
201
                     toggleButton.setText("Disable");
201
                     toggleButton.setText("Disable");

+ 2
- 2
src/com/dmdirc/updater/components/PluginComponent.java View File

92
     public boolean doInstall(final String path) throws Throwable {
92
     public boolean doInstall(final String path) throws Throwable {
93
         final File target = new File(plugin.getFullFilename());
93
         final File target = new File(plugin.getFullFilename());
94
         
94
         
95
-        if (!plugin.hasPersistant() && target.exists()) {
95
+        if (!plugin.hasPersistent() && target.exists()) {
96
             target.delete();
96
             target.delete();
97
         }
97
         }
98
         
98
         
99
-        if (plugin.hasPersistant() || !new File(path).renameTo(target)) {
99
+        if (plugin.hasPersistent() || !new File(path).renameTo(target)) {
100
             // Windows rocks!
100
             // Windows rocks!
101
             final File newTarget = new File(plugin.getFullFilename() + ".update");
101
             final File newTarget = new File(plugin.getFullFilename() + ".update");
102
             
102
             

Loading…
Cancel
Save