1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
29*cdf0e10cSrcweir #define __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	interface includes
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/document/XExtendedFilterDetection.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/media/XPlayer.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49*cdf0e10cSrcweir //	other includes
50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include <vcl/timer.hxx>
54*cdf0e10cSrcweir #include <tools/link.hxx>
55*cdf0e10cSrcweir #include <avmedia/mediawindow.hxx>
56*cdf0e10cSrcweir #include <vos/mutex.hxx>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir namespace css = ::com::sun::star;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61*cdf0e10cSrcweir //	namespace
62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir namespace avmedia{
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
67*cdf0e10cSrcweir //	exported const
68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
71*cdf0e10cSrcweir //	exported definitions
72*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir struct ThreadHelpBase
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir     public:
77*cdf0e10cSrcweir         mutable ::vos::OMutex m_aLock;
78*cdf0e10cSrcweir };
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir /*-************************************************************************************************************//**
81*cdf0e10cSrcweir     @short          handler to detect and play sounds ("wav" and "au" only!)
82*cdf0e10cSrcweir     @descr          Register this implementation as a content handler to detect and/or play wav- and au-sounds.
83*cdf0e10cSrcweir                     It doesn't depend from the target platform. But one instance of this class
84*cdf0e10cSrcweir                     can play one sound at the same time only. Means every new dispatch request will stop the
85*cdf0e10cSrcweir                     might still running one. So we support one operation/one URL/one listener at the same time
86*cdf0e10cSrcweir                     only.
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     @devstatus      ready
89*cdf0e10cSrcweir     @threadsafe     yes
90*cdf0e10cSrcweir *//*-*************************************************************************************************************/
91*cdf0e10cSrcweir class SoundHandler  :   // interfaces
92*cdf0e10cSrcweir                         public  css::lang::XTypeProvider
93*cdf0e10cSrcweir                     ,   public  css::lang::XServiceInfo
94*cdf0e10cSrcweir                     ,   public  css::frame::XNotifyingDispatch // => XDispatch
95*cdf0e10cSrcweir                     ,   public  css::document::XExtendedFilterDetection
96*cdf0e10cSrcweir                         // baseclasses
97*cdf0e10cSrcweir                         // Order is neccessary for right initialization!
98*cdf0e10cSrcweir                     ,   private ThreadHelpBase
99*cdf0e10cSrcweir                     ,   public  ::cppu::OWeakObject
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
102*cdf0e10cSrcweir 	//	public methods
103*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
104*cdf0e10cSrcweir 	public:
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
107*cdf0e10cSrcweir 		//	constructor / destructor
108*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
109*cdf0e10cSrcweir                  SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
110*cdf0e10cSrcweir         virtual ~SoundHandler(                                                                        );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
113*cdf0e10cSrcweir         //  XInterface, XTypeProvider, XServiceInfo
114*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
115*cdf0e10cSrcweir         virtual css::uno::Any  SAL_CALL queryInterface( const css::uno::Type& aType   ) throw( css::uno::RuntimeException );
116*cdf0e10cSrcweir         virtual void SAL_CALL acquire() throw();
117*cdf0e10cSrcweir         virtual void SAL_CALL release() throw();
118*cdf0e10cSrcweir         virtual css::uno::Sequence< css::uno::Type >  SAL_CALL getTypes () throw( css::uno::RuntimeException );
119*cdf0e10cSrcweir         virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( css::uno::RuntimeException );
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     /* interface XServiceInfo */
123*cdf0e10cSrcweir        virtual ::rtl::OUString                                        SAL_CALL getImplementationName              (                                                                               ) throw( css::uno::RuntimeException );
124*cdf0e10cSrcweir        virtual sal_Bool                                               SAL_CALL supportsService                    ( const ::rtl::OUString&                                        sServiceName    ) throw( css::uno::RuntimeException );
125*cdf0e10cSrcweir        virtual css::uno::Sequence< ::rtl::OUString >                  SAL_CALL getSupportedServiceNames           (                                                                               ) throw( css::uno::RuntimeException );
126*cdf0e10cSrcweir     /* Helper for XServiceInfo */
127*cdf0e10cSrcweir        static css::uno::Sequence< ::rtl::OUString >                   SAL_CALL impl_getStaticSupportedServiceNames(                                                                               );
128*cdf0e10cSrcweir        static ::rtl::OUString                                         SAL_CALL impl_getStaticImplementationName   (                                                                               );
129*cdf0e10cSrcweir     /* Helper for registry */
130*cdf0e10cSrcweir        static css::uno::Reference< css::uno::XInterface >             SAL_CALL impl_createInstance                ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception );
131*cdf0e10cSrcweir        static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory                 ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
132*cdf0e10cSrcweir     /* Helper for initialization of service by using own reference! */
133*cdf0e10cSrcweir        virtual void                                                   SAL_CALL impl_initService                   (                                                                               );
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
136*cdf0e10cSrcweir         //  XNotifyingDispatch
137*cdf0e10cSrcweir         //---------------------------------------------------------------------------------------------------------
138*cdf0e10cSrcweir         virtual void SAL_CALL dispatchWithNotification(const css::util::URL&                                             aURL      ,
139*cdf0e10cSrcweir                                                        const css::uno::Sequence< css::beans::PropertyValue >&            lArguments,
140*cdf0e10cSrcweir                                                        const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
143*cdf0e10cSrcweir 		//	XDispatch
144*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
145*cdf0e10cSrcweir         virtual void SAL_CALL dispatch              (   const   css::util::URL&                                     aURL        ,
146*cdf0e10cSrcweir                                                         const   css::uno::Sequence< css::beans::PropertyValue >&    lArguments  ) throw( css::uno::RuntimeException );
147*cdf0e10cSrcweir         // not supported !
148*cdf0e10cSrcweir         virtual void SAL_CALL addStatusListener     (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
149*cdf0e10cSrcweir                                                         const   css::util::URL&                                     /*aURL*/        ) throw( css::uno::RuntimeException ) {};
150*cdf0e10cSrcweir         virtual void SAL_CALL removeStatusListener  (   const   css::uno::Reference< css::frame::XStatusListener >& /*xListener*/   ,
151*cdf0e10cSrcweir                                                         const   css::util::URL&                                     /*aURL*/        ) throw( css::uno::RuntimeException ) {};
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
154*cdf0e10cSrcweir         //  XExtendedFilterDetection
155*cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
156*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL detect     (           css::uno::Sequence< css::beans::PropertyValue >&    lDescriptor ) throw( css::uno::RuntimeException );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
159*cdf0e10cSrcweir 	//	protected methods
160*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
161*cdf0e10cSrcweir 	protected:
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
164*cdf0e10cSrcweir 	//	private methods
165*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
166*cdf0e10cSrcweir 	private:
167*cdf0e10cSrcweir         DECL_LINK( implts_PlayerNotify, void* );
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
170*cdf0e10cSrcweir 	//	variables
171*cdf0e10cSrcweir 	//	(should be private everyway!)
172*cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
173*cdf0e10cSrcweir 	private:
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 		bool m_bError;
176*cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory >     m_xFactory          ;   /// global uno service factory to create new services
177*cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface >                m_xSelfHold         ;   /// we must protect us against dieing during async(!) dispatch() call!
178*cdf0e10cSrcweir         css::uno::Reference< css::media::XPlayer >                 m_xPlayer           ;   /// uses avmedia player to play sounds ...
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir         css::uno::Reference< css::frame::XDispatchResultListener > m_xListener         ;
181*cdf0e10cSrcweir         Timer m_aUpdateTimer;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir };      //  class SoundHandler
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir }		//	namespace avmedia
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir #endif  //  #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
188