[rygel/wip/basic-management: 6/21] GasicManagement: Use ExecutionState for TestState UPnP variable
- From: Jussi Kukkonen <jussik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/basic-management: 6/21] GasicManagement: Use ExecutionState for TestState UPnP variable
- Date: Fri, 14 Jun 2013 08:50:45 +0000 (UTC)
commit f51598ee25add5c7d425d6fd93978c042e86f702
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date: Fri May 31 13:30:28 2013 +0300
GasicManagement: Use ExecutionState for TestState UPnP variable
src/librygel-core/rygel-basic-management.vala | 4 +-
src/librygel-core/rygel-bm-test-nslookup.vala | 2 +-
src/librygel-core/rygel-bm-test.vala | 45 +++++++++++++++++--------
3 files changed, 34 insertions(+), 17 deletions(-)
---
diff --git a/src/librygel-core/rygel-basic-management.vala b/src/librygel-core/rygel-basic-management.vala
index 984902a..825602b 100644
--- a/src/librygel-core/rygel-basic-management.vala
+++ b/src/librygel-core/rygel-basic-management.vala
@@ -148,7 +148,7 @@ public class Rygel.BasicManagement : Service {
return false;
} else if ((action.get_name() != "GetTestInfo") &&
- (bm_test.state != "Completed")) {
+ (bm_test.execution_state != BMTest.ExecutionState.COMPLETED)) {
// TestID is valid but the test Results are not available
action.return_error (708, _("Invalid Test State"));
@@ -486,7 +486,7 @@ public class Rygel.BasicManagement : Service {
bm_test.type,
"State",
typeof (string),
- bm_test.state);
+ bm_test.execution_state.to_string());
action.return ();
}
diff --git a/src/librygel-core/rygel-bm-test-nslookup.vala b/src/librygel-core/rygel-bm-test-nslookup.vala
index c465b5a..7cf89e8 100644
--- a/src/librygel-core/rygel-bm-test-nslookup.vala
+++ b/src/librygel-core/rygel-bm-test-nslookup.vala
@@ -202,7 +202,7 @@ internal class Rygel.BMTestNSLookup : BMTest {
protected override void finish_iteration () {
switch (execution_state) {
- case ExecutionState.RUNNING:
+ case ExecutionState.IN_PROGRESS:
var execution_time = (uint)Math.round(timer.elapsed (null) * 1000);
results[results.length - 1].execution_time = execution_time;
break;
diff --git a/src/librygel-core/rygel-bm-test.vala b/src/librygel-core/rygel-bm-test.vala
index 3b7f45b..1a95bee 100644
--- a/src/librygel-core/rygel-bm-test.vala
+++ b/src/librygel-core/rygel-bm-test.vala
@@ -30,18 +30,35 @@ internal errordomain Rygel.BMTestError {
}
internal abstract class Rygel.BMTest : Object {
- protected enum ExecutionState {
- IDLE,
- RUNNING,
- CANCELED,
+ public enum ExecutionState {
+ REQUESTED,
+ IN_PROGRESS,
+ COMPLETED,
SPAWN_FAILED,
+ CANCELED;
+
+ /* Return values fit for A_ARG_TYPE_TestState */
+ public string to_string () {
+ switch (this) {
+ case REQUESTED:
+ return "Requested";
+ case IN_PROGRESS:
+ return "InProgress";
+ case COMPLETED:
+ return "Completed";
+ case SPAWN_FAILED:
+ return "Completed";
+ case CANCELED:
+ return "Canceled";
+ default:
+ assert_not_reached ();
+ }
+ }
}
-
+ public ExecutionState execution_state;
public string type;
- public string state;
public string id;
- protected ExecutionState execution_state;
/* properties for implementations to access */
protected SpawnFlags flags = SpawnFlags.SEARCH_PATH |
@@ -68,10 +85,10 @@ internal abstract class Rygel.BMTest : Object {
}
protected virtual void finish_iteration () {
iteration++;
- if (execution_state != ExecutionState.RUNNING) {
+ if (execution_state != ExecutionState.IN_PROGRESS) {
async_callback ();
} else if (iteration >= repetitions) {
- execution_state = ExecutionState.IDLE;
+ execution_state = ExecutionState.COMPLETED;
async_callback ();
} else {
run_iteration ();
@@ -155,15 +172,15 @@ internal abstract class Rygel.BMTest : Object {
public BMTest(string type) {
this.type = type;
- this.state = "Requested";
+ this.execution_state = ExecutionState.REQUESTED;
this.id = null;
}
public async virtual void execute () throws BMTestError {
- if (execution_state == ExecutionState.RUNNING)
- throw new BMTestError.NOT_POSSIBLE ("Already executing");
+ if (execution_state != ExecutionState.REQUESTED)
+ throw new BMTestError.NOT_POSSIBLE ("Already executing or executed");
- execution_state = ExecutionState.RUNNING;
+ execution_state = ExecutionState.IN_PROGRESS;
iteration = 0;
async_callback = execute.callback;
@@ -174,7 +191,7 @@ internal abstract class Rygel.BMTest : Object {
}
public void cancel () throws BMTestError {
- if (execution_state != ExecutionState.RUNNING)
+ if (execution_state != ExecutionState.IN_PROGRESS)
throw new BMTestError.NOT_POSSIBLE ("Not executing");
Posix.killpg (child_pid, Posix.SIGTERM);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]