Groups (for 0.8.4's ratio handling)

4 views
Skip to first unread message

llamaX

unread,
May 26, 2009, 1:20:43 PM5/26/09
to rtGui
I've just hacked together what seems to be semi-functional support for
rTorrent 0.8.4's custom groups (see http://libtorrent.rakshasa.no/wiki/RTorrentRatioHandling#Ratiogroups).

If anyone is interested, please test this and let me know what breaks.

Add this to your functions.php:
// Return custom views as tabs.
function get_view_groups() {
$request = xmlrpc_encode_request("view_list", array());
$response = do_xmlrpc($request);
$retarr = array();

if (xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response
[faultCode])");
} else {
$retarr = array_chunk($response, 10);
$retarr = $retarr[1];
}
}

Add this to control.php in the bulk_action switch:
case ("grp_" == substr($r_bulkaction, 0, 4)):
$viewgroups=do_xmlrpc(xmlrpc_encode_request("d.views",array
("$hash")));
foreach ($viewgroups as $viewgroup) {
do_xmlrpc(xmlrpc_encode_request
("view.set_not_visible",array("$hash","$viewgroup")));
}
$response=do_xmlrpc(xmlrpc_encode_request
("view.set_visible",array("$hash",substr($r_bulkaction, 4))));
break;

Add to index.php by the rate/globalstats variables:
$viewgroups=get_view_groups();

Also index.php, this goes with the rest of the tabs:
if ($displaytrackerurl==TRUE) {
echo "/ <a href='?setsortkey=tracker_url&amp;setsortord=".($_SESSION
['sortord']=="asc" ? "desc" : "asc")."'>Trk</a> ".($_SESSION['sortkey']
=="tracker_url" ? ($_SESSION['sortord']=="asc" ? "$downarr" :
"$uparr") :"");
}

Finally in index.php, add to the bulk_action select:
echo "<optgroup label='Set Group...'>\n";
foreach ($viewgroups as $viewgroup) {
echo "<option value='grp_$viewgroup'>". ucfirst($viewgroup) ."</
option>\n";
}
echo "</optgroup>\n";

I've tested this (with only one group) and it appears to be working
great. Feedback appreciated.
Reply all
Reply to author
Forward
0 new messages