Skip to content

Commit

Permalink
Close #304 oids.txt not found etc if prefix non-standard
Browse files Browse the repository at this point in the history
Add INSTALL_PREFIX to the header and add it to the search path
for OIDs, translations and documentation.
  • Loading branch information
chris2511 committed Aug 23, 2024
1 parent d7a96e3 commit 79dba74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
18 changes: 15 additions & 3 deletions lib/func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ const QString getDocDir()
QStringList docs;
#ifdef DOCDIR
docs << QString(DOCDIR);
#endif
#ifdef INSTALL_PREFIX
docs << QString(INSTALL_PREFIX "/share/xca");
#endif
docs += QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
foreach (docdir, docs) {
Expand Down Expand Up @@ -260,12 +263,21 @@ const QString getUserSettingsDir()

const QString getI18nDir()
{
QString qm = QStandardPaths::locate(QStandardPaths::AppDataLocation,
I18N_DIR "xca_de.qm");
static QString qm;
if (qm.isEmpty())
return qm;
#ifdef INSTALL_PREFIX
if (QFileInfo::exists(INSTALL_PREFIX "/share/xca/xca_de.qm"))
qm = INSTALL_PREFIX "/share/xca/xca_de.qm";
#endif
if (qm.isEmpty())
qm = QStandardPaths::locate(QStandardPaths::AppDataLocation,
I18N_DIR "xca_de.qm");
if (qm.isEmpty())
qm = QCoreApplication::applicationDirPath() + "/xca_de.qm";
qm = QFileInfo(qm).path();
qDebug() << "QM" << qm;
return QFileInfo(qm).path();
return qm;
}

void migrateOldPaths()
Expand Down
18 changes: 13 additions & 5 deletions lib/oid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ NIDlist distname_nid;
QMap<QString,const char*> oid_name_clash;
QMap<QString,int> oid_lower_map;

static QStringList searchdirs()
{
QStringList dirs = QStandardPaths::standardLocations(
QStandardPaths::AppDataLocation);
#ifdef INSTALL_PREFIX
dirs << QString(INSTALL_PREFIX "/share/xca");
#endif
return dirs;
}

static void addToLowerMap(int nid)
{
QString n = OBJ_nid2sn(nid);
Expand Down Expand Up @@ -120,7 +130,7 @@ static void readOIDs(const QString &fname)
int line = 0;
QFile file(fname);
if (!file.open(QIODevice::ReadOnly))
return;
return;
qDebug() << "Read additional OIDs from" << fname;
QTextStream in(&file);
while (!in.atEnd()) {
Expand Down Expand Up @@ -171,8 +181,7 @@ static NIDlist read_nidlist(const QString &name)
{
NIDlist nl;

foreach(QString d, QStandardPaths::standardLocations(
QStandardPaths::AppDataLocation))
foreach(QString d, searchdirs())
{
nl = readNIDlist(d + "/" + name);
qDebug() << "Read" << nl.count() << "NIDs from"
Expand All @@ -191,8 +200,7 @@ void initOIDs()
addToLowerMap(i);
ign_openssl_error();

foreach(QString d, QStandardPaths::standardLocations(
QStandardPaths::AppDataLocation))
foreach(QString d, searchdirs())
readOIDs(d + "/oids.txt");

extkeyuse_nid = read_nidlist("eku.txt");
Expand Down
3 changes: 3 additions & 0 deletions local.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@

/* Build an AppStore compliant version */
#cmakedefine APPSTORE_COMPLIANT

/* Install PREFIX */
#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"

0 comments on commit 79dba74

Please sign in to comment.