Pradyumna
Pradyumna

Reputation: 1633

Xulrunner/JavaXPCOM - How to create instances of imgIContainer?

I am trying to create a Java-XPCOM version of this answer:

xul/xpcom copy image from string to clipboard

I am able to get hold of most of the services/components via calls such as these listed below (clipboard, io, transferable), but I can't do the same with the image container (container = {}; in the linked answer above)

nsIClipboard clipboard = (nsIClipboard) org.mozilla.xpcom.Mozilla.getInstance().getServiceManager().getService("8b5314ba-db01-11d2-96ce-0060b0fb9956", nsIClipboard.NS_ICLIPBOARD_IID);

nsIIOService io = (nsIIOService) org.mozilla.xpcom.Mozilla.getInstance().getServiceManager().getService("9ac9e770-18bc-11d3-9337-00104ba0fd40", nsIIOService.NS_IIOSERVICE_IID);

nsITransferable transferable = (nsITransferable)org.mozilla.xpcom.Mozilla.getInstance().getServiceManager().getService("8b5314bc-db01-11d2-96ce-0060b0fb9956", nsITransferable.NS_ITRANSFERABLE_IID);

I tried making an array of imgIContainers using both the componentManager as well as the serviceManager, but no luck..

imgIContainer imgContainer = (imgIContainer)org.mozilla.xpcom.Mozilla.getInstance().getComponentManager().createInstance("5e04ec5e-1dd2-11b2-8fda-c4db5fb666e0", null, imgIContainer.IMGICONTAINER_IID);

Is it that my Class ID is wrong, or should I be doing this all in a totally different way?

Thank you

Pradyumna

Upvotes: 1

Views: 461

Answers (1)

Pradyumna
Pradyumna

Reputation: 1633

I figured out that the class ID of @mozilla.org/image/container;1 is 27f0682c-ff64-4dd2-ae7a-668e59f2fd38, not 5e04ec5e-1dd2-11b2-8fda-c4db5fb666e0 that I was wrongly using..

Upvotes: 1

Related Questions