diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-08 21:10:35 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-08 21:10:35 +0900 |
commit | 5f33ccbb5f8174b1b64cc1b2172ded390b22d172 (patch) | |
tree | 19426c27ffdf3282ab743c7574f8a96a061e6cb6 /src | |
parent | 7d244de21521e47bafce032bbf2d84a13d60ab9e (diff) | |
download | tdeio-appinfo-5f33ccbb5f8174b1b64cc1b2172ded390b22d172.tar.gz tdeio-appinfo-5f33ccbb5f8174b1b64cc1b2172ded390b22d172.zip |
Specify TDE config folder through CMAKE parameters.
More code clean up.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src')
-rw-r--r-- | src/appimpl.cpp | 105 | ||||
-rw-r--r-- | src/appimpl.h | 28 |
2 files changed, 63 insertions, 70 deletions
diff --git a/src/appimpl.cpp b/src/appimpl.cpp index cc4ccb6..913ae0d 100644 --- a/src/appimpl.cpp +++ b/src/appimpl.cpp @@ -32,6 +32,7 @@ #include <kservice.h> #include <tdeio/job.h> +#include "config.h" 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, - const TQString &shortname, - const TQStringList &fullname) +void AppImpl::createExeEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname, + const TQStringList &fullname) { + TDEIO::UDSEntry entry; for (const TQString &name : fullname) { 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, - const TQString &shortname) +void AppImpl::createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { - entry.clear(); + TDEIO::UDSEntry entry; addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Manual for %1").arg(shortname)); addAtom(entry, TDEIO::UDS_URL, 0, "man:/"+shortname); addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); @@ -218,8 +218,7 @@ void AppImpl::createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSE list.append(entry); } -void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - const TQString &shortname) +void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { TQStringList homedir; homedir << TQString("%1/").arg(getenv("HOME")); @@ -227,6 +226,7 @@ void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSE TQStringList fullname = getFullLocation(homedir, dirname, TQDir::FilterSpec(TQDir::Hidden | TQDir::Dirs | TQDir::Readable), true, false); + TDEIO::UDSEntry entry; for (const TQString &fname : fullname) { 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, - const TQString &shortname) +void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { TQStringList dirList = TDEGlobal::instance()->dirs()->resourceDirs("data"); TQStringList TDEDataDir = getFullLocation(dirList, shortname, @@ -255,6 +254,7 @@ void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UD return; } + TDEIO::UDSEntry entry; for (const TQString &dirname : TDEDataDir) { if (dirname.isEmpty()) @@ -272,8 +272,7 @@ void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UD } } -void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, - TDEIO::UDSEntry &entry, const TQString &shortname) +void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { TQStringList dirList; dirList << "/usr/share/"; @@ -285,6 +284,7 @@ void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, return; } + TDEIO::UDSEntry entry; for (const TQString &dirname : StandardDataDir) { if (dirname.isEmpty()) @@ -302,27 +302,32 @@ void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, } } - -void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, - TDEIO::UDSEntry &entry, const TQString &shortname) +void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { + TDEIO::UDSEntry entry; + // Global TDE config - TQStringList dirList; - dirList << "/etc/trinity/"; - TQStringList TDEConfigFiles = getFullLocation(dirList, shortname + "rc", - TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), false, true); + TQString tdeCfgDir(TDESYSCONFDIR); - for (const TQString &filename : TDEConfigFiles) + if (!tdeCfgDir.isEmpty()) { - if (!filename.isEmpty()) + TQStringList dirList; + dirList << tdeCfgDir; + TQStringList TDEConfigFiles = getFullLocation(dirList, shortname + "rc", + TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), false, true); + + for (const TQString &filename : TDEConfigFiles) { - entry.clear(); - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config File (%1)").arg(filename)); - addAtom(entry, TDEIO::UDS_URL, 0, filename); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "configure"); - list.append(entry); + if (!filename.isEmpty()) + { + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config File (%1)").arg(filename)); + addAtom(entry, TDEIO::UDS_URL, 0, filename); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "configure"); + list.append(entry); + } } } @@ -342,8 +347,7 @@ void AppImpl::createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, list.append(entry); } -void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - const TQString &shortname) +void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { TQStringList dirList; dirList << "/etc/"; @@ -356,6 +360,7 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI return; } + TDEIO::UDSEntry entry; for (const TQString &fname : StandardConfigFile) { if (fname.isEmpty()) @@ -363,7 +368,6 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI continue; } - entry.clear(); bool isFolder = false; TQFileInfo fi(fname); if (fi.isDir()) @@ -373,6 +377,7 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI kdDebug() << "createStandardConfigEntry: " << fname << endl; + entry.clear(); addAtom(entry, TDEIO::UDS_URL, 0, fname); TQString icon; if (isFolder) @@ -393,8 +398,7 @@ void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEI } } -void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - const TQString &shortname) +void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { TQStringList dirList; dirList << "/tmp/"; @@ -412,7 +416,6 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn continue; } - entry.clear(); bool isFolder = false; TQFileInfo fi(fname); if (fi.isDir()) @@ -422,6 +425,7 @@ void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn kdDebug() << "createTmpDirEntry: " << fname << endl; + TDEIO::UDSEntry entry; addAtom(entry, TDEIO::UDS_URL, 0, fname); 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, - const TQString &shortname) +void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname) { TQStringList dirList; dirList << TQString("%1/.config/").arg(getenv("HOME")); @@ -456,7 +459,6 @@ void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn continue; } - entry.clear(); bool isFolder = false; TQFileInfo fi(filename); if (fi.isDir()) @@ -466,6 +468,7 @@ void AppImpl::createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEn kdDebug() << "createXdgDirEntry: " << filename << endl; + TDEIO::UDSEntry entry; addAtom(entry, TDEIO::UDS_URL, 0, filename); if (isFolder) { @@ -489,30 +492,28 @@ bool AppImpl::listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> { kdDebug() << "AppImpl::listAppContents" << endl; - TDEIO::UDSEntry entry; - // Create entry for binary file - createExeEntry(list, entry, name, getAppAddress(name)); - - // Create entry for data folder in home dir - createHomeDirEntry(list, entry, name); + createExeEntry(list, name, getAppAddress(name)); // Create entry for standard config and data folders - createStandardConfigEntry(list, entry, name); - createStandardDataDirEntry(list, entry, name); - - //Create entry for app XDF config folder in home dir - createXDGDirEntry(list, entry, name); + createStandardConfigEntry(list, name); + createStandardDataDirEntry(list, name); // Create entry for TDE config and data folders - createTDEConfigEntry(list, entry, name); - createTDEDataDirEntry(list, entry, name); + createTDEConfigEntry(list, 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 - createManPageEntry(list, entry, name); + createManPageEntry(list, name); //Create entry for folders in tmp dir - createTmpDirEntry(list, entry, name); + createTmpDirEntry(list, name); return true; } diff --git a/src/appimpl.h b/src/appimpl.h index 8402e15..7b28306 100644 --- a/src/appimpl.h +++ b/src/appimpl.h @@ -55,24 +55,16 @@ public: TQString lastErrorMessage() const { return m_lastErrorMessage; } private slots: - void createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - const TQString &shortname); - void createExeEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - const TQString &shortname, const TQStringList &fullname); - void createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, - const TQString &shortname); - void createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, - const TQString &shortname); - void createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - 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); + void createManPageEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createExeEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname, + const TQStringList &fullname); + void createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createTDEConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); + void createXDGDirEntry(TQValueList<TDEIO::UDSEntry> &list, const TQString &shortname); TQStringList getAppAddress(const TQString &name); TQStringList getFullLocation(const TQStringList &dirList, const TQString &name, |