msi: Use MSI_QueryGetRecord in ACTION_AppSearchGetSignature.

This commit is contained in:
Mike McCormack 2006-11-27 17:48:37 +09:00 committed by Alexandre Julliard
parent 0670ebc67b
commit a1c969ee23
1 changed files with 58 additions and 83 deletions

View File

@ -80,40 +80,27 @@ static void ACTION_VerStrToInteger(LPCWSTR verStr, PDWORD ms, PDWORD ls)
* Returns ERROR_SUCCESS upon success (where not finding the record counts as * Returns ERROR_SUCCESS upon success (where not finding the record counts as
* success), something else on error. * success), something else on error.
*/ */
static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig, static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig, LPCWSTR name)
LPCWSTR name)
{ {
MSIQUERY *view; static const WCHAR query[] = {
UINT rc;
static const WCHAR ExecSeqQuery[] = {
's','e','l','e','c','t',' ','*',' ', 's','e','l','e','c','t',' ','*',' ',
'f','r','o','m',' ', 'f','r','o','m',' ',
'S','i','g','n','a','t','u','r','e',' ', 'S','i','g','n','a','t','u','r','e',' ',
'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e',' ','=',' ', 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e',' ','=',' ',
'\'','%','s','\'',0}; '\'','%','s','\'',0};
LPWSTR minVersion, maxVersion;
MSIRECORD *row;
DWORD time;
TRACE("package %p, sig %p\n", package, sig);
TRACE("(package %p, sig %p)\n", package, sig);
memset(sig, 0, sizeof(*sig)); memset(sig, 0, sizeof(*sig));
sig->Name = name; sig->Name = name;
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, name); row = MSI_QueryGetRecord( package->db, query, name );
if (rc == ERROR_SUCCESS) if (!row)
{ {
MSIRECORD *row = 0; TRACE("failed to query signature for %s\n", debugstr_w(name));
DWORD time; return ERROR_SUCCESS;
WCHAR *minVersion, *maxVersion;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
TRACE("MSI_ViewExecute returned %d\n", rc);
goto end;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
TRACE("MSI_ViewFetch returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
} }
/* get properties */ /* get properties */
@ -121,16 +108,14 @@ static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig,
minVersion = msi_dup_record_field(row,3); minVersion = msi_dup_record_field(row,3);
if (minVersion) if (minVersion)
{ {
ACTION_VerStrToInteger(minVersion, &sig->MinVersionMS, ACTION_VerStrToInteger(minVersion, &sig->MinVersionMS, &sig->MinVersionLS);
&sig->MinVersionLS); msi_free( minVersion );
msi_free( minVersion);
} }
maxVersion = msi_dup_record_field(row,4); maxVersion = msi_dup_record_field(row,4);
if (maxVersion) if (maxVersion)
{ {
ACTION_VerStrToInteger(maxVersion, &sig->MaxVersionMS, ACTION_VerStrToInteger(maxVersion, &sig->MaxVersionMS, &sig->MaxVersionLS);
&sig->MaxVersionLS); msi_free( maxVersion );
msi_free( maxVersion);
} }
sig->MinSize = MSI_RecordGetInteger(row,5); sig->MinSize = MSI_RecordGetInteger(row,5);
if (sig->MinSize == MSI_NULL_INTEGER) if (sig->MinSize == MSI_NULL_INTEGER)
@ -145,6 +130,7 @@ static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig,
time = MSI_RecordGetInteger(row,8); time = MSI_RecordGetInteger(row,8);
if (time != MSI_NULL_INTEGER) if (time != MSI_NULL_INTEGER)
DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MaxTime); DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MaxTime);
TRACE("Found file name %s for Signature_ %s;\n", TRACE("Found file name %s for Signature_ %s;\n",
debugstr_w(sig->File), debugstr_w(name)); debugstr_w(sig->File), debugstr_w(name));
TRACE("MinVersion is %d.%d.%d.%d\n", HIWORD(sig->MinVersionMS), TRACE("MinVersion is %d.%d.%d.%d\n", HIWORD(sig->MinVersionMS),
@ -156,20 +142,9 @@ static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig,
TRACE("MinSize is %d, MaxSize is %d;\n", sig->MinSize, sig->MaxSize); TRACE("MinSize is %d, MaxSize is %d;\n", sig->MinSize, sig->MaxSize);
TRACE("Languages is %s\n", debugstr_w(sig->Languages)); TRACE("Languages is %s\n", debugstr_w(sig->Languages));
end: msiobj_release( &row->hdr );
if (row)
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
}
else
{
TRACE("MSI_OpenQuery returned %d\n", rc);
rc = ERROR_SUCCESS;
}
TRACE("returning %d\n", rc); return ERROR_SUCCESS;
return rc;
} }
/* Frees any memory allocated in sig */ /* Frees any memory allocated in sig */