|
@@ -32,6 +32,7 @@ import com.dmdirc.util.InvalidConfigFileException;
|
32
|
32
|
import com.dmdirc.logger.Logger;
|
33
|
33
|
import com.dmdirc.logger.ErrorLevel;
|
34
|
34
|
|
|
35
|
+import com.dmdirc.updater.Version;
|
35
|
36
|
import java.io.File;
|
36
|
37
|
import java.io.IOException;
|
37
|
38
|
import java.lang.reflect.Constructor;
|
|
@@ -144,7 +145,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
144
|
145
|
throw new PluginException("Plugin "+filename+" failed to load, plugin.config failed to open - "+e.getMessage(), e);
|
145
|
146
|
}
|
146
|
147
|
|
147
|
|
- if (getVersion() < 0) {
|
|
148
|
+ if (!getVersion().isValid()) {
|
148
|
149
|
lastError = "Incomplete plugin.config (Missing or invalid 'version')";
|
149
|
150
|
throw new PluginException("Plugin "+filename+" failed to load. "+lastError);
|
150
|
151
|
} else if (getAuthor().isEmpty()) {
|
|
@@ -664,36 +665,21 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
664
|
665
|
if (pi == null) {
|
665
|
666
|
requirementsError = "Required plugin '"+data[0]+"' was not found";
|
666
|
667
|
return false;
|
667
|
|
- } else if (pi.getVersion() == 0) {
|
668
|
|
- // Probably compiled from a non-svn version, assume version is ok
|
669
|
|
- return true;
|
670
|
668
|
} else {
|
671
|
669
|
if (data.length > 1) {
|
672
|
670
|
// Check plugin minimum version matches.
|
673
|
|
- try {
|
674
|
|
- final int minversion = Integer.parseInt(data[1]);
|
675
|
|
- if (pi.getVersion() < minversion) {
|
676
|
|
- requirementsError = "Plugin '"+data[0]+"' is too old (Required Version: "+minversion+", Actual Version: "+pi.getVersion()+")";
|
677
|
|
- return false;
|
678
|
|
- } else {
|
679
|
|
- if (data.length > 2) {
|
680
|
|
- // Check plugin maximum version matches.
|
681
|
|
- try {
|
682
|
|
- final int maxversion = Integer.parseInt(data[2]);
|
683
|
|
- if (pi.getVersion() > maxversion) {
|
684
|
|
- requirementsError = "Plugin '"+data[0]+"' is too new (Required Version: "+maxversion+", Actual Version: "+pi.getVersion()+")";
|
685
|
|
- return false;
|
686
|
|
- }
|
687
|
|
- } catch (NumberFormatException nfe) {
|
688
|
|
- requirementsError = "Plugin max-version '"+data[2]+"' for plugin ('"+data[0]+"') is a non-integer";
|
689
|
|
- return false;
|
690
|
|
- }
|
691
|
|
- }
|
692
|
|
- }
|
693
|
|
- } catch (NumberFormatException nfe) {
|
694
|
|
- requirementsError = "Plugin min-version '"+data[1]+"' for plugin ('"+data[0]+"') is a non-integer";
|
695
|
|
- return false;
|
696
|
|
- }
|
|
671
|
+ if (pi.getVersion().compareTo(new Version(data[1])) < 0) {
|
|
672
|
+ requirementsError = "Plugin '"+data[0]+"' is too old (Required Version: "+data[1]+", Actual Version: "+pi.getVersion()+")";
|
|
673
|
+ return false;
|
|
674
|
+ } else {
|
|
675
|
+ if (data.length > 2) {
|
|
676
|
+ // Check plugin maximum version matches.
|
|
677
|
+ if (pi.getVersion().compareTo(new Version(data[2])) > 0) {
|
|
678
|
+ requirementsError = "Plugin '"+data[0]+"' is too new (Required Version: "+data[2]+", Actual Version: "+pi.getVersion()+")";
|
|
679
|
+ return false;
|
|
680
|
+ }
|
|
681
|
+ }
|
|
682
|
+ }
|
697
|
683
|
}
|
698
|
684
|
}
|
699
|
685
|
}
|
|
@@ -1148,12 +1134,8 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
1148
|
1134
|
*
|
1149
|
1135
|
* @return Plugin Version
|
1150
|
1136
|
*/
|
1151
|
|
- public int getVersion() {
|
1152
|
|
- try {
|
1153
|
|
- return Integer.parseInt(getKeyValue("version", "number", "0"));
|
1154
|
|
- } catch (NumberFormatException nfe) {
|
1155
|
|
- return -1;
|
1156
|
|
- }
|
|
1137
|
+ public Version getVersion() {
|
|
1138
|
+ return new Version(getKeyValue("version", "number", "0"));
|
1157
|
1139
|
}
|
1158
|
1140
|
|
1159
|
1141
|
/**
|