Author: jerome
Date: 2008-11-27 11:52:21 +0100 (Thu, 27 Nov 2008)
New Revision: 2858

Modified:
   
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
Log:
* Typo, cleanup.

Modified: 
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
    2008-11-27 10:32:20 UTC (rev 2857)
+++ 
software_suite_v2/software/gadgets/tuxdroid-gadget-mail/trunk/tuxdroid-gadget-mail/sources/net/karmaLab/tuxDroid/gadgets/MailGadget.java
    2008-11-27 10:52:21 UTC (rev 2858)
@@ -114,7 +114,6 @@
                /* If (ALERT MODE) */
                if (readOne) {
                        /* If new message */
-                       //TODO set filter here.
                        if (newMessageAlert) {
                                throwMessage("You have a new message.");
 
@@ -161,51 +160,16 @@
                                        if 
(!messages[i].getFlags().contains(Flag.SEEN)) {
                                                boolean mailAlreadyRead = false;
                                                
-                                               //Set sender filter.
                                                
if(this.configuration().isSenderFiltered())
                                                {
-                                                       Vector<Boolean> ver = 
new Vector<Boolean>();
-                                                       for(String 
allowedSender : this.configuration().getSenderFilter())
-                                                       {
-                                                               
if(!mail.equals(allowedSender))
-                                                               {
-                                                                       
ver.add(new Boolean(false));
-                                                               }
-                                                       }
-                                                       
-                                                       for(Boolean bool : ver)
-                                                       {
-                                                               
if(!bool.booleanValue())
-                                                               {
-                                                                       
mailAlreadyRead = true;
-                                                                       break;
-                                                               }
-                                                       }
-                                                       
+                                                       //Set sender filter.
+                                                       mailAlreadyRead = 
filterSender(mail);
                                                }
                                                
-                                               
-                                               //Set subject filter.
-                                               
if(this.configuration().isSubjectFiltered())
+                                               else 
if(this.configuration().isSubjectFiltered())
                                                {
-                                                       Vector<Boolean> ver = 
new Vector<Boolean>();
-                                                       for(String 
allowedContent : this.configuration().getSubjectFilter())
-                                                       {
-                                                               
if(!subject.contains(allowedContent))
-                                                               {
-                                                                       
ver.add(new Boolean(false));
-                                                               }
-                                                       }
-                                                       
-                                                       for(Boolean bool : ver)
-                                                       {
-                                                               
if(!bool.booleanValue())
-                                                               {
-                                                                       
mailAlreadyRead = true;
-                                                                       break;
-                                                               }
-                                                       }
-                                                       
+                                                       //Set subject filter.
+                                                       mailAlreadyRead = 
filterSubject(subject);
                                                }
                                                
                                                else
@@ -246,6 +210,62 @@
                writeState(stateAlert, sessionId + "ALERT");
                writeState(stateRun, sessionId + "RUN");
        }
+       
+       
+       /**
+        * Return true if the sender is not allowed.
+        * @param mail
+        * @return
+        */
+       private boolean filterSender(String mail)
+       {
+               Vector<Boolean> ver = new Vector<Boolean>();
+               for(String allowedSender : 
this.configuration().getSenderFilter())
+               {
+                       if(!mail.equals(allowedSender))
+                       {
+                               ver.add(new Boolean(false));
+                       }
+               }
+               
+               for(Boolean bool : ver)
+               {
+                       if(!bool.booleanValue())
+                       {
+                               return true;
+                       }
+               }
+                       
+               return false;
+       }
+       
+       
+       /**
+        * Return true if subject is not allowed.
+        * @param subject
+        * @return
+        */
+       private boolean filterSubject(String subject)
+       {
+               Vector<Boolean> ver = new Vector<Boolean>();
+               for(String allowedContent : 
this.configuration().getSubjectFilter())
+               {
+                       if(!subject.contains(allowedContent))
+                       {
+                               ver.add(new Boolean(false));
+                       }
+               }
+               
+               for(Boolean bool : ver)
+               {
+                       if(!bool.booleanValue())
+                       {
+                               return true;
+                       }
+               }
+               
+               return false;
+       }
 
        /**
         * @throws MessagingException


-------------------------------------------------------------------------
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