turnOnScreen() works.

This commit is contained in:
jens 2021-02-27 02:42:07 +01:00
parent 4f5db24e76
commit cae17bff96
3 changed files with 24 additions and 140 deletions

View File

@ -6,16 +6,6 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/Jens/Documents/Entwicklung/Eclipse workspace/libs/mailapi-1.5.0.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/Users/Jens/Documents/Entwicklung/Eclipse workspace/libs/smtp-1.5.0.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/commons-lang3-3.9.jar">
<attributes>
<attribute name="module" value="true"/>

View File

@ -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)
{
}
}
}

View File

@ -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)
{