[Commits] (bkirsch) Updated Mail.py and parcel.xml for more robust mail functionality

commits at osafoundation.org commits at osafoundation.org
Tue Aug 17 14:45:40 PDT 2004


Commit by: bkirsch
Modified files:
chandler/parcels/osaf/contentmodel/mail/Mail.py 1.16 1.17
chandler/parcels/osaf/contentmodel/mail/parcel.xml 1.48 1.49

Log message:
Updated Mail.py and parcel.xml for more robust mail functionality

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/mail/Mail.py.diff?r1=text&tr1=1.16&r2=text&tr2=1.17
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/mail/parcel.xml.diff?r1=text&tr1=1.48&r2=text&tr2=1.49

Index: chandler/parcels/osaf/contentmodel/mail/Mail.py
diff -u chandler/parcels/osaf/contentmodel/mail/Mail.py:1.16 chandler/parcels/osaf/contentmodel/mail/Mail.py:1.17
--- chandler/parcels/osaf/contentmodel/mail/Mail.py:1.16	Fri Aug 13 12:03:32 2004
+++ chandler/parcels/osaf/contentmodel/mail/Mail.py	Tue Aug 17 14:45:39 2004
@@ -1,8 +1,8 @@
 """ Classes used for Mail parcel kinds
 """
 
-__revision__  = "$Revision: 1.16 $"
-__date__      = "$Date: 2004/08/13 19:03:32 $"
+__revision__  = "$Revision: 1.17 $"
+__date__      = "$Date: 2004/08/17 21:45:39 $"
 __copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -191,6 +191,8 @@
             kind = MailParcel.getSMTPAccountKind()
         super (SMTPAccount, self).__init__(name, parent, kind)
 
+        self.accountType = "SMTP"
+
 class IMAPAccount(AccountBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
@@ -199,6 +201,8 @@
             kind = MailParcel.getIMAPAccountKind()
         super (IMAPAccount, self).__init__(name, parent, kind)
 
+        self.accountType = "IMAP"
+
 class MailDeliveryBase(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
@@ -207,6 +211,7 @@
             kind = MailParcel.getMailDeliveryBaseKind()
         super (MailDeliveryBase, self).__init__(name, parent, kind)
 
+
 class SMTPDelivery(MailDeliveryBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
@@ -215,6 +220,23 @@
             kind = MailParcel.getSMTPDeliveryKind()
         super (SMTPDelivery, self).__init__(name, parent, kind)
 
+        self.deliveryType = "SMTP"
+        self.state = "DRAFT"
+
+    #XXX: Will want to expand state to an object with error or sucess code 
+    #     desc string, and date
+    def sendFailed(self):
+        self.history.append("FAILED")
+        self.state = "FAILED"
+        self.tries += 1
+
+    #XXX: See comments above
+    def sendSucceeded(self):
+        self.history.append("SENT")
+        self.state = "SENT"
+        self.tries += 1
+
+
 class IMAPDelivery(MailDeliveryBase):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
@@ -223,6 +245,8 @@
             kind = MailParcel.getIMAPDeliveryKind()
         super (IMAPDelivery, self).__init__(name, parent, kind)
 
+        self.deliveryType = "IMAP"
+
 class MIMEBase(Item.Item):
     def __init__(self, name=None, parent=None, kind=None):
         if not parent:
@@ -259,7 +283,9 @@
             kind = MailParcel.getMailMessageMixinKind()
         super (MailMessageMixin, self).__init__(name, parent, kind)
 
-    def InitOutgoingAttributes (self):
+        self.mimeType = "MESSAGE"
+
+    def InitOutgoingAttributes(self):
         """ Init any attributes on ourself that are appropriate for
         a new outgoing item.
         """
@@ -268,14 +294,62 @@
         except AttributeError:
             pass
 
+        self.outgoingMessage()
+
+
+    def outgoingMessage(self, type="SMTP", account=None):
+        if type != "SMTP":
+            raise TypeError("Only SMTP currently supported")
+
+        if account is None:
+            accountKind = MailParcel.getSMTPAccountKind()
+
+            """Get the first SMTP Account"""
+            for acc in Query.KindQuery().run([accountKind]):
+                acccount = acc
+                break
+
+            if account is None:
+                raise Exception("No SMTP Account exists in the Repository")
+
+        #XXX:SAdd test to make sure it is an item
+        elif not account.isItemOf(MailParcel.getSMTPAccountKind()):
+            raise TypeError("Only SMTP Accounts Supported")
+
+        self.deliveryExtension = SMTPDelivery()
+        self.isOutbound = True
+        self.parentAccount = account
+
+
+    def incomingMessage(self, type="IMAP", account=None):
+        if type != "IMAP":
+            raise TypeError("Only IMAP currently supported")
+
+        if account is None:
+            accountKind = MailParcel.getIMAPAccountKind()
+
+            """Get the first IMAP Account"""
+            for acc in Query.KindQuery().run([accountKind]):
+                acccount = acc
+                break
+
+            if account is None:
+                raise Exception("No IMAP Account exists in the Repository")
+
+        #XXX:SAdd test to make sure it is an item
+        elif not account.isItemOf(MailParcel.getIMAPAccountKind()):
+            raise TypeError("Only IMAP Accounts Supported")
+
+        self.deliveryExtension = IMAPDelivery()
+        self.isInbound = True
+        self.parentAccount = account
+
+
 class MailMessage(Notes.Note, MailMessageMixin):
     def __init__(self, name=None, parent=None, kind=None):
         if not kind:
             kind = MailParcel.getMailMessageKind()
         super (MailMessage, self).__init__(name, parent, kind)
-        self.mimeType = "MESSAGE"
-        self.isInBound = False
-        self.isOutBound = False
 
 class MIMEBinary(MIMENote):
     def __init__(self, name=None, parent=None, kind=None):

Index: chandler/parcels/osaf/contentmodel/mail/parcel.xml
diff -u chandler/parcels/osaf/contentmodel/mail/parcel.xml:1.48 chandler/parcels/osaf/contentmodel/mail/parcel.xml:1.49
--- chandler/parcels/osaf/contentmodel/mail/parcel.xml:1.48	Mon Aug 16 16:50:12 2004
+++ chandler/parcels/osaf/contentmodel/mail/parcel.xml	Tue Aug 17 14:45:39 2004
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.48 $ -->
-<!-- $Date: 2004/08/16 23:50:12 $ -->
+<!-- $Revision: 1.49 $ -->
+<!-- $Date: 2004/08/17 21:45:39 $ -->
 <!-- Copyright (c) 2003-2004 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -86,6 +86,18 @@
             <initialValue type="Integer" value="300" />
         </Attribute>
 
+        <Attribute itsName="accountType">
+            <displayName value="Account Type" />
+            <description value="POP, IMAP, WEBDAV, or SMTP" />
+            <type ref="mail:AccountBase/accountType/accountTypeEnum" />
+
+            <Enumeration itsName="accountTypeEnum">
+                <values value="POP" />
+                <values value="IMAP" />
+                <values value="SMTP" />
+                <values value="WEBDAV" />
+            </Enumeration>
+        </Attribute>
     </Kind>
 
     <Kind itsName="IMAPAccount">
@@ -124,7 +136,7 @@
             <initialValue />
         </Attribute>
 
-        <Attribute itsName="defaultSmtpAccount">
+        <Attribute itsName="defaultSMTPAccount">
             <displayName value="Default SMTP Account" />
             <description value="Which SMTP account to use for sending mail from this account" />
             <type ref="mail:SMTPAccount" />
@@ -180,7 +192,7 @@
             <displayName value="Accounts" />
             <description value="Which IMAP accounts use this SMTP account as their default" />
             <type ref="mail:IMAPAccount" />
-            <inverseAttribute ref="mail:IMAPAccount/defaultSmtpAccount" />
+            <inverseAttribute ref="mail:IMAPAccount/defaultSMTPAccount" />
             <cardinality value="list" />
             <initialValue />
         </Attribute>
@@ -202,7 +214,6 @@
                 <values value="IMAP" />
                 <values value="SMTP" />
             </Enumeration>
-
         </Attribute>
 
         <Attribute itsName="mailMessage">
@@ -267,14 +278,14 @@
         <Attribute itsName="folder">
             <displayName value="Folder" />
             <type ref="String" />
-            <initialValue type="String" value="INBOX" />
+            <initialValue type="String" value="" />
         </Attribute>
 
         <Attribute itsName="uid">
             <displayName value="IMAP UID" />
             <description value="The unique IMAP ID for the message" />
-            <type ref="String" />
-            <initialValue ref="None" />
+            <type ref="Long" />
+            <initialValue type="Long" value="0"/>
         </Attribute>
 
         <Attribute itsName="namespace">
@@ -404,12 +415,12 @@
             <inverseAttribute ref="mail:MailDeliveryBase/mailMessage" />
         </Attribute>
 
-        <Attribute itsName="isOutBound">
+        <Attribute itsName="isOutbound">
             <type ref="Boolean" />
             <initialValue type="Boolean" value="False" />
         </Attribute>
 
-        <Attribute itsName="isInBound">
+        <Attribute itsName="isInbound">
             <type ref="Boolean" />
             <initialValue type="Boolean" value="False" />
         </Attribute>



More information about the Commits mailing list