diff options
author | Sebastian Reichel <sre@ring0.de> | 2017-04-18 22:15:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 22:15:34 +0200 |
commit | b1bd88ef5355ea1b8edbf777215bb44fce36f32a (patch) | |
tree | 665b0df5b26f55cf845723a4b1629937ed1fa422 /src/web | |
parent | 529d6dd34f9209efef18c04121075be9ac310c9c (diff) | |
parent | cee8d7e8684ec03240e95f8443e4f5cbc04bec5a (diff) | |
download | serial-barcode-scanner-b1bd88ef5355ea1b8edbf777215bb44fce36f32a.tar.bz2 |
Merge pull request #24 from smilix/customizable_user_sounds
Customizable user sounds
Diffstat (limited to 'src/web')
-rw-r--r-- | src/web/Makefile | 2 | ||||
-rw-r--r-- | src/web/main.vala | 2 | ||||
-rw-r--r-- | src/web/web.vala | 27 |
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); |