This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Expose a "load torrent with destination" function

Tags: None
(comma "," separated)
imported4-markr
Registered Member
Posts
1
Karma
0
Hi,

I'd like to request that in addition to the openTorrent and openTorrentSilently functions exposed via dcop, we get one that allows us to supply a destination directory.

Something like that shown below, and then brought out to the dcop interface:

ktorrentcore.cpp:
Code: Select all
void KTorrentCore::loadWithDir(const KURL& url, const QString & dir)
{
        QString target;
        // download the contents
        if (KIO::NetAccess::download(url,target,0))
        {
                if (dir != QString::null)
                {
                        load(target,dir,true);
                }
                // and remove the temp file
                KIO::NetAccess::removeTempFile(target);
        }
        else
        {
                KMessageBox::error(0,KIO::NetAccess::lastErrorString(),i18n("Error"));
        }
}

ktorrentdcop.cpp:
Code: Select all
void KTorrentDCOP::openTorrentWithDir(const QString & file, const QString & dir)
{
       app->loadWithDir(KURL(file), dir);
}

ktorrent.cpp:
Code: Select all
void KTorrent::loadWithDir(const KURL& url, const QString & dir)
{
   m_core->loadWithDir(url, dir);
}


With this in place it makes it pretty easy to do stuff like RSS feed parsing in external scripts using python or something. (Obviously you can already do this, but it's nice to put items that match certain regexs into certain directories).

Appologies if the code is rubbish, I don't know C++, but it seems to work okay. Obviously I haven't shown the headers, and I don't have a kidl file for the dcop stuff because I did it all by hand before discovering it's supposed to be generated. Doh.
George
Moderator
Posts
5421
Karma
1

Wed Aug 23, 2006 5:17 pm
Not a bad idea, I will test it and then add it.

But first I have some bugs to squash.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft