[rygel/wip/basic-management: 7/21] BasicManagement: Fix test type comparisons



commit 5396fea12e7752b376a1ba2911ced517c6000584
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date:   Fri May 31 13:50:15 2013 +0300

    BasicManagement: Fix test type comparisons
    
    Now BMTest implementations implement two properties:
    method_type ("NSLookup")
    results_type ("GetNSLookupResult")

 src/librygel-core/rygel-basic-management.vala   |    4 ++--
 src/librygel-core/rygel-bm-test-nslookup.vala   |    7 ++-----
 src/librygel-core/rygel-bm-test-ping.vala       |    5 ++---
 src/librygel-core/rygel-bm-test-traceroute.vala |    5 ++---
 src/librygel-core/rygel-bm-test.vala            |    7 ++++---
 5 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/src/librygel-core/rygel-basic-management.vala b/src/librygel-core/rygel-basic-management.vala
index 825602b..51c7ede 100644
--- a/src/librygel-core/rygel-basic-management.vala
+++ b/src/librygel-core/rygel-basic-management.vala
@@ -142,7 +142,7 @@ public class Rygel.BasicManagement : Service {
             return false;
         } else if ((action.get_name() != "CancelTest") &&
                    (action.get_name() != "GetTestInfo") &&
-                   (bm_test.type != action.get_name())) {
+                   (bm_test.results_type != action.get_name())) {
             // TestID is valid but refers to the wrong test type
             action.return_error (707, _("Wrong Test Type"));
 
@@ -483,7 +483,7 @@ public class Rygel.BasicManagement : Service {
 
         action.set ("Type",
                         typeof (string),
-                        bm_test.type,
+                        bm_test.method_type,
                     "State",
                         typeof (string),
                         bm_test.execution_state.to_string());
diff --git a/src/librygel-core/rygel-bm-test-nslookup.vala b/src/librygel-core/rygel-bm-test-nslookup.vala
index 7cf89e8..4005a26 100644
--- a/src/librygel-core/rygel-bm-test-nslookup.vala
+++ b/src/librygel-core/rygel-bm-test-nslookup.vala
@@ -156,10 +156,8 @@ internal class Rygel.BMTestNSLookup : BMTest {
     private string additional_info;
     private Timer timer = new Timer ();
 
-    public BMTestNSLookup() {
-        base("NSLookup");
-    }
-
+    public override string method_type { get { return "NSLookup"; } }
+    public override string results_type { get { return "GetNSLookupResult"; } }
 
     public void init(string host_name, string? name_server, uint repetitions,
                      uint32 interval_time_out) throws BMTestError {
@@ -276,7 +274,6 @@ internal class Rygel.BMTestNSLookup : BMTest {
         status = generic_status.to_string();
         additional_info = "";
     }
-
 /*
     //valac --pkg gio-2.0 --pkg posix -X -lm  rygel-bm-test-nslookup.vala rygel-bm-test.vala
 
diff --git a/src/librygel-core/rygel-bm-test-ping.vala b/src/librygel-core/rygel-bm-test-ping.vala
index fa250bb..4d43003 100644
--- a/src/librygel-core/rygel-bm-test-ping.vala
+++ b/src/librygel-core/rygel-bm-test-ping.vala
@@ -58,9 +58,8 @@ internal class Rygel.BMTestPing : BMTest {
     private static const uint PING_MAX_STATUS_STR_SIZE = 32;
     private static const uint PING_MAX_RESULT_ARRAY_SIZE = 7;
 
-    public BMTestPing() {
-        base("Ping");
-    }
+    public override string method_type { get { return "Ping"; } }
+    public override string results_type { get { return "GetPingResult"; } }
 
     public bool init(string host, uint repeat_count, uint data_block_size,
                      uint dscp, uint32 interval_time_out) {
diff --git a/src/librygel-core/rygel-bm-test-traceroute.vala b/src/librygel-core/rygel-bm-test-traceroute.vala
index e966cb3..2a3c0a3 100644
--- a/src/librygel-core/rygel-bm-test-traceroute.vala
+++ b/src/librygel-core/rygel-bm-test-traceroute.vala
@@ -54,9 +54,8 @@ internal class Rygel.BMTestTraceroute : BMTest {
     private static const uint TRACEROUTE_MAX_HOSTS = 2048;
     private static const uint TRACEROUTE_MAX_RESULT_SIZE = 4;
 
-    public BMTestTraceroute() {
-        base("Traceroute");
-    }
+    public override string method_type { get { return "Traceroute"; } }
+    public override string results_type { get { return "GetTracerouteResult"; } }
 
     public bool init(string host, uint32 wait_time_out, uint data_block_size,
                      uint max_hop_count, uint dscp) {
diff --git a/src/librygel-core/rygel-bm-test.vala b/src/librygel-core/rygel-bm-test.vala
index 1a95bee..f90c9a8 100644
--- a/src/librygel-core/rygel-bm-test.vala
+++ b/src/librygel-core/rygel-bm-test.vala
@@ -56,9 +56,11 @@ internal abstract class Rygel.BMTest : Object {
         }
     }
     public ExecutionState execution_state;
-    public string type;
     public string id;
 
+    /* properties implementations need to provide */
+    public abstract string method_type { get; }
+    public abstract string results_type { get; }
 
     /* properties for implementations to access */
     protected SpawnFlags flags = SpawnFlags.SEARCH_PATH |
@@ -170,8 +172,7 @@ internal abstract class Rygel.BMTest : Object {
     }
 
 
-    public BMTest(string type) {
-        this.type = type;
+    public BMTest() {
         this.execution_state = ExecutionState.REQUESTED;
         this.id = null;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]