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

[win-pv-devel] [PATCH] XENBUS_MONITOR refinements



Use a string table for the dialog message rather than coding it inline.
Also, trim the DisplayName pulled from the registry because Windows 10
seems to prefix it with useless tags.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/monitor/messages.mc       | 30 ++++++++++++++++++++++++++++++
 src/monitor/monitor.c         | 37 +++++++++++++++++++++++++++----------
 src/monitor/strings.h         | 37 +++++++++++++++++++++++++++++++++++++
 src/monitor/strings.rc        | 37 +++++++++++++++++++++++++++++++++++++
 src/monitor/xenbus_monitor.rc |  2 +-
 5 files changed, 132 insertions(+), 11 deletions(-)
 create mode 100644 src/monitor/strings.h
 create mode 100644 src/monitor/strings.rc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
index ab49243..9fff135 100644
--- a/src/monitor/messages.mc
+++ b/src/monitor/messages.mc
@@ -1,3 +1,33 @@
+; // Copyright (c) Citrix Systems Inc.
+; // All rights reserved.
+; //
+; // Redistribution and use in source and binary forms,
+; // with or without modification, are permitted provided
+; // that the following conditions are met:
+; //
+; // *   Redistributions of source code must retain the above
+; //     copyright notice, this list of conditions and the
+; //     following disclaimer.
+; // *   Redistributions in binary form must reproduce the above
+; //     copyright notice, this list of conditions and the
+; //     following disclaimer in the documentation and/or other
+; //     materials provided with the distribution.
+; //
+; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+; // SUCH DAMAGE.
+
 MessageIdTypedef=DWORD
 
 SeverityNames=(
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 9e4555f..9a4f4f9 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -40,6 +40,7 @@
 #include <version.h>
 
 #include "messages.h"
+#include "strings.h"
 
 #define MONITOR_NAME        __MODULE__
 #define MONITOR_DISPLAYNAME MONITOR_NAME
@@ -316,9 +317,11 @@ PromptForReboot(
     DWORD               MaxValueLength;
     DWORD               DisplayNameLength;
     PTCHAR              DisplayName;
+    PTCHAR              Description;
     DWORD               Type;
     TCHAR               Title[] = TEXT(VENDOR_NAME_STR);
     TCHAR               Message[MAXIMUM_BUFFER_SIZE];
+    DWORD               Length;
     PWTS_SESSION_INFO   SessionInfo;
     DWORD               Count;
     DWORD               Index;
@@ -382,16 +385,27 @@ PromptForReboot(
         goto fail5;
     }
 
+    Description = _tcsrchr(DisplayName, ';');
+    if (Description == NULL)
+        Description = DisplayName;
+    else
+        Description++;
+
     Result = StringCbPrintf(Message,
                             MAXIMUM_BUFFER_SIZE,
-                            TEXT("%s needs to restart the system to "
-                                 "complete installation.\n"
-                                 "Press 'Yes' to restart the system "
-                                 "now or 'No' if you plan to restart "
-                                 "the system later.\n"),
-                            DisplayName);
+                            TEXT("%s "),
+                            Description);
     assert(SUCCEEDED(Result));
 
+    Length = (DWORD)_tcslen(Message);
+
+    Length = LoadString(GetModuleHandle(NULL),
+                        IDS_DIALOG,
+                        Message + Length,
+                        ARRAYSIZE(Message) - Length);
+    if (Length == 0)
+        goto fail6;
+
     Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
                                    0,
                                    1,
@@ -399,7 +413,7 @@ PromptForReboot(
                                    &Count);
 
     if (!Success)
-        goto fail6;
+        goto fail7;
 
     for (Index = 0; Index < Count; Index++) {
         DWORD                   SessionId = SessionInfo[Index].SessionId;
@@ -427,7 +441,7 @@ PromptForReboot(
                                  TRUE);
 
         if (!Success)
-            goto fail7;
+            goto fail8;
 
         Context->RebootPending = TRUE;
 
@@ -447,11 +461,14 @@ PromptForReboot(
 
     return;
 
-fail7:
-    Log("fail7");
+fail8:
+    Log("fail8");
 
     WTSFreeMemory(SessionInfo);
 
+fail7:
+    Log("fail7");
+
 fail6:
     Log("fail6");
 
diff --git a/src/monitor/strings.h b/src/monitor/strings.h
new file mode 100644
index 0000000..76ef975
--- /dev/null
+++ b/src/monitor/strings.h
@@ -0,0 +1,37 @@
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer.
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
+ *     materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MONITOR_STRINGS_H_
+#define _MONITOR_STRINGS_H_
+
+#define        IDS_DIALOG      1
+
+#endif // _MONITOR_STRINGS_H_
diff --git a/src/monitor/strings.rc b/src/monitor/strings.rc
new file mode 100644
index 0000000..99d4fc1
--- /dev/null
+++ b/src/monitor/strings.rc
@@ -0,0 +1,37 @@
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer.
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
+ *     materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "strings.h"
+
+STRINGTABLE
+{
+       IDS_DIALOG, "needs to restart the system to complete 
installation.\nPress 'Yes' to restart the system now or 'No' if you plan to 
restart the system later."
+}
\ No newline at end of file
diff --git a/src/monitor/xenbus_monitor.rc b/src/monitor/xenbus_monitor.rc
index 1948657..96247e3 100644
--- a/src/monitor/xenbus_monitor.rc
+++ b/src/monitor/xenbus_monitor.rc
@@ -29,7 +29,6 @@
  * SUCH DAMAGE.
  */
 
-
 #include <windows.h>
 #include <ntverp.h>
 
@@ -55,3 +54,4 @@
 
 #include "common.ver"
 #include "messages.rc"
+#include "strings.rc"
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.