Bug 43369 - Specific UI for collecting PostgreSQL connection settings
Summary: Specific UI for collecting PostgreSQL connection settings
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: nirnaykorde
URL:
Whiteboard: target:7.6.0 target:24.2.0
Keywords: difficultyInteresting, easyHack, skillCpp, skillVcl, topicUI
: 132476 (view as bug list)
Depends on:
Blocks: Database-Connectivity
  Show dependency treegraph
 
Reported: 2011-11-30 03:09 UTC by Lionel Elie Mamane
Modified: 2023-09-20 11:14 UTC (History)
11 users (show)

See Also:
Crash report or crash signature:


Attachments
screenshot of MySQL-specific UI (8.92 KB, image/png)
2011-11-30 03:09 UTC, Lionel Elie Mamane
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lionel Elie Mamane 2011-11-30 03:09:14 UTC
Created attachment 53965 [details]
screenshot of MySQL-specific UI

When connecting to a PostgreSQL database (through PostgreSQL-SDBC driver), we currently just ask the user to type a conninfo string. That's familiar to PostgreSQL experts, but other people would benefit from some hand-holding.

Implement a PostgreSQL-specific UI to get the connection info, along the lines of the MySQL-specific UI we already have.


The file you need to change in LibreOffice is dbaccess/source/ui/dlg/ConnectionHelper.cxx, in function

   IMPL_LINK(OConnectionHelper, OnBrowseConnections, PushButton*, /*_pButton*/)

there is a big

        switch ( eType )

We need to add a case for PostgreSQL. You can take inspiration from the MySQL case.

You may also need to adapt ODbDataSourceAdministrationHelper::getConnectionURL() in file DbAdminImpl.cxx, as well as ODbTypeWizDialog::determineNextState in file dbwiz to activate a new state ADDITIONAL_PAGE_PGSQL, which you have to create first.

Finally, the dialog itself would be in file dbaccess/source/ui/dlg/dbadminsetup.src, in a to-be-created section TabPage PAGE_DBWIZARD_PGSQL.

You could just generate a conninfo string from that, but I'd prefer if you set it as properties of the datasouce/database/..., so that the driver gets it through the same interface as the username and password; cf handling of these for inspiration. There is already support for that in the driver, see connectivity/source/drivers/postgresql/pq_connection.cxx, function properties2arrays. POssibly you need to extend the handling there to support more keywords.


Please *also* allow advanced users to enter a conninfo string, and mixing of entering a conninfo string (like now) and information through widgets in the specific UI. See http://developer.postgresql.org/pgdocs/postgres/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS for an up-to-date list of all recognised connection settings. Make a decision on which of these settings make or do not make sense to give a friendly UI for.
Comment 1 Terrence Enger 2011-11-30 05:16:04 UTC Comment hidden (obsolete)
Comment 2 Lionel Elie Mamane 2011-11-30 05:28:47 UTC Comment hidden (no-value)
Comment 3 Terrence Enger 2011-11-30 05:48:22 UTC Comment hidden (no-value)
Comment 4 Björn Michaelsen 2013-10-04 18:47:47 UTC Comment hidden (no-value)
Comment 5 Alex Thurgood 2015-01-03 17:39:37 UTC Comment hidden (no-value)
Comment 6 Robinson Tryon (qubit) 2015-12-14 07:02:30 UTC Comment hidden (obsolete)
Comment 7 Robinson Tryon (qubit) 2016-02-18 14:52:31 UTC Comment hidden (obsolete)
Comment 8 kerem 2016-03-29 19:05:04 UTC
I sent following for this patch;

https://gerrit.libreoffice.org/#/c/23602/
Comment 9 Lionel Elie Mamane 2016-04-04 08:08:17 UTC
You'll need to create new dialogs (.ui files) for that. This is done with a tool called "Glade", run from a shell after doing

export GLADE_CATALOG_SEARCH_PATH=${PATH_TO_BUILT_LIBREOFFICE_SOURCE_TREE}/instdir/share/glade

You can use the ones we have for MySQL as inspiration:

dbaccess/uiconfig/ui/dbwizmysqlnativepage.ui
dbaccess/uiconfig/ui/mysqlnativepage.ui
dbaccess/uiconfig/ui/mysqlnativesettings.ui
Comment 10 Xisco Faulí 2020-03-09 13:28:56 UTC
Please add keyword 'needsUXEval' and CC 'libreoffice-ux-advise@lists.freedesktop.org' if input from UX is needed.
Comment 11 Alex Thurgood 2020-05-07 06:47:08 UTC
*** Bug 132476 has been marked as a duplicate of this bug. ***
Comment 12 Popa Adrian Marius 2020-12-21 12:48:57 UTC
Current Link for PQconnectdbParams https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNECTDBPARAMS
Comment 13 Siddhant Chaudhary 2022-06-16 14:52:59 UTC
Hi. I'd love to work on this feature. I have two questions: 

1) I cannot find the file dbaccess/source/ui/dlg/dbadminsetup.src. It seems like there is no file with this name anymore. Was this changed in some patch?

2) I didn't understand this part: "but I'd prefer if you set it as properties of the datasouce/database/..., so that the driver gets it through the same interface as the username and password". Can someone please explain what this means?

Also, I have postgres installed on my machine. Will that be enough to test all aspects of this feature?

Thanks!
Comment 14 Lionel Elie Mamane 2022-06-16 15:09:10 UTC
(In reply to Siddhant Chaudhary from comment #13)
> 1) I cannot find the file dbaccess/source/ui/dlg/dbadminsetup.src. It seems
> like there is no file with this name anymore. Was this changed in some patch?

Yes, all .src files were removed in

commit 00657aef09d854c74fb426a935a3e8b1fc390bb0
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Sun Jun 11 20:56:30 2017 +0100

    migrate to boost::gettext

AS the commit message says:

    * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string")

So this is now in dbaccess/inc/strings.hrc

> 2) I didn't understand this part: "but I'd prefer if you set it as
> properties of the datasouce/database/..., so that the driver gets it through
> the same interface as the username and password". Can someone please explain
> what this means?

It means that the values set in the UI should be set as properties on the data source object, in the same way the username and password already are now. Now, the password is set in property PROPERTY_PASSWORD (which is "Password"), the username in PROPERTY_USER ("User"). You will put the TCP port to connect to in property "port", the database name in property "dbname", etc.

> 
> Also, I have postgres installed on my machine. Will that be enough to test
> all aspects of this feature?
> 
> Thanks!
Comment 15 nirnaykorde 2023-04-04 17:01:33 UTC
@Lionel Elie Mamane could please state all the updated requirements. Just to be sure that I do not work on unnecessary things
Comment 16 Lionel Elie Mamane 2023-04-05 10:25:44 UTC
(In reply to nirnaykorde from comment #15)
> @Lionel Elie Mamane could please state all the updated requirements. Just to
> be sure that I do not work on unnecessary things

See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS for the list of recognised connection keywords; at first glance the following make sense to include in the UI, the others can be typed in manually in the connstring by experts:

host
port
dbname
user
password
service

MAYBE (but maybe too confusing for newbies? behind an "advanced fold option"... or leave them out altogether):

gssencmode
sslmode
sslcert
passfile
sslkey
sslpassword
sslrootcert
sslcrl
sslcrldir
requirepeer
ssl_min_protocol_version
ssl_max_protocol_version
krbsrvname
gsslib (on Windows only)



DO NOT include in the UI:
client_encoding
application_name
Comment 17 nirnaykorde 2023-04-05 18:23:30 UTC
I am assigning this hack to myself
Comment 18 nirnaykorde 2023-04-05 18:24:18 UTC Comment hidden (obsolete)
Comment 19 nirnaykorde 2023-04-05 18:24:21 UTC Comment hidden (obsolete)
Comment 20 nirnaykorde 2023-04-05 18:46:19 UTC
(In reply to Lionel Elie Mamane from comment #0)
> Created attachment 53965 [details]
> screenshot of MySQL-specific UI
> 
> When connecting to a PostgreSQL database (through PostgreSQL-SDBC driver),
> we currently just ask the user to type a conninfo string. That's familiar to
> PostgreSQL experts, but other people would benefit from some hand-holding.
> 
> Implement a PostgreSQL-specific UI to get the connection info, along the
> lines of the MySQL-specific UI we already have.
> 
> 
> The file you need to change in LibreOffice is
> dbaccess/source/ui/dlg/ConnectionHelper.cxx, in function
> 
>    IMPL_LINK(OConnectionHelper, OnBrowseConnections, PushButton*,
> /*_pButton*/)
> 
> there is a big
> 
>         switch ( eType )
> 
> We need to add a case for PostgreSQL. You can take inspiration from the
> MySQL case.
> 
> You may also need to adapt
> ODbDataSourceAdministrationHelper::getConnectionURL() in file
> DbAdminImpl.cxx, as well as ODbTypeWizDialog::determineNextState in file
> dbwiz to activate a new state ADDITIONAL_PAGE_PGSQL, which you have to
> create first.
> 
> Finally, the dialog itself would be in file
> dbaccess/source/ui/dlg/dbadminsetup.src, in a to-be-created section TabPage
> PAGE_DBWIZARD_PGSQL.
> 
> You could just generate a conninfo string from that, but I'd prefer if you
> set it as properties of the datasouce/database/..., so that the driver gets
> it through the same interface as the username and password; cf handling of
> these for inspiration. There is already support for that in the driver, see
> connectivity/source/drivers/postgresql/pq_connection.cxx, function
> properties2arrays. POssibly you need to extend the handling there to support
> more keywords.

 I cant find datasouce/database/... has the name of the directory changed ?

> Please *also* allow advanced users to enter a conninfo string, and mixing of
> entering a conninfo string (like now) and information through widgets in the
> specific UI. See
> http://developer.postgresql.org/pgdocs/postgres/libpq-connect.html#LIBPQ-
> PQCONNECTDBPARAMS for an up-to-date list of all recognised connection
> settings. Make a decision on which of these settings make or do not make
> sense to give a friendly UI for.
Comment 21 Buovjaga 2023-04-06 05:33:47 UTC
(In reply to nirnaykorde from comment #20)
> (In reply to Lionel Elie Mamane from comment #0)
> > You could just generate a conninfo string from that, but I'd prefer if you
> > set it as properties of the datasouce/database/..., so that the driver gets
> > it through the same interface as the username and password; cf handling of
> > these for inspiration. There is already support for that in the driver, see
> > connectivity/source/drivers/postgresql/pq_connection.cxx, function
> > properties2arrays. POssibly you need to extend the handling there to support
> > more keywords.
> 
>  I cant find datasouce/database/... has the name of the directory changed ?

That is not referring to any directory. Read it as "datasource or database".
Comment 22 nirnaykorde 2023-04-08 11:39:00 UTC
My proposed solution for this bug is as follows:
For postgres to have a gui similar to mysql(in connect to existing database) we can:
1)instead of starting of the connection settings start of a page similar to mysql where instead of choosing the drivers we allow the user to use either a connstring or a gui interface.
2)if the the user selects connstring the next page would be the original connection settings page which appears after choosing postgres 
OR if the user chooses the GUI the users next page would be a copy of the MySQL JDBC driver connection page and the data would be used to feed the data in properties.
3)Both the page lead to user authentication page and rest is same

Do let me know if something seems wrong.
Comment 23 Lionel Elie Mamane 2023-04-09 08:31:13 UTC
(In reply to nirnaykorde from comment #22)
> My proposed solution for this bug is as follows:

Your plan is reasonable. However, I would rather do it in a way that "the GUI" has an extra field for "connstring" and the user can fill in things in "the GUI" and also at the same time in the connstring. All the information given, both in "the GUI" and in the connstring is given to libpq (whichever takes precedence is up to the postgresql-sdbc layer and/or libpq)
Comment 24 nirnaykorde 2023-04-09 13:50:14 UTC
I was able to find the JDBC GUI by searching but the connstring for postgresql,I havent been able to find. Is it being implemented through generalpage.cxx ?
Comment 25 Lionel Elie Mamane 2023-04-11 14:56:10 UTC
Yes, PostgreSQL currently just uses the generic UI.
Comment 26 nirnaykorde 2023-04-13 19:19:44 UTC
I have for the most part figured it out. One of the questions I have is if I implement something of the sort

OGeneralSpecialJDBCConnectionPageSetup::OGeneralSpecialJDBCConnectionPageSetup( weld::Container* pPage, 
	weld::DialogController* pController, const SfxItemSet& _rCoreAttrs ,sal_uInt16 _nPortId, TranslateId pDefaultPortResId, 
	TranslateId pHelpTextResId, TranslateId pHeaderTextResId, TranslateId pDriverClassId)

from DBSetupConnectionPages.cxx      

How would the postgres driver class need to be handled in that case since in the generic code it somewhat difficult to figure out
Comment 27 Commit Notification 2023-04-28 03:51:02 UTC
nirnay committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/afe99617707c92460e66486c0057ef327e8aa017

tdf#43369: Specific UI for collecting PostgreSQL connection settings

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 28 jcsanz 2023-05-30 19:30:05 UTC
Perhaps this should be added to the release notes of version 7.6 so it would show some advances in Base
Comment 29 Olivier Hallot 2023-06-14 13:39:19 UTC
Similarly, the Help page must be updated

https://help.libreoffice.org/master/en-US/text/sdatabase/dabawiz02pgsql.html?DbPAR=BASE#bm_id861587404584956
Comment 30 Commit Notification 2023-06-20 14:22:19 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/90f40e996fe1aaa93606f7e1b1fb60882bcf058b

tdf#43369 Refactor PosgresSQL connection setup

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 31 Alex Thurgood 2023-09-20 11:13:15 UTC
*** Bug 132476 has been marked as a duplicate of this bug. ***