Author: ulhume
Date: 2008-08-15 01:44:34 +0200 (Fri, 15 Aug 2008)
New Revision: 1492

Added:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/resources/
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/resources/evolution.png
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/resources/gadget.pot
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/tests/
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/tests/MailGadgetTest.java
Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/.classpath
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/gadgets.xml
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/project.xml
Log:


Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/.classpath
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/.classpath
       2008-08-14 23:44:15 UTC (rev 1491)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/.classpath
       2008-08-14 23:44:34 UTC (rev 1492)
@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
        <classpathentry kind="src" path="sources"/>
+       <classpathentry kind="src" path="tests"/>
        <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry combineaccessrules="false" kind="src" 
path="/karmalab-commons"/>
        <classpathentry combineaccessrules="false" kind="src" 
path="/tuxdroid-gadget-framework"/>
        <classpathentry combineaccessrules="false" kind="src" 
path="/tuxdroid-gadget-tester"/>
+       <classpathentry kind="lib" path="libraries/javamail-1.4.1.jar"/>
+       <classpathentry kind="lib" path="libraries/g4j-lib.jar"/>
        <classpathentry kind="output" path="targets/eclipse"/>
 </classpath>

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/gadgets.xml
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/gadgets.xml
      2008-08-14 23:44:15 UTC (rev 1491)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/gadgets.xml
      2008-08-14 23:44:34 UTC (rev 1492)
@@ -11,23 +11,47 @@
                        <version>1.0</version>
                        <iconFile>resources/MailGadget.png</iconFile>
                        <executionMode>service</executionMode>
-                       <uuid>f63af23e-7ae0-4389-b89b-bc5a8185b0b8</uuid>
+                       <uuid>f63af23e-7ae0-4389-b89b-bc5a8185b0c8</uuid>
                </description>
                <parameters>
                        <parameter
                                name="host"
-                               description="MPD server"
+                               description="server host"
                                type="string"
                                defaultValue="nephilia" />
                        <parameter
                                name="port"
-                               description="MPD port"
+                               description="Server port"
                                type="integer"
-                               defaultValue="6600" />
+                               defaultValue="143" />
+                       <parameter
+                               name="user"
+                               description="Username"
+                               type="string"
+                               defaultValue="yoran" />
+                       <parameter
+                               name="folder"
+                               description="IMAP folder to retreive"
+                               type="string"
+                               defaultValue="INBOX" />
+                       <parameter
+                               name="password"
+                               description="Password"
+                               type="string"
+                               defaultValue="" />
+                       <parameter
+                               name="protocol"
+                               description="Protocol"
+                               type="enum(pop3,imap)"
+                               defaultValue="imap" />
                </parameters>
                <commands>
-                       <command name="play" description="play"/>
-                       <command name="stop" description="stop"/>
+                       <command
+                               name="check"
+                               description="Check if there is any new mail" />
+                       <command
+                               name="read"
+                               description="Read your mail" />
                </commands>
        </gadget>
 </gadgets>
\ No newline at end of file

Modified: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/project.xml
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/project.xml
      2008-08-14 23:44:15 UTC (rev 1491)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/project.xml
      2008-08-14 23:44:34 UTC (rev 1492)
@@ -2,15 +2,12 @@
        <name>tuxdroid-gadget-mail</name>
        <title>TuxDroid Gadget Mail</title>
        <description>TuxDroid Gadget Weather</description>
-
        <license>
                <name>GPL</name>
        </license>
-
        <groupId>com.kysoh</groupId>
        <artifactId>tuxdroid-gadget-mail</artifactId>
        <version>0.1</version>
-
        <dependencies>
                <dependency>
                        <groupId>net.karmaLab</groupId>
@@ -22,6 +19,11 @@
                        <artifactId>tuxdroid-gadget-framework</artifactId>
                        <version>0.1</version>
                </dependency>
+               <dependency>
+                       <groupId>javamail</groupId>
+                       <artifactId>javamail</artifactId>
+                       <version>1.4.1</version>
+               </dependency>
        </dependencies>
        <repositories>
                <repository>
@@ -47,18 +49,17 @@
                <developer>
                        <name>Yoran Brault</name>
                        <organization>kysoh</organization>
-                       <email>
-                               [EMAIL PROTECTED] (remove _bad_ before sending
-                               an email)
-                       </email>
+                       <email> [EMAIL PROTECTED] (remove _bad_ before sending 
an email)</email>
                        <organizationUrl>http://www.kysoh.com/</organizationUrl>
                </developer>
        </developers>
-
        <releases>
-               <release date="03/06/2008" version="0.1">
+               <release
+                       date="03/06/2008"
+                       version="0.1">
                        <changes>
-                               <change kind="creation">
+                               <change
+                                       kind="creation">
                                        <description>First version</description>
                                </change>
                        </changes>

Added: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/resources/evolution.png
===================================================================
(Binary files differ)


Property changes on: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/resources/evolution.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/resources/gadget.pot
===================================================================

Added: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
                            (rev 0)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
    2008-08-14 23:44:34 UTC (rev 1492)
@@ -0,0 +1,243 @@
+package net.karmaLab.tuxDroid.gadgets;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+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 net.karmaLab.xml.bean.XmlObjectReaderException;
+
+import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadget;
+import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadgetConfiguration;
+
+public class MailGadget extends SimpleGadget<MailGadget.Configuration> {
+       public enum ServerProtocol {
+               pop3, imap
+       }
+
+       public static class State implements Serializable {
+               private Vector<String> lastMessages = new Vector<String>();
+
+               /**
+                * @return the lastMessages
+                */
+               public Vector<String> getLastMessages() {
+                       return lastMessages;
+               }
+
+               /**
+                * @param lastMessages
+                *            the lastMessages to set
+                */
+               public void setLastMessages(Vector<String> lastMessages) {
+                       this.lastMessages = lastMessages;
+               }
+
+       }
+
+       public static class Configuration extends SimpleGadgetConfiguration {
+               private String host;
+               private int port;
+               private ServerProtocol protocol;
+               private String password;
+               private String user;
+               private String folder;
+               private boolean useFrom;
+               private boolean useSubject;
+
+               /**
+                * @return the useFrom
+                */
+               public boolean isUseFrom() {
+                       return useFrom;
+               }
+
+               /**
+                * @param useFrom
+                *            the useFrom to set
+                */
+               public void setUseFrom(boolean useFrom) {
+                       this.useFrom = useFrom;
+               }
+
+               /**
+                * @return the useSubject
+                */
+               public boolean isUseSubject() {
+                       return useSubject;
+               }
+
+               /**
+                * @param useSubject
+                *            the useSubject to set
+                */
+               public void setUseSubject(boolean useSubject) {
+                       this.useSubject = useSubject;
+               }
+
+               /**
+                * @return the folder
+                */
+               public String getFolder() {
+                       return folder;
+               }
+
+               /**
+                * @param folder
+                *            the folder to set
+                */
+               public void setFolder(String folder) {
+                       this.folder = folder;
+               }
+
+               /**
+                * @return the password
+                */
+               public String getPassword() {
+                       return password;
+               }
+
+               /**
+                * @param password
+                *            the password to set
+                */
+               public void setPassword(String password) {
+                       this.password = password;
+               }
+
+               /**
+                * @return the user
+                */
+               public String getUser() {
+                       return user;
+               }
+
+               /**
+                * @param user
+                *            the user to set
+                */
+               public void setUser(String user) {
+                       this.user = user;
+               }
+
+               /**
+                * @return the port
+                */
+               public int getPort() {
+                       return port;
+               }
+
+               /**
+                * @param port
+                *            the port to set
+                */
+               public void setPort(int port) {
+                       this.port = port;
+               }
+
+               /**
+                * @return the kind
+                */
+               public ServerProtocol getProtocol() {
+                       return protocol;
+               }
+
+               /**
+                * @param kind
+                *            the kind to set
+                */
+               public void setProtocol(ServerProtocol kind) {
+                       this.protocol = kind;
+               }
+
+               public String getHost() {
+                       return host;
+               }
+
+               public void setHost(String host) {
+                       this.host = host;
+               }
+       }
+
+       private static Configuration configuration;
+
+       public static void main(String[] args) throws Exception {
+               new MailGadget().boot(args, configuration = new 
Configuration());
+       }
+
+       public void check() throws MessagingException, 
XmlObjectReaderException, IOException, ClassNotFoundException {
+               File sessionId = new File(configuration.getHost() + "_" + 
configuration.getPort() + "_" + configuration.getUser());
+               State state = null;
+               if (sessionId.exists()) {
+                       ObjectInputStream inputStream = new 
ObjectInputStream(new FileInputStream(sessionId));
+                       state = (State) inputStream.readObject();
+               } else {
+                       state = new State();
+               }
+               System.setProperty("mail.mime.decodetext.strict", "false");
+
+               throwTrace("Last Messages :" + state.getLastMessages().size());
+               Properties props = new Properties();
+               Session session = Session.getDefaultInstance(props, null);
+               throwTrace("Using protocol :" + configuration.getProtocol());
+               Store store = 
session.getStore(configuration.getProtocol().toString());
+               throwTrace("Connecting to " + configuration.getHost() + " as " 
+ configuration.getUser() + " with " + configuration.getPassword());
+               store.connect(configuration.getHost(), configuration.getUser(), 
configuration.getPassword());
+               Folder folder = store.getFolder(configuration.getFolder());
+               throwTrace("Getting folder " + configuration.getFolder());
+
+               folder.open(Folder.READ_ONLY);
+               Message messages[] = folder.getMessages();
+               for (int i = 0; i < messages.length; i++) {
+                       String subject = messages[i].getSubject();
+                       // throwTrace("#" + i + " - " + subject);
+                       if (!messages[i].getFlags().contains(Flag.SEEN)) {
+                               boolean found = false;
+                               for (int j = 0; j < 
state.getLastMessages().size(); j++) {
+                                       if 
(subject.equals(state.getLastMessages().get(j))) {
+                                               found = true;
+                                               break;
+                                       }
+                               }
+                               if (!found) {
+                                       if (!configuration.useFrom && 
!configuration.useSubject) {
+                                               throwMessage("You have a new 
message");
+                                       } else {
+                                               if (configuration.useFrom) {
+                                                       throwMessage("This 
message is sent by %s", messages[i].getFrom()[0].toString());
+                                               }
+
+                                               if (configuration.useSubject) {
+                                                       throwMessage("The 
message subject is : %s", subject);
+                                               }
+                                       }
+                                       state.getLastMessages().add(subject);
+                               }
+                       }
+               }
+               ObjectOutputStream outputStream = new ObjectOutputStream(new 
FileOutputStream(sessionId));
+               outputStream.writeObject(state);
+               outputStream.close();
+       }
+
+       @Override
+       public void start() throws Exception {
+               if (getCommand().equals("check")) {
+                       check();
+                       return;
+               }
+       }
+
+}


Property changes on: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/tests/MailGadgetTest.java
===================================================================
--- 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/tests/MailGadgetTest.java
                                (rev 0)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/tests/MailGadgetTest.java
        2008-08-14 23:44:34 UTC (rev 1492)
@@ -0,0 +1,14 @@
+
+import java.io.File;
+
+import net.karmaLab.tools.SystemInformation;
+import net.karmaLab.tuxDroid.gadgets.MailGadget;
+
+import com.kysoh.tuxdroid.gadget.framework.container.GadgetsContainerException;
+import com.kysoh.tuxdroid.gadget.framework.tester.GadgetTester;
+
+public class MailGadgetTest {
+       public static void main(String[] args) throws GadgetsContainerException 
{
+               new GadgetTester().testGadget(new File("."), MailGadget.class, 
SystemInformation.classpathFiles());
+       }
+}


Property changes on: 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/tests/MailGadgetTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to