import griffon.core.GriffonApplication import griffon.core.env.Metadata import groovy.util.logging.Log import org.codehaus.griffon.runtime.core.AbstractLifecycleHandler import com.muwire.core.Core import com.muwire.core.MuWireSettings import com.muwire.core.files.FileSharedEvent import javax.annotation.Nonnull import javax.inject.Inject import javax.swing.JFileChooser import javax.swing.JOptionPane import static griffon.util.GriffonApplicationUtils.isMacOSX import static groovy.swing.SwingBuilder.lookAndFeel import java.beans.PropertyChangeEvent import java.util.logging.Level @Log class Ready extends AbstractLifecycleHandler { @Inject Metadata metadata @Inject Ready(@Nonnull GriffonApplication application) { super(application) } @Override void execute() { log.info "starting core services" def portableHome = System.getProperty("portable.home") def home = portableHome == null ? System.getProperty("user.home") + File.separator + ".MuWire" : portableHome 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 new properties") props = new MuWireSettings() def nickname while (true) { nickname = JOptionPane.showInputDialog(null, "Your nickname is displayed when you send search results so other MuWire users can choose to trust you", "Please choose a nickname", JOptionPane.PLAIN_MESSAGE) if (nickname == null || nickname.trim().length() == 0) { JOptionPane.showMessageDialog(null, "Nickname cannot be empty", "Select another nickname", JOptionPane.WARNING_MESSAGE) continue } if (nickname.contains("@")) { JOptionPane.showMessageDialog(null, "Nickname cannot contain @, choose another", "Select another nickname", JOptionPane.WARNING_MESSAGE) continue } nickname = nickname.trim() break } props.setNickname(nickname) def portableDownloads = System.getProperty("portable.downloads") if (portableDownloads != null) { props.downloadLocation = new File(portableDownloads) } else { def chooser = new JFileChooser() chooser.setDialogTitle("Select a directory where downloads will be saved") chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) int rv = chooser.showOpenDialog(null) if (rv != JFileChooser.APPROVE_OPTION) { JOptionPane.showMessageDialog(null, "MuWire will now exit") System.exit(0) } props.downloadLocation = chooser.getSelecteHTTP/1.1 200 OK Date: Wed, 23 Jul 2025 04:59:27 GMT X-Frame-Options: SAMEORIGIN Connection: close Access-Control-Expose-Headers: Content-Disposition Content-Disposition: inline; filename="Ready.groovy"; filename*=UTF-8''Ready.groovy Content-Length: 4484 Etag: "2a21ec5208ab21c5d4be6280bbbe2959fbacc881" Last-Modified: Mon, 03 Jun 2019 22:11:03 GMT X-Content-Type-Options: nosniff Cache-Control: public, max-age=21600, no-transform Content-Type: text/plain; charset=utf-8 Set-Cookie: i_like_gitea=f30a2df75cdd98bd; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=SZigVzDk9V42IDOTvJjdflHi1s06MTc1MzI0Njc2Nzg2MTEwNDg2MQ; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Cache-Status: HIT X-Cache-Age: 0 import griffon.core.GriffonApplication import griffon.core.env.Metadata import groovy.util.logging.Log import org.codehaus.griffon.runtime.core.AbstractLifecycleHandler import com.muwire.core.Core import com.muwire.core.MuWireSettings import com.muwire.core.files.FileSharedEvent import javax.annotation.Nonnull import javax.inject.Inject import ja