[tuxdroid-svn] r5793 - in software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail: resou
Status: Beta
Brought to you by:
ks156
From: ks156 <c2m...@c2...> - 2009-10-29 06:37:11
|
Author: ks156 Date: 2009-10-29 07:37:00 +0100 (Thu, 29 Oct 2009) New Revision: 5793 Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/de.po software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/en.po software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/fr.po software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/nl.po software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/plugin.pot software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java Log: * Merged r5667 through r5785 from random_sentences Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/de.po =================================================================== --- software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/de.po 2009-10-29 06:36:27 UTC (rev 5792) +++ software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/de.po 2009-10-29 06:37:00 UTC (rev 5793) @@ -41,18 +41,60 @@ msgid "Options" msgstr "Optionen" -msgid "You have a new message." -msgstr "Sie haben eine neue Nachricht." +msgid "You have a new mail." +msgstr "Sie haben eine neue Email." +msgid "A new mail has arrived !" +msgstr "Eine neue Mail ist eingetroffen!" + +msgid "It appears you have received a new email." +msgstr "Anscheinend haben Sie eine neue E-Mail erhalten." + +msgid "A new email ? I wonder who could be thinking about you." +msgstr "Eine neue E-Mail? Ich frage mich, wer gerade an Sie denkt." + +msgid "It would appear you have received new mails." +msgstr "Es sieht so aus, als hätten Sie neue E-Mails erhalten." + msgid "Mail sent by {0}" msgstr "Mail gesendet von {0}" -msgid "The message subject is : {0}" -msgstr "Betreff der Nachricht ist: {0}" +msgid "The email was sent by {0}" +msgstr "Die E-Mail wurde gesendet von {0}" +msgid "The sender of the mail is {0}" +msgstr "Der Absender der E-Mail ist {0}" + +msgid "The sender is {0}" +msgstr "Der Absender ist {0}" + +msgid "The email subject is : {0}" +msgstr "Betreff der Email ist: {0}" + +msgid "The subject of the email is : {0}" +msgstr "Thema der E-Mail ist: {0}" + +msgid "The email topic is : {0}" +msgstr "Das E-Mail-Thema ist: {0}" + +msgid "The topic is : {0}" +msgstr "Das Thema ist: {0}" + +msgid "The title of the email is : {0}" +msgstr "Der Titel der E-Mail ist: {0}" + msgid "No new mail." msgstr "Keine neue Mail." +msgid "I'm sorry, nobody sent you any email." +msgstr "Es tut mir leid, niemand hat Ihnen eine E-Mail gesandt." + +msgid "No mails. Nobody seems to be thinking about you." +msgstr "Keine Mails. Anscheinend denkt niemand an Sie." + +msgid "Your mailbox is empty." +msgstr "Ihre Mailbox ist leer." + msgid "your_user" msgstr "Ihr Benutzer" @@ -78,7 +120,7 @@ msgstr "Sie müssen das pop3 Dienst in Ihrem Mail-Konto aktivieren" msgid "Sorry, I could not connect to the mail server. Please check your internet connection or try again later." -msgstr "Sorry, Verbindung zum Mailserver nicht möglich. Überprüfen Sie Ihre Internetverbindung oder versuchen Sie es später." +msgstr "Sorry, Verbindung zum Mailserver nicht möglich. Prüfen Sie die Internet-Verbindung oder versuchen Sie es später." msgid "Sorry, there was an error when connecting to the mail server. Please check your email configuration." msgstr "Sorry, Bei der Verbindung mit dem Mailserver gab es einen Fehler. Prüfen Sie Ihre Email-Konfiguration." @@ -94,3 +136,15 @@ msgid "Start me every x (From full hour)" msgstr "Prüfen Sie meine Mailbox häufig" + +msgid "G-mail is busy right now. Please try again later." +msgstr "G-mail ist gerade beschäftigt. Bitte versuchen Sie es später erneut." + +msgid "The Google mail website has a lot of traffic at the moment. Better to try again later." +msgstr "Die Google Mail-Website ist gerade ziemlich ausgelastet. Sie sollten es später wieder versuchen." + +msgid "I'm having difficulties to connect to Google mail. Please try again later." +msgstr "Ich habe Schwierigkeiten bei der Verbindung mit Google Mail. Bitte versuchen Sie es später erneut." + +msgid "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." +msgstr "Ich habe eine Pause beim Prüfen Ihres G-mail-Kontos eingelegt. Die Google-Mail-Website ist gerade zu beschäftigt." Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/en.po =================================================================== --- software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/en.po 2009-10-29 06:36:27 UTC (rev 5792) +++ software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/en.po 2009-10-29 06:37:00 UTC (rev 5793) @@ -41,18 +41,60 @@ msgid "Options" msgstr "Options" -msgid "You have a new message." -msgstr "You have a new message." +msgid "You have a new mail." +msgstr "You have a new mail." +msgid "A new mail has arrived !" +msgstr "A new mail has arrived !" + +msgid "It appears you have received a new email." +msgstr "It appears you have received a new email." + +msgid "A new email ? I wonder who could be thinking about you." +msgstr "A new email ? I wonder who could be thinking about you." + +msgid "It would appear you have received new mails." +msgstr "It would appear you have received new mails." + msgid "Mail sent by {0}" msgstr "Mail sent by {0}" -msgid "The message subject is : {0}" -msgstr "The message subject is : {0}" +msgid "The email was sent by {0}" +msgstr "The email was sent by {0}" +msgid "The sender of the mail is {0}" +msgstr "The sender of the mail is {0}" + +msgid "The sender is {0}" +msgstr "The sender is {0}" + +msgid "The email subject is : {0}" +msgstr "The email subject is : {0}" + +msgid "The subject of the email is : {0}" +msgstr "The subject of the email is : {0}" + +msgid "The email topic is : {0}" +msgstr "The email topic is : {0}" + +msgid "The topic is : {0}" +msgstr "The topic is : {0}" + +msgid "The title of the email is : {0}" +msgstr "The title of the email is : {0}" + msgid "No new mail." msgstr "No new mail." +msgid "I'm sorry, nobody sent you any email." +msgstr "I'm sorry, nobody sent you any email." + +msgid "No mails. Nobody seems to be thinking about you." +msgstr "No mails. Nobody seems to be thinking about you." + +msgid "Your mailbox is empty." +msgstr "Your mailbox is empty." + msgid "your_user" msgstr "your_user" @@ -94,3 +136,15 @@ msgid "Start me every x (From full hour)" msgstr "Check my mail box frequently" + +msgid "G-mail is busy right now. Please try again later." +msgstr "G-mail is busy right now. Please try again later." + +msgid "The Google mail website has a lot of traffic at the moment. Better to try again later." +msgstr "The Google mail website has a lot of traffic at the moment. Better to try again later." + +msgid "I'm having difficulties to connect to Google mail. Please try again later." +msgstr "I'm having difficulties to connect to Google mail. Please try again later." + +msgid "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." +msgstr "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/fr.po =================================================================== --- software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/fr.po 2009-10-29 06:36:27 UTC (rev 5792) +++ software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/fr.po 2009-10-29 06:37:00 UTC (rev 5793) @@ -41,18 +41,60 @@ msgid "Options" msgstr "Options" -msgid "You have a new message." -msgstr "Vous avez un nouveau message" +msgid "You have a new mail." +msgstr "Vous avez un nouvel email" +msgid "A new mail has arrived !" +msgstr "Un nouvel email est arrivé !" + +msgid "It appears you have received a new email." +msgstr "Il semble que vous ayez reçu un email." + +msgid "A new email ? I wonder who could be thinking about you." +msgstr "Un nouvel email ? Je me demande qui peut bien penser à vous." + +msgid "It would appear you have received new mails." +msgstr "Il semble que des emails soient arrivés" + msgid "Mail sent by {0}" -msgstr "Message envoyé par {0}" +msgstr "Email envoyé par {0}" -msgid "The message subject is : {0}" -msgstr "Le sujet du message est : {0}" +msgid "The email was sent by {0}" +msgstr "L'email vous a été envoyé par {0}" +msgid "The sender of the mail is {0}" +msgstr "L'expéditeur de l'email est {0}" + +msgid "The sender is {0}" +msgstr "L'expéditeur de l'email est : {0}" + +msgid "The email subject is : {0}" +msgstr "L'email a comme sujet : {0}" + +msgid "The subject of the email is : {0}" +msgstr "Le sujet de l'email est : {0}" + +msgid "The email topic is : {0}" +msgstr "Le thème de l'email est : {0}" + +msgid "The topic is : {0}" +msgstr "Le thème est : {0}" + +msgid "The title of the email is : {0}" +msgstr "Le titre de l'email est : {0}" + msgid "No new mail." -msgstr "Aucun nouveau message" +msgstr "Aucun nouvel email" +msgid "I'm sorry, nobody sent you any email." +msgstr "Désolé, personne ne vous a envoyé d'email ..." + +msgid "No mails. Nobody seems to be thinking about you." +msgstr "Pas de nouveaux emails. Personne ne semble avoir pensé à vous." + +msgid "Your mailbox is empty." +msgstr "Votre boîte email est vide." + msgid "your_user" msgstr "votre_identifiant" @@ -81,7 +123,7 @@ msgstr "Désolé, je ne peux pas me connecter au serveur de messagerie. Merci de controler votre connexion internet ou de réessayer plus tard." msgid "Sorry, there was an error when connecting to the mail server. Please check your email configuration." -msgstr "Désolé, il y a eu une erreur lors de la connexion au serveur de messagerie. Merci de controler les paramètres du plugin." +msgstr "Désolé, il y a eu une erreur lors de la connexion au serveur de messagerie. Merci de controler les paramètres du gadget." msgid "Start every x" msgstr "Alertes" @@ -94,3 +136,15 @@ msgid "Start me every x (From full hour)" msgstr "Me faire un rapport régulièrement" + +msgid "G-mail is busy right now. Please try again later." +msgstr "G-mail est occupé pour l'instant. Merci de réessayer plus tard." + +msgid "The Google mail website has a lot of traffic at the moment. Better to try again later." +msgstr "Le site d'email de Google a beaucoup de traffic pour le moment. Il est préférable de réessayer plus tard." + +msgid "I'm having difficulties to connect to Google mail. Please try again later." +msgstr "J'ai des difficultés à me connecter à Google mail. Merci de réessayer plus tard." + +msgid "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." +msgstr "Le temps de réponse est trop long pour vérifier votre compte GMail. Le site Google mail est trop occupé pour l'instant." Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/nl.po =================================================================== --- software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/nl.po 2009-10-29 06:36:27 UTC (rev 5792) +++ software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/nl.po 2009-10-29 06:37:00 UTC (rev 5793) @@ -27,7 +27,7 @@ msgstr "Controleer of er nieuwe E-mail is" msgid "Read your mail" -msgstr "Lees jouw E-mail" +msgstr "Lees je E-mail" msgid "User parameters" msgstr "Gebruikersinstellingen" @@ -41,18 +41,60 @@ msgid "Options" msgstr "Opties" -msgid "You have a new message." -msgstr "Je hebt een nieuw bericht" +msgid "You have a new mail." +msgstr "Je hebt een nieuwe email." +msgid "A new mail has arrived !" +msgstr "Er is een nieuwe mail binnengekomen !" + +msgid "It appears you have received a new email." +msgstr "Ik geloof dat je nieuwe mail hebt." + +msgid "A new email ? I wonder who could be thinking about you." +msgstr "Een nieuwe email ? Ik ben benieuwd van wie het is." + +msgid "It would appear you have received new mails." +msgstr "Ik geloof dat er nieuwe mails zijn binnengekomen." + msgid "Mail sent by {0}" msgstr "Dit bericht werd verzonden door {0}" -msgid "The message subject is : {0}" +msgid "The email was sent by {0}" +msgstr "De email werd verzonden door {0}" + +msgid "The sender of the mail is {0}" +msgstr "De afzender van de mail is {0}" + +msgid "The sender is {0}" +msgstr "De afzender is {0}" + +msgid "The email subject is : {0}" msgstr "Het onderwerp is : {0}" +msgid "The subject of the email is : {0}" +msgstr "Het onderwerp van de email is : {0}" + +msgid "The email topic is : {0}" +msgstr "Het email onderwerp is : {0}" + +msgid "The topic is : {0}" +msgstr "Het onderwerp is : {0}" + +msgid "The title of the email is : {0}" +msgstr "De titel van de email is : {0}" + msgid "No new mail." msgstr "Geen nieuwe mails." +msgid "I'm sorry, nobody sent you any email." +msgstr "Sorry, niemand heeft je een mail gestuurd." + +msgid "No mails. Nobody seems to be thinking about you." +msgstr "Geen nieuwe mails. Er lijkt op het ogenblik niemand aan jou te denken." + +msgid "Your mailbox is empty." +msgstr "Je mailbox is leeg." + msgid "your_user" msgstr "jouw_login" @@ -78,10 +120,10 @@ msgstr "Je moet je pop3 service activeren in je Mail account" msgid "Sorry, I could not connect to the mail server. Please check your internet connection or try again later." -msgstr "Sorry, ik kan geen connectie maken met de mailserver. Controleer je internet connectie of probeer later opnieuw." +msgstr "Sorry, ik kan geen connectie maken met de mail server. Controleer je internet connectie of probeer later opnieuw." msgid "Sorry, there was an error when connecting to the mail server. Please check your email configuration." -msgstr "Sorry, ik kan niet inloggen op de mailserver. Controleer of je email configuratie correct is." +msgstr "Sorry, ik kan niet inloggen op de mail server. Controleer of je email configuratie correct is." msgid "Start every x" msgstr "Alarmen" @@ -94,3 +136,15 @@ msgid "Start me every x (From full hour)" msgstr "Check mijn E-mail op regelmatige tijdstippen" + +msgid "G-mail is busy right now. Please try again later." +msgstr "Gimail is bezet op het ogenblik. Probeer later opnieuw." + +msgid "The Google mail website has a lot of traffic at the moment. Better to try again later." +msgstr "De Goegel mail website heeft veel verkeer op het moment. Beter om later opnieuw te proberen." + +msgid "I'm having difficulties to connect to Google mail. Please try again later." +msgstr "Ik heb problemen om een verbinding te maken met Goegel mail. Gelieve later opnieuw te proberen." + +msgid "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." +msgstr "Ik krijg een time-out als ik een verbinding maak met je Gimail account. De Goegel mail website, heeft teveel verkeer op het ogenblik." Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/plugin.pot =================================================================== --- software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/plugin.pot 2009-10-29 06:36:27 UTC (rev 5792) +++ software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/resources/plugin.pot 2009-10-29 06:37:00 UTC (rev 5793) @@ -1,63 +1,106 @@ -msgid "Mail Gadget" -msgstr "" - -msgid "Username" -msgstr "" - -msgid "Server host" -msgstr "" - -msgid "Server port" -msgstr "" - -msgid "IMAP folder to retreive" -msgstr "" - -msgid "Password" -msgstr "" - -msgid "Protocol" -msgstr "" - -msgid "Check if there is any new mail" -msgstr "" - -msgid "Read your mail" -msgstr "" - -msgid "User parameters" -msgstr "" - -msgid "Server parameters" -msgstr "" - -msgid "Advanced Server parameters" -msgstr "" - -msgid "Options" -msgstr "" - -msgid "You have a new message." -msgstr "" - -msgid "Mail sent by {0}" -msgstr "" - -msgid "The message subject is : {0}" -msgstr "" - -msgid "No new mail." -msgstr "" - -msgid "your_user" -msgstr "" - -msgid "your_secret_password" -msgstr "" - -msgid "your.server.com" + +msgid "GMail Plugin" msgstr "" +msgid "Username" +msgstr "" + +msgid "Server host" +msgstr "" + +msgid "Server port" +msgstr "" + +msgid "IMAP folder to retreive" +msgstr "" + +msgid "Password" +msgstr "" + +msgid "Protocol" +msgstr "" + +msgid "Check if there is any new mail" +msgstr "" + +msgid "Read your mail" +msgstr "" + +msgid "User parameters" +msgstr "" + +msgid "Server parameters" +msgstr "" + +msgid "Advanced Server parameters" +msgstr "" + +msgid "Options" +msgstr "" + +msgid "You have a new mail." +msgstr "" + +msgid "A new mail has arrived !" +msgstr "" + +msgid "It appears you have received a new email." +msgstr "" + +msgid "A new email ? I wonder who could be thinking about you." +msgstr "" + +msgid "It would appear you have received new mails." +msgstr "" + +msgid "Mail sent by {0}" +msgstr "" + +msgid "The email was sent by {0}" +msgstr "" + +msgid "The sender of the mail is {0}" +msgstr "" + +msgid "The sender is {0}" +msgstr "" + +msgid "The email subject is : {0}" +msgstr "" + +msgid "The subject of the email is : {0}" +msgstr "" + +msgid "The email topic is : {0}" +msgstr "" + +msgid "The topic is : {0}" +msgstr "" + +msgid "The title of the email is : {0}" +msgstr "" + +msgid "No new mail." +msgstr "" + +msgid "I'm sorry, nobody sent you any email." +msgstr "" + +msgid "No mails. Nobody seems to be thinking about you." +msgstr "" + +msgid "Your mailbox is empty." +msgstr "" + +msgid "your_user" +msgstr "" + +msgid "your_secret_password" +msgstr "" + +msgid "your.server.com" +msgstr "" + msgid "Use sender filter" msgstr "" @@ -68,14 +111,37 @@ msgstr "" msgid "Subject filter to apply" -msgstr "" - -msgid "You must activate the pop3 service in your Mail account" -msgstr "" +msgstr "" +msgid "You must activate the pop3 service in your Mail account" +msgstr "" msgid "Sorry, I could not connect to the mail server. Please check your internet connection or try again later." msgstr "" msgid "Sorry, there was an error when connecting to the mail server. Please check your email configuration." msgstr "" + +msgid "Start every x" +msgstr "" + +msgid "Start me every x" +msgstr "" + +msgid "Start every x from full hour" +msgstr "" + +msgid "Start me every x (From full hour)" +msgstr "" + +msgid "G-mail is busy right now. Please try again later." +msgstr "" + +msgid "The Google mail website has a lot of traffic at the moment. Better to try again later." +msgstr "" + +msgid "I'm having difficulties to connect to Google mail. Please try again later." +msgstr "" + +msgid "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." +msgstr "" Modified: software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java =================================================================== --- software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java 2009-10-29 06:36:27 UTC (rev 5792) +++ software_suite_v3/software/plugin/plugin-gmail/trunk/plugin-gmail/src/net/karmaLab/tuxDroid/plugins/MailPlugin.java 2009-10-29 06:37:00 UTC (rev 5793) @@ -1,354 +1,404 @@ -/* This file is part of "TuxDroid Gadget Mail". - * Copyright 2008, kysoh - * Author : Yoran Brault - * eMail : software@_bad_karma-lab.net (remove _bad_ before sending an email) - * Site : http://www.kysoh.com/ - * - * "TuxDroid Gadget Mail" is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * "TuxDroid Gadget Mail" is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with "TuxDroid Gadget Mail"; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ - -package net.karmaLab.tuxDroid.plugins; - -import java.io.IOException; -import java.security.Security; -import java.util.Properties; -import java.util.Vector; - -import javax.mail.Folder; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Store; -import javax.mail.Flags.Flag; -import javax.mail.internet.InternetAddress; - -import com.kysoh.tuxdroid.plugin.framework.plugin.SimplePlugin; - -/** - * @author User - */ -public class MailPlugin extends SimplePlugin<Configuration> -{ - /** - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception - { - new MailPlugin().boot(args, new Configuration()); - } - - /** - * - */ - @Override - public void start() - { - try - { - if (getCommand().equals("run")) - { - run(); - } - else if (getCommand().equals("check")) - { - check(); - } - else - { - run(); - } - } - catch (Exception e) {} - } - - - /** - * @throws MessagingException - * @throws IOException - * @throws ClassNotFoundException - */ - public void check() throws MessagingException, IOException, ClassNotFoundException, Exception - { - Message messages[] = connectToMailBox(); - - if (messages == null) - { - throwResult(false); - return; - } - String sessionId = "pop.gmail.com_" + configuration().getUser(); - State stateAlert = readState(State.class, sessionId + "ALERT"); - /* Is first check ? */ - boolean firstCheck; - if (stateAlert.getLastMessages().size() == 0) - { - firstCheck = true; - stateAlert.getLastMessages().add("FIRST_CHECK_HACK"); - } - else - { - firstCheck = false; - } - /* Check if you have a new message */ - boolean newMessageAlert = false; - for (int i = messages.length - 1; i >= 0; i--) - { - if (!messages[i].getFlags().contains(Flag.SEEN)) - { - String subject = messages[i].getSubject(); - if (subject != null) - { - if (!stateAlert.getLastMessages().contains(subject)) - { - newMessageAlert = true; - stateAlert.getLastMessages().add(subject); - } - } - } - } - if((newMessageAlert) && (!firstCheck)) - { - throwResult(true); - throwMessage("You have a new message."); - } - else - { - throwResult(false); - } - /* Save the current referenced mails */ - writeState(stateAlert, sessionId + "ALERT"); - } - - /** - * - * @throws MessagingException - * @throws IOException - * @throws ClassNotFoundException - */ - public void run() throws MessagingException, IOException, ClassNotFoundException - { - Message messages[] = connectToMailBox(); - if (messages == null) - { - return; - } - String sessionId = "pop.gmail.com_" + configuration().getUser(); - State stateRun = readState(State.class, sessionId + "RUN"); - /* Check for new message */ - boolean newMessageRun = false; - for (int i = messages.length - 1; i >= 0; i--) - { - if (!messages[i].getFlags().contains(Flag.SEEN)) - { - if (!stateRun.getLastMessages().contains(messages[i].getSubject())) - { - newMessageRun = true; - break; - } - } - } - /* If new message found */ - if (newMessageRun) - { - int mailCounter = 0; - boolean notifyNoNewMail = true; - /* For all unread mails */ - for (int i = messages.length - 1; i >= 0; i--) - { - String subject; - String filteredSubject; - String sender; - String senderPersonal; - String senderAddress; - boolean seen; - boolean mailAlreadyRead; - - try - { - /* Get current mail data */ - subject = messages[i].getSubject(); - senderPersonal = ((InternetAddress) messages[i].getFrom()[0]).getPersonal(); - senderAddress = ((InternetAddress)messages[i].getFrom()[0]).getAddress(); - seen = messages[i].getFlags().contains(Flag.SEEN); - /* Pass if mail is already seen */ - if (seen) - { - continue; - } - /* Pass if subject is empty */ - if (subject == null) - { - continue; - } - /* Filtering the mail address */ - if (senderPersonal == null) - { - sender = senderAddress; - } - else - { - sender = senderPersonal; - } - if (sender.contains("<")) - { - sender = sender.substring(0, sender.indexOf("<")); - } - /* Filtering the mail subject */ - filteredSubject = subject.replace("*", " "); - filteredSubject = filteredSubject.replace("_", " "); - filteredSubject = filteredSubject.replace("{", " "); - filteredSubject = filteredSubject.replace("}", " "); - filteredSubject = filteredSubject.replace("[", " "); - filteredSubject = filteredSubject.replace("]", " "); - filteredSubject = filteredSubject.replace("/", " "); - filteredSubject = filteredSubject.replace("\\", " "); - filteredSubject = filteredSubject.replace(" ", " "); - mailAlreadyRead = false; - /* Check if the mail has already be read */ - for (int j = 0; j < stateRun.getLastMessages().size(); j++) - { - if (filteredSubject.equals(stateRun.getLastMessages().get(j))) - { - mailAlreadyRead = true; - break; - } - } - /* If the mail is not already read */ - if (!mailAlreadyRead) - { - notifyNoNewMail = false; - /* Read max 5 mails */ - mailCounter++; - if (mailCounter <= 5) - { - throwMessage("Mail sent by {0}", sender); - throwMessage("The message subject is : {0}", filteredSubject); - } - /* Referencing the current mail */ - stateRun.getLastMessages().add(filteredSubject); - } - } - catch (Exception e) - { - /* Prevent unhandled errors */ - ; - } - } - if(notifyNoNewMail) - { - throwMessage("No new mail."); - } - } - /* No new message */ - else - { - throwMessage("No new mail."); - } - /* Save the current referenced mails */ - writeState(stateRun, sessionId + "RUN"); - } - - /** - * - * @return - * @throws MessagingException - * @throws IOException - * @throws ClassNotFoundException - */ - private Message[] connectToMailBox() throws MessagingException, IOException, ClassNotFoundException - { - String user; - String host; - String password; - Session session; - Properties props; - int port; - String protocol; - Store store; - Folder folder; - Message messages[]; - - /* Get user data */ - user = configuration().getUser(); - password = configuration().getPassword(); - host = "pop.gmail.com"; - /* Set ssl socket */ - Security.setProperty("ssl.SocketFactory.provider", "net.karmaLab.tuxDroid.plugins.DummySSLSocketFactory"); - /* Set text decoder */ - System.setProperty("mail.mime.decodetext.strict", "false"); - /* Configure seesion */ - props = new Properties(); - session = Session.getDefaultInstance(props, null); - /* Find server port */ - port = 995; - /* Get mail protocol */ - protocol = "pop3s"; - /* Create mail store */ - store = session.getStore(protocol); - /* Connect to the mailbox */ - try - { - store.connect(host, port, user, password); - } - /* Authentification exception (login / password / protocol / etc) */ - catch (javax.mail.AuthenticationFailedException e) - { - if (!getCommand().equals("check")) - { - if (e.toString().contains("[SYS/PERM]")) - { - BareBonesBrowserLaunch.openURL("http://mail.google.com/mail/?#settings/fwdandpop"); - throwMessage("You must activate the pop3 service in your Mail account"); - } - else - { - throwMessage("Sorry, there was an error when connecting to the mail server. Please check your email configuration."); - } - } - return null; - } - /* Connection failed exception (timeout / network unreachable) */ - catch (javax.mail.MessagingException e) - { - if (!getCommand().equals("check")) - { - throwMessage("Sorry, I could not connect to the mail server. Please check your internet connection or try again later."); - } - return null; - } - /* Connect and open inbox folder */ - folder = store.getFolder("INBOX"); - folder.open(Folder.READ_ONLY); - /* Get messages */ - messages = folder.getMessages(); - return messages; - } - - @Override - protected void onPluginEvent(String arg0, String[] arg1) throws Throwable - { - // TODO Auto-generated method stub - ; - } - - @Override - protected void onPluginStop() throws Throwable - { - // TODO Auto-generated method stub - ; - } -} \ No newline at end of file +/* This file is part of "TuxDroid Gadget Mail". + * Copyright 2008, kysoh + * Author : Yoran Brault + * eMail : software@_bad_karma-lab.net (remove _bad_ before sending an + * email) + * Site : http://www.kysoh.com/ + * + * "TuxDroid Gadget Mail" is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * "TuxDroid Gadget Mail" is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with "TuxDroid Gadget Mail"; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package net.karmaLab.tuxDroid.plugins; + +import java.io.IOException; +import java.security.Security; +import java.util.Properties; +import java.util.Vector; +import java.util.Random; + +import javax.mail.Folder; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.Store; +import javax.mail.Flags.Flag; +import javax.mail.internet.InternetAddress; + +import com.kysoh.tuxdroid.plugin.framework.plugin.SimplePlugin; + +/** + * @author User + */ +public class MailPlugin extends SimplePlugin<Configuration> +{ + String[] newMailSentences = { + "You have a new mail.", + "A new mail has arrived !", + "It appears you have received a new email.", + "A new email ? I wonder who could be thinking about you.", + "It would appear you have received new mails." + }; + + String[] mailSenderSentences = { + "Mail sent by {0}", + "The email was sent by {0}", + "The sender of the mail is {0}", + "The sender is {0}" + }; + + String[] mailSubjectSentences = { + "The email subject is : {0}", + "The subject of the email is : {0}", + "The email topic is : {0}", + "The topic is : {0}", + "The title of the email is : {0}" + }; + + String[] noNewMailSentences = { + "No new mail.", + "I'm sorry, nobody sent you any email.", + "No mails. Nobody seems to be thinking about you.", + "Your mailbox is empty." + }; + + String[] timeoutSentences = { + "G-mail is busy right now. Please try again later.", + "The Google mail website has a lot of traffic at the moment. Better to try again later.", + "I'm having difficulties to connect to Google mail. Please try again later.", + "I got a time-out while checking your G-mail account. The Google mail website is too busy right now." + }; + + /** + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception + { + new MailPlugin().boot(args, new Configuration()); + } + + /** + * + */ + @Override + public void start() + { + try + { + if (getCommand().equals("run")) + { + run(); + } + else if (getCommand().equals("check")) + { + check(); + } + else + { + run(); + } + } + catch (Exception e) {} + } + + + /** + * @throws MessagingException + * @throws IOException + * @throws ClassNotFoundException + */ + public void check() throws MessagingException, IOException, ClassNotFoundException, Exception + { + Message messages[] = connectToMailBox(); + + if (messages == null) + { + throwResult(false); + return; + } + String sessionId = "pop.gmail.com_" + configuration().getUser(); + State stateAlert = readState(State.class, sessionId + "ALERT"); + /* Is first check ? */ + boolean firstCheck; + if (stateAlert.getLastMessages().size() == 0) + { + firstCheck = true; + stateAlert.getLastMessages().add("FIRST_CHECK_HACK"); + } + else + { + firstCheck = false; + } + /* Check if you have a new message */ + boolean newMessageAlert = false; + for (int i = messages.length - 1; i >= 0; i--) + { + if (!messages[i].getFlags().contains(Flag.SEEN)) + { + String subject = messages[i].getSubject(); + if (subject != null) + { + if (!stateAlert.getLastMessages().contains(subject)) + { + newMessageAlert = true; + stateAlert.getLastMessages().add(subject); + } + } + } + } + if((newMessageAlert) && (!firstCheck)) + { + throwResult(true); + throwMessage(this.pickSentence(newMailSentences)); + } + else + { + throwResult(false); + } + /* Save the current referenced mails */ + writeState(stateAlert, sessionId + "ALERT"); + } + + /** + * + * @throws MessagingException + * @throws IOException + * @throws ClassNotFoundException + */ + public void run() throws MessagingException, IOException, ClassNotFoundException + { + Message messages[] = connectToMailBox(); + if (messages == null) + { + return; + } + String sessionId = "pop.gmail.com_" + configuration().getUser(); + State stateRun = readState(State.class, sessionId + "RUN"); + + String senderSentence = this.pickSentence(mailSenderSentences); + String subjectSentence = this.pickSentence(mailSubjectSentences); + /* Check for new message */ + boolean newMessageRun = false; + for (int i = messages.length - 1; i >= 0; i--) + { + if (!messages[i].getFlags().contains(Flag.SEEN)) + { + if (!stateRun.getLastMessages().contains(messages[i].getSubject())) + { + newMessageRun = true; + break; + } + } + } + /* If new message found */ + if (newMessageRun) + { + int mailCounter = 0; + boolean notifyNoNewMail = true; + /* For all unread mails */ + for (int i = messages.length - 1; i >= 0; i--) + { + String subject; + String filteredSubject; + String sender; + String senderPersonal; + String senderAddress; + boolean seen; + boolean mailAlreadyRead; + + try + { + /* Get current mail data */ + subject = messages[i].getSubject(); + senderPersonal = ((InternetAddress) messages[i].getFrom()[0]).getPersonal(); + senderAddress = ((InternetAddress)messages[i].getFrom()[0]).getAddress(); + seen = messages[i].getFlags().contains(Flag.SEEN); + /* Pass if mail is already seen */ + if (seen) + { + continue; + } + /* Pass if subject is empty */ + if (subject == null) + { + continue; + } + /* Filtering the mail address */ + if (senderPersonal == null) + { + sender = senderAddress; + } + else + { + sender = senderPersonal; + } + if (sender.contains("<")) + { + sender = sender.substring(0, sender.indexOf("<")); + } + /* Filtering the mail subject */ + filteredSubject = subject.replace("*", " "); + filteredSubject = filteredSubject.replace("_", " "); + filteredSubject = filteredSubject.replace("{", " "); + filteredSubject = filteredSubject.replace("}", " "); + filteredSubject = filteredSubject.replace("[", " "); + filteredSubject = filteredSubject.replace("]", " "); + filteredSubject = filteredSubject.replace("/", " "); + filteredSubject = filteredSubject.replace("\\", " "); + filteredSubject = filteredSubject.replace(" ", " "); + mailAlreadyRead = false; + /* Check if the mail has already be read */ + for (int j = 0; j < stateRun.getLastMessages().size(); j++) + { + if (filteredSubject.equals(stateRun.getLastMessages().get(j))) + { + mailAlreadyRead = true; + break; + } + } + /* If the mail is not already read */ + if (!mailAlreadyRead) + { + notifyNoNewMail = false; + /* Read max 5 mails */ + mailCounter++; + if (mailCounter <= 5) + { + throwMessage(senderSentence, sender); + throwMessage(subjectSentence, filteredSubject); + } + /* Referencing the current mail */ + stateRun.getLastMessages().add(filteredSubject); + } + } + catch (Exception e) + { + /* Prevent unhandled errors */ + ; + } + } + if(notifyNoNewMail) + { + throwMessage(this.pickSentence(noNewMailSentences)); + } + } + /* No new message */ + else + { + 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)]; + } + + /** + * + * @return + * @throws MessagingException + * @throws IOException + * @throws ClassNotFoundException + */ + private Message[] connectToMailBox() throws MessagingException, IOException, ClassNotFoundException + { + String user; + String host; + String password; + Session session; + Properties props; + int port; + String protocol; + Store store; + Folder folder; + Message messages[]; + + /* Get user data */ + user = configuration().getUser(); + password = configuration().getPassword(); + host = "pop.gmail.com"; + /* Set ssl socket */ + Security.setProperty("ssl.SocketFactory.provider", "net.karmaLab.tuxDroid.plugins.DummySSLSocketFactory"); + /* Set text decoder */ + System.setProperty("mail.mime.decodetext.strict", "false"); + /* Configure seesion */ + props = new Properties(); + session = Session.getDefaultInstance(props, null); + /* Find server port */ + port = 995; + /* Get mail protocol */ + protocol = "pop3s"; + /* Create mail store */ + store = session.getStore(protocol); + /* Connect to the mailbox */ + try + { + store.connect(host, port, user, password); + } + /* Authentification exception (login / password / protocol / etc) */ + catch (javax.mail.AuthenticationFailedException e) + { + if (!getCommand().equals("check")) + { + if (e.toString().contains("[SYS/PERM]")) + { + BareBonesBrowserLaunch.openURL("http://mail.google.com/mail/?#settings/fwdandpop"); + throwMessage("You must activate the pop3 service in your Mail account"); + } + else + { + throwMessage("Sorry, there was an error when connecting to the mail server. Please check your email configuration."); + } + } + return null; + } + /* Connection failed exception (timeout / network unreachable) */ + catch (javax.mail.MessagingException e) + { + if (!getCommand().equals("check")) + { + throwMessage("Sorry, I could not connect to the mail server. Please check your internet connection or try again later."); + } + return null; + } + /* Connect and open inbox folder */ + folder = store.getFolder("INBOX"); + folder.open(Folder.READ_ONLY); + /* Get messages */ + messages = folder.getMessages(); + return messages; + } + + @Override + protected void onPluginEvent(String arg0, String[] arg1) throws Throwable + { + // TODO Auto-generated method stub + ; + } + + @Override + protected void onPluginStop() throws Throwable + { + // TODO Auto-generated method stub + ; + } +} |