Starting Plugin Development

saroos1

Member
May 25, 2018
718
0
16
hey everyone

i'm starting to create a small plugin for ruTorrent but i'm having a hard time figure what i can use...theres basically 0 information about it on the web

ruTorrent doesn't have any codex or something like that?

tks
 

saroos1

Member
May 25, 2018
718
0
16
rutorrent is written in javascript and php. look at some of the other plugins for more hints. Also, if you have a specific question, by all means ask.
 

lisas4567

Member
May 25, 2018
773
0
16
that's basically what i'm doing m8 smiley.gif

i was just hopping there would be some info about the available rutorrent objects. (kinda like wordpress has)

anyway at this point i need a function that returns a torrent files list, basically the same info on the Files tab.

wink.gif
 

simur612

Member
May 25, 2018
879
0
16
ok this is where i am atm

Code:
plugin.loadLang();

theWebUI.tables.move =
{
obj: new dxSTable(),
columns:
[
{ text: theUILang.Name, width: "300px", id: "name", type: TYPE_STRING }
],
container: "MoveFileList",
format: theFormatter.files,
onselect: function(e,id) { theWebUI.flsSelect(e,id) }/*,
ondblclick: function(obj)
{
if(!theWebUI.settings["webui.fls.view"] && (theWebUI.dID!=""))
{
var lnk = this.getAttr(obj.id, "link");
if(lnk!=null)
{
theWebUI.dirs[theWebUI.dID].setDirectory(lnk);
this.clearRows();
theWebUI.redrawFilesMove(theWebUI.dID);
}
}
return(false);
}*/
}

theWebUI.redrawFilesMove = function(hash)
{
if(this.dID == hash)
{
var table = this.getTable("move");
for(var i in this.files[hash])
{
var sId = hash + "_f_" + i;
var file = this.files[hash];
file.percent = (file.size > 0) ? theConverter.round((file.done/file.size)*100,1): "100.0";
if(this.settings["webui.fls.view"])
{
if(!$type(table.rowdata[sId]))
table.addRowById(file, sId, file.icon, file.attr);
else
{
for(var j in file)
table.setValueById(sId, j, file[j]);
table.setIcon(sId,file.icon);
table.setAttr(sId,file.attr);
}
}
else
{
if(!$type(this.dirs[hash]))
this.dirs[hash] = new rDirectory();
this.dirs[hash].addFile(file, i);
}
}
if(!this.settings["webui.fls.view"] && this.dirs[hash])
{
var dir = this.dirs[hash].getDirectory();
for(var i in dir)
{
var entry = dir;
if(entry.link!=null)
{
if(!$type(table.rowdata))
table.addRowById(entry.data, i, entry.icon, {link : entry.link});
else
for(var j in entry.data)
table.setValueById(i, j, entry.data[j]);
}
}
for(var i in dir)
{
var entry = dir;
if(entry.link==null)
{
if(!$type(table.rowdata))
table.addRowById(entry.data, i, entry.icon, {link : null});
else
for(var j in entry.data)
table.setValueById(i, j, entry.data[j]);
}
}
}
table.Sort();
}
}

theWebUI.getFilesMove= function(hash, isUpdate)
{
var table = this.getTable("move");
if(!isUpdate)
{
table.dBody.scrollTop = 0;
$(table.tpad).height(0);
$(table.bpad).height(0);
table.clearRows();
}
if($type(this.files[hash]) && !isUpdate)
this.redrawFilesMove(hash);
else
{
if(!$type(this.files[hash]))
this.files[hash] = new Array(0);
this.request("?action=getfiles&hash=" + hash, [this.addFiles, this]);
}
}

if(plugin.enabled)
{
if(plugin.canChangeMenu())
{
plugin.createMenu = theWebUI.createMenu;
theWebUI.createMenu = function( e, id )
{
plugin.createMenu.call(this, e, id);
if(plugin.enabled)
{

//var table = this.getTable("move");
var el = theContextMenu.get( theUILang.Properties );
if( el )
theContextMenu.add([CMENU_SEP]);
theContextMenu.add( el, [theUILang.move+"...", "theWebUI.dummy('" + theWebUI.dID + "')"]);
//theDialogManager.show( "dlg_move" );
//theWebUI.redrawFilesMove.call(this,theWebUI.dID);
}
}
}

theWebUI.dummy = function(dID)
{
theDialogManager.show( "dlg_move" );
theWebUI.getFilesMove.call(this, theWebUI.dID);
}

}

plugin.onLangLoaded = function()
{
theDialogManager.make( 'dlg_move', theUILang.moveDlgCaption,
"<div class='cont fxcaret'>" +
"<fieldset>" +
"<div id='MoveFileList' class='table_tab'>" +
"</div>" +
"</fieldset>" +
"</div>"+
"<div class='aright buttons-list'>" +
"<input type='button' value='" + theUILang.ok + "' class='OK Button' id='btn_move_ok'" +
" onclick='theWebUI.sendmove(); return(false);' />" +
"<input type='button' value='"+ theUILang.Cancel + "' class='Cancel Button'/>" +
"</div>", true);
if(thePlugins.isInstalled("_getdir"))
{
var btn = new theWebUI.rDirBrowser( 'dlg_move', 'edit_move', 'btn_move_browse', 'frame_move_browse' );
theDialogManager.setHandler('dlg_move','afterHide',function()
{
btn.hide();
});
}
else
$('#btn_move_browse').remove();
}

plugin.onRemove = function()
{
theDialogManager.hide("dlg_move");
}
i created a new table (move) based on the "fls" table

i duplicated and renamed getFiles and redrawFiles ho seemed to be the responsible for the files list table.

i have now a context menu ho open (badly) a popup with the files list.

now i have to find a way to add a column with a browse button

any help?
 

peshua19

Member
May 25, 2018
897
0
16
Object dxSTable now doesn't support something like "column with a browse button". You must realize a new column type.
 

simur612

Member
May 25, 2018
879
0
16
relocate how? are you trying to move them on the same system? or send them to a remote server?
 

lisas4567

Member
May 25, 2018
773
0
16
hrm, well when someone says "relocate" i think of moving a file from one location to another. but i could see how your idea would be nice.


Maybe auto-tools should be extended. It already has the ability to move torrents when complete.
 

peshua19

Member
May 25, 2018
897
0
16
ok i changed my approach and started with the easy things first

this is what i've created:

Code:
plugin.loadLang();

if(plugin.enabled)
{
if(plugin.canChangeMenu())
{
plugin.createFileMenu = theWebUI.createFileMenu;
theWebUI.createFileMenu = function( e, id )
{
if(plugin.createFileMenu.call(this, e, id))
{
if(plugin.enabled)
{
theContextMenu.add([CMENU_SEP]);
var fno = null;
var table = this.getTable("fls");
if((table.selCount == 1) && (theWebUI.dID.length==40))
{
var fid = table.getFirstSelected();
if(this.settings["webui.fls.view"])
{
var arr = fid.split('_f_');
fno = arr[1];
}
else
if(!this.dirs[this.dID].isDirectory(fid))
fno = fid.substr(3);
}
theContextMenu.add( [theUILang.Relocate+"...", (fno==null) ? null : "theWebUI.dummy('" + theWebUI.dID + "')"] );
}
return(true);
}
return(false);
}
}

theWebUI.dummy = function(dID)
{
theDialogManager.show( "dlg_relocate" );
log(theWebUI.dID);
}

}

plugin.onLangLoaded = function()
{
theDialogManager.make( 'dlg_relocate', theUILang.RelocateDlgCaption,
"<div class='cont fxcaret'>" +
"<fieldset>" +
"<label id='lbl_relocate' for='edit_relocate'>" + theUILang.Relocate + ": </label>" +
"<input type='file' name='edit_relocate' id='edit_relocate' class='TextboxLarge' size='42'>"+
"<!--<input type='button' id='btn_relocate_browse' class='Button' value='...' />-->" +
"</fieldset>" +
"</div>"+
"<div class='aright buttons-list'>" +
"<input type='button' value='" + theUILang.ok + "' class='OK Button' id='btn_relocate_ok'" +
" onclick='theWebUI.sendRelocate(); return(false);' />" +
"<input type='button' value='"+ theUILang.Cancel + "' class='Cancel Button'/>" +
"</div>", true);
}

plugin.onRemove = function()
{
theDialogManager.hide("dlg_relocate");
}
first thing i've noticed is that popup behavior is totally weird...i have to click multiple times in every button...

can someone take a look at it pls?
 

randac56

Member
May 25, 2018
915
0
16
theContextMenu.add( [theUILang.Relocate+"...", (fno==null) ? null : function() {theWebUI.dummy('" + theWebUI.dID + "');}] );
 

simur612

Member
May 25, 2018
879
0
16
i did what you told but unfortunately the behavior remains...

for example this is my dialog code:

Code:
plugin.onLangLoaded = function()
{
theDialogManager.make( 'dlg_relocate', theUILang.RelocateDlgCaption,
"<div class='cont fxcaret'>" +
"<fieldset>" +
"<label id='lbl_relocate' for='rel_destination'>" + theUILang.RelocateFrmCaption + ": </label>" +
"<input type='text' name='rel_destination' id='rel_destination' class='TextboxLarge' maxlength='200' autocomplete='off' />"+
"<input type='button' id='btn_relocate_browse' class='Button' value='...' />" +
"<input type='hidden' name='rel_id' id='rel_id' />"+
"<input type='hidden' name='rel_fno' id='rel_fno' />"+
"</fieldset>" +
"</div>"+
"<div class='aright buttons-list'>" +
"<input type='button' value='" + theUILang.ok + "' class='OK Button' id='btn_relocate_ok'" +
" onclick='theWebUI.sendRelocate(); return(false);' />" +
"<input type='button' value='"+ theUILang.Cancel + "' class='Cancel Button'/>" +
"</div>", true);
if(thePlugins.isInstalled("_getdir"))
{
var btn = new theWebUI.rDirBrowser( 'dlg_relocate', 'rel_destination', 'btn_relocate_browse', 'frame_relocate_browse',true );
theDialogManager.setHandler('dlg_relocate','afterHide',function()
{
btn.hide();
});
}
else
$('#btn_relocate_browse').remove();
}
but when i choose the file location and dblclick it nothing happens...:/
 

peshua19

Member
May 25, 2018
897
0
16
ok i finally was able to solve it!

the bug was in _getfiles plugin itself. for some weird reason getfiles.php is searching for the imput field "path_edit" instead the variable we passed with rDirBrowser()...this only happens if we use getfiles insead of getdirs...

the solution is to name our field "path_edit" too....

how can i report this bug to the developer?