Specify TDE config folder through CMAKE parameters.

More code clean up.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
r14.0.x
Michele Calgaro 3 years ago
parent 7d244de215
commit 5f33ccbb5f
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -6,3 +6,6 @@
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */ significant byte first (like Motorola and SPARC, unlike Intel). */
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ #cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
/* The compiled in system configuration prefix */
#define TDESYSCONFDIR "@CONFIG_INSTALL_DIR@/"

@ -32,6 +32,7 @@
#include <kservice.h> #include <kservice.h>
#include <tdeio/job.h> #include <tdeio/job.h>
#include "config.h"
AppImpl::AppImpl(TDEIO_AppInfo *slave) : TQObject(), m_slave(slave) AppImpl::AppImpl(TDEIO_AppInfo *slave) : TQObject(), m_slave(slave)
{ {
@ -173,10 +174,10 @@ void AppImpl::createEntry(TDEIO::UDSEntry &entry, const TQString &file)
} }
} }
void AppImpl::createExeEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, void AppImpl::createExeEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname,
const TQString &shortname,
const TQStringList &fullname) const TQStringList &fullname)
{ {
TDEIO::UDSEntry entry;
for (const TQString &name : fullname) for (const TQString &name : fullname)
{ {
if (name.isEmpty()) if (name.isEmpty())
@ -206,10 +207,9 @@ void AppImpl::createExeEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry
} }
} }
void AppImpl::createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void AppImpl::createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
const TQString &shortname)
{ {
entry.clear(); TDEIO::UDSEntry entry;
addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Manual for %1").arg(shortname)); addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Manual for %1").arg(shortname));
addAtom(entry, TDEIO::UDS_URL, 0, "man:/"+shortname); addAtom(entry, TDEIO::UDS_URL, 0, "man:/"+shortname);
addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG);
@ -218,8 +218,7 @@ void AppImpl::createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSE
list.append(entry); list.append(entry);
} }
void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
const TQString &shortname)
{ {
TQStringList homedir; TQStringList homedir;
homedir << TQString("%1/").arg(getenv("HOME")); homedir << TQString("%1/").arg(getenv("HOME"));
@ -227,6 +226,7 @@ void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSE
TQStringList fullname = getFullLocation(homedir, dirname, TQStringList fullname = getFullLocation(homedir, dirname,
TQDir::FilterSpec(TQDir::Hidden | TQDir::Dirs | TQDir::Readable), true, false); TQDir::FilterSpec(TQDir::Hidden | TQDir::Dirs | TQDir::Readable), true, false);
TDEIO::UDSEntry entry;
for (const TQString &fname : fullname) for (const TQString &fname : fullname)
{ {
if (fname.isEmpty()) if (fname.isEmpty())
@ -244,8 +244,7 @@ void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSE
} }
} }
void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
const TQString &shortname)
{ {
TQStringList dirList = TDEGlobal::instance()->dirs()->resourceDirs("data"); TQStringList dirList = TDEGlobal::instance()->dirs()->resourceDirs("data");
TQStringList TDEDataDir = getFullLocation(dirList, shortname, TQStringList TDEDataDir = getFullLocation(dirList, shortname,
@ -255,6 +254,7 @@ void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UD
return; return;
} }
TDEIO::UDSEntry entry;
for (const TQString &dirname : TDEDataDir) for (const TQString &dirname : TDEDataDir)
{ {
if (dirname.isEmpty()) if (dirname.isEmpty())
@ -272,8 +272,7 @@ void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UD
} }
} }
void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
TDEIO::UDSEntry &entry, const TQString &shortname)
{ {
TQStringList dirList; TQStringList dirList;
dirList << "/usr/share/"; dirList << "/usr/share/";
@ -285,6 +284,7 @@ void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,
return; return;
} }
TDEIO::UDSEntry entry;
for (const TQString &dirname : StandardDataDir) for (const TQString &dirname : StandardDataDir)
{ {
if (dirname.isEmpty()) if (dirname.isEmpty())
@ -302,13 +302,17 @@ void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,
} }
} }
void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list,
TDEIO::UDSEntry &entry, const TQString &shortname)
{ {
TDEIO::UDSEntry entry;
// Global TDE config // Global TDE config
TQString tdeCfgDir(TDESYSCONFDIR);
if (!tdeCfgDir.isEmpty())
{
TQStringList dirList; TQStringList dirList;
dirList << "/etc/trinity/"; dirList << tdeCfgDir;
TQStringList TDEConfigFiles = getFullLocation(dirList, shortname + "rc", TQStringList TDEConfigFiles = getFullLocation(dirList, shortname + "rc",
TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), false, true); TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), false, true);
@ -325,6 +329,7 @@ void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list,
list.append(entry); list.append(entry);
} }
} }
}
// Resource file // Resource file
TQString TDEDataDir = locate("config", shortname + "rc"); TQString TDEDataDir = locate("config", shortname + "rc");
@ -342,8 +347,7 @@ void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list,
list.append(entry); list.append(entry);
} }
void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
const TQString &shortname)
{ {
TQStringList dirList; TQStringList dirList;
dirList << "/etc/"; dirList << "/etc/";
@ -356,6 +360,7 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI
return; return;
} }
TDEIO::UDSEntry entry;
for (const TQString &fname : StandardConfigFile) for (const TQString &fname : StandardConfigFile)
{ {
if (fname.isEmpty()) if (fname.isEmpty())
@ -363,7 +368,6 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI
continue; continue;
} }
entry.clear();
bool isFolder = false; bool isFolder = false;
TQFileInfo fi(fname); TQFileInfo fi(fname);
if (fi.isDir()) if (fi.isDir())
@ -373,6 +377,7 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI
kdDebug() << "createStandardConfigEntry: " << fname << endl; kdDebug() << "createStandardConfigEntry: " << fname << endl;
entry.clear();
addAtom(entry, TDEIO::UDS_URL, 0, fname); addAtom(entry, TDEIO::UDS_URL, 0, fname);
TQString icon; TQString icon;
if (isFolder) if (isFolder)
@ -393,8 +398,7 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI
} }
} }
void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
const TQString &shortname)
{ {
TQStringList dirList; TQStringList dirList;
dirList << "/tmp/"; dirList << "/tmp/";
@ -412,7 +416,6 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn
continue; continue;
} }
entry.clear();
bool isFolder = false; bool isFolder = false;
TQFileInfo fi(fname); TQFileInfo fi(fname);
if (fi.isDir()) if (fi.isDir())
@ -422,6 +425,7 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn
kdDebug() << "createTmpDirEntry: " << fname << endl; kdDebug() << "createTmpDirEntry: " << fname << endl;
TDEIO::UDSEntry entry;
addAtom(entry, TDEIO::UDS_URL, 0, fname); addAtom(entry, TDEIO::UDS_URL, 0, fname);
if (isFolder) if (isFolder)
{ {
@ -441,8 +445,7 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn
} }
} }
void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname)
const TQString &shortname)
{ {
TQStringList dirList; TQStringList dirList;
dirList << TQString("%1/.config/").arg(getenv("HOME")); dirList << TQString("%1/.config/").arg(getenv("HOME"));
@ -456,7 +459,6 @@ void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn
continue; continue;
} }
entry.clear();
bool isFolder = false; bool isFolder = false;
TQFileInfo fi(filename); TQFileInfo fi(filename);
if (fi.isDir()) if (fi.isDir())
@ -466,6 +468,7 @@ void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn
kdDebug() << "createXdgDirEntry: " << filename << endl; kdDebug() << "createXdgDirEntry: " << filename << endl;
TDEIO::UDSEntry entry;
addAtom(entry, TDEIO::UDS_URL, 0, filename); addAtom(entry, TDEIO::UDS_URL, 0, filename);
if (isFolder) if (isFolder)
{ {
@ -489,30 +492,28 @@ bool AppImpl::listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry>
{ {
kdDebug() << "AppImpl::listAppContents" << endl; kdDebug() << "AppImpl::listAppContents" << endl;
TDEIO::UDSEntry entry;
// Create entry for binary file // Create entry for binary file
createExeEntry(list, entry, name, getAppAddress(name)); createExeEntry(list, name, getAppAddress(name));
// Create entry for data folder in home dir
createHomeDirEntry(list, entry, name);
// Create entry for standard config and data folders // Create entry for standard config and data folders
createStandardConfigEntry(list, entry, name); createStandardConfigEntry(list, name);
createStandardDataDirEntry(list, entry, name); createStandardDataDirEntry(list, name);
//Create entry for app XDF config folder in home dir
createXDGDirEntry(list, entry, name);
// Create entry for TDE config and data folders // Create entry for TDE config and data folders
createTDEConfigEntry(list, entry, name); createTDEConfigEntry(list, name);
createTDEDataDirEntry(list, entry, name); createTDEDataDirEntry(list, name);
// Create entry for data folder in home dir
createHomeDirEntry(list, name);
//Create entry for app XDF config folder in home dir
createXDGDirEntry(list, name);
// Create entry for manual // Create entry for manual
createManPageEntry(list, entry, name); createManPageEntry(list, name);
//Create entry for folders in tmp dir //Create entry for folders in tmp dir
createTmpDirEntry(list, entry, name); createTmpDirEntry(list, name);
return true; return true;
} }

@ -55,24 +55,16 @@ public:
TQString lastErrorMessage() const { return m_lastErrorMessage; } TQString lastErrorMessage() const { return m_lastErrorMessage; }
private slots: private slots:
void createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
const TQString &shortname); void createExeEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname,
void createExeEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, const TQStringList &fullname);
const TQString &shortname, const TQStringList &fullname); void createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
void createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, void createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
const TQString &shortname); void createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
void createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, void createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
const TQString &shortname); void createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
void createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, void createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
const TQString &shortname); void createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname);
void createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry,
const TQString &shortname);
void createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry,
const TQString &shortname);
void createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry,
const TQString &shortname);
void createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry,
const TQString &shortname);
TQStringList getAppAddress(const TQString &name); TQStringList getAppAddress(const TQString &name);
TQStringList getFullLocation(const TQStringList &dirList, const TQString &name, TQStringList getFullLocation(const TQStringList &dirList, const TQString &name,

Loading…
Cancel
Save