Return-Path: X-Original-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-ooo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A12F7BB59 for ; Mon, 16 Jan 2012 19:51:13 +0000 (UTC) Received: (qmail 67119 invoked by uid 500); 16 Jan 2012 19:51:13 -0000 Delivered-To: apmail-incubator-ooo-commits-archive@incubator.apache.org Received: (qmail 67028 invoked by uid 500); 16 Jan 2012 19:51:13 -0000 Mailing-List: contact ooo-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ooo-dev@incubator.apache.org Delivered-To: mailing list ooo-commits@incubator.apache.org Received: (qmail 67021 invoked by uid 99); 16 Jan 2012 19:51:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jan 2012 19:51:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jan 2012 19:51:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 21D352388993; Mon, 16 Jan 2012 19:50:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1232130 - /incubator/ooo/trunk/main/scripting/source/pyprov/mailmerge.py Date: Mon, 16 Jan 2012 19:50:51 -0000 To: ooo-commits@incubator.apache.org From: arielch@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120116195051.21D352388993@eris.apache.org> 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()