2005-06-15 21:12:42 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-15 21:12:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here are helper functions formally in action.c that are used by a variaty of
|
|
|
|
* actions and functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "action.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
static const WCHAR cszTargetDir[] = {'T','A','R','G','E','T','D','I','R',0};
|
|
|
|
static const WCHAR cszDatabase[]={'D','A','T','A','B','A','S','E',0};
|
|
|
|
|
|
|
|
const WCHAR cszSourceDir[] = {'S','o','u','r','c','e','D','i','r',0};
|
|
|
|
const WCHAR cszRootDrive[] = {'R','O','O','T','D','R','I','V','E',0};
|
|
|
|
const WCHAR cszbs[]={'\\',0};
|
|
|
|
|
2005-09-22 12:33:57 +02:00
|
|
|
LPWSTR build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-22 12:33:57 +02:00
|
|
|
LPWSTR SystemFolder, dest, FilePath;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
static const WCHAR szInstaller[] =
|
|
|
|
{'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'I','n','s','t','a','l','l','e','r','\\',0};
|
|
|
|
static const WCHAR szFolder[] =
|
|
|
|
{'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
|
|
|
|
|
2005-09-15 17:04:08 +02:00
|
|
|
SystemFolder = msi_dup_property( package, szFolder );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-07-07 22:27:06 +02:00
|
|
|
dest = build_directory_name(3, SystemFolder, szInstaller, package->ProductCode);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
create_full_pathW(dest);
|
|
|
|
|
2005-09-22 12:33:57 +02:00
|
|
|
FilePath = build_directory_name(2, dest, icon_name);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(SystemFolder);
|
|
|
|
msi_free(dest);
|
2005-09-22 12:33:57 +02:00
|
|
|
return FilePath;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
LPWSTR msi_dup_record_field( MSIRECORD *row, INT index )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-10-27 14:36:12 +02:00
|
|
|
return strdupW( MSI_RecordGetString(row,index) );
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT* get_loaded_component( MSIPACKAGE* package, LPCWSTR Component )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 12:03:17 +02:00
|
|
|
MSICOMPONENT *comp;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
if (lstrcmpW(Component,comp->Component)==0)
|
|
|
|
return comp;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
2005-08-22 11:15:23 +02:00
|
|
|
return NULL;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE* get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
if (lstrcmpW( Feature, feature->Feature )==0)
|
|
|
|
return feature;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
2005-08-22 16:09:17 +02:00
|
|
|
return NULL;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE* get_loaded_file( MSIPACKAGE* package, LPCWSTR key )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 12:03:17 +02:00
|
|
|
if (lstrcmpW( key, file->File )==0)
|
|
|
|
return file;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
2005-08-23 12:03:17 +02:00
|
|
|
return NULL;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
int track_tempfile( MSIPACKAGE *package, LPCWSTR name, LPCWSTR path )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-07 13:25:18 +02:00
|
|
|
MSITEMPFILE *temp;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-07 13:25:18 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( temp, &package->tempfiles, MSITEMPFILE, entry )
|
|
|
|
{
|
|
|
|
if (lstrcmpW( name, temp->File )==0)
|
|
|
|
{
|
|
|
|
TRACE("tempfile %s already exists with path %s\n",
|
|
|
|
debugstr_w(temp->File), debugstr_w(temp->Path));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
temp = msi_alloc_zero( sizeof (MSITEMPFILE) );
|
2005-09-07 13:25:18 +02:00
|
|
|
if (!temp)
|
2005-08-23 12:03:17 +02:00
|
|
|
return -1;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-07 13:25:18 +02:00
|
|
|
list_add_head( &package->tempfiles, &temp->entry );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-07 13:25:18 +02:00
|
|
|
temp->File = strdupW( name );
|
|
|
|
temp->Path = strdupW( path );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-07 13:25:18 +02:00
|
|
|
TRACE("adding tempfile %s with path %s\n",
|
|
|
|
debugstr_w(temp->File), debugstr_w(temp->Path));
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-08-23 20:15:44 +02:00
|
|
|
MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir )
|
|
|
|
{
|
|
|
|
MSIFOLDER *folder;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
|
|
|
|
{
|
|
|
|
if (lstrcmpW( dir, folder->Directory )==0)
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-11-28 10:37:08 +01:00
|
|
|
static LPWSTR get_source_root( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
LPWSTR path, p;
|
|
|
|
|
|
|
|
path = msi_dup_property( package, cszSourceDir );
|
|
|
|
if (path)
|
|
|
|
return path;
|
|
|
|
|
|
|
|
path = msi_dup_property( package, cszDatabase );
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
p = strrchrW(path,'\\');
|
|
|
|
if (p)
|
|
|
|
*(p+1) = 0;
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2006-01-06 12:19:22 +01:00
|
|
|
/*
|
|
|
|
* clean_spaces_from_path()
|
|
|
|
*
|
|
|
|
* removes spaces from the beginning and end of path segments
|
|
|
|
* removes multiple \\ characters
|
|
|
|
*/
|
|
|
|
static void clean_spaces_from_path( LPWSTR p )
|
|
|
|
{
|
|
|
|
LPWSTR q = p;
|
|
|
|
int n, len = 0;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* copy until the end of the string or a space */
|
|
|
|
while (*p != ' ' && (*q = *p))
|
|
|
|
{
|
|
|
|
p++, len++;
|
|
|
|
/* reduce many backslashes to one */
|
|
|
|
if (*p != '\\' || *q != '\\')
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* quit at the end of the string */
|
|
|
|
if (!*p)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* count the number of spaces */
|
|
|
|
n = 0;
|
|
|
|
while (p[n] == ' ')
|
|
|
|
n++;
|
|
|
|
|
|
|
|
/* if it's leading or trailing space, skip it */
|
|
|
|
if ( len == 0 || p[-1] == '\\' || p[n] == '\\' )
|
|
|
|
p += n;
|
|
|
|
else /* copy n spaces */
|
|
|
|
while (n && (*q++ = *p++)) n--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-15 21:12:42 +02:00
|
|
|
LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
|
|
|
|
BOOL set_prop, MSIFOLDER **folder)
|
|
|
|
{
|
2005-08-23 20:15:44 +02:00
|
|
|
MSIFOLDER *f;
|
2005-06-15 21:12:42 +02:00
|
|
|
LPWSTR p, path = NULL;
|
|
|
|
|
|
|
|
TRACE("Working to resolve %s\n",debugstr_w(name));
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return NULL;
|
|
|
|
|
2005-11-28 10:37:08 +01:00
|
|
|
/* special resolving for Target and Source root dir */
|
|
|
|
if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-11-28 10:37:08 +01:00
|
|
|
if (!source)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-11-28 10:37:08 +01:00
|
|
|
LPWSTR check_path;
|
|
|
|
check_path = msi_dup_property( package, cszTargetDir );
|
|
|
|
if (!check_path)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-11-28 10:37:08 +01:00
|
|
|
check_path = msi_dup_property( package, cszRootDrive );
|
|
|
|
if (set_prop)
|
|
|
|
MSI_SetPropertyW(package,cszTargetDir,check_path);
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
2005-11-24 19:22:44 +01:00
|
|
|
|
2005-11-28 10:37:08 +01:00
|
|
|
/* correct misbuilt target dir */
|
|
|
|
path = build_directory_name(2, check_path, NULL);
|
2006-01-06 12:19:22 +01:00
|
|
|
clean_spaces_from_path( path );
|
2005-11-28 10:37:08 +01:00
|
|
|
if (strcmpiW(path,check_path)!=0)
|
|
|
|
MSI_SetPropertyW(package,cszTargetDir,path);
|
|
|
|
msi_free(check_path);
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
2005-11-28 10:37:08 +01:00
|
|
|
else
|
|
|
|
path = get_source_root( package );
|
2005-08-23 20:15:44 +02:00
|
|
|
if (folder)
|
|
|
|
*folder = get_loaded_folder( package, name );
|
|
|
|
return path;
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-23 20:15:44 +02:00
|
|
|
f = get_loaded_folder( package, name );
|
|
|
|
if (!f)
|
2005-06-15 21:12:42 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (folder)
|
2005-08-23 20:15:44 +02:00
|
|
|
*folder = f;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-11-28 10:37:08 +01:00
|
|
|
if (!source && f->ResolvedTarget)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 20:15:44 +02:00
|
|
|
path = strdupW( f->ResolvedTarget );
|
2005-06-15 21:12:42 +02:00
|
|
|
TRACE(" already resolved to %s\n",debugstr_w(path));
|
|
|
|
return path;
|
|
|
|
}
|
2005-11-28 10:37:08 +01:00
|
|
|
else if (source && f->ResolvedSource)
|
|
|
|
{
|
|
|
|
path = strdupW( f->ResolvedSource );
|
|
|
|
TRACE(" (source)already resolved to %s\n",debugstr_w(path));
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
else if (!source && f->Property)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 20:15:44 +02:00
|
|
|
path = build_directory_name( 2, f->Property, NULL );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
TRACE(" internally set to %s\n",debugstr_w(path));
|
|
|
|
if (set_prop)
|
2005-08-23 20:15:44 +02:00
|
|
|
MSI_SetPropertyW( package, name, path );
|
2005-06-15 21:12:42 +02:00
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2005-08-23 20:15:44 +02:00
|
|
|
if (f->Parent)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 20:15:44 +02:00
|
|
|
LPWSTR parent = f->Parent->Directory;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
TRACE(" ! Parent is %s\n", debugstr_w(parent));
|
|
|
|
|
|
|
|
p = resolve_folder(package, parent, source, set_prop, NULL);
|
2005-11-28 10:37:08 +01:00
|
|
|
if (!source)
|
|
|
|
{
|
|
|
|
TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-11-28 10:37:08 +01:00
|
|
|
path = build_directory_name( 3, p, f->TargetDefault, NULL );
|
2006-01-06 12:19:22 +01:00
|
|
|
clean_spaces_from_path( path );
|
2005-11-28 10:37:08 +01:00
|
|
|
f->ResolvedTarget = strdupW( path );
|
|
|
|
TRACE("target -> %s\n", debugstr_w(path));
|
|
|
|
if (set_prop)
|
|
|
|
MSI_SetPropertyW(package,name,path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-21 11:40:36 +01:00
|
|
|
/* source may be in a few different places ... check each of them */
|
|
|
|
path = NULL;
|
2005-11-28 10:37:08 +01:00
|
|
|
|
2006-03-21 11:40:36 +01:00
|
|
|
/* try the long path directory */
|
|
|
|
if (f->SourceLongPath)
|
2005-11-28 10:37:08 +01:00
|
|
|
{
|
2006-03-21 11:40:36 +01:00
|
|
|
path = build_directory_name( 3, p, f->SourceLongPath, NULL );
|
|
|
|
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
|
|
|
|
{
|
|
|
|
msi_free( path );
|
|
|
|
path = NULL;
|
|
|
|
}
|
2005-11-28 10:37:08 +01:00
|
|
|
}
|
2006-03-21 11:40:36 +01:00
|
|
|
|
|
|
|
/* try the short path directory */
|
|
|
|
if (!path && f->SourceShortPath)
|
|
|
|
{
|
|
|
|
path = build_directory_name( 3, p, f->SourceShortPath, NULL );
|
|
|
|
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
|
|
|
|
{
|
|
|
|
msi_free( path );
|
|
|
|
path = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try the root of the install */
|
|
|
|
if (!path)
|
|
|
|
path = get_source_root( package );
|
|
|
|
|
|
|
|
TRACE("source -> %s\n", debugstr_w(path));
|
|
|
|
f->ResolvedSource = strdupW( path );
|
2005-11-28 10:37:08 +01:00
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(p);
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wrapper to resist a need for a full rewrite right now */
|
|
|
|
DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data )
|
|
|
|
{
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
MSIRECORD *rec = MSI_CreateRecord(1);
|
|
|
|
DWORD size = 0;
|
|
|
|
|
|
|
|
MSI_RecordSetStringW(rec,0,ptr);
|
|
|
|
MSI_FormatRecordW(package,rec,NULL,&size);
|
|
|
|
if (size >= 0)
|
|
|
|
{
|
|
|
|
size++;
|
2005-09-20 13:59:14 +02:00
|
|
|
*data = msi_alloc(size*sizeof(WCHAR));
|
2005-06-15 21:12:42 +02:00
|
|
|
if (size > 1)
|
|
|
|
MSI_FormatRecordW(package,rec,*data,&size);
|
|
|
|
else
|
|
|
|
*data[0] = 0;
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return sizeof(WCHAR)*size;
|
|
|
|
}
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
}
|
|
|
|
|
|
|
|
*data = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
|
|
|
|
{
|
|
|
|
UINT count;
|
|
|
|
LPWSTR *newbuf = NULL;
|
|
|
|
if (script >= TOTAL_SCRIPTS)
|
|
|
|
{
|
|
|
|
FIXME("Unknown script requested %i\n",script);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
TRACE("Scheduling Action %s in script %i\n",debugstr_w(action), script);
|
|
|
|
|
|
|
|
count = package->script->ActionCount[script];
|
|
|
|
package->script->ActionCount[script]++;
|
|
|
|
if (count != 0)
|
2005-09-20 13:59:14 +02:00
|
|
|
newbuf = msi_realloc( package->script->Actions[script],
|
2005-06-15 21:12:42 +02:00
|
|
|
package->script->ActionCount[script]* sizeof(LPWSTR));
|
|
|
|
else
|
2005-09-20 13:59:14 +02:00
|
|
|
newbuf = msi_alloc( sizeof(LPWSTR));
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
newbuf[count] = strdupW(action);
|
|
|
|
package->script->Actions[script] = newbuf;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void remove_tracked_tempfiles(MSIPACKAGE* package)
|
|
|
|
{
|
2005-09-07 13:25:18 +02:00
|
|
|
struct list *item, *cursor;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-07 13:25:18 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->tempfiles )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-07 13:25:18 +02:00
|
|
|
MSITEMPFILE *temp = LIST_ENTRY( item, MSITEMPFILE, entry );
|
|
|
|
|
|
|
|
list_remove( &temp->entry );
|
|
|
|
TRACE("deleting temp file %s\n", debugstr_w( temp->Path ));
|
|
|
|
DeleteFileW( temp->Path );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( temp->File );
|
|
|
|
msi_free( temp->Path );
|
|
|
|
msi_free( temp );
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
static void free_feature( MSIFEATURE *feature )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
|
|
|
|
2006-09-21 04:59:19 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &feature->Children )
|
|
|
|
{
|
|
|
|
FeatureList *fl = LIST_ENTRY( item, FeatureList, entry );
|
|
|
|
list_remove( &fl->entry );
|
|
|
|
msi_free( fl );
|
|
|
|
}
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &feature->Components )
|
|
|
|
{
|
|
|
|
ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
|
|
|
|
list_remove( &cl->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( cl );
|
|
|
|
}
|
|
|
|
msi_free( feature->Feature );
|
|
|
|
msi_free( feature->Feature_Parent );
|
|
|
|
msi_free( feature->Directory );
|
|
|
|
msi_free( feature->Description );
|
|
|
|
msi_free( feature->Title );
|
|
|
|
msi_free( feature );
|
2005-08-22 16:09:17 +02:00
|
|
|
}
|
|
|
|
|
2005-09-02 16:39:13 +02:00
|
|
|
void free_extension( MSIEXTENSION *ext )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &ext->verbs )
|
|
|
|
{
|
|
|
|
MSIVERB *verb = LIST_ENTRY( item, MSIVERB, entry );
|
|
|
|
|
|
|
|
list_remove( &verb->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( verb->Verb );
|
|
|
|
msi_free( verb->Command );
|
|
|
|
msi_free( verb->Argument );
|
|
|
|
msi_free( verb );
|
2005-09-02 16:39:13 +02:00
|
|
|
}
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( ext->Extension );
|
|
|
|
msi_free( ext->ProgIDText );
|
|
|
|
msi_free( ext );
|
2005-09-02 16:39:13 +02:00
|
|
|
}
|
|
|
|
|
2005-06-15 21:12:42 +02:00
|
|
|
/* Called when the package is being closed */
|
|
|
|
void ACTION_free_package_structures( MSIPACKAGE* package)
|
|
|
|
{
|
|
|
|
INT i;
|
2005-08-19 12:03:11 +02:00
|
|
|
struct list *item, *cursor;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
TRACE("Freeing package action data\n");
|
|
|
|
|
|
|
|
remove_tracked_tempfiles(package);
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->features )
|
2005-08-19 12:03:11 +02:00
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature = LIST_ENTRY( item, MSIFEATURE, entry );
|
|
|
|
list_remove( &feature->entry );
|
|
|
|
free_feature( feature );
|
2005-08-19 12:03:11 +02:00
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-23 20:15:44 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->folders )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 20:15:44 +02:00
|
|
|
MSIFOLDER *folder = LIST_ENTRY( item, MSIFOLDER, entry );
|
|
|
|
|
|
|
|
list_remove( &folder->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( folder->Directory );
|
|
|
|
msi_free( folder->TargetDefault );
|
2006-03-21 11:40:36 +01:00
|
|
|
msi_free( folder->SourceLongPath );
|
|
|
|
msi_free( folder->SourceShortPath );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( folder->ResolvedTarget );
|
|
|
|
msi_free( folder->ResolvedSource );
|
|
|
|
msi_free( folder->Property );
|
2005-09-21 11:43:29 +02:00
|
|
|
msi_free( folder );
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->components )
|
|
|
|
{
|
|
|
|
MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
|
|
|
|
|
|
|
|
list_remove( &comp->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( comp->Component );
|
|
|
|
msi_free( comp->ComponentId );
|
|
|
|
msi_free( comp->Directory );
|
|
|
|
msi_free( comp->Condition );
|
|
|
|
msi_free( comp->KeyPath );
|
|
|
|
msi_free( comp->FullKeypath );
|
|
|
|
msi_free( comp );
|
2005-08-22 11:15:23 +02:00
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->files )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file = LIST_ENTRY( item, MSIFILE, entry );
|
|
|
|
|
|
|
|
list_remove( &file->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( file->File );
|
|
|
|
msi_free( file->FileName );
|
|
|
|
msi_free( file->ShortName );
|
2006-03-21 11:40:36 +01:00
|
|
|
msi_free( file->LongName );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( file->Version );
|
|
|
|
msi_free( file->Language );
|
|
|
|
msi_free( file->SourcePath );
|
|
|
|
msi_free( file->TargetPath );
|
|
|
|
msi_free( file );
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up extension, progid, class and verb structures */
|
2005-08-25 12:22:32 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->classes )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-25 12:22:32 +02:00
|
|
|
MSICLASS *cls = LIST_ENTRY( item, MSICLASS, entry );
|
|
|
|
|
|
|
|
list_remove( &cls->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( cls->clsid );
|
|
|
|
msi_free( cls->Context );
|
|
|
|
msi_free( cls->Description );
|
|
|
|
msi_free( cls->FileTypeMask );
|
|
|
|
msi_free( cls->IconPath );
|
|
|
|
msi_free( cls->DefInprocHandler );
|
|
|
|
msi_free( cls->DefInprocHandler32 );
|
|
|
|
msi_free( cls->Argument );
|
|
|
|
msi_free( cls->ProgIDText );
|
|
|
|
msi_free( cls );
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-08-29 11:38:39 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->extensions )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-29 11:38:39 +02:00
|
|
|
MSIEXTENSION *ext = LIST_ENTRY( item, MSIEXTENSION, entry );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-29 11:38:39 +02:00
|
|
|
list_remove( &ext->entry );
|
2005-09-02 16:39:13 +02:00
|
|
|
free_extension( ext );
|
2005-08-29 11:38:39 +02:00
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-06 11:26:18 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->progids )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-06 11:26:18 +02:00
|
|
|
MSIPROGID *progid = LIST_ENTRY( item, MSIPROGID, entry );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-06 11:26:18 +02:00
|
|
|
list_remove( &progid->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( progid->ProgID );
|
|
|
|
msi_free( progid->Description );
|
|
|
|
msi_free( progid->IconPath );
|
|
|
|
msi_free( progid );
|
2005-09-06 11:26:18 +02:00
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-26 10:47:31 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->mimes )
|
|
|
|
{
|
|
|
|
MSIMIME *mt = LIST_ENTRY( item, MSIMIME, entry );
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-26 10:47:31 +02:00
|
|
|
list_remove( &mt->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( mt->clsid );
|
|
|
|
msi_free( mt->ContentType );
|
|
|
|
msi_free( mt );
|
2005-08-26 10:47:31 +02:00
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-24 11:45:18 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->appids )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-24 11:45:18 +02:00
|
|
|
MSIAPPID *appid = LIST_ENTRY( item, MSIAPPID, entry );
|
|
|
|
|
|
|
|
list_remove( &appid->entry );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( appid->AppID );
|
|
|
|
msi_free( appid->RemoteServerName );
|
|
|
|
msi_free( appid->LocalServer );
|
|
|
|
msi_free( appid->ServiceParameters );
|
|
|
|
msi_free( appid->DllSurrogate );
|
|
|
|
msi_free( appid );
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (package->script)
|
|
|
|
{
|
|
|
|
for (i = 0; i < TOTAL_SCRIPTS; i++)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < package->script->ActionCount[i]; j++)
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->script->Actions[i][j]);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->script->Actions[i]);
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
2005-06-30 22:45:43 +02:00
|
|
|
|
|
|
|
for (i = 0; i < package->script->UniqueActionsCount; i++)
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->script->UniqueActions[i]);
|
2005-06-30 22:45:43 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->script->UniqueActions);
|
|
|
|
msi_free(package->script);
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->PackagePath);
|
|
|
|
msi_free(package->ProductCode);
|
2005-09-22 12:56:26 +02:00
|
|
|
msi_free(package->ActionFormat);
|
|
|
|
msi_free(package->LastAction);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
/* cleanup control event subscriptions */
|
|
|
|
ControlEvent_CleanupSubscriptions(package);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* build_directory_name()
|
|
|
|
*
|
|
|
|
* This function is to save messing round with directory names
|
|
|
|
* It handles adding backslashes between path segments,
|
|
|
|
* and can add \ at the end of the directory name if told to.
|
|
|
|
*
|
|
|
|
* It takes a variable number of arguments.
|
|
|
|
* It always allocates a new string for the result, so make sure
|
|
|
|
* to free the return value when finished with it.
|
|
|
|
*
|
|
|
|
* The first arg is the number of path segments that follow.
|
|
|
|
* The arguments following count are a list of path segments.
|
|
|
|
* A path segment may be NULL.
|
|
|
|
*
|
|
|
|
* Path segments will be added with a \ separating them.
|
|
|
|
* A \ will not be added after the last segment, however if the
|
|
|
|
* last segment is NULL, then the last character will be a \
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPWSTR build_directory_name(DWORD count, ...)
|
|
|
|
{
|
|
|
|
DWORD sz = 1, i;
|
|
|
|
LPWSTR dir;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start(va,count);
|
|
|
|
for(i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
LPCWSTR str = va_arg(va,LPCWSTR);
|
|
|
|
if (str)
|
|
|
|
sz += strlenW(str) + 1;
|
|
|
|
}
|
|
|
|
va_end(va);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
dir = msi_alloc(sz*sizeof(WCHAR));
|
2005-06-15 21:12:42 +02:00
|
|
|
dir[0]=0;
|
|
|
|
|
|
|
|
va_start(va,count);
|
|
|
|
for(i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
LPCWSTR str = va_arg(va,LPCWSTR);
|
|
|
|
if (!str)
|
|
|
|
continue;
|
|
|
|
strcatW(dir, str);
|
|
|
|
if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\')
|
|
|
|
strcatW(dir, cszbs);
|
|
|
|
}
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* create_full_pathW
|
|
|
|
*
|
|
|
|
* Recursively create all directories in the path.
|
|
|
|
*
|
|
|
|
* shamelessly stolen from setupapi/queue.c
|
|
|
|
*/
|
|
|
|
BOOL create_full_pathW(const WCHAR *path)
|
|
|
|
{
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
int len;
|
|
|
|
WCHAR *new_path;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
new_path = msi_alloc( (strlenW(path) + 1) * sizeof(WCHAR));
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
strcpyW(new_path, path);
|
|
|
|
|
|
|
|
while((len = strlenW(new_path)) && new_path[len - 1] == '\\')
|
|
|
|
new_path[len - 1] = 0;
|
|
|
|
|
|
|
|
while(!CreateDirectoryW(new_path, NULL))
|
|
|
|
{
|
|
|
|
WCHAR *slash;
|
|
|
|
DWORD last_error = GetLastError();
|
|
|
|
if(last_error == ERROR_ALREADY_EXISTS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if(last_error != ERROR_PATH_NOT_FOUND)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(slash = strrchrW(new_path, '\\')))
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = slash - new_path;
|
|
|
|
new_path[len] = 0;
|
|
|
|
if(!create_full_pathW(new_path))
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
new_path[len] = '\\';
|
|
|
|
}
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(new_path);
|
2005-06-15 21:12:42 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d )
|
|
|
|
{
|
|
|
|
MSIRECORD * row;
|
|
|
|
|
|
|
|
row = MSI_CreateRecord(4);
|
|
|
|
MSI_RecordSetInteger(row,1,a);
|
|
|
|
MSI_RecordSetInteger(row,2,b);
|
|
|
|
MSI_RecordSetInteger(row,3,c);
|
|
|
|
MSI_RecordSetInteger(row,4,d);
|
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row);
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
|
|
|
|
msi_dialog_check_messages(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
MSIRECORD * row = 0;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (!package->LastAction || strcmpW(package->LastAction,action))
|
|
|
|
{
|
|
|
|
row = MSI_QueryGetRecord(package->db, Query_t, action);
|
|
|
|
if (!row)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (MSI_RecordIsNull(row,3))
|
|
|
|
{
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update the cached actionformat */
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->ActionFormat);
|
2005-10-27 14:36:12 +02:00
|
|
|
package->ActionFormat = msi_dup_record_field(row,3);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(package->LastAction);
|
2005-06-15 21:12:42 +02:00
|
|
|
package->LastAction = strdupW(action);
|
|
|
|
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
MSI_RecordSetStringW(record,0,package->ActionFormat);
|
|
|
|
size = 1024;
|
|
|
|
MSI_FormatRecordW(package,record,message,&size);
|
|
|
|
|
|
|
|
row = MSI_CreateRecord(1);
|
|
|
|
MSI_RecordSetStringW(row,1,message);
|
|
|
|
|
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
|
|
|
|
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
}
|
|
|
|
|
2005-10-29 13:36:48 +02:00
|
|
|
BOOL ACTION_VerifyComponentForAction( MSICOMPONENT* comp, INSTALLSTATE check )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-12 13:08:20 +02:00
|
|
|
if (!comp)
|
|
|
|
return FALSE;
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
if (comp->Installed == check)
|
2005-06-15 21:12:42 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
if (comp->ActionRequest == check)
|
2005-06-15 21:12:42 +02:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
BOOL ACTION_VerifyFeatureForAction( MSIFEATURE* feature, INSTALLSTATE check )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-12 13:08:20 +02:00
|
|
|
if (!feature)
|
|
|
|
return FALSE;
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
if (feature->Installed == check)
|
2005-06-15 21:12:42 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
if (feature->ActionRequest == check)
|
2005-06-15 21:12:42 +02:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reduce_to_longfilename(WCHAR* filename)
|
|
|
|
{
|
|
|
|
LPWSTR p = strchrW(filename,'|');
|
|
|
|
if (p)
|
|
|
|
memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
|
|
|
|
void reduce_to_shortfilename(WCHAR* filename)
|
|
|
|
{
|
|
|
|
LPWSTR p = strchrW(filename,'|');
|
|
|
|
if (p)
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPWSTR create_component_advertise_string(MSIPACKAGE* package,
|
|
|
|
MSICOMPONENT* component, LPCWSTR feature)
|
|
|
|
{
|
2006-04-18 13:06:52 +02:00
|
|
|
static const WCHAR fmt[] = {'%','s','%','s','%','c','%','s',0};
|
|
|
|
WCHAR productid_85[21], component_85[21];
|
2005-06-15 21:12:42 +02:00
|
|
|
LPWSTR output = NULL;
|
|
|
|
DWORD sz = 0;
|
2006-04-18 13:06:52 +02:00
|
|
|
GUID clsid;
|
|
|
|
|
|
|
|
/* > is used if there is a component GUID and < if not. */
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2006-04-18 13:06:52 +02:00
|
|
|
productid_85[0] = 0;
|
|
|
|
component_85[0] = 0;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-07-07 22:27:06 +02:00
|
|
|
CLSIDFromString(package->ProductCode, &clsid);
|
2006-04-18 13:06:52 +02:00
|
|
|
encode_base85_guid(&clsid, productid_85);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2006-04-18 13:06:52 +02:00
|
|
|
if (component)
|
|
|
|
{
|
|
|
|
CLSIDFromString(component->ComponentId, &clsid);
|
|
|
|
encode_base85_guid(&clsid, component_85);
|
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2006-04-18 13:06:52 +02:00
|
|
|
TRACE("prod=%s feat=%s comp=%s\n", debugstr_w(productid_85),
|
|
|
|
debugstr_w(feature), debugstr_w(component_85));
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2006-04-18 13:06:52 +02:00
|
|
|
sz = 20 + lstrlenW(feature) + 20 + 3;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2006-04-18 13:06:52 +02:00
|
|
|
output = msi_alloc_zero(sz*sizeof(WCHAR));
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2006-04-18 13:06:52 +02:00
|
|
|
sprintfW(output, fmt, productid_85, feature,
|
|
|
|
component?'>':'<', component_85);
|
2005-06-15 21:12:42 +02:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update compoennt state based on a feature change */
|
|
|
|
void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
|
|
|
|
{
|
|
|
|
INSTALLSTATE newstate;
|
|
|
|
MSIFEATURE *feature;
|
2005-08-19 12:03:11 +02:00
|
|
|
ComponentList *cl;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
feature = get_loaded_feature(package,szFeature);
|
|
|
|
if (!feature)
|
2005-06-15 21:12:42 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
newstate = feature->ActionRequest;
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT* component = cl->component;
|
|
|
|
|
2005-06-15 21:12:42 +02:00
|
|
|
TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
|
|
|
|
newstate, debugstr_w(component->Component), component->Installed,
|
|
|
|
component->Action, component->ActionRequest);
|
|
|
|
|
|
|
|
if (!component->Enabled)
|
|
|
|
continue;
|
2005-09-06 12:23:34 +02:00
|
|
|
|
|
|
|
if (newstate == INSTALLSTATE_LOCAL)
|
2005-06-15 21:12:42 +02:00
|
|
|
{
|
2005-09-06 12:23:34 +02:00
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ComponentList *clist;
|
|
|
|
MSIFEATURE *f;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-06 12:23:34 +02:00
|
|
|
component->ActionRequest = newstate;
|
|
|
|
component->Action = newstate;
|
2005-06-15 21:12:42 +02:00
|
|
|
|
2005-09-06 12:23:34 +02:00
|
|
|
/*if any other feature wants is local we need to set it local*/
|
|
|
|
LIST_FOR_EACH_ENTRY( f, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
2006-09-16 02:10:01 +02:00
|
|
|
if ( f->ActionRequest != INSTALLSTATE_LOCAL &&
|
|
|
|
f->ActionRequest != INSTALLSTATE_SOURCE )
|
|
|
|
{
|
2005-09-06 12:23:34 +02:00
|
|
|
break;
|
2006-09-16 02:10:01 +02:00
|
|
|
}
|
2005-08-22 16:09:17 +02:00
|
|
|
|
2005-09-06 12:23:34 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( clist, &f->Components, ComponentList, entry )
|
|
|
|
{
|
2006-09-16 02:10:01 +02:00
|
|
|
if ( clist->component == component &&
|
|
|
|
(f->ActionRequest == INSTALLSTATE_LOCAL ||
|
|
|
|
f->ActionRequest == INSTALLSTATE_SOURCE) )
|
2005-08-19 12:03:11 +02:00
|
|
|
{
|
2006-09-16 02:10:01 +02:00
|
|
|
TRACE("Saved by %s\n", debugstr_w(f->Feature));
|
|
|
|
component->ActionRequest = f->ActionRequest;
|
|
|
|
component->Action = f->ActionRequest;
|
2005-08-19 12:03:11 +02:00
|
|
|
}
|
2005-06-15 21:12:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
|
|
|
|
newstate, debugstr_w(component->Component), component->Installed,
|
|
|
|
component->Action, component->ActionRequest);
|
|
|
|
}
|
|
|
|
}
|
2005-06-29 21:19:09 +02:00
|
|
|
|
2005-06-30 22:45:43 +02:00
|
|
|
UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action)
|
|
|
|
{
|
|
|
|
UINT count;
|
|
|
|
LPWSTR *newbuf = NULL;
|
|
|
|
|
2005-11-03 10:56:29 +01:00
|
|
|
if (!package->script)
|
2005-06-30 22:45:43 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
TRACE("Registering Action %s as having fun\n",debugstr_w(action));
|
|
|
|
|
|
|
|
count = package->script->UniqueActionsCount;
|
|
|
|
package->script->UniqueActionsCount++;
|
|
|
|
if (count != 0)
|
2005-09-20 13:59:14 +02:00
|
|
|
newbuf = msi_realloc( package->script->UniqueActions,
|
2005-06-30 22:45:43 +02:00
|
|
|
package->script->UniqueActionsCount* sizeof(LPWSTR));
|
|
|
|
else
|
2005-09-20 13:59:14 +02:00
|
|
|
newbuf = msi_alloc( sizeof(LPWSTR));
|
2005-06-30 22:45:43 +02:00
|
|
|
|
|
|
|
newbuf[count] = strdupW(action);
|
|
|
|
package->script->UniqueActions = newbuf;
|
|
|
|
|
2005-09-06 12:23:34 +02:00
|
|
|
return ERROR_SUCCESS;
|
2005-06-30 22:45:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL check_unique_action(MSIPACKAGE *package, LPCWSTR action)
|
|
|
|
{
|
|
|
|
INT i;
|
|
|
|
|
2005-11-03 10:56:29 +01:00
|
|
|
if (!package->script)
|
2005-06-30 22:45:43 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < package->script->UniqueActionsCount; i++)
|
|
|
|
if (!strcmpW(package->script->UniqueActions[i],action))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-29 21:19:09 +02:00
|
|
|
WCHAR* generate_error_string(MSIPACKAGE *package, UINT error, DWORD count, ... )
|
|
|
|
{
|
|
|
|
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};
|
|
|
|
|
|
|
|
MSIRECORD *rec;
|
|
|
|
MSIRECORD *row;
|
|
|
|
DWORD size = 0;
|
|
|
|
DWORD i;
|
|
|
|
va_list va;
|
|
|
|
LPCWSTR str;
|
|
|
|
LPWSTR data;
|
|
|
|
|
|
|
|
row = MSI_QueryGetRecord(package->db, query, error);
|
|
|
|
if (!row)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rec = MSI_CreateRecord(count+2);
|
|
|
|
|
|
|
|
str = MSI_RecordGetString(row,1);
|
|
|
|
MSI_RecordSetStringW(rec,0,str);
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
MSI_RecordSetInteger(rec,1,error);
|
|
|
|
|
|
|
|
va_start(va,count);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
str = va_arg(va,LPCWSTR);
|
|
|
|
MSI_RecordSetStringW(rec,(i+2),str);
|
|
|
|
}
|
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
MSI_FormatRecordW(package,rec,NULL,&size);
|
|
|
|
if (size >= 0)
|
|
|
|
{
|
|
|
|
size++;
|
2005-09-20 13:59:14 +02:00
|
|
|
data = msi_alloc(size*sizeof(WCHAR));
|
2005-06-29 21:19:09 +02:00
|
|
|
if (size > 1)
|
|
|
|
MSI_FormatRecordW(package,rec,data,&size);
|
|
|
|
else
|
|
|
|
data[0] = 0;
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
data = NULL;
|
|
|
|
return data;
|
|
|
|
}
|
2006-08-24 21:34:51 +02:00
|
|
|
|
|
|
|
void msi_ui_error( DWORD msg_id, DWORD type )
|
|
|
|
{
|
|
|
|
WCHAR text[2048];
|
|
|
|
|
|
|
|
static const WCHAR title[] = {
|
|
|
|
'W','i','n','d','o','w','s',' ','I','n','s','t','a','l','l','e','r',0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!MsiLoadStringW( -1, msg_id, text, sizeof(text) / sizeof(text[0]),
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
MessageBoxW( NULL, text, title, type );
|
|
|
|
}
|