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_THEEXTMGR_HXX
29 #define INCLUDED_DP_GUI_THEEXTMGR_HXX
30 
31 #include "comphelper/sequence.hxx"
32 
33 #include "cppuhelper/implbase2.hxx"
34 
35 #include "com/sun/star/container/XNameAccess.hpp"
36 #include "com/sun/star/deployment/XExtensionManager.hpp"
37 #include "com/sun/star/deployment/ExtensionManager.hpp"
38 #include "com/sun/star/frame/XDesktop.hpp"
39 #include "com/sun/star/frame/XTerminateListener.hpp"
40 #include "com/sun/star/uno/XComponentContext.hpp"
41 #include "com/sun/star/util/XModifyListener.hpp"
42 
43 #include "dp_gui.h"
44 #include "dp_gui_dialog2.hxx"
45 #include "dp_gui_updatedata.hxx"
46 
47 //==============================================================================
48 namespace dp_gui {
49 
50 //------------------------------------------------------------------------------
51 class ExtensionCmdQueue;
52 
53 //------------------------------------------------------------------------------
54 class TheExtensionManager :
55     public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XTerminateListener,
56                                     ::com::sun::star::util::XModifyListener >
57 {
58 private:
59     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >    m_xContext;
60     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop >           m_xDesktop;
61     ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > m_xExtensionManager;
62     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >    m_xNameAccessNodes;
63 
64     Window                  *m_pParent;
65     ExtMgrDialog            *m_pExtMgrDialog;
66     UpdateRequiredDialog    *m_pUpdReqDialog;
67     ExtensionCmdQueue       *m_pExecuteCmdQueue;
68 
69     ::rtl::OUString          m_sGetExtensionsURL;
70 
71     void createPackageList();
72 
73 public:
74     static ::rtl::Reference<TheExtensionManager> s_ExtMgr;
75 
76          TheExtensionManager( Window * pParent,
77                               const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &xContext );
78         ~TheExtensionManager();
79 
80     void createDialog( const bool bCreateUpdDlg );
81     sal_Int16 execute();
82 
83     Dialog* getDialog() { return m_pExtMgrDialog ? (Dialog*) m_pExtMgrDialog : (Dialog*) m_pUpdReqDialog; }
84     DialogHelper* getDialogHelper() { return m_pExtMgrDialog ? (DialogHelper*) m_pExtMgrDialog : (DialogHelper*) m_pUpdReqDialog; }
85     ExtensionCmdQueue* getCmdQueue() const { return m_pExecuteCmdQueue; }
86 
87     void SetText( const ::rtl::OUString &rTitle );
88     void Show();
89     void ToTop( sal_uInt16 nFlags );
90     bool Close();
91     bool isVisible();
92 
93     //-----------------
94     bool checkUpdates( bool showUpdateOnly, bool parentVisible );
95     bool installPackage( const ::rtl::OUString &rPackageURL, bool bWarnUser = false );
96 
97     bool queryTermination();
98     void terminateDialog();
99 
100     // Tools
101     bool supportsOptions( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
102     PackageState getPackageState( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
103     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext; }
104     ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XExtensionManager > getExtensionManager() const { return m_xExtensionManager; }
105     bool isReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const;
106 
107     //-----------------
108     static ::rtl::Reference<TheExtensionManager> get(
109         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xContext,
110         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> const & xParent = 0,
111         ::rtl::OUString const & view = ::rtl::OUString() );
112 
113     // XEventListener
114     virtual void SAL_CALL disposing( ::com::sun::star::lang::EventObject const & evt )
115         throw (::com::sun::star::uno::RuntimeException);
116 
117     // XTerminateListener
118     virtual void SAL_CALL queryTermination( ::com::sun::star::lang::EventObject const & evt )
119         throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
120     virtual void SAL_CALL notifyTermination( ::com::sun::star::lang::EventObject const & evt )
121         throw (::com::sun::star::uno::RuntimeException);
122 
123     // XModifyListener
124     virtual void SAL_CALL modified( ::com::sun::star::lang::EventObject const & evt )
125         throw (::com::sun::star::uno::RuntimeException);
126 };
127 
128 } // namespace dp_gui
129 
130 #endif
131 
132