2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * Here are helper functions formally in action.c that are used by a variaty of
23 * actions and functions.
31 #include "wine/debug.h"
34 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
39 static const WCHAR cszTargetDir
[] = {'T','A','R','G','E','T','D','I','R',0};
40 static const WCHAR cszDatabase
[]={'D','A','T','A','B','A','S','E',0};
42 const WCHAR cszSourceDir
[] = {'S','o','u','r','c','e','D','i','r',0};
43 const WCHAR cszSOURCEDIR
[] = {'S','O','U','R','C','E','D','I','R',0};
44 const WCHAR cszRootDrive
[] = {'R','O','O','T','D','R','I','V','E',0};
45 const WCHAR cszbs
[]={'\\',0};
47 LPWSTR
build_icon_path(MSIPACKAGE
*package
, LPCWSTR icon_name
)
49 LPWSTR SystemFolder
, dest
, FilePath
;
51 static const WCHAR szInstaller
[] =
52 {'M','i','c','r','o','s','o','f','t','\\',
53 'I','n','s','t','a','l','l','e','r','\\',0};
54 static const WCHAR szFolder
[] =
55 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
57 SystemFolder
= msi_dup_property( package
, szFolder
);
59 dest
= build_directory_name(3, SystemFolder
, szInstaller
, package
->ProductCode
);
61 create_full_pathW(dest
);
63 FilePath
= build_directory_name(2, dest
, icon_name
);
65 msi_free(SystemFolder
);
70 LPWSTR
msi_dup_record_field( MSIRECORD
*rec
, INT field
)
76 if (MSI_RecordIsNull( rec
, field
))
79 r
= MSI_RecordGetStringW( rec
, field
, NULL
, &sz
);
80 if (r
!= ERROR_SUCCESS
)
84 str
= msi_alloc( sz
* sizeof (WCHAR
) );
88 r
= MSI_RecordGetStringW( rec
, field
, str
, &sz
);
89 if (r
!= ERROR_SUCCESS
)
91 ERR("failed to get string!\n");
98 MSICOMPONENT
* get_loaded_component( MSIPACKAGE
* package
, LPCWSTR Component
)
102 LIST_FOR_EACH_ENTRY( comp
, &package
->components
, MSICOMPONENT
, entry
)
104 if (lstrcmpW(Component
,comp
->Component
)==0)
110 MSIFEATURE
* get_loaded_feature(MSIPACKAGE
* package
, LPCWSTR Feature
)
114 LIST_FOR_EACH_ENTRY( feature
, &package
->features
, MSIFEATURE
, entry
)
116 if (lstrcmpW( Feature
, feature
->Feature
)==0)
122 MSIFILE
* get_loaded_file( MSIPACKAGE
* package
, LPCWSTR key
)
126 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
128 if (lstrcmpW( key
, file
->File
)==0)
134 int track_tempfile( MSIPACKAGE
*package
, LPCWSTR path
)
138 TRACE("%s\n", debugstr_w(path
));
140 LIST_FOR_EACH_ENTRY( temp
, &package
->tempfiles
, MSITEMPFILE
, entry
)
141 if (!lstrcmpW( path
, temp
->Path
))
144 temp
= msi_alloc_zero( sizeof (MSITEMPFILE
) );
148 list_add_head( &package
->tempfiles
, &temp
->entry
);
149 temp
->Path
= strdupW( path
);
154 MSIFOLDER
*get_loaded_folder( MSIPACKAGE
*package
, LPCWSTR dir
)
158 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
160 if (lstrcmpW( dir
, folder
->Directory
)==0)
166 static LPWSTR
get_source_root( MSIPACKAGE
*package
)
170 path
= msi_dup_property( package
, cszSourceDir
);
174 path
= msi_dup_property( package
, cszDatabase
);
177 p
= strrchrW(path
,'\\');
185 * clean_spaces_from_path()
187 * removes spaces from the beginning and end of path segments
188 * removes multiple \\ characters
190 static void clean_spaces_from_path( LPWSTR p
)
197 /* copy until the end of the string or a space */
198 while (*p
!= ' ' && (*q
= *p
))
201 /* reduce many backslashes to one */
202 if (*p
!= '\\' || *q
!= '\\')
206 /* quit at the end of the string */
210 /* count the number of spaces */
215 /* if it's leading or trailing space, skip it */
216 if ( len
== 0 || p
[-1] == '\\' || p
[n
] == '\\' )
218 else /* copy n spaces */
219 while (n
&& (*q
++ = *p
++)) n
--;
223 LPWSTR
resolve_folder(MSIPACKAGE
*package
, LPCWSTR name
, BOOL source
,
224 BOOL set_prop
, BOOL load_prop
, MSIFOLDER
**folder
)
227 LPWSTR p
, path
= NULL
, parent
;
229 TRACE("Working to resolve %s\n",debugstr_w(name
));
234 if (!lstrcmpW(name
,cszSourceDir
))
237 f
= get_loaded_folder( package
, name
);
241 /* special resolving for Target and Source root dir */
242 if (!strcmpW(name
,cszTargetDir
))
244 if (!f
->ResolvedTarget
&& !f
->Property
)
247 check_path
= msi_dup_property( package
, cszTargetDir
);
250 check_path
= msi_dup_property( package
, cszRootDrive
);
252 MSI_SetPropertyW(package
,cszTargetDir
,check_path
);
255 /* correct misbuilt target dir */
256 path
= build_directory_name(2, check_path
, NULL
);
257 clean_spaces_from_path( path
);
258 if (strcmpiW(path
,check_path
)!=0)
259 MSI_SetPropertyW(package
,cszTargetDir
,path
);
260 msi_free(check_path
);
262 f
->ResolvedTarget
= path
;
265 if (!f
->ResolvedSource
)
266 f
->ResolvedSource
= get_source_root( package
);
272 if (!source
&& f
->ResolvedTarget
)
274 path
= strdupW( f
->ResolvedTarget
);
275 TRACE(" already resolved to %s\n",debugstr_w(path
));
279 if (source
&& f
->ResolvedSource
)
281 path
= strdupW( f
->ResolvedSource
);
282 TRACE(" (source)already resolved to %s\n",debugstr_w(path
));
286 if (!source
&& f
->Property
)
288 path
= build_directory_name( 2, f
->Property
, NULL
);
290 TRACE(" internally set to %s\n",debugstr_w(path
));
292 MSI_SetPropertyW( package
, name
, path
);
296 if (!source
&& load_prop
&& (path
= msi_dup_property( package
, name
)))
298 f
->ResolvedTarget
= strdupW( path
);
299 TRACE(" property set to %s\n", debugstr_w(path
));
308 TRACE(" ! Parent is %s\n", debugstr_w(parent
));
310 p
= resolve_folder(package
, parent
, source
, set_prop
, load_prop
, NULL
);
313 TRACE(" TargetDefault = %s\n", debugstr_w(f
->TargetDefault
));
315 path
= build_directory_name( 3, p
, f
->TargetDefault
, NULL
);
316 clean_spaces_from_path( path
);
317 f
->ResolvedTarget
= strdupW( path
);
318 TRACE("target -> %s\n", debugstr_w(path
));
320 MSI_SetPropertyW(package
,name
,path
);
324 /* source may be in a few different places ... check each of them */
327 /* try the long path directory */
328 if (f
->SourceLongPath
)
330 path
= build_directory_name( 3, p
, f
->SourceLongPath
, NULL
);
331 if (INVALID_FILE_ATTRIBUTES
== GetFileAttributesW( path
))
338 /* try the short path directory */
339 if (!path
&& f
->SourceShortPath
)
341 path
= build_directory_name( 3, p
, f
->SourceShortPath
, NULL
);
342 if (INVALID_FILE_ATTRIBUTES
== GetFileAttributesW( path
))
349 /* try the root of the install */
351 path
= get_source_root( package
);
353 TRACE("source -> %s\n", debugstr_w(path
));
354 f
->ResolvedSource
= strdupW( path
);
361 /* wrapper to resist a need for a full rewrite right now */
362 DWORD
deformat_string(MSIPACKAGE
*package
, LPCWSTR ptr
, WCHAR
** data
)
366 MSIRECORD
*rec
= MSI_CreateRecord(1);
369 MSI_RecordSetStringW(rec
,0,ptr
);
370 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
373 *data
= msi_alloc(size
*sizeof(WCHAR
));
375 MSI_FormatRecordW(package
,rec
,*data
,&size
);
379 msiobj_release( &rec
->hdr
);
380 return sizeof(WCHAR
)*size
;
387 UINT
schedule_action(MSIPACKAGE
*package
, UINT script
, LPCWSTR action
)
390 LPWSTR
*newbuf
= NULL
;
391 if (script
>= TOTAL_SCRIPTS
)
393 FIXME("Unknown script requested %i\n",script
);
394 return ERROR_FUNCTION_FAILED
;
396 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action
), script
);
398 count
= package
->script
->ActionCount
[script
];
399 package
->script
->ActionCount
[script
]++;
401 newbuf
= msi_realloc( package
->script
->Actions
[script
],
402 package
->script
->ActionCount
[script
]* sizeof(LPWSTR
));
404 newbuf
= msi_alloc( sizeof(LPWSTR
));
406 newbuf
[count
] = strdupW(action
);
407 package
->script
->Actions
[script
] = newbuf
;
409 return ERROR_SUCCESS
;
412 void msi_free_action_script(MSIPACKAGE
*package
, UINT script
)
415 for (i
= 0; i
< package
->script
->ActionCount
[script
]; i
++)
416 msi_free(package
->script
->Actions
[script
][i
]);
418 msi_free(package
->script
->Actions
[script
]);
419 package
->script
->Actions
[script
] = NULL
;
420 package
->script
->ActionCount
[script
] = 0;
423 static void remove_tracked_tempfiles(MSIPACKAGE
* package
)
425 struct list
*item
, *cursor
;
427 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->tempfiles
)
429 MSITEMPFILE
*temp
= LIST_ENTRY( item
, MSITEMPFILE
, entry
);
431 list_remove( &temp
->entry
);
432 TRACE("deleting temp file %s\n", debugstr_w( temp
->Path
));
433 if (!DeleteFileW( temp
->Path
))
434 ERR("failed to delete %s\n", debugstr_w( temp
->Path
));
435 msi_free( temp
->Path
);
440 static void free_feature( MSIFEATURE
*feature
)
442 struct list
*item
, *cursor
;
444 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Children
)
446 FeatureList
*fl
= LIST_ENTRY( item
, FeatureList
, entry
);
447 list_remove( &fl
->entry
);
451 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
453 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
454 list_remove( &cl
->entry
);
457 msi_free( feature
->Feature
);
458 msi_free( feature
->Feature_Parent
);
459 msi_free( feature
->Directory
);
460 msi_free( feature
->Description
);
461 msi_free( feature
->Title
);
465 static void free_extension( MSIEXTENSION
*ext
)
467 struct list
*item
, *cursor
;
469 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
471 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
473 list_remove( &verb
->entry
);
474 msi_free( verb
->Verb
);
475 msi_free( verb
->Command
);
476 msi_free( verb
->Argument
);
480 msi_free( ext
->Extension
);
481 msi_free( ext
->ProgIDText
);
485 /* Called when the package is being closed */
486 void ACTION_free_package_structures( MSIPACKAGE
* package
)
489 struct list
*item
, *cursor
;
491 TRACE("Freeing package action data\n");
493 remove_tracked_tempfiles(package
);
495 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
497 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
498 list_remove( &feature
->entry
);
499 free_feature( feature
);
502 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
504 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
506 list_remove( &folder
->entry
);
507 msi_free( folder
->Parent
);
508 msi_free( folder
->Directory
);
509 msi_free( folder
->TargetDefault
);
510 msi_free( folder
->SourceLongPath
);
511 msi_free( folder
->SourceShortPath
);
512 msi_free( folder
->ResolvedTarget
);
513 msi_free( folder
->ResolvedSource
);
514 msi_free( folder
->Property
);
518 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
520 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
522 list_remove( &comp
->entry
);
523 msi_free( comp
->Component
);
524 msi_free( comp
->ComponentId
);
525 msi_free( comp
->Directory
);
526 msi_free( comp
->Condition
);
527 msi_free( comp
->KeyPath
);
528 msi_free( comp
->FullKeypath
);
532 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
534 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
536 list_remove( &file
->entry
);
537 msi_free( file
->File
);
538 msi_free( file
->FileName
);
539 msi_free( file
->ShortName
);
540 msi_free( file
->LongName
);
541 msi_free( file
->Version
);
542 msi_free( file
->Language
);
543 msi_free( file
->SourcePath
);
544 msi_free( file
->TargetPath
);
548 /* clean up extension, progid, class and verb structures */
549 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
551 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
553 list_remove( &cls
->entry
);
554 msi_free( cls
->clsid
);
555 msi_free( cls
->Context
);
556 msi_free( cls
->Description
);
557 msi_free( cls
->FileTypeMask
);
558 msi_free( cls
->IconPath
);
559 msi_free( cls
->DefInprocHandler
);
560 msi_free( cls
->DefInprocHandler32
);
561 msi_free( cls
->Argument
);
562 msi_free( cls
->ProgIDText
);
566 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
568 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
570 list_remove( &ext
->entry
);
571 free_extension( ext
);
574 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
576 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
578 list_remove( &progid
->entry
);
579 msi_free( progid
->ProgID
);
580 msi_free( progid
->Description
);
581 msi_free( progid
->IconPath
);
585 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
587 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
589 list_remove( &mt
->entry
);
590 msi_free( mt
->clsid
);
591 msi_free( mt
->ContentType
);
595 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
597 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
599 list_remove( &appid
->entry
);
600 msi_free( appid
->AppID
);
601 msi_free( appid
->RemoteServerName
);
602 msi_free( appid
->LocalServer
);
603 msi_free( appid
->ServiceParameters
);
604 msi_free( appid
->DllSurrogate
);
608 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_info
)
610 MSISOURCELISTINFO
*info
= LIST_ENTRY( item
, MSISOURCELISTINFO
, entry
);
612 list_remove( &info
->entry
);
613 msi_free( info
->value
);
617 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->sourcelist_media
)
619 MSIMEDIADISK
*info
= LIST_ENTRY( item
, MSIMEDIADISK
, entry
);
621 list_remove( &info
->entry
);
622 msi_free( info
->volume_label
);
623 msi_free( info
->disk_prompt
);
629 for (i
= 0; i
< TOTAL_SCRIPTS
; i
++)
630 msi_free_action_script(package
, i
);
632 for (i
= 0; i
< package
->script
->UniqueActionsCount
; i
++)
633 msi_free(package
->script
->UniqueActions
[i
]);
635 msi_free(package
->script
->UniqueActions
);
636 msi_free(package
->script
);
639 msi_free(package
->BaseURL
);
640 msi_free(package
->PackagePath
);
641 msi_free(package
->ProductCode
);
642 msi_free(package
->ActionFormat
);
643 msi_free(package
->LastAction
);
645 /* cleanup control event subscriptions */
646 ControlEvent_CleanupSubscriptions(package
);
650 * build_directory_name()
652 * This function is to save messing round with directory names
653 * It handles adding backslashes between path segments,
654 * and can add \ at the end of the directory name if told to.
656 * It takes a variable number of arguments.
657 * It always allocates a new string for the result, so make sure
658 * to free the return value when finished with it.
660 * The first arg is the number of path segments that follow.
661 * The arguments following count are a list of path segments.
662 * A path segment may be NULL.
664 * Path segments will be added with a \ separating them.
665 * A \ will not be added after the last segment, however if the
666 * last segment is NULL, then the last character will be a \
669 LPWSTR
build_directory_name(DWORD count
, ...)
676 for(i
=0; i
<count
; i
++)
678 LPCWSTR str
= va_arg(va
,LPCWSTR
);
680 sz
+= strlenW(str
) + 1;
684 dir
= msi_alloc(sz
*sizeof(WCHAR
));
688 for(i
=0; i
<count
; i
++)
690 LPCWSTR str
= va_arg(va
,LPCWSTR
);
694 if( ((i
+1)!=count
) && dir
[strlenW(dir
)-1]!='\\')
700 /***********************************************************************
703 * Recursively create all directories in the path.
705 * shamelessly stolen from setupapi/queue.c
707 BOOL
create_full_pathW(const WCHAR
*path
)
713 new_path
= msi_alloc( (strlenW(path
) + 1) * sizeof(WCHAR
));
715 strcpyW(new_path
, path
);
717 while((len
= strlenW(new_path
)) && new_path
[len
- 1] == '\\')
718 new_path
[len
- 1] = 0;
720 while(!CreateDirectoryW(new_path
, NULL
))
723 DWORD last_error
= GetLastError();
724 if(last_error
== ERROR_ALREADY_EXISTS
)
727 if(last_error
!= ERROR_PATH_NOT_FOUND
)
733 if(!(slash
= strrchrW(new_path
, '\\')))
739 len
= slash
- new_path
;
741 if(!create_full_pathW(new_path
))
746 new_path
[len
] = '\\';
753 void ui_progress(MSIPACKAGE
*package
, int a
, int b
, int c
, int d
)
757 row
= MSI_CreateRecord(4);
758 MSI_RecordSetInteger(row
,1,a
);
759 MSI_RecordSetInteger(row
,2,b
);
760 MSI_RecordSetInteger(row
,3,c
);
761 MSI_RecordSetInteger(row
,4,d
);
762 MSI_ProcessMessage(package
, INSTALLMESSAGE_PROGRESS
, row
);
763 msiobj_release(&row
->hdr
);
765 msi_dialog_check_messages(NULL
);
768 void ui_actiondata(MSIPACKAGE
*package
, LPCWSTR action
, MSIRECORD
* record
)
770 static const WCHAR Query_t
[] =
771 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
772 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
773 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
774 ' ','\'','%','s','\'',0};
779 if (!package
->LastAction
|| strcmpW(package
->LastAction
,action
))
781 row
= MSI_QueryGetRecord(package
->db
, Query_t
, action
);
785 if (MSI_RecordIsNull(row
,3))
787 msiobj_release(&row
->hdr
);
791 /* update the cached actionformat */
792 msi_free(package
->ActionFormat
);
793 package
->ActionFormat
= msi_dup_record_field(row
,3);
795 msi_free(package
->LastAction
);
796 package
->LastAction
= strdupW(action
);
798 msiobj_release(&row
->hdr
);
801 MSI_RecordSetStringW(record
,0,package
->ActionFormat
);
803 MSI_FormatRecordW(package
,record
,message
,&size
);
805 row
= MSI_CreateRecord(1);
806 MSI_RecordSetStringW(row
,1,message
);
808 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, row
);
810 msiobj_release(&row
->hdr
);
813 BOOL
ACTION_VerifyComponentForAction( const MSICOMPONENT
* comp
, INSTALLSTATE check
)
818 if (comp
->Installed
== check
)
821 if (comp
->ActionRequest
== check
)
827 BOOL
ACTION_VerifyFeatureForAction( const MSIFEATURE
* feature
, INSTALLSTATE check
)
832 if (feature
->ActionRequest
== check
)
838 void reduce_to_longfilename(WCHAR
* filename
)
840 LPWSTR p
= strchrW(filename
,'|');
842 memmove(filename
, p
+1, (strlenW(p
+1)+1)*sizeof(WCHAR
));
845 void reduce_to_shortfilename(WCHAR
* filename
)
847 LPWSTR p
= strchrW(filename
,'|');
852 LPWSTR
create_component_advertise_string(MSIPACKAGE
* package
,
853 MSICOMPONENT
* component
, LPCWSTR feature
)
855 static const WCHAR fmt
[] = {'%','s','%','s','%','c','%','s',0};
856 WCHAR productid_85
[21], component_85
[21];
857 LPWSTR output
= NULL
;
861 /* > is used if there is a component GUID and < if not. */
866 CLSIDFromString(package
->ProductCode
, &clsid
);
867 encode_base85_guid(&clsid
, productid_85
);
871 CLSIDFromString(component
->ComponentId
, &clsid
);
872 encode_base85_guid(&clsid
, component_85
);
875 TRACE("prod=%s feat=%s comp=%s\n", debugstr_w(productid_85
),
876 debugstr_w(feature
), debugstr_w(component_85
));
878 sz
= 20 + lstrlenW(feature
) + 20 + 3;
880 output
= msi_alloc_zero(sz
*sizeof(WCHAR
));
882 sprintfW(output
, fmt
, productid_85
, feature
,
883 component
?'>':'<', component_85
);
888 /* update compoennt state based on a feature change */
889 void ACTION_UpdateComponentStates(MSIPACKAGE
*package
, LPCWSTR szFeature
)
891 INSTALLSTATE newstate
;
895 feature
= get_loaded_feature(package
,szFeature
);
899 newstate
= feature
->ActionRequest
;
901 if (newstate
== INSTALLSTATE_ABSENT
)
902 newstate
= INSTALLSTATE_UNKNOWN
;
904 LIST_FOR_EACH_ENTRY( cl
, &feature
->Components
, ComponentList
, entry
)
906 MSICOMPONENT
* component
= cl
->component
;
908 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
909 newstate
, debugstr_w(component
->Component
), component
->Installed
,
910 component
->Action
, component
->ActionRequest
);
912 if (!component
->Enabled
)
915 if (newstate
== INSTALLSTATE_LOCAL
)
916 msi_component_set_state( component
, INSTALLSTATE_LOCAL
);
919 ComponentList
*clist
;
922 msi_component_set_state( component
, newstate
);
924 /*if any other feature wants is local we need to set it local*/
925 LIST_FOR_EACH_ENTRY( f
, &package
->features
, MSIFEATURE
, entry
)
927 if ( f
->ActionRequest
!= INSTALLSTATE_LOCAL
&&
928 f
->ActionRequest
!= INSTALLSTATE_SOURCE
)
933 LIST_FOR_EACH_ENTRY( clist
, &f
->Components
, ComponentList
, entry
)
935 if ( clist
->component
== component
&&
936 (f
->ActionRequest
== INSTALLSTATE_LOCAL
||
937 f
->ActionRequest
== INSTALLSTATE_SOURCE
) )
939 TRACE("Saved by %s\n", debugstr_w(f
->Feature
));
941 if (component
->Attributes
& msidbComponentAttributesOptional
)
943 if (f
->Attributes
& msidbFeatureAttributesFavorSource
)
944 msi_component_set_state( component
, INSTALLSTATE_SOURCE
);
946 msi_component_set_state( component
, INSTALLSTATE_LOCAL
);
948 else if (component
->Attributes
& msidbComponentAttributesSourceOnly
)
949 msi_component_set_state( component
, INSTALLSTATE_SOURCE
);
951 msi_component_set_state( component
, INSTALLSTATE_LOCAL
);
956 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
957 newstate
, debugstr_w(component
->Component
), component
->Installed
,
958 component
->Action
, component
->ActionRequest
);
962 UINT
register_unique_action(MSIPACKAGE
*package
, LPCWSTR action
)
965 LPWSTR
*newbuf
= NULL
;
967 if (!package
->script
)
970 TRACE("Registering Action %s as having fun\n",debugstr_w(action
));
972 count
= package
->script
->UniqueActionsCount
;
973 package
->script
->UniqueActionsCount
++;
975 newbuf
= msi_realloc( package
->script
->UniqueActions
,
976 package
->script
->UniqueActionsCount
* sizeof(LPWSTR
));
978 newbuf
= msi_alloc( sizeof(LPWSTR
));
980 newbuf
[count
] = strdupW(action
);
981 package
->script
->UniqueActions
= newbuf
;
983 return ERROR_SUCCESS
;
986 BOOL
check_unique_action(const MSIPACKAGE
*package
, LPCWSTR action
)
990 if (!package
->script
)
993 for (i
= 0; i
< package
->script
->UniqueActionsCount
; i
++)
994 if (!strcmpW(package
->script
->UniqueActions
[i
],action
))
1000 WCHAR
* generate_error_string(MSIPACKAGE
*package
, UINT error
, DWORD count
, ... )
1002 static const WCHAR query
[] = {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ','F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ','%','i',0};
1012 row
= MSI_QueryGetRecord(package
->db
, query
, error
);
1016 rec
= MSI_CreateRecord(count
+2);
1018 str
= MSI_RecordGetString(row
,1);
1019 MSI_RecordSetStringW(rec
,0,str
);
1020 msiobj_release( &row
->hdr
);
1021 MSI_RecordSetInteger(rec
,1,error
);
1024 for (i
= 0; i
< count
; i
++)
1026 str
= va_arg(va
,LPCWSTR
);
1027 MSI_RecordSetStringW(rec
,(i
+2),str
);
1031 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
1034 data
= msi_alloc(size
*sizeof(WCHAR
));
1036 MSI_FormatRecordW(package
,rec
,data
,&size
);
1039 msiobj_release( &rec
->hdr
);
1043 void msi_ui_error( DWORD msg_id
, DWORD type
)
1047 static const WCHAR title
[] = {
1048 'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
1051 if (!MsiLoadStringW( -1, msg_id
, text
, sizeof(text
) / sizeof(text
[0]),
1052 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
) ))
1055 MessageBoxW( NULL
, text
, title
, type
);