Skip to content

Commit

Permalink
Merge pull request #2913 from MerginMaps/pgservice
Browse files Browse the repository at this point in the history
add support for pg_service.conf file
  • Loading branch information
PeterPetrik authored Nov 15, 2023
2 parents 0cd97bd + f814c96 commit b80b90e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/inputhelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ QVector<QString> InputHelp::logHeader( bool isHtml )
{
QVector<QString> retLines;
retLines.push_back( QStringLiteral( "Input App: %1 - %2 (%3)" ).arg( CoreUtils::appVersion() ).arg( InputUtils::appPlatform() ).arg( CoreUtils::appVersionCode() ) );
retLines.push_back( QStringLiteral( "Data Dir: %1" ).arg( InputUtils::appDataDir() ) );
retLines.push_back( QStringLiteral( "System: %1" ).arg( QSysInfo::prettyProductName() ) );
retLines.push_back( QStringLiteral( "Mergin URL: %1" ).arg( mMerginApi->apiRoot() ) );
retLines.push_back( QStringLiteral( "Mergin User: %1" ).arg( mMerginApi->userAuth()->username() ) );
Expand Down
6 changes: 6 additions & 0 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,12 @@ bool InputUtils::isMobilePlatform()
return platform == QStringLiteral( "android" ) || platform == QStringLiteral( "ios" );
}

QString InputUtils::appDataDir()
{
QString dataDir = QString::fromLocal8Bit( qgetenv( "QGIS_QUICK_DATA_PATH" ) ) ;
return dataDir;
}

void InputUtils::onQgsLogMessageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level )
{
QString levelStr;
Expand Down
2 changes: 2 additions & 0 deletions app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class InputUtils: public QObject
static QString appPlatform();
static bool isMobilePlatform();

static QString appDataDir();

/**
* Converts string in rational number format to double.
* @param rationalValue String - expecting value in format "numerator/denominator" (e.g "123/100").
Expand Down
13 changes: 13 additions & 0 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ static void init_qgis( const QString &pkgPath )
qDebug( "qgis providers:\n%s", QgsProviderRegistry::instance()->pluginList().toLatin1().data() );
}

static void init_pg( const QString &dataDir )
{
QFileInfo pgFile( QStringLiteral( "%1/pg_service.conf" ).arg( dataDir ) );
if ( pgFile.exists() && pgFile.isReadable() )
{
qputenv( "PGSYSCONFDIR", dataDir.toUtf8() );
CoreUtils::log( QStringLiteral( "PostgreSQL" ), QStringLiteral( "found pg_service.conf, setting PGSYSCONFDIR" ) );
}
}

void initDeclarative()
{
qmlRegisterUncreatableType<MerginUserAuth>( "lc", 1, 0, "MerginUserAuth", "" );
Expand Down Expand Up @@ -455,6 +465,9 @@ int main( int argc, char *argv[] )
#endif
InputProjUtils inputProjUtils;
inputProjUtils.initProjLib( appBundleDir, dataDir, projectDir );

init_pg( dataDir );

init_qgis( appBundleDir );

// AppSettings has to be initialized after QGIS app init (because of correct reading/writing QSettings).
Expand Down

1 comment on commit b80b90e

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.11.488711 just submitted!

Please sign in to comment.