tdf#116944 Warn user before database migration
Warn user with a pop-up dialog before migration. To do that we have to know the database URL at UI level. In order to get that I updated XDataSource interface with getConnectionURL(). The dialog offers two options: proceed with or without migration. If the user choose "yes", we store that information in XDataSource. The migration itself will be made in buildLowConnection(). Change-Id: I1f0d03da6352f7a0a8d989da79c4b2fe60a03ca1 Reviewed-on: https://gerrit.libreoffice.org/52876 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
This commit is contained in:
parent
f7d155e71d
commit
5b0ceb86c3
12 changed files with 203 additions and 6 deletions
|
@ -152,6 +152,7 @@ $(eval $(call gb_Library_add_exception_objects,dbu,\
|
|||
dbaccess/source/ui/dlg/textconnectionsettings \
|
||||
dbaccess/source/ui/dlg/UserAdmin \
|
||||
dbaccess/source/ui/dlg/UserAdminDlg \
|
||||
dbaccess/source/ui/dlg/migrwarndlg \
|
||||
dbaccess/source/ui/misc/asyncmodaldialog \
|
||||
dbaccess/source/ui/misc/charsets \
|
||||
dbaccess/source/ui/misc/controllerframe \
|
||||
|
|
|
@ -80,6 +80,7 @@ $(eval $(call gb_UIConfig_add_uifiles,dbaccess, \
|
|||
dbaccess/uiconfig/ui/useradmindialog \
|
||||
dbaccess/uiconfig/ui/useradminpage \
|
||||
dbaccess/uiconfig/ui/userdetailspage \
|
||||
dbaccess/uiconfig/ui/migrwarndlg \
|
||||
))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
|
|
@ -575,22 +575,24 @@ void ODatabaseSource::disposing()
|
|||
m_pImpl.clear();
|
||||
}
|
||||
|
||||
OUString SAL_CALL ODatabaseSource::getConnectionUrl()
|
||||
{
|
||||
return m_pImpl->m_sConnectURL;
|
||||
}
|
||||
|
||||
Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString& _rUid, const OUString& _rPwd)
|
||||
{
|
||||
Reference< XConnection > xReturn;
|
||||
|
||||
Reference< XDriverManager > xManager;
|
||||
|
||||
bool bNeedMigration = false;
|
||||
OUString sMigrEnvVal;
|
||||
osl_getEnvironment(OUString("DBACCESS_HSQL_MIGRATION").pData,
|
||||
&sMigrEnvVal.pData);
|
||||
if( m_pImpl->m_sConnectURL == "sdbc:embedded:hsqldb" &&
|
||||
!sMigrEnvVal.isEmpty())
|
||||
{
|
||||
bool bNeedMigration = m_pImpl->m_sConnectURL == "sdbc:embedded:hsqldb" &&
|
||||
(m_bMigationNeeded || !sMigrEnvVal.isEmpty());
|
||||
if(bNeedMigration)
|
||||
m_pImpl->m_sConnectURL = "sdbc:embedded:firebird";
|
||||
bNeedMigration = true;
|
||||
}
|
||||
|
||||
try {
|
||||
xManager.set( ConnectionPool::create( m_pImpl->m_aContext ), UNO_QUERY_THROW );
|
||||
|
|
|
@ -84,6 +84,7 @@ private:
|
|||
using ODatabaseSource_Base::rBHelper;
|
||||
// note: this thing uses the ref-count of "this", see OBookmarkContainer::acquire!
|
||||
OBookmarkContainer m_Bookmarks;
|
||||
bool m_bMigationNeeded = false;
|
||||
::comphelper::OInterfaceContainerHelper2 m_aFlushListeners;
|
||||
|
||||
private:
|
||||
|
@ -162,6 +163,9 @@ public:
|
|||
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( const OUString& user, const OUString& password ) override;
|
||||
virtual void SAL_CALL setLoginTimeout( sal_Int32 seconds ) override;
|
||||
virtual sal_Int32 SAL_CALL getLoginTimeout( ) override;
|
||||
virtual void SAL_CALL setMigrationNeeded( sal_Bool bNeeded ) override { m_bMigationNeeded = bNeeded; }
|
||||
virtual sal_Bool SAL_CALL getMigrationNeeded() override { return m_bMigationNeeded; }
|
||||
virtual OUString SAL_CALL getConnectionUrl() override;
|
||||
|
||||
//::css::sdb::XBookmarksSupplier
|
||||
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getBookmarks( ) override;
|
||||
|
|
29
dbaccess/source/core/inc/warndlg.hxx
Normal file
29
dbaccess/source/core/inc/warndlg.hxx
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* -*- 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_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX
|
||||
#define INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX
|
||||
|
||||
#include <vcl/weld.hxx>
|
||||
|
||||
namespace dbaccess
|
||||
{
|
||||
class MigrationWarnDialog : public weld::MessageDialogController
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<weld::Button> m_xOkBtn;
|
||||
std::unique_ptr<weld::Button> m_xLaterBtn;
|
||||
|
||||
public:
|
||||
MigrationWarnDialog(weld::Window* pParent);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
22
dbaccess/source/core/misc/warndlg.cxx
Normal file
22
dbaccess/source/core/misc/warndlg.cxx
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#include <warndlg.hxx>
|
||||
|
||||
namespace dbaccess
|
||||
{
|
||||
MigrationWarnDialog::MigrationWarnDialog(weld::Window* pParent)
|
||||
: MessageDialogController(pParent, "TODOUIfile", "MigrationWarnDialog", "ask")
|
||||
, m_xOkBtn(m_xBuilder->weld_button("yes"))
|
||||
, m_xLaterBtn(m_xBuilder->weld_button("later"))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
22
dbaccess/source/ui/dlg/migrwarndlg.cxx
Normal file
22
dbaccess/source/ui/dlg/migrwarndlg.cxx
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#include <migrwarndlg.hxx>
|
||||
|
||||
namespace dbaui
|
||||
{
|
||||
MigrationWarnDialog::MigrationWarnDialog(weld::Window* pParent)
|
||||
: MessageDialogController(pParent, "dbaccess/ui/migrwarndlg.ui", "MigrationWarnDialog")
|
||||
, m_xOkBtn(m_xBuilder->weld_button("yes"))
|
||||
, m_xLaterBtn(m_xBuilder->weld_button("later"))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
29
dbaccess/source/ui/inc/migrwarndlg.hxx
Normal file
29
dbaccess/source/ui/inc/migrwarndlg.hxx
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* -*- 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_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX
|
||||
#define INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX
|
||||
|
||||
#include <vcl/weld.hxx>
|
||||
|
||||
namespace dbaui
|
||||
{
|
||||
class MigrationWarnDialog : public weld::MessageDialogController
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<weld::Button> m_xOkBtn;
|
||||
std::unique_ptr<weld::Button> m_xLaterBtn;
|
||||
|
||||
public:
|
||||
MigrationWarnDialog(weld::Window* pParent);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // INCLUDED_DBACCESS_SOURCE_CORE_INC_WARNDLG_HXX
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -41,6 +41,7 @@
|
|||
#include <cppuhelper/exc_hlp.hxx>
|
||||
#include <strings.hrc>
|
||||
#include <strings.hxx>
|
||||
#include <migrwarndlg.hxx>
|
||||
|
||||
namespace dbaui
|
||||
{
|
||||
|
@ -114,6 +115,12 @@ namespace dbaui
|
|||
DBG_UNHANDLED_EXCEPTION("dbaccess");
|
||||
}
|
||||
|
||||
if(_xDataSource->getConnectionUrl().startsWithIgnoreAsciiCase("sdbc:embedded:hsqldb"))
|
||||
{
|
||||
MigrationWarnDialog aWarnDlg{m_pErrorMessageParent->GetFrameWeld()};
|
||||
_xDataSource->setMigrationNeeded(aWarnDlg.run() == RET_OK);
|
||||
}
|
||||
|
||||
// try to connect
|
||||
SQLExceptionInfo aInfo;
|
||||
try
|
||||
|
|
73
dbaccess/uiconfig/ui/migrwarndlg.ui
Normal file
73
dbaccess/uiconfig/ui/migrwarndlg.ui
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.2 -->
|
||||
<interface domain="sfx">
|
||||
<requires lib="gtk+" version="3.18"/>
|
||||
<object class="GtkMessageDialog" id="MigrationWarnDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="title" translatable="yes" context="migrationwarndialog|MigrationWarnDialog">Confirm Migration</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="yes">
|
||||
<property name="label" translatable="yes" context="migrationwarndialog|yes">yes</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="later">
|
||||
<property name="label" translatable="yes" context="migrationwarndialog|later">later</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes" context="migrationwarndialog|dialogmessage">The document contains embedded HSQL data, which is deprecated.
|
||||
Would you like to migrate to Firebird now?</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">yes</action-widget>
|
||||
<action-widget response="-6">later</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
|
@ -34,6 +34,11 @@
|
|||
*/
|
||||
published interface XDataSource: com::sun::star::uno::XInterface
|
||||
{
|
||||
/** indicates whether database migration is needed or not.
|
||||
*/
|
||||
[attribute] boolean MigrationNeeded;
|
||||
|
||||
string getConnectionUrl();
|
||||
|
||||
/** attempts to establish a database connection.
|
||||
@param user
|
||||
|
|
|
@ -10212,6 +10212,8 @@ module com {
|
|||
};
|
||||
module sdbc {
|
||||
published interface XDataSource {
|
||||
[attribute] boolean MigrationNeeded;
|
||||
string getConnectionUrl();
|
||||
interface ::com::sun::star::uno::XInterface;
|
||||
::com::sun::star::sdbc::XConnection getConnection([in] string user, [in] string password) raises (::com::sun::star::sdbc::SQLException);
|
||||
void setLoginTimeout([in] long seconds) raises (::com::sun::star::sdbc::SQLException);
|
||||
|
|
Loading…
Reference in a new issue