📄 updatecheckinstanceimpl.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: UpdateCheckInstanceImpl.java
package org.gudy.azureus2.pluginsimpl.local.update;
import java.util.*;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.update.*;
import org.gudy.azureus2.plugins.utils.resourcedownloader.ResourceDownloader;
// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.update:
// UpdatableComponentImpl, UpdateCheckerImpl, UpdateImpl
public class UpdateCheckInstanceImpl
implements UpdateCheckInstance
{
private static final LogIDs LOGID;
private List listeners;
private List updates;
private List decision_listeners;
private AESemaphore sem;
private UpdateManager manager;
private int check_type;
private String name;
private UpdatableComponentImpl components[];
private UpdateCheckerImpl checkers[];
private boolean completed;
private boolean cancelled;
private boolean automatic;
private boolean low_noise;
protected AEMonitor this_mon;
private Map properties;
protected UpdateCheckInstanceImpl(UpdateManager _manager, int _check_type, String _name, UpdatableComponentImpl _components[])
{
listeners = new ArrayList();
updates = new ArrayList();
decision_listeners = new ArrayList();
sem = new AESemaphore("UpdateCheckInstance");
automatic = true;
low_noise = false;
this_mon = new AEMonitor("UpdateCheckInstance");
properties = new HashMap();
properties.put(Integer.valueOf(1), Integer.valueOf(1));
manager = _manager;
check_type = _check_type;
name = _name;
components = _components;
checkers = new UpdateCheckerImpl[components.length];
for (int i = 0; i < components.length; i++)
{
UpdatableComponentImpl comp = components[i];
checkers[i] = new UpdateCheckerImpl(this, comp, sem);
}
}
public int getType()
{
return check_type;
}
public String getName()
{
return name;
}
public void addUpdatableComponent(UpdatableComponent component, boolean mandatory)
{
UpdatableComponentImpl comp = new UpdatableComponentImpl(component, mandatory);
UpdatableComponentImpl new_comps[] = new UpdatableComponentImpl[components.length + 1];
System.arraycopy(components, 0, new_comps, 0, components.length);
new_comps[components.length] = comp;
components = new_comps;
UpdateCheckerImpl checker = new UpdateCheckerImpl(this, comp, sem);
UpdateCheckerImpl new_checkers[] = new UpdateCheckerImpl[checkers.length + 1];
System.arraycopy(checkers, 0, new_checkers, 0, checkers.length);
new_checkers[checkers.length] = checker;
checkers = new_checkers;
}
public void setAutomatic(boolean a)
{
automatic = a;
}
public boolean isAutomatic()
{
return automatic;
}
public void setLowNoise(boolean a)
{
low_noise = a;
}
public boolean isLowNoise()
{
return low_noise;
}
public Object getProperty(int property_name)
{
return properties.get(Integer.valueOf(property_name));
}
public void setProperty(int property_name, Object value)
{
properties.put(Integer.valueOf(property_name), value);
}
public void start()
{
for (int i = 0; i < components.length; i++)
{
UpdateCheckerImpl checker = checkers[i];
(new AEThread2(true, checker) {
final UpdateCheckerImpl val$checker;
final UpdateCheckInstanceImpl this$0;
public void run()
{
try
{
checker.getComponent().checkForUpdate(checker);
}
catch (Throwable e)
{
checker.reportProgress((new StringBuilder()).append("Update check failed: ").append(Debug.getNestedExceptionMessage(e)).toString());
e.printStackTrace();
checker.failed();
}
}
{
this$0 = UpdateCheckInstanceImpl.this;
checker = updatecheckerimpl;
super(x0, x1);
}
}).start();
}
(new AEThread2("UpdatableComponent Completion Waiter", true) {
final UpdateCheckInstanceImpl this$0;
public void run()
{
for (int i = 0; i < components.length; i++)
sem.reserve();
this_mon.enter();
if (cancelled)
{
this_mon.exit();
return;
}
completed = true;
this_mon.exit();
break MISSING_BLOCK_LABEL_96;
Exception exception;
exception;
this_mon.exit();
throw exception;
boolean mandatory_failed = false;
int i = 0;
do
{
if (i >= checkers.length)
break;
if (components[i].isMandatory() && checkers[i].getFailed())
{
mandatory_failed = true;
break;
}
i++;
} while (true);
List target_updates = new ArrayList();
if (mandatory_failed)
{
if (Logger.isEnabled())
Logger.log(new LogEvent(UpdateCheckInstanceImpl.LOGID, 3, "Dropping all updates as a mandatory update check failed"));
} else
{
boolean mandatory_only = false;
int i = 0;
do
{
if (i >= updates.size())
break;
UpdateImpl update = (UpdateImpl)updates.get(i);
if (update.isMandatory())
{
mandatory_only = true;
break;
}
i++;
} while (true);
for (i = 0; i < updates.size(); i++)
{
UpdateImpl update = (UpdateImpl)updates.get(i);
if (update.isMandatory() || !mandatory_only)
{
target_updates.add(update);
continue;
}
if (Logger.isEnabled())
Logger.log(new LogEvent(UpdateCheckInstanceImpl.LOGID, 3, (new StringBuilder()).append("Dropping update '").append(update.getName()).append("' as non-mandatory and ").append("mandatory updates found").toString()));
}
}
updates = target_updates;
for (int i = 0; i < listeners.size(); i++)
try
{
((UpdateCheckInstanceListener)listeners.get(i)).complete(UpdateCheckInstanceImpl.this);
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
return;
}
{
this$0 = UpdateCheckInstanceImpl.this;
super(x0, x1);
}
}).start();
}
protected UpdateImpl addUpdate(UpdatableComponentImpl comp, String update_name, String desc[], String new_version, ResourceDownloader downloaders[], int restart_required)
{
UpdateImpl updateimpl;
this_mon.enter();
UpdateImpl update = new UpdateImpl(this, update_name, desc, new_version, downloaders, comp.isMandatory(), restart_required);
updates.add(update);
if (cancelled)
update.cancel();
updateimpl = update;
this_mon.exit();
return updateimpl;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public Update[] getUpdates()
{
Update aupdate[];
this_mon.enter();
Update res[] = new Update[updates.size()];
updates.toArray(res);
aupdate = res;
this_mon.exit();
return aupdate;
Exception exception;
exception;
this_mon.exit();
throw exception;
}
public UpdateChecker[] getCheckers()
{
return checkers;
}
public UpdateInstaller createInstaller()
throws UpdateException
{
return manager.createInstaller();
}
public void cancel()
{
boolean just_do_updates = false;
this_mon.enter();
if (completed)
just_do_updates = true;
cancelled = true;
this_mon.exit();
break MISSING_BLOCK_LABEL_43;
Exception exception;
exception;
this_mon.exit();
throw exception;
for (int i = 0; i < updates.size(); i++)
((UpdateImpl)updates.get(i)).cancel();
if (!just_do_updates)
{
for (int i = 0; i < checkers.length; i++)
if (checkers[i] != null)
checkers[i].cancel();
for (int i = 0; i < listeners.size(); i++)
try
{
((UpdateCheckInstanceListener)listeners.get(i)).cancelled(this);
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
return;
}
public boolean isCancelled()
{
return cancelled;
}
public UpdateManager getManager()
{
return manager;
}
protected Object getDecision(Update update, int decision_type, String decision_name, String decision_description, Object decision_data)
{
for (int i = 0; i < decision_listeners.size(); i++)
{
Object res = ((UpdateManagerDecisionListener)decision_listeners.get(i)).decide(update, decision_type, decision_name, decision_description, decision_data);
if (res != null)
return res;
}
return null;
}
public void addDecisionListener(UpdateManagerDecisionListener l)
{
decision_listeners.add(l);
}
public void removeDecisionListener(UpdateManagerDecisionListener l)
{
decision_listeners.remove(l);
}
public void addListener(UpdateCheckInstanceListener l)
{
listeners.add(l);
if (completed)
l.complete(this);
else
if (cancelled)
l.cancelled(this);
}
public void removeListener(UpdateCheckInstanceListener l)
{
listeners.remove(l);
}
static
{
LOGID = LogIDs.CORE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -