summaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/Makefile2
-rw-r--r--src/web/main.vala2
-rw-r--r--src/web/web.vala27
3 files changed, 25 insertions, 6 deletions
diff --git a/src/web/Makefile b/src/web/Makefile
index 17140c3..e6094f6 100644
--- a/src/web/Makefile
+++ b/src/web/Makefile
@@ -1,7 +1,7 @@
all: web
@echo > /dev/null
-web: main.vala web.vala websession.vala csv.vala template.vala ../database/db-interface.vala ../pgp/pgp-interface.vala ../price.vapi ../config/config-interface.vala
+web: main.vala web.vala websession.vala csv.vala template.vala ../database/db-interface.vala ../pgp/pgp-interface.vala ../price.vapi ../config/config-interface.vala ../audio/audio-interface.vala
valac -X -w -o $@ --vapidir=../../vapi --enable-experimental --pkg gee-0.8 --pkg gio-2.0 --pkg libsoup-2.4 --pkg posix $^
clean:
diff --git a/src/web/main.vala b/src/web/main.vala
index c0fd77f..7070e66 100644
--- a/src/web/main.vala
+++ b/src/web/main.vala
@@ -17,6 +17,7 @@ Database db;
public CSVMemberFile csvimport;
public PGP pgp;
public Config cfg;
+public AudioPlayer audio;
string templatedir;
public static int main(string[] args) {
@@ -29,6 +30,7 @@ public static int main(string[] args) {
db = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Database", "/io/mainframe/shopsystem/database");
pgp = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.PGP", "/io/mainframe/shopsystem/pgp");
cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
+ audio = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.AudioPlayer", "/io/mainframe/shopsystem/audio");
templatedir = cfg.get_string("WEB", "filepath");
port = cfg.get_integer("WEB", "port");
diff --git a/src/web/web.vala b/src/web/web.vala
index fb03e4b..c63db73 100644
--- a/src/web/web.vala
+++ b/src/web/web.vala
@@ -359,19 +359,36 @@ public class WebServer {
t.replace("ISADMIN2", "disabled=\"disabled\"");
}
+ var userThemeList = audio.get_user_themes();
+ var message = "";
var postdata = Soup.Form.decode_multipart(msg, null, null, null, null);
if(postdata != null && postdata.contains("password1") && postdata.contains("password2")) {
if(postdata["password1"] != postdata["password2"]) {
- t.replace("MESSAGE", "<div class=\"alert alert-error\">Error! Passwords do not match!</div>");
+ message = "<div class=\"alert alert-error\">Error! Passwords do not match!</div>";
} else if(postdata["password1"] == "") {
- t.replace("MESSAGE", "<div class=\"alert alert-error\">Error! Empty Password not allowed!</div>");
+ message = "<div class=\"alert alert-error\">Error! Empty Password not allowed!</div>";
} else {
db.set_user_password(id, postdata["password1"]);
- t.replace("MESSAGE", "<div class=\"alert alert-success\">Password Changed!</div>");
+ message = "<div class=\"alert alert-success\">Password Changed!</div>";
}
- } else {
- t.replace("MESSAGE", "");
+ } else if(postdata != null && postdata.contains("soundTheme")) {
+ if (postdata["soundTheme"] in userThemeList) {
+ userinfo.soundTheme = postdata["soundTheme"];
+ db.set_userTheme(id, postdata["soundTheme"]);
+ } else {
+ userinfo.soundTheme = null;
+ db.set_userTheme(id, "");
+ }
+ message = "<div class=\"alert alert-success\">Sound theme changed.</div>";
+ }
+ t.replace("MESSAGE", message);
+
+ var soundThemes = "";
+ foreach(var theme in userThemeList) {
+ var selected = userinfo.soundTheme == theme ? "selected" : "";
+ soundThemes += @"<option $selected>$theme</option>";
}
+ t.replace("SOUND_THEMES", soundThemes);
msg.set_response("text/html", Soup.MemoryUse.COPY, t.data);
msg.set_status(200);