rpms/openoffice.org/devel openoffice.org-1.9.114.ooo51638.mailmerge.patch, NONE, 1.1

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Wed Jul 6 12:07:22 UTC 2005


Author: caolanm

Update of /cvs/dist/rpms/openoffice.org/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv9412

Added Files:
	openoffice.org-1.9.114.ooo51638.mailmerge.patch 
Log Message:
add openoffice.org-1.9.114.ooo51638.mailmerge.patch

openoffice.org-1.9.114.ooo51638.mailmerge.patch:
 openoffice.org/scp2/source/python/module_python_mailmerge.scp |   71 ++
 openoffice.org/scripting/source/pyprov/mailmerge.py           |  343 ++++++++++
 scp2/source/python/file_python.scp                            |   14 
 scp2/source/python/makefile.mk                                |    1 
 scp2/source/python/module_python.ulf                          |    5 
 scp2/util/makefile.mk                                         |    2 
 scripting/source/pyprov/makefile.mk                           |    3 
 source/pyprov/makefile.mk                                     |    0 
 source/python/file_python.scp                                 |    0 
 source/python/makefile.mk                                     |    0 
 source/python/module_python.ulf                               |    0 
 util/makefile.mk                                              |    0 
 12 files changed, 436 insertions(+), 3 deletions(-)

--- NEW FILE openoffice.org-1.9.114.ooo51638.mailmerge.patch ---
Index: source/pyprov/makefile.mk
===================================================================
RCS file: /cvs/framework/scripting/source/pyprov/makefile.mk,v
retrieving revision 1.5
diff -u -p -r1.5 makefile.mk
--- openoffice.org.orig/scripting/source/pyprov/makefile.mk	11 Feb 2005 16:35:48 -0000	1.5
+++ openoffice.org/scripting/source/pyprov/makefile.mk	6 Jul 2005 09:56:59 -0000
@@ -76,7 +76,8 @@ TARGET=pyprov
 
 # --- Targets ------------------------------------------------------
 ALL : ALLTAR \
-        $(DLLDEST)$/pythonscript.py
+        $(DLLDEST)$/pythonscript.py \
+        $(DLLDEST)$/mailmerge.py
 
 $(DLLDEST)$/%.py: %.py
     +cp $? $@
--- /dev/null	2005-07-06 07:58:19.524521250 +0100
+++ openoffice.org/scripting/source/pyprov/mailmerge.py	2005-07-06 12:36:24.000000000 +0100
@@ -0,0 +1,343 @@
+#!/bin/python
+
+# Caolan McNamara caolanm at redhat.com
+# a simple email mailmerge component
+
+# manual installation for hackers, not necessary for users
+# cp mailmerge.py /usr/lib/openoffice.org2.0/program
+# cd /usr/lib/openoffice.org2.0/program
+# ./unopkg add --shared mailmerge.py
+# edit ~/.openoffice.org2/user/registry/data/org/openoffice/Office/Writer.xcu
+# and change EMailSupported to as follows...
+#  <prop oor:name="EMailSupported" oor:type="xs:boolean">
+#   <value>true</value>
+#  </prop>
+
+import unohelper
+import uno
+
+#to implement com::sun::star::mail::XMailServiceProvider
+
+from com.sun.star.mail import XMailServiceProvider
+from com.sun.star.mail import XMailService
+from com.sun.star.mail import XSmtpService
+from com.sun.star.mail import XConnectionListener
+from com.sun.star.mail import XAuthenticator
+from com.sun.star.mail import XMailMessage
+from com.sun.star.mail.MailServiceType import SMTP
+from com.sun.star.mail.MailServiceType import POP3
+from com.sun.star.mail.MailServiceType import IMAP
+from com.sun.star.uno import XCurrentContext
+from com.sun.star.lang import IllegalArgumentException
+from com.sun.star.lang import EventObject
+from com.sun.star.mail import SendMailMessageFailedException
+
+from email.MIMEBase import MIMEBase
+from email.Message import Message
+from email import Encoders
+from email.MIMEMultipart import MIMEMultipart
+
+import sys, smtplib, imaplib, poplib
+
+dbg = False
+
+class PyMailSMTPService(unohelper.Base, XSmtpService):
+	def __init__( self, ctx ):
+		self.ctx = ctx
+		self.listeners = []
+		self.supportedtypes = ('Insecure', 'Ssl')
+		self.server = None
+		self.connectioncontext = None
+		self.notify = EventObject()
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService init"
+	def addConnectionListener(self, xListener):
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService addConnectionListener"
+		self.listeners.append(xListener)
+	def removeConnectionListener(self, xListener):
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService removeConnectionListener"
+		self.listeners.remove(xListener)
+	def getSupportedConnectionTypes(self):
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService getSupportedConnectionTypes"
+		return self.supportedtypes
+	def connect(self, xConnectionContext, xAuthenticator):
+		self.connectioncontext = xConnectionContext
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService connect"
+		server = xConnectionContext.getValueByName("ServerName")
+		if dbg:
+			print >> sys.stderr, server
+		port = xConnectionContext.getValueByName("Port")
+		if dbg:
+			print >> sys.stderr, port
+		self.server = smtplib.SMTP(server, port)
+		if dbg:
+			self.server.set_debuglevel(1)
+		connectiontype = xConnectionContext.getValueByName("ConnectionType")
+		if dbg:
+			print >> sys.stderr, connectiontype
+		if connectiontype == 'Ssl':
+			self.server.starttls()
+
+		user = xAuthenticator.getUserName()
+		password = xAuthenticator.getPassword()
+		if user != '':
+			if dbg:
+				print >> sys.stderr, 'Logging in, username of', user
+			self.server.login(user, password)
+
+		for listener in self.listeners:
+			listener.connected(self.notify)
+	def disconnect(self):
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService disconnect"
+		if self.server:
+			self.server.quit()
+			self.server = None
+		for listener in self.listeners:
+			listener.disconnected(self.notify)
+	def isConnected(self):
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService isConnected"
+		return self.server != None
+	def getCurrentConnectionContext(self):
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService getCurrentConnectionContext"
+		return self.connectioncontext
+	def sendMailMessage(self, xMailMessage):
+		COMMASPACE = ', '
+
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService sendMailMessage"
+		recipients = xMailMessage.getRecipients()
+		sender = xMailMessage.SenderAddress
+		subject = xMailMessage.Subject
+		ccrecipients = xMailMessage.getCcRecipients()
+		bccrecipients = xMailMessage.getBccRecipients()
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService subject", subject
+			print >> sys.stderr, "PyMailSMPTService from", sender
+			print >> sys.stderr, "PyMailSMPTService send to", recipients
+
+		attachments = xMailMessage.getAttachments()
+
+		content = xMailMessage.Body
+		flavors = content.getTransferDataFlavors()
+		flavor = flavors[0]
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType
+		textbody = content.getTransferData(flavor)
+
+		textmsg = Message()
+		textmsg['Content-Type'] = flavor.MimeType
+	        textmsg['MIME-Version'] = '1.0'
+		textmsg.set_payload(textbody)
+
+		if (len(attachments)):
+			msg = MIMEMultipart()
+			msg.epilogue = ''
+			msg.attach(textmsg)
+		else:
+			msg = textmsg
+
+		msg['Subject'] = subject
+		msg['From'] = sender
+		msg['To'] = COMMASPACE.join(recipients)
+		if len(ccrecipients):
+			msg['Cc'] = COMMASPACE.join(ccrecipients)
+		if xMailMessage.ReplyToAddress != '':
+			msg['Reply-To'] = xMailMessage.ReplyToAddress
+		msg['X-Mailer'] = "OpenOffice.org 2.0 via Caolan's mailmerge component"
+
+		for attachment in attachments:
+			content = attachment.Data
+			flavors = content.getTransferDataFlavors()
+			flavor = flavors[0]
+			ctype = flavor.MimeType
+			maintype, subtype = ctype.split('/', 1)
+			msgattachment = MIMEBase(maintype, subtype)
+			data = content.getTransferData(flavor)
+			msgattachment.set_payload(data)
+			Encoders.encode_base64(msgattachment)
+			msgattachment.add_header('Content-Disposition', 'attachment', \
+				filename=attachment.ReadableName)
+			msg.attach(msgattachment)
+
+		uniquer = {}
+		for key in recipients:
+			uniquer[key] = True
+		if len(ccrecipients):
+			for key in ccrecipients:
+				uniquer[key] = True
+		if len(bccrecipients):
+			for key in bccrecipients:
+				uniquer[key] = True
+		truerecipients = uniquer.keys()
+
+		if dbg:
+			print >> sys.stderr, "PyMailSMPTService recipients are", truerecipients
+
+		self.server.sendmail(sender, recipients, msg.as_string())
+
+class PyMailIMAPService(unohelper.Base, XMailService):
+	def __init__( self, ctx ):
+		self.ctx = ctx
+		self.listeners = []
+		self.supportedtypes = ('Insecure', 'Ssl')
+		self.server = None
+		self.connectioncontext = None
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService init"
+	def addConnectionListener(self, xListener):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService addConnectionListener"
+		self.listeners.append(xListener)
+	def removeConnectionListener(self, xListener):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService removeConnectionListener"
+		self.listeners.remove(xListener)
+	def getSupportedConnectionTypes(self):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService getSupportedConnectionTypes"
+		return self.supportedtypes
+	def connect(self, xConnectionContext, xAuthenticator):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService connect"
+
+		self.connectioncontext = xConnectionContext
+		server = xConnectionContext.getValueByName("ServerName")
+		if dbg:
+			print >> sys.stderr, server
+		port = xConnectionContext.getValueByName("Port")
+		if dbg:
+			print >> sys.stderr, port
+		connectiontype = xConnectionContext.getValueByName("ConnectionType")
+		if dbg:
+			print >> sys.stderr, connectiontype
+		print >> sys.stderr, "BEFORE"
+		if connectiontype == 'Ssl':
+			self.server = imaplib.IMAP4_SSL(server, port)
+		else:
+			self.server = imaplib.IMAP4(server, port)
+		print >> sys.stderr, "AFTER"
+			
+		user = xAuthenticator.getUserName()
+		password = xAuthenticator.getPassword()
+		if user != '':
+			if dbg:
+				print >> sys.stderr, 'Logging in, username of', user
+			self.server.login(user, password)
+
+		for listener in self.listeners:
+			listener.connected(self.notify)
+	def disconnect(self):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService disconnect"
+		if self.server:
+			self.server.logout()
+			self.server = None
+		for listener in self.listeners:
+			listener.disconnected(self.notify)
+	def isConnected(self):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService isConnected"
+		return self.server != None
+	def getCurrentConnectionContext(self):
+		if dbg:
+			print >> sys.stderr, "PyMailIMAPService getCurrentConnectionContext"
+		return self.connectioncontext
+
+class PyMailPOP3Service(unohelper.Base, XMailService):
+	def __init__( self, ctx ):
+		self.ctx = ctx
+		self.listeners = []
+		self.supportedtypes = ('Insecure', 'Ssl')
+		self.server = None
+		self.connectioncontext = None
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service init"
+	def addConnectionListener(self, xListener):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service addConnectionListener"
+		self.listeners.append(xListener)
+	def removeConnectionListener(self, xListener):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service removeConnectionListener"
+		self.listeners.remove(xListener)
+	def getSupportedConnectionTypes(self):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service getSupportedConnectionTypes"
+		return self.supportedtypes
+	def connect(self, xConnectionContext, xAuthenticator):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service connect"
+
+		self.connectioncontext = xConnectionContext
+		server = xConnectionContext.getValueByName("ServerName")
+		if dbg:
+			print >> sys.stderr, server
+		port = xConnectionContext.getValueByName("Port")
+		if dbg:
+			print >> sys.stderr, port
+		connectiontype = xConnectionContext.getValueByName("ConnectionType")
+		if dbg:
+			print >> sys.stderr, connectiontype
+		print >> sys.stderr, "BEFORE"
+		if connectiontype == 'Ssl':
+			self.server = poplib.POP3_SSL(server, port)
+		else:
+			self.server = poplib.POP3(server, port)
+		print >> sys.stderr, "AFTER"
+			
+		user = xAuthenticator.getUserName()
+		password = xAuthenticator.getPassword()
+		if dbg:
+			print >> sys.stderr, 'Logging in, username of', user
+		self.server.user(user)
+		self.server.pass_(user, password)
+
+		for listener in self.listeners:
+			listener.connected(self.notify)
+	def disconnect(self):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service disconnect"
+		if self.server:
+			self.server.quit()
+			self.server = None
+		for listener in self.listeners:
+			listener.disconnected(self.notify)
+	def isConnected(self):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service isConnected"
+		return self.server != None
+	def getCurrentConnectionContext(self):
+		if dbg:
+			print >> sys.stderr, "PyMailPOP3Service getCurrentConnectionContext"
+		return self.connectioncontext
+
+class PyMailServiceProvider(unohelper.Base, XMailServiceProvider):
+	def __init__( self, ctx ):
+		if dbg:
+			print >> sys.stderr, "PyMailServiceProvider init"
+		self.ctx = ctx
+	def create(self, aType):
+		if dbg:
+			print >> sys.stderr, "PyMailServiceProvider create with", aType
+		if aType == SMTP:
+			return PyMailSMTPService(self.ctx);
+		elif aType == POP3:
+			return PyMailPOP3Service(self.ctx);
+		elif aType == IMAP:
+			return PyMailIMAPService(self.ctx);
+		else:
+			print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType
+
+# pythonloader looks for a static g_ImplementationHelper variable
+g_ImplementationHelper = unohelper.ImplementationHelper()
+g_ImplementationHelper.addImplementation( \
+	PyMailServiceProvider, "org.openoffice.pyuno.MailServiceProvider",
+		("com.sun.star.mail.MailServiceProvider",),)
+
Index: source/python/file_python.scp
===================================================================
RCS file: /cvs/installation/scp2/source/python/file_python.scp,v
retrieving revision 1.10
diff -u -p -r1.10 file_python.scp
--- openoffice.org.orig/scp2/source/python/file_python.scp	20 Apr 2005 12:02:13 -0000	1.10
+++ openoffice.org/scp2/source/python/file_python.scp	6 Jul 2005 11:15:06 -0000
@@ -114,6 +114,20 @@ File gid_File_Py_Python_Core
 End
 #endif
 
+File gid_File_Pymailmerge
+    TXT_FILE_BODY;
+    Dir = gid_Dir_Program;
+    Name = "mailmerge.py";
+    RegistryID = gid_Starregistry_Services_Rdb;
+    Styles = (PACKED,UNO_COMPONENT);
+End
+
+File gid_File_Registry_Spool_Oo_Office_Writer_PyMailMerge_Xcu
+    TXT_FILE_BODY;
+    Dir = gid_Dir_Share_Registry_Modules_Oo_Office_Writer;
+    Name = "/registry/spool/org/openoffice/Office/Writer-javamail.xcu";
+    Styles = (PACKED,SCPZIP_REPLACE);
+End
 
 // substitute for the python Windows basic scripts
 
Index: source/python/makefile.mk
===================================================================
RCS file: /cvs/installation/scp2/source/python/makefile.mk,v
retrieving revision 1.9
diff -u -p -r1.9 makefile.mk
--- openoffice.org.orig/scp2/source/python/makefile.mk	11 Feb 2005 15:55:37 -0000	1.9
+++ openoffice.org/scp2/source/python/makefile.mk	6 Jul 2005 11:15:07 -0000
@@ -86,6 +86,7 @@ SCP_PRODUCT_TYPE=osl
 
 PARFILES=\
         module_python.par              \
+	module_python_mailmerge.par    \
         profileitem_python.par         \
         file_python.par
 
Index: source/python/module_python.ulf
===================================================================
RCS file: /cvs/installation/scp2/source/python/module_python.ulf,v
retrieving revision 1.3
diff -u -p -r1.3 module_python.ulf
--- openoffice.org.orig/scp2/source/python/module_python.ulf	12 Aug 2004 08:16:30 -0000	1.3
+++ openoffice.org/scp2/source/python/module_python.ulf	6 Jul 2005 11:15:07 -0000
@@ -67,5 +67,6 @@ de = "Python-UNO Sprachanbindung"
 en-US = "Adds the ability to automate %PRODUCTNAME with the python scripting language. See http://udk.openoffice.org/python/python-bridge.html for a complete documentation."
 de = "Ermöglicht es, %PRODUCTNAME mit der Skriptsprache Python zu automatisieren. Die komplette Dokumentation finden Sie auf http://udk.openoffice.org/python/python-bridge.html."
 
-
-
+[STR_NAME_MODULE_OPTIONAL_PYTHON_MAILMERGE]
+en-US = "Python Email Mailmerge"
+de = "Python Email Mailmerge"
Index: util/makefile.mk
===================================================================
RCS file: /cvs/installation/scp2/util/makefile.mk,v
retrieving revision 1.22
diff -u -p -r1.22 makefile.mk
--- openoffice.org.orig/scp2/util/makefile.mk	21 Jun 2005 13:25:19 -0000	1.22
+++ openoffice.org/scp2/util/makefile.mk	6 Jul 2005 11:15:08 -0000
@@ -109,6 +109,7 @@ SCP1FILES  = installation_ooo.par       
              module_xsltfilter.par         \
              file_xsltfilter.par           \
              module_python.par             \
+             module_python_mailmerge.par   \
              file_python.par               \
              profileitem_python.par
 
@@ -214,6 +215,7 @@ SCP2FILES  = installation_ooo.par       
              module_xsltfilter.par         \
              file_xsltfilter.par           \
              module_python.par             \
+             module_python_mailmerge.par   \
              file_python.par               \
              profileitem_python.par
 
--- /dev/null	2005-07-06 07:58:19.524521250 +0100
+++ openoffice.org/scp2/source/python/module_python_mailmerge.scp	2005-07-06 12:08:22.000000000 +0100
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ *  $RCSfile$
+ *
+ *  $Revision$
+ *
+ *  last change: $Author$ $Date$
+ *
+ *  The Contents of this file are made available subject to the terms of
+ *  either of the following licenses
+ *
+ *         - GNU Lesser General Public License Version 2.1
+ *         - Sun Industry Standards Source License Version 1.1
+ *
+ *  Sun Microsystems Inc., October, 2000
+ *
+ *  GNU Lesser General Public License Version 2.1
+ *  =============================================
+ *  Copyright 2000 by Sun Microsystems, Inc.
+ *  901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License version 2.1, as published by the Free Software Foundation.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ *  MA  02111-1307  USA
+ *
+ *
+ *  Sun Industry Standards Source License Version 1.1
+ *  =================================================
+ *  The contents of this file are subject to the Sun Industry Standards
+ *  Source License Version 1.1 (the "License"); You may not use this file
+ *  except in compliance with the License. You may obtain a copy of the
+ *  License at http://www.openoffice.org/license.html.
+ *
+ *  Software provided under this License is provided on an "AS IS" basis,
+ *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ *  See the License for the specific provisions governing your rights and
+ *  obligations concerning the Software.
+ *
+ *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ *  Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ *  All Rights Reserved.
+ *
+ *  Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "macros.inc"
+
+Module gid_Module_Optional_Pymailmerge
+    MOD_NAME_DESC ( MODULE_OPTIONAL_PYTHON_MAILMERGE );
+    ParentID = gid_Module_Optional_Pyuno;
+    Files = (gid_File_Pymailmerge, gid_File_Registry_Spool_Oo_Office_Writer_PyMailMerge_Xcu);
+    Minimal = NO;
+    Default = YES;
+    Styles = ( );
+End




More information about the fedora-cvs-commits mailing list