diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/win32/simplemail/exports.dxp | 3 | ||||
-rw-r--r-- | shell/source/win32/simplemail/makefile.mk | 106 | ||||
-rw-r--r-- | shell/source/win32/simplemail/simplemapi.cxx | 194 | ||||
-rw-r--r-- | shell/source/win32/simplemail/simplemapi.hxx | 125 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmail.xml | 37 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.cxx | 427 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.hxx | 148 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailentry.cxx | 186 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.cxx | 216 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.hxx | 164 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailsuppl.cxx | 197 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailsuppl.hxx | 133 |
12 files changed, 1936 insertions, 0 deletions
diff --git a/shell/source/win32/simplemail/exports.dxp b/shell/source/win32/simplemail/exports.dxp new file mode 100644 index 000000000000..028ac4175990 --- /dev/null +++ b/shell/source/win32/simplemail/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/shell/source/win32/simplemail/makefile.mk b/shell/source/win32/simplemail/makefile.mk new file mode 100644 index 000000000000..5e038a0c9723 --- /dev/null +++ b/shell/source/win32/simplemail/makefile.mk @@ -0,0 +1,106 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: tra $ $Date: 2001-05-14 08:09:08 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJNAME=shell +TARGET=smplmail +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) +COMPRDB=$(SOLARBINDIR)$/applicat.rdb + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +#.INCLUDE : ..$/cppumaker.mk + +SLOFILES=$(SLO)$/smplmailentry.obj\ + $(SLO)$/smplmailmsg.obj\ + $(SLO)$/smplmailclient.obj\ + $(SLO)$/smplmailsuppl.obj\ + $(SLO)$/simplemapi.obj + +SHL1TARGET=$(TARGET) + +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB) + +SHL1LIBS= + +SHL1DEPN= +SHL1IMPLIB=i$(SHL1TARGET) + +SHL1OBJS=$(SLOFILES) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/shell/source/win32/simplemail/simplemapi.cxx b/shell/source/win32/simplemail/simplemapi.cxx new file mode 100644 index 000000000000..3c5ddec39cb0 --- /dev/null +++ b/shell/source/win32/simplemail/simplemapi.cxx @@ -0,0 +1,194 @@ +/************************************************************************* + * + * $RCSfile: simplemapi.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:09:15 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SIMPLEMAPI_HXX_ +#include "simplemapi.hxx" +#endif + +//---------------------------------------------------------- +// static variables +//---------------------------------------------------------- + +CSimpleMapi* CSimpleMapi::s_Instance = NULL; +osl::Mutex CSimpleMapi::s_aMutex; +CSimpleMapi::SIMPLEMAPI_SINGLETON_DESTROYER_T CSimpleMapi::s_SingletonDestroyer; + +//---------------------------------------------------------- +// +//---------------------------------------------------------- + +CSimpleMapi* CSimpleMapi::create( ) +{ + if ( !s_Instance ) + { + osl::MutexGuard aGuard( s_aMutex ); + + if ( !s_Instance ) + { + s_Instance = new CSimpleMapi( ); + s_SingletonDestroyer.reset( s_Instance ); + } + } + + return s_Instance; +} + +//---------------------------------------------------------- +// +//---------------------------------------------------------- + +CSimpleMapi::CSimpleMapi( ) : + m_lpfnMapiLogon( NULL ), + m_lpfnMapiLogoff( NULL ), + m_lpfnMapiSendMail( NULL ) +{ + // load the library + m_hMapiDll = LoadLibrary( "mapi32.dll" ); + + if ( m_hMapiDll ) + { + // initialize the function pointer + m_lpfnMapiLogon = reinterpret_cast< LPMAPILOGON >( + GetProcAddress( m_hMapiDll, "MAPILogon" ) ); + + m_lpfnMapiLogoff = reinterpret_cast< LPMAPILOGOFF >( + GetProcAddress( m_hMapiDll, "MAPILogoff" ) ); + + m_lpfnMapiSendMail = reinterpret_cast< LPMAPISENDMAIL >( + GetProcAddress( m_hMapiDll, "MAPISendMail" ) ); + } +} + +//---------------------------------------------------------- +// +//---------------------------------------------------------- + +CSimpleMapi::~CSimpleMapi( ) +{ + if ( m_hMapiDll ) + FreeLibrary( m_hMapiDll ); +} + +//---------------------------------------------------------- +// +//---------------------------------------------------------- + +ULONG CSimpleMapi::MAPILogon( + ULONG ulUIParam, + LPTSTR lpszProfileName, + LPTSTR lpszPassword, + FLAGS flFlags, + ULONG ulReserved, + LPLHANDLE lplhSession ) +{ + ULONG ulRet = MAPI_E_FAILURE; + + if ( m_lpfnMapiLogon ) + ulRet = m_lpfnMapiLogon( + ulUIParam, + lpszProfileName, + lpszPassword, + flFlags, + ulReserved, + lplhSession ); + + return ulRet; +} + +//---------------------------------------------------------- +// +//---------------------------------------------------------- + +ULONG CSimpleMapi::MAPILogoff( + LHANDLE lhSession, + ULONG ulUIParam, + FLAGS flFlags, + ULONG ulReserved ) +{ + ULONG ulRet = MAPI_E_FAILURE; + + if ( m_lpfnMapiLogoff ) + ulRet = m_lpfnMapiLogoff( + lhSession, ulUIParam, flFlags, ulReserved ); + + return ulRet; +} + +//---------------------------------------------------------- +// +//---------------------------------------------------------- + +ULONG CSimpleMapi::MAPISendMail( + LHANDLE lhSession, + ULONG ulUIParam, + lpMapiMessage lpMessage, + FLAGS flFlags, + ULONG ulReserved ) +{ + ULONG ulRet = MAPI_E_FAILURE; + + if ( m_lpfnMapiSendMail ) + ulRet = m_lpfnMapiSendMail( + lhSession, ulUIParam, lpMessage, flFlags, ulReserved ); + + return ulRet; +} + diff --git a/shell/source/win32/simplemail/simplemapi.hxx b/shell/source/win32/simplemail/simplemapi.hxx new file mode 100644 index 000000000000..b991cbc5d20f --- /dev/null +++ b/shell/source/win32/simplemail/simplemapi.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: simplemapi.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:09:21 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SIMPLEMAPI_HXX_ +#define _SIMPLEMAPI_HXX_ + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#include <memory> + +#include <windows.h> +#include <mapi.h> +#include <mapix.h> + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CSimpleMapi +{ +public: + static CSimpleMapi* create( ); + + ULONG MAPILogon( + ULONG ulUIParam, + LPTSTR lpszProfileName, + LPTSTR lpszPassword, + FLAGS flFlags, + ULONG ulReserved, + LPLHANDLE lplhSession ); + + ULONG MAPILogoff( + LHANDLE lhSession, + ULONG ulUIParam, + FLAGS flFlags, + ULONG ulReserved ); + + ULONG MAPISendMail( + LHANDLE lhSession, + ULONG ulUIParam, + lpMapiMessage lpMessage, + FLAGS flFlags, + ULONG ulReserved ); + +private: + CSimpleMapi( ); + ~CSimpleMapi( ); + + typedef std::auto_ptr< CSimpleMapi > SIMPLEMAPI_SINGLETON_DESTROYER_T; + +private: + HMODULE m_hMapiDll; + LPMAPILOGON m_lpfnMapiLogon; + LPMAPILOGOFF m_lpfnMapiLogoff; + LPMAPISENDMAIL m_lpfnMapiSendMail; + + static CSimpleMapi* s_Instance; + static osl::Mutex s_aMutex; + static SIMPLEMAPI_SINGLETON_DESTROYER_T s_SingletonDestroyer; + + friend SIMPLEMAPI_SINGLETON_DESTROYER_T; +}; + + +#endif diff --git a/shell/source/win32/simplemail/smplmail.xml b/shell/source/win32/simplemail/smplmail.xml new file mode 100644 index 000000000000..8176f094acad --- /dev/null +++ b/shell/source/win32/simplemail/smplmail.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> smplmail </module-name> + <component-description> + <author> Tino Rachui </author> + <name>com.sun.star.comp.system.SimpleSystemMail</name> + <description> + The win32 implementation of a SimpleSystemMail service. +</description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language> c++ </language> + <status value="beta"/> + <supported-service> com.sun.star.system.SimpleSystemMail </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.XMultiServiceFactory </type> + <type> com.sun.star.lang.XSingleServiceFactory </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.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.container.XSet </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 </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/shell/source/win32/simplemail/smplmailclient.cxx b/shell/source/win32/simplemail/smplmailclient.cxx new file mode 100644 index 000000000000..6a0e43d4af65 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -0,0 +1,427 @@ +/************************************************************************* + * + * $RCSfile: smplmailclient.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:08 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _SMPLMAILCLIENT_HXX_ +#include "smplmailclient.hxx" +#endif + +#ifndef _SMPLMAILMSG_HXX_ +#include "smplmailmsg.hxx" +#endif + +#ifndef _COM_SUN_STAR_SYSTEM_SIMPLEMAILCLIENTFLAGS_HPP_ +#include <com/sun/star/system/SimpleMailClientFlags.hpp> +#endif + +#ifndef _RTL_TENCINFO_H +#include <rtl/tencinfo.h> +#endif + +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::uno::Reference; +using com::sun::star::uno::Exception; +using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::lang::IllegalArgumentException; +using com::sun::star::system::XSimpleMailClient; +using com::sun::star::system::XSimpleMailMessage; +using rtl::OUString; +using rtl::OString; +using osl::Mutex; + +using namespace com::sun::star::system::SimpleMailClientFlags; +using namespace cppu; + +//------------------------------------------------ +// +//------------------------------------------------ + +namespace // private +{ + const sal_uInt32 LEN_SMTP_PREFIX = 5; // "SMTP:" + + inline + OString getSmtpPrefixedEmailAddress( const OUString& aAddress ) + { + return OString( "SMTP:" ) + + OString( + aAddress.getStr( ), + aAddress.getLength( ), + osl_getThreadTextEncoding( ) ); + } + +} // end private namespace + +//------------------------------------------------ +// +//------------------------------------------------ + +CSmplMailClient::CSmplMailClient( ) : + m_pSimpleMapi( CSimpleMapi::create( ) ) +{ +} + +//------------------------------------------------ +// +//------------------------------------------------ + +Reference< XSimpleMailMessage > SAL_CALL CSmplMailClient::createSimpleMailMessage( ) + throw (::com::sun::star::uno::RuntimeException) +{ + return Reference< XSimpleMailMessage >( new CSmplMailMsg( ) ); +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailClient::sendSimpleMailMessage( const Reference< XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 aFlag ) + throw (IllegalArgumentException, Exception, RuntimeException) +{ + try + { + validateParameter( xSimpleMailMessage, aFlag ); + + MapiMessage mapiMsg; + FLAGS flFlags; + + initMapiMessage( xSimpleMailMessage, mapiMsg ); + initMapiSendMailFlags( aFlag, flFlags ); + + ULONG ulRet = m_pSimpleMapi->MAPISendMail( + 0, // no session, create a new one + 0, // no parent window + &mapiMsg, // a configured mapi message struct + flFlags, // some flags + 0 ); // reserved + + if ( SUCCESS_SUCCESS != ulRet ) + throw Exception( + getMapiErrorMsg( ulRet ), + static_cast< XSimpleMailClient* >( this ) ); + } + catch( RuntimeException& ) + { + OSL_ASSERT( sal_False ); + } +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void CSmplMailClient::validateParameter( + const Reference< XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 aFlag ) +{ + // check the flags, the allowed range is 0 - (2^n - 1) + if ( aFlag < 0 || aFlag > 3 ) + throw IllegalArgumentException( + OUString::createFromAscii( "Invalid flag value" ), + static_cast< XSimpleMailClient* >( this ), + 2 ); + + // check if a recipient is specified of the flags NO_USER_INTERFACE is specified + if ( (aFlag & NO_USER_INTERFACE) && !xSimpleMailMessage->getRecipient( ).getLength( ) ) + throw IllegalArgumentException( + OUString::createFromAscii( "No recipient specified" ), + static_cast< XSimpleMailClient* >( this ), + 1 ); +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void CSmplMailClient::initMapiMessage( + const Reference< XSimpleMailMessage >& xSimpleMailMessage, MapiMessage& aMapiMessage ) +{ + ZeroMemory( &aMapiMessage, sizeof( aMapiMessage ) ); + + if ( xSimpleMailMessage.is( ) ) + { + // unfortunately the simple mapi functions have + // only an ANSI prototype, so we have to convert + // all strings to ascii assuming an us-ascii + // encoding + + // we hand the buffer of this OStrings directly + // to the MapiMessage members but have to + // cast away the constness of the returned buffer + // pointer, we assume the function MAPISendMail + // doesn't alter the strings + + m_Subject = OString( + xSimpleMailMessage->getSubject( ).getStr( ), + xSimpleMailMessage->getSubject( ).getLength( ), + osl_getThreadTextEncoding( ) ); + + aMapiMessage.lpszSubject = const_cast< LPSTR >( m_Subject.getStr( ) ); + + // set the originator information + + if ( xSimpleMailMessage->getOriginator( ).getLength( ) ) + { + ZeroMemory( &m_MsgOriginator, sizeof( m_MsgOriginator ) ); + + m_SmtpAddressOriginator = getSmtpPrefixedEmailAddress( + xSimpleMailMessage->getOriginator( ) ); + + m_MsgOriginator.ulRecipClass = MAPI_ORIG; + m_MsgOriginator.lpszName = ""; + m_MsgOriginator.lpszAddress = + const_cast< LPSTR >( m_SmtpAddressOriginator.getStr( ) ); + + aMapiMessage.lpOriginator = &m_MsgOriginator; + } + + // set the recipient information + + sal_uInt32 nRecips = calcNumRecipients( xSimpleMailMessage ); + if ( nRecips > 0 ) + { + m_RecipientList.realloc( nRecips ); + m_RecipientList.clean( ); + m_RecipsSmtpAddressList.clear( ); + + size_t nPos = 0; + + // init the main recipient + OUString aRecipient = xSimpleMailMessage->getRecipient( ); + if ( aRecipient.getLength( ) ) + { + m_RecipsSmtpAddressList.push_back( + getSmtpPrefixedEmailAddress( aRecipient ) ); + + m_RecipientList[nPos].ulRecipClass = MAPI_TO; + m_RecipientList[nPos].lpszName = + const_cast< LPSTR >( m_RecipsSmtpAddressList.back( ).getStr( ) + LEN_SMTP_PREFIX ); + m_RecipientList[nPos].lpszAddress = + const_cast< LPSTR >( m_RecipsSmtpAddressList.back( ).getStr( ) ); + + nPos++; + } + + // add all cc recipients to the list + initRecipientList( + xSimpleMailMessage->getCcRecipient( ), + MAPI_CC, + nPos ); + + // add all bcc recipients to the list + initRecipientList( + xSimpleMailMessage->getBccRecipient( ), + MAPI_BCC, + nPos ); + + aMapiMessage.lpRecips = &m_RecipientList; + aMapiMessage.nRecipCount = m_RecipientList.size( ); + } + + initAttachementList( xSimpleMailMessage ); + aMapiMessage.lpFiles = &m_AttachementList; + aMapiMessage.nFileCount = m_AttachementList.size( ); + } +} + +//------------------------------------------------ +// +//------------------------------------------------ + +sal_uInt32 CSmplMailClient::calcNumRecipients( + const Reference< XSimpleMailMessage >& xSimpleMailMessage ) +{ + sal_uInt32 nRecips = xSimpleMailMessage->getCcRecipient( ).getLength( ); + nRecips += xSimpleMailMessage->getBccRecipient( ).getLength( ); + + if ( xSimpleMailMessage->getRecipient( ).getLength( ) ) + nRecips += 1; + + return nRecips; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void CSmplMailClient::initRecipientList( + const Sequence< rtl::OUString >& aRecipList, + ULONG ulRecipClass, + size_t& nPos ) +{ + OSL_PRECOND( nPos < m_RecipientList.size( ), "Wrong index" ); + + for( sal_Int32 i = 0; i < aRecipList.getLength( ); i++ ) + { + m_RecipsSmtpAddressList.push_back( + getSmtpPrefixedEmailAddress( aRecipList[i] ) ); + + m_RecipientList[nPos].ulRecipClass = ulRecipClass; + m_RecipientList[nPos].lpszName = + const_cast< LPSTR >( m_RecipsSmtpAddressList.back( ).getStr( ) + LEN_SMTP_PREFIX ); + m_RecipientList[nPos].lpszAddress = + const_cast< LPSTR >( m_RecipsSmtpAddressList.back( ).getStr( ) ); + + nPos++; + } +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void CSmplMailClient::initAttachementList( + const Reference< XSimpleMailMessage >& xSimpleMailMessage ) +{ + Sequence< OUString > aAttachementList = + xSimpleMailMessage->getAttachement( ); + + sal_uInt32 nAttachements = aAttachementList.getLength( ); + + // avoid old entries + m_AttchmtsSysPathList.clear( ); + m_AttachementList.realloc( nAttachements ); + m_AttachementList.clean( ); + + OUString aSysPath; + for ( sal_uInt32 i = 0; i < nAttachements; i++ ) + { + osl::FileBase::RC rc = + osl::FileBase::getSystemPathFromFileURL( + aAttachementList[i], aSysPath ); + + if ( osl::FileBase::RC::E_None != rc ) + throw IllegalArgumentException( + OUString::createFromAscii( " " ), + static_cast< XSimpleMailClient* >( this ), + 1 ); + + m_AttchmtsSysPathList.push_back( + OString( + aSysPath.getStr( ), + aSysPath.getLength( ), + osl_getThreadTextEncoding( ) ) ); + + m_AttachementList[i].lpszFileName = const_cast< LPSTR >( + m_AttchmtsSysPathList.back( ).getStr( ) ); + } +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void CSmplMailClient::initMapiSendMailFlags( sal_Int32 aFlags, FLAGS& aMapiFlags ) +{ + aMapiFlags = MAPI_NEW_SESSION | MAPI_UNICODE; + + if ( !( aFlags & NO_USER_INTERFACE ) ) + aMapiFlags |= MAPI_DIALOG; + + if ( !( aFlags & NO_LOGON_DIALOG ) ) + aMapiFlags |= MAPI_LOGON_UI; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +rtl::OUString CSmplMailClient::getMapiErrorMsg( ULONG ulMapiError ) +{ + LPVOID lpMsgBuff; + DWORD dwRet = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE, + GetModuleHandleA( "mapi32.dll" ), + ulMapiError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast< LPSTR >( &lpMsgBuff ), + 0, + NULL ); + + OUString errMsg; + + if ( dwRet ) + { + errMsg = OUString::createFromAscii( + static_cast< LPSTR >( lpMsgBuff ) ); + LocalFree( lpMsgBuff ); + } + + return errMsg; +}
\ No newline at end of file diff --git a/shell/source/win32/simplemail/smplmailclient.hxx b/shell/source/win32/simplemail/smplmailclient.hxx new file mode 100644 index 000000000000..d8bac6904ef4 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailclient.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * $RCSfile: smplmailclient.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:31 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SMPLMAILCLIENT_HXX_ +#define _SMPLMAILCLIENT_HXX_ + +//_______________________________________________________________________________________________________________________ +// includes of other projects +//_______________________________________________________________________________________________________________________ + +#ifndef _CPPUHELPER_COMPBASE1_HXX_ +#include <cppuhelper/compbase1.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSimpleMailClient.hpp> +#endif + +#ifndef _SIMPLEMAPI_HXX_ +#include "simplemapi.hxx" +#endif + +#ifndef _GENERICBUFFER_HXX_ +#include "genericbuffer.hxx" +#endif + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CSmplMailClient : + public cppu::WeakImplHelper1< com::sun::star::system::XSimpleMailClient > +{ +public: + CSmplMailClient( ); + + //------------------------------------------------ + // + //------------------------------------------------ + + 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); + +private: + void validateParameter( const ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 aFlag ); + void initMapiMessage( const ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage >& xSimpleMailMessage, MapiMessage& aMapiMessage ); + void initMapiSendMailFlags( sal_Int32 aFlags, FLAGS& aMapiFlags ); + + inline + sal_uInt32 calcNumRecipients( + const ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage >& xSimpleMailMessage ); + + inline + void initRecipientList( const ::com::sun::star::uno::Sequence< rtl::OUString >& aRecipList, + ULONG ulRecipClass, + size_t& nPos ); + + inline + void initAttachementList( + const ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailMessage >& xSimpleMailMessage ); + + rtl::OUString getMapiErrorMsg( ULONG ulMapiError ); + +private: + CSimpleMapi* m_pSimpleMapi; + rtl::OString m_Subject; + rtl::OString m_SmtpAddressOriginator; + std::vector< rtl::OString > m_RecipsSmtpAddressList; + std::vector< rtl::OString > m_AttchmtsSysPathList; + MapiRecipDesc m_MsgOriginator; + TGenericBuffer< MapiRecipDesc > m_RecipientList; + TGenericBuffer< MapiFileDesc > m_AttachementList; +}; + +#endif diff --git a/shell/source/win32/simplemail/smplmailentry.cxx b/shell/source/win32/simplemail/smplmailentry.cxx new file mode 100644 index 000000000000..7f5702fa98e1 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailentry.cxx @@ -0,0 +1,186 @@ +/************************************************************************* + * + * $RCSfile: smplmailentry.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:25 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +//----------------------------------------------------------------------- +// includes of other projects +//----------------------------------------------------------------------- + +#ifndef _CPPUHELPER_FACTORY_HXX_ +#include <cppuhelper/factory.hxx> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ +#include <com/sun/star/container/XSet.hpp> +#endif + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _SMPLMAILSUPPL_HXX_ +#include "smplmailsuppl.hxx" +#endif + +//----------------------------------------------------------------------- +// 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 +//----------------------------------------------------------------------- + +#define COMP_SERVICE_NAME "com.sun.star.system.SimpleSystemMail" +#define COMP_IMPL_NAME "com.sun.star.system.SimpleSystemMail" +#define COMP_REGKEY_NAME "/com.sun.star.system.SimpleSystemMail/UNO/SERVICES/com.sun.star.system.SimpleSystemMail" + +//----------------------------------------------------------------------- +// +//----------------------------------------------------------------------- + +namespace +{ + Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) + { + return Reference< XInterface >( static_cast< XSimpleMailClientSupplier* >( new CSmplMailSuppl( ) ) ); + } +} + +//----------------------------------------------------------------------- +// 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; +} + +//----------------------------------------------------------------------- +// +//----------------------------------------------------------------------- + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRetVal = sal_True; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( + OUString::createFromAscii( COMP_REGKEY_NAME ) ); + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE(sal_False, "InvalidRegistryException caught"); + bRetVal = sal_False; + } + } + + return bRetVal; +} + +//---------------------------------------------------------------------- +// component_getFactory +// returns a factory to create XFilePicker-Services +//---------------------------------------------------------------------- + +void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey ) +{ + void* pRet = 0; + + if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, COMP_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString::createFromAscii( COMP_SERVICE_NAME ); + + Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern "C" diff --git a/shell/source/win32/simplemail/smplmailmsg.cxx b/shell/source/win32/simplemail/smplmailmsg.cxx new file mode 100644 index 000000000000..78e031cd4298 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailmsg.cxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * $RCSfile: smplmailmsg.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:43 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#include <osl/file.h> + +#ifndef _SMPLMAILMSG_HXX_ +#include "smplmailmsg.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::uno::Reference; +using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::lang::XServiceInfo; +using com::sun::star::lang::IllegalArgumentException; +using rtl::OUString; +using osl::Mutex; + +using namespace cppu; + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +CSmplMailMsg::CSmplMailMsg( ) +{ +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailMsg::setRecipient( const ::rtl::OUString& aRecipient ) + throw (RuntimeException) +{ + m_aRecipient = aRecipient; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +::rtl::OUString SAL_CALL CSmplMailMsg::getRecipient( ) + throw (RuntimeException) +{ + return m_aRecipient; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailMsg::setCcRecipient( const Sequence< OUString >& aCcRecipient ) + throw (RuntimeException) +{ + m_CcRecipients = aCcRecipient; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +Sequence< OUString > SAL_CALL CSmplMailMsg::getCcRecipient( ) + throw (RuntimeException) +{ + return m_CcRecipients; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailMsg::setBccRecipient( const Sequence< OUString >& aBccRecipient ) + throw (RuntimeException) +{ + m_BccRecipients = aBccRecipient; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +Sequence< OUString > SAL_CALL CSmplMailMsg::getBccRecipient( ) + throw (RuntimeException) +{ + return m_BccRecipients; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailMsg::setOriginator( const OUString& aOriginator ) + throw (RuntimeException) +{ + m_aOriginator = aOriginator; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +OUString SAL_CALL CSmplMailMsg::getOriginator( ) + throw (RuntimeException) +{ + return m_aOriginator; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailMsg::setSubject( const OUString& aSubject ) + throw (RuntimeException) +{ + m_aSubject = aSubject; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +OUString SAL_CALL CSmplMailMsg::getSubject( ) + throw (RuntimeException) +{ + return m_aSubject; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +void SAL_CALL CSmplMailMsg::setAttachement( const Sequence< ::rtl::OUString >& aAttachement ) + throw (IllegalArgumentException, RuntimeException) +{ + m_Attachements = aAttachement; +} + +//------------------------------------------------ +// +//------------------------------------------------ + +Sequence< OUString > SAL_CALL CSmplMailMsg::getAttachement( ) + throw (RuntimeException) +{ + return m_Attachements; +}
\ No newline at end of file diff --git a/shell/source/win32/simplemail/smplmailmsg.hxx b/shell/source/win32/simplemail/smplmailmsg.hxx new file mode 100644 index 000000000000..acb6a5661373 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailmsg.hxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * $RCSfile: smplmailmsg.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:37 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SMPLMAILMSG_HXX_ +#define _SMPLMAILMSG_HXX_ + +//_______________________________________________________________________________________________________________________ +// includes of other projects +//_______________________________________________________________________________________________________________________ + +#ifndef _CPPUHELPER_COMPBASE1_HXX_ +#include <cppuhelper/compbase1.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#endif + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSimpleMailMessage.hpp> +#endif + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CSmplMailMsg : + public cppu::WeakImplHelper1< com::sun::star::system::XSimpleMailMessage > +{ +public: + CSmplMailMsg( ); + + //------------------------------------------------ + // + //------------------------------------------------ + + 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); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getCcRecipient( ) + 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); + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getBccRecipient( ) + 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 getOriginator( ) + 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 getSubject( ) + 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 getAttachement( ) + throw (::com::sun::star::uno::RuntimeException); + +private: + 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_Attachements; +}; + +#endif diff --git a/shell/source/win32/simplemail/smplmailsuppl.cxx b/shell/source/win32/simplemail/smplmailsuppl.cxx new file mode 100644 index 000000000000..62cee02c2b82 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailsuppl.cxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * $RCSfile: smplmailsuppl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:49 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ + +#ifndef _OSL_DIAGNOSE_H_ +#include <osl/diagnose.h> +#endif + +#ifndef _SMPLMAILSUPPL_HXX_ +#include "smplmailsuppl.hxx" +#endif + +#ifndef _SMPLMAILCLIENT_HXX_ +#include "smplmailclient.hxx" +#endif + +//------------------------------------------------------------------------ +// namespace directives +//------------------------------------------------------------------------ + +using com::sun::star::uno::Reference; +using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::lang::XServiceInfo; +using com::sun::star::system::XSimpleMailClientSupplier; +using com::sun::star::system::XSimpleMailClient; +using rtl::OUString; +using osl::Mutex; + +using namespace cppu; + +//------------------------------------------------------------------------ +// defines +//------------------------------------------------------------------------ + +#define COMP_IMPL_NAME "com.sun.star.sys.shell.SimpleSystemMail" + +//------------------------------------------------------------------------ +// helper functions +//------------------------------------------------------------------------ + +namespace // private +{ + Sequence< OUString > SAL_CALL Component_getSupportedServiceNames() + { + Sequence< OUString > aRet(1); + aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SimpleSystemMail"); + return aRet; + } + +} // end private namespace + +//------------------------------------------------- +// +//------------------------------------------------- + +CSmplMailSuppl::CSmplMailSuppl( ) : + WeakComponentImplHelper2< XSimpleMailClientSupplier, XServiceInfo >( m_aMutex ), + m_pSimpleMapi( CSimpleMapi::create( ) ) +{ +} + +//------------------------------------------------- +// +//------------------------------------------------- + +CSmplMailSuppl::~CSmplMailSuppl( ) +{ +} + +//------------------------------------------------- +// +//------------------------------------------------- + +Reference< XSimpleMailClient > SAL_CALL CSmplMailSuppl::querySimpleMailClient( ) + throw (RuntimeException) +{ + // try to determine if a valid mapi mail client + // is available + // if so create and return a new instance of a + // simple mail client + FLAGS flFlag =MAPI_NEW_SESSION;// | MAPI_LOGON_UI; + LHANDLE hSession; + ULONG ulRet = m_pSimpleMapi->MAPILogon( + 0, NULL, NULL, flFlag, 0L, &hSession ); + + Reference< XSimpleMailClient > xSmplMailClient; + + if ( SUCCESS_SUCCESS == ulRet ) + { + xSmplMailClient = + Reference< XSimpleMailClient >( new CSmplMailClient( ) ); + + // logoff again + m_pSimpleMapi->MAPILogoff( hSession, 0, 0, 0 ); + } + + return xSmplMailClient; +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +OUString SAL_CALL CSmplMailSuppl::getImplementationName( ) + throw( RuntimeException ) +{ + return OUString::createFromAscii( COMP_IMPL_NAME ); +} + +// ------------------------------------------------- +// XServiceInfo +// ------------------------------------------------- + +sal_Bool SAL_CALL CSmplMailSuppl::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 CSmplMailSuppl::getSupportedServiceNames( ) + throw( RuntimeException ) +{ + return Component_getSupportedServiceNames(); +} + diff --git a/shell/source/win32/simplemail/smplmailsuppl.hxx b/shell/source/win32/simplemail/smplmailsuppl.hxx new file mode 100644 index 000000000000..e9c317e457a2 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailsuppl.hxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * $RCSfile: smplmailsuppl.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: tra $ $Date: 2001-05-14 08:08:56 $ + * + * 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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SMPLMAILSUPPL_HXX_ +#define _SMPLMAILSUPPL_HXX_ + +//---------------------------------------------------------- +// includes of other projects +//---------------------------------------------------------- + +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#include <cppuhelper/compbase2.hxx> +#endif + +#ifndef _OSL_MUTEX_HXX_ +#include <osl/mutex.hxx> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> +#endif + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSimpleMailClientSupplier.hpp> +#endif + +#ifndef _SIMPLEMAPI_HXX_ +#include "simplemapi.hxx" +#endif + +//---------------------------------------------------------- +// class declaration +//---------------------------------------------------------- + +class CSmplMailSupplBase +{ +protected: + osl::Mutex m_aMutex; +}; + +class CSmplMailSuppl : + public CSmplMailSupplBase, + public cppu::WeakComponentImplHelper2< + com::sun::star::system::XSimpleMailClientSupplier, + com::sun::star::lang::XServiceInfo > +{ +public: + CSmplMailSuppl( ); + ~CSmplMailSuppl( ); + + //------------------------------------------------ + // XSimpleMailClientSupplier + //------------------------------------------------ + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailClient > SAL_CALL querySimpleMailClient( ) + throw (::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); + +private: + CSimpleMapi* m_pSimpleMapi; +}; + +#endif |