From 34595bc248660a6cd9c51f2b7a18ed33ae31cce4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 18 May 2008 04:21:44 +0000 Subject: Some cleanup in the VSDefaultPrefs. Initial ProtocolEvent, which is for protocol activation/deactivation --- .../events/implementations/ProcessCrashEvent.java | 2 +- .../implementations/ProcessRecoverEvent.java | 2 +- .../implementations/ProtocolActivateEvent.java | 11 ----- sources/events/implementations/ProtocolEvent.java | 52 ++++++++++++++++++++++ 4 files changed, 54 insertions(+), 13 deletions(-) delete mode 100644 sources/events/implementations/ProtocolActivateEvent.java create mode 100644 sources/events/implementations/ProtocolEvent.java (limited to 'sources/events/implementations') diff --git a/sources/events/implementations/ProcessCrashEvent.java b/sources/events/implementations/ProcessCrashEvent.java index de5dfa5..c82fdb4 100644 --- a/sources/events/implementations/ProcessCrashEvent.java +++ b/sources/events/implementations/ProcessCrashEvent.java @@ -5,7 +5,7 @@ import events.VSProcessEvent; public class ProcessCrashEvent extends VSProcessEvent { public void onStart() { - process.logg(prefs.getString("lang.crashed")); process.isCrashed(true); + logg(prefs.getString("lang.crashed")); } } diff --git a/sources/events/implementations/ProcessRecoverEvent.java b/sources/events/implementations/ProcessRecoverEvent.java index 6522537..f0b54d4 100644 --- a/sources/events/implementations/ProcessRecoverEvent.java +++ b/sources/events/implementations/ProcessRecoverEvent.java @@ -5,7 +5,7 @@ import events.VSProcessEvent; public class ProcessRecoverEvent extends VSProcessEvent { public void onStart() { - process.logg(prefs.getString("lang.recovered")); process.isCrashed(false); + logg(prefs.getString("lang.recovered")); } } diff --git a/sources/events/implementations/ProtocolActivateEvent.java b/sources/events/implementations/ProtocolActivateEvent.java deleted file mode 100644 index 6522537..0000000 --- a/sources/events/implementations/ProtocolActivateEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package events.implementations; - -import core.VSProcess; -import events.VSProcessEvent; - -public class ProcessRecoverEvent extends VSProcessEvent { - public void onStart() { - process.logg(prefs.getString("lang.recovered")); - process.isCrashed(false); - } -} diff --git a/sources/events/implementations/ProtocolEvent.java b/sources/events/implementations/ProtocolEvent.java new file mode 100644 index 0000000..442407d --- /dev/null +++ b/sources/events/implementations/ProtocolEvent.java @@ -0,0 +1,52 @@ +package events.implementations; + +import core.VSProcess; +import events.VSProcessEvent; +import protocols.VSRegisteredProtocols; + +public class ProtocolEvent extends VSProcessEvent { + private String protocolClassname; + private boolean isClientProtocol; /* true = client, false = server */ + private boolean isProtocolActivation; /* true = activate, false = deactivate */ + + public void setProtocolClassname(String protocolClassname) { + this.protocolClassname = protocolClassname; + } + + public String getProtocolClassname() { + return protocolClassname; + } + + public void isClientProtocol(boolean isClientProtocol) { + this.isClientProtocol = isClientProtocol; + } + + public boolean isClientProtocol() { + return isClientProtocol; + } + + public void isProtocolActivation(boolean isProtocolActivation) { + this.isProtocolActivation = isProtocolActivation; + } + + public boolean isProtocolActivation() { + return isProtocolActivation; + } + + public void onStart() { + String type = isClientProtocol ? "client" : "server"; + String name = VSRegisteredProtocols.getProtocolName(protocolClassname); + process.setBoolean("sim."+name.toLowerCase()+"."+type+".enabled!", isProtocolActivation); + + StringBuffer buffer = new StringBuffer(); + buffer.append(VSRegisteredProtocols.getProtocolShortname(protocolClassname)); + buffer.append(" "); + buffer.append(isClientProtocol + ? prefs.getString("lang.client") : prefs.getString("lang.server")); + buffer.append(" "); + buffer.append(isProtocolActivation + ? prefs.getString("lang.activated") : prefs.getString("lang.deactivated")); + + logg(buffer.toString()); + } +} -- cgit v1.2.3