1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: soundhandler.hxx,v $
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 #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
32 #define __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <com/sun/star/lang/XTypeProvider.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
41 #include <com/sun/star/frame/XStatusListener.hpp>
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
44 #include <com/sun/star/media/XPlayer.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include <com/sun/star/util/URL.hpp>
48 #include <com/sun/star/lang/XServiceInfo.hpp>
49 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
51 //_________________________________________________________________________________________________________________
53 //_________________________________________________________________________________________________________________
54 #include <cppuhelper/weak.hxx>
56 #include <vcl/timer.hxx>
57 #include <tools/link.hxx>
58 #include <avmedia/mediawindow.hxx>
59 #include <vos/mutex.hxx>
61 namespace css
= ::com::sun::star
;
63 //_________________________________________________________________________________________________________________
65 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
71 //_________________________________________________________________________________________________________________
73 //_________________________________________________________________________________________________________________
74 // exported definitions
75 //_________________________________________________________________________________________________________________
80 mutable ::vos::OMutex m_aLock
;
83 /*-************************************************************************************************************//**
84 @short handler to detect and play sounds ("wav" and "au" only!)
85 @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds.
86 It doesn't depend from the target platform. But one instance of this class
87 can play one sound at the same time only. Means every new dispatch request will stop the
88 might still running one. So we support one operation/one URL/one listener at the same time
93 *//*-*************************************************************************************************************/
94 class SoundHandler
: // interfaces
95 public css::lang::XTypeProvider
96 , public css::lang::XServiceInfo
97 , public css::frame::XNotifyingDispatch
// => XDispatch
98 , public css::document::XExtendedFilterDetection
100 // Order is neccessary for right initialization!
101 , private ThreadHelpBase
102 , public ::cppu::OWeakObject
104 //-------------------------------------------------------------------------------------------------------------
106 //-------------------------------------------------------------------------------------------------------------
109 //---------------------------------------------------------------------------------------------------------
110 // constructor / destructor
111 //---------------------------------------------------------------------------------------------------------
112 SoundHandler( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
113 virtual ~SoundHandler( );
115 //---------------------------------------------------------------------------------------------------------
116 // XInterface, XTypeProvider, XServiceInfo
117 //---------------------------------------------------------------------------------------------------------
118 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) throw( css::uno::RuntimeException
);
119 virtual void SAL_CALL
acquire() throw();
120 virtual void SAL_CALL
release() throw();
121 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes () throw( css::uno::RuntimeException
);
122 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() throw( css::uno::RuntimeException
);
125 /* interface XServiceInfo */
126 virtual ::rtl::OUString SAL_CALL
getImplementationName ( ) throw( css::uno::RuntimeException
);
127 virtual sal_Bool SAL_CALL
supportsService ( const ::rtl::OUString
& sServiceName
) throw( css::uno::RuntimeException
);
128 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames ( ) throw( css::uno::RuntimeException
);
129 /* Helper for XServiceInfo */
130 static css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
impl_getStaticSupportedServiceNames( );
131 static ::rtl::OUString SAL_CALL
impl_getStaticImplementationName ( );
132 /* Helper for registry */
133 static css::uno::Reference
< css::uno::XInterface
> SAL_CALL
impl_createInstance ( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceManager
) throw( css::uno::Exception
);
134 static css::uno::Reference
< css::lang::XSingleServiceFactory
> SAL_CALL
impl_createFactory ( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xServiceManager
);
135 /* Helper for initialization of service by using own reference! */
136 virtual void SAL_CALL
impl_initService ( );
138 //---------------------------------------------------------------------------------------------------------
139 // XNotifyingDispatch
140 //---------------------------------------------------------------------------------------------------------
141 virtual void SAL_CALL
dispatchWithNotification(const css::util::URL
& aURL
,
142 const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
,
143 const css::uno::Reference
< css::frame::XDispatchResultListener
>& xListener
) throw(css::uno::RuntimeException
);
145 //---------------------------------------------------------------------------------------------------------
147 //---------------------------------------------------------------------------------------------------------
148 virtual void SAL_CALL
dispatch ( const css::util::URL
& aURL
,
149 const css::uno::Sequence
< css::beans::PropertyValue
>& lArguments
) throw( css::uno::RuntimeException
);
151 virtual void SAL_CALL
addStatusListener ( const css::uno::Reference
< css::frame::XStatusListener
>& /*xListener*/ ,
152 const css::util::URL
& /*aURL*/ ) throw( css::uno::RuntimeException
) {};
153 virtual void SAL_CALL
removeStatusListener ( const css::uno::Reference
< css::frame::XStatusListener
>& /*xListener*/ ,
154 const css::util::URL
& /*aURL*/ ) throw( css::uno::RuntimeException
) {};
156 //---------------------------------------------------------------------------------------------------------
157 // XExtendedFilterDetection
158 //---------------------------------------------------------------------------------------------------------
159 virtual ::rtl::OUString SAL_CALL
detect ( css::uno::Sequence
< css::beans::PropertyValue
>& lDescriptor
) throw( css::uno::RuntimeException
);
161 //-------------------------------------------------------------------------------------------------------------
163 //-------------------------------------------------------------------------------------------------------------
166 //-------------------------------------------------------------------------------------------------------------
168 //-------------------------------------------------------------------------------------------------------------
170 DECL_LINK( implts_PlayerNotify
, void* );
172 //-------------------------------------------------------------------------------------------------------------
174 // (should be private everyway!)
175 //-------------------------------------------------------------------------------------------------------------
179 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xFactory
; /// global uno service factory to create new services
180 css::uno::Reference
< css::uno::XInterface
> m_xSelfHold
; /// we must protect us against dieing during async(!) dispatch() call!
181 css::uno::Reference
< css::media::XPlayer
> m_xPlayer
; /// uses avmedia player to play sounds ...
183 css::uno::Reference
< css::frame::XDispatchResultListener
> m_xListener
;
184 Timer m_aUpdateTimer
;
186 }; // class SoundHandler
188 } // namespace avmedia
190 #endif // #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_