update dev300-m58
[ooovba.git] / shell / source / cmdmail / cmdmailentry.cxx
blob0934a6e034d3207aeb3274d7132beefb9f542deb
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: cmdmailentry.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"
34 //-----------------------------------------------------------------------
35 // includes of other projects
36 //-----------------------------------------------------------------------
37 #include <cppuhelper/factory.hxx>
38 #include <com/sun/star/container/XSet.hpp>
39 #include <osl/diagnose.h>
40 #include "cmdmailsuppl.hxx"
42 //-----------------------------------------------------------------------
43 // namespace directives
44 //-----------------------------------------------------------------------
46 using namespace ::rtl ;
47 using namespace ::com::sun::star::uno ;
48 using namespace ::com::sun::star::container ;
49 using namespace ::com::sun::star::lang ;
50 using namespace ::com::sun::star::registry ;
51 using namespace ::cppu ;
52 using com::sun::star::system::XSimpleMailClientSupplier;
54 //-----------------------------------------------------------------------
55 // defines
56 //-----------------------------------------------------------------------
58 #define COMP_SERVICE_NAME "com.sun.star.system.SimpleCommandMail"
59 #define COMP_IMPL_NAME "com.sun.star.comp.system.SimpleCommandMail"
60 #define COMP_REGKEY_NAME "/com.sun.star.comp.system.SimpleCommandMail/UNO/SERVICES/com.sun.star.system.SimpleCommandMail"
62 //-----------------------------------------------------------------------
63 //
64 //-----------------------------------------------------------------------
66 namespace
68 Reference< XInterface > SAL_CALL createInstance( const Reference< XComponentContext >& xContext )
70 return Reference< XInterface >( static_cast< XSimpleMailClientSupplier* >( new CmdMailSuppl( xContext ) ) );
74 //-----------------------------------------------------------------------
75 // the 3 important functions which will be exported
76 //-----------------------------------------------------------------------
78 extern "C"
81 //----------------------------------------------------------------------
82 // component_getImplementationEnvironment
83 //----------------------------------------------------------------------
85 void SAL_CALL component_getImplementationEnvironment(
86 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
88 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
91 //-----------------------------------------------------------------------
93 //-----------------------------------------------------------------------
95 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
97 if ( pRegistryKey )
99 try
101 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
102 pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( COMP_REGKEY_NAME ) ) );
103 return sal_True;
105 catch( InvalidRegistryException& )
107 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
111 return sal_False;
114 //----------------------------------------------------------------------
115 // component_getFactory
116 //----------------------------------------------------------------------
118 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* /*pSrvManager*/, uno_Interface* /*pRegistryKey*/ )
120 Reference< XSingleComponentFactory > xFactory;
122 if (0 == ::rtl_str_compare( pImplName, COMP_IMPL_NAME ))
124 OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(COMP_SERVICE_NAME) );
126 xFactory = ::cppu::createSingleComponentFactory(
127 createInstance,
128 OUString( RTL_CONSTASCII_USTRINGPARAM(COMP_IMPL_NAME) ),
129 Sequence< OUString >( &serviceName, 1 ) );
132 if (xFactory.is())
133 xFactory->acquire();
135 return xFactory.get();
138 } // extern "C"