update dev300-m58
[ooovba.git] / shell / source / win32 / simplemail / smplmailsuppl.cxx
blobb81c91e438ea91488dd7f6eb08c6b473b5cb36c1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: smplmailsuppl.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
33 #include <osl/diagnose.h>
34 #include "smplmailsuppl.hxx"
35 #include "smplmailclient.hxx"
37 using com::sun::star::uno::Reference;
38 using com::sun::star::uno::RuntimeException;
39 using com::sun::star::uno::Sequence;
40 using com::sun::star::lang::XServiceInfo;
41 using com::sun::star::system::XSimpleMailClientSupplier;
42 using com::sun::star::system::XSimpleMailClient;
43 using rtl::OUString;
44 using osl::Mutex;
46 using namespace cppu;
48 #define COMP_IMPL_NAME "com.sun.star.sys.shell.SimpleSystemMail"
50 namespace // private
52 Sequence< OUString > SAL_CALL Component_getSupportedServiceNames()
54 Sequence< OUString > aRet(1);
55 aRet[0] = OUString::createFromAscii("com.sun.star.sys.shell.SimpleSystemMail");
56 return aRet;
59 } // end private namespace
61 CSmplMailSuppl::CSmplMailSuppl() :
62 WeakComponentImplHelper2<XSimpleMailClientSupplier, XServiceInfo>(m_aMutex)
66 CSmplMailSuppl::~CSmplMailSuppl()
70 Reference<XSimpleMailClient> SAL_CALL CSmplMailSuppl::querySimpleMailClient()
71 throw (RuntimeException)
73 /* We just try to load the MAPI dll as a test
74 if a mail client is available */
75 Reference<XSimpleMailClient> xSmplMailClient;
76 HMODULE handle = LoadLibrary("mapi32.dll");
77 if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL))
79 FreeLibrary(handle);
80 xSmplMailClient = Reference<XSimpleMailClient>(new CSmplMailClient());
82 return xSmplMailClient;
85 // XServiceInfo
87 OUString SAL_CALL CSmplMailSuppl::getImplementationName()
88 throw(RuntimeException)
90 return OUString::createFromAscii(COMP_IMPL_NAME);
93 sal_Bool SAL_CALL CSmplMailSuppl::supportsService(const OUString& ServiceName)
94 throw(RuntimeException)
96 Sequence <OUString> SupportedServicesNames = Component_getSupportedServiceNames();
98 for (sal_Int32 n = SupportedServicesNames.getLength(); n--;)
99 if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
100 return sal_True;
102 return sal_False;
105 Sequence<OUString> SAL_CALL CSmplMailSuppl::getSupportedServiceNames()
106 throw(RuntimeException)
108 return Component_getSupportedServiceNames();