ArrayList<SoftwareUpdateItem> updateItems = new ArrayList<SoftwareUpdateItem>();
//ArrayList<PluginsSoftwareUpdateItem> blockedItems = new ArrayList<PluginsSoftwareUpdateItem>(0);
try {
SoftwareUpdateItem curItem=null;
String line=reader.readLine();
while (line != null) {
matcher=pluginTypePattern.matcher(line);
if (matcher.find()) { // new plugin
String type=matcher.group(1);
String className=matcher.group(2);
if ("plugin".equals(type)) {
curItem=new PluginSoftwareUpdateItem(className);
}
else if ("dataservice".equals(type)) {
curItem=new DataServiceSoftwareUpdateItem(className);
}
else if ("tvbrowser".equals(type)) {
curItem=new TvbrowserSoftwareUpdateItem(className);
}
if (curItem==null) {
throw new IOException("invalid software update file");
}
updateItems.add(curItem);
}
else {
matcher=keyValuePattern.matcher(line);
if (matcher.find()) { // new plugin
String value = matcher.group(2);
value = value.replaceAll("\\\\", ""); // fix wrong HTML encoding in plugin descriptions
if(curItem != null) {
curItem.addProperty(matcher.group(1), value);
}
}
}
line=reader.readLine();
}
mIsRequestingBlockArrayClear = true;
Settings.propBlockedPluginArray.clear(this);
mIsRequestingBlockArrayClear = false;
// remove all items we can't use
Iterator<SoftwareUpdateItem> it = updateItems.iterator();
while (it.hasNext()) {
SoftwareUpdateItem item = it.next();
String className = item.getClassName();
// remove incompatible items
Version required = item.getRequiredVersion();
Version maximum = item.getMaximumVersion();
if ((required!=null && TVBrowser.VERSION.compareTo(required)<0) ||
(maximum != null && TVBrowser.VERSION.compareTo(maximum)>0) ||
!item.getProperty("filename").toLowerCase().endsWith(".jar") ||
!item.isSupportingCurrentOs()) {
/* maximum contains the block start version if this is a block plugin entry
* required cotains the block end version
*/
if(required!=null && maximum != null && required.compareTo(maximum) > 0) {
if(item instanceof PluginsSoftwareUpdateItem) {
PluginsSoftwareUpdateItem blocked = (PluginsSoftwareUpdateItem)item;
mBlockRequestingPluginId = blocked.getId();
Settings.propBlockedPluginArray.addBlockedPlugin(this, mBlockRequestingPluginId, blocked.getMaximumVersion(), blocked.getRequiredVersion());
mBlockRequestingPluginId = null;
}
if(item.getVersion().compareTo(required) <= 0 && item.getVersion().compareTo(maximum) >= 0) {
it.remove();
continue;
}
}
else {
it.remove();
continue;
}
}
// remove already installed plugins
String pluginId = "java." + className.toLowerCase() + "." + className;
if(baseInfos == null) {
PluginProxy installedPlugin = PluginProxyManager.getInstance().getPluginForId(pluginId);
if(onlyUpdates) {
// remove all not installed plugins
if (installedPlugin == null) {
TvDataServiceProxy service = TvDataServiceProxyManager.getInstance().findDataServiceById(className.toLowerCase()+"."+className);
if(service == null) {
it.remove();
continue;
}
}
}
if (installedPlugin!=null && ((installedPlugin.getInfo().getVersion().compareTo(item.getVersion())>0 ||
(installedPlugin.getInfo().getVersion().compareTo(item.getVersion())==0 && (!dragNdrop || item.getVersion().isStable()))))) {
it.remove();
continue;
}
// remove already installed dataservices
TvDataServiceProxy service= TvDataServiceProxyManager.getInstance().findDataServiceById(className.toLowerCase()+"."+className);
if (service!=null && ((service.getInfo().getVersion().compareTo(item.getVersion())>0) ||
(service.getInfo().getVersion().compareTo(item.getVersion())==0 && (!dragNdrop || item.getVersion().isStable())))) {
it.remove();
continue;
}
if(item.isOnlyUpdate() && installedPlugin == null && service == null) {
it.remove();
}
PluginProxyManager.getInstance().firePluginBlockListRenewed();
}
else {
PluginBaseInfo baseInfo = getBaseInfoFor(pluginId,baseInfos);
if(baseInfo == null) {
it.remove();
continue;
}
else if(baseInfo.getVersion().compareTo(item.getVersion()) >= 0) {
it.remove();
continue;
}
}
}