summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorobo <obo@openoffice.org>2010-06-22 15:46:16 +0200
committerobo <obo@openoffice.org>2010-06-22 15:46:16 +0200
commitefb69220b96a518cccaed6f5961227252820d95f (patch)
tree4ee61a1d0a8172b02f4664c676560ce7a3be6f8f
parente8d1ae1363e850f8fd20eef17beb4f2c89aab889 (diff)
parent31cd92a128569ecddba39a3a14587c2edd19c30c (diff)
CWS-TOOLING: integrate CWS cmcfixes75
-rw-r--r--framework/inc/threadhelp/transactionmanager.hxx1
-rw-r--r--framework/source/threadhelp/transactionmanager.cxx36
-rw-r--r--scripting/source/pyprov/mailmerge.py120
-rw-r--r--shell/source/unix/misc/gnome-open-url.sh4
-rwxr-xr-xshell/source/unix/misc/open-url.sh54
-rw-r--r--shell/source/unix/sysshell/recently_used_file.cxx3
6 files changed, 140 insertions, 78 deletions
diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx
index 536cb86234..e8cf8f9bd9 100644
--- a/framework/inc/threadhelp/transactionmanager.hxx
+++ b/framework/inc/threadhelp/transactionmanager.hxx
@@ -93,7 +93,6 @@ class TransactionManager : public ITransactionManager
virtual sal_Bool isCallRejected ( ERejectReason& eReason ) const;
virtual void registerTransaction ( EExceptionMode eMode, ERejectReason& eReason ) throw( css::uno::RuntimeException, css::lang::DisposedException );
virtual void unregisterTransaction ( ) throw( css::uno::RuntimeException, css::lang::DisposedException );
- static TransactionManager& getGlobalTransactionManager ( );
//-------------------------------------------------------------------------------------------------------------
// private methods
diff --git a/framework/source/threadhelp/transactionmanager.cxx b/framework/source/threadhelp/transactionmanager.cxx
index d1bb759dfc..0c09f309a6 100644
--- a/framework/source/threadhelp/transactionmanager.cxx
+++ b/framework/source/threadhelp/transactionmanager.cxx
@@ -319,42 +319,6 @@ sal_Bool TransactionManager::isCallRejected( ERejectReason& eReason ) const
}
/*-****************************************************************************************************//**
- @short return a reference to a static manager
- @descr Sometimes we need the global member! (e.g. in our own static methods)
- We create our own "class global static" member threadsafe.
- It will be created at first call only!
- All other requests use these created one then directly.
-
- @seealso -
-
- @param -
- @return A reference to a static member.
-
- @onerror No error should occure.
-*//*-*****************************************************************************************************/
-TransactionManager& TransactionManager::getGlobalTransactionManager()
-{
- // Initialize static member only for one time!
- static TransactionManager* pManager = NULL;
- // If these method first called (member not already exist!) ...
- if( pManager == NULL )
- {
- // ... we must create a new one. Protect follow code with the global mutex -
- // It must be - we create a static variable!
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- // We must check our pointer again - because ... another instance of ouer class could be faster then these one!
- if( pManager == NULL )
- {
- // Create the new manager and set it for return on static variable.
- static TransactionManager aManager;
- pManager = &aManager;
- }
- }
- // Return new created or already existing object.
- return *pManager;
-}
-
-/*-****************************************************************************************************//**
@short throw any exceptions for rejected calls
@descr If user whish to use our automaticly exception mode we use this impl-method.
We check all combinations of eReason and eExceptionMode and throw right exception with some
diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py
index f9c2f0f70b..55c204f87d 100644
--- a/scripting/source/pyprov/mailmerge.py
+++ b/scripting/source/pyprov/mailmerge.py
@@ -16,6 +16,8 @@ import uno
import re
#to implement com::sun::star::mail::XMailServiceProvider
+#and
+#to implement com.sun.star.mail.XMailMessage
from com.sun.star.mail import XMailServiceProvider
from com.sun.star.mail import XMailService
@@ -37,7 +39,7 @@ from email import Encoders
from email.Header import Header
from email.MIMEMultipart import MIMEMultipart
from email.Utils import formatdate
-from email.Utils import formataddr
+from email.Utils import parseaddr
import sys, smtplib, imaplib, poplib
@@ -118,30 +120,46 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
print >> sys.stderr, "PyMailSMPTService sendMailMessage"
recipients = xMailMessage.getRecipients()
sendermail = xMailMessage.SenderAddress
- sendername = xMailMessage.SenderName
+ sendername = xMailMessage.SenderName
subject = xMailMessage.Subject
ccrecipients = xMailMessage.getCcRecipients()
bccrecipients = xMailMessage.getBccRecipients()
if dbg:
print >> sys.stderr, "PyMailSMPTService subject", subject
- print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8'), sendermail
- print >> sys.stderr, "PyMailSMTPService from", formataddr((sendername.encode('utf-8'), sendermail))
+ print >> sys.stderr, "PyMailSMPTService from", sendername.encode('utf-8')
+ print >> sys.stderr, "PyMailSMTPService from", sendermail
print >> sys.stderr, "PyMailSMPTService send to", recipients
attachments = xMailMessage.getAttachments()
+ textmsg = Message()
+
content = xMailMessage.Body
flavors = content.getTransferDataFlavors()
- flavor = flavors[0]
if dbg:
- print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType
- textbody = content.getTransferData(flavor)
+ print >> sys.stderr, "PyMailSMPTService flavors len", len(flavors)
- textmsg = Message()
- mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType)
- textmsg['Content-Type'] = mimeEncoding
- textmsg['MIME-Version'] = '1.0'
- textmsg.set_payload(textbody.encode('utf-8'))
+ #Use first flavor that's sane for an email body
+ for flavor in flavors:
+ if flavor.MimeType.find('text/html') != -1 or flavor.MimeType.find('text/plain') != -1:
+ if dbg:
+ print >> sys.stderr, "PyMailSMPTService mimetype is", flavor.MimeType
+ textbody = content.getTransferData(flavor)
+ try:
+ textbody = textbody.value
+ except:
+ pass
+ textbody = textbody.encode('utf-8')
+
+ if len(textbody):
+ mimeEncoding = re.sub("charset=.*", "charset=UTF-8", flavor.MimeType)
+ if mimeEncoding.find('charset=UTF-8') == -1:
+ mimeEncoding = mimeEncoding + "; charset=UTF-8"
+ textmsg['Content-Type'] = mimeEncoding
+ textmsg['MIME-Version'] = '1.0'
+ textmsg.set_payload(textbody)
+
+ break
if (len(attachments)):
msg = MIMEMultipart()
@@ -150,15 +168,31 @@ class PyMailSMTPService(unohelper.Base, XSmtpService):
else:
msg = textmsg
- msg['Subject'] = subject
- msg['From'] = formataddr((sendername.encode('utf-8'), sendermail))
+ hdr = Header(sendername, 'utf-8')
+ hdr.append('<'+sendermail+'>','us-ascii')
+ msg['Subject'] = subject
+ msg['From'] = hdr
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"
+ mailerstring = "OpenOffice.org 2.0 via Caolan's mailmerge component"
+ try:
+ ctx = uno.getComponentContext()
+ aConfigProvider = ctx.ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider")
+ prop = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
+ prop.Name = "nodepath"
+ prop.Value = "/org.openoffice.Setup/Product"
+ aSettings = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",
+ (prop,))
+ mailerstring = aSettings.getByName("ooName") + " " + \
+ aSettings.getByName("ooSetupVersion") + " via Caolan's mailmerge component"
+ except:
+ pass
+
+ msg['X-Mailer'] = mailerstring
msg['Date'] = formatdate(localtime=True)
for attachment in attachments:
@@ -344,9 +378,63 @@ class PyMailServiceProvider(unohelper.Base, XMailServiceProvider):
else:
print >> sys.stderr, "PyMailServiceProvider, unknown TYPE", aType
+class PyMailMessage(unohelper.Base, XMailMessage):
+ def __init__( self, ctx, sTo='', sFrom='', Subject='', Body=None, aMailAttachment=None ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage init"
+ self.ctx = ctx
+
+ self.recipients = sTo,
+ self.ccrecipients = ()
+ self.bccrecipients = ()
+ self.aMailAttachments = ()
+ if aMailAttachment != None:
+ self.aMailAttachments = aMailAttachment,
+
+ self.SenderName, self.SenderAddress = parseaddr(sFrom)
+ self.ReplyToAddress = sFrom
+ self.Subject = Subject
+ self.Body = Body
+ if dbg:
+ print >> sys.stderr, "post PyMailMessage init"
+ def addRecipient( self, recipient ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.addRecipient", recipient
+ self.recipients = self.recipients, recipient
+ def addCcRecipient( self, ccrecipient ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.addCcRecipient", ccrecipient
+ self.ccrecipients = self.ccrecipients, ccrecipient
+ def addBccRecipient( self, bccrecipient ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.addBccRecipient", bccrecipient
+ self.bccrecipients = self.bccrecipients, bccrecipient
+ def getRecipients( self ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.getRecipients", self.recipients
+ return self.recipients
+ def getCcRecipients( self ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.getCcRecipients", self.ccrecipients
+ return self.ccrecipients
+ def getBccRecipients( self ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.getBccRecipients", self.bccrecipients
+ return self.bccrecipients
+ def addAttachment( self, aMailAttachment ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.addAttachment"
+ self.aMailAttachments = self.aMailAttachments, aMailAttachment
+ def getAttachments( self ):
+ if dbg:
+ print >> sys.stderr, "PyMailMessage.getAttachments"
+ return self.aMailAttachments
+
# 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",),)
-
+g_ImplementationHelper.addImplementation( \
+ PyMailMessage, "org.openoffice.pyuno.MailMessage",
+ ("com.sun.star.mail.MailMessage",),)
diff --git a/shell/source/unix/misc/gnome-open-url.sh b/shell/source/unix/misc/gnome-open-url.sh
index 1a52fc7637..ab730d169a 100644
--- a/shell/source/unix/misc/gnome-open-url.sh
+++ b/shell/source/unix/misc/gnome-open-url.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-# use gnome-open utility coming with libgnome if available
-gnome-open "$1" 2>/dev/null || "$0.bin" $1
+# use xdg-open or gnome-open if available
+xdg-open "$1" 2>/dev/null || gnome-open "$1" 2>/dev/null || "$0.bin" $1
exit 0
diff --git a/shell/source/unix/misc/open-url.sh b/shell/source/unix/misc/open-url.sh
index be414d0e11..dd304f5f0d 100755
--- a/shell/source/unix/misc/open-url.sh
+++ b/shell/source/unix/misc/open-url.sh
@@ -46,38 +46,48 @@ run_browser() {
# special handling for mailto: uris
if echo $1 | grep '^mailto:' > /dev/null; then
+ # check for xdg-email
+ mailer=`which xdg-email`
+ if [ ! -z "$mailer" ]; then
+ $mailer "$1" &
+ exit 0
+ fi
# check $MAILER variable
if [ ! -z "$MAILER" ]; then
$MAILER "$1" &
exit 0
- else
- # mozilla derivates may need -remote semantics
- for i in thunderbird mozilla netscape; do
- mailer=`which $i`
- if [ ! -z "$mailer" ]; then
- run_mozilla "$mailer" "$1"
- exit 0
- fi
- done
- # handle all non mozilla mail clients below
- # ..
fi
+ # mozilla derivates may need -remote semantics
+ for i in thunderbird mozilla netscape; do
+ mailer=`which $i`
+ if [ ! -z "$mailer" ]; then
+ run_mozilla "$mailer" "$1"
+ exit 0
+ fi
+ done
+ # handle all non mozilla mail clients below
+ # ..
else
+ # check for xdg-open
+ browser=`which xdg-open`
+ if [ ! -z "$browser" ]; then
+ $browser "$1" &
+ exit 0
+ fi
# check $BROWSER variable
if [ ! -z "$BROWSER" ]; then
$BROWSER "$1" &
exit 0
- else
- # mozilla derivates may need -remote semantics
- for i in firefox mozilla netscape; do
- browser=`which $i`
- if [ ! -z "$browser" ]; then
- run_mozilla "$browser" "$1"
- exit 0
- fi
- done
- # handle all non mozilla browers below
- # ..
fi
+ # mozilla derivates may need -remote semantics
+ for i in firefox mozilla netscape; do
+ browser=`which $i`
+ if [ ! -z "$browser" ]; then
+ run_mozilla "$browser" "$1"
+ exit 0
+ fi
+ done
+ # handle all non mozilla browers below
+ # ..
fi
exit 1
diff --git a/shell/source/unix/sysshell/recently_used_file.cxx b/shell/source/unix/sysshell/recently_used_file.cxx
index 050ba60caa..63f92afb0e 100644
--- a/shell/source/unix/sysshell/recently_used_file.cxx
+++ b/shell/source/unix/sysshell/recently_used_file.cxx
@@ -114,7 +114,8 @@ void recently_used_file::reset() const
//------------------------------------------------
void recently_used_file::truncate(off_t length)
{
- ftruncate(fileno(file_), length);
+ if (ftruncate(fileno(file_), length) == -1)
+ throw "I/O error: ftruncate failed";
}
//------------------------------------------------