[Commits] (bkirsch) Updated mail package to handle new Mail Content Model

commits at osafoundation.org commits at osafoundation.org
Thu Aug 12 18:55:15 PDT 2004


Commit by: bkirsch
Modified files:
chandler/parcels/osaf/mail/parcel.xml 1.10 1.11
chandler/parcels/osaf/mail/message.py 1.6 1.7
chandler/parcels/osaf/mail/imap.py 1.4 1.5

Log message:
Updated mail package to handle new Mail Content Model

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/parcel.xml.diff?r1=text&tr1=1.10&r2=text&tr2=1.11
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/message.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/mail/imap.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5

Index: chandler/parcels/osaf/mail/parcel.xml
diff -u chandler/parcels/osaf/mail/parcel.xml:1.10 chandler/parcels/osaf/mail/parcel.xml:1.11
--- chandler/parcels/osaf/mail/parcel.xml:1.10	Wed Aug 11 10:39:34 2004
+++ chandler/parcels/osaf/mail/parcel.xml	Thu Aug 12 18:55:14 2004
@@ -6,14 +6,14 @@
              xmlns:mail="http://osafoundation.org/parcels/osaf/mail"
              xmlns:task="http://osafoundation.org/parcels/osaf/framework/tasks">
 
-  <content:EmailAccount itsName="IMAPAccount One">
-    <content:displayName>IMAP Server</content:displayName>
-    <content:serverName>code-bear.com</content:serverName>
-    <content:accountType>IMAP4</content:accountType>
-    <content:accountName>osafuser</content:accountName>
+  <content:IMAPAccount itsName="IMAPAccount One">
+    <content:displayName>IMAP Server Account One</content:displayName>
+    <content:host>code-bear.com</content:host>
+    <content:username>osafuser</content:username>
     <content:password>chandler</content:password>
-    <content:serverPort>143</content:serverPort>
-  </content:EmailAccount>
+    <content:port>143</content:port>
+    <content:useSSL>False</content:useSSL>
+  </content:IMAPAccount>
 
   <task:Task itsName="IMAPMailClient">
     <task:Schedule itsName="MailSchedule">

Index: chandler/parcels/osaf/mail/imap.py
diff -u chandler/parcels/osaf/mail/imap.py:1.4 chandler/parcels/osaf/mail/imap.py:1.5
--- chandler/parcels/osaf/mail/imap.py:1.4	Tue Aug  3 16:47:57 2004
+++ chandler/parcels/osaf/mail/imap.py	Thu Aug 12 18:55:14 2004
@@ -1,5 +1,5 @@
-__revision__  = "$Revision: 1.4 $"
-__date__      = "$Date: 2004/08/03 23:47:57 $"
+__revision__  = "$Revision: 1.5 $"
+__date__      = "$Date: 2004/08/13 01:55:14 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -93,8 +93,8 @@
     def __init__(self, account):
         """
         Creates a C{IMAPDownload} instance
-        @param account: An Instance of C{EmailAccountKind}
-        @type account: C{EmailAccountKind}
+        @param account: An Instance of C{IMAPAccount}
+        @type account: C{IMAPAccount}
         @return: C{None}
         """
 
@@ -144,8 +144,8 @@
 
             self.account.setPinned()
 
-            serverName = self.account.serverName
-            serverPort = self.account.serverPort
+            host  = self.account.host
+            port = self.account.port
 
             if __debug__:
                 self.printAccount()
@@ -154,11 +154,11 @@
             self.restorePreviousView()
 
         factory = ChandlerIMAP4Factory(self.loginClient, self.catchErrors)
-        reactor.connectTCP(serverName, serverPort, factory)
+        reactor.connectTCP(host, port, factory)
  
     def printAccount(self):
         """
-        Utility method that prints out C{EmailAccountKind} information for debugging
+        Utility method that prints out C{IMAPAccount} information for debugging
         purposes
         @return: C{None}
         """
@@ -168,9 +168,9 @@
         if self.account is None:
             return
 
-        str  = "\nHost: %s\n" % self.account.serverName
-        str += "Port: %d\n" % self.account.serverPort
-        str += "Username: %s\n" % self.account.accountName
+        str  = "\nHost: %s\n" % self.account.host
+        str += "Port: %d\n" % self.account.port
+        str += "Username: %s\n" % self.account.username
         str += "Password: %s\n" % self.account.password
 
         self.log.info(str)
@@ -208,7 +208,7 @@
 
             assert self.account is not None, "Account is None can not login client"
 
-            return self.proto.login(str(self.account.accountName),
+            return self.proto.login(str(self.account.username),
                                     str(self.account.password)).addCallback(self.__selectInbox)
         finally:
            self.restorePreviousView()
@@ -347,7 +347,7 @@
 
     def __getAccount(self):
 
-        accountKind = Mail.MailParcel.getEmailAccountKind()
+        accountKind = Mail.MailParcel.getIMAPAccountKind()
         account = accountKind.findUUID(self.accountUUID)
 
         if account is None: 
@@ -357,12 +357,12 @@
 
     def __printInfo(self, info):
 
-        if self.account.serverPort != 143:
-            str = "[Server: %s:%d User: %s] %s" % (self.account.serverName,
-                                                   self.account.serverPort,
-                                                   self.account.accountName, info)
+        if self.account.port != 143:
+            str = "[Server: %s:%d User: %s] %s" % (self.account.host,
+                                                   self.account.port,
+                                                   self.account.username, info)
         else:
-            str = "[Server: %s User: %s] %s" % (self.account.serverName,
-                                                self.account.accountName, info)
+            str = "[Server: %s User: %s] %s" % (self.account.host,
+                                                self.account.username, info)
 
         self.log.info(str)

Index: chandler/parcels/osaf/mail/message.py
diff -u chandler/parcels/osaf/mail/message.py:1.6 chandler/parcels/osaf/mail/message.py:1.7
--- chandler/parcels/osaf/mail/message.py:1.6	Thu Aug 12 16:55:13 2004
+++ chandler/parcels/osaf/mail/message.py	Thu Aug 12 18:55:14 2004
@@ -1,5 +1,5 @@
-__revision__  = "$Revision: 1.6 $"
-__date__      = "$Date: 2004/08/12 23:55:13 $"
+__revision__  = "$Revision: 1.7 $"
+__date__      = "$Date: 2004/08/13 01:55:14 $"
 __copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -133,6 +133,7 @@
 
     if messageObject['Date'] is not None:
         m.dateSent = DateTime.mktime(Utils.parsedate(messageObject['Date']))
+        m.dateSentString = messageObject['Date']
 
     else:
         m.dateSent = None
@@ -144,9 +145,8 @@
     else:
         m.subject = messageObject['Subject']
 
-    # XXX replyAddress should really be the Reply-to header, not From
-    m.replyAddress = Mail.EmailAddress()
-    m.replyAddress.emailAddress = format_addr(Utils.parseaddr(messageObject['From']))
+    m.fromAddress = Mail.EmailAddress()
+    m.fromAddress.emailAddress = format_addr(Utils.parseaddr(messageObject['From']))
 
     m.toAddress = []
     for addr in Utils.getaddresses(messageObject.get_all('To', [])):
@@ -184,11 +184,13 @@
 
     messageObject = Message.Message()
 
-    messageObject['Date'] = Utils.formatdate(mailMessage.dateSent.ticks(), True)
+    messageObject['Date'] = mailMessage.dateSentString()
+    #Utils.formatdate(mailMessage.dateSent.ticks(), True)
+
     messageObject['Date Received'] = Utils.formatdate(mailMessage.dateReceived.ticks(), True)
     messageObject['Subject'] = mailMessage.subject
 
-    messageObject['From'] = mailMessage.replyAddress.emailAddress
+    messageObject['From'] = mailMessage.fromAddress.emailAddress
 
     to = []
 



More information about the Commits mailing list