summaryrefslogtreecommitdiffstats
path: root/tdeioslave/home/tdeio_home.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 15:11:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 15:11:21 -0600
commit472156a41b1348c714986c772759ad950fffbe75 (patch)
tree86369dab3bbe3d52c49051665bdfb49b9dfc16e3 /tdeioslave/home/tdeio_home.cpp
parent3e891e81335e5243583dab27faeebf001b8139a6 (diff)
downloadtdebase-472156a41b1348c714986c772759ad950fffbe75.tar.gz
tdebase-472156a41b1348c714986c772759ad950fffbe75.zip
Rename kioslaves
Diffstat (limited to 'tdeioslave/home/tdeio_home.cpp')
-rw-r--r--tdeioslave/home/tdeio_home.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/tdeioslave/home/tdeio_home.cpp b/tdeioslave/home/tdeio_home.cpp
new file mode 100644
index 000000000..23d78778b
--- /dev/null
+++ b/tdeioslave/home/tdeio_home.cpp
@@ -0,0 +1,186 @@
+/* This file is part of the KDE project
+ Copyright (c) 2005 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 <stdlib.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kapplication.h>
+#include <dcopclient.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+
+
+#include "tdeio_home.h"
+
+static const KCmdLineOptions options[] =
+{
+ { "+protocol", I18N_NOOP( "Protocol name" ), 0 },
+ { "+pool", I18N_NOOP( "Socket name" ), 0 },
+ { "+app", I18N_NOOP( "Socket name" ), 0 },
+ KCmdLineLastOption
+};
+
+extern "C" {
+ int KDE_EXPORT kdemain( int argc, char **argv )
+ {
+ // TDEApplication is necessary to use other ioslaves
+ putenv(strdup("SESSION_MANAGER="));
+ TDECmdLineArgs::init(argc, argv, "tdeio_home", 0, 0, 0, 0);
+ TDECmdLineArgs::addCmdLineOptions( options );
+ TDEApplication app( false, false );
+ // We want to be anonymous even if we use DCOP
+ app.dcopClient()->attach();
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ HomeProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
+ slave.dispatchLoop();
+ return 0;
+ }
+}
+
+
+HomeProtocol::HomeProtocol(const TQCString &protocol,
+ const TQCString &pool, const TQCString &app)
+ : ForwardingSlaveBase(protocol, pool, app)
+{
+}
+
+HomeProtocol::~HomeProtocol()
+{
+}
+
+bool HomeProtocol::rewriteURL(const KURL &url, KURL &newUrl)
+{
+ TQString name, path;
+
+ if ( !m_impl.parseURL(url, name, path) )
+ {
+ error(TDEIO::ERR_MALFORMED_URL, url.prettyURL());
+ return false;
+ }
+
+
+ if ( !m_impl.realURL(name, path, newUrl) )
+ {
+ error(TDEIO::ERR_MALFORMED_URL, url.prettyURL());
+ return false;
+ }
+
+ return true;
+}
+
+
+void HomeProtocol::listDir(const KURL &url)
+{
+ kdDebug() << "HomeProtocol::listDir: " << url << endl;
+
+ if ( url.path().length() <= 1 )
+ {
+ listRoot();
+ return;
+ }
+
+ TQString name, path;
+ bool ok = m_impl.parseURL(url, name, path);
+
+ if ( !ok )
+ {
+ error(TDEIO::ERR_MALFORMED_URL, url.prettyURL());
+ return;
+ }
+
+ ForwardingSlaveBase::listDir(url);
+}
+
+void HomeProtocol::listRoot()
+{
+ TDEIO::UDSEntry entry;
+
+ TDEIO::UDSEntryList home_entries;
+ bool ok = m_impl.listHomes(home_entries);
+
+ if (!ok) // can't happen
+ {
+ error(TDEIO::ERR_UNKNOWN, "");
+ return;
+ }
+
+ totalSize(home_entries.count()+1);
+
+ m_impl.createTopLevelEntry(entry);
+ listEntry(entry, false);
+
+ TDEIO::UDSEntryListIterator it = home_entries.begin();
+ TDEIO::UDSEntryListIterator end = home_entries.end();
+
+ for(; it!=end; ++it)
+ {
+ listEntry(*it, false);
+ }
+
+ entry.clear();
+ listEntry(entry, true);
+
+ finished();
+}
+
+void HomeProtocol::stat(const KURL &url)
+{
+ kdDebug() << "HomeProtocol::stat: " << url << endl;
+
+ TQString path = url.path();
+ if ( path.isEmpty() || path == "/" )
+ {
+ // 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 )
+ {
+ error(TDEIO::ERR_MALFORMED_URL, url.prettyURL());
+ return;
+ }
+
+ if( path.isEmpty() )
+ {
+ TDEIO::UDSEntry entry;
+
+ if ( m_impl.statHome(name, entry) )
+ {
+ statEntry(entry);
+ finished();
+ }
+ else
+ {
+ error(TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL());
+ }
+ }
+ else
+ {
+ ForwardingSlaveBase::stat(url);
+ }
+}