[PATCH 2/5] msi: Use the Error table for more messages.

Zebediah Figura z.figura12 at gmail.com
Sun Jul 23 15:50:54 CDT 2017


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msi/action.c   |  5 +++--
 dlls/msi/msipriv.h  |  1 +
 dlls/msi/package.c  | 17 ++++++++++-------
 dlls/msi/resource.h | 17 ++++++++++-------
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 55a16d9..59c4610 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -175,14 +175,14 @@ static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
                           INT rc)
 {
     MSIRECORD *row;
-    WCHAR template[1024];
+    WCHAR *template;
     static const WCHAR format[] = 
         {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
     WCHAR message[1024];
     WCHAR timet[0x100];
 
     GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
-    LoadStringW(msi_hInstance, start ? IDS_INFO_ACTIONSTART : IDS_INFO_ACTIONENDED, template, 1024);
+    template = msi_get_error_message(package->db, start ? MSIERR_INFO_ACTIONSTART : MSIERR_INFO_ACTIONENDED);
     sprintfW(message, template, timet);
 
     row = MSI_CreateRecord(2);
@@ -192,6 +192,7 @@ static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
     MSI_RecordSetInteger(row, 2, start ? package->LastActionResult : rc);
     MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
     msiobj_release(&row->hdr);
+    msi_free(template);
     if (!start) package->LastActionResult = rc;
 }
 
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 91c614e..1400603 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -1053,6 +1053,7 @@ extern WCHAR *msi_get_assembly_path(MSIPACKAGE *, const WCHAR *) DECLSPEC_HIDDEN
 extern WCHAR *msi_font_version_from_file(const WCHAR *) DECLSPEC_HIDDEN;
 extern WCHAR **msi_split_string(const WCHAR *, WCHAR) DECLSPEC_HIDDEN;
 extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *) DECLSPEC_HIDDEN;
+extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN;
 
 /* media */
 
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index c3b4f5f..82fd718 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -1482,7 +1482,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
         {'M','/','d','/','y','y','y','y',0};
     static const WCHAR time_format[] =
         {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
-    WCHAR timet[100], datet[100], info_template[1024], info_message[1024];
+    WCHAR timet[100], datet[100], info_message[1024];
+    WCHAR *info_template;
 
     TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
 
@@ -1637,9 +1638,10 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
     }
     GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, time_format, timet, 100);
     GetDateFormatW(LOCALE_USER_DEFAULT, 0, NULL, date_format, datet, 100);
-    LoadStringW(msi_hInstance, IDS_INFO_LOGGINGSTART, info_template, 1024);
+    info_template = msi_get_error_message(package->db, MSIERR_INFO_LOGGINGSTART);
     sprintfW(info_message, info_template, datet, timet);
     MSI_RecordSetStringW(info_row, 0, info_message);
+    msi_free(info_template);
     MSI_ProcessMessage(package, INSTALLMESSAGE_INFO|MB_ICONHAND, info_row);
 
     MSI_ProcessMessage(package, INSTALLMESSAGE_COMMONDATA, data_row);
@@ -1877,7 +1879,7 @@ static LPCWSTR get_internal_error_message(int error)
 }
 
 /* Returned string must be freed */
-static LPWSTR msi_get_error_message(MSIDATABASE *db, int error)
+LPWSTR msi_get_error_message(MSIDATABASE *db, int error)
 {
     static const WCHAR query[] =
         {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
@@ -2069,15 +2071,16 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIREC
         break;
     case INSTALLMESSAGE_ACTIONSTART:
     {
-        WCHAR template_s[1024];
+        WCHAR *template_s;
         static const WCHAR time_format[] =
             {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
         WCHAR timet[100], template[1024];
 
-        LoadStringW(msi_hInstance, IDS_ACTIONSTART, template_s, 1024);
+        template_s = msi_get_error_message(package->db, MSIERR_ACTIONSTART);
         GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, time_format, timet, 100);
         sprintfW(template, template_s, timet);
         MSI_RecordSetStringW(record, 0, template);
+        msi_free(template);
 
         msi_free(package->LastAction);
         msi_free(package->LastActionTemplate);
@@ -2102,9 +2105,9 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIREC
         break;
     case INSTALLMESSAGE_COMMONDATA:
     {
-        WCHAR template[1024];
-        LoadStringW(msi_hInstance, IDS_COMMONDATA, template, 1024);
+        WCHAR *template = msi_get_error_message(package->db, MSIERR_COMMONDATA);
         MSI_RecordSetStringW(record, 0, template);
+        msi_free(template);
     }
     break;
     }
diff --git a/dlls/msi/resource.h b/dlls/msi/resource.h
index 88d4e3e..045aa20 100644
--- a/dlls/msi/resource.h
+++ b/dlls/msi/resource.h
@@ -17,6 +17,11 @@
  */
 
 #define MSIERR_INSTALLERROR         5
+#define MSIERR_ACTIONSTART          8
+#define MSIERR_COMMONDATA           11
+#define MSIERR_INFO_LOGGINGSTART    12
+#define MSIERR_INFO_ACTIONSTART     14
+#define MSIERR_INFO_ACTIONENDED     15
 
 #define MSIERR_INSERTDISK           1302
 #define MSIERR_CABNOTFOUND          1311
@@ -29,17 +34,15 @@
 #define IDS_INFO                (IDS_ERROR_BASE + 4)
 #define IDS_INSTALLERROR        (IDS_ERROR_BASE + MSIERR_INSTALLERROR)
 #define IDS_OUTOFDISKSPACE      (IDS_ERROR_BASE + 7)
+#define IDS_ACTIONSTART         (IDS_ERROR_BASE + MSIERR_ACTIONSTART)
+#define IDS_COMMONDATA          (IDS_ERROR_BASE + MSIERR_COMMONDATA)
+#define IDS_INFO_LOGGINGSTART   (IDS_ERROR_BASE + MSIERR_INFO_LOGGINGSTART)
+#define IDS_INFO_ACTIONSTART    (IDS_ERROR_BASE + MSIERR_INFO_ACTIONSTART)
+#define IDS_INFO_ACTIONENDED    (IDS_ERROR_BASE + MSIERR_INFO_ACTIONENDED)
 
 #define IDS_ERR_INSERTDISK      (IDS_ERROR_BASE + MSIERR_INSERTDISK)
 #define IDS_ERR_CABNOTFOUND     (IDS_ERROR_BASE + MSIERR_CABNOTFOUND)
 
-#define IDS_ACTIONSTART 1008
-#define IDS_COMMONDATA 1011
-
-#define IDS_INFO_ACTIONSTART 1050
-#define IDS_INFO_ACTIONENDED 1051
-#define IDS_INFO_LOGGINGSTART 1052
-
 #define IDS_DESC_ALLOCATEREGISTRYSPACE 1100
 #define IDS_DESC_APPSEARCH 1101
 #define IDS_DESC_BINDIMAGE 1102
-- 
2.7.4




More information about the wine-patches mailing list