1
/* This file is part of the KDE project
2
Copyright (c) 2005 Kevin Ottens <ervin ipsquad net>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
24
#include <kapplication.h>
25
#include <dcopclient.h>
26
#include <kcmdlineargs.h>
32
static const KCmdLineOptions options[] =
34
{ "+protocol", I18N_NOOP( "Protocol name" ), 0 },
35
{ "+pool", I18N_NOOP( "Socket name" ), 0 },
36
{ "+app", I18N_NOOP( "Socket name" ), 0 },
41
int KDE_EXPORT kdemain( int argc, char **argv )
43
// KApplication is necessary to use other ioslaves
44
putenv(strdup("SESSION_MANAGER="));
45
KCmdLineArgs::init(argc, argv, "kio_home", 0, 0, 0, 0);
46
KCmdLineArgs::addCmdLineOptions( options );
47
KApplication app( false, false );
48
// We want to be anonymous even if we use DCOP
49
app.dcopClient()->attach();
51
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
52
HomeProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
59
HomeProtocol::HomeProtocol(const QCString &protocol,
60
const QCString &pool, const QCString &app)
61
: ForwardingSlaveBase(protocol, pool, app)
65
HomeProtocol::~HomeProtocol()
69
bool HomeProtocol::rewriteURL(const KURL &url, KURL &newUrl)
73
if ( !m_impl.parseURL(url, name, path) )
75
error(KIO::ERR_MALFORMED_URL, url.prettyURL());
80
if ( !m_impl.realURL(name, path, newUrl) )
82
error(KIO::ERR_MALFORMED_URL, url.prettyURL());
90
void HomeProtocol::listDir(const KURL &url)
92
kdDebug() << "HomeProtocol::listDir: " << url << endl;
94
if ( url.path().length() <= 1 )
101
bool ok = m_impl.parseURL(url, name, path);
105
error(KIO::ERR_MALFORMED_URL, url.prettyURL());
109
ForwardingSlaveBase::listDir(url);
112
void HomeProtocol::listRoot()
116
KIO::UDSEntryList home_entries;
117
bool ok = m_impl.listHomes(home_entries);
119
if (!ok) // can't happen
121
error(KIO::ERR_UNKNOWN, "");
125
totalSize(home_entries.count()+1);
127
m_impl.createTopLevelEntry(entry);
128
listEntry(entry, false);
130
KIO::UDSEntryListIterator it = home_entries.begin();
131
KIO::UDSEntryListIterator end = home_entries.end();
135
listEntry(*it, false);
139
listEntry(entry, true);
144
void HomeProtocol::stat(const KURL &url)
146
kdDebug() << "HomeProtocol::stat: " << url << endl;
148
QString path = url.path();
149
if ( path.isEmpty() || path == "/" )
151
// The root is "virtual" - it's not a single physical directory
153
m_impl.createTopLevelEntry( entry );
160
bool ok = m_impl.parseURL(url, name, path);
164
error(KIO::ERR_MALFORMED_URL, url.prettyURL());
172
if ( m_impl.statHome(name, entry) )
179
error(KIO::ERR_DOES_NOT_EXIST, url.prettyURL());
184
ForwardingSlaveBase::stat(url);