diff options
Diffstat (limited to 'shell/source/win32/simplemail')
-rw-r--r-- | shell/source/win32/simplemail/exports.dxp | 2 | ||||
-rw-r--r-- | shell/source/win32/simplemail/makefile.mk | 87 | ||||
-rw-r--r-- | shell/source/win32/simplemail/senddoc.cxx | 347 | ||||
-rw-r--r-- | shell/source/win32/simplemail/simplemapi.cxx | 97 | ||||
-rw-r--r-- | shell/source/win32/simplemail/simplemapi.hxx | 84 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmail.component | 34 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmail.xml | 37 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.cxx | 289 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailclient.hxx | 54 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailentry.cxx | 117 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.cxx | 179 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailmsg.hxx | 122 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailsuppl.cxx | 107 | ||||
-rw-r--r-- | shell/source/win32/simplemail/smplmailsuppl.hxx | 75 |
14 files changed, 1631 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..f0e1c69934bc --- /dev/null +++ b/shell/source/win32/simplemail/exports.dxp @@ -0,0 +1,2 @@ +component_getImplementationEnvironment +component_getFactory diff --git a/shell/source/win32/simplemail/makefile.mk b/shell/source/win32/simplemail/makefile.mk new file mode 100644 index 000000000000..abd35e408e2d --- /dev/null +++ b/shell/source/win32/simplemail/makefile.mk @@ -0,0 +1,87 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. +PRJNAME=shell +TARGET=smplmail +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +SLOFILES=$(SLO)$/smplmailentry.obj\ + $(SLO)$/smplmailmsg.obj\ + $(SLO)$/smplmailclient.obj\ + $(SLO)$/smplmailsuppl.obj\ + $(SLO)$/simplemapi.obj + +SHL1TARGET=$(TARGET).uno + +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + $(ADVAPI32LIB) + +SHL1IMPLIB=i$(SHL1TARGET) + +SHL1OBJS=$(SLOFILES) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- mapimailer -------------------------------------------------------- + +TARGETTYPE=CUI + +OBJFILES= $(OBJ)$/senddoc.obj\ + $(OBJ)$/simplemapi.obj + +APP1TARGET=senddoc +APP1OBJS=$(OBJFILES) +APP1STDLIBS=$(KERNEL32LIB)\ + $(SALLIB) + +APP1DEF=$(MISC)$/$(APP1TARGET).def + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + +ALLTAR : $(MISC)/smplmail.component + +$(MISC)/smplmail.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + smplmail.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt smplmail.component diff --git a/shell/source/win32/simplemail/senddoc.cxx b/shell/source/win32/simplemail/senddoc.cxx new file mode 100644 index 000000000000..c8ac40799cea --- /dev/null +++ b/shell/source/win32/simplemail/senddoc.cxx @@ -0,0 +1,347 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" +#include <osl/diagnose.h> + +#ifndef _RTL_STRING_HXX_ +//#include <rtl/string.hxx> +#endif +#include "simplemapi.hxx" + +#define WIN32_LEAN_AND_MEAN +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include <windows.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif +#include <tchar.h> + +#include <iostream> +#include <vector> +#include <sstream> +#include <stdexcept> + +#if OSL_DEBUG_LEVEL > 2 + void dumpParameter(); +#endif + +typedef std::vector<std::string> StringList_t; +typedef StringList_t::const_iterator StringListIterator_t; +typedef std::vector<MapiRecipDesc> MapiRecipientList_t; +typedef std::vector<MapiFileDesc> MapiAttachmentList_t; + +const int LEN_SMTP_PREFIX = 5; // "SMTP:" + +namespace /* private */ +{ + std::string gFrom; + std::string gSubject; + std::string gBody; + StringList_t gTo; + StringList_t gCc; + StringList_t gBcc; + StringList_t gAttachments; + int gMapiFlags = 0; +} + +/** + Add a prefix to an email address. MAPI requires that that + email addresses have an 'SMTP:' prefix. + + @param aEmailAddress + [in] the email address. + + @param aPrefix + [in] the prefix to be added to the email address. + + @returns + the email address prefixed with the specified prefix. +*/ +inline std::string prefixEmailAddress( + const std::string& aEmailAddress, + const std::string& aPrefix = "SMTP:") +{ + return (aPrefix + aEmailAddress); +} + +/** @internal */ +void addRecipient( + ULONG recipClass, + const std::string& recipAddress, + MapiRecipientList_t* pMapiRecipientList) +{ + MapiRecipDesc mrd; + ZeroMemory(&mrd, sizeof(mrd)); + + mrd.ulRecipClass = recipClass; + mrd.lpszName = const_cast<char*>(recipAddress.c_str()) + LEN_SMTP_PREFIX; + mrd.lpszAddress = const_cast<char*>(recipAddress.c_str()); + pMapiRecipientList->push_back(mrd); +} + +/** @internal */ +void initRecipientList(MapiRecipientList_t* pMapiRecipientList) +{ + OSL_ASSERT(pMapiRecipientList->size() == 0); + + // add to recipients + StringListIterator_t iter = gTo.begin(); + StringListIterator_t iter_end = gTo.end(); + for (; iter != iter_end; ++iter) + addRecipient(MAPI_TO, *iter, pMapiRecipientList); + + // add cc recipients + iter = gCc.begin(); + iter_end = gCc.end(); + for (; iter != iter_end; ++iter) + addRecipient(MAPI_CC, *iter, pMapiRecipientList); + + // add bcc recipients + iter = gBcc.begin(); + iter_end = gBcc.end(); + for (; iter != iter_end; ++iter) + addRecipient(MAPI_BCC, *iter, pMapiRecipientList); +} + +/** @internal */ +void initAttachementList(MapiAttachmentList_t* pMapiAttachmentList) +{ + OSL_ASSERT(pMapiAttachmentList->size() == 0); + + StringListIterator_t iter = gAttachments.begin(); + StringListIterator_t iter_end = gAttachments.end(); + for (/**/; iter != iter_end; ++iter) + { + MapiFileDesc mfd; + ZeroMemory(&mfd, sizeof(mfd)); + mfd.lpszPathName = const_cast<char*>(iter->c_str()); + mfd.nPosition = sal::static_int_cast<ULONG>(-1); + pMapiAttachmentList->push_back(mfd); + } +} + +/** @internal */ +void initMapiOriginator(MapiRecipDesc* pMapiOriginator) +{ + ZeroMemory(pMapiOriginator, sizeof(MapiRecipDesc)); + + pMapiOriginator->ulRecipClass = MAPI_ORIG; + pMapiOriginator->lpszName = ""; + pMapiOriginator->lpszAddress = const_cast<char*>(gFrom.c_str()); +} + +/** @internal */ +void initMapiMessage( + MapiRecipDesc* aMapiOriginator, + MapiRecipientList_t& aMapiRecipientList, + MapiAttachmentList_t& aMapiAttachmentList, + MapiMessage* pMapiMessage) +{ + ZeroMemory(pMapiMessage, sizeof(MapiMessage)); + + pMapiMessage->lpszSubject = const_cast<char*>(gSubject.c_str()); + pMapiMessage->lpszNoteText = (gBody.length() ? const_cast<char*>(gBody.c_str()) : NULL); + pMapiMessage->lpOriginator = aMapiOriginator; + pMapiMessage->lpRecips = &aMapiRecipientList[0]; + pMapiMessage->nRecipCount = aMapiRecipientList.size(); + pMapiMessage->lpFiles = &aMapiAttachmentList[0]; + pMapiMessage->nFileCount = aMapiAttachmentList.size(); +} + +char* KnownParameter[] = +{ + "--to", + "--cc", + "--bcc", + "--from", + "--subject", + "--body", + "--attach", + "--mapi-dialog", + "--mapi-logon-ui" +}; + +const size_t nKnownParameter = (sizeof(KnownParameter)/sizeof(KnownParameter[0])); + +/** @internal */ +bool isKnownParameter(const char* aParameterName) +{ + for (size_t i = 0; i < nKnownParameter; i++) + if (_tcsicmp(aParameterName, KnownParameter[i]) == 0) + return true; + + return false; +} + +/** @internal */ +void initParameter(int argc, char* argv[]) +{ + for (int i = 1; i < argc; i++) + { + if (!isKnownParameter(argv[i])) + { + OSL_ENSURE(false, "Wrong parameter received"); + continue; + } + + if ((_tcsicmp(argv[i], TEXT("--mapi-dialog")) == 0)) + { + gMapiFlags |= MAPI_DIALOG; + } + else if ((_tcsicmp(argv[i], TEXT("--mapi-logon-ui")) == 0)) + { + gMapiFlags |= MAPI_LOGON_UI; + } + else if ((i+1) < argc) // is the value of a parameter available too? + { + if (_tcsicmp(argv[i], TEXT("--to")) == 0) + gTo.push_back(prefixEmailAddress(argv[i+1])); + else if (_tcsicmp(argv[i], TEXT("--cc")) == 0) + gCc.push_back(prefixEmailAddress(argv[i+1])); + else if (_tcsicmp(argv[i], TEXT("--bcc")) == 0) + gBcc.push_back(prefixEmailAddress(argv[i+1])); + else if (_tcsicmp(argv[i], TEXT("--from")) == 0) + gFrom = prefixEmailAddress(argv[i+1]); + else if (_tcsicmp(argv[i], TEXT("--subject")) == 0) + gSubject = argv[i+1]; + else if (_tcsicmp(argv[i], TEXT("--body")) == 0) + gBody = argv[i+1]; + else if ((_tcsicmp(argv[i], TEXT("--attach")) == 0)) + gAttachments.push_back(argv[i+1]); + + i++; + } + } +} + +/** + Main. + NOTE: Because this is program only serves implementation + purposes and should not be used by any end user the + parameter checking is very limited. Every unknown parameter + will be ignored. +*/ +int main(int argc, char* argv[]) +{ + //MessageBox(NULL, "Debug", "Debug", MB_OK); + + initParameter(argc, argv); + +#if OSL_DEBUG_LEVEL > 2 + dumpParameter(); +#endif + + ULONG ulRet = MAPI_E_FAILURE; + + try + { + CSimpleMapi mapi; + + // #93007# we have to set the flag MAPI_NEW_SESSION, + // because in the case Outlook xxx (not Outlook Express!) + // is installed as Exchange and Mail Client a Profile + // selection dialog must appear because we specify no + // profile name, so the user has to specify a profile + FLAGS flFlag = MAPI_NEW_SESSION | MAPI_LOGON_UI; + LHANDLE hSession; + ulRet = mapi.MAPILogon(0, NULL, NULL, flFlag, 0L, &hSession); + + if (ulRet == SUCCESS_SUCCESS) + { + MapiRecipDesc mapiOriginator; + MapiRecipientList_t mapiRecipientList; + MapiAttachmentList_t mapiAttachmentList; + MapiMessage mapiMsg; + + initMapiOriginator(&mapiOriginator); + initRecipientList(&mapiRecipientList); + initAttachementList(&mapiAttachmentList); + initMapiMessage((gFrom.length() ? &mapiOriginator : NULL), mapiRecipientList, mapiAttachmentList, &mapiMsg); + + ulRet = mapi.MAPISendMail(hSession, 0, &mapiMsg, gMapiFlags, 0); + + mapi.MAPILogoff(hSession, 0, 0, 0); + } + } + catch (const std::runtime_error& + #if OSL_DEBUG_LEVEL > 0 + ex + #endif + ) + { + OSL_ENSURE(false, ex.what()); + } + return ulRet; +} + +#if OSL_DEBUG_LEVEL > 2 + void dumpParameter() + { + std::ostringstream oss; + + if (gFrom.length() > 0) + oss << "--from" << " " << gFrom << std::endl; + + if (gSubject.length() > 0) + oss << "--subject" << " " << gSubject << std::endl; + + if (gBody.length() > 0) + oss << "--body" << " " << gBody << std::endl; + + StringListIterator_t iter = gTo.begin(); + StringListIterator_t iter_end = gTo.end(); + for (/**/;iter != iter_end; ++iter) + oss << "--to" << " " << *iter << std::endl; + + iter = gCc.begin(); + iter_end = gCc.end(); + for (/**/;iter != iter_end; ++iter) + oss << "--cc" << " " << *iter << std::endl; + + iter = gBcc.begin(); + iter_end = gBcc.end(); + for (/**/;iter != iter_end; ++iter) + oss << "--bcc" << " " << *iter << std::endl; + + iter = gAttachments.begin(); + iter_end = gAttachments.end(); + for (/**/;iter != iter_end; ++iter) + oss << "--attach" << " " << *iter << std::endl; + + if (gMapiFlags & MAPI_DIALOG) + oss << "--mapi-dialog" << std::endl; + + if (gMapiFlags & MAPI_LOGON_UI) + oss << "--mapi-logon-ui" << std::endl; + + MessageBox(NULL, oss.str().c_str(), "Arguments", MB_OK | MB_ICONINFORMATION); + } +#endif diff --git a/shell/source/win32/simplemail/simplemapi.cxx b/shell/source/win32/simplemail/simplemapi.cxx new file mode 100644 index 000000000000..faf383f580aa --- /dev/null +++ b/shell/source/win32/simplemail/simplemapi.cxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" +#include "simplemapi.hxx" + +#include <string> +#include <stdexcept> + +CSimpleMapi::CSimpleMapi() : + m_lpfnMapiLogon(NULL), + m_lpfnMapiLogoff(NULL), + m_lpfnMapiSendMail(NULL) +{ + m_hMapiDll = LoadLibrary("mapi32.dll"); + if ((m_hMapiDll == INVALID_HANDLE_VALUE) || (m_hMapiDll == NULL)) + throw std::runtime_error("Couldn't load MAPI library"); + + m_lpfnMapiLogon = reinterpret_cast<LPMAPILOGON>(GetProcAddress(m_hMapiDll, "MAPILogon")); + if (!m_lpfnMapiLogon) + throw std::runtime_error("Couldn't find method MAPILogon"); + + m_lpfnMapiLogoff = reinterpret_cast<LPMAPILOGOFF>(GetProcAddress(m_hMapiDll, "MAPILogoff")); + if (!m_lpfnMapiLogoff) + throw std::runtime_error("Couldn't find method MAPILogoff"); + + m_lpfnMapiSendMail = reinterpret_cast<LPMAPISENDMAIL>(GetProcAddress(m_hMapiDll, "MAPISendMail")); + if (!m_lpfnMapiSendMail) + throw std::runtime_error("Couldn't find method MAPISendMail"); +} + +CSimpleMapi::~CSimpleMapi() +{ + FreeLibrary(m_hMapiDll); +} + +ULONG CSimpleMapi::MAPILogon( + ULONG ulUIParam, + LPTSTR lpszProfileName, + LPTSTR lpszPassword, + FLAGS flFlags, + ULONG ulReserved, + LPLHANDLE lplhSession ) +{ + return m_lpfnMapiLogon( + ulUIParam, + lpszProfileName, + lpszPassword, + flFlags, + ulReserved, + lplhSession ); +} + +ULONG CSimpleMapi::MAPILogoff( + LHANDLE lhSession, + ULONG ulUIParam, + FLAGS flFlags, + ULONG ulReserved ) +{ + return m_lpfnMapiLogoff(lhSession, ulUIParam, flFlags, ulReserved); +} + +ULONG CSimpleMapi::MAPISendMail( + LHANDLE lhSession, + ULONG ulUIParam, + lpMapiMessage lpMessage, + FLAGS flFlags, + ULONG ulReserved ) +{ + return m_lpfnMapiSendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved); +} + diff --git a/shell/source/win32/simplemail/simplemapi.hxx b/shell/source/win32/simplemail/simplemapi.hxx new file mode 100644 index 000000000000..e4feb3524ed3 --- /dev/null +++ b/shell/source/win32/simplemail/simplemapi.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_SIMPLEMAPI_HXX +#define INCLUDED_SIMPLEMAPI_HXX + +#define WIN32_LEAN_AND_MEAN +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include <windows.h> +#include <mapi.h> +#ifndef __MINGW32__ +#include <mapix.h> +#endif +#if defined _MSC_VER +#pragma warning(pop) +#endif + +class CSimpleMapi +{ +public: + /** + @throws std::runtime_error + if either the mapi32.dll could not be loaded at all + or necessary function exports are missing + */ + CSimpleMapi(); // throws std::runtime_error; + + ~CSimpleMapi(); + + 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: + HMODULE m_hMapiDll; + LPMAPILOGON m_lpfnMapiLogon; + LPMAPILOGOFF m_lpfnMapiLogoff; + LPMAPISENDMAIL m_lpfnMapiSendMail; +}; + +#endif diff --git a/shell/source/win32/simplemail/smplmail.component b/shell/source/win32/simplemail/smplmail.component new file mode 100644 index 000000000000..59246c6d1551 --- /dev/null +++ b/shell/source/win32/simplemail/smplmail.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.system.SimpleSystemMail"> + <service name="com.sun.star.system.SimpleSystemMail"/> + </implementation> +</component> 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..49c546e5721d --- /dev/null +++ b/shell/source/win32/simplemail/smplmailclient.cxx @@ -0,0 +1,289 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" +#include <osl/diagnose.h> +#include <osl/process.h> +#include <rtl/bootstrap.hxx> +#include "smplmailclient.hxx" +#include "smplmailmsg.hxx" +#include <com/sun/star/system/SimpleMailClientFlags.hpp> +#include <osl/file.hxx> + +#define WIN32_LEAN_AND_MEAN +#if defined _MSC_VER +#pragma warning(push, 1) +#endif +#include <windows.h> +#include <mapi.h> +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#include <process.h> +#include <vector> + +using css::uno::Reference; +using css::uno::Exception; +using css::uno::RuntimeException; +using css::uno::Sequence; +using css::lang::IllegalArgumentException; + +using css::system::XSimpleMailClient; +using css::system::XSimpleMailMessage; +using css::system::SimpleMailClientFlags::NO_USER_INTERFACE; +using css::system::SimpleMailClientFlags::NO_LOGON_DIALOG; + +typedef std::vector<rtl::OUString> StringList_t; +typedef StringList_t::const_iterator StringListIterator_t; + +const rtl::OUString TO = rtl::OUString::createFromAscii("--to"); +const rtl::OUString CC = rtl::OUString::createFromAscii("--cc"); +const rtl::OUString BCC = rtl::OUString::createFromAscii("--bcc"); +const rtl::OUString FROM = rtl::OUString::createFromAscii("--from"); +const rtl::OUString SUBJECT = rtl::OUString::createFromAscii("--subject"); +const rtl::OUString BODY = rtl::OUString::createFromAscii("--body"); +const rtl::OUString ATTACH = rtl::OUString::createFromAscii("--attach"); +const rtl::OUString FLAG_MAPI_DIALOG = rtl::OUString::createFromAscii("--mapi-dialog"); +const rtl::OUString FLAG_MAPI_LOGON_UI = rtl::OUString::createFromAscii("--mapi-logon-ui"); + +namespace /* private */ +{ + /** @internal + look if an alternative program is configured + which should be used as senddoc executable */ + rtl::OUString getAlternativeSenddocUrl() + { + rtl::OUString altSenddocUrl; + HKEY hkey; + LONG lret = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\OpenOffice.org\\SendAsEMailClient", &hkey); + if (lret == ERROR_SUCCESS) + { + wchar_t buff[MAX_PATH]; + LONG sz = sizeof(buff); + lret = RegQueryValueW(hkey, NULL, buff, &sz); + if (lret == ERROR_SUCCESS) + { + osl::FileBase::getFileURLFromSystemPath(reinterpret_cast<const sal_Unicode*>(buff), altSenddocUrl); + } + RegCloseKey(hkey); + } + return altSenddocUrl; + } + + /** + Returns the absolute file Url of the senddoc executable. + + @returns + the absolute file Url of the senddoc executable. In case + of an error an empty string will be returned. + */ + rtl::OUString getSenddocUrl() + { + rtl::OUString senddocUrl = getAlternativeSenddocUrl(); + + if (senddocUrl.getLength() == 0) + { + senddocUrl = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "$OOO_BASE_DIR/program/senddoc.exe")); + rtl::Bootstrap::expandMacros(senddocUrl); //TODO: detect failure + } + return senddocUrl; + } + + /** + Execute Senddoc.exe which a MAPI wrapper. + + @param rCommandArgs + [in] the arguments to be passed to Senddoc.exe + + @returns + <TRUE/> on success. + */ + bool executeSenddoc(const StringList_t& rCommandArgs) + { + rtl::OUString senddocUrl = getSenddocUrl(); + if (senddocUrl.getLength() == 0) + return false; + + oslProcess proc; + oslProcessError err = osl_Process_E_Unknown; + + /* for efficiency reasons we are using a 'bad' cast here + as a vector or rtl::OUStrings is nothing else than + an array of pointers to rtl_uString's */ + err = osl_executeProcess( + senddocUrl.pData, + (rtl_uString**)&rCommandArgs[0], + rCommandArgs.size(), + osl_Process_WAIT | osl_Process_DETACHED, + NULL, + NULL, + NULL, + 0, + &proc); + + if (err != osl_Process_E_None) + return false; + + oslProcessInfo procInfo; + procInfo.Size = sizeof(oslProcessInfo); + osl_getProcessInfo(proc, osl_Process_EXITCODE, &procInfo); + osl_freeProcessHandle(proc); + return (procInfo.Code == SUCCESS_SUCCESS); + } +} // namespace private + +Reference<XSimpleMailMessage> SAL_CALL CSmplMailClient::createSimpleMailMessage() + throw (RuntimeException) +{ + return Reference<XSimpleMailMessage>(new CSmplMailMsg()); +} + +/** + Assemble a command line for SendDoc.exe out of the members + of the supplied SimpleMailMessage. + + @param xSimpleMailMessage + [in] the mail message. + + @param aFlags + [in] different flags to be used with the simple mail service. + + @param rCommandArgs + [in|out] a buffer for the command line arguments. The buffer + is assumed to be empty. + + @throws com::sun::star::lang::IllegalArgumentException + if an invalid file URL has been detected in the attachment list. +*/ +void CSmplMailClient::assembleCommandLine( + const Reference<XSimpleMailMessage>& xSimpleMailMessage, + sal_Int32 aFlag, StringList_t& rCommandArgs) +{ + OSL_ENSURE(rCommandArgs.size() == 0, "Provided command argument buffer not empty"); + + rtl::OUString to = xSimpleMailMessage->getRecipient(); + if (to.getLength() > 0) + { + rCommandArgs.push_back(TO); + rCommandArgs.push_back(to); + } + + Sequence<rtl::OUString> ccRecipients = xSimpleMailMessage->getCcRecipient(); + for (int i = 0; i < ccRecipients.getLength(); i++) + { + rCommandArgs.push_back(CC); + rCommandArgs.push_back(ccRecipients[i]); + } + + Sequence<rtl::OUString> bccRecipients = xSimpleMailMessage->getBccRecipient(); + for (int i = 0; i < bccRecipients.getLength(); i++) + { + rCommandArgs.push_back(BCC); + rCommandArgs.push_back(bccRecipients[i]); + } + + rtl::OUString from = xSimpleMailMessage->getOriginator(); + if (from.getLength() > 0) + { + rCommandArgs.push_back(FROM); + rCommandArgs.push_back(from); + } + + rtl::OUString subject = xSimpleMailMessage->getSubject(); + if (subject.getLength() > 0) + { + rCommandArgs.push_back(SUBJECT); + rCommandArgs.push_back(subject); + } + + Sequence<rtl::OUString> attachments = xSimpleMailMessage->getAttachement(); + for (int i = 0; i < attachments.getLength(); i++) + { + rtl::OUString sysPath; + osl::FileBase::RC err = osl::FileBase::getSystemPathFromFileURL(attachments[i], sysPath); + if (err != osl::FileBase::E_None) + throw IllegalArgumentException( + rtl::OUString::createFromAscii("Invalid attachment file URL"), + static_cast<XSimpleMailClient*>(this), + 1); + + rCommandArgs.push_back(ATTACH); + rCommandArgs.push_back(sysPath); + } + + if (!(aFlag & NO_USER_INTERFACE)) + rCommandArgs.push_back(FLAG_MAPI_DIALOG); + + if (!(aFlag & NO_LOGON_DIALOG)) + rCommandArgs.push_back(FLAG_MAPI_LOGON_UI); +} + +void SAL_CALL CSmplMailClient::sendSimpleMailMessage( + const Reference<XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag) + throw (IllegalArgumentException, Exception, RuntimeException) +{ + validateParameter(xSimpleMailMessage, aFlag); + + StringList_t senddocParams; + assembleCommandLine(xSimpleMailMessage, aFlag, senddocParams); + + if (!executeSenddoc(senddocParams)) + throw Exception( + rtl::OUString::createFromAscii("Send email failed"), + static_cast<XSimpleMailClient*>(this)); +} + +void CSmplMailClient::validateParameter( + const Reference<XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag ) +{ + if (!xSimpleMailMessage.is()) + throw IllegalArgumentException( + rtl::OUString::createFromAscii("Empty mail message reference"), + static_cast<XSimpleMailClient*>(this), + 1); + + // #93077# + OSL_ENSURE(!(aFlag & NO_LOGON_DIALOG), "Flag NO_LOGON_DIALOG has currently no effect"); + + // check the flags, the allowed range is 0 - (2^n - 1) + if (aFlag < 0 || aFlag > 3) + throw IllegalArgumentException( + rtl::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( + rtl::OUString::createFromAscii("No recipient specified"), + static_cast<XSimpleMailClient*>(this), + 1); +} diff --git a/shell/source/win32/simplemail/smplmailclient.hxx b/shell/source/win32/simplemail/smplmailclient.hxx new file mode 100644 index 000000000000..5457dffbffd9 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailclient.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SMPLMAILCLIENT_HXX_ +#define _SMPLMAILCLIENT_HXX_ + +#include <cppuhelper/compbase1.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSimpleMailClient.hpp> +#endif + +namespace css = ::com::sun::star; + +class CSmplMailClient : public cppu::WeakImplHelper1<css::system::XSimpleMailClient> +{ +public: + virtual css::uno::Reference<css::system::XSimpleMailMessage> SAL_CALL createSimpleMailMessage() + throw (css::uno::RuntimeException); + + virtual void SAL_CALL sendSimpleMailMessage(const css::uno::Reference<css::system::XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag) + throw (css::lang::IllegalArgumentException, css::uno::Exception, css::uno::RuntimeException); + +private: + void validateParameter(const css::uno::Reference<css::system::XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag); + void assembleCommandLine(const css::uno::Reference<css::system::XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag, std::vector<rtl::OUString>& rCommandArgs); +}; + +#endif diff --git a/shell/source/win32/simplemail/smplmailentry.cxx b/shell/source/win32/simplemail/smplmailentry.cxx new file mode 100644 index 000000000000..9970baa28122 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailentry.cxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// 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 "smplmailsuppl.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 +//----------------------------------------------------------------------- + +#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 >& ) + { + 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 ** ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +//---------------------------------------------------------------------- +// 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..088d84a050ad --- /dev/null +++ b/shell/source/win32/simplemail/smplmailmsg.cxx @@ -0,0 +1,179 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" + +//------------------------------------------------------------------------ +// includes +//------------------------------------------------------------------------ +#include <osl/diagnose.h> + +#include <osl/file.h> +#include "smplmailmsg.hxx" + +//------------------------------------------------------------------------ +// 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; +} diff --git a/shell/source/win32/simplemail/smplmailmsg.hxx b/shell/source/win32/simplemail/smplmailmsg.hxx new file mode 100644 index 000000000000..caeb0710de90 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailmsg.hxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SMPLMAILMSG_HXX_ +#define _SMPLMAILMSG_HXX_ + +//_______________________________________________________________________________________________________________________ +// includes of other projects +//_______________________________________________________________________________________________________________________ + +#include <cppuhelper/compbase1.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> + +#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..375da5b07856 --- /dev/null +++ b/shell/source/win32/simplemail/smplmailsuppl.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_shell.hxx" +#include <osl/diagnose.h> +#include "smplmailsuppl.hxx" +#include "smplmailclient.hxx" + +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; + +#define COMP_IMPL_NAME "com.sun.star.sys.shell.SimpleSystemMail" + +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) +{ +} + +CSmplMailSuppl::~CSmplMailSuppl() +{ +} + +Reference<XSimpleMailClient> SAL_CALL CSmplMailSuppl::querySimpleMailClient() + throw (RuntimeException) +{ + /* We just try to load the MAPI dll as a test + if a mail client is available */ + Reference<XSimpleMailClient> xSmplMailClient; + HMODULE handle = LoadLibrary("mapi32.dll"); + if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL)) + { + FreeLibrary(handle); + xSmplMailClient = Reference<XSimpleMailClient>(new CSmplMailClient()); + } + return xSmplMailClient; +} + +// XServiceInfo + +OUString SAL_CALL CSmplMailSuppl::getImplementationName() + throw(RuntimeException) +{ + return OUString::createFromAscii(COMP_IMPL_NAME); +} + +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; +} + +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..e945556c6f8b --- /dev/null +++ b/shell/source/win32/simplemail/smplmailsuppl.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SMPLMAILSUPPL_HXX_ +#define _SMPLMAILSUPPL_HXX_ + +#include <cppuhelper/compbase2.hxx> +#include <osl/mutex.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_ +#include <com/sun/star/system/XSimpleMailClientSupplier.hpp> +#endif + +#ifndef _SIMPLEMAPI_HXX_ +#include "simplemapi.hxx" +#endif + + +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); +}; + +#endif |