summaryrefslogtreecommitdiffstats
path: root/src/appinfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/appinfo.cpp')
-rw-r--r--src/appinfo.cpp175
1 files changed, 175 insertions, 0 deletions
diff --git a/src/appinfo.cpp b/src/appinfo.cpp
new file mode 100644
index 0000000..6cc34f8
--- /dev/null
+++ b/src/appinfo.cpp
@@ -0,0 +1,175 @@
+/***************************************************************************
+ * $Id: tork.cpp,v 1.160 2007/12/30 12:58:22 hoganrobert Exp $
+ * Copyright (C) 2006 by Robert Hogan *
+ * robert@roberthogan.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <stdlib.h>
+
+#include <tqcstring.h>
+#include <kdebug.h>
+#include <kinstance.h>
+#include <kurl.h>
+
+#include "appinfo.h"
+
+using namespace TDEIO;
+
+extern "C"
+{
+ int kdemain(int argc, char **argv)
+ {
+ kdDebug(7101) << "*** Starting tdeio_appinfo " << endl;
+
+ if (argc != 4)
+ {
+ kdDebug(7101) << "Usage: tdeio_appinfo protocol domain-socket1 domain-socket2" << endl;
+ exit(255);
+ }
+
+ TDEInstance instance("tdeio_appinfo");
+ tdeio_appInfoProtocol 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)
+{
+ kdDebug() << "tdeio_appInfoProtocol::tdeio_appInfoProtocol()" << endl;
+}
+
+
+tdeio_appInfoProtocol::~tdeio_appInfoProtocol()
+{
+ kdDebug() << "tdeio_appInfoProtocol::~tdeio_appInfoProtocol()" << endl;
+}
+
+
+void tdeio_appInfoProtocol::stat(const KURL &url)
+{
+ kdDebug() << "tdeio_appInfoProtocol::stat: " << url << endl;
+
+ TQString path = url.path();
+ if (path.isEmpty() || path == "/")
+ {
+ kdDebug() << "tdeio_appInfoProtocol::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_appInfoProtocol::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;
+
+ TDEIO::UDSEntry entry;
+ if (m_impl.statByName(name, entry))
+ {
+ statEntry(entry);
+ finished();
+ }
+ else
+ {
+ error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL());
+ }
+ }
+ else
+ {
+ kdDebug() << "tdeio_appInfoProtocol::stat: " << "url not empty after parsing: statting" << endl;
+ SlaveBase::stat(url);
+ }
+}
+
+void tdeio_appInfoProtocol::listDir(const KURL &url)
+{
+ kdDebug() << "tdeio_appInfoProtocol::listDir: " << url << endl;
+
+ if (url.path().length() <= 1)
+ {
+ kdDebug() << "tdeio_appInfoProtocol::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_appInfoProtocol::listDir: " << "name is " << name << endl;
+ kdDebug() << "tdeio_appInfoProtocol::listDir: " << "path is " << path << endl;
+
+ // We've been given something like appinfo:/name
+ listAppContents(name);
+}
+
+void tdeio_appInfoProtocol::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();
+}
+
+void tdeio_appInfoProtocol::listAppContents(const TQString &name)
+{
+ 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);
+
+ TDEIO::UDSEntry entry;
+ m_impl.createTopLevelEntry(entry);
+ listEntry(entry, false);
+ listEntries(app_entries);
+ finished();
+}