summaryrefslogtreecommitdiff
path: root/include/svtools/ServerDetailsControls.hxx
blob: aaef76f90998227decbc0fb6daded3e5b2e34305 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* -*- 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/.
 */
#ifndef INCLUDED_SVTOOLS_SERVERDETAILSCONTROLS_HXX
#define INCLUDED_SVTOOLS_SERVERDETAILSCONTROLS_HXX

#include <map>

#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/task/PasswordContainer.hpp>
#include <com/sun/star/task/XPasswordContainer2.hpp>

#include <tools/urlobj.hxx>
#include <vcl/builder.hxx>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/field.hxx>
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/msgbox.hxx>

class DetailsContainer
{
    protected:
        Link<DetailsContainer*,void> m_aChangeHdl;
        VclPtr<VclGrid>        m_pDetailsGrid;
        VclPtr<VclHBox>        m_pHostBox;
        VclPtr<Edit>           m_pEDHost;
        VclPtr<FixedText>      m_pFTHost;
        VclPtr<NumericField>   m_pEDPort;
        VclPtr<FixedText>      m_pFTPort;
        VclPtr<Edit>           m_pEDRoot;
        VclPtr<FixedText>      m_pFTRoot;

    public:
        DetailsContainer( VclBuilderContainer* pBuilder );
        virtual ~DetailsContainer( );

        void setChangeHdl( const Link<DetailsContainer*,void>& rLink ) { m_aChangeHdl = rLink; }

        virtual void show( bool bShow = true );
        virtual INetURLObject getUrl( );

        /** Try to split the URL in the controls of that container.

            \param sUrl the URL to split
            \return true if the split worked, false otherwise.
         */
        virtual bool setUrl( const INetURLObject& rUrl );

        virtual void setUsername( const OUString& /*rUsername*/ ) { };
        virtual void setPassword( const OUString& ) { };

        virtual bool enableUserCredentials( ) { return true; };

    protected:
        void notifyChange( );
        DECL_LINK_TYPED ( ValueChangeHdl, Edit&, void );
};

class HostDetailsContainer : public DetailsContainer
{
    private:
        sal_uInt16 m_nDefaultPort;
        OUString m_sScheme;
        OUString m_sHost;

    public:
        HostDetailsContainer( VclBuilderContainer* pBuilder, sal_uInt16 nPort, const OUString& sScheme );
        virtual ~HostDetailsContainer( ) { };

        virtual void show( bool bShow = true ) override;
        virtual INetURLObject getUrl( ) override;
        virtual bool setUrl( const INetURLObject& rUrl ) override;

    protected:
        void setScheme( const OUString& sScheme ) { m_sScheme = sScheme; }

        /** Verifies that the scheme split from the URL can be handled by
            the container and set the proper controls accordingly if needed.
          */
        virtual bool verifyScheme( const OUString& rScheme );
};

class DavDetailsContainer : public HostDetailsContainer
{
    private:
        VclPtr<CheckBox>   m_pCBDavs;

    public:
        DavDetailsContainer( VclBuilderContainer* pBuilder );
        virtual ~DavDetailsContainer( ) { };

        virtual void show( bool bShow = true ) override;
    virtual bool enableUserCredentials( ) override { return false; };

    protected:
        virtual bool verifyScheme( const OUString& rScheme ) override;

    private:
        DECL_LINK_TYPED( ToggledDavsHdl, CheckBox&, void );
};

class SmbDetailsContainer : public DetailsContainer
{
    private:
        VclPtr<Edit>           m_pEDShare;
        VclPtr<FixedText>      m_pFTShare;

    public:
        SmbDetailsContainer( VclBuilderContainer* pBuilder );
        virtual ~SmbDetailsContainer( ) { };

        virtual INetURLObject getUrl( ) override;
        virtual bool setUrl( const INetURLObject& rUrl ) override;
        virtual void show( bool bShow = true ) override;
};

class CmisDetailsContainer : public DetailsContainer
{
    private:
        OUString m_sUsername;
        OUString m_sPassword;
        css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv;
        std::vector< OUString > m_aRepoIds;
        OUString m_sRepoId;
        OUString m_sBinding;

        VclPtr<VclHBox>    m_pRepositoryBox;
        VclPtr<FixedText>  m_pFTRepository;
        VclPtr<ListBox>    m_pLBRepository;
        VclPtr<Button>     m_pBTRepoRefresh;
        css::uno::Reference< css::awt::XWindow > m_xParentDialog;

    public:
        CmisDetailsContainer(VclBuilderContainer* pBuilder, Dialog* pParentDialog, OUString const & sBinding);
        virtual ~CmisDetailsContainer( ) { };

        virtual void show( bool bShow = true ) override;
        virtual INetURLObject getUrl( ) override;
        virtual bool setUrl( const INetURLObject& rUrl ) override;
        virtual void setUsername( const OUString& rUsername ) override;
        virtual void setPassword( const OUString& rPass ) override;

    private:
        void selectRepository( );
        DECL_LINK_TYPED ( RefreshReposHdl, Button*, void );
        DECL_LINK_TYPED ( SelectRepoHdl, ListBox&, void );
};

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