summaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp295
1 files changed, 125 insertions, 170 deletions
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();
}