[msi]
[reactos.git] / reactos / dll / win32 / msi / dialog.c
index e0e27d1..40aa7df 100644 (file)
@@ -73,7 +73,7 @@ struct msi_control_tag
 
 typedef struct msi_font_tag
 {
-    struct msi_font_tag *next;
+    struct list entry;
     HFONT hfont;
     COLORREF color;
     WCHAR name[1];
@@ -90,7 +90,7 @@ struct msi_dialog_tag
     SIZE size;
     HWND hwnd;
     LPWSTR default_font;
-    msi_font *font_list;
+    struct list fonts;
     struct list controls;
     HWND hWndFocus;
     LPWSTR control_default;
@@ -310,8 +310,7 @@ static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
     name = MSI_RecordGetString( rec, 1 );
     font = msi_alloc( sizeof *font + strlenW( name )*sizeof (WCHAR) );
     strcpyW( font->name, name );
-    font->next = dialog->font_list;
-    dialog->font_list = font;
+    list_add_head( &dialog->fonts, &font->entry );
 
     font->color = MSI_RecordGetInteger( rec, 4 );
 
@@ -346,9 +345,9 @@ static UINT msi_dialog_add_font( MSIRECORD *rec, LPVOID param )
 
 static msi_font *msi_dialog_find_font( msi_dialog *dialog, LPCWSTR name )
 {
-    msi_font *font;
+    msi_font *font = NULL;
 
-    for( font = dialog->font_list; font; font = font->next )
+    LIST_FOR_EACH_ENTRY( font, &dialog->fonts, msi_font, entry )
         if( !strcmpW( font->name, name ) )  /* FIXME: case sensitive? */
             break;
 
@@ -578,7 +577,7 @@ static void msi_dialog_update_controls( msi_dialog *dialog, LPCWSTR property )
 
     LIST_FOR_EACH_ENTRY( control, &dialog->controls, msi_control, entry )
     {
-        if ( !lstrcmpW( control->property, property ) && control->update )
+        if ( control->property && !strcmpW( control->property, property ) && control->update )
             control->update( dialog, control );
     }
 }
@@ -601,7 +600,7 @@ void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
     ctrl = msi_dialog_find_control( dialog, control );
     if (!ctrl)
         return;
-    if( !lstrcmpW(attribute, szText) )
+    if( !strcmpW( attribute, szText ) )
     {
         font_text = MSI_RecordGetString( rec , 1 );
         font = msi_dialog_get_style( font_text, &text );
@@ -610,7 +609,7 @@ void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
         msi_free( font );
         msi_dialog_check_messages( NULL );
     }
-    else if( !lstrcmpW(attribute, szProgress) )
+    else if( !strcmpW( attribute, szProgress ) )
     {
         DWORD func, val;
 
@@ -640,12 +639,12 @@ void msi_dialog_handle_event( msi_dialog* dialog, LPCWSTR control,
             break;
         }
     }
-    else if ( !lstrcmpW(attribute, szProperty) )
+    else if ( !strcmpW( attribute, szProperty ) )
     {
         MSIFEATURE *feature = msi_seltree_get_selected_feature( ctrl );
         msi_dialog_set_property( dialog->package, ctrl->property, feature->Directory );
     }
-    else if ( !lstrcmpW(attribute, szSelectionPath) )
+    else if ( !strcmpW( attribute, szSelectionPath ) )
     {
         LPWSTR prop = msi_dialog_dup_property( dialog, ctrl->property, TRUE );
         LPWSTR path;
@@ -1368,7 +1367,7 @@ static void msi_dialog_combobox_update( msi_dialog *dialog,
     for (j = 0; j < info->num_items; j++)
     {
         tmp = (LPWSTR) SendMessageW( control->hwnd, CB_GETITEMDATA, j, 0 );
-        if (!lstrcmpW( value, tmp ))
+        if (!strcmpW( value, tmp ))
             break;
     }
 
@@ -1743,7 +1742,7 @@ static UINT msi_dialog_maskedit_control( msi_dialog *dialog, MSIRECORD *rec )
     font = msi_dialog_get_style( font_mask, &mask );
     if( !mask )
     {
-        ERR("mask template is empty\n");
+        WARN("mask template is empty\n");
         goto end;
     }
 
@@ -1988,7 +1987,7 @@ static UINT msi_dialog_create_radiobutton( MSIRECORD *rec, LPVOID param )
         return ERROR_FUNCTION_FAILED;
     control->handler = msi_dialog_radiogroup_handler;
 
-    if (!lstrcmpW(control->name, group->propval))
+    if (group->propval && !strcmpW( control->name, group->propval ))
         SendMessageW(control->hwnd, BM_SETCHECK, BST_CHECKED, 0);
 
     prop = MSI_RecordGetString( rec, 1 );
@@ -2126,9 +2125,9 @@ static void
 msi_seltree_update_feature_installstate( HWND hwnd, HTREEITEM hItem,
         MSIPACKAGE *package, MSIFEATURE *feature, INSTALLSTATE state )
 {
-    msi_feature_set_state( package, feature, state );
+    feature->ActionRequest = state;
     msi_seltree_sync_item_state( hwnd, feature, hItem );
-    ACTION_UpdateComponentStates( package, feature->Feature );
+    ACTION_UpdateComponentStates( package, feature );
 }
 
 static void
@@ -2258,7 +2257,11 @@ msi_seltree_add_child_features( MSIPACKAGE *package, HWND hwnd,
 
     LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
     {
-        if ( lstrcmpW( parent, feature->Feature_Parent ) )
+        if ( parent && feature->Feature_Parent && strcmpW( parent, feature->Feature_Parent ))
+            continue;
+        else if ( parent && !feature->Feature_Parent )
+            continue;
+        else if ( !parent && feature->Feature_Parent )
             continue;
 
         if ( !feature->Title )
@@ -2373,14 +2376,19 @@ static UINT msi_dialog_seltree_handler( msi_dialog *dialog,
     ControlEvent_FireSubscribedEvent( dialog->package, szSelectionDescription, rec );
 
     dir = MSI_RecordGetString( row, 7 );
-    folder = get_loaded_folder( dialog->package, dir );
-    if (!folder)
+    if (dir)
     {
-        r = ERROR_FUNCTION_FAILED;
-        goto done;
+        folder = get_loaded_folder( dialog->package, dir );
+        if (!folder)
+        {
+            r = ERROR_FUNCTION_FAILED;
+            goto done;
+        }
+        MSI_RecordSetStringW( rec, 1, folder->ResolvedTarget );
     }
+    else
+        MSI_RecordSetStringW( rec, 1, NULL );
 
-    MSI_RecordSetStringW( rec, 1, folder->ResolvedTarget );
     ControlEvent_FireSubscribedEvent( dialog->package, szSelectionPath, rec );
 
 done:
@@ -2682,7 +2690,7 @@ static void msi_dialog_update_directory_list( msi_dialog *dialog, msi_control *c
         if ( wfd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY )
             continue;
 
-        if ( !lstrcmpW( wfd.cFileName, szDot ) || !lstrcmpW( wfd.cFileName, szDotDot ) )
+        if ( !strcmpW( wfd.cFileName, szDot ) || !strcmpW( wfd.cFileName, szDotDot ) )
             continue;
 
         item.mask = LVIF_TEXT;
@@ -2846,7 +2854,7 @@ static void msi_dialog_vcl_add_columns( msi_dialog *dialog, msi_control *control
         begin += end - begin + 1;
 
         /* empty braces or '0' hides the column */ 
-        if ( !num[0] || !lstrcmpW( num, szZero ) )
+        if ( !num[0] || !strcmpW( num, szZero ) )
         {
             count++;
             msi_free( num );
@@ -3151,15 +3159,15 @@ static UINT msi_dialog_set_control_condition( MSIRECORD *rec, LPVOID param )
         TRACE("%s control %s\n", debugstr_w(action), debugstr_w(name));
 
         /* FIXME: case sensitive? */
-        if(!lstrcmpW(action, szHide))
+        if (!strcmpW( action, szHide ))
             ShowWindow(control->hwnd, SW_HIDE);
-        else if(!strcmpW(action, szShow))
+        else if (!strcmpW( action, szShow ))
             ShowWindow(control->hwnd, SW_SHOW);
-        else if(!strcmpW(action, szDisable))
+        else if (!strcmpW( action, szDisable ))
             EnableWindow(control->hwnd, FALSE);
-        else if(!strcmpW(action, szEnable))
+        else if (!strcmpW( action, szEnable ))
             EnableWindow(control->hwnd, TRUE);
-        else if(!strcmpW(action, szDefault))
+        else if (!strcmpW( action, szDefault ))
             SetFocus(control->hwnd);
         else
             FIXME("Unhandled action %s\n", debugstr_w(action));
@@ -3844,6 +3852,7 @@ msi_dialog *msi_dialog_create( MSIPACKAGE* package,
     dialog->event_handler = event_handler;
     dialog->finished = 0;
     list_init( &dialog->controls );
+    list_init( &dialog->fonts );
 
     /* verify that the dialog exists */
     rec = msi_get_dialog_record( dialog );
@@ -3960,6 +3969,8 @@ void msi_dialog_do_preview( msi_dialog *dialog )
 
 void msi_dialog_destroy( msi_dialog *dialog )
 {
+    msi_font *font, *next;
+
     if( uiThreadId != GetCurrentThreadId() )
     {
         SendMessageW( hMsiHiddenWindow, WM_MSI_DIALOG_DESTROY, 0, (LPARAM) dialog );
@@ -3986,12 +3997,11 @@ void msi_dialog_destroy( msi_dialog *dialog )
     }
 
     /* destroy the list of fonts */
-    while( dialog->font_list )
+    LIST_FOR_EACH_ENTRY_SAFE( font, next, &dialog->fonts, msi_font, entry )
     {
-        msi_font *t = dialog->font_list;
-        dialog->font_list = t->next;
-        DeleteObject( t->hfont );
-        msi_free( t );
+        list_remove( &font->entry );
+        DeleteObject( font->hfont );
+        msi_free( font );
     }
     msi_free( dialog->default_font );
 
@@ -4022,11 +4032,11 @@ static UINT error_dialog_handler(MSIPACKAGE *package, LPCWSTR event,
         'M','S','I','E','r','r','o','r','D','i','a','l','o','g','R','e','s','u','l','t',0
     };
 
-    if ( lstrcmpW( event, end_dialog ) )
+    if ( strcmpW( event, end_dialog ) )
         return ERROR_SUCCESS;
 
-    if ( !lstrcmpW( argument, error_abort ) || !lstrcmpW( argument, error_cancel ) ||
-         !lstrcmpW( argument, error_no ) )
+    if ( !strcmpW( argument, error_abort ) || !strcmpW( argument, error_cancel ) ||
+         !strcmpW( argument, error_no ) )
     {
          msi_set_property( package->db, result_prop, error_abort );
     }
@@ -4108,7 +4118,7 @@ UINT msi_spawn_error_dialog( MSIPACKAGE *package, LPWSTR error_dialog, LPWSTR er
     if ( r != ERROR_SUCCESS)
         r = ERROR_SUCCESS;
 
-    if ( !lstrcmpW( result, error_abort ) )
+    if ( !strcmpW( result, error_abort ) )
         r = ERROR_FUNCTION_FAILED;
 
 done: