1*0a1e2f0eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0a1e2f0eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0a1e2f0eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0a1e2f0eSAndrew Rist  * distributed with this work for additional information
6*0a1e2f0eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0a1e2f0eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0a1e2f0eSAndrew Rist  * "License"); you may not use this file except in compliance
9*0a1e2f0eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0a1e2f0eSAndrew Rist  *
11*0a1e2f0eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0a1e2f0eSAndrew Rist  *
13*0a1e2f0eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0a1e2f0eSAndrew Rist  * software distributed under the License is distributed on an
15*0a1e2f0eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0a1e2f0eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0a1e2f0eSAndrew Rist  * specific language governing permissions and limitations
18*0a1e2f0eSAndrew Rist  * under the License.
19*0a1e2f0eSAndrew Rist  *
20*0a1e2f0eSAndrew Rist  *************************************************************/
21*0a1e2f0eSAndrew Rist 
22*0a1e2f0eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_DP_GUI_EXTENSIONCMDQUEUE_HXX
25cdf0e10cSrcweir #define INCLUDED_DP_GUI_EXTENSIONCMDQUEUE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "sal/config.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx"
30cdf0e10cSrcweir #include "rtl/ref.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vector>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include "dp_gui_updatedata.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir /// @HTML
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace com { namespace sun { namespace star {
39cdf0e10cSrcweir     namespace task { class XInteractionRequest; }
40cdf0e10cSrcweir     namespace uno { class XComponentContext; }
41cdf0e10cSrcweir } } }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir namespace dp_gui {
44cdf0e10cSrcweir 
45cdf0e10cSrcweir class DialogHelper;
46cdf0e10cSrcweir class TheExtensionManager;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir /**
49cdf0e10cSrcweir    Manages installing of extensions in the GUI mode. Requests for installing
50cdf0e10cSrcweir    Extensions can be asynchronous. For example, the Extension Manager is running
51cdf0e10cSrcweir    in an office process and someone uses the system integration to install an Extension.
52cdf0e10cSrcweir    That is, the user double clicks an extension symbol in a file browser, which then
53cdf0e10cSrcweir    causes an invocation of "unopkg gui ext". When at that time the Extension Manager
54cdf0e10cSrcweir    already performs a task, triggered by the user (for example, add, update, disable,
55cdf0e10cSrcweir    enable) then adding of the extension will be postponed until the user has finished
56cdf0e10cSrcweir    the task.
57cdf0e10cSrcweir 
58cdf0e10cSrcweir    This class also ensures that the extensions are not installed in the main thread.
59cdf0e10cSrcweir    Doing so would cause a deadlock because of the progress bar which needs to be constantly
60cdf0e10cSrcweir    updated.
61cdf0e10cSrcweir */
62cdf0e10cSrcweir class ExtensionCmdQueue {
63cdf0e10cSrcweir 
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir     /**
66cdf0e10cSrcweir        Create an instance.
67cdf0e10cSrcweir     */
68cdf0e10cSrcweir     ExtensionCmdQueue( DialogHelper * pDialogHelper,
69cdf0e10cSrcweir                        TheExtensionManager *pManager,
70cdf0e10cSrcweir                        const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     ~ExtensionCmdQueue();
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     /**
75cdf0e10cSrcweir     */
76cdf0e10cSrcweir     void addExtension( const ::rtl::OUString &rExtensionURL,
77cdf0e10cSrcweir                        const ::rtl::OUString &rRepository,
78cdf0e10cSrcweir                        const bool bWarnUser );
79cdf0e10cSrcweir     void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
80cdf0e10cSrcweir     void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage,
81cdf0e10cSrcweir                           const bool bEnable );
82cdf0e10cSrcweir     void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference<
83cdf0e10cSrcweir                          ::com::sun::star::deployment::XPackage > > &vList );
84cdf0e10cSrcweir     void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
85cdf0e10cSrcweir     static void syncRepositories( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
86cdf0e10cSrcweir     /**
87cdf0e10cSrcweir        This call does not block. It signals the internal thread
88cdf0e10cSrcweir        that it should install the remaining extensions and then terminate.
89cdf0e10cSrcweir     */
90cdf0e10cSrcweir     void stop();
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     bool isBusy();
93cdf0e10cSrcweir private:
94cdf0e10cSrcweir     ExtensionCmdQueue(ExtensionCmdQueue &); // not defined
95cdf0e10cSrcweir     void operator =(ExtensionCmdQueue &); // not defined
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     class Thread;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     rtl::Reference< Thread > m_thread;
100cdf0e10cSrcweir };
101cdf0e10cSrcweir 
102cdf0e10cSrcweir void handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext,
103cdf0e10cSrcweir                                const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > & xRequest );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir #endif
108