Update of /cvsroot/freevo/freevo/src/plugins/idlebar
In directory sc8-pr-cvs1:/tmp/cvs-serv31807/src/plugins/idlebar

Modified Files:
        MultiMail.py 
Log Message:
Made the mail checking a background task since it tended to freeze the display for 
several seconds while checking.

Index: MultiMail.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugins/idlebar/MultiMail.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MultiMail.py        14 Nov 2003 04:08:55 -0000      1.1
--- MultiMail.py        19 Nov 2003 06:05:03 -0000      1.2
***************
*** 31,36 ****
--- 31,40 ----
  import poplib
  import mailbox
+ import threading
+ import time
+ 
  from plugins.idlebar import IdleBarPlugin
  
+ 
  class MultiMail(IdleBarPlugin):
      """
***************
*** 47,65 ****
          self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_dimmed.png')
          self.MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_active_small.png')
!         self.FREQUENCY = 10
!         self.skip = 0
          self.unread = 0
! 
      def checkmail(self):
          return 0
  
      def draw(self, (type, object), x, osd):
-         print 'imap called'
-         if self.skip == 0:
-             self.skip = self.FREQUENCY
-             print 'checking mail'
-             self.unread = self.checkmail()
-         else:
-             self.skip -= 1
          if self.unread > 0:
              image_width = osd.draw_image(self.MAILIMAGE, (x, osd.y + 2, -1, -1))[0]
--- 51,69 ----
          self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_dimmed.png')
          self.MAILIMAGE = os.path.join(config.ICON_DIR, 
'status/newmail_active_small.png')
!         self.FREQUENCY = 20 # seconds between checks
          self.unread = 0
!         self.bg_thread = threading.Thread(target=self._bg_function, name='MultiMail 
Thread')
!         self.bg_thread.setDaemon(1)
!         self.bg_thread.start() # Run self._bg_function() in a separate thread
!         
!     def _bg_function(self):
!         while 1:
!             self.unread = self.checkmail()
!             time.sleep(self.FREQUENCY)
!         
      def checkmail(self):
          return 0
  
      def draw(self, (type, object), x, osd):
          if self.unread > 0:
              image_width = osd.draw_image(self.MAILIMAGE, (x, osd.y + 2, -1, -1))[0]
***************
*** 75,79 ****
  class Imap(MultiMail):
      def __init__(self, username, password, host, port=143, folder="INBOX"):
-         MultiMail.__init__(self)
          self.USERNAME = username
          self.PASSWORD = password
--- 79,82 ----
***************
*** 81,84 ****
--- 84,88 ----
          self.PORT = port
          self.FOLDER = folder
+         MultiMail.__init__(self)
          
      def checkmail(self):
***************
*** 91,103 ****
              return unread            
          except:
              return 0
          
  class Pop3(MultiMail):        
      def __init__(self, username, password, host, port=110):
-         MultiMail.__init__(self)    
          self.USERNAME = username
          self.PASSWORD = password
          self.HOST = host
          self.PORT = port
  
      def checkmail(self):
--- 95,108 ----
              return unread            
          except:
+             _debug_('IMAP exception')
              return 0
          
  class Pop3(MultiMail):        
      def __init__(self, username, password, host, port=110):
          self.USERNAME = username
          self.PASSWORD = password
          self.HOST = host
          self.PORT = port
+         MultiMail.__init__(self)    
  
      def checkmail(self):
***************
*** 114,119 ****
  class Mbox(MultiMail):
      def __init__(self, mailbox):
-         MultiMail.__init__(self)    
          self.MAILBOX = mailbox
  
      def checkmail(self):
--- 119,124 ----
  class Mbox(MultiMail):
      def __init__(self, mailbox):
          self.MAILBOX = mailbox
+         MultiMail.__init__(self)    
  
      def checkmail(self):




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to