1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 */ 9 #ifndef INCLUDED_SVTOOLS_SERVERDETAILSCONTROLS_HXX 10 #define INCLUDED_SVTOOLS_SERVERDETAILSCONTROLS_HXX 11 12 #include <vector> 13 14 #include <com/sun/star/uno/Reference.hxx> 15 16 #include <tools/link.hxx> 17 #include <tools/urlobj.hxx> 18 19 namespace com :: sun :: star :: ucb { class XCommandEnvironment; } 20 namespace com :: sun :: star :: awt { class XWindow; } 21 22 namespace weld { 23 class Button; 24 class ComboBox; 25 class Entry; 26 class SpinButton; 27 class ToggleButton; 28 } 29 30 class PlaceEditDialog; 31 32 class DetailsContainer 33 { 34 protected: 35 PlaceEditDialog* m_pDialog; 36 Link<DetailsContainer*,void> m_aChangeHdl; 37 38 public: 39 DetailsContainer(PlaceEditDialog* pDialog); 40 virtual ~DetailsContainer( ); 41 setChangeHdl(const Link<DetailsContainer *,void> & rLink)42 void setChangeHdl( const Link<DetailsContainer*,void>& rLink ) { m_aChangeHdl = rLink; } 43 44 virtual void set_visible( bool bShow ); 45 virtual INetURLObject getUrl( ); 46 47 /** Try to split the URL in the controls of that container. 48 49 \param sUrl the URL to split 50 \return true if the split worked, false otherwise. 51 */ 52 virtual bool setUrl( const INetURLObject& rUrl ); 53 setUsername(const OUString &)54 virtual void setUsername( const OUString& /*rUsername*/ ) { }; setPassword(const OUString &)55 virtual void setPassword( const OUString& ) { }; 56 enableUserCredentials()57 virtual bool enableUserCredentials( ) { return true; }; 58 59 protected: 60 void notifyChange( ); 61 DECL_LINK(ValueChangeHdl, weld::Entry&, void); 62 DECL_STATIC_LINK(DetailsContainer, FormatPortHdl, weld::SpinButton&, void); 63 }; 64 65 class HostDetailsContainer : public DetailsContainer 66 { 67 private: 68 sal_uInt16 m_nDefaultPort; 69 OUString m_sScheme; 70 OUString m_sHost; 71 72 public: 73 HostDetailsContainer(PlaceEditDialog* pDialog, sal_uInt16 nPort, const OUString& sScheme); 74 75 virtual void set_visible( bool bShow ) override; 76 virtual INetURLObject getUrl( ) override; 77 virtual bool setUrl( const INetURLObject& rUrl ) override; 78 79 protected: setScheme(const OUString & sScheme)80 void setScheme( const OUString& sScheme ) { m_sScheme = sScheme; } 81 82 /** Verifies that the scheme split from the URL can be handled by 83 the container and set the proper controls accordingly if needed. 84 */ 85 virtual bool verifyScheme( const OUString& rScheme ); 86 }; 87 88 class DavDetailsContainer final : public HostDetailsContainer 89 { 90 public: 91 DavDetailsContainer(PlaceEditDialog* pDialog); 92 93 virtual void set_visible( bool bShow ) override; enableUserCredentials()94 virtual bool enableUserCredentials( ) override { return false; }; 95 96 private: 97 virtual bool verifyScheme( const OUString& rScheme ) override; 98 99 DECL_LINK(ToggledDavsHdl, weld::Toggleable&, void); 100 }; 101 102 class SmbDetailsContainer final : public DetailsContainer 103 { 104 private: 105 OUString m_sHost; 106 107 public: 108 SmbDetailsContainer(PlaceEditDialog* pDialog); 109 110 virtual INetURLObject getUrl( ) override; 111 virtual bool setUrl( const INetURLObject& rUrl ) override; 112 virtual void set_visible( bool bShow ) override; 113 }; 114 115 class CmisDetailsContainer final : public DetailsContainer 116 { 117 private: 118 OUString m_sUsername; 119 OUString m_sPassword; 120 css::uno::Reference< css::ucb::XCommandEnvironment > m_xCmdEnv; 121 std::vector< OUString > m_aRepoIds; 122 OUString m_sRepoId; 123 OUString m_sBinding; 124 css::uno::Reference< css::awt::XWindow > m_xParentDialog; 125 126 public: 127 CmisDetailsContainer(PlaceEditDialog* pDialog, OUString const & sBinding); 128 129 virtual void set_visible( bool bShow ) override; 130 virtual INetURLObject getUrl( ) override; 131 virtual bool setUrl( const INetURLObject& rUrl ) override; 132 virtual void setUsername( const OUString& rUsername ) override; 133 virtual void setPassword( const OUString& rPass ) override; 134 135 private: 136 void selectRepository( ); 137 DECL_LINK ( RefreshReposHdl, weld::Button&, void ); 138 DECL_LINK ( SelectRepoHdl, weld::ComboBox&, void ); 139 }; 140 141 #endif 142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 143