1*ae77b8caSAriel Constenla-Haile /**************************************************************
2*ae77b8caSAriel Constenla-Haile  *
3*ae77b8caSAriel Constenla-Haile  * Licensed to the Apache Software Foundation (ASF) under one
4*ae77b8caSAriel Constenla-Haile  * or more contributor license agreements.  See the NOTICE file
5*ae77b8caSAriel Constenla-Haile  * distributed with this work for additional information
6*ae77b8caSAriel Constenla-Haile  * regarding copyright ownership.  The ASF licenses this file
7*ae77b8caSAriel Constenla-Haile  * to you under the Apache License, Version 2.0 (the
8*ae77b8caSAriel Constenla-Haile  * "License"); you may not use this file except in compliance
9*ae77b8caSAriel Constenla-Haile  * with the License.  You may obtain a copy of the License at
10*ae77b8caSAriel Constenla-Haile  *
11*ae77b8caSAriel Constenla-Haile  *   http://www.apache.org/licenses/LICENSE-2.0
12*ae77b8caSAriel Constenla-Haile  *
13*ae77b8caSAriel Constenla-Haile  * Unless required by applicable law or agreed to in writing,
14*ae77b8caSAriel Constenla-Haile  * software distributed under the License is distributed on an
15*ae77b8caSAriel Constenla-Haile  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ae77b8caSAriel Constenla-Haile  * KIND, either express or implied.  See the License for the
17*ae77b8caSAriel Constenla-Haile  * specific language governing permissions and limitations
18*ae77b8caSAriel Constenla-Haile  * under the License.
19*ae77b8caSAriel Constenla-Haile  *
20*ae77b8caSAriel Constenla-Haile  *************************************************************/
21*ae77b8caSAriel Constenla-Haile 
22*ae77b8caSAriel Constenla-Haile // MARKER(update_precomp.py): autogen include statement, do not remove
23*ae77b8caSAriel Constenla-Haile #include "precompiled_shell.hxx"
24*ae77b8caSAriel Constenla-Haile 
25*ae77b8caSAriel Constenla-Haile #include "sysmailprov.hxx"
26*ae77b8caSAriel Constenla-Haile #include "sysmailclient.hxx"
27*ae77b8caSAriel Constenla-Haile #include "sysmapi.hxx"
28*ae77b8caSAriel Constenla-Haile 
29*ae77b8caSAriel Constenla-Haile using com::sun::star::system::XMailClient;
30*ae77b8caSAriel Constenla-Haile using rtl::OUString;
31*ae77b8caSAriel Constenla-Haile 
32*ae77b8caSAriel Constenla-Haile using namespace com::sun::star::uno;
33*ae77b8caSAriel Constenla-Haile 
34*ae77b8caSAriel Constenla-Haile #define COMP_SERVICE_NAME  "com.sun.star.system.SystemMailProvider"
35*ae77b8caSAriel Constenla-Haile #define COMP_IMPL_NAME     "com.sun.star.comp.system.win.SystemMailProvider"
36*ae77b8caSAriel Constenla-Haile 
37*ae77b8caSAriel Constenla-Haile 
38*ae77b8caSAriel Constenla-Haile namespace shell
39*ae77b8caSAriel Constenla-Haile {
40*ae77b8caSAriel Constenla-Haile 
WinSysMailProvider(const Reference<XComponentContext> & xContext)41*ae77b8caSAriel Constenla-Haile WinSysMailProvider::WinSysMailProvider(
42*ae77b8caSAriel Constenla-Haile     const Reference< XComponentContext >& xContext )
43*ae77b8caSAriel Constenla-Haile     : WinSysMailProvider_Base( m_aMutex )
44*ae77b8caSAriel Constenla-Haile     , m_xContext( xContext )
45*ae77b8caSAriel Constenla-Haile {}
46*ae77b8caSAriel Constenla-Haile 
~WinSysMailProvider()47*ae77b8caSAriel Constenla-Haile WinSysMailProvider::~WinSysMailProvider()
48*ae77b8caSAriel Constenla-Haile {
49*ae77b8caSAriel Constenla-Haile     m_xContext.clear();
50*ae77b8caSAriel Constenla-Haile }
51*ae77b8caSAriel Constenla-Haile 
52*ae77b8caSAriel Constenla-Haile Reference<XMailClient> SAL_CALL
queryMailClient()53*ae77b8caSAriel Constenla-Haile WinSysMailProvider::queryMailClient()
54*ae77b8caSAriel Constenla-Haile throw (RuntimeException)
55*ae77b8caSAriel Constenla-Haile {
56*ae77b8caSAriel Constenla-Haile     /* We just try to load the MAPI dll as a test
57*ae77b8caSAriel Constenla-Haile        if a mail client is available */
58*ae77b8caSAriel Constenla-Haile     Reference<XMailClient> xMailClient;
59*ae77b8caSAriel Constenla-Haile     HMODULE handle = LoadLibrary("mapi32.dll");
60*ae77b8caSAriel Constenla-Haile     if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL)) {
61*ae77b8caSAriel Constenla-Haile 
62*ae77b8caSAriel Constenla-Haile         FreeLibrary(handle);
63*ae77b8caSAriel Constenla-Haile         xMailClient = Reference<XMailClient>(
64*ae77b8caSAriel Constenla-Haile                 new WinSysMailClient() );
65*ae77b8caSAriel Constenla-Haile     }
66*ae77b8caSAriel Constenla-Haile 
67*ae77b8caSAriel Constenla-Haile     return xMailClient;
68*ae77b8caSAriel Constenla-Haile }
69*ae77b8caSAriel Constenla-Haile 
70*ae77b8caSAriel Constenla-Haile OUString SAL_CALL
getImplementationName()71*ae77b8caSAriel Constenla-Haile WinSysMailProvider::getImplementationName()
72*ae77b8caSAriel Constenla-Haile throw(RuntimeException)
73*ae77b8caSAriel Constenla-Haile {
74*ae77b8caSAriel Constenla-Haile     return getImplementationName_static();
75*ae77b8caSAriel Constenla-Haile }
76*ae77b8caSAriel Constenla-Haile 
77*ae77b8caSAriel Constenla-Haile sal_Bool SAL_CALL
supportsService(const OUString & ServiceName)78*ae77b8caSAriel Constenla-Haile WinSysMailProvider::supportsService(
79*ae77b8caSAriel Constenla-Haile     const OUString& ServiceName )
80*ae77b8caSAriel Constenla-Haile throw(RuntimeException)
81*ae77b8caSAriel Constenla-Haile {
82*ae77b8caSAriel Constenla-Haile     Sequence <OUString> SupportedServicesNames = getSupportedServiceNames_static();
83*ae77b8caSAriel Constenla-Haile 
84*ae77b8caSAriel Constenla-Haile     for (sal_Int32 n = SupportedServicesNames.getLength(); n--;)
85*ae77b8caSAriel Constenla-Haile         if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
86*ae77b8caSAriel Constenla-Haile             return sal_True;
87*ae77b8caSAriel Constenla-Haile 
88*ae77b8caSAriel Constenla-Haile     return sal_False;
89*ae77b8caSAriel Constenla-Haile }
90*ae77b8caSAriel Constenla-Haile 
91*ae77b8caSAriel Constenla-Haile Sequence< OUString > SAL_CALL
getSupportedServiceNames()92*ae77b8caSAriel Constenla-Haile WinSysMailProvider::getSupportedServiceNames()
93*ae77b8caSAriel Constenla-Haile throw( RuntimeException )
94*ae77b8caSAriel Constenla-Haile {
95*ae77b8caSAriel Constenla-Haile     return getSupportedServiceNames_static();
96*ae77b8caSAriel Constenla-Haile }
97*ae77b8caSAriel Constenla-Haile 
98*ae77b8caSAriel Constenla-Haile Reference< XInterface >
Create(const Reference<XComponentContext> & xContext)99*ae77b8caSAriel Constenla-Haile WinSysMailProvider::Create(
100*ae77b8caSAriel Constenla-Haile     const Reference< XComponentContext > &xContext)
101*ae77b8caSAriel Constenla-Haile {
102*ae77b8caSAriel Constenla-Haile     return Reference< XInterface >(
103*ae77b8caSAriel Constenla-Haile         static_cast< cppu::OWeakObject *>(
104*ae77b8caSAriel Constenla-Haile             new WinSysMailProvider( xContext ) ) );
105*ae77b8caSAriel Constenla-Haile }
106*ae77b8caSAriel Constenla-Haile 
107*ae77b8caSAriel Constenla-Haile OUString
getImplementationName_static()108*ae77b8caSAriel Constenla-Haile WinSysMailProvider::getImplementationName_static()
109*ae77b8caSAriel Constenla-Haile {
110*ae77b8caSAriel Constenla-Haile     return OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_IMPL_NAME ) );
111*ae77b8caSAriel Constenla-Haile }
112*ae77b8caSAriel Constenla-Haile 
113*ae77b8caSAriel Constenla-Haile Sequence< OUString >
getSupportedServiceNames_static()114*ae77b8caSAriel Constenla-Haile WinSysMailProvider::getSupportedServiceNames_static()
115*ae77b8caSAriel Constenla-Haile {
116*ae77b8caSAriel Constenla-Haile     Sequence< OUString > aRet(1);
117*ae77b8caSAriel Constenla-Haile     aRet[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_SERVICE_NAME ) );
118*ae77b8caSAriel Constenla-Haile     return aRet;
119*ae77b8caSAriel Constenla-Haile }
120*ae77b8caSAriel Constenla-Haile 
121*ae77b8caSAriel Constenla-Haile }
122