[tuxdroid-svn] r5660 - software_suite_v3/software/plugin/plugin-email/branches/random_sentences/plu
Status: Beta
Brought to you by:
ks156
|
From: ks156 <c2m...@c2...> - 2009-10-14 13:29:31
|
Author: ks156
Date: 2009-10-14 15:29:19 +0200 (Wed, 14 Oct 2009)
New Revision: 5660
Modified:
software_suite_v3/software/plugin/plugin-email/branches/random_sentences/plugin-email/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java
Log:
* Added lists with differents sentences and updated the gadget to retrieve them
randomly
Modified: software_suite_v3/software/plugin/plugin-email/branches/random_sentences/plugin-email/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java
===================================================================
--- software_suite_v3/software/plugin/plugin-email/branches/random_sentences/plugin-email/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java 2009-10-14 13:27:23 UTC (rev 5659)
+++ software_suite_v3/software/plugin/plugin-email/branches/random_sentences/plugin-email/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java 2009-10-14 13:29:19 UTC (rev 5660)
@@ -27,6 +27,7 @@
import java.security.Security;
import java.util.Properties;
import java.util.Vector;
+import java.util.Random;
import javax.mail.Folder;
import javax.mail.Message;
@@ -47,6 +48,33 @@
*/
public class MailPlugin extends SimplePlugin<Configuration>
{
+
+ String[] newMailSentences = {
+ "You have a new message.",
+ "A new message has arrived !",
+ "It appears you have received a new email.",
+ "A new message ? I wonder who could be thinking about you.",
+ "It would appear you have received new messages."
+ };
+
+ String[] mailSenderSentences = {
+ "Mail sent by {0}",
+ "The message was sent by {0}",
+ "The sender of the message is {0}"
+ };
+
+ String[] mailSubjectSentences = {
+ "The message subject is : {0}",
+ "The subject of the message is : {0}"
+ };
+
+ String[] noNewMailSentences = {
+ "No new mail.",
+ "I'm sorry, nobody sent you any messages.",
+ "No messages. Nobody seems to be thinking about you.",
+ "Your mailbox is empty."
+ };
+
/**
* @param args
* @throws Exception
@@ -124,7 +152,7 @@
if((newMessageAlert) && (!firstCheck))
{
throwResult(true);
- throwMessage("You have a new message.");
+ throwMessage(this.pickSentence(newMailSentences));
}
else
{
@@ -236,8 +264,8 @@
mailCounter++;
if (mailCounter <= 5)
{
- throwMessage("Mail sent by {0}", sender);
- throwMessage("The message subject is : {0}", filteredSubject);
+ throwMessage(this.pickSentence(mailSenderSentences), sender);
+ throwMessage(this.pickSentence(mailSubjectSentences), filteredSubject);
}
/* Referencing the current mail */
stateRun.getLastMessages().add(filteredSubject);
@@ -251,19 +279,27 @@
}
if(notifyNoNewMail)
{
- throwMessage("No new mail.");
+ throwMessage(this.pickSentence(noNewMailSentences));
}
}
/* No new message */
else
{
- throwMessage("No new mail.");
+ throwMessage(this.pickSentence(noNewMailSentences));
}
/* Save the current referenced mails */
writeState(stateRun, sessionId + "RUN");
}
/**
+ * This function return a sentences from a defined list
+ */
+ private String pickSentence(String[] list) {
+ Random rand = new Random();
+ return list[rand.nextInt(list.length)];
+ }
+
+ /**
* Check if the mail server is responding to the x port.
* @param host Server host
* @param port Server port
|