diff options
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | src/app.cpp | 295 | ||||
-rw-r--r-- | src/app.h | 30 | ||||
-rw-r--r-- | src/appimpl.cpp | 1019 | ||||
-rw-r--r-- | src/appimpl.h | 113 |
5 files changed, 654 insertions, 812 deletions
@@ -3,18 +3,19 @@ TDEIO appinfo The appinfo:/ TDEIO slave combines an application's configuration, data, manual and temp files and folders into a single view. -Type 'appinfo:/' followed by the application name you're interested in the +Type 'app:/' followed by the application name you're interested in the konqueror address bar to get information about the specified application. -Type 'appinfo:/' without an application name to list all the applications -found in the usual suspect directories (e.g. /usr/bin, /usr/local/bin, etc.) +Type 'appinfo:/' without any application name to list all the applications +found in the usual suspect directories (e.g. /usr/bin, /usr/local/bin, etc.). +This may take some time, during which Konqueror will be mostly irresponsive. . Contributing -------------- -If you wish to contribute to katapult, you might do so: +If you wish to contribute to tdeio-appinfo, you might do so: - TDE Gitea Workspace (TGW) collaboration tool. https://mirror.git.trinitydesktop.org/gitea diff --git a/src/app.cpp b/src/app.cpp index ef19b67..da5135e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -19,36 +19,12 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/time.h> -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif - - -#include <tqcstring.h> -#include <tqsocket.h> -#include <tqdatetime.h> -#include <tqbitarray.h> - #include <stdlib.h> -#include <math.h> -#include <unistd.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> -#include <tdeapplication.h> +#include <tqcstring.h> #include <kdebug.h> -#include <tdemessagebox.h> #include <kinstance.h> -#include <tdeglobal.h> -#include <kstandarddirs.h> -#include <tdelocale.h> #include <kurl.h> -#include <ksock.h> #include "app.h" @@ -56,178 +32,157 @@ using namespace TDEIO; extern "C" { - int kdemain(int argc, char **argv) + int kdemain(int argc, char **argv) + { + kdDebug(7101) << "*** Starting tdeio_app " << endl; + + if (argc != 4) { - TDEInstance instance( "tdeio_app" ); - - kdDebug(7101) << "*** Starting tdeio_app " << endl; - - if (argc != 4) { - kdDebug(7101) << "Usage: tdeio_app protocol domain-socket1 domain-socket2" << endl; - exit(-1); - } - - tdeio_appProtocol slave(argv[2], argv[3]); - slave.dispatchLoop(); - - kdDebug(7101) << "*** tdeio_app Done" << endl; - return 0; + kdDebug(7101) << "Usage: tdeio_app protocol domain-socket1 domain-socket2" << endl; + exit(255); } -} + + TDEInstance instance("tdeio_app"); + tdeio_appProtocol slave(argv[2], argv[3]); + slave.dispatchLoop(); + return 0; + } +} tdeio_appProtocol::tdeio_appProtocol(const TQCString &pool_socket, const TQCString &app_socket) : SlaveBase("tdeio_app", pool_socket, app_socket) { - kdDebug() << "tdeio_appProtocol::tdeio_appProtocol()" << endl; + kdDebug() << "tdeio_appProtocol::tdeio_appProtocol()" << endl; } tdeio_appProtocol::~tdeio_appProtocol() { - kdDebug() << "tdeio_appProtocol::~tdeio_appProtocol()" << endl; + kdDebug() << "tdeio_appProtocol::~tdeio_appProtocol()" << endl; } void tdeio_appProtocol::stat(const KURL &url) { - kdDebug() << "tdeio_appProtocol::stat: " << url << endl; - - TQString path = url.path(); - if ( path.isEmpty() || path == "/" ) - { - kdDebug() << "tdeio_appProtocol::stat: " << "creating top level entry" << endl; - // The root is "virtual" - it's not a single physical directory - TDEIO::UDSEntry entry; - m_impl.createTopLevelEntry( entry ); - statEntry( entry ); - finished(); - return; - } - - TQString name; - bool ok = m_impl.parseURL(url, name, path); - - if ( !ok ) - { - kdDebug() << "tdeio_appProtocol::stat: " << "can't parse url" << endl; - error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); - return; - } - - - if( path.isEmpty() ) - { - kdDebug() << "tdeio_appProtocol::stat4: " << "url empty after parsing" << endl; - - TDEIO::UDSEntry entry; - - if ( m_impl.statByName(name, entry) ) - { - statEntry(entry); - finished(); - } - else - { - error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL()); - } - } - else - { - kdDebug() << "tdeio_appProtocol::stat4: " << "url not empty after parsing: statting" << endl; - SlaveBase::stat(url); - } + kdDebug() << "tdeio_appProtocol::stat: " << url << endl; + + TQString path = url.path(); + if (path.isEmpty() || path == "/") + { + kdDebug() << "tdeio_appProtocol::stat: " << "creating top level entry" << endl; + // The root is "virtual" - it's not a single physical directory + TDEIO::UDSEntry entry; + m_impl.createTopLevelEntry(entry); + statEntry(entry); + finished(); + return; + } + + TQString name; + bool ok = m_impl.parseURL(url, name, path); + if (!ok) + { + kdDebug() << "tdeio_appProtocol::stat: " << "can't parse url" << endl; + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return; + } + + if (path.isEmpty()) + { + kdDebug() << "tdeio_appProtocol::stat: " << "url empty after parsing" << endl; + + TDEIO::UDSEntry entry; + if (m_impl.statByName(name, entry)) + { + statEntry(entry); + finished(); + } + else + { + error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL()); + } + } + else + { + kdDebug() << "tdeio_appProtocol::stat: " << "url not empty after parsing: statting" << endl; + SlaveBase::stat(url); + } } void tdeio_appProtocol::listDir(const KURL &url) { - kdDebug() << "tdeio_appProtocol::listDir: " << url << endl; - - if ( url.path().length() <= 1 ) - { - kdDebug() << "tdeio_appProtocol::listDir: " << "url empty: listing root" << endl; - listRoot(); - return; - } - - TQString name, path; - bool ok = m_impl.parseURL(url, name, path); - - if ( !ok ) - { - error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); - return; - } - - kdDebug() << "tdeio_appProtocol::listDir: " << "url is " << url << ": doing a listDir" << endl; - kdDebug() << "tdeio_appProtocol::listDir: " << "name is " << name << ": doing a listDir" << endl; - kdDebug() << "tdeio_appProtocol::listDir: " << "path is " << path << ": doing a listDir" << endl; - // We've been given something like app:/appname - listAppContents(name); + kdDebug() << "tdeio_appProtocol::listDir: " << url << endl; + + if (url.path().length() <= 1) + { + kdDebug() << "tdeio_appProtocol::listDir: " << "url empty: listing root" << endl; + listRoot(); + return; + } + + TQString name, path; + bool ok = m_impl.parseURL(url, name, path); + if (!ok) + { + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return; + } + + kdDebug() << "tdeio_appProtocol::listDir: " << "url is " << url << ": doing a listDir" << endl; + kdDebug() << "tdeio_appProtocol::listDir: " << "name is " << name << ": doing a listDir" << endl; + kdDebug() << "tdeio_appProtocol::listDir: " << "path is " << path << ": doing a listDir" << endl; + // We've been given something like app:/appname + + listAppContents(name); } void tdeio_appProtocol::listRoot() { - TDEIO::UDSEntry entry; - - 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); - - m_impl.createTopLevelEntry(entry); - listEntry(entry, false); - - TDEIO::UDSEntryListIterator it = system_entries.begin(); - TDEIO::UDSEntryListIterator end = system_entries.end(); - - for(; it!=end; ++it) - { - listEntry(*it, false); - } - - entry.clear(); - listEntry(entry, true); - - finished(); + TDEIO::UDSEntry entry; + 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); + + m_impl.createTopLevelEntry(entry); + listEntry(entry, false); + for(const UDSEntry &sysEntry : system_entries) + { + listEntry(sysEntry, false); + } + + entry.clear(); + listEntry(entry, true); + finished(); } - void tdeio_appProtocol::listAppContents(const TQString &name) { - TDEIO::UDSEntry entry; - - TDEIO::UDSEntryList app_entries; - bool ok = m_impl.listAppContents(name, app_entries); - - if (!ok) - { - error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() ); - return; - } - - totalSize(app_entries.count()+1); - - m_impl.createTopLevelEntry(entry); - listEntry(entry, false); - - TDEIO::UDSEntryListIterator it = app_entries.begin(); - TDEIO::UDSEntryListIterator end = app_entries.end(); - - for(; it!=end; ++it) - { - listEntry(*it, false); - } - - entry.clear(); - listEntry(entry, true); - - finished(); - + TDEIO::UDSEntry entry; + TDEIO::UDSEntryList app_entries; + bool ok = m_impl.listAppContents(name, app_entries); + if (!ok) + { + error(m_impl.lastErrorCode(), m_impl.lastErrorMessage()); + return; + } + + totalSize(app_entries.count() + 1); + + m_impl.createTopLevelEntry(entry); + listEntry(entry, false); + for(const UDSEntry &appEntry : app_entries) + { + listEntry(appEntry, false); + } + + entry.clear(); + listEntry(entry, true); + finished(); } @@ -18,36 +18,30 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef _app_H_ -#define _app_H_ +#ifndef TDEIO_APP_H_ +#define TDEIO_APP_H_ -#include <tqstring.h> -#include <tqcstring.h> - -#include <stdio.h> - -#include <tdeio/tcpslavebase.h> - -#include <kurl.h> -#include <tdeio/global.h> #include <tdeio/slavebase.h> #include "appimpl.h" class TQCString; +class TQString; +class KURL; class tdeio_appProtocol : public TDEIO::SlaveBase { public: - tdeio_appProtocol(const TQCString &pool_socket, const TQCString &app_socket); - virtual ~tdeio_appProtocol(); - virtual void listDir(const KURL & url); - virtual void stat(const KURL & url); + tdeio_appProtocol(const TQCString &pool_socket, const TQCString &app_socket); + virtual ~tdeio_appProtocol(); + virtual void listDir(const KURL &url); + virtual void stat(const KURL &url); private: - void listRoot(); - void listAppContents(const TQString &name); - AppImpl m_impl; + void listRoot(); + void listAppContents(const TQString &name); + + AppImpl m_impl; }; #endif diff --git a/src/appimpl.cpp b/src/appimpl.cpp index 3bcc079..8676bcf 100644 --- a/src/appimpl.cpp +++ b/src/appimpl.cpp @@ -1,5 +1,4 @@ /*************************************************************************** - * $Id: tork.cpp,v 1.160 2007/12/30 12:58:22 hoganrobert Exp $ * Copyright (C) 2006 by Robert Hogan * * robert@roberthogan.net * * * @@ -18,41 +17,20 @@ * Free Software Foundation, Inc., * * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -/* This file is part of the KDE project - Copyright (c) 2004 Kevin Ottens <ervin ipsquad net> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ #include "appimpl.h" +#include <tqapplication.h> +#include <tqeventloop.h> + #include <kdebug.h> -#include <tdeglobalsettings.h> #include <kstandarddirs.h> #include <kdesktopfile.h> #include <tdelocale.h> -#include <kiconloader.h> #include <kservice.h> #include <kservicegroup.h> +#include <tdeio/job.h> -#include <tqapplication.h> -#include <tqeventloop.h> -#include <tqdir.h> - -#include <sys/stat.h> #include <stdlib.h> @@ -62,639 +40,570 @@ AppImpl::AppImpl() : TQObject() bool AppImpl::listRoot(TQValueList<TDEIO::UDSEntry> &list) { + kdDebug() << "AppImpl::listRoot" << endl; + + TQStringList dirList = TQStringList::split(":", getenv("PATH")); + kdDebug() << dirList << endl; + + TQStringList names_found; + 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) + { + if (!names_found.contains(filename)) + { + entry.clear(); + createEntry(entry, filename); + if (!entry.isEmpty()) + { + list.append(entry); + names_found.append(filename); + } + } + } + } - kdDebug() << "AppImpl::listRoot" << endl; - - - TQStringList dirList = TQStringList::split(":",getenv("PATH")); - kdDebug() << dirList << endl; - TQStringList names_found; -// TQStringList dirList; -// dirList << "/usr/local/bin/"; -// dirList << "/usr/bin/"; -// dirList << "/usr/sbin/"; -// dirList << "/bin/"; - - - TQStringList::ConstIterator dirpath = dirList.begin(); - TQStringList::ConstIterator end = dirList.end(); - for(; dirpath!=end; ++dirpath) - { - TQDir dir = *dirpath; - if (!dir.exists()) continue; - - TQStringList filenames - = dir.entryList( TQDir::Files | TQDir::Readable ); - - TDEIO::UDSEntry entry; - - TQStringList::ConstIterator filename = filenames.begin(); - TQStringList::ConstIterator endf = filenames.end(); - - for(; filename!=endf; ++filename) - { - if (!names_found.contains(*filename)) - { - entry.clear(); - createEntry(entry, /**dirpath,*/ *filename); - if ( !entry.isEmpty() ) - { - list.append(entry); - names_found.append(*filename); - } - } - } - } - - kdDebug() << "AppImpl::listRoot" << endl; - - return true; + return true; } bool AppImpl::parseURL(const KURL &url, TQString &name, TQString &path) const { - TQString url_path = url.path(); - - int i = url_path.find('/', 1); - if (i > 0) - { - name = url_path.mid(1, i-1); - path = url_path.mid(i+1); - } - else - { - name = url_path.mid(1); - path = TQString::null; - } - - return name != TQString::null; + kdDebug() << "AppImpl::parseURL" << endl; + TQString url_path = url.path(); + + int i = url_path.find('/', 1); + if (i > 0) + { + name = url_path.mid(1, i-1); + path = url_path.mid(i+1); + } + else + { + name = url_path.mid(1); + path = TQString::null; + } + + return !name.isEmpty(); } -bool AppImpl::realURL(const TQString &name, const TQString &path, - KURL &url) const +bool AppImpl::realURL(const TQString &name, const TQString &path, KURL &url) const { - url = findBaseURL(name); - if (!url.isValid()) - { - return false; - } - - url.addPath(path); - return true; + url = findBaseURL(name); + if (!url.isValid()) + { + return false; + } + + url.addPath(path); + return true; } bool AppImpl::statByName(const TQString &filename, TDEIO::UDSEntry& entry) { + kdDebug() << "AppImpl::statByName" << endl; + + TQStringList dirList; + dirList << "/usr/bin/"; + dirList << "/usr/local/bin/"; + dirList << "/opt/trinity/bin/"; + + TQStringList names_found; + 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 &fname : filenames) + { + if (fname == filename) + { + createEntry(entry, fname); + return true; + } + } + } - kdDebug() << "AppImpl::statByName" << endl; - - TQStringList dirList; - dirList << "/usr/local/bin/"; - dirList << "/usr/bin/"; - - TQStringList::ConstIterator dirpath = dirList.begin(); - TQStringList::ConstIterator end = dirList.end(); - for(; dirpath!=end; ++dirpath) - { - TQDir dir = *dirpath; - if (!dir.exists()) continue; - - TQStringList filenames - = dir.entryList( TQDir::Files | TQDir::Readable ); - - - TQStringList::ConstIterator name = filenames.begin(); - TQStringList::ConstIterator endf = filenames.end(); - - for(; name!=endf; ++name) - { - if (*name==filename) - { - createEntry(entry, /**dirpath,*/ *name); - return true; - } - } - } - - return false; + return false; } KURL AppImpl::findBaseURL(const TQString &filename) const { - kdDebug() << "AppImpl::findBaseURL" << endl; - - TQStringList dirList = TDEGlobal::dirs()->resourceDirs("system_entries"); - - TQStringList::ConstIterator dirpath = dirList.begin(); - TQStringList::ConstIterator end = dirList.end(); - for(; dirpath!=end; ++dirpath) - { - TQDir dir = *dirpath; - if (!dir.exists()) continue; - - TQStringList filenames - = dir.entryList( TQDir::Files | TQDir::Readable ); - - - TDEIO::UDSEntry entry; - - TQStringList::ConstIterator name = filenames.begin(); - TQStringList::ConstIterator endf = filenames.end(); - - for(; name!=endf; ++name) - { - if (*name==filename+".desktop") - { - KDesktopFile desktop(*dirpath+filename+".desktop", true); - if ( desktop.readURL().isEmpty() ) - { - KURL url; - url.setPath( desktop.readPath() ); - return url; - } - - return desktop.readURL(); - } - } - } - - return KURL(); + kdDebug() << "AppImpl::findBaseURL" << endl; + + TQStringList dirList = TDEGlobal::dirs()->resourceDirs("system_entries"); + 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 &fname : filenames) + { + if (fname == filename + ".desktop") + { + KDesktopFile desktop(dirName + fname, true); + if (desktop.readURL().isEmpty()) + { + KURL url; + url.setPath(desktop.readPath()); + return url; + } + return desktop.readURL(); + } + } + } + + return KURL(); } static void addAtom(TDEIO::UDSEntry &entry, unsigned int ID, long l, const TQString &s = TQString::null) { - TDEIO::UDSAtom atom; - atom.m_uds = ID; - atom.m_long = l; - atom.m_str = s; - entry.append(atom); + TDEIO::UDSAtom atom; + atom.m_uds = ID; + atom.m_long = l; + atom.m_str = s; + entry.append(atom); } - void AppImpl::createTopLevelEntry(TDEIO::UDSEntry &entry) const { - entry.clear(); - addAtom(entry, TDEIO::UDS_NAME, 0, "."); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_ACCESS, 0555); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/system_directory"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "system"); + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, "."); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_ACCESS, 0555); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/system_directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "system"); } -void AppImpl::createEntry(TDEIO::UDSEntry &entry, -// const TQString &directory, - const TQString &file) +void AppImpl::createEntry(TDEIO::UDSEntry &entry, const TQString &file) { - - entry.clear(); - - addAtom(entry, TDEIO::UDS_NAME, 0, file); - - TQString new_filename = file; - new_filename.truncate(file.length()-8); - addAtom(entry, TDEIO::UDS_URL, 0, "app:/"+new_filename); - - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - - KService::Ptr service = KService::serviceByDesktopName( new_filename ); - if (service && service->isValid()) - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, service->icon()); - else - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binary"); - + entry.clear(); + + addAtom(entry, TDEIO::UDS_NAME, 0, file); + + TQString new_filename = file; + new_filename.truncate(file.length() - 8); + addAtom(entry, TDEIO::UDS_URL, 0, "app:/" + new_filename); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + + KService::Ptr service = KService::serviceByDesktopName(new_filename); + if (service && service->isValid()) + { + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, service->icon()); + } + else + { + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binary"); + } } void AppImpl::createExeEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, const TQString &shortname, const TQStringList &fullname) { + for (const TQString &name : fullname) + { + if (name.isEmpty()) + { + continue; + } - - for ( TQStringList::ConstIterator it = fullname.begin(); it != fullname.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - entry.clear(); - -/* TQStringList dirList = TDEGlobal::instance()->dirs()->resourceDirs("apps"); - kdDebug() << dirList << endl; - TQStringList desktop = getFullLocation(dirList,shortname+".desktop", - TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), - false,true); - kdDebug() << desktop << endl;*/ - KService::Ptr service = KService::serviceByDesktopName( shortname ); - -// if (!desktop.isEmpty()){ - if (service && service->isValid()) { - -// for ( TQStringList::Iterator dit = desktop.begin(); dit != desktop.end(); ++dit ) -// { -// if ((*dit).isEmpty()) -// continue; -// entry.clear(); - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Application (%1)").arg(service->name())); - addAtom(entry, TDEIO::UDS_URL, 0, locate("apps", service->desktopEntryPath())); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application/x-desktop"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, service->icon()); -// createFileEntry(entry, service->name(), url.url(1)+service->desktopEntryName(), -// "application/x-desktop", service->icon(), locate("apps", -// service->desktopEntryPath()) ); - - if ( !entry.isEmpty() ) - list.append(entry); -// } - return; - } - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Application (%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_URL, 0, *it); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application"); - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binary"); - if ( !entry.isEmpty() ) - list.append(entry); + entry.clear(); + KService::Ptr service = KService::serviceByDesktopName(shortname); + if (service && service->isValid()) + { + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Application (%1)").arg(service->name())); + addAtom(entry, TDEIO::UDS_URL, 0, locate("apps", service->desktopEntryPath())); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application/x-desktop"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, service->icon()); + list.append(entry); + return; } + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Application (%1)").arg(name)); + addAtom(entry, TDEIO::UDS_URL, 0, name); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binary"); + list.append(entry); + } } -void AppImpl::createManPageEntry(TDEIO::UDSEntry &entry, - const TQString &shortname) +void AppImpl::createManPageEntry(TDEIO::UDSEntry &entry, const TQString &shortname) { - - entry.clear(); - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Manual for %1").arg(shortname)); - -/* TQString new_filename = file; - new_filename.truncate(file.length()-8);*/ - addAtom(entry, TDEIO::UDS_URL, 0, "man:/"+shortname); - - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application/x-desktop"); - - TQString icon = "man"; - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); + entry.clear(); + 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); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "application/x-desktop"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "man"); } void AppImpl::createHomeDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, const TQString &shortname) { - - TQStringList homedir; - homedir << TQString("%1/").arg(getenv("HOME")); - - TQString dirname = "."+shortname; - TQStringList fullname = getFullLocation(homedir,dirname, - TQDir::FilterSpec(TQDir::Hidden | TQDir::Dirs | TQDir::Readable), - true, false); - - for ( TQStringList::Iterator it = fullname.begin(); it != fullname.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - entry.clear(); - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("User Data (%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_URL, 0, *it); - - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - - TQString icon = "cachefolder"; - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); - if ( !entry.isEmpty() ) - list.append(entry); + TQStringList homedir; + homedir << TQString("%1/").arg(getenv("HOME")); + TQString dirname = "." + shortname; + TQStringList fullname = getFullLocation(homedir, dirname, + TQDir::FilterSpec(TQDir::Hidden | TQDir::Dirs | TQDir::Readable), true, false); + + for (const TQString &fname : fullname) + { + if (fname.isEmpty()) + { + continue; } + + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("User Data (%1)").arg(fname)); + addAtom(entry, TDEIO::UDS_URL, 0, fname); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "cachefolder"); + list.append(entry); + } } -void AppImpl::createKDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, +void AppImpl::createTDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, const TQString &shortname) { - - TQStringList dirList = TDEGlobal::instance()->dirs()->resourceDirs("data"); - - TQStringList KDEDataDir = getFullLocation(dirList,shortname, - TQDir::FilterSpec(TQDir::Dirs | TQDir::Readable), false, false); - if (KDEDataDir.isEmpty()) - return; - - - for ( TQStringList::Iterator it = KDEDataDir.begin(); it != KDEDataDir.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - entry.clear(); - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("App Data (%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_URL, 0, *it); - - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - - TQString icon = "binaryfolder"; - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); - if ( !entry.isEmpty() ) - list.append(entry); + TQStringList dirList = TDEGlobal::instance()->dirs()->resourceDirs("data"); + TQStringList TDEDataDir = getFullLocation(dirList, shortname, + TQDir::FilterSpec(TQDir::Dirs | TQDir::Readable), false, false); + if (TDEDataDir.isEmpty()) + { + return; + } + + for (const TQString &dirname : TDEDataDir) + { + if (dirname.isEmpty()) + { + continue; } + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("App Data (%1)").arg(dirname)); + addAtom(entry, TDEIO::UDS_URL, 0, dirname); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binaryfolder"); + list.append(entry); + } } -void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, - const TQString &shortname) +void AppImpl::createStandardDataDirEntry(TQValueList<TDEIO::UDSEntry> &list, + TDEIO::UDSEntry &entry, const TQString &shortname) { - - - TQStringList dirList; - dirList << "/usr/share/"; - dirList << "/usr/local/share/"; - - TQStringList StandardDataDir = - getFullLocation(dirList,shortname, - TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), - true, false); - - if (StandardDataDir.isEmpty()) - return; - - for ( TQStringList::Iterator it = StandardDataDir.begin(); it != StandardDataDir.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - entry.clear(); - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("App Data (%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_URL, 0, *it); - - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - - TQString icon = "binaryfolder"; - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); - if ( !entry.isEmpty() ) - list.append(entry); + TQStringList dirList; + dirList << "/usr/share/"; + dirList << "/usr/local/share/"; + dirList << "/opt/trinity/share/"; + TQStringList StandardDataDir = getFullLocation(dirList, shortname, + TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), true, false); + if (StandardDataDir.isEmpty()) + { + return; + } + + for (const TQString &dirname : StandardDataDir) + { + if (dirname.isEmpty()) + { + continue; } + + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("App Data (%1)").arg(dirname)); + addAtom(entry, TDEIO::UDS_URL, 0, dirname); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "binaryfolder"); + list.append(entry); + } } -void AppImpl::createKDEConfigEntry(TDEIO::UDSEntry &entry, - const TQString &shortname) +void AppImpl::createTDEConfigEntry(TDEIO::UDSEntry &entry, const TQString &shortname) { - - entry.clear(); - - TQString KDEDataDir = locate("config", shortname+"rc"); - kdDebug() << "KDEDataDir: " << KDEDataDir << endl; - - if (KDEDataDir.isEmpty()) - return; - - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config File (%1)").arg(KDEDataDir)); - addAtom(entry, TDEIO::UDS_URL, 0, KDEDataDir); - - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); - - TQString icon = "configure"; - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); + TQString TDEDataDir = locate("config", shortname + "rc"); + kdDebug() << "TDEDataDir: " << TDEDataDir << endl; + if (TDEDataDir.isEmpty()) + { + return; + } + + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config File (%1)").arg(TDEDataDir)); + addAtom(entry, TDEIO::UDS_URL, 0, TDEDataDir); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "configure"); } void AppImpl::createStandardConfigEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, const TQString &shortname) { + TQStringList dirList; + dirList << "/etc/"; + dirList << "/usr/etc/"; + dirList << "/usr/local/etc/"; + dirList << "/opt/trinity/etc/"; + TQStringList StandardConfigFile = getFullLocation(dirList,shortname, + TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), true, false); + if (StandardConfigFile.isEmpty()) + { + return; + } + + for (const TQString &fname : StandardConfigFile) + { + if (fname.isEmpty()) + { + continue; + } + entry.clear(); + bool isFolder = false; + TQFileInfo fi(fname); + if (fi.isDir()) + { + isFolder = true; + } - TQStringList dirList; - dirList << "/etc/"; - dirList << "/usr/local/etc/"; - dirList << "/usr/etc/"; - - TQStringList StandardConfigFile = - getFullLocation(dirList,shortname, - TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), - true, false); - - if (StandardConfigFile.isEmpty()) - return; - - for ( TQStringList::Iterator it = StandardConfigFile.begin(); it != StandardConfigFile.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - entry.clear(); + kdDebug() << "createStandardConfigEntry: " << fname << endl; - bool isFolder = false; - TQFileInfo fi(*it); - if (fi.isDir()) - isFolder = true; - - kdDebug() << "createStandardConfigEntry: " << *it << endl; - - addAtom(entry, TDEIO::UDS_URL, 0, *it); - - TQString icon; - if (isFolder){ - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config Data(%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - icon = "configfolder"; - }else{ - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config File(%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); - icon = "configure"; - } - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); - if ( !entry.isEmpty() ) - list.append(entry); + addAtom(entry, TDEIO::UDS_URL, 0, fname); + TQString icon; + if (isFolder) + { + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config Data(%1)").arg(fname)); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "configfolder"); + } + else + { + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Config File(%1)").arg(fname)); + 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); + } } void AppImpl::createTmpDirEntry(TQValueList<TDEIO::UDSEntry> &list, TDEIO::UDSEntry &entry, const TQString &shortname) { + TQStringList dirList; + dirList << "/tmp/"; + TQStringList TmpDir = getFullLocation(dirList,shortname, + TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), true, true); + if (TmpDir.isEmpty()) + { + return; + } + + for (const TQString &fname : TmpDir) + { + if (fname.isEmpty()) + { + continue; + } + entry.clear(); + bool isFolder = false; + TQFileInfo fi(fname); + if (fi.isDir()) + { + isFolder = true; + } - TQStringList dirList; - dirList << "/tmp/"; - - TQStringList TmpDir = - getFullLocation(dirList,shortname, - TQDir::FilterSpec(TQDir::Files | TQDir::Dirs | TQDir::Readable), - true, true); - - if (TmpDir.isEmpty()) - return; - - for ( TQStringList::Iterator it = TmpDir.begin(); it != TmpDir.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - entry.clear(); + kdDebug() << "createTmpDirEntry: " << fname << endl; - bool isFolder = false; - TQFileInfo fi(*it); - if (fi.isDir()) - isFolder = true; - - kdDebug() << "createTmpDirEntry: " << *it << endl; - - addAtom(entry, TDEIO::UDS_URL, 0, *it); - - TQString icon; - if (isFolder){ - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Tmp Data (%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); - icon = "tmpfolder"; - }else{ - addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Tmp File (%1)").arg(*it)); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); - icon = "eraser"; - } - addAtom(entry, TDEIO::UDS_ICON_NAME, 0, icon); - if ( !entry.isEmpty() ) - list.append(entry); + addAtom(entry, TDEIO::UDS_URL, 0, fname); + if (isFolder) + { + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Tmp Data (%1)").arg(fname)); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "inode/directory"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "tmpfolder"); + } + else + { + addAtom(entry, TDEIO::UDS_NAME, 0, i18n("Tmp File (%1)").arg(fname)); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, "text/plain"); + addAtom(entry, TDEIO::UDS_ICON_NAME, 0, "eraser"); } + list.append(entry); + } } void AppImpl::slotEntries(TDEIO::Job *job, const TDEIO::UDSEntryList &list) { - if (list.size()>0) - { - job->kill(true); - m_lastListingEmpty = false; - tqApp->eventLoop()->exitLoop(); - } + if (list.size() > 0) + { + job->kill(true); + m_lastListingEmpty = false; + tqApp->eventLoop()->exitLoop(); + } } void AppImpl::slotResult(TDEIO::Job *) { - tqApp->eventLoop()->exitLoop(); + tqApp->eventLoop()->exitLoop(); } bool AppImpl::listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> &list) { - - - kdDebug() << "AppImpl::listAppEntries" << endl; - TDEIO::UDSEntry entry; - - //Create entry for binary file - entry.clear(); - createExeEntry(list,entry,name,getAppAddress(name)); -// if ( !entry.isEmpty() ) -// list.append(entry); - - //Create entry for man page - entry.clear(); - createManPageEntry(entry,name); - if ( !entry.isEmpty() ) - list.append(entry); - - //Create entry for apps folder in home dir - entry.clear(); - createHomeDirEntry(list,entry,name); -// if ( !entry.isEmpty() ) -// list.append(entry); - - //Create entry for apps folder in home dir - entry.clear(); - createKDEDataDirEntry(list,entry,name); -// if ( !entry.isEmpty() ) -// list.append(entry); - - //Create entry for apps folder in home dir - entry.clear(); - createStandardDataDirEntry(list,entry,name); -// if ( !entry.isEmpty() ) -// list.append(entry); - - //Create entry for apps folder in home dir - entry.clear(); - createKDEConfigEntry(entry,name); - if ( !entry.isEmpty() ) - list.append(entry); - - //Create entry for apps folder in home dir - entry.clear(); - createStandardConfigEntry(list,entry,name); -// if ( !entry.isEmpty() ) -// list.append(entry); - - //Create entry for apps folder in home dir - entry.clear(); - createTmpDirEntry(list,entry,name); - - return true; + kdDebug() << "AppImpl::listAppEntries" << endl; + TDEIO::UDSEntry entry; + + // Create entry for binary file + entry.clear(); + createExeEntry(list, entry, name, getAppAddress(name)); + if (!entry.isEmpty()) + { + list.append(entry); + } + + // Create entry for man page + entry.clear(); + createManPageEntry(entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + // Create entry for apps folder in home dir + entry.clear(); + createHomeDirEntry(list, entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + // Create entry for apps folder in home dir + entry.clear(); + createTDEDataDirEntry(list, entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + // Create entry for apps folder in home dir + entry.clear(); + createStandardDataDirEntry(list, entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + // Create entry for apps folder in home dir + entry.clear(); + createTDEConfigEntry(entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + // Create entry for apps folder in home dir + entry.clear(); + createStandardConfigEntry(list, entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + //Create entry for apps folder in home dir + entry.clear(); + createTmpDirEntry(list, entry, name); + if (!entry.isEmpty()) + { + list.append(entry); + } + + return true; } TQStringList AppImpl::getAppAddress(const TQString &name) { - - TQStringList dirList; - dirList << "/usr/local/bin/"; - dirList << "/usr/bin/"; - - return getFullLocation(dirList,name, TQDir::FilterSpec(TQDir::Files | TQDir::Readable),false, false); + TQStringList dirList; + dirList << "/usr/bin/"; + dirList << "/usr/local/bin/"; + dirList << "/opt/trinity/bin/"; + return getFullLocation(dirList, name, + TQDir::FilterSpec(TQDir::Files | TQDir::Readable), false, false); } - - -TQStringList AppImpl::getFullLocation(const TQStringList &dirList, const TQString &name, +TQStringList AppImpl::getFullLocation(const TQStringList &dirList, const TQString &name, const TQDir::FilterSpec &filter, bool beginswith, bool recursive) { + TQStringList finds; + for (const TQString &dirpath : dirList) + { + TQDir dir = dirpath; + if (!dir.exists()) + { + continue; + } - TQStringList finds; - TQStringList::ConstIterator dirpath = dirList.begin(); - TQStringList::ConstIterator end = dirList.end(); - for(; dirpath!=end; ++dirpath) - { - TQDir dir = *dirpath; - if (!dir.exists()) continue; - - TQStringList filenames - = dir.entryList( filter ); - - TQStringList::ConstIterator filename = filenames.begin(); - TQStringList::ConstIterator endf = filenames.end(); - - for(; filename!=endf; ++filename) - { - - if ((recursive) && ((*filename != "..")&&(*filename != "."))){ - TQFileInfo fi(*dirpath+*filename); - if (fi.isDir()){ - TQStringList recurfinds; - recurfinds = getFullLocation(TQStringList(*dirpath+*filename+"/"), - name, filter, beginswith, recursive); - if (!recurfinds.isEmpty()){ - for ( TQStringList::Iterator it = recurfinds.begin(); - it != recurfinds.end(); ++it ) - { - if ((*it).isEmpty()) - continue; - finds << (*it); - } - } - } + TQStringList filenames = dir.entryList(filter); + for (const TQString &filename : dirList) + { + if (recursive && filename != ".." && filename != ".") + { + TQFileInfo fi(dirpath + filename); + if (fi.isDir()) + { + TQStringList recurfinds; + recurfinds = getFullLocation(TQStringList(dirpath + filename + "/"), + name, filter, beginswith, recursive); + if (!recurfinds.isEmpty()) + { + for (const TQString &recurFilename : recurfinds) + { + if (recurFilename.isEmpty()) + { + continue; + } + finds << recurFilename; } - - if ((name == *filename) || - ((beginswith) && (*filename).startsWith(name))) - { - finds << *dirpath+*filename; - } - } - } - return finds; + } + } + } + + if (name == filename || (beginswith && filename.startsWith(name))) + { + finds << dirpath + filename; + } + } + } + return finds; } #include "appimpl.moc" diff --git a/src/appimpl.h b/src/appimpl.h index 974f648..3f39858 100644 --- a/src/appimpl.h +++ b/src/appimpl.h @@ -1,5 +1,4 @@ /*************************************************************************** - * $Id: tork.cpp,v 1.160 2007/12/30 12:58:22 hoganrobert Exp $ * Copyright (C) 2006 by Robert Hogan * * robert@roberthogan.net * * * @@ -18,90 +17,74 @@ * Free Software Foundation, Inc., * * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -/* This file is part of the KDE project - Copyright (c) 2004 Kevin Ottens <ervin ipsquad net> - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef APPIMPL_H -#define APPIMPL_H +#ifndef TDEIO_APPIMPL_H +#define TDEIO_APPIMPL_H #include <tdeio/global.h> -#include <tdeio/job.h> -#include <kurl.h> -#include <dcopobject.h> #include <tqobject.h> #include <tqstring.h> #include <tqdir.h> +namespace TDEIO +{ + class Job; +} + +class KURL; + + class AppImpl : public TQObject { -Q_OBJECT + Q_OBJECT + public: - AppImpl(); + AppImpl(); - void createTopLevelEntry(TDEIO::UDSEntry& entry) const; - bool statByName(const TQString &filename, TDEIO::UDSEntry& entry); + void createTopLevelEntry(TDEIO::UDSEntry &entry) const; + bool statByName(const TQString &filename, TDEIO::UDSEntry &entry); - bool listRoot(TQValueList<TDEIO::UDSEntry> &list); + bool listRoot(TQValueList<TDEIO::UDSEntry> &list); + bool listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> &list); - bool parseURL(const KURL &url, TQString &name, TQString &path) const; - bool realURL(const TQString &name, const TQString &path, KURL &url) const; + bool parseURL(const KURL &url, TQString &name, TQString &path) const; + bool realURL(const TQString &name, const TQString &path, KURL &url) const; - int lastErrorCode() const { return m_lastErrorCode; } - TQString lastErrorMessage() const { return m_lastErrorMessage; } - bool listAppContents(const TQString &name, TQValueList<TDEIO::UDSEntry> &list); + int lastErrorCode() const { return m_lastErrorCode; } + TQString lastErrorMessage() const { return m_lastErrorMessage; } private slots: - KURL findBaseURL(const TQString &filename) const; - void slotEntries(TDEIO::Job *job, const TDEIO::UDSEntryList &list); - void slotResult(TDEIO::Job *job); - void createManPageEntry(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 createKDEDataDirEntry(TQValueList<TDEIO::UDSEntry> &list,TDEIO::UDSEntry &entry, - const TQString &shortname); - void createKDEConfigEntry(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); - - TQStringList getAppAddress(const TQString &name); - TQStringList getFullLocation(const TQStringList & dirList, const TQString &name, - const TQDir::FilterSpec &filter, bool beginswith, bool recursive); + KURL findBaseURL(const TQString &filename) const; + void slotEntries(TDEIO::Job *job, const TDEIO::UDSEntryList &list); + void slotResult(TDEIO::Job *job); + void createManPageEntry(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(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); + + TQStringList getAppAddress(const TQString &name); + TQStringList getFullLocation(const TQStringList &dirList, const TQString &name, + const TQDir::FilterSpec &filter, bool beginswith, bool recursive); private: - void createEntry(TDEIO::UDSEntry& entry, /*const TQString &directory,*/ - const TQString &file); + void createEntry(TDEIO::UDSEntry& entry, const TQString &file); - bool m_lastListingEmpty; + bool m_lastListingEmpty; - /// Last error code stored in class to simplify API. - /// Note that this means almost no method can be const. - int m_lastErrorCode; - TQString m_lastErrorMessage; + /// Last error code stored in class to simplify API. + /// Note that this means almost no method can be const. + int m_lastErrorCode; + TQString m_lastErrorMessage; }; #endif |