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>
r14.0.x
Michele Calgaro 3 years ago
parent 8e55bfc594
commit aacfa49889
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -18,6 +18,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "appinfo.h"
#include "appimpl.h"
#include <stdlib.h>
@ -33,14 +34,19 @@
#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;
// 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/";
@ -48,6 +54,7 @@ bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list)
dirList << "/usr/local/bin/";
kdDebug() << dirList << endl;
TQValueList<TDEIO::UDSEntry> list;
for (const TQString &dirName : dirList)
{
TQDir dir(dirName);
@ -62,10 +69,19 @@ bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list)
{
createEntry(entry, filename);
list.append(entry);
if (list.count() >= 50)
{
m_slave->listEntries(list);
list.clear();
}
}
return true;
}
if (list.count() > 0)
{
m_slave->listEntries(list);
list.clear();
}
m_slave->finished();
}
bool AppImpl::parseURL(const KURL &url, TQString &name, TQString &path) const

@ -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.

@ -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);

@ -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);

Loading…
Cancel
Save