find tdeio plugin
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.
 
 
 
 

146 lines
4.3 KiB

/***************************************************************************
* 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>
#include <dcopclient.h>
#include <tdecmdlineargs.h>
#include <tdeglobal.h>
#include "findurl.h"
#include "find.h"
static const TDECmdLineOptions options[] =
{
{ "+protocol", I18N_NOOP( "Protocol name" ), 0 },
{ "+pool", I18N_NOOP( "Socket name" ), 0 },
{ "+app", I18N_NOOP( "Socket name" ), 0 },
TDECmdLineLastOption
};
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 );
app.dcopClient()->attach();
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
tdeio_findProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
slave.dispatchLoop();
return 0;
}
}
tdeio_findProtocol::tdeio_findProtocol(const TQCString &protocol,
const TQCString &pool, const TQCString &app)
: SlaveBase(protocol, pool, app)
{
}
tdeio_findProtocol::~tdeio_findProtocol()
{
}
void tdeio_findProtocol::listDir(const KURL &url)
{
FindURL furl(url);
if(furl.isMalformed())
{
malformedError(url, TQString("listDir"), furl);
return;
}
if(furl.isNormalised())
{
redirection(KURL(furl));
finished();
return;
}
TDEIO::UDSEntry entry;
TDEIO::UDSEntryList result_list;
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)
{
FindURL furl(url);
if (furl.isMalformed())
{
malformedError(url, TQString("rewriteURL"), furl);
return;
}
if(furl.isNormalised())
{
redirection(KURL(furl));
finished();
return;
}
if(!furl.hasSearch())
{
TDEIO::UDSEntry entry;
m_impl.createTopLevelEntry(entry);
statEntry(entry);
finished();
return;
}
TDEIO::UDSEntry entry;
m_impl.createSearchSecondLevelEntry(entry , furl.search());
statEntry(entry);
finished();
return;
}
void tdeio_findProtocol::malformedError(const KURL& url, TQString func, FindURL& furl)
{
TQString msg = url.url() + ", " + func + ", path=" + url.path() + "|search=" + furl.search() + "|filter=" + furl.filter() + "|query=" + furl.query() + "|ref=" + furl.ref();
error(TDEIO::ERR_MALFORMED_URL, msg);
}