summaryrefslogtreecommitdiff
path: root/shell/source/cmdmail
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2013-01-04 18:57:08 +0000
committerAriel Constenla-Haile <arielch@apache.org>2013-01-04 18:57:08 +0000
commit938c867ce8820104a116ca46ffe683a9a69c285d (patch)
tree3c47861ac00173f92971e8cb39cd5bec489161f5 /shell/source/cmdmail
parent11c6e0d643b4646167aa1b30a32fc0c6881b1596 (diff)
i121579 - Clean-up system mail API
Notes
Notes: reject: half-baked clean-up of published mail API (e.g., consolidates Simple{Command,System}Mail but keeps needless queryMailClient indirection; consolidates XSimpleMailMessage{,2} but needlessly keeps it an interface instead of a struct); probably does more harm than good
Diffstat (limited to 'shell/source/cmdmail')
-rw-r--r--shell/source/cmdmail/cmdmail.component14
-rw-r--r--shell/source/cmdmail/cmdmail.xml74
-rw-r--r--shell/source/cmdmail/cmdmailentry.cxx97
-rw-r--r--shell/source/cmdmail/cmdmailmsg.cxx114
-rw-r--r--shell/source/cmdmail/cmdmailmsg.hxx134
-rw-r--r--shell/source/cmdmail/cmdmailsuppl.cxx337
-rw-r--r--shell/source/cmdmail/cmdmailsuppl.hxx91
-rw-r--r--shell/source/cmdmail/makefile.mk2
-rw-r--r--shell/source/cmdmail/syscmdmail.cxx355
-rw-r--r--shell/source/cmdmail/syscmdmail.hxx74
10 files changed, 553 insertions, 739 deletions
diff --git a/shell/source/cmdmail/cmdmail.component b/shell/source/cmdmail/cmdmail.component
index 81074c560e9c..518accc63f69 100644
--- a/shell/source/cmdmail/cmdmail.component
+++ b/shell/source/cmdmail/cmdmail.component
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -8,23 +8,21 @@
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
***********************************************************-->
-
-
<component loader="com.sun.star.loader.SharedLibrary"
xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.system.SimpleCommandMail">
- <service name="com.sun.star.system.SimpleCommandMail"/>
+ <implementation name="com.sun.star.comp.system.unx.SystemMailProvider">
+ <service name="com.sun.star.system.SystemMailProvider"/>
</implementation>
</component>
diff --git a/shell/source/cmdmail/cmdmail.xml b/shell/source/cmdmail/cmdmail.xml
index c0bde0eefc07..7c5d5c2a249d 100644
--- a/shell/source/cmdmail/cmdmail.xml
+++ b/shell/source/cmdmail/cmdmail.xml
@@ -23,47 +23,45 @@
<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
- <module-name> cmdmail </module-name>
+ <module-name>cmdmail</module-name>
<component-description>
- <author> Oliver Braun </author>
- <name>com.sun.star.comp.system.SimpleCommandMail</name>
- <description>
- A generic implementation of a SimpleCommandMail service.
- </description>
+ <author>Oliver Braun</author>
+ <name>com.sun.star.comp.system.unx.SystemMailProvider</name>
+ <description>A generic implementation of a SystemMailProvider service.</description>
<loader-name>com.sun.star.loader.SharedLibrary</loader-name>
- <language> c++ </language>
+ <language>c++</language>
<status value="beta"/>
- <supported-service> com.sun.star.system.SimpleCommandMail </supported-service>
+ <supported-service>com.sun.star.system.SystemMailProvider</supported-service>
<service-dependency>...</service-dependency>
- <type> com.sun.star.system.XSimpleMailClient </type>
- <type> com.sun.star.system.XSimpleMailClientSupplier </type>
- <type> com.sun.star.system.XSimpleMailMessage </type>
- <type> com.sun.star.system.SimpleMailClientFlags </type>
- <type> com.sun.star.lang.XEventListener </type>
- <type> com.sun.star.lang.XMultiServiceFactory </type>
- <type> com.sun.star.lang.XSingleServiceFactory </type>
- <type> com.sun.star.lang.XSingleComponentFactory </type>
- <type> com.sun.star.lang.XServiceInfo </type>
- <type> com.sun.star.lang.XTypeProvider </type>
- <type> com.sun.star.lang.IllegalArgumentException </type>
- <type> com.sun.star.lang.XComponent </type>
- <type> com.sun.star.uno.RuntimeException </type>
- <type> com.sun.star.uno.TypeClass </type>
- <type> com.sun.star.uno.XWeak </type>
- <type> com.sun.star.uno.XAggregation </type>
- <type> com.sun.star.uno.XComponentContext </type>
- <type> com.sun.star.registry.XRegistryKey </type>
- <type> com.sun.star.container.XNameAccess </type>
- <type> com.sun.star.container.XSet </type>
- <type> com.sun.star.beans.PropertyValue </type>
- <type> com.sun.star.beans.XPropertySet </type>
- <type> com.sun.star.uri.ExternalUriReferenceTranslator </type>
- <type> com.sun.star.uri.XExternalUriReferenceTranslator </type>
+ <type>com.sun.star.system.XMailClient</type>
+ <type>com.sun.star.system.SystemMailProvider</type>
+ <type>com.sun.star.system.XMailMessage</type>
+ <type>com.sun.star.system.MailClientFlags</type>
+ <type>com.sun.star.lang.XEventListener</type>
+ <type>com.sun.star.lang.XMultiServiceFactory</type>
+ <type>com.sun.star.lang.XSingleServiceFactory</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.lang.IllegalArgumentException</type>
+ <type>com.sun.star.lang.XComponent</type>
+ <type>com.sun.star.uno.RuntimeException</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ <type>com.sun.star.container.XNameAccess</type>
+ <type>com.sun.star.container.XSet</type>
+ <type>com.sun.star.beans.PropertyValue</type>
+ <type>com.sun.star.beans.XPropertySet</type>
+ <type>com.sun.star.uri.ExternalUriReferenceTranslator</type>
+ <type>com.sun.star.uri.XExternalUriReferenceTranslator</type>
</component-description>
- <project-build-dependency> cppuhelper </project-build-dependency>
- <project-build-dependency> cppu </project-build-dependency>
- <project-build-dependency> sal </project-build-dependency>
- <runtime-module-dependency> cppuhelper$(COM) </runtime-module-dependency>
- <runtime-module-dependency> cppu3 </runtime-module-dependency>
- <runtime-module-dependency> sal3 </runtime-module-dependency>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
</module-description>
diff --git a/shell/source/cmdmail/cmdmailentry.cxx b/shell/source/cmdmail/cmdmailentry.cxx
index 3e022ad9699d..ebbd424ee715 100644
--- a/shell/source/cmdmail/cmdmailentry.cxx
+++ b/shell/source/cmdmail/cmdmailentry.cxx
@@ -19,89 +19,44 @@
*
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_shell.hxx"
-//-----------------------------------------------------------------------
-// includes of other projects
-//-----------------------------------------------------------------------
-#include <cppuhelper/factory.hxx>
-#include <com/sun/star/container/XSet.hpp>
-#include <osl/diagnose.h>
-#include "cmdmailsuppl.hxx"
-
-//-----------------------------------------------------------------------
-// namespace directives
-//-----------------------------------------------------------------------
-
-using namespace ::rtl ;
-using namespace ::com::sun::star::uno ;
-using namespace ::com::sun::star::container ;
-using namespace ::com::sun::star::lang ;
-using namespace ::com::sun::star::registry ;
-using namespace ::cppu ;
-using com::sun::star::system::XSimpleMailClientSupplier;
-
-//-----------------------------------------------------------------------
-// defines
-//-----------------------------------------------------------------------
+#include "syscmdmail.hxx"
-#define COMP_SERVICE_NAME "com.sun.star.system.SimpleCommandMail"
-#define COMP_IMPL_NAME "com.sun.star.comp.system.SimpleCommandMail"
-
-//-----------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
-namespace
+namespace shell
{
- Reference< XInterface > SAL_CALL createInstance( const Reference< XComponentContext >& xContext )
+ static ::cppu::ImplementationEntry const unxsysmail_impl_entries[] =
{
- return Reference< XInterface >( static_cast< XSimpleMailClientSupplier* >( new CmdMailSuppl( xContext ) ) );
- }
+ {
+ SystemCommandMail::Create,
+ SystemCommandMail::getImplementationName_static,
+ SystemCommandMail::getSupportedServiceNames_static,
+ ::cppu::createSingleComponentFactory,
+ 0,
+ 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+ };
}
-//-----------------------------------------------------------------------
-// the 3 important functions which will be exported
-//-----------------------------------------------------------------------
-
extern "C"
{
-
-//----------------------------------------------------------------------
-// component_getImplementationEnvironment
-//----------------------------------------------------------------------
-
-void SAL_CALL component_getImplementationEnvironment(
- const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
-{
- *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
-}
-
-//----------------------------------------------------------------------
-// component_getFactory
-//----------------------------------------------------------------------
-
-void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
-{
- Reference< XSingleComponentFactory > xFactory;
-
- if (0 == ::rtl_str_compare( pImplName, COMP_IMPL_NAME ))
+ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName, uno_Environment ** )
{
- OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(COMP_SERVICE_NAME) );
-
- xFactory = ::cppu::createSingleComponentFactory(
- createInstance,
- OUString( RTL_CONSTASCII_USTRINGPARAM(COMP_IMPL_NAME) ),
- Sequence< OUString >( &serviceName, 1 ) );
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
- if (xFactory.is())
- xFactory->acquire();
-
- return xFactory.get();
+ SAL_DLLPUBLIC_EXPORT void *SAL_CALL component_getFactory(
+ const sal_Char *pImplName, void *pServiceManager, void *pRegistryKey )
+ {
+ return ::cppu::component_getFactoryHelper( pImplName,
+ pServiceManager,
+ pRegistryKey ,
+ shell::unxsysmail_impl_entries );
+ }
}
-
-} // extern "C"
diff --git a/shell/source/cmdmail/cmdmailmsg.cxx b/shell/source/cmdmail/cmdmailmsg.cxx
index f32271c9b1fb..e80327614cfd 100644
--- a/shell/source/cmdmail/cmdmailmsg.cxx
+++ b/shell/source/cmdmail/cmdmailmsg.cxx
@@ -19,23 +19,24 @@
*
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_shell.hxx"
#include "cmdmailmsg.hxx"
using com::sun::star::lang::IllegalArgumentException;
-using com::sun::star::lang::WrappedTargetException;
-using com::sun::star::container::NoSuchElementException;
-using com::sun::star::container::XNameAccess;
using rtl::OUString;
using osl::MutexGuard;
using namespace cppu;
using namespace com::sun::star::uno;
+namespace shell
+{
+
+CmdMailMsg::CmdMailMsg()
+{
+}
void SAL_CALL CmdMailMsg::setBody( const OUString& aBody )
throw (RuntimeException)
@@ -135,107 +136,4 @@ Sequence< OUString > SAL_CALL CmdMailMsg::getAttachement( )
return m_Attachments;
}
-Any SAL_CALL CmdMailMsg::getByName( const OUString& aName )
- throw (NoSuchElementException, WrappedTargetException, RuntimeException)
-{
- MutexGuard aGuard( m_aMutex );
-
- if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "body" )) && m_aBody.getLength() )
- return makeAny( m_aBody );
-
- if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "from" )) && m_aOriginator.getLength() )
- return makeAny( m_aOriginator );
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "to" )) && m_aRecipient.getLength() )
- return makeAny( m_aRecipient );
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "cc" )) && m_CcRecipients.getLength() )
- return makeAny( m_CcRecipients );
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "bcc" )) && m_BccRecipients.getLength() )
- return makeAny( m_BccRecipients );
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "subject" )) && m_aSubject.getLength() )
- return makeAny( m_aSubject );
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "attachment" )) && m_Attachments.getLength() )
- return makeAny( m_Attachments );
-
- throw NoSuchElementException( OUString(RTL_CONSTASCII_USTRINGPARAM( "key not found: ")) + aName,
- static_cast < XNameAccess * > (this) );
-}
-
-Sequence< OUString > SAL_CALL CmdMailMsg::getElementNames( )
- throw (::com::sun::star::uno::RuntimeException)
-{
- MutexGuard aGuard( m_aMutex );
-
- sal_Int32 nItems = 0;
- Sequence< OUString > aRet( 7 );
-
- if( m_aBody.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "body" ));
-
- if( m_aOriginator.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "from" ));
-
- if( m_aRecipient.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "to" ));
-
- if( m_CcRecipients.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "cc" ));
-
- if( m_BccRecipients.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "bcc" ));
-
- if( m_aSubject.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "subject" ));
-
- if( m_Attachments.getLength() )
- aRet[nItems++] = OUString(RTL_CONSTASCII_USTRINGPARAM( "attachment" ));
-
- aRet.realloc( nItems );
- return aRet;
-}
-
- sal_Bool SAL_CALL CmdMailMsg::hasByName( const OUString& aName )
- throw (RuntimeException)
-{
- MutexGuard aGuard( m_aMutex );
-
- if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "body" )) && m_aBody.getLength() )
- return sal_True;
-
- if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "from" )) && m_aOriginator.getLength() )
- return sal_True;
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "to" )) && m_aRecipient.getLength() )
- return sal_True;
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "cc" )) && m_CcRecipients.getLength() )
- return sal_True;
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "bcc" )) && m_BccRecipients.getLength() )
- return sal_True;
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "subject" )) && m_aSubject.getLength() )
- return sal_True;
-
- else if( 0 == aName.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "attachment" )) && m_Attachments.getLength() )
- return sal_True;
-
- return sal_False;
-}
-
-Type SAL_CALL CmdMailMsg::getElementType( )
- throw (RuntimeException)
-{
- // returning void for multi type container
- return Type();
-}
-
-sal_Bool SAL_CALL CmdMailMsg::hasElements( )
- throw (RuntimeException)
-{
- return 0 != getElementNames().getLength();
}
diff --git a/shell/source/cmdmail/cmdmailmsg.hxx b/shell/source/cmdmail/cmdmailmsg.hxx
index 75ff09559187..017a308867ad 100644
--- a/shell/source/cmdmail/cmdmailmsg.hxx
+++ b/shell/source/cmdmail/cmdmailmsg.hxx
@@ -19,113 +19,77 @@
*
*************************************************************/
-
-
#ifndef _CMDMAILMSG_HXX_
#define _CMDMAILMSG_HXX_
-#include <cppuhelper/implbase2.hxx>
-#include <com/sun/star/lang/IllegalArgumentException.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-
-#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
-#include <com/sun/star/system/XSimpleMailMessage2.hpp>
-#endif
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
-//----------------------------------------------------------
-// class declaration
-//----------------------------------------------------------
+#include <com/sun/star/system/XMailMessage.hpp>
-class CmdMailMsg :
- public cppu::WeakImplHelper2<
- ::com::sun::star::system::XSimpleMailMessage2,
- ::com::sun::star::container::XNameAccess >
+namespace shell
{
- ::rtl::OUString m_aBody;
- ::rtl::OUString m_aRecipient;
- ::rtl::OUString m_aOriginator;
- ::rtl::OUString m_aSubject;
- ::com::sun::star::uno::Sequence< rtl::OUString > m_CcRecipients;
- ::com::sun::star::uno::Sequence< rtl::OUString > m_BccRecipients;
- ::com::sun::star::uno::Sequence< rtl::OUString > m_Attachments;
-
- ::osl::Mutex m_aMutex;
-
-public:
-
- CmdMailMsg() {};
-
- //------------------------------------------------
- // XSimpleMailMessage
- //------------------------------------------------
-
- virtual void SAL_CALL setBody( const ::rtl::OUString& aBody )
- throw (::com::sun::star::uno::RuntimeException);
-
- virtual ::rtl::OUString SAL_CALL getBody( )
- throw (::com::sun::star::uno::RuntimeException);
-
- virtual void SAL_CALL setRecipient( const ::rtl::OUString& aRecipient )
- throw (::com::sun::star::uno::RuntimeException);
-
- virtual ::rtl::OUString SAL_CALL getRecipient( )
- throw (::com::sun::star::uno::RuntimeException);
-
- virtual void SAL_CALL setCcRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aCcRecipient )
- throw (::com::sun::star::uno::RuntimeException);
+ typedef cppu::WeakImplHelper1<
+ com::sun::star::system::XMailMessage > CmdMailMsg_Base;
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCcRecipient( )
- throw (::com::sun::star::uno::RuntimeException);
+ class CmdMailMsg : protected cppu::BaseMutex,
+ public CmdMailMsg_Base
+ {
+ private:
+ ::rtl::OUString m_aBody;
+ ::rtl::OUString m_aRecipient;
+ ::rtl::OUString m_aOriginator;
+ ::rtl::OUString m_aSubject;
+ ::com::sun::star::uno::Sequence< rtl::OUString > m_CcRecipients;
+ ::com::sun::star::uno::Sequence< rtl::OUString > m_BccRecipients;
+ ::com::sun::star::uno::Sequence< rtl::OUString > m_Attachments;
- virtual void SAL_CALL setBccRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aBccRecipient )
- throw (::com::sun::star::uno::RuntimeException);
+ public:
+ CmdMailMsg();
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getBccRecipient( )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBody( const ::rtl::OUString& aBody )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setOriginator( const ::rtl::OUString& aOriginator )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getBody( )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getOriginator( )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRecipient( const ::rtl::OUString& aRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setSubject( const ::rtl::OUString& aSubject )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual ::rtl::OUString SAL_CALL getSubject( )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCcRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aCcRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setAttachement( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAttachement )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCcRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAttachement( )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBccRecipient( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aBccRecipient )
+ throw (::com::sun::star::uno::RuntimeException);
- //------------------------------------------------
- // XNameAccess
- //------------------------------------------------
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getBccRecipient( )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
- throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setOriginator( const ::rtl::OUString& aOriginator )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
- throw (::com::sun::star::uno::RuntimeException) ;
+ virtual ::rtl::OUString SAL_CALL getOriginator( )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSubject( const ::rtl::OUString& aSubject )
+ throw (::com::sun::star::uno::RuntimeException);
- //------------------------------------------------
- // XElementAccess
- //------------------------------------------------
+ virtual ::rtl::OUString SAL_CALL getSubject( )
+ throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAttachement( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aAttachement )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
- virtual sal_Bool SAL_CALL hasElements( )
- throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAttachement( )
+ throw (::com::sun::star::uno::RuntimeException);
-};
+ };
+}
#endif
diff --git a/shell/source/cmdmail/cmdmailsuppl.cxx b/shell/source/cmdmail/cmdmailsuppl.cxx
deleted file mode 100644
index bda87405d82d..000000000000
--- a/shell/source/cmdmail/cmdmailsuppl.cxx
+++ /dev/null
@@ -1,337 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_shell.hxx"
-
-//------------------------------------------------------------------------
-// includes
-//------------------------------------------------------------------------
-#include <osl/diagnose.h>
-#include <osl/thread.h>
-
-#include <rtl/bootstrap.hxx>
-
-#include <osl/file.hxx>
-#include <rtl/strbuf.hxx>
-#include "cmdmailsuppl.hxx"
-#include "cmdmailmsg.hxx"
-#include <com/sun/star/system/SimpleMailClientFlags.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-//------------------------------------------------------------------------
-// namespace directives
-//------------------------------------------------------------------------
-
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::system::XSimpleMailClientSupplier;
-using com::sun::star::system::XSimpleMailClient;
-using com::sun::star::system::XSimpleMailMessage;
-using com::sun::star::system::XSimpleMailMessage2;
-using com::sun::star::container::XNameAccess;
-using com::sun::star::container::NoSuchElementException;
-using rtl::OUString;
-using rtl::OUStringToOString;
-using rtl::OString;
-using rtl::OStringBuffer;
-using osl::MutexGuard;
-using osl::FileBase;
-
-using namespace cppu;
-using namespace com::sun::star::system::SimpleMailClientFlags;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::lang;
-
-//------------------------------------------------------------------------
-// defines
-//------------------------------------------------------------------------
-
-#define COMP_IMPL_NAME "com.sun.star.comp.system.SimpleCommandMail2"
-
-//------------------------------------------------------------------------
-// helper functions
-//------------------------------------------------------------------------
-
-namespace // private
-{
- Sequence< OUString > SAL_CALL Component_getSupportedServiceNames()
- {
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii("com.sun.star.system.SimpleCommandMail");
- return aRet;
- }
-
-} // end private namespace
-
-//-------------------------------------------------
-//
-//-------------------------------------------------
-
-CmdMailSuppl::CmdMailSuppl( const Reference< XComponentContext >& xContext ) :
- WeakImplHelper3< XSimpleMailClientSupplier, XSimpleMailClient, XServiceInfo >()
-{
- Reference< XMultiComponentFactory > xServiceManager = xContext->getServiceManager();
-
- if ( xServiceManager.is() ) {
- m_xConfigurationProvider = Reference< XMultiServiceFactory > (
- xServiceManager->createInstanceWithContext(
- OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ), xContext ),
- UNO_QUERY );
- }
-}
-
-//-------------------------------------------------
-// XSimpleMailClientSupplier
-//-------------------------------------------------
-
-Reference< XSimpleMailClient > SAL_CALL CmdMailSuppl::querySimpleMailClient( )
- throw (RuntimeException)
-{
- return static_cast < XSimpleMailClient * > (this);
-}
-
-//------------------------------------------------
-// XSimpleMailClient
-//------------------------------------------------
-
-Reference< XSimpleMailMessage > SAL_CALL CmdMailSuppl::createSimpleMailMessage( )
- throw (::com::sun::star::uno::RuntimeException)
-{
- return Reference< XSimpleMailMessage >( new CmdMailMsg( ) );
-}
-
-//------------------------------------------------
-// XSimpleMailClient
-//------------------------------------------------
-
-void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 /*aFlag*/ )
- throw (IllegalArgumentException, Exception, RuntimeException)
-{
- if ( ! xSimpleMailMessage.is() )
- {
- throw ::com::sun::star::lang::IllegalArgumentException(
- OUString(RTL_CONSTASCII_USTRINGPARAM( "No message specified" )),
- static_cast < XSimpleMailClient * > (this), 1 );
- }
-
- if( ! m_xConfigurationProvider.is() )
- {
- throw ::com::sun::star::uno::Exception(
- OUString(RTL_CONSTASCII_USTRINGPARAM( "Can not access configuration" )),
- static_cast < XSimpleMailClient * > (this) );
- }
-
- OStringBuffer aBuffer;
- aBuffer.append("\"");
-
- OUString aProgramURL(RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/senddoc"));
- rtl::Bootstrap::expandMacros(aProgramURL);
-
- OUString aProgram;
- if ( FileBase::E_None != FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
- {
- throw ::com::sun::star::uno::Exception(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
- static_cast < XSimpleMailClient * > (this));
- }
-
- aBuffer.append(OUStringToOString(aProgram, osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
-
- try
- {
- // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
- // configuration node to retriece the users preferred email application. This may
- // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
- OUString aConfigRoot = OUString(
- RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
-
- PropertyValue aProperty;
- aProperty.Name = OUString::createFromAscii( "nodepath" );
- aProperty.Value = makeAny( aConfigRoot );
-
- Sequence< Any > aArgumentList( 1 );
- aArgumentList[0] = makeAny( aProperty );
-
- Reference< XNameAccess > xNameAccess =
- Reference< XNameAccess > (
- m_xConfigurationProvider->createInstanceWithArguments(
- OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ),
- aArgumentList ),
- UNO_QUERY );
-
- if( xNameAccess.is() )
- {
- OUString aMailer;
-
- // Retrieve the value for "Program" node and append it feed senddoc with it
- // using the (undocumented) --mailclient switch
- xNameAccess->getByName( OUString::createFromAscii( "Program" ) ) >>= aMailer;
-
- if( aMailer.getLength() )
- {
- // make sure we have a system path
- FileBase::getSystemPathFromFileURL( aMailer, aMailer );
-
- aBuffer.append("--mailclient ");
- aBuffer.append(OUStringToOString( aMailer, osl_getThreadTextEncoding() ));
- aBuffer.append(" ");
- }
-#ifdef MACOSX
- else
- aBuffer.append("--mailclient Mail ");
-#endif
- }
-
- }
-
- catch( RuntimeException e )
- {
- m_xConfigurationProvider.clear();
- OSL_TRACE( "RuntimeException caught accessing configuration provider." );
- OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
- throw e;
- }
-
- Reference< XSimpleMailMessage2 > xMessage( xSimpleMailMessage, UNO_QUERY );
- if ( xMessage.is() )
- {
- rtl::OUString sBody = xMessage->getBody();
- if ( sBody.getLength() > 0 )
- {
- aBuffer.append("--body \"");
- aBuffer.append(OUStringToOString(sBody, osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
- }
-
- // Append originator if set in the message
- if ( xSimpleMailMessage->getOriginator().getLength() > 0 )
- {
- aBuffer.append("--from \"");
- aBuffer.append(OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
-
- // Append receipient if set in the message
- if ( xSimpleMailMessage->getRecipient().getLength() > 0 )
- {
- aBuffer.append("--to \"");
- aBuffer.append(OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
-
- // Append carbon copy receipients set in the message
- Sequence< OUString > aStringList = xSimpleMailMessage->getCcRecipient();
- sal_Int32 n, nmax = aStringList.getLength();
- for ( n = 0; n < nmax; n++ )
- {
- aBuffer.append("--cc \"");
- aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
-
- // Append blind carbon copy receipients set in the message
- aStringList = xSimpleMailMessage->getBccRecipient();
- nmax = aStringList.getLength();
- for ( n = 0; n < nmax; n++ )
- {
- aBuffer.append("--bcc \"");
- aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
-
- // Append subject if set in the message
- if ( xSimpleMailMessage->getSubject().getLength() > 0 )
- {
- aBuffer.append("--subject \"");
- aBuffer.append(OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
-
- // Append attachments set in the message
- aStringList = xSimpleMailMessage->getAttachement();
- nmax = aStringList.getLength();
- for ( n = 0; n < nmax; n++ )
- {
- OUString aSystemPath;
- if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
- {
- aBuffer.append("--attach \"");
- aBuffer.append(OUStringToOString(aSystemPath, osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
- }
- }
-
- OString cmd = aBuffer.makeStringAndClear();
- if ( 0 != pclose(popen(cmd.getStr(), "w")) )
- {
- throw ::com::sun::star::uno::Exception(
- OUString(RTL_CONSTASCII_USTRINGPARAM( "No mail client configured" )),
- static_cast < XSimpleMailClient * > (this) );
- }
-}
-
-// -------------------------------------------------
-// XServiceInfo
-// -------------------------------------------------
-
-OUString SAL_CALL CmdMailSuppl::getImplementationName( )
- throw( RuntimeException )
-{
- return OUString::createFromAscii( COMP_IMPL_NAME );
-}
-
-// -------------------------------------------------
-// XServiceInfo
-// -------------------------------------------------
-
-sal_Bool SAL_CALL CmdMailSuppl::supportsService( const OUString& ServiceName )
- throw( RuntimeException )
-{
- Sequence < OUString > SupportedServicesNames = Component_getSupportedServiceNames();
-
- for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
- if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
- return sal_True;
-
- return sal_False;
-}
-
-// -------------------------------------------------
-// XServiceInfo
-// -------------------------------------------------
-
-Sequence< OUString > SAL_CALL CmdMailSuppl::getSupportedServiceNames( )
- throw( RuntimeException )
-{
- return Component_getSupportedServiceNames();
-}
-
diff --git a/shell/source/cmdmail/cmdmailsuppl.hxx b/shell/source/cmdmail/cmdmailsuppl.hxx
deleted file mode 100644
index 877c2c2af563..000000000000
--- a/shell/source/cmdmail/cmdmailsuppl.hxx
+++ /dev/null
@@ -1,91 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-#ifndef _CMDMAILSUPPL_HXX_
-#define _CMDMAILSUPPL_HXX_
-
-//----------------------------------------------------------
-// includes of other projects
-//----------------------------------------------------------
-
-#include <cppuhelper/implbase3.hxx>
-#include <osl/mutex.hxx>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-
-#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
-#include <com/sun/star/system/XSimpleMailClient.hpp>
-#endif
-
-#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
-#include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
-#endif
-
-//----------------------------------------------------------
-// class declaration
-//----------------------------------------------------------
-
-class CmdMailSuppl :
- public cppu::WeakImplHelper3<
- com::sun::star::system::XSimpleMailClientSupplier,
- com::sun::star::system::XSimpleMailClient,
- com::sun::star::lang::XServiceInfo >
-{
-
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigurationProvider;
-
-public:
- CmdMailSuppl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
-
- //------------------------------------------------
- // XSimpleMailClientSupplier
- //------------------------------------------------
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailClient > SAL_CALL querySimpleMailClient( )
- throw (::com::sun::star::uno::RuntimeException);
-
- //------------------------------------------------
- // XSimpleMailClient
- //------------------------------------------------
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage > SAL_CALL createSimpleMailMessage( )
- throw (::com::sun::star::uno::RuntimeException);
-
- virtual void SAL_CALL sendSimpleMailMessage( const ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 aFlag )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-
- //------------------------------------------------
- // XServiceInfo
- //------------------------------------------------
-
- virtual ::rtl::OUString SAL_CALL getImplementationName( )
- throw(::com::sun::star::uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
- throw(::com::sun::star::uno::RuntimeException);
-
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
- throw(::com::sun::star::uno::RuntimeException);
-};
-
-#endif
diff --git a/shell/source/cmdmail/makefile.mk b/shell/source/cmdmail/makefile.mk
index e1c39933d4cd..75d143855388 100644
--- a/shell/source/cmdmail/makefile.mk
+++ b/shell/source/cmdmail/makefile.mk
@@ -37,7 +37,7 @@ COMP1TYPELIST=$(TARGET)
DLLPRE=
SLOFILES= \
- $(SLO)$/cmdmailsuppl.obj \
+ $(SLO)$/syscmdmail.obj \
$(SLO)$/cmdmailmsg.obj \
$(SLO)$/cmdmailentry.obj
SHL1OBJS=$(SLOFILES)
diff --git a/shell/source/cmdmail/syscmdmail.cxx b/shell/source/cmdmail/syscmdmail.cxx
new file mode 100644
index 000000000000..6d10208eaacf
--- /dev/null
+++ b/shell/source/cmdmail/syscmdmail.cxx
@@ -0,0 +1,355 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_shell.hxx"
+
+#include "syscmdmail.hxx"
+#include "cmdmailmsg.hxx"
+
+#include <com/sun/star/system/MailClientFlags.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <osl/file.hxx>
+#include <osl/thread.hxx>
+#include <rtl/bootstrap.hxx>
+#include <rtl/strbuf.hxx>
+
+#include <unistd.h>
+
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::container::XNameAccess;
+using com::sun::star::system::XMailClient;
+using com::sun::star::system::XMailMessage;
+using rtl::OString;
+using rtl::OStringBuffer;
+using rtl::OUString;
+using rtl::OUStringToOString;
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::system::MailClientFlags;
+using namespace com::sun::star::uno;
+
+#define COMP_SERVICE_NAME "com.sun.star.system.SystemMailProvider"
+#define COMP_IMPL_NAME "com.sun.star.comp.system.unx.SystemMailProvider"
+
+namespace shell
+{
+
+namespace
+{
+ static void escapeDoubleQuotes( OStringBuffer &rBuffer,
+ const OUString &ustr,
+ rtl_TextEncoding iEncoding )
+ {
+ const OString rStr( OUStringToOString( ustr, iEncoding ) );
+ sal_Int32 nIndex = rStr.indexOf('"');
+ if ( nIndex == -1 )
+ rBuffer.append( rStr );
+ else
+ {
+ const sal_Char *pStart = rStr.getStr();
+ const sal_Char *pFrom = pStart;
+ const sal_Int32 nLen = rStr.getLength();
+ sal_Int32 nPrev = 0;;
+ do
+ {
+ rBuffer.append( pFrom, nIndex - nPrev );
+ rBuffer.append( RTL_CONSTASCII_STRINGPARAM( "\\\"" ) );
+ nIndex++;
+ pFrom = pStart + nIndex;
+ nPrev = nIndex;
+ }
+ while ( ( nIndex = rStr.indexOf( '"' , nIndex ) ) != -1 );
+
+ rBuffer.append( pFrom, nLen - nPrev );
+ }
+ }
+}
+
+SystemCommandMail::SystemCommandMail(
+ const Reference< XComponentContext >& xContext )
+ : SystemCommandMail_Base( m_aMutex )
+ , m_xContext( xContext )
+{
+ try
+ {
+ m_xConfigurationProvider.set(
+ m_xContext->getServiceManager()->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationProvider") ),
+ m_xContext ),
+ UNO_QUERY );
+ }
+ catch(...){}
+}
+
+SystemCommandMail::~SystemCommandMail()
+{
+ m_xConfigurationProvider.clear();
+ m_xContext.clear();
+}
+
+Reference< XMailClient > SAL_CALL
+SystemCommandMail::queryMailClient()
+throw ( RuntimeException )
+{
+ return Reference< XMailClient >(
+ static_cast < cppu::OWeakObject * >( this ), UNO_QUERY );
+}
+
+
+Reference< XMailMessage > SAL_CALL
+SystemCommandMail::createMailMessage()
+throw ( RuntimeException )
+{
+ return Reference< XMailMessage >(
+ static_cast< cppu::OWeakObject *>(
+ new CmdMailMsg() ),
+ UNO_QUERY );
+}
+
+
+void SAL_CALL
+SystemCommandMail::sendMailMessage(
+ const Reference< XMailMessage >& xMailMessage,
+ sal_Int32 /*aFlag*/ )
+throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ osl::ClearableMutexGuard aGuard( m_aMutex );
+ Reference< XMultiServiceFactory > xConfigurationProvider = m_xConfigurationProvider;
+ aGuard.clear();
+
+ if ( ! xMailMessage.is() )
+ {
+ throw IllegalArgumentException(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "No message specified" )),
+ static_cast < XMailClient * > (this), 1 );
+ }
+
+ if( ! xConfigurationProvider.is() )
+ {
+ throw Exception(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "Can not access configuration" )),
+ static_cast < XMailClient * > (this) );
+ }
+
+ OStringBuffer aBuffer;
+ aBuffer.append("\"");
+
+ OUString aProgramURL(RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/senddoc"));
+ rtl::Bootstrap::expandMacros(aProgramURL);
+ OUString aProgram;
+ if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
+ {
+ throw Exception(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
+ static_cast < XMailClient * > (this));
+ }
+
+ const rtl_TextEncoding iEncoding = osl_getThreadTextEncoding();
+ aBuffer.append(OUStringToOString(aProgram, iEncoding));
+ aBuffer.append("\" ");
+
+ try
+ {
+ // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
+ // configuration node to retriece the users preferred email application. This may
+ // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
+ OUString aConfigRoot = OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
+
+ PropertyValue aProperty;
+ aProperty.Name = OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath" ));
+ aProperty.Value = makeAny( aConfigRoot );
+
+ Sequence< Any > aArgumentList( 1 );
+ aArgumentList[0] = makeAny( aProperty );
+
+ Reference< XNameAccess > xNameAccess =
+ Reference< XNameAccess > (
+ xConfigurationProvider->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" )),
+ aArgumentList ),
+ UNO_QUERY );
+
+ if( xNameAccess.is() )
+ {
+ OUString aMailer;
+
+ // Retrieve the value for "Program" node and append it feed senddoc with it
+ // using the (undocumented) --mailclient switch
+ xNameAccess->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM("Program") ) ) >>= aMailer;
+
+ if( aMailer.getLength() )
+ {
+ // make sure we have a system path
+ osl::FileBase::getSystemPathFromFileURL( aMailer, aMailer );
+
+ aBuffer.append("--mailclient ");
+ aBuffer.append(OUStringToOString( aMailer, iEncoding ));
+ aBuffer.append(" ");
+ }
+#ifdef MACOSX
+ else
+ aBuffer.append("--mailclient Mail ");
+#endif
+ }
+
+ }
+ catch( RuntimeException e )
+ {
+ OSL_TRACE( "RuntimeException caught accessing configuration provider." );
+ OSL_TRACE( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ throw e;
+ }
+
+ // Append body if set in the message
+ OUString ustr = xMailMessage->getBody();
+ if ( ustr.getLength() > 0 )
+ {
+ aBuffer.append("--body \"");
+ escapeDoubleQuotes( aBuffer, ustr, iEncoding );
+ aBuffer.append("\" ");
+ }
+
+ // Append subject if set in the message
+ ustr = xMailMessage->getSubject();
+ if ( ustr.getLength() > 0 )
+ {
+ aBuffer.append("--subject \"");
+ escapeDoubleQuotes( aBuffer, ustr, iEncoding );
+ aBuffer.append("\" ");
+ }
+
+ // Append originator if set in the message
+ if ( xMailMessage->getOriginator().getLength() > 0 )
+ {
+ aBuffer.append("--from \"");
+ aBuffer.append(OUStringToOString(xMailMessage->getOriginator(), iEncoding));
+ aBuffer.append("\" ");
+ }
+
+ // Append receipient if set in the message
+ if ( xMailMessage->getRecipient().getLength() > 0 )
+ {
+ aBuffer.append("--to \"");
+ aBuffer.append(OUStringToOString(xMailMessage->getRecipient(), iEncoding));
+ aBuffer.append("\" ");
+ }
+
+ // Append carbon copy receipients set in the message
+ Sequence< OUString > aStringList = xMailMessage->getCcRecipient();
+ sal_Int32 n, nmax = aStringList.getLength();
+ for ( n = 0; n < nmax; n++ )
+ {
+ aBuffer.append("--cc \"");
+ aBuffer.append(OUStringToOString(aStringList[n], iEncoding));
+ aBuffer.append("\" ");
+ }
+
+ // Append blind carbon copy receipients set in the message
+ aStringList = xMailMessage->getBccRecipient();
+ nmax = aStringList.getLength();
+ for ( n = 0; n < nmax; n++ )
+ {
+ aBuffer.append("--bcc \"");
+ aBuffer.append(OUStringToOString(aStringList[n], iEncoding));
+ aBuffer.append("\" ");
+ }
+
+ // Append attachments set in the message
+ aStringList = xMailMessage->getAttachement();
+ nmax = aStringList.getLength();
+ for ( n = 0; n < nmax; n++ )
+ {
+ OUString aSystemPath;
+ if ( osl::FileBase::E_None == osl::FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
+ {
+ aBuffer.append("--attach \"");
+ aBuffer.append(OUStringToOString(aSystemPath, iEncoding));
+ aBuffer.append("\" ");
+ }
+ }
+
+ OString cmd = aBuffer.makeStringAndClear();
+ if ( 0 != pclose(popen(cmd.getStr(), "w")) )
+ {
+ throw ::com::sun::star::uno::Exception(
+ OUString(RTL_CONSTASCII_USTRINGPARAM( "No mail client configured" )),
+ static_cast < XMailClient * > (this) );
+ }
+}
+
+OUString SAL_CALL
+SystemCommandMail::getImplementationName( )
+throw( RuntimeException )
+{
+ return getImplementationName_static();
+}
+
+sal_Bool SAL_CALL
+SystemCommandMail::supportsService(
+ const OUString& ServiceName )
+throw( RuntimeException )
+{
+ Sequence < OUString > SupportedServicesNames = getSupportedServiceNames_static();
+
+ for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; )
+ if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
+ return sal_True;
+
+ return sal_False;
+}
+
+Sequence< OUString > SAL_CALL
+SystemCommandMail::getSupportedServiceNames()
+throw( RuntimeException )
+{
+ return getSupportedServiceNames_static();
+}
+
+Reference< XInterface >
+SystemCommandMail::Create(
+ const Reference< XComponentContext > &xContext)
+{
+ return Reference< XInterface >(
+ static_cast< cppu::OWeakObject *>(
+ new SystemCommandMail( xContext ) ) );
+}
+
+OUString
+SystemCommandMail::getImplementationName_static()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_IMPL_NAME ) );
+}
+
+Sequence< OUString >
+SystemCommandMail::getSupportedServiceNames_static()
+{
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_SERVICE_NAME ) );
+ return aRet;
+}
+
+}
diff --git a/shell/source/cmdmail/syscmdmail.hxx b/shell/source/cmdmail/syscmdmail.hxx
new file mode 100644
index 000000000000..9acf054210ac
--- /dev/null
+++ b/shell/source/cmdmail/syscmdmail.hxx
@@ -0,0 +1,74 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _SYSTEMCMDMAIL_HXX_
+#define _SYSTEMCMDMAIL_HXX_
+
+#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/system/XSystemMailProvider.hpp>
+
+namespace shell
+{
+ typedef cppu::WeakComponentImplHelper3<
+ com::sun::star::system::XSystemMailProvider,
+ com::sun::star::system::XMailClient,
+ com::sun::star::lang::XServiceInfo > SystemCommandMail_Base;
+
+ class SystemCommandMail : protected cppu::BaseMutex,
+ public SystemCommandMail_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigurationProvider;
+
+ public:
+ SystemCommandMail( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
+ ~SystemCommandMail();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XMailClient > SAL_CALL queryMailClient( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XMailMessage > SAL_CALL createMailMessage( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL sendMailMessage( const ::com::sun::star::uno::Reference< ::com::sun::star::system::XMailMessage >& xMailMessage, sal_Int32 aFlag )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(::com::sun::star::uno::RuntimeException);
+
+ static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > Create( const com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext);
+ static rtl::OUString getImplementationName_static();
+ static com::sun::star::uno::Sequence< rtl::OUString > getSupportedServiceNames_static();
+ };
+}
+
+#endif