Replace utils’ ListBuilder by Guava’s ImmutableList.Builder.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index fcde685..2a2eb8f 100644 (file)
@@ -70,6 +70,8 @@ import net.pterodactylus.util.version.Version;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
+import com.google.inject.Inject;
+
 import freenet.keys.FreenetURI;
 
 /**
@@ -192,6 +194,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
         * @param webOfTrustUpdater
         *            The WebOfTrust updater
         */
+       @Inject
        public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, WebOfTrustUpdater webOfTrustUpdater) {
                super("Sone Core");
                this.configuration = configuration;
@@ -416,7 +419,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                                sone = new Sone(id, true);
                                sones.put(id, sone);
                        }
-                       if (!sone.isLocal()) {
+                       if ((sone != null) && !sone.isLocal()) {
                                sone = new Sone(id, true);
                                sones.put(id, sone);
                        }
@@ -1893,6 +1896,9 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                loadConfiguration();
                updateChecker.addUpdateListener(this);
                updateChecker.start();
+               identityManager.addIdentityListener(this);
+               identityManager.start();
+               webOfTrustUpdater.init();
                webOfTrustUpdater.start();
        }
 
@@ -1932,6 +1938,8 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis
                updateChecker.stop();
                updateChecker.removeUpdateListener(this);
                soneDownloader.stop();
+               identityManager.removeIdentityListener(this);
+               identityManager.stop();
        }
 
        //