[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KParts and remote files question
From:       David Faure <faure () kde ! org>
Date:       2006-06-01 12:31:12
Message-ID: 200606011431.12594.faure () kde ! org
[Download RAW message or body]

On Thursday 01 June 2006 13:57, Armando Navarro-Vazquez wrote:
> Dear All:
> I am writing a KParts based application for chemistry stuff. However, to
> adequately parse the files, I need to read not only the m_file member in
> KPart class but also some other files in the same directory.
> For local files this is easy to implement, however I have trouble with
> remote files since m_file points to the temporal file transferred.
> I have to access the m_url member, however I do not have experience with
> KIO slaves and it is not clear for me how to list remote directories. Can
> anyone to point me to some sample code or modern tutorials.

Do you need to list the directory or just to retrieve other files whose name you know
(and therefore you could generate the urls to those files?).

To list a directory, use KIO::listDir. Example (from kio/kurlcompletion.cpp) :

    d->list_job = KIO::listDir( kurl, false );
    connect( d->list_job, SIGNAL(result(KIO::Job*)),
                                this, SLOT(slotListDirFinished(KIO::Job*)) );
    connect( d->list_job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList&)),
                                this, SLOT( slotEntries( KIO::Job*, const KIO::UDSEntryList&)) );
}

And in slotEntries iterate over the entries and extract e.g. the names, see kurlcompletion.cpp 
for details [that stuff has become easier in kde4].
In slotListDirFinished() you know that the directory listing is finished, and you can then
start downloading the files that you want with KIO::get().

But as I said, if you know the names of those files before hand, it might be simpler
to just try to get() them (and maybe ignore errors). This would make it work also
over HTTP, which doesn't support directory listing...

-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic