diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-08 00:26:59 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-08 00:26:59 +0900 |
commit | aacfa4988921bed952fc600dccd7e6ceccb8780c (patch) | |
tree | 19e8ec7f87031e128cbfa10ba29954366c6c8c81 | |
parent | 8e55bfc59469faf50b41d90ac716b89f5fc1c684 (diff) | |
download | tdeio-appinfo-aacfa4988921bed952fc600dccd7e6ceccb8780c.tar.gz tdeio-appinfo-aacfa4988921bed952fc600dccd7e6ceccb8780c.zip |
Improve user experience when requesting the list of available
applications with 'appinfo:/' (makes Konqueror less irresponsive).
Some code renaming for better clarity.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | src/appimpl.cpp | 74 | ||||
-rw-r--r-- | src/appimpl.h | 6 | ||||
-rw-r--r-- | src/appinfo.cpp | 54 | ||||
-rw-r--r-- | src/appinfo.h | 6 |
4 files changed, 72 insertions, 68 deletions
diff --git a/src/appimpl.cpp b/src/appimpl.cpp index f0efb32..cd3fe18 100644 --- a/src/appimpl.cpp +++ b/src/appimpl.cpp @@ -18,6 +18,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ +#include "appinfo.h" #include "appimpl.h" #include <stdlib.h> @@ -33,39 +34,54 @@ #include <tdeio/job.h> -AppImpl::AppImpl() : TQObject() +AppImpl::AppImpl(TDEIO_AppInfo *slave) : TQObject(), m_slave(slave) { } -bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list) +void AppImpl::listRoot() { - kdDebug() << "AppImpl::listRoot" << endl; - - //TQStringList dirList = TQStringList::split(":", getenv("PATH")); - TQStringList dirList; - dirList << "/opt/trinity/bin/"; - dirList << "/usr/bin/"; - dirList << "/usr/local/bin/"; - kdDebug() << dirList << endl; - - for (const TQString &dirName : dirList) - { - TQDir dir(dirName); - if (!dir.exists()) - { - continue; - } - - TQStringList filenames = dir.entryList(TQDir::Files | TQDir::Readable); - TDEIO::UDSEntry entry; - for (const TQString &filename : filenames) - { - createEntry(entry, filename); - list.append(entry); - } - } - - return true; + kdDebug() << "AppImpl::listRoot" << endl; + + // Top level entry + TDEIO::UDSEntry entry; + 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/"; + kdDebug() << dirList << endl; + + TQValueList<TDEIO::UDSEntry> list; + for (const TQString &dirName : dirList) + { + TQDir dir(dirName); + if (!dir.exists()) + { + continue; + } + + TQStringList filenames = dir.entryList(TQDir::Files | TQDir::Readable); + TDEIO::UDSEntry entry; + for (const TQString &filename : filenames) + { + createEntry(entry, filename); + list.append(entry); + if (list.count() >= 50) + { + m_slave->listEntries(list); + list.clear(); + } + } + } + if (list.count() > 0) + { + m_slave->listEntries(list); + list.clear(); + } + m_slave->finished(); } bool AppImpl::parseURL(const KURL &url, TQString &name, TQString &path) const diff --git a/src/appimpl.h b/src/appimpl.h index 554b5ff..f5dadcd 100644 --- a/src/appimpl.h +++ b/src/appimpl.h @@ -33,6 +33,7 @@ namespace TDEIO } class KURL; +class TDEIO_AppInfo; class AppImpl : public TQObject @@ -40,12 +41,12 @@ class AppImpl : public TQObject Q_OBJECT public: - AppImpl(); + AppImpl(TDEIO_AppInfo *slave); void createTopLevelEntry(TDEIO::UDSEntry &entry) const; bool statByName(const TQString &filename, TDEIO::UDSEntry &entry); - bool listRoot(TQValueList<TDEIO::UDSEntry> &list); + void listRoot(); bool listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> &list); bool parseURL(const KURL &url, TQString &name, TQString &path) const; @@ -82,6 +83,7 @@ private: void createEntry(TDEIO::UDSEntry& entry, const TQString &file); bool m_lastListingEmpty; + TDEIO_AppInfo *m_slave; /// Last error code stored in class to simplify API. /// Note that this means almost no method can be const. diff --git a/src/appinfo.cpp b/src/appinfo.cpp index 6cc34f8..0748529 100644 --- a/src/appinfo.cpp +++ b/src/appinfo.cpp @@ -43,34 +43,34 @@ extern "C" } TDEInstance instance("tdeio_appinfo"); - tdeio_appInfoProtocol slave(argv[2], argv[3]); + TDEIO_AppInfo slave(argv[2], argv[3]); slave.dispatchLoop(); return 0; } } -tdeio_appInfoProtocol::tdeio_appInfoProtocol(const TQCString &pool_socket, - const TQCString &app_socket) : SlaveBase("tdeio_appinfo", pool_socket, app_socket) +TDEIO_AppInfo::TDEIO_AppInfo(const TQCString &pool_socket, const TQCString &app_socket) + : SlaveBase("tdeio_appinfo", pool_socket, app_socket), m_impl(this) { - kdDebug() << "tdeio_appInfoProtocol::tdeio_appInfoProtocol()" << endl; + kdDebug() << "TDEIO_AppInfo::TDEIO_AppInfo()" << endl; } -tdeio_appInfoProtocol::~tdeio_appInfoProtocol() +TDEIO_AppInfo::~TDEIO_AppInfo() { - kdDebug() << "tdeio_appInfoProtocol::~tdeio_appInfoProtocol()" << endl; + kdDebug() << "TDEIO_AppInfo::~TDEIO_AppInfo()" << endl; } -void tdeio_appInfoProtocol::stat(const KURL &url) +void TDEIO_AppInfo::stat(const KURL &url) { - kdDebug() << "tdeio_appInfoProtocol::stat: " << url << endl; + kdDebug() << "TDEIO_AppInfo::stat: " << url << endl; TQString path = url.path(); if (path.isEmpty() || path == "/") { - kdDebug() << "tdeio_appInfoProtocol::stat: " << "creating top level entry" << endl; + kdDebug() << "TDEIO_AppInfo::stat: " << "creating top level entry" << endl; // The root is "virtual" - it's not a single physical directory TDEIO::UDSEntry entry; m_impl.createTopLevelEntry(entry); @@ -83,14 +83,14 @@ void tdeio_appInfoProtocol::stat(const KURL &url) bool ok = m_impl.parseURL(url, name, path); if (!ok) { - kdDebug() << "tdeio_appInfoProtocol::stat: " << "can't parse url" << endl; + kdDebug() << "TDEIO_AppInfo::stat: " << "can't parse url" << endl; error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); return; } if (path.isEmpty()) { - kdDebug() << "tdeio_appInfoProtocol::stat: " << "url empty after parsing" << endl; + kdDebug() << "TDEIO_AppInfo::stat: " << "url empty after parsing" << endl; TDEIO::UDSEntry entry; if (m_impl.statByName(name, entry)) @@ -105,18 +105,18 @@ void tdeio_appInfoProtocol::stat(const KURL &url) } else { - kdDebug() << "tdeio_appInfoProtocol::stat: " << "url not empty after parsing: statting" << endl; + kdDebug() << "TDEIO_AppInfo::stat: " << "url not empty after parsing: statting" << endl; SlaveBase::stat(url); } } -void tdeio_appInfoProtocol::listDir(const KURL &url) +void TDEIO_AppInfo::listDir(const KURL &url) { - kdDebug() << "tdeio_appInfoProtocol::listDir: " << url << endl; + kdDebug() << "TDEIO_AppInfo::listDir: " << url << endl; if (url.path().length() <= 1) { - kdDebug() << "tdeio_appInfoProtocol::listDir: " << "url empty: listing root" << endl; + kdDebug() << "TDEIO_AppInfo::listDir: " << "url empty: listing root" << endl; listRoot(); return; } @@ -129,33 +129,19 @@ void tdeio_appInfoProtocol::listDir(const KURL &url) return; } - kdDebug() << "tdeio_appInfoProtocol::listDir: " << "name is " << name << endl; - kdDebug() << "tdeio_appInfoProtocol::listDir: " << "path is " << path << endl; + kdDebug() << "TDEIO_AppInfo::listDir: " << "name is " << name << endl; + kdDebug() << "TDEIO_AppInfo::listDir: " << "path is " << path << endl; // We've been given something like appinfo:/name listAppContents(name); } -void tdeio_appInfoProtocol::listRoot() +void TDEIO_AppInfo::listRoot() { - TDEIO::UDSEntryList system_entries; - bool ok = m_impl.listRoot(system_entries); - if (!ok) - { - error(m_impl.lastErrorCode(), m_impl.lastErrorMessage()); - return; - } - - totalSize(system_entries.count() + 1); - - TDEIO::UDSEntry entry; - m_impl.createTopLevelEntry(entry); - listEntry(entry, false); - listEntries(system_entries); - finished(); + m_impl.listRoot(); } -void tdeio_appInfoProtocol::listAppContents(const TQString &name) +void TDEIO_AppInfo::listAppContents(const TQString &name) { TDEIO::UDSEntryList app_entries; bool ok = m_impl.listAppContents(name, app_entries); diff --git a/src/appinfo.h b/src/appinfo.h index c8b6c57..838c556 100644 --- a/src/appinfo.h +++ b/src/appinfo.h @@ -29,11 +29,11 @@ class TQCString; class TQString; class KURL; -class tdeio_appInfoProtocol : public TDEIO::SlaveBase +class TDEIO_AppInfo : public TDEIO::SlaveBase { public: - tdeio_appInfoProtocol(const TQCString &pool_socket, const TQCString &app_socket); - virtual ~tdeio_appInfoProtocol(); + TDEIO_AppInfo(const TQCString &pool_socket, const TQCString &app_socket); + virtual ~TDEIO_AppInfo(); virtual void listDir(const KURL &url); virtual void stat(const KURL &url); |