msi: Implement the UnregisterMIMEInfo standard action.

This commit is contained in:
Hans Leidekker 2010-04-02 09:40:07 +01:00 committed by Alexandre Julliard
parent a7ef96f97f
commit 3050cde95e
3 changed files with 71 additions and 34 deletions

View file

@ -158,8 +158,6 @@ static const WCHAR szUnpublishFeatures[] =
{'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
static const WCHAR szUnregisterComPlus[] =
{'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
static const WCHAR szUnregisterMIMEInfo[] =
{'U','n','r','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
static const WCHAR szUnregisterTypeLibraries[] =
{'U','n','r','e','g','i','s','t','e','r','T','y','p','e','L','i','b','r','a','r','i','e','s',0};
static const WCHAR szValidateProductID[] =
@ -6947,12 +6945,6 @@ static UINT ACTION_RemoveExistingProducts( MSIPACKAGE *package )
return msi_unimplemented_action_stub( package, "RemoveExistingProducts", table );
}
static UINT ACTION_UnregisterMIMEInfo( MSIPACKAGE *package )
{
static const WCHAR table[] = { 'M','I','M','E',0 };
return msi_unimplemented_action_stub( package, "UnregisterMIMEInfo", table );
}
typedef UINT (*STANDARDACTIONHANDLER)(MSIPACKAGE*);
static const struct

View file

@ -27,7 +27,7 @@
* UnregisterClassInfo
* UnregisterProgIdInfo
* UnregisterExtensionInfo
* UnregisterMIMEInfo (TODO)
* UnregisterMIMEInfo
*/
#include <stdarg.h>
@ -1429,11 +1429,6 @@ UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
LIST_FOR_EACH_ENTRY( mt, &package->mimes, MSIMIME, entry )
{
LPWSTR extension;
LPCWSTR exten;
LPCWSTR mime;
static const WCHAR fmt[] =
{'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\',
'C','o','n','t','e','n','t',' ','T','y','p','e','\\', '%','s',0};
LPWSTR key;
/*
@ -1446,33 +1441,80 @@ UINT ACTION_RegisterMIMEInfo(MSIPACKAGE *package)
if (!mt->InstallMe)
{
TRACE("MIME %s not scheduled to be installed\n",
debugstr_w(mt->ContentType));
TRACE("MIME %s not scheduled to be installed\n", debugstr_w(mt->ContentType));
continue;
}
mime = mt->ContentType;
exten = mt->Extension->Extension;
extension = msi_alloc( (lstrlenW( exten ) + 2)*sizeof(WCHAR) );
extension[0] = '.';
lstrcpyW(extension+1,exten);
TRACE("Registering MIME type %s\n", debugstr_w(mt->ContentType));
key = msi_alloc( (strlenW(mime)+strlenW(fmt)+1) * sizeof(WCHAR) );
sprintfW(key,fmt,mime);
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szExten, extension );
extension = msi_alloc( (strlenW( mt->Extension->Extension ) + 2) * sizeof(WCHAR) );
key = msi_alloc( (strlenW( mt->ContentType ) + strlenW( szMIMEDatabase ) + 1) * sizeof(WCHAR) );
msi_free(extension);
msi_free(key);
if (extension && key)
{
extension[0] = '.';
strcpyW( extension + 1, mt->Extension->Extension );
if (mt->clsid)
FIXME("Handle non null for field 3\n");
strcpyW( key, szMIMEDatabase );
strcatW( key, mt->ContentType );
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szExten, extension );
uirow = MSI_CreateRecord(2);
MSI_RecordSetStringW(uirow,1,mt->ContentType);
MSI_RecordSetStringW(uirow,2,exten);
ui_actiondata(package,szRegisterMIMEInfo,uirow);
msiobj_release(&uirow->hdr);
if (mt->clsid)
msi_reg_set_subkey_val( HKEY_CLASSES_ROOT, key, szCLSID, mt->clsid );
}
msi_free( extension );
msi_free( key );
uirow = MSI_CreateRecord( 2 );
MSI_RecordSetStringW( uirow, 1, mt->ContentType );
MSI_RecordSetStringW( uirow, 2, mt->Extension->Extension );
ui_actiondata( package, szRegisterMIMEInfo, uirow );
msiobj_release( &uirow->hdr );
}
return ERROR_SUCCESS;
}
UINT ACTION_UnregisterMIMEInfo( MSIPACKAGE *package )
{
MSIRECORD *uirow;
MSIMIME *mime;
load_classes_and_such( package );
LIST_FOR_EACH_ENTRY( mime, &package->mimes, MSIMIME, entry )
{
LONG res;
LPWSTR mime_key;
mime->InstallMe = (mime->InstallMe ||
(mime->Class && mime->Class->Installed) ||
(mime->Extension && mime->Extension->Installed));
if (mime->InstallMe)
{
TRACE("MIME %s not scheduled to be removed\n", debugstr_w(mime->ContentType));
continue;
}
TRACE("Unregistering MIME type %s\n", debugstr_w(mime->ContentType));
mime_key = msi_alloc( (strlenW( szMIMEDatabase ) + strlenW( mime->ContentType ) + 1) * sizeof(WCHAR) );
if (mime_key)
{
strcpyW( mime_key, szMIMEDatabase );
strcatW( mime_key, mime->ContentType );
res = RegDeleteKeyW( HKEY_CLASSES_ROOT, mime_key );
if (res != ERROR_SUCCESS)
WARN("Failed to delete MIME key %d\n", res);
msi_free( mime_key );
}
uirow = MSI_CreateRecord( 2 );
MSI_RecordSetStringW( uirow, 1, mime->ContentType );
MSI_RecordSetStringW( uirow, 2, mime->Extension->Extension );
ui_actiondata( package, szUnregisterMIMEInfo, uirow );
msiobj_release( &uirow->hdr );
}
return ERROR_SUCCESS;

View file

@ -965,6 +965,7 @@ extern UINT ACTION_RegisterFonts(MSIPACKAGE *package);
extern UINT ACTION_UnregisterClassInfo(MSIPACKAGE *package);
extern UINT ACTION_UnregisterExtensionInfo(MSIPACKAGE *package);
extern UINT ACTION_UnregisterFonts(MSIPACKAGE *package);
extern UINT ACTION_UnregisterMIMEInfo(MSIPACKAGE *package);
extern UINT ACTION_UnregisterProgIdInfo(MSIPACKAGE *package);
/* Helpers */
@ -1089,6 +1090,7 @@ static const WCHAR szMoveFiles[] = {'M','o','v','e','F','i','l','e','s',0};
static const WCHAR szCCPSearch[] = {'C','C','P','S','e','a','r','c','h',0};
static const WCHAR szUnregisterClassInfo[] = {'U','n','r','e','g','i','s','t','e','r','C','l','a','s','s','I','n','f','o',0};
static const WCHAR szUnregisterExtensionInfo[] = {'U','n','r','e','g','i','s','t','e','r','E','x','t','e','n','s','i','o','n','I','n','f','o',0};
static const WCHAR szUnregisterMIMEInfo[] = {'U','n','r','e','g','i','s','t','e','r','M','I','M','E','I','n','f','o',0};
static const WCHAR szUnregisterProgIdInfo[] = {'U','n','r','e','g','i','s','t','e','r','P','r','o','g','I','d','I','n','f','o',0};
static const WCHAR szRegisterFonts[] = {'R','e','g','i','s','t','e','r','F','o','n','t','s',0};
static const WCHAR szUnregisterFonts[] = {'U','n','r','e','g','i','s','t','e','r','F','o','n','t','s',0};
@ -1099,6 +1101,7 @@ static const WCHAR szAppID[] = {'A','p','p','I','D',0};
static const WCHAR szDefaultIcon[] = {'D','e','f','a','u','l','t','I','c','o','n',0};
static const WCHAR szInprocHandler[] = {'I','n','p','r','o','c','H','a','n','d','l','e','r',0};
static const WCHAR szInprocHandler32[] = {'I','n','p','r','o','c','H','a','n','d','l','e','r','3','2',0};
static const WCHAR szMIMEDatabase[] = {'M','I','M','E','\\','D','a','t','a','b','a','s','e','\\','C','o','n','t','e','n','t',' ','T','y','p','e','\\',0};
/* memory allocation macro functions */
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);