21#include <com/sun/star/sdbc/SQLException.hpp>
22#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
23#include <com/sun/star/sdbc/XDriver.hpp>
24#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
25#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
26#include <com/sun/star/sdbcx/XDrop.hpp>
27#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/sdbcx/XUser.hpp>
30#include <com/sun/star/sdbcx/XAppend.hpp>
34#include <core_resource.hxx>
52#define MNI_ACTION_ADD_USER "add"
53#define MNI_ACTION_DEL_USER "delete"
54#define MNI_ACTION_CHANGE_PASSWORD "password"
58 std::unique_ptr<weld::Frame> m_xUser;
59 std::unique_ptr<weld::Entry> m_xEDOldPassword;
60 std::unique_ptr<weld::Entry> m_xEDPassword;
61 std::unique_ptr<weld::Entry> m_xEDPasswordRepeat;
62 std::unique_ptr<weld::Button> m_xOKBtn;
68 OPasswordDialog(
weld::Window* pParent, std::u16string_view rUserName);
70 OUString GetOldPassword()
const {
return m_xEDOldPassword->get_text(); }
71 OUString GetNewPassword()
const {
return m_xEDPassword->get_text(); }
76OPasswordDialog::OPasswordDialog(
weld::Window* _pParent, std::u16string_view rUserName)
77 : GenericDialogController(_pParent,
"dbaccess/ui/password.ui",
"PasswordDialog")
78 , m_xUser(m_xBuilder->weld_frame(
"userframe"))
79 , m_xEDOldPassword(m_xBuilder->weld_entry(
"oldpassword"))
80 , m_xEDPassword(m_xBuilder->weld_entry(
"newpassword"))
81 , m_xEDPasswordRepeat(m_xBuilder->weld_entry(
"confirmpassword"))
82 , m_xOKBtn(m_xBuilder->weld_button(
"ok"))
84 OUString sUser = m_xUser->get_label();
85 sUser = sUser.replaceFirst(
"$name$: $", rUserName);
86 m_xUser->set_label(sUser);
87 m_xOKBtn->set_sensitive(
false);
89 m_xOKBtn->connect_clicked(
LINK(
this, OPasswordDialog, OKHdl_Impl ) );
90 m_xEDOldPassword->connect_changed(
LINK(
this, OPasswordDialog, ModifiedHdl ) );
95 if (m_xEDPassword->get_text() == m_xEDPasswordRepeat->get_text())
99 OUString aErrorMsg(
DBA_RES( STR_ERROR_PASSWORDS_NOT_IDENTICAL));
101 VclMessageType::Warning, VclButtonsType::Ok,
104 m_xEDPassword->set_text(OUString());
105 m_xEDPasswordRepeat->set_text(OUString());
106 m_xEDPassword->grab_focus();
112 m_xOKBtn->set_sensitive(!rEdit.get_text().isEmpty());
118 , mxActionBar(m_xBuilder->weld_menu_button(
"action_menu"))
119 , m_xUSER(m_xBuilder->weld_combo_box(
"user"))
120 , m_xTable(m_xBuilder->weld_container(
"table"))
121 , m_xTableCtrlParent(m_xTable->CreateChildFrame())
151 xAppend->appendByDescriptor(xNewUser);
156 if (m_xUsers.is() && m_xUsers->hasByName(GetUser()))
162 VclMessageType::Question, VclButtonsType::YesNo,
163 DBA_RES(STR_QUERY_USERADMIN_DELETE_USER)));
165 xDrop->dropByName(GetUser());
170 OUString
sName = GetUser();
171 if(m_xUsers->hasByName(
sName))
174 m_xUsers->getByName(
sName) >>= xUser;
180 OUString sNewPassword,sOldPassword;
181 sNewPassword = aDlg.GetNewPassword();
182 sOldPassword = aDlg.GetOldPassword();
184 if(!sNewPassword.isEmpty())
185 xUser->changePassword(sOldPassword,sNewPassword);
192 catch(
const SQLException& e)
217 if ( xMetaData.is() )
228 const OUString* pEnd = pBegin +
m_aUserNames.getLength();
229 for(;pBegin != pEnd;++pBegin)
257 return std::make_unique<OUserAdmin>( pPage, pController, *_rAttrSet );
262 m_xTableCtrl->setUserName(GetUser());
263 m_xTableCtrl->UpdateTables();
264 m_xTableCtrl->DeactivateCell();
265 m_xTableCtrl->ActivateCell(m_xTableCtrl->GetCurRow(),m_xTableCtrl->GetCurColumnId());
270 return m_xUSER->get_active_text();
291 if ( !xUsersSup.is() )
296 xUsersSup.set(xDriver->getDataDefinitionByConnection(
m_xConnection),UNO_QUERY);
297 xTablesSup.set(xUsersSup,UNO_QUERY);
300 if ( xUsersSup.is() )
308 catch(
const SQLException& e)
#define MNI_ACTION_DEL_USER
IMPL_LINK_NOARG(OPasswordDialog, OKHdl_Impl, weld::Button &, void)
#define MNI_ACTION_CHANGE_PASSWORD
IMPL_LINK(OPasswordDialog, ModifiedHdl, weld::Entry &, rEdit, void)
#define MNI_ACTION_ADD_USER
Reference< XExecutableDialog > m_xDialog
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
OUString GetPassword() const
virtual short run() override
void ShowExtras(SfxShowExtras nExtras)
SfxOkDialogController * GetDialogController() const
virtual css::uno::Reference< css::sdbc::XDriver > getDriver()=0
virtual std::pair< css::uno::Reference< css::sdbc::XConnection >, bool > createConnection()=0
IDatabaseSettingsDialog * m_pAdminDialog
css::uno::Reference< css::uno::XComponentContext > m_xORB
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue)
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
virtual void fillControls(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to save the value if necessary
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
virtual ~OUserAdmin() override
std::unique_ptr< weld::MenuButton > mxActionBar
std::unique_ptr< weld::ComboBox > m_xUSER
css::uno::Reference< css::awt::XWindow > m_xTableCtrlParent
css::uno::Reference< css::container::XNameAccess > m_xUsers
virtual void fillWindows(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to disable if necessary
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
css::uno::Sequence< OUString > m_aUserNames
VclPtr< OTableGrantControl > m_xTableCtrl
css::uno::Reference< css::sdbc::XConnection > m_xConnection
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
#define LINK(Instance, Class, Member)
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)
constexpr OUStringLiteral PROPERTY_PASSWORD(u"Password")
constexpr OUStringLiteral PROPERTY_NAME(u"Name")