Changeset 1767 in josm
- Timestamp:
- 2009-07-11T14:52:02+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r1755 r1767 15 15 import java.util.List; 16 16 import java.util.Map; 17 import java.util.Set; 17 18 import java.util.TreeMap; 18 19 import java.util.jar.Attributes; … … 21 22 22 23 import org.openstreetmap.josm.Main; 24 import org.openstreetmap.josm.actions.AboutAction; 23 25 import org.openstreetmap.josm.tools.LanguageInfo; 24 26 … … 34 36 public int mainversion = 0; 35 37 public String className = null; 38 public boolean oldmode = false; 36 39 public String requires = null; 37 40 public String link = null; … … 70 73 if (manifest == null) 71 74 throw new IOException(file+" contains no manifest."); 72 scanManifest(manifest );75 scanManifest(manifest, false); 73 76 libraries.add(0, fileToURL(file)); 74 77 jar.close(); … … 78 81 } 79 82 80 public PluginInformation(InputStream manifestStream, String name ) {83 public PluginInformation(InputStream manifestStream, String name, String url) { 81 84 this.name = name; 82 85 try { 83 86 Manifest manifest = new Manifest(); 84 87 manifest.read(manifestStream); 85 scanManifest(manifest); 88 if(url != null) 89 downloadlink = url; 90 scanManifest(manifest, url != null); 86 91 } catch (IOException e) { 87 92 throw new PluginException(null, name, e); … … 89 94 } 90 95 91 private void scanManifest(Manifest manifest )96 private void scanManifest(Manifest manifest, boolean oldcheck) 92 97 { 93 98 String lang = LanguageInfo.getLanguageCodeManifest(); … … 114 119 catch(NumberFormatException e) {} 115 120 author = attr.getValue("Author"); 121 if(oldcheck && mainversion > AboutAction.getVersionNumber()) 122 { 123 int myv = AboutAction.getVersionNumber(); 124 for(Map.Entry entry : attr.entrySet()) 125 { 126 try { 127 String key = ((Attributes.Name)entry.getKey()).toString(); 128 if(key.endsWith("_Plugin-Url")) 129 { 130 int mv = Integer.parseInt(key.substring(0,key.length()-11)); 131 if(mv <= myv && (mv > mainversion || mainversion > myv)) 132 { 133 String v = (String)entry.getValue(); 134 int i = v.indexOf(";"); 135 if(i > 0) 136 { 137 downloadlink = v.substring(i+1); 138 mainversion = mv; 139 version = v.substring(0,i); 140 oldmode = true; 141 } 142 } 143 } 144 } 145 catch(Exception e) { e.printStackTrace(); } 146 } 147 } 116 148 117 149 String classPath = attr.getValue(Attributes.Name.CLASS_PATH); … … 213 245 InputStream manifestStream = PluginInformation.class.getResourceAsStream("/org/openstreetmap/josm/plugins/"+name+"/MANIFEST.MF"); 214 246 if (manifestStream != null) 215 return new PluginInformation(manifestStream, pluginName );247 return new PluginInformation(manifestStream, pluginName, null); 216 248 217 249 Collection<String> locations = getPluginLocations(); -
trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java
r1739 r1767 168 168 if ((remoteversion == null) || remoteversion.equals("")) 169 169 remoteversion = tr("unknown"); 170 else if(plugin.oldmode) 171 remoteversion += "*"; 170 172 171 173 String localversion = ""; … … 284 286 PluginInformation info = new PluginInformation( 285 287 new ByteArrayInputStream(manifest.getBytes("utf-8")), 286 name.substring(0,name.length()-4)); 287 info.downloadlink = url; 288 name.substring(0,name.length()-4), url); 288 289 if(!availablePlugins.containsKey(info.name)) 289 290 availablePlugins.put(info.name, info); … … 305 306 PluginInformation info = new PluginInformation( 306 307 new ByteArrayInputStream(manifest.getBytes("utf-8")), 307 name.substring(0,name.length()-4)); 308 info.downloadlink = url; 308 name.substring(0,name.length()-4), url); 309 309 if(!availablePlugins.containsKey(info.name)) 310 310 availablePlugins.put(info.name, info);
Note:
See TracChangeset
for help on using the changeset viewer.