Use the new helper function MSI_QueryGetRecord.

This commit is contained in:
Mike McCormack 2005-06-02 10:29:57 +00:00 committed by Alexandre Julliard
parent 6309892499
commit 0b352c7f7f
2 changed files with 44 additions and 331 deletions

View File

@ -730,8 +730,6 @@ static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * recor
'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
' ','\'','%','s','\'',0};
WCHAR message[1024];
UINT rc;
MSIQUERY * view;
MSIRECORD * row = 0;
DWORD size;
static const WCHAR szActionData[] =
@ -739,30 +737,13 @@ static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * recor
if (!package->LastAction || strcmpW(package->LastAction,action))
{
rc = MSI_OpenQuery(package->db, &view, Query_t, action);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, Query_t, action);
if (!row)
return;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return;
}
if (MSI_RecordIsNull(row,3))
{
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return;
}
@ -774,8 +755,6 @@ static void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * recor
package->LastAction = strdupW(action);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
}
MSI_RecordSetStringW(record,0,package->ActionFormat);
@ -807,35 +786,17 @@ static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
' ','\'','%','s','\'',0};
WCHAR message[1024];
WCHAR timet[0x100];
UINT rc;
MSIQUERY * view;
MSIRECORD * row = 0;
WCHAR *ActionText=NULL;
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
rc = MSI_OpenQuery(package->db, &view, Query_t, action);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord( package->db, Query_t, action );
if (!row)
return;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return;
}
ActionText = load_dynamic_stringW(row,2);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
sprintfW(message,template_s,timet,action,ActionText);
@ -1100,8 +1061,7 @@ UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
{
MSIQUERY * view;
UINT rc;
UINT rc = ERROR_SUCCESS;
WCHAR buffer[0x100];
DWORD sz = 0x100;
MSIRECORD * row = 0;
@ -1118,30 +1078,14 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
' ', '=',' ','%','i',0};
if (UI)
rc = MSI_OpenQuery(package->db, &view, UISeqQuery, seq);
row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
else
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
if (rc == ERROR_SUCCESS)
if (row)
{
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
goto end;
}
TRACE("Running the actions\n");
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
rc = ERROR_SUCCESS;
goto end;
}
/* check conditions */
if (!MSI_RecordIsNull(row,2))
{
@ -1154,7 +1098,6 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
{
HeapFree(GetProcessHeap(),0,cond);
msiobj_release(&row->hdr);
goto end;
}
else
@ -1175,10 +1118,8 @@ static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq, BOOL UI)
rc = ACTION_PerformUIAction(package,buffer);
else
rc = ACTION_PerformAction(package,buffer, FALSE);
msiobj_release(&row->hdr);
end:
MSI_ViewClose(view);
msiobj_release(&view->hdr);
msiobj_release(&row->hdr);
}
else
rc = ERROR_SUCCESS;
@ -1219,27 +1160,11 @@ static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
/* get the sequence number */
if (UIran)
{
rc = MSI_DatabaseOpenViewW(package->db, IVQuery, &view);
if (rc != ERROR_SUCCESS)
return rc;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
row = MSI_QueryGetRecord(package->db, IVQuery);
if( !row )
return ERROR_FUNCTION_FAILED;
seq = MSI_RecordGetInteger(row,1);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
@ -2105,8 +2030,6 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir)
'W','H','E','R','E',' ', '`', 'D','i','r','e','c','t', 'o','r','y','`',
' ','=',' ','\'','%','s','\'',
0};
UINT rc;
MSIQUERY * view;
LPWSTR ptargetdir, targetdir, parent, srcdir;
LPWSTR shortname = NULL;
MSIRECORD * row = 0;
@ -2139,26 +2062,10 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir)
package->folders[index].Directory = strdupW(dir);
rc = MSI_OpenQuery(package->db, &view, Query, dir);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, Query, dir);
if (!row)
return -1;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
ptargetdir = targetdir = load_dynamic_stringW(row,3);
/* split src and target dir */
@ -2226,8 +2133,6 @@ static INT load_folder(MSIPACKAGE *package, const WCHAR* dir)
package->folders[index].Property = load_dynamic_property(package, dir,NULL);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
TRACE(" %s retuning on index %i\n",debugstr_w(dir),index);
return index;
}
@ -3154,8 +3059,7 @@ static BOOL extract_a_cabinet_file(MSIPACKAGE* package, const WCHAR* source,
static UINT ready_media_for_file(MSIPACKAGE *package, WCHAR* path,
MSIFILE* file)
{
UINT rc;
MSIQUERY * view;
UINT rc = ERROR_SUCCESS;
MSIRECORD * row = 0;
static WCHAR source[MAX_PATH];
static const WCHAR ExecSeqQuery[] =
@ -3164,7 +3068,6 @@ static UINT ready_media_for_file(MSIPACKAGE *package, WCHAR* path,
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',
' ','%', 'i',' ','O','R','D','E','R',' ','B','Y',' ',
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',0};
WCHAR Query[1024];
WCHAR cab[0x100];
DWORD sz=0x100;
INT seq;
@ -3183,27 +3086,10 @@ static UINT ready_media_for_file(MSIPACKAGE *package, WCHAR* path,
return ERROR_SUCCESS;
}
sprintfW(Query,ExecSeqQuery,file->Sequence);
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, file->Sequence);
if (!row)
return ERROR_FUNCTION_FAILED;
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
if (rc != ERROR_SUCCESS)
return rc;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
seq = MSI_RecordGetInteger(row,2);
last_sequence = seq;
@ -3247,8 +3133,6 @@ static UINT ready_media_for_file(MSIPACKAGE *package, WCHAR* path,
strcpyW(path,source);
}
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
@ -4043,9 +3927,8 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, INT
}
if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
{
MSIQUERY * view;
MSIRECORD * row = 0;
UINT rc,root,len;
UINT root,len;
LPWSTR key,deformated,buffer,name,deformated_name;
static const WCHAR ExecSeqQuery[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@ -4056,27 +3939,10 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, INT
static const WCHAR fmt2[]=
{'%','0','2','i',':','\\','%','s','\\','%','s',0};
rc = MSI_OpenQuery(package->db,&view,ExecSeqQuery,cmp->KeyPath);
if (rc!=ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
if (!row)
return NULL;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return NULL;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return NULL;
}
root = MSI_RecordGetInteger(row,2);
key = load_dynamic_stringW(row, 3);
name = load_dynamic_stringW(row, 4);
@ -4099,8 +3965,6 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, INT
HeapFree(GetProcessHeap(),0,name);
HeapFree(GetProcessHeap(),0,deformated_name);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return buffer;
}
@ -4596,7 +4460,6 @@ static INT load_appid(MSIPACKAGE* package, MSIRECORD *row)
static INT load_given_appid(MSIPACKAGE *package, LPCWSTR appid)
{
INT rc;
MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@ -4615,30 +4478,12 @@ static INT load_given_appid(MSIPACKAGE *package, LPCWSTR appid)
return i;
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, appid);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, appid);
if (!row)
return -1;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = load_appid(package, row);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
@ -4725,7 +4570,6 @@ static INT load_progid(MSIPACKAGE* package, MSIRECORD *row)
static INT load_given_progid(MSIPACKAGE *package, LPCWSTR progid)
{
INT rc;
MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@ -4744,30 +4588,12 @@ static INT load_given_progid(MSIPACKAGE *package, LPCWSTR progid)
return i;
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, progid);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, progid);
if(!row)
return -1;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = load_progid(package, row);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
@ -4893,7 +4719,6 @@ static INT load_class(MSIPACKAGE* package, MSIRECORD *row)
static INT load_given_class(MSIPACKAGE *package, LPCWSTR classid)
{
INT rc;
MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@ -4913,30 +4738,12 @@ static INT load_given_class(MSIPACKAGE *package, LPCWSTR classid)
return i;
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, classid);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, classid);
if (!row)
return -1;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = load_class(package, row);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
@ -4980,7 +4787,6 @@ static INT load_mime(MSIPACKAGE* package, MSIRECORD *row)
static INT load_given_mime(MSIPACKAGE *package, LPCWSTR mime)
{
INT rc;
MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@ -5000,30 +4806,12 @@ static INT load_given_mime(MSIPACKAGE *package, LPCWSTR mime)
return i;
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, mime);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, mime);
if (!row)
return -1;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = load_mime(package, row);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
@ -5079,7 +4867,6 @@ static INT load_extension(MSIPACKAGE* package, MSIRECORD *row)
static INT load_given_extension(MSIPACKAGE *package, LPCWSTR extension)
{
INT rc;
MSIQUERY *view;
MSIRECORD *row;
INT i;
static const WCHAR ExecSeqQuery[] =
@ -5101,30 +4888,12 @@ static INT load_given_extension(MSIPACKAGE *package, LPCWSTR extension)
return i;
}
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, extension);
if (rc != ERROR_SUCCESS)
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, extension);
if (!row)
return -1;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return -1;
}
rc = load_extension(package, row);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}

View File

@ -77,7 +77,6 @@ static UINT HANDLE_CustomType34(MSIPACKAGE *package, LPCWSTR source,
UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
{
UINT rc = ERROR_SUCCESS;
MSIQUERY * view;
MSIRECORD * row = 0;
static const WCHAR ExecSeqQuery[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@ -89,25 +88,9 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
LPWSTR target;
WCHAR *deformated=NULL;
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, action);
if (rc != ERROR_SUCCESS)
return rc;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
row = MSI_QueryGetRecord( package->db, ExecSeqQuery, action );
if (!row)
return ERROR_CALL_NOT_IMPLEMENTED;
}
type = MSI_RecordGetInteger(row,2);
@ -127,8 +110,6 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return ERROR_SUCCESS;
}
if (!execute)
@ -147,8 +128,6 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return ERROR_SUCCESS;
}
else
@ -202,8 +181,6 @@ UINT ACTION_CustomAction(MSIPACKAGE *package,LPCWSTR action, BOOL execute)
HeapFree(GetProcessHeap(),0,source);
HeapFree(GetProcessHeap(),0,target);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
@ -228,7 +205,6 @@ static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
{
/* write out the file */
UINT rc;
MSIQUERY * view;
MSIRECORD * row = 0;
static const WCHAR fmt[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
@ -246,25 +222,9 @@ static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
if (the_file == INVALID_HANDLE_VALUE)
return ERROR_FUNCTION_FAILED;
rc = MSI_OpenQuery(package->db, &view, fmt, source);
if (rc != ERROR_SUCCESS)
return rc;
rc = MSI_ViewExecute(view, 0);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
MSI_ViewClose(view);
msiobj_release(&view->hdr);
return rc;
}
row = MSI_QueryGetRecord(package->db, fmt, source);
if (!row)
return ERROR_FUNCTION_FAILED;
do
{
@ -284,8 +244,6 @@ static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
CloseHandle(the_file);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
}
return ERROR_SUCCESS;
@ -615,37 +573,23 @@ static UINT HANDLE_CustomType19(MSIPACKAGE *package, LPCWSTR source,
'W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ',
'\'','%','s','\'',0
};
MSIQUERY *view = NULL;
MSIRECORD *row = 0;
UINT r;
LPWSTR deformated = NULL;
deformat_string( package, target, &deformated );
/* first try treat the error as a number */
r = MSI_OpenQuery( package->db, &view, query, deformated );
if( r == ERROR_SUCCESS )
row = MSI_QueryGetRecord( package->db, query, deformated );
if( row )
{
r = MSI_ViewExecute( view, 0 );
if( r == ERROR_SUCCESS )
{
r = MSI_ViewFetch( view, &row );
if( r == ERROR_SUCCESS )
{
LPCWSTR error = MSI_RecordGetString( row, 1 );
MessageBoxW( NULL, error, NULL, MB_OK );
msiobj_release( &row->hdr );
}
}
MSI_ViewClose( view );
msiobj_release( &view->hdr );
LPCWSTR error = MSI_RecordGetString( row, 1 );
MessageBoxW( NULL, error, NULL, MB_OK );
msiobj_release( &row->hdr );
}
if (r != ERROR_SUCCESS )
{
else
MessageBoxW( NULL, deformated, NULL, MB_OK );
HeapFree( GetProcessHeap(), 0, deformated );
}
HeapFree( GetProcessHeap(), 0, deformated );
return ERROR_FUNCTION_FAILED;
}