1*6b3ad84fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6b3ad84fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6b3ad84fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6b3ad84fSAndrew Rist * distributed with this work for additional information 6*6b3ad84fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6b3ad84fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6b3ad84fSAndrew Rist * "License"); you may not use this file except in compliance 9*6b3ad84fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*6b3ad84fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*6b3ad84fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6b3ad84fSAndrew Rist * software distributed under the License is distributed on an 15*6b3ad84fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6b3ad84fSAndrew Rist * KIND, either express or implied. See the License for the 17*6b3ad84fSAndrew Rist * specific language governing permissions and limitations 18*6b3ad84fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*6b3ad84fSAndrew Rist *************************************************************/ 21*6b3ad84fSAndrew Rist 22*6b3ad84fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include <cppuhelper/factory.hxx> 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "MyProtocolHandler.h" 27cdf0e10cSrcweir #include "MyListener.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir namespace css = ::com::sun::star; 30cdf0e10cSrcweir 31cb2654afSPedro Giffuni #if 0 32cb2654afSPedro Giffuni static void writeInfo(const css::uno::Reference< css::registry::XRegistryKey >& xRegistryKey , 33cb2654afSPedro Giffuni const char* pImplementationName, 34cb2654afSPedro Giffuni const char* pServiceName ) 35cb2654afSPedro Giffuni { 36cb2654afSPedro Giffuni ::rtl::OUStringBuffer sKey(256); 37cb2654afSPedro Giffuni sKey.append (::rtl::OUString::createFromAscii(pImplementationName)); 38cb2654afSPedro Giffuni sKey.appendAscii("/UNO/SERVICES/"); 39cb2654afSPedro Giffuni sKey.append (::rtl::OUString::createFromAscii(pServiceName)); 40cdf0e10cSrcweir 41cb2654afSPedro Giffuni xRegistryKey->createKey(sKey.makeStringAndClear()); 42cb2654afSPedro Giffuni } 43cb2654afSPedro Giffuni #endif 44cdf0e10cSrcweir 45cdf0e10cSrcweir extern "C" 46cdf0e10cSrcweir { 47cdf0e10cSrcweir //================================================================================================== 48cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char** ppEnvTypeName, 49cdf0e10cSrcweir uno_Environment** ppEnv ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cb2654afSPedro Giffuni #if 0 55cb2654afSPedro Giffuni /** 56cb2654afSPedro Giffuni * This method not longer necessary since OOo 3.4 where the component registration was 57cb2654afSPedro Giffuni * was changed to passive component registration. For more details see 58cb2654afSPedro Giffuni * http://wiki.services.openoffice.org/wiki/Passive_Component_Registration 59cb2654afSPedro Giffuni */ 60cdf0e10cSrcweir //================================================================================================== 61cb2654afSPedro Giffuni SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* pServiceManager, 62cb2654afSPedro Giffuni void* pRegistryKey ) 63cb2654afSPedro Giffuni { 64cb2654afSPedro Giffuni if (!pRegistryKey) 65cb2654afSPedro Giffuni return sal_False; 66cdf0e10cSrcweir 67cb2654afSPedro Giffuni try 68cb2654afSPedro Giffuni { 69cb2654afSPedro Giffuni css::uno::Reference< css::registry::XRegistryKey > xKey(reinterpret_cast< css::registry::XRegistryKey* >(pRegistryKey), css::uno::UNO_QUERY); 70cdf0e10cSrcweir 71cb2654afSPedro Giffuni writeInfo( xKey, MYLISTENER_IMPLEMENTATIONNAME , MYLISTENER_SERVICENAME ); 72cb2654afSPedro Giffuni writeInfo( xKey, MYPROTOCOLHANDLER_IMPLEMENTATIONNAME, MYPROTOCOLHANDLER_SERVICENAME ); 73cdf0e10cSrcweir 74cb2654afSPedro Giffuni return sal_True; 75cb2654afSPedro Giffuni } 76cb2654afSPedro Giffuni catch(const css::registry::InvalidRegistryException&) 77cb2654afSPedro Giffuni { OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); } 78cdf0e10cSrcweir 79cb2654afSPedro Giffuni return sal_False; 80cb2654afSPedro Giffuni } 81cb2654afSPedro Giffuni #endif 82cdf0e10cSrcweir 83cdf0e10cSrcweir //================================================================================================== 84cdf0e10cSrcweir SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplName , 85cdf0e10cSrcweir void* pServiceManager, 86cdf0e10cSrcweir void* pRegistryKey ) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if ( !pServiceManager || !pImplName ) 89cdf0e10cSrcweir return 0; 90cdf0e10cSrcweir 91cdf0e10cSrcweir css::uno::Reference< css::lang::XSingleServiceFactory > xFactory ; 92cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (reinterpret_cast< css::lang::XMultiServiceFactory* >(pServiceManager), css::uno::UNO_QUERY); 93cdf0e10cSrcweir ::rtl::OUString sImplName = ::rtl::OUString::createFromAscii(pImplName); 94cdf0e10cSrcweir 95cb2654afSPedro Giffuni if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) ) ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lNames(1); 98cb2654afSPedro Giffuni lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) ); 99cdf0e10cSrcweir xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyListener::st_createInstance, lNames); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir else 102cb2654afSPedro Giffuni if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYPROTOCOLHANDLER_IMPLEMENTATIONNAME ) ) ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lNames(1); 105cb2654afSPedro Giffuni lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) ); 106cdf0e10cSrcweir xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyProtocolHandler_createInstance, lNames); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir if (!xFactory.is()) 110cdf0e10cSrcweir return 0; 111cdf0e10cSrcweir 112cdf0e10cSrcweir xFactory->acquire(); 113cdf0e10cSrcweir return xFactory.get(); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir } // extern C 117