From cae17bff9627f5e33a61dac7bd1394431b76afbc Mon Sep 17 00:00:00 2001 From: jens Date: Sat, 27 Feb 2021 02:42:07 +0100 Subject: [PATCH] turnOnScreen() works. --- RhasspyVisualConversationTool/.classpath | 10 -- .../src/com/jens/rhasspy/visualtool/GUI.java | 28 +++- .../rhasspy/visualtool/Miscellaneous.java | 126 +----------------- 3 files changed, 24 insertions(+), 140 deletions(-) diff --git a/RhasspyVisualConversationTool/.classpath b/RhasspyVisualConversationTool/.classpath index c0e03b5..4859dd5 100644 --- a/RhasspyVisualConversationTool/.classpath +++ b/RhasspyVisualConversationTool/.classpath @@ -6,16 +6,6 @@ - - - - - - - - - - diff --git a/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/GUI.java b/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/GUI.java index 97f4b47..337503c 100644 --- a/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/GUI.java +++ b/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/GUI.java @@ -1,7 +1,9 @@ package com.jens.rhasspy.visualtool; +import java.awt.AWTException; import java.awt.Dimension; import java.awt.Font; +import java.awt.Robot; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; @@ -212,7 +214,7 @@ public class GUI if(MqttTopic.isMatched(Settings.topicNameWakewordRecognized, topic)) { - turnScreenOn(); + turnOnScreen(); textEntriesList.clear(); textEntriesList.add(getMeString() + "Hello! What can I do for you?"); @@ -220,6 +222,8 @@ public class GUI } else if(MqttTopic.isMatched(Settings.topicNameIntentsRecognized, topic)) { + turnOnScreen(); + JSONObject jo = new JSONObject(payload); textEntriesList.clear(); textEntriesList.add(getYouString() + jo.getString("input")); @@ -264,12 +268,6 @@ public class GUI } } - private void turnScreenOn() - { - // TODO Auto-generated method stub - - } - static String getYouString() { return "You: \t"; @@ -313,5 +311,21 @@ public class GUI Monitor is Off pi@raspberrypi11:~ $ */ + + try + { + // These coordinates are screen coordinates +// int xCoord = 500; +// int yCoord = 500; + + // Move the cursor + Robot robot = new Robot(); + for(int xCoord = 500; xCoord < 505; xCoord++) + for(int yCoord = 500; yCoord < 505; yCoord++) + robot.mouseMove(xCoord, yCoord); + } + catch (AWTException e) + { + } } } diff --git a/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/Miscellaneous.java b/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/Miscellaneous.java index a3c2740..57f940e 100644 --- a/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/Miscellaneous.java +++ b/RhasspyVisualConversationTool/src/com/jens/rhasspy/visualtool/Miscellaneous.java @@ -60,15 +60,6 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import javax.mail.Authenticator; -import javax.mail.Message; -import javax.mail.PasswordAuthentication; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.AddressException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; - public class Miscellaneous { protected static Calendar logDate; @@ -666,117 +657,6 @@ public class Miscellaneous return returnString.toString(); } - public static boolean notifyAdminViaEmail(String text, boolean force, int verbosity) - { - if((Settings.notificationsEnabled && Settings.notificationVerbosity >= verbosity) | force) - { - if(Settings.notificationToAddress.length() > 0 && !Settings.notificationToAddress.equalsIgnoreCase(Settings.default_notificationToAddress)) - { - SmtpSimple smtp = new SmtpSimple(); - try - { - if(smtp.sendEmail(Settings.notificationMailServer, Settings.notificationMailServerPort, Settings.notificationEncryptionType, Settings.notificationAuthenticate, Settings.notificationUsername, Settings.notificationPassword, Settings.notificationFromAddress, Settings.notificationToAddress, "Notification from " + Settings.programName, text)) - { - Miscellaneous.logEvent("Successfully sent notification email to " + Settings.notificationToAddress + " via server " + Settings.notificationMailServer, 2); - return true; - } - else - Miscellaneous.logEvent("Error sending notification email.", 2); - } - catch (Exception e) - { - Miscellaneous.logEvent("Error sending notification email: " + Miscellaneous.getStackTraceAsString(e), 2); - } - } - else - { - Miscellaneous.logEvent("Error sending notification email: No valid mail address or only default address specified.", 2); - } - } - else - Miscellaneous.logEvent("Email notifications are disabled.", 3); - - return false; - } - - public static class SmtpSimple - { - /** - * Send a single email. - */ - public boolean sendEmail(String mailServer, int mailServerPor, String encryptionType, boolean useAuthentication, final String username, final String password, String aFromEmailAddr, String aToEmailAddr, String aSubject, String aBody) - { - // Properties über die Systemeigenschaften anlegen - Properties properties = System.getProperties(); - - properties.setProperty("mail.smtp.host", mailServer); - properties.setProperty("mail.smtp.port", String.valueOf(mailServerPor)); - - properties.setProperty("mail.smtp.auth", String.valueOf(useAuthentication)); - - /* - * final Properties props = new Properties(); - * props.put("mail.smtp.host", "SMTPHOST"); - * props.put("mail.smtp.port", "PORTNUMBER"); - * props.put("mail.transport.protocol","smtp"); - * props.put("mail.smtp.auth", "true"); - * props.put("mail.smtp.starttls.enable", "true"); - * props.put("mail.smtp.tls", "true"); - * props.put("mail.smtp.ssl.checkserveridentity", "true"); - */ - - if(encryptionType.equalsIgnoreCase("STARTTLS")) - properties.setProperty("mail.smtp.starttls.enable", "true"); - else if(encryptionType.equalsIgnoreCase("TLS")) - properties.put("mail.smtp.tls", "true"); - else if(encryptionType.equalsIgnoreCase("SSL")) - properties.setProperty("mail.smtp.ssl.enable", "true"); - -// properties.put("mail.smtp.ssl.checkserveridentity", "false"); -// properties.put("mail.smtp.ssl.trust", "exchange2.brainscanner.dyndns.org"); - - Session session; - - Authenticator auth = new Authenticator() - { - protected PasswordAuthentication getPasswordAuthentication() - { - return new PasswordAuthentication(username, password); - } - }; - - if(useAuthentication) - session = Session.getDefaultInstance(properties, auth); - else - session= Session.getDefaultInstance(properties, null); - -// session.setDebug(true); - - MimeMessage message = new MimeMessage(session); - try - { - //the "from" address may be set in code, or set in the - //config file under "mail.from" ; here, the latter style is used - message.setFrom(new InternetAddress(aFromEmailAddr)); - message.addRecipient(Message.RecipientType.TO, new InternetAddress(aToEmailAddr)); - message.setSubject(aSubject); - message.setText(aBody); - Transport.send(message); - return true; - } - catch (AddressException e) - { - System.err.println("Cannot send email. " + Miscellaneous.getStackTraceAsString(e)); - } - catch (javax.mail.MessagingException e) - { - System.err.println("Cannot send email. " + Miscellaneous.getStackTraceAsString(e)); - } - - return false; - } - } - public static UncaughtExceptionHandler getUncaughtExceptionHandler(final int criticality) { UncaughtExceptionHandler handler = new UncaughtExceptionHandler() @@ -793,8 +673,7 @@ public class Miscellaneous builder.append(Miscellaneous.lineSeparator); builder.append(Miscellaneous.getStackTraceAsString(e)); - Miscellaneous.logEvent(builder.toString(), 1); - Miscellaneous.notifyAdminViaEmail(builder.toString(), false, criticality); + Miscellaneous.logEvent(builder.toString(), 1); } catch(Exception ex) { @@ -1004,7 +883,8 @@ public class Miscellaneous try { - desenv = new File(".").getCanonicalPath().contains("workspace"); + File workingPath = new File("."); + desenv = workingPath.getCanonicalPath().contains("workspace") || workingPath.getCanonicalPath().contains("git"); } catch (IOException e) {