Uninstall Extension from XPCOM component

Anatoly Kaverin <[email protected]> 15 Sep 2005 10:18:49 GMT
Newsgroups gmane.comp.mozilla.devel.xpinstall
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Greetings to everyone...

We're developing DLL, which installs our XPI package file - for installation 
we used -install-global-extension, so now DLL installs XPI without starting 
FF with install dialog.
But also we need to develop UnInstall method, which would uninstall xpi from 
FF without user help.
I've noticed that such option we'll be available in FF 1.5, but we need to 
make it work till that time and also we have to support earlier version of 
FF.

I've noticed nsIExtensionManager service and managed to create uninstall 
method in XUL (of Extension) - and it really works fine, here it is:

var ext = Components.classes["@mozilla.org/extensions/manager;1"].getService();
ext = ext.QueryInterface(Components.interfaces.nsIExtensionManager);
ext.uninstallExtension("our_extension_GUID");

But we need to put that func inside our XPCOM component... i've translated 
it - but it doesn't work, here it is:

nsCOMPtr<nsIServiceManager> servman;
nsresult res = NS_GetServiceManager(getter_AddRefs(servman));

if (res == NS_OK)
{
	nsCOMPtr<nsIExtensionManager> extMan;

	res = servman->GetServiceByContractID("@mozilla.org/extensions/manager;1", 
NS_GET_IID(nsIExtensionManager), getter_AddRefs(extMan));
	if (res == NS_OK)
	{
	     res = extMan->UninstallExtension("{our_extension_GUID}");
			
	     if (res == NS_OK)
	     {
		MessageBox(NULL, "uninstall succeeded!", "!", MB_OK);
	     }
	}
}

We always got message -- "Uninstall Succeeded", but Extension remain uninstalled.

P.S> THNXm for attension, looking forward fr your help, guys.

With Best Regards,
Anatoly Kaverin, 
Firefox VEngine team
Comodo CA Limited
http://www.vengine.com http://www.comodo.com
[email protected]
MSN: [email protected]