🚧 Add event for first start of Sone
[Sone.git] / src / main / java / net / pterodactylus / sone / main / SonePlugin.java
index 7723db1..4fd40f5 100644 (file)
@@ -23,9 +23,12 @@ import java.util.logging.Logger;
 import java.util.logging.*;
 
 import net.pterodactylus.sone.core.*;
+import net.pterodactylus.sone.core.event.*;
 import net.pterodactylus.sone.fcp.*;
 import net.pterodactylus.sone.freenet.wot.*;
 import net.pterodactylus.sone.web.*;
+import net.pterodactylus.sone.web.notification.NotificationHandler;
+import net.pterodactylus.sone.web.notification.NotificationHandlerModule;
 
 import freenet.l10n.BaseL10n.*;
 import freenet.l10n.*;
@@ -197,11 +200,21 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
                /* create the web interface. */
                webInterface = injector.getInstance(WebInterface.class);
 
+               /* we need to request this to install all notification handlers. */
+               injector.getInstance(NotificationHandler.class);
+
                /* start core! */
                core.start();
+
+               /* start the web interface! */
                webInterface.start();
                webInterface.setFirstStart(injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart"))));
                webInterface.setNewConfig(injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig"))));
+
+               /* first start? */
+               if (injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart")))) {
+                       injector.getInstance(EventBus.class).post(new FirstStart());
+               }
        }
 
        @VisibleForTesting
@@ -209,8 +222,9 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
                FreenetModule freenetModule = new FreenetModule(pluginRespirator);
                AbstractModule soneModule = new SoneModule(this, new EventBus());
                Module webInterfaceModule = new WebInterfaceModule();
+               Module notificationHandlerModule = new NotificationHandlerModule();
 
-               return createInjector(freenetModule, soneModule, webInterfaceModule);
+               return createInjector(freenetModule, soneModule, webInterfaceModule, notificationHandlerModule);
        }
 
        @VisibleForTesting