projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use event bus to activate and deactivate the FCP interface.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
core
/
Preferences.java
diff --git
a/src/main/java/net/pterodactylus/sone/core/Preferences.java
b/src/main/java/net/pterodactylus/sone/core/Preferences.java
index
f44e977
..
1f28c69
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Preferences.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Preferences.java
@@
-17,8
+17,13
@@
package net.pterodactylus.sone.core;
package net.pterodactylus.sone.core;
+import net.pterodactylus.sone.core.event.InsertionDelayChangedEvent;
import net.pterodactylus.sone.fcp.FcpInterface;
import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired;
import net.pterodactylus.sone.fcp.FcpInterface;
import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired;
+import net.pterodactylus.sone.fcp.event.FcpInterfaceActivatedEvent;
+import net.pterodactylus.sone.fcp.event.FcpInterfaceDeactivatedEvent;
+
+import com.google.common.eventbus.EventBus;
/**
* Convenience interface for external classes that want to access the core’s
/**
* Convenience interface for external classes that want to access the core’s
@@
-28,16
+33,11
@@
import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired;
*/
public class Preferences {
*/
public class Preferences {
- /** The wrapped options. */
+ private final EventBus eventBus;
private final Options options;
private final Options options;
- /**
- * Creates a new preferences object wrapped around the given options.
- *
- * @param options
- * The options to wrap
- */
- public Preferences(Options options) {
+ public Preferences(EventBus eventBus, Options options) {
+ this.eventBus = eventBus;
this.options = options;
}
this.options = options;
}
@@
-72,6
+72,7
@@
public class Preferences {
*/
public Preferences setInsertionDelay(Integer insertionDelay) {
options.getIntegerOption("InsertionDelay").set(insertionDelay);
*/
public Preferences setInsertionDelay(Integer insertionDelay) {
options.getIntegerOption("InsertionDelay").set(insertionDelay);
+ eventBus.post(new InsertionDelayChangedEvent(getInsertionDelay()));
return this;
}
return this;
}
@@
-345,6
+346,11
@@
public class Preferences {
*/
public Preferences setFcpInterfaceActive(boolean fcpInterfaceActive) {
options.getBooleanOption("ActivateFcpInterface").set(fcpInterfaceActive);
*/
public Preferences setFcpInterfaceActive(boolean fcpInterfaceActive) {
options.getBooleanOption("ActivateFcpInterface").set(fcpInterfaceActive);
+ if (fcpInterfaceActive) {
+ eventBus.post(new FcpInterfaceActivatedEvent());
+ } else {
+ eventBus.post(new FcpInterfaceDeactivatedEvent());
+ }
return this;
}
return this;
}
@@
-372,4
+378,4
@@
public class Preferences {
return this;
}
return this;
}
-}
\ No newline at end of file
+}