summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2022-05-08 14:21:56 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2022-05-08 14:21:56 +0900
commitffa531ae90fd6fcbed0f39c764b4eb557d543866 (patch)
tree81af2d8dee00e2f8be8dc0e3fad1b547b4ef05d7
parentaacfa4988921bed952fc600dccd7e6ceccb8780c (diff)
downloadtdeio-appinfo-ffa531ae.tar.gz
tdeio-appinfo-ffa531ae.zip
Search apps in user's PATH.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--src/appimpl.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/src/appimpl.cpp b/src/appimpl.cpp
index cd3fe18..9077afc 100644
--- a/src/appimpl.cpp
+++ b/src/appimpl.cpp
@@ -25,6 +25,7 @@
#include <tqapplication.h>
#include <tqeventloop.h>
+#include <tqmap.h>
#include <kdebug.h>
#include <kstandarddirs.h>
@@ -47,17 +48,14 @@ void AppImpl::listRoot()
createTopLevelEntry(entry);
m_slave->listEntry(entry, false);
- //TQStringList dirList = TQStringList::split(":", getenv("PATH"));
- TQStringList dirList;
- dirList << "/opt/trinity/bin/";
- dirList << "/usr/bin/";
- dirList << "/usr/local/bin/";
+ TQStringList dirList = TQStringList::split(":", getenv("PATH"));
kdDebug() << dirList << endl;
+ TQMap<TQString, bool> knownApps;
TQValueList<TDEIO::UDSEntry> list;
- for (const TQString &dirName : dirList)
+ for (const TQString &dirname : dirList)
{
- TQDir dir(dirName);
+ TQDir dir(dirname);
if (!dir.exists())
{
continue;
@@ -67,12 +65,17 @@ void AppImpl::listRoot()
TDEIO::UDSEntry entry;
for (const TQString &filename : filenames)
{
- createEntry(entry, filename);
- list.append(entry);
- if (list.count() >= 50)
+ TQString fullname = dirname + filename;
+ if (!knownApps.contains(fullname))
{
- m_slave->listEntries(list);
- list.clear();
+ knownApps[fullname] = true;
+ createEntry(entry, filename);
+ list.append(entry);
+ if (list.count() >= 50)
+ {
+ m_slave->listEntries(list);
+ list.clear();
+ }
}
}
}
@@ -124,9 +127,9 @@ bool AppImpl::statByName(const TQString &filename, TDEIO::UDSEntry &entry)
dirList << "/opt/trinity/bin/";
TQStringList names_found;
- for (const TQString &dirName : dirList)
+ for (const TQString &dirname : dirList)
{
- TQDir dir(dirName);
+ TQDir dir(dirname);
if (!dir.exists())
{
continue;
@@ -151,9 +154,9 @@ KURL AppImpl::findBaseURL(const TQString &filename) const
kdDebug() << "AppImpl::findBaseURL" << endl;
TQStringList dirList = TDEGlobal::dirs()->resourceDirs("system_entries");
- for (const TQString &dirName : dirList)
+ for (const TQString &dirname : dirList)
{
- TQDir dir(dirName);
+ TQDir dir(dirname);
if (!dir.exists())
{
continue;
@@ -165,7 +168,7 @@ KURL AppImpl::findBaseURL(const TQString &filename) const
{
if (fname == filename + ".desktop")
{
- KDesktopFile desktop(dirName + fname, true);
+ KDesktopFile desktop(dirname + fname, true);
if (desktop.readURL().isEmpty())
{
KURL url;
@@ -489,7 +492,6 @@ void AppImpl::slotResult(TDEIO::Job *)
bool AppImpl::listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> &list)
{
-tqWarning("MIKE AppImpl::listAppContents name="+name);
kdDebug() << "AppImpl::listAppContents" << endl;
TDEIO::UDSEntry entry;
@@ -522,10 +524,7 @@ tqWarning("MIKE AppImpl::listAppContents name="+name);
TQStringList AppImpl::getAppAddress(const TQString &name)
{
- TQStringList dirList;
- dirList << "/opt/trinity/bin/";
- dirList << "/usr/bin/";
- dirList << "/usr/local/bin/";
+ TQStringList dirList = TQStringList::split(":", getenv("PATH"));
return getFullLocation(dirList, name,
TQDir::FilterSpec(TQDir::Files | TQDir::Readable), false, false);
@@ -533,6 +532,7 @@ TQStringList AppImpl::getAppAddress(const TQString &name)
TQStringList AppImpl::getFullLocation(const TQStringList &dirList, const TQString &name,
const TQDir::FilterSpec &filter, bool beginswith, bool recursive)
{
+ TQMap<TQString, bool> knownApps;
TQStringList finds;
for (const TQString &dirpath : dirList)
{
@@ -569,7 +569,12 @@ TQStringList AppImpl::getFullLocation(const TQStringList &dirList, const TQStrin
if (name == filename || (beginswith && filename.startsWith(name)))
{
- finds << dirpath + filename;
+ TQString fullname = dirpath + filename;
+ if (!knownApps.contains(fullname))
+ {
+ knownApps[fullname] = true;
+ finds << fullname;
+ }
}
}
}