diff --git a/deluge/ui/webui/json_api.py b/deluge/ui/webui/json_api.py
index beb25bcb3..054bed2f9 100644
--- a/deluge/ui/webui/json_api.py
+++ b/deluge/ui/webui/json_api.py
@@ -52,7 +52,6 @@ from deluge import component
from utils import dict_cb
from lib import json
-
def json_response(result, id):
print json.write({
"version":"1.1",
@@ -80,7 +79,8 @@ class json_rpc:
* methods : http://dev.deluge-torrent.org/wiki/Development/UiClient#Remoteapi
"""
#extra exposed methods
- json_exposed = ["update_ui","get_stats","set_torrent_options","system_listMethods"]
+ json_exposed = ["update_ui","get_stats","set_torrent_options","system_listMethods",
+ "get_webui_config","set_webui_config"]
cache = {}
torrent_options = ["trackers","max_connections","max_upload_slots","max_upload_speed",
"max_download_speed","file_priorities","prioritize_first_last","auto_managed","stop_at_ratio",
@@ -90,7 +90,6 @@ class json_rpc:
def GET(self):
return json_error("only POST is supported")
-
def POST(self , name=None):
web.header("Content-Type", "application/x-json")
ck = cookies()
@@ -233,6 +232,20 @@ class json_rpc:
func = getattr(sclient, 'set_torrent_' + option)
func(torrent_id, value)
+ def get_webui_config(self):
+ return dict([x for x in utils.config.get_config().iteritems() if not x[0].startswith("pwd")])
+
+ def set_webui_config(self, data):
+ utils.validate_config(data)
+ if "pwd" in data:
+ utils.update_pwd(pwd)
+ del data["pwd"]
+ for key, value in data.iteritems():
+ utils.config.set(key, value)
+ utils.config.save()
+ utils.apply_config()
+
+
def register():
component.get("PageManager").register_page("/json/rpc",json_rpc)
diff --git a/deluge/ui/webui/templates/ajax_demo/index.html b/deluge/ui/webui/templates/ajax_demo/index.html
index 0416baecb..f58c15a34 100644
--- a/deluge/ui/webui/templates/ajax_demo/index.html
+++ b/deluge/ui/webui/templates/ajax_demo/index.html
@@ -86,6 +86,29 @@ function update_ui() {
};
+function get_webui_config() {
+ service.get_webui_config({params:[ ],
+ onSuccess:function(data){
+ alert(service.__toJSON(data));
+ },
+ onException:function(errorObj){
+ alert("Error: " + errorObj);
+ }
+ });
+};
+
+
+function set_webui_config(cfg_dict) {
+ service.set_webui_config({params:[cfg_dict],
+ onSuccess:function(data){
+ alert(service.__toJSON(data));
+ },
+ onException:function(errorObj){
+ alert("Error: " + errorObj);
+ }
+ });
+};
+
@@ -104,6 +127,13 @@ function update_ui() {
+
+
+
+
+
+
+