summaryrefslogtreecommitdiffstats
path: root/desktop/source/deployment/gui/dp_gui_theextmgr.hxx
blob: 13c329d6d142013cae252a99d3d2c9188f6fc2a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#pragma once

#include <cppuhelper/implbase.hxx>

#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/deployment/XExtensionManager.hpp>
#include <com/sun/star/frame/XDesktop2.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/util/XModifyListener.hpp>

#include "dp_gui.h"
#include "dp_gui_dialog2.hxx"


namespace dp_gui {


class ExtensionCmdQueue;


class TheExtensionManager :
    public ::cppu::WeakImplHelper< css::frame::XTerminateListener,
                                    css::util::XModifyListener >
{
private:
    css::uno::Reference< css::uno::XComponentContext >        m_xContext;
    css::uno::Reference< css::frame::XDesktop2 >              m_xDesktop;
    css::uno::Reference< css::deployment::XExtensionManager > m_xExtensionManager;
    css::uno::Reference< css::container::XNameAccess >        m_xNameAccessNodes;
    css::uno::Reference< css::awt::XWindow >                  m_xParent;
    std::shared_ptr<ExtMgrDialog> m_xExtMgrDialog;
    std::unique_ptr<UpdateRequiredDialog> m_xUpdReqDialog;
    std::unique_ptr<ExtensionCmdQueue> m_xExecuteCmdQueue;

    OUString                     m_sGetExtensionsURL;
    bool                         m_bModified;
    bool                         m_bExtMgrDialogExecuting;

public:
    static ::rtl::Reference<TheExtensionManager> s_ExtMgr;

         TheExtensionManager( css::uno::Reference< css::awt::XWindow > xParent,
                              const css::uno::Reference< css::uno::XComponentContext > &xContext );
        virtual ~TheExtensionManager() override;

    void createDialog( const bool bCreateUpdDlg );
    sal_Int16 execute();

    bool isModified() const { return m_bModified; }
    void clearModified() { m_bModified = false; }

    weld::Window* getDialog()
    {
        if (m_xExtMgrDialog)
            return m_xExtMgrDialog->getDialog();
        if (m_xUpdReqDialog)
            return m_xUpdReqDialog->getDialog();
        return nullptr;
    }
    DialogHelper* getDialogHelper()
    {
        if (m_xExtMgrDialog)
            return m_xExtMgrDialog.get();
        return m_xUpdReqDialog.get();
    }
    ExtensionCmdQueue* getCmdQueue() const { return m_xExecuteCmdQueue.get(); }

    void SetText( const OUString &rTitle );
    void Show();
    void ToTop();
    void Close();
    bool isVisible();


    void checkUpdates();
    bool installPackage( const OUString &rPackageURL, bool bWarnUser = false );
    void createPackageList();

    void terminateDialog();

    // Tools
    bool supportsOptions( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const;
    static PackageState getPackageState( const css::uno::Reference< css::deployment::XPackage > &xPackage );
    const css::uno::Reference< css::uno::XComponentContext >& getContext() const { return m_xContext; }
    const css::uno::Reference< css::deployment::XExtensionManager >& getExtensionManager() const { return m_xExtensionManager; }
    bool isReadOnly( const css::uno::Reference< css::deployment::XPackage > &xPackage ) const;


    static ::rtl::Reference<TheExtensionManager> get(
        css::uno::Reference< css::uno::XComponentContext> const & xContext,
        css::uno::Reference< css::awt::XWindow> const & xParent = nullptr,
        OUString const & view = OUString() );

    // XEventListener
    virtual void SAL_CALL disposing( css::lang::EventObject const & evt ) override;

    // XTerminateListener
    virtual void SAL_CALL queryTermination( css::lang::EventObject const & evt ) override;
    virtual void SAL_CALL notifyTermination( css::lang::EventObject const & evt ) override;

    // XModifyListener
    virtual void SAL_CALL modified( css::lang::EventObject const & evt ) override;
};

} // namespace dp_gui

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */