From: Debayan Sutradhar Date: Fri, 30 Apr 2021 01:03:35 +0530 Subject: Merge remote-tracking branch 'origin/master' --- Merge remote-tracking branch 'origin/master' --- --- 'a/src/main/java/com/stream_pi/server/connection/ClientConnection.java' +++ b/src/main/java/com/stream_pi/server/connection/ClientConnection.java @@ -440,13 +440,18 @@ public class ClientConnection extends Th } } + int totalActions; public void registerProfilesFromClient(Message message) throws StreamPiException { logger.info("Registering profiles ..."); String[] r = message.getStringArrValue(); - for (String profileID : r) { + totalActions = message.getIntValue(); + System.out.println("TTOOOX : "+totalActions); + + for (String profileID : r) + { getProfileDetailsFromClient(profileID); } } @@ -491,6 +496,8 @@ public class ClientConnection extends Th public synchronized void registerActionToProfile(Message message) throws StreamPiException { + totalActions--; + String[] r = message.getStringArrValue(); String profileID = r[0]; @@ -638,6 +645,7 @@ public class ClientConnection extends Th exceptionAndAlertHandler.handleMinorException(new MinorException("action", "Unable to clone")); } + checkIfReady(); return; } } @@ -696,6 +704,16 @@ public class ClientConnection extends Th e.printStackTrace(); exceptionAndAlertHandler.handleMinorException(new MinorException("action", "Unable to clone")); } + + checkIfReady(); + } + + public void checkIfReady() throws SevereException + { + if(totalActions == 0) + { + sendMessage(new Message("ready")); + } } public synchronized void saveActionDetails(String profileID, Action action) throws SevereException @@ -796,11 +814,8 @@ public class ClientConnection extends Th public void onClientScreenDetailsReceived(Message message) { - double width = Double.parseDouble(message.getStringArrValue()[0]); - double height = Double.parseDouble(message.getStringArrValue()[1]); - - getClient().setDisplayWidth(width); - getClient().setDisplayHeight(height); + getClient().setDisplayWidth(message.getDoubleArrValue()[0]); + getClient().setDisplayHeight(message.getDoubleArrValue()[1]); } public void deleteAction(String profileID, String actionID) throws SevereException --- 'a/src/main/java/com/stream_pi/server/controller/Controller.java' +++ b/src/main/java/com/stream_pi/server/controller/Controller.java @@ -236,6 +236,7 @@ public class Controller extends Base imp } finally { + getLogger().info("Shut down"); closeLogger(); } } --- 'a/src/main/java/com/stream_pi/server/io/Config.java' +++ b/src/main/java/com/stream_pi/server/io/Config.java @@ -8,7 +8,9 @@ handler for config.xml package com.stream_pi.server.io; +import java.awt.*; import java.io.File; +import java.util.Objects; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; @@ -20,8 +22,10 @@ import javax.xml.transform.TransformerFa import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import com.stream_pi.server.Main; import com.stream_pi.server.info.ServerInfo; import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.iohelper.IOHelper; import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -322,4 +326,19 @@ public class Config { getOthersElement().getElementsByTagName("allow-donate-popup").item(0).setTextContent(value+""); } + + public static void unzipToDefaultPrePath() throws Exception + { + IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ServerInfo.getInstance().getPrePath()); + + Config.getInstance().setThemesPath(ServerInfo.getInstance().getPrePath()+"Themes/"); + Config.getInstance().setPluginsPath(ServerInfo.getInstance().getPrePath()+"Plugins/"); + + if(SystemTray.isSupported()) + { + Config.getInstance().setMinimiseToSystemTrayOnClose(true); + } + + Config.getInstance().save(); + } } --- 'a/src/main/java/com/stream_pi/server/window/Base.java' +++ b/src/main/java/com/stream_pi/server/window/Base.java @@ -157,17 +157,7 @@ public abstract class Base extends Stack boolean result = filex.mkdirs(); if(result) { - IOHelper.unzip(Main.class.getResourceAsStream("Default.zip"), ServerInfo.getInstance().getPrePath()); - - Config.getInstance().setThemesPath(ServerInfo.getInstance().getPrePath()+"Themes/"); - Config.getInstance().setPluginsPath(ServerInfo.getInstance().getPrePath()+"Plugins/"); - - if(SystemTray.isSupported()) - { - Config.getInstance().setMinimiseToSystemTrayOnClose(true); - } - - Config.getInstance().save(); + Config.unzipToDefaultPrePath(); initLogger(); }