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