From 0de65c0d45a3b559216032959b2f8a0f85651caa Mon Sep 17 00:00:00 2001 From: lado Date: Fri, 11 Nov 2011 14:51:53 +0100 Subject: add support for Toggle operation + modify has now 2 params --- .../vdrmanager/tasks/ModifyTimerTask.java | 4 +-- .../vdrmanager/tasks/ToggleTimerTask.java | 2 +- .../vdrmanager/utils/svdrp/SetTimerClient.java | 42 +++++++++++++++------- 3 files changed, 33 insertions(+), 15 deletions(-) (limited to 'vdrmanager/src') diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ModifyTimerTask.java b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ModifyTimerTask.java index 57fba6e..14e7b1a 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ModifyTimerTask.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ModifyTimerTask.java @@ -8,8 +8,8 @@ import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation; public abstract class ModifyTimerTask extends AsyncProgressTask { - public ModifyTimerTask(final Activity activity, final Timer timer) { - super(activity, new SetTimerClient(timer, TimerOperation.MODIFY) { + public ModifyTimerTask(final Activity activity, final Timer newTimer, final Timer oldTimer) { + super(activity, new SetTimerClient(newTimer, oldTimer, TimerOperation.MODIFY) { @Override public int getProgressTextId() { return R.string.progress_timer_modify; diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ToggleTimerTask.java b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ToggleTimerTask.java index a3b5d6a..0f96926 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ToggleTimerTask.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/ToggleTimerTask.java @@ -9,7 +9,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation; public abstract class ToggleTimerTask extends AsyncProgressTask { public ToggleTimerTask(final Activity activity, final Timer timer) { - super(activity, new SetTimerClient(timer, TimerOperation.MODIFY) { + super(activity, new SetTimerClient(timer, TimerOperation.TOGGLE) { boolean enabled = timer.isEnabled(); @Override diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SetTimerClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SetTimerClient.java index c1e0f73..765e780 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SetTimerClient.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/SetTimerClient.java @@ -13,7 +13,9 @@ public class SetTimerClient extends SvdrpClient { public enum TimerOperation { CREATE("C"),// DELETE("D"),// - MODIFY("M");// + MODIFY("M"),// + TOGGLE("T"),// + ; private String command; private TimerOperation(String command){ this.command = command; @@ -25,22 +27,33 @@ public class SetTimerClient extends SvdrpClient { } /** channel names for timer */ - Timer timer; + Timer newTimer; + + Timer oldTimer; + /** timer should be deleted */ private TimerOperation timerOperation; /** - * Constructor - * @param host host - * @param port port - * @param ssl use ssl + * @param newTimer Das was modifiziert angelegt wird + */ + public SetTimerClient(final Timer newTimer, TimerOperation op) { + this(newTimer, null, op); + } + + /** + * @param newTimer + * @param oldTimer this is original Timer, if any (modify) + * @param op */ - public SetTimerClient(final Timer timer, TimerOperation op) { + public SetTimerClient(final Timer newTimer, final Timer oldTimer, TimerOperation op) { super(); - this.timer = timer; + this.newTimer = newTimer; + this.oldTimer = oldTimer; this.timerOperation = op; } + /** * Starts the request */ @@ -51,11 +64,16 @@ public class SetTimerClient extends SvdrpClient { command.append("timer "); command.append(timerOperation.getCommand()); - - command.append(timer.getNumber()); + //command.append(oldTimer.getNumber()); command.append(" "); - command.append(timer.toCommandLine(timerOperation)); - + command.append(newTimer.toCommandLine()); + if(timerOperation == TimerOperation.MODIFY){ + command.append("#|#|#").append(oldTimer.toCommandLine()); + } + //timer D 1:1:2011-11-11:1513:1710:50:99:Mirrors 2 + //timer C 1:1:2011-11-11:2223:2250:50:99:Zapping + //timer T 0:1:2011-11-11:2013:2230:50:99:So spielt das Leben + //timer M runCommand(command.toString()); } -- cgit v1.2.3