Version: 2.0beta (using KDE KDE 3.5.2) Installed from: Ubuntu Packages You should be able to send most commands and get most information available through the KTorrent GUI using DCOP. Start, stop, remove, manual announce, change file selection / priority, status, speed, etc.
Created attachment 16366 [details] greatly extend the KTorrent DCOP interface This patch adds the following DCOP commands to KTorrent: QValueList<int> getTorrentNumbers(int type = 3); returns the torX number of all torrents QCStringList getTorrentInfo(int tornumber); returns all the KTorrentView data for a torrent unsigned int getFileCount(int tornumber); returns the number of files in a torrent QCStringList getInfo(); returns the info shown in ktorrent's statusbar QCStringList getFileNames(int tornumber); returns the names of all files in a multi file torrent QValueList<int> getFilePriorities(int tornumber); returns the priorities of all files in a multi file torrent void setFilePriority(int tornumber, unsigned int index, int priority); sets the priority of a file in a multi file torrent void start(int tornumber); starts a torrent void stop(int tornumber, bool user); stops a torrent void remove(int tornumber, bool del_data); removes a torrent void announce(int tornumber); does a manual announce
Some more things that should be added: 1. queue manager stuff 2. get the info shown on the infowidget status tab 3. set the max ratio 4. get the info shown on the infowidget tracker tab 5. add / change trackers Also, a console program should be added to ktorrent that will allow you to easily see and control what's going on with KTorrent from the command line. This will satisfy the people who like Ktorrent but also like being able to use their bittorrent client over SSH. I plan to work on this next.
Created attachment 16371 [details] typo fix causing getTorrentNumbers to return all 0s Doh! I managed to reverse the order of some arguments in getTorrentNumbers() before I submitted my patch. Here is the correct version.
Are you sure you included everything, I noticed the last part of the patch adds a subdir named ktconsole, yet I don't see any new files ?
It seems to work OK apart from this missing directory.
Two things: First, I accidentally left in my chink display speed averaging patch in the fix version. If you're still not a fan of that you should take it out. Second, yeah, I had started working on a ktorrent specific easy to use dcop client. I didn't svn add the files yet. It's not close to done yet so just remove that directory. I completely forgot to edit that second diff since I was going to sleep.
Created attachment 16390 [details] updated patch: fix problems and apply cleanly to latest svn This removes the two things mentioned above, and also will now apply cleanly to the latest svn. No actual changes to the code, just fixes the patch.
Created attachment 16392 [details] updated patch: able to get settings you can set This version of the patch allows you to see the current values of all the settings you could already set. I meant to do this before but forgot.
Created attachment 16396 [details] A shell script that makes using the dcop interface easy I don't know if you're interested in including this with KTorrent, but lots of people will only use clients they can control remotely through a web interface or via SSH. This script makes that much easier and more user friendly than just using the standard console dcop client directly. It gives access to all of KTorrent's dcop features, and organizes them and the information they provide. If it doesn't automatically detect the dcop server (which it won't over SSH), it will let the user specify the username of the server to connect to. As long as the user is logged in as that user or another who has permission to connect to that server (like root) it will work.
Created attachment 16397 [details] updated patch: make sure things get updated This is a tiny fix to make sure things get updated so the DCOP methods pass the right information.
I will do some more tests on the patch and then commit it. That script is interesting, allthough it doesn't seem to work properly here. I get into the menu and then it allways craps out with line 111: dcop ktorrent KTorrent command not found. Btw, when this script is working, you might want to make a topic about it on the forums.
Created attachment 16410 [details] updated dcop shell script: hopefully fix problems I don't have that problem, but I bet I know what causes it. I do some wierd stuff to make sure I get line break separated input instead of space separated input. As a result, the $ktorrent variable has to look like this: /usr/bin/dcop --user username ktorrent KTorrent method arg For me, that seems to work whether or not I mess with line breaks vs. spaces, but maybe for you it doesn't. However, if I remove the line breaks from the variable, I get the same error as you. I have changed it so that all calls to dcop are made while the same settings are in effect. It doesn't break anything for me. Please let me know if it fixes things for you. I also added an "about this script" option to the main menu (so there would be an even number of choices). If that doesn't fix it for you, keep reading. At the main menu, do you see something like this: Totals: Transferred up: 46.4 MB / down: 576.4 MB Speed up: 0.0 KB/s / down: 0.0 KB/s DHT: 0 nodes, 0 tasks (Menu Here) If you see that, could you put: echo "\"$ktorrent\""; read on the line right before you get the error and tell me what you see? (The read gives you time to see what it says). If you don't see that, please put that statement in the mainmenu function around line 260.
Created attachment 16413 [details] updated patch: allow most settings to be grabbed with one call
Created attachment 16417 [details] updated dcop shell script: greatly reduce the number of dcop calls This version of the script invokes the console dcop client much less that the previous version. The script uses dcop's --pipe option for listing torrents and setting priorities, and uses the new intSettings call I added with the latest version of my patch to reduce the number of invocations necissary to retrieve the current settings. No more than two invocations need to be done at a time now. Sorry I always shoot off a million versions of everything.
SVN commit 547634 by guisson: Added Adam Forsyth's patch which expands the DCOP interface significantly. BUG: 128332 M +19 -0 apps/ktorrent/dcopinterface.h M +35 -1 apps/ktorrent/ktorrent.cpp M +7 -2 apps/ktorrent/ktorrent.h M +129 -0 apps/ktorrent/ktorrentcore.cpp M +11 -0 apps/ktorrent/ktorrentcore.h M +120 -1 apps/ktorrent/ktorrentdcop.cpp M +19 -0 apps/ktorrent/ktorrentdcop.h M +19 -0 apps/ktorrent/ktorrentview.cpp M +4 -0 apps/ktorrent/ktorrentview.h M +2 -1 plugins/infowidget/infowidget.cpp
Btw, the script seems to work now.
Created attachment 16436 [details] updated shell script: less dcop calls, other minor improvements Glad the script works for you now. It's no longer necissary for the script to call dcop after you select a torrent from the torrent list. Several dcop invocations have been moved "up" out of loops or functions so they occur less frequently. Getting filecounts for torrents has been changed to use a --pipe dcop call so one call suffices for all the torrents. After changing a setting the settings are redisplayed. Other optimizations.
Created attachment 16438 [details] patch: add a way to get all the integer or boolean settings at once Could you apply this small patch that allows the settings to be grabbed with one call? It's just a convenience, but it comes in handy. It was in the last version of the full patch I posted but you tested and committed the version before that.
I think it would be worth including the script with KTorrent and installing it when KTorrent is installed. When I posted about the beta release on a few forums frequented by BitTorrent users, the majority of responses I got were "Looks nice, but unless I can run it in a screen session or control it with a web interface I'll keep using what I use now". I generally would say the same, but I temporarily have only one computer, so I've had a chance to find KTorrent, and add to it so it will meet my needs once that is no longer the case. You can't really say that the DCOP interface alone fills that need, since it's not very convenient to use. This script however fills it for me, and probably would for many others. I think "Can be controlled remotely using ssh and a simple command line client" would be a good feature to add to KTorrent's list.
I'm impressed, it's a cool script. We will include it with KT.
Created attachment 16481 [details] updated shell script: improved initialization process This version of the shell script has a significantly improved initialization process. - Less dcop invocations during initialization - Better detection / selection of dcop server - Works if KTorrent's dcop appid is "ktorrent-####" rather than just "ktorrent" If you could test it that would be great, since your sytem is different than mine (at least in the value of some environmental variables). In order to test the new functionality, please either try it while there are two running sessions of KDE under two different users or while running a fake dcop server as another user like this: echo "#!/bin/sh while true; do true; done" > dcopserver chmod 755 dcopserver sudo ./dcopserver &
Just a suggestion for naming the script: I think you should leave off the .sh extension because it won't really matter to people whether it's a shell script or a compiled command line program, and people are more likely to use it if they think of it as a "program" rather than a "script". People don't realise they're running a script when they use "startx" or "startkde". I know it doesn't seem like a bid deal but I think it matters. Also, I've known people who assumed a .sh file had to be run like "sh ktshell.sh" like you run a python script with "python pyscript.py" or a perl script with "perl plscript.pl".
Created attachment 16484 [details] patch: change "unsigned int" to "int" Please apply this (trivial) patch. The python DCOP bindings can't handle unsigned ints, so it's necessary to use signed ints instead for python compatibility. Attempting to call a method with an argument of type unsigned int, or which returned an unsigned int, using the python dcop bindings, resulted in a "no such method" error. Using type double also did not work. File indexes and file counts were the only places I was using unsigned ints. I don't think any torrents actually have enough files that this will matter, although I think theoretically one could.