diff --git a/deluge/ui/web/js/deluge-add.js b/deluge/ui/web/js/deluge-add.js index 700e7f536..79c29994f 100644 --- a/deluge/ui/web/js/deluge-add.js +++ b/deluge/ui/web/js/deluge-add.js @@ -22,12 +22,30 @@ Copyright: */ Deluge.Add = { + torrents: new Hash(), + + onAdd: function() { + torrents = new Array(); + this.torrents.each(function(info, hash) { + torrents.include({ + path: info['filename'], + options: {} + }); + }); + Deluge.Client.web.add_torrents(torrents, { + onSuccess: function(result) { + } + }) + this.Window.hide(); + }, + onRender: function(window) { }, onTorrentAdded: function(info) { this.Store.loadData([[info['info_hash'], info['name']]], true); + this.torrents[info['info_hash']] = info; }, onUrl: function(button, event) { @@ -181,12 +199,11 @@ Deluge.Add.Url.Form = new Ext.form.FormPanel({ Deluge.Add.Url.Window = new Ext.Window({ layout: 'fit', - width: 300, - height: 150, + width: 350, + height: 115, bodyStyle: 'padding: 10px 5px;', buttonAlign: 'center', closeAction: 'hide', - closable: false, modal: true, plain: true, title: _('Add from Url'), @@ -214,7 +231,9 @@ Deluge.Add.Window = new Ext.Window({ buttons: [{ text: _('Cancel') }, { - text: _('Add') + text: _('Add'), + handler: Deluge.Add.onAdd, + scope: Deluge.Add }], listeners: {'render': {fn: Deluge.Add.onRender, scope: Deluge.Add}} }); \ No newline at end of file diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 0f535d494..a588a7ca6 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -24,6 +24,7 @@ import os import time +import base64 import urllib import hashlib import logging @@ -357,8 +358,10 @@ class WebApi(JSONComponent): """ for torrent in torrents: filename = os.path.basename(torrent["path"]) - fdump = open(torrent["path"], "r").read() - client.add_torrent_file(filename, fdump, torrent["options"]) + fdump = base64.encodestring(open(torrent["path"], "r").read()) + log.info("Adding torrent from file `%s` with options `%r`", + filename, torrent["options"]) + client.core.add_torrent_file(filename, fdump, torrent["options"]) d = Deferred() d.callback(True) return d