Kaydet (Commit) 4166969f authored tarafından Ariel Constenla-Haile's avatar Ariel Constenla-Haile

i118736 - i118787 : fix XMailMessage implementation in mailmerge.py

üst 91a17ad2
......@@ -52,7 +52,7 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
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, XSmtpService):
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, XSmtpService):
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, XSmtpService):
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, XSmtpService):
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, XMailService):
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, XMailService):
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, XMailService):
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, XMailService):
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, XMailMessage):
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, XMailMessage):
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment