Robert Shearman : msi: Move the firing of control events to MSI_ProcessMessage.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 23 10:35:22 CST 2006


Module: wine
Branch: refs/heads/master
Commit: d679bc5ab31b7d7181bf386e8200dc99667d2e3f
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=d679bc5ab31b7d7181bf386e8200dc99667d2e3f

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon Jan 23 17:30:31 2006 +0100

msi: Move the firing of control events to MSI_ProcessMessage.
Move the firing of control events from internal helper functions to
MSI_ProcessMessage so that custom actions can all cause control events
to be fired.
Added the firing of progress events.

---

 dlls/msi/action.c  |   37 ----------------
 dlls/msi/helpers.c |    4 --
 dlls/msi/package.c |  119 ++++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 92 insertions(+), 68 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 01c57d4..636f01c 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -247,55 +247,20 @@ static struct _actions StandardActions[]
  * helper functions
  ********************************************************/
 
-static void ce_actiontext(MSIPACKAGE* package, LPCWSTR action)
-{
-    static const WCHAR szActionText[] = 
-        {'A','c','t','i','o','n','T','e','x','t',0};
-    MSIRECORD *row;
-
-    row = MSI_CreateRecord(1);
-    MSI_RecordSetStringW(row,1,action);
-    ControlEvent_FireSubscribedEvent(package,szActionText, row);
-    msiobj_release(&row->hdr);
-}
-
 static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
 {
-    static const WCHAR template_s[]=
-        {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
-         '.',0};
-    static const WCHAR format[] = 
-        {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
     static const WCHAR Query_t[] = 
         {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
          '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
          'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=', 
          ' ','\'','%','s','\'',0};
-    WCHAR message[1024];
-    WCHAR timet[0x100];
-    MSIRECORD * row = 0;
-    LPCWSTR ActionText;
-    LPWSTR deformated;
-
-    GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
+    MSIRECORD * row;
 
     row = MSI_QueryGetRecord( package->db, Query_t, action );
     if (!row)
         return;
-
-    ActionText = MSI_RecordGetString(row,2);
-    deformat_string(package, ActionText, &deformated);
-
-    sprintfW(message,template_s,timet,action,deformated);
-    ce_actiontext(package, deformated);
-    msiobj_release(&row->hdr);
-
-    row = MSI_CreateRecord(1);
-    MSI_RecordSetStringW(row,1,message);
- 
     MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row);
     msiobj_release(&row->hdr);
-    msi_free(deformated);
 }
 
 static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start, 
diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c
index ffdf3be..fbe451c 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -760,8 +760,6 @@ void ui_actiondata(MSIPACKAGE *package, 
     WCHAR message[1024];
     MSIRECORD * row = 0;
     DWORD size;
-    static const WCHAR szActionData[] = 
-        {'A','c','t','i','o','n','D','a','t','a',0};
 
     if (!package->LastAction || strcmpW(package->LastAction,action))
     {
@@ -794,8 +792,6 @@ void ui_actiondata(MSIPACKAGE *package, 
  
     MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
 
-    ControlEvent_FireSubscribedEvent(package,szActionData, row);
-
     msiobj_release(&row->hdr);
 }
 
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index cb022bd..eb486ac 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -576,11 +576,16 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MS
 INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
                                MSIRECORD *record)
 {
+    static const WCHAR szActionData[] =
+        {'A','c','t','i','o','n','D','a','t','a',0};
+    static const WCHAR szSetProgress[] =
+        {'S','e','t','P','r','o','g','r','e','s','s',0};
+    static const WCHAR szActionText[] =
+        {'A','c','t','i','o','n','T','e','x','t',0};
     DWORD log_type = 0;
     LPWSTR message;
     DWORD sz;
     DWORD total_size = 0;
-    INT msg_field=1;
     INT i;
     INT rc;
     char *msg;
@@ -607,34 +612,62 @@ INT MSI_ProcessMessage( MSIPACKAGE *pack
     if ((eMessageType & 0xff000000) == INSTALLMESSAGE_PROGRESS)
         log_type |= 0x800;
 
-    message = msi_alloc(1*sizeof (WCHAR));
-    message[0]=0;
-    msg_field = MSI_RecordGetFieldCount(record);
-    for (i = 1; i <= msg_field; i++)
-    {
-        LPWSTR tmp;
-        WCHAR number[3];
-        static const WCHAR format[] = { '%','i',':',' ',0};
-        static const WCHAR space[] = { ' ',0};
-        sz = 0;
-        MSI_RecordGetStringW(record,i,NULL,&sz);
-        sz+=4;
-        total_size+=sz*sizeof(WCHAR);
-        tmp = msi_alloc(sz*sizeof(WCHAR));
-        message = msi_realloc(message,total_size*sizeof (WCHAR));
-
-        MSI_RecordGetStringW(record,i,tmp,&sz);
-
-        if (msg_field > 1)
+    if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
+    {
+        static const WCHAR template_s[]=
+            {'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ', '%','s',
+            '.',0};
+        static const WCHAR format[] = 
+            {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
+        WCHAR timet[0x100];
+        LPCWSTR action_text;
+        LPCWSTR action;
+        LPWSTR deformated;
+
+        GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
+
+        action = MSI_RecordGetString(record, 1);
+        action_text = MSI_RecordGetString(record, 2);
+        deformat_string(package, action_text, &deformated);
+
+        len = strlenW(timet) + strlenW(action) + strlenW(deformated) + 
+              strlenW(template_s) - 6 /* 6 characters of format specifier */;
+        message = msi_alloc((len + 1)*sizeof(WCHAR));
+        sprintfW(message,template_s,timet,action,deformated);
+        msi_free(deformated);
+    }
+    else
+    {
+        INT msg_field=1;
+        message = msi_alloc(1*sizeof (WCHAR));
+        message[0]=0;
+        msg_field = MSI_RecordGetFieldCount(record);
+        for (i = 1; i <= msg_field; i++)
         {
-            sprintfW(number,format,i);
-            strcatW(message,number);
-        }
-        strcatW(message,tmp);
-        if (msg_field > 1)
-            strcatW(message,space);
+            LPWSTR tmp;
+            WCHAR number[3];
+            static const WCHAR format[] = { '%','i',':',' ',0};
+            static const WCHAR space[] = { ' ',0};
+            sz = 0;
+            MSI_RecordGetStringW(record,i,NULL,&sz);
+            sz+=4;
+            total_size+=sz*sizeof(WCHAR);
+            tmp = msi_alloc(sz*sizeof(WCHAR));
+            message = msi_realloc(message,total_size*sizeof (WCHAR));
+
+            MSI_RecordGetStringW(record,i,tmp,&sz);
+
+            if (msg_field > 1)
+            {
+                sprintfW(number,format,i);
+                strcatW(message,number);
+            }
+            strcatW(message,tmp);
+            if (msg_field > 1)
+                strcatW(message,space);
 
-        msi_free(tmp);
+            msi_free(tmp);
+        }
     }
 
     TRACE("(%p %lx %lx %s)\n",gUIHandlerA, gUIFilter, log_type,
@@ -668,8 +701,38 @@ INT MSI_ProcessMessage( MSIPACKAGE *pack
         }
     }
     msi_free( msg );
-    
+
     msi_free( message);
+
+    switch (eMessageType & 0xff000000)
+    {
+    case INSTALLMESSAGE_ACTIONDATA:
+        /* FIXME: format record here instead of in ui_actiondata to get the
+         * correct action data for external scripts */
+        ControlEvent_FireSubscribedEvent(package, szActionData, record);
+        break;
+    case INSTALLMESSAGE_ACTIONSTART:
+    {
+        MSIRECORD *uirow;
+        LPWSTR deformated;
+        LPCWSTR action_text = MSI_RecordGetString(record, 2);
+
+        deformat_string(package, action_text, &deformated);
+        uirow = MSI_CreateRecord(1);
+        MSI_RecordSetStringW(uirow, 1, deformated);
+        TRACE("INSTALLMESSAGE_ACTIONSTART: %s\n", debugstr_w(deformated));
+        msi_free(deformated);
+
+        ControlEvent_FireSubscribedEvent(package, szActionText, uirow);
+
+        msiobj_release(&uirow->hdr);
+        break;
+    }
+    case INSTALLMESSAGE_PROGRESS:
+        ControlEvent_FireSubscribedEvent(package, szSetProgress, record);
+        break;
+    }
+
     return ERROR_SUCCESS;
 }
 




More information about the wine-cvs mailing list