incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arie...@apache.org
Subject svn commit: r1232130 - /incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
Date Mon, 16 Jan 2012 19:50:51 GMT
Author: arielch
Date: Mon Jan 16 19:50:50 2012
New Revision: 1232130

URL: http://svn.apache.org/viewvc?rev=1232130&view=rev
Log:
i118736 - i118787 : fix XMailMessage implementation in mailmerge.py

Modified:
    incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py

Modified: incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py?rev=1232130&r1=1232129&r2=1232130&view=diff
==============================================================================
--- incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py (original)
+++ incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py Mon Jan 16 19:50:50 2012
@@ -52,7 +52,7 @@ class PyMailSMTPService(unohelper.Base, 
 		self.supportedtypes = ('Insecure', 'Ssl')
 		self.server = None
 		self.connectioncontext = None
-		self.notify = EventObject()
+		self.notify = EventObject(self)
 		if dbg:
 			print >> sys.stderr, "PyMailSMPTService init"
 	def addConnectionListener(self, xListener):
@@ -83,7 +83,7 @@ class PyMailSMTPService(unohelper.Base, 
 		connectiontype = xConnectionContext.getValueByName("ConnectionType")
 		if dbg:
 			print >> sys.stderr, connectiontype
-		if connectiontype == 'Ssl':
+		if connectiontype.upper() == 'SSL':
 			self.server.ehlo()
 			self.server.starttls()
 			self.server.ehlo()
@@ -180,7 +180,7 @@ class PyMailSMTPService(unohelper.Base, 
 
 		mailerstring = "OpenOffice.org 2.0 via Caolan's mailmerge component"
 		try:
-			ctx = uno.getComponentContext() 
+			ctx = uno.getComponentContext()
 			aConfigProvider = ctx.ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider")
 			prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
 			prop.Name = "nodepath"
@@ -191,7 +191,7 @@ class PyMailSMTPService(unohelper.Base, 
 				aSettings.getByName("ooSetupVersion") + " via Caolan's mailmerge component"
 		except:
 			pass
-		
+
 		msg['X-Mailer'] = mailerstring
 		msg['Date'] = formatdate(localtime=True)
 
@@ -206,9 +206,10 @@ class PyMailSMTPService(unohelper.Base, 
 			msgattachment.set_payload(data)
 			Encoders.encode_base64(msgattachment)
 			msgattachment.add_header('Content-Disposition', 'attachment', \
-				filename=attachment.ReadableName)
+				filename=('utf-8','',attachment.ReadableName.encode('utf-8')))
 			msg.attach(msgattachment)
 
+
 		uniquer = {}
 		for key in recipients:
 			uniquer[key] = True
@@ -232,6 +233,7 @@ class PyMailIMAPService(unohelper.Base, 
 		self.supportedtypes = ('Insecure', 'Ssl')
 		self.server = None
 		self.connectioncontext = None
+		self.notify = EventObject(self)
 		if dbg:
 			print >> sys.stderr, "PyMailIMAPService init"
 	def addConnectionListener(self, xListener):
@@ -261,12 +263,12 @@ class PyMailIMAPService(unohelper.Base, 
 		if dbg:
 			print >> sys.stderr, connectiontype
 		print >> sys.stderr, "BEFORE"
-		if connectiontype == 'Ssl':
+		if connectiontype.upper() == 'SSL':
 			self.server = imaplib.IMAP4_SSL(server, port)
 		else:
 			self.server = imaplib.IMAP4(server, port)
 		print >> sys.stderr, "AFTER"
-			
+
 		user = xAuthenticator.getUserName().encode('ascii')
 		password = xAuthenticator.getPassword().encode('ascii')
 		if user != '':
@@ -300,6 +302,7 @@ class PyMailPOP3Service(unohelper.Base, 
 		self.supportedtypes = ('Insecure', 'Ssl')
 		self.server = None
 		self.connectioncontext = None
+		self.notify = EventObject(self)
 		if dbg:
 			print >> sys.stderr, "PyMailPOP3Service init"
 	def addConnectionListener(self, xListener):
@@ -329,18 +332,18 @@ class PyMailPOP3Service(unohelper.Base, 
 		if dbg:
 			print >> sys.stderr, connectiontype
 		print >> sys.stderr, "BEFORE"
-		if connectiontype == 'Ssl':
+		if connectiontype.upper() == 'SSL':
 			self.server = poplib.POP3_SSL(server, port)
 		else:
 			self.server = poplib.POP3(server, port)
 		print >> sys.stderr, "AFTER"
-			
+
 		user = xAuthenticator.getUserName().encode('ascii')
 		password = xAuthenticator.getPassword().encode('ascii')
 		if dbg:
 			print >> sys.stderr, 'Logging in, username of', user
 		self.server.user(user)
-		self.server.pass_(user, password)
+		self.server.pass_(password)
 
 		for listener in self.listeners:
 			listener.connected(self.notify)
@@ -384,12 +387,12 @@ class PyMailMessage(unohelper.Base, XMai
 			print >> sys.stderr, "PyMailMessage init"
 		self.ctx = ctx
 
-		self.recipients = sTo,
-		self.ccrecipients = ()
-		self.bccrecipients = ()
-		self.aMailAttachments = ()
+		self.recipients = [sTo]
+		self.ccrecipients = []
+		self.bccrecipients = []
+		self.aMailAttachments = []
 		if aMailAttachment != None:
-			self.aMailAttachments = aMailAttachment, 
+			self.aMailAttachments.append(aMailAttachment)
 
 		self.SenderName, self.SenderAddress = parseaddr(sFrom)
 		self.ReplyToAddress = sFrom
@@ -400,35 +403,36 @@ class PyMailMessage(unohelper.Base, XMai
 	def addRecipient( self, recipient ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.addRecipient", recipient
-		self.recipients = self.recipients, recipient
+		self.recipients.append(recipient)
 	def addCcRecipient( self, ccrecipient ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient
-		self.ccrecipients = self.ccrecipients, ccrecipient
+		self.ccrecipients.append(ccrecipient)
 	def addBccRecipient( self, bccrecipient ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient
-		self.bccrecipients = self.bccrecipients, bccrecipient
+		self.bccrecipients.append(bccrecipient)
 	def getRecipients( self ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients
-		return self.recipients
+		return tuple(self.recipients)
 	def getCcRecipients( self ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients
-		return self.ccrecipients
+		return tuple(self.ccrecipients)
 	def getBccRecipients( self ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients
-		return self.bccrecipients
+		return tuple(self.bccrecipients)
 	def addAttachment( self, aMailAttachment ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.addAttachment"
-		self.aMailAttachments = self.aMailAttachments, aMailAttachment
+		self.aMailAttachments.append(aMailAttachment)
 	def getAttachments( self ):
 		if dbg:
 			print >> sys.stderr, "PyMailMessage.getAttachments"
-		return self.aMailAttachments
+		return tuple(self.aMailAttachments)
+
 
 # pythonloader looks for a static g_ImplementationHelper variable
 g_ImplementationHelper = unohelper.ImplementationHelper()



Mime
View raw message