1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_DP_GUI_EXTENSIONCMDQUEUE_HXX
29 #define INCLUDED_DP_GUI_EXTENSIONCMDQUEUE_HXX
30 
31 #include "sal/config.h"
32 
33 #include "com/sun/star/uno/Reference.hxx"
34 #include "rtl/ref.hxx"
35 
36 #include <vector>
37 
38 #include "dp_gui_updatedata.hxx"
39 
40 /// @HTML
41 
42 namespace com { namespace sun { namespace star {
43     namespace task { class XInteractionRequest; }
44     namespace uno { class XComponentContext; }
45 } } }
46 
47 namespace dp_gui {
48 
49 class DialogHelper;
50 class TheExtensionManager;
51 
52 /**
53    Manages installing of extensions in the GUI mode. Requests for installing
54    Extensions can be asynchronous. For example, the Extension Manager is running
55    in an office process and someone uses the system integration to install an Extension.
56    That is, the user double clicks an extension symbol in a file browser, which then
57    causes an invocation of "unopkg gui ext". When at that time the Extension Manager
58    already performs a task, triggered by the user (for example, add, update, disable,
59    enable) then adding of the extension will be postponed until the user has finished
60    the task.
61 
62    This class also ensures that the extensions are not installed in the main thread.
63    Doing so would cause a deadlock because of the progress bar which needs to be constantly
64    updated.
65 */
66 class ExtensionCmdQueue {
67 
68 public:
69     /**
70        Create an instance.
71     */
72     ExtensionCmdQueue( DialogHelper * pDialogHelper,
73                        TheExtensionManager *pManager,
74                        const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext);
75 
76     ~ExtensionCmdQueue();
77 
78     /**
79     */
80     void addExtension( const ::rtl::OUString &rExtensionURL,
81                        const ::rtl::OUString &rRepository,
82                        const bool bWarnUser );
83     void removeExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
84     void enableExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage,
85                           const bool bEnable );
86     void checkForUpdates(const std::vector< ::com::sun::star::uno::Reference<
87                          ::com::sun::star::deployment::XPackage > > &vList );
88     void acceptLicense( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &rPackage );
89     static void syncRepositories( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
90     /**
91        This call does not block. It signals the internal thread
92        that it should install the remaining extensions and then terminate.
93     */
94     void stop();
95 
96     bool isBusy();
97 private:
98     ExtensionCmdQueue(ExtensionCmdQueue &); // not defined
99     void operator =(ExtensionCmdQueue &); // not defined
100 
101     class Thread;
102 
103     rtl::Reference< Thread > m_thread;
104 };
105 
106 void handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext,
107                                const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > & xRequest );
108 
109 }
110 
111 #endif
112