You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.3 KiB

10 years ago
/***************************************************************************
* Copyright (C) 2007 by Andreas Eckstein *
* andreas.eckstein@gmx.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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <kdebug.h>
#include <tdelocale.h>
#include <tdeapplication.h>
10 years ago
#include <dcopclient.h>
#include <tdecmdlineargs.h>
#include <tdeglobal.h>
10 years ago
#include "findurl.h"
#include "find.h"
static const TDECmdLineOptions options[] =
10 years ago
{
{ "+protocol", I18N_NOOP( "Protocol name" ), 0 },
{ "+pool", I18N_NOOP( "Socket name" ), 0 },
{ "+app", I18N_NOOP( "Socket name" ), 0 },
TDECmdLineLastOption
10 years ago
};
extern "C" {
int KDE_EXPORT kdemain( int argc, char **argv )
{
putenv(strdup("SESSION_MANAGER="));
TDECmdLineArgs::init(argc, argv, "tdeio_find", 0, 0, 0, 0);
TDECmdLineArgs::addCmdLineOptions( options );
TDEApplication app( false, false );
10 years ago
app.dcopClient()->attach();
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
tdeio_findProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
10 years ago
slave.dispatchLoop();
return 0;
}
}
tdeio_findProtocol::tdeio_findProtocol(const TQCString &protocol,
const TQCString &pool, const TQCString &app)
10 years ago
: SlaveBase(protocol, pool, app)
{
}
tdeio_findProtocol::~tdeio_findProtocol()
10 years ago
{
}
void tdeio_findProtocol::listDir(const KURL &url)
10 years ago
{
FindURL furl(url);
if(furl.isMalformed())
{
malformedError(url, TQString("listDir"), furl);
10 years ago
return;
}
if(furl.isNormalised())
{
redirection(KURL(furl));
finished();
return;
}
TDEIO::UDSEntry entry;
TDEIO::UDSEntryList result_list;
10 years ago
if(furl.hasSearch())
{
m_impl.createSearchSecondLevelEntry(entry,furl.search());
listEntry(entry,false);
m_impl.listSearch(furl, result_list);
}
else
{
m_impl.createTopLevelEntry(entry);
listEntry(entry,false);
m_impl.listSearches(result_list);
}
totalSize(result_list.count()+1);
listEntries(result_list);
entry.clear();
listEntry(entry, true);
finished();
return;
}
void tdeio_findProtocol::stat(const KURL &url)
10 years ago
{
FindURL furl(url);
if (furl.isMalformed())
{
malformedError(url, TQString("rewriteURL"), furl);
10 years ago
return;
}
if(furl.isNormalised())
{
redirection(KURL(furl));
finished();
return;
}
if(!furl.hasSearch())
{
TDEIO::UDSEntry entry;
10 years ago
m_impl.createTopLevelEntry(entry);
statEntry(entry);
finished();
return;
}
TDEIO::UDSEntry entry;
10 years ago
m_impl.createSearchSecondLevelEntry(entry , furl.search());
statEntry(entry);
finished();
return;
}
void tdeio_findProtocol::malformedError(const KURL& url, TQString func, FindURL& furl)
10 years ago
{
TQString msg = url.url() + ", " + func + ", path=" + url.path() + "|search=" + furl.search() + "|filter=" + furl.filter() + "|query=" + furl.query() + "|ref=" + furl.ref();
10 years ago
error(TDEIO::ERR_MALFORMED_URL, msg);
10 years ago
}