[PATCH 08/18] event-test: Use typecasted enum to convert graphics event phase

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

 



---
 examples/object-events/event-test.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 22bd706..e1ad990 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -386,6 +386,24 @@ myDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
 }


+static const char *
+graphicsPhaseToStr(int phase)
+{
+    switch ((virDomainEventGraphicsPhase) phase) {
+    case VIR_DOMAIN_EVENT_GRAPHICS_CONNECT:
+        return "connected ";
+
+    case VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE:
+        return "initialized ";
+
+    case VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT:
+        return "disconnected ";
+    }
+
+    return "unknown";
+}
+
+
 static int
 myDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
                               virDomainPtr dom,
@@ -400,17 +418,8 @@ myDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
     printf("%s EVENT: Domain %s(%d) graphics ", __func__, virDomainGetName(dom),
            virDomainGetID(dom));

-    switch (phase) {
-    case VIR_DOMAIN_EVENT_GRAPHICS_CONNECT:
-        printf("connected ");
-        break;
-    case VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE:
-        printf("initialized ");
-        break;
-    case VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT:
-        printf("disconnected ");
-        break;
-    }
+    printf("%s", graphicsPhaseToStr(phase));
+

     printf("local: family=%d node=%s service=%s ",
            local->family, local->node, local->service);
-- 
2.8.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]