Author: jerome
Date: 2010-02-04 15:10:52 +0100 (Thu, 04 Feb 2010)
New Revision: 6052

Modified:
   
software_suite_v3/software/plugin/plugin-hotmail/trunk/executables/plugin-hotmail.py
   software_suite_v3/software/plugin/plugin-hotmail/trunk/resources/plugin.xml
Log:
* Updated plugin to match with the eMail plugin.

Modified: 
software_suite_v3/software/plugin/plugin-hotmail/trunk/executables/plugin-hotmail.py
===================================================================
--- 
software_suite_v3/software/plugin/plugin-hotmail/trunk/executables/plugin-hotmail.py
        2010-02-03 14:25:35 UTC (rev 6051)
+++ 
software_suite_v3/software/plugin/plugin-hotmail/trunk/executables/plugin-hotmail.py
        2010-02-04 14:10:52 UTC (rev 6052)
@@ -56,7 +56,7 @@
         '''Return the user parameter value.
         '''
         #Verify email validity.
-        if ( find( self.__user, '@' ) == -1) and ( rfind( self.__user, '.' ) 
== -1 ):
+        if ( self.__user.find('@') == -1) or ( 
self.__user[self.__user.find('@'):].find('.') == -1 ):
             return ""
         
         if not self.isValidAddress(self.__user):
@@ -148,13 +148,12 @@
     # 
--------------------------------------------------------------------------
     # Dynamic sentences lists.
     # 
--------------------------------------------------------------------------
-    SINGLE_MAIL   = ['You have a new mail.', 'A new mail has arrived !',
+    NEW_MAIL   = ['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.'
+                     'A new email ? I wonder who could be thinking about you.',
+                     'It would appear you have received new mails.'
                     ]
     
-    MULTIPLE_MAIL = ['You have {0} new emails', 'It would appear you have 
received new mails.']
-    
     NO_NEW_MAIL   = ['No new mail.', 'I\'m sorry, nobody sent you any email.',
                      'No mails. Nobody seems to be thinking about you.',
                      'Your mailbox is empty.'
@@ -200,6 +199,8 @@
             if ( self.configuration().getUser() == "" ) or ( 
self.configuration().getPassword() == "" ):
                 if self.getCommand() == "run":
                     self.throwMessage(self.pickSentence(self.BAD_LOGIN))
+                elif self.getCommand() == "check":
+                    self.throwResult(False)
                 self.stop()
             #Username is hotmail friendly, so trying to get connected.
             else:
@@ -224,7 +225,6 @@
             #No internet connection, so exiting.
             if self.getCommand() == "run":
                 self.throwMessage(self.pickSentence(self.BAD_INTERNET))
-            self.stop()
        
     # 
--------------------------------------------------------------------------
     # Plugin entry point for the "run" command.
@@ -232,32 +232,28 @@
     def run(self):
         '''Plugin entry point for the "run" command.
         '''
+        thrown = False
         if not self.isWindows():
             self.stop()
         
         #Else there have at least one new email.
-        else:
-            #Checking how many email were already said.
-            count = 0
+        else:   
+            #Getting sender and subject.
             for mail in self.mails.keys():
-                if not self.isRegistered(mail):
-                    count += 1
-            if count > 1:
-                self.throwMessage(self.pickSentence(self.MULTIPLE_MAIL), count)
-            elif count == 1:
-                self.throwMessage(self.pickSentence(self.SINGLE_MAIL))
-            elif ( count == 0 ) and self.login :
-                self.throwMessage(self.pickSentence(self.NO_NEW_MAIL))
-                
-            #Getting sender and subject now.
-            for mail in self.mails.keys():
-                if not self.isRegistered(mail):
+                if not self.isRegistered(mail,"RUN"):
+                    if not thrown:
+                        thrown = True
                     if self.configuration().getReadSender():
                         self.throwMessage(self.pickSentence(self.FROM), 
self.mails[mail]['sender'])
                     if self.configuration().getReadSubject():
                         self.throwMessage(self.pickSentence(self.SUBJECT), 
self.mails[mail]['subject'])
                     #Finally registering this new mail into history.
-                    self.registerMail(mail)
+                    self.registerMail(mail,"RUN")
+                    self.registerMail(mail, "CHECK")
+        #No new mail
+        if not thrown:
+            self.throwMessage(self.pickSentence(self.NO_NEW_MAIL))
+            
         self.stop()
 
     # 
--------------------------------------------------------------------------
@@ -267,32 +263,31 @@
         '''Plugin entry point for the "check" command.
         '''
         if not self.isWindows():
-            self.throwResult('false')
+            self.throwResult(False)
             self.stop()
             
         if not ( len(self.mails) == 0 ):
-            count = 0
+            newMail = False
             #Checking how many email were already said.
             for mail in self.mails.keys():
-                if not self.isRegistered(mail):
-                    count += 1
+                if not self.isRegistered(mail,"CHECK"):
+                    newMail = True
                     #Registering as readed into history.
-                    self.registerMail(mail)
+                    self.registerMail(mail,"CHECK")
             
+            self.registerHistory()
+            
             if self.__firstCycle:
+                self.throwResult(False)
                 self.stop()
-            
+           
             #Throwing the result.
-            if count > 1:
-                self.throwNotification('start')
-                self.throwMessage(self.pickSentence(self.MULTIPLE_MAIL), count)
-                self.throwNotification('stop')
-            elif count == 1:
-                self.throwNotification("start")
-                self.throwMessage(self.pickSentence(self.SINGLE_MAIL))
-                self.throwNotification('stop')
-              
-        self.stop()
+            if newMail:
+                self.throwResult(True)
+                self.throwMessage(self.pickSentence(self.NEW_MAIL))
+        else:
+            self.throwResult(False)
+    
         
     # 
--------------------------------------------------------------------------
     # Ping for internet connection.
@@ -360,18 +355,20 @@
     # 
--------------------------------------------------------------------------
     # Return True if an email is registered into history list.
     # 
--------------------------------------------------------------------------
-    def isRegistered(self, mailID):
+    def isRegistered(self, mailID, type):
         '''Return True if an email is registered into history list.
         '''
+        mailID += type
         return ( mailID in self.__history )
     
     # 
--------------------------------------------------------------------------
     # Register an eMail to the history list.
     # 
--------------------------------------------------------------------------
-    def registerMail(self, mailID):
+    def registerMail(self, mailID, type):
         '''Register an eMail to the history list.
+           @Param type = RUN or CHECK
         '''
-        self.__history.append(mailID)
+        self.__history.append(mailID + type)
             
     # 
--------------------------------------------------------------------------
     # Load pickle history object.
@@ -426,7 +423,7 @@
         '''Callback on plugin stop.
         '''
         #Registering pickle struct.
-        if len(self.__history) > 0:
+        if ( self.getCommand() == "run" ) and ( len(self.__history) > 0 ):
             self.registerHistory()
         #Rest leds if not already done.
         if self.getCommand() == "run":

Modified: 
software_suite_v3/software/plugin/plugin-hotmail/trunk/resources/plugin.xml
===================================================================
--- software_suite_v3/software/plugin/plugin-hotmail/trunk/resources/plugin.xml 
2010-02-03 14:25:35 UTC (rev 6051)
+++ software_suite_v3/software/plugin/plugin-hotmail/trunk/resources/plugin.xml 
2010-02-04 14:10:52 UTC (rev 6052)
@@ -42,9 +42,7 @@
                <command
                        name="check"
                        description="Check if there is any new mail" 
-            daemon="true"
-            expiration="1"
-            notifier="true"/>
+            />
         <command
                        name="run"
                        description="Read your new mails" 


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Tux-droid-svn mailing list
Tux-droid-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to