mirror of https://github.com/zlatinb/muwire
start core when gui is loaded
parent
2cafba56ea
commit
b1d30dc29f
|
@ -64,7 +64,7 @@ public class Core {
|
||||||
private final ConnectionEstablisher connectionEstablisher
|
private final ConnectionEstablisher connectionEstablisher
|
||||||
private final HasherService hasherService
|
private final HasherService hasherService
|
||||||
|
|
||||||
public Core(MuWireSettings props) {
|
public Core(MuWireSettings props, File home) {
|
||||||
log.info "Initializing I2P context"
|
log.info "Initializing I2P context"
|
||||||
I2PAppContext.getGlobalContext().logManager()
|
I2PAppContext.getGlobalContext().logManager()
|
||||||
I2PAppContext.getGlobalContext()._logManager = new MuWireLogManager()
|
I2PAppContext.getGlobalContext()._logManager = new MuWireLogManager()
|
||||||
|
@ -221,7 +221,7 @@ public class Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core core = new Core(props)
|
Core core = new Core(props, home)
|
||||||
core.startServices()
|
core.startServices()
|
||||||
|
|
||||||
// ... at the end, sleep or execute script
|
// ... at the end, sleep or execute script
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
import griffon.core.GriffonApplication
|
||||||
|
import groovy.util.logging.Log
|
||||||
|
|
||||||
|
import org.codehaus.griffon.runtime.core.AbstractLifecycleHandler
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.MuWireSettings
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
import static griffon.util.GriffonApplicationUtils.isMacOSX
|
||||||
|
import static groovy.swing.SwingBuilder.lookAndFeel
|
||||||
|
|
||||||
|
@Log
|
||||||
|
class Initialize extends AbstractLifecycleHandler {
|
||||||
|
@Inject
|
||||||
|
Initialize(@Nonnull GriffonApplication application) {
|
||||||
|
super(application)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void execute() {
|
||||||
|
lookAndFeel((isMacOSX ? 'system' : 'nimbus'), 'gtk', ['metal', [boldFonts: false]])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
import griffon.core.GriffonApplication
|
||||||
|
import groovy.util.logging.Log
|
||||||
|
|
||||||
|
import org.codehaus.griffon.runtime.core.AbstractLifecycleHandler
|
||||||
|
|
||||||
|
import com.muwire.core.Core
|
||||||
|
import com.muwire.core.MuWireSettings
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
import static griffon.util.GriffonApplicationUtils.isMacOSX
|
||||||
|
import static groovy.swing.SwingBuilder.lookAndFeel
|
||||||
|
|
||||||
|
@Log
|
||||||
|
class Ready extends AbstractLifecycleHandler {
|
||||||
|
@Inject
|
||||||
|
Ready(@Nonnull GriffonApplication application) {
|
||||||
|
super(application)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void execute() {
|
||||||
|
log.info "starting core services"
|
||||||
|
def home = System.getProperty("user.home") + File.separator + ".MuWire"
|
||||||
|
home = new File(home)
|
||||||
|
if (!home.exists()) {
|
||||||
|
log.info("creating home dir")
|
||||||
|
home.mkdir()
|
||||||
|
}
|
||||||
|
|
||||||
|
def props = new Properties()
|
||||||
|
def propsFile = new File(home, "MuWire.properties")
|
||||||
|
if (propsFile.exists()) {
|
||||||
|
log.info("loading existing props file")
|
||||||
|
propsFile.withInputStream {
|
||||||
|
props.load(it)
|
||||||
|
}
|
||||||
|
props = new MuWireSettings(props)
|
||||||
|
} else {
|
||||||
|
log.info("creating default properties")
|
||||||
|
props = new MuWireSettings()
|
||||||
|
propsFile.withOutputStream {
|
||||||
|
props.write(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Core core = new Core(props, home)
|
||||||
|
core.startServices()
|
||||||
|
application.context.put("core",core)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue