Mercurial > simple_xpcom_firefox_extension
changeset 0:439a78563622 default tip
Origination.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 08 Feb 2008 14:02:26 -0600 |
parents | |
children | |
files | my_extension/chrome.manifest my_extension/chrome/content/sample.xul my_extension/chrome/content/stuff.js my_extension/install.rdf my_xpcom_component/Makefile my_xpcom_component/thingy.idl my_xpcom_component/thingy_impl.cpp my_xpcom_component/thingy_impl.h my_xpcom_component/thingy_module.cpp |
diffstat | 9 files changed, 146 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_extension/chrome.manifest Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,2 @@ +content sample chrome/content/ +overlay chrome://browser/content/browser.xul chrome://sample/content/sample.xul
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_extension/chrome/content/sample.xul Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<overlay id="sample" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> + <statusbar id="status-bar"> + <script src="stuff.js"/> + <statusbarpanel id="atul-panel" label="Hai2u!" + onclick="atulOnLabelClicked();" /> + </statusbar> +</overlay>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_extension/chrome/content/stuff.js Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,26 @@ +dump("Loading stuff.js.\n"); + +function atulOnLabelClicked() +{ + dump("halloes.\n"); + var thing = Components.classes["@toolness.com/thingy;1"].getService(); + thing = thing.QueryInterface(Components.interfaces.IThingy); + answer = thing.add(1,2); + dump("done...\n"); + dump("answer is " + answer + "\n" ); +/* + var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"] + .getService(); + cookieManager = cookieManager.QueryInterface(Components.interfaces.nsICookieManager); + + enum = cookieManager.enumerator; + dump("Beginning cookie list.\n"); + while (enum.hasMoreElements()) + { + cookie = enum.getNext(); + cookie = cookie.QueryInterface(Components.interfaces.nsICookie); + dump( cookie.name + "\n" ); + } + dump("Done with cookie list.\n"); +*/ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_extension/install.rdf Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,23 @@ +<?xml version="1.0"?> + +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + <Description about="urn:mozilla:install-manifest"> + <em:id>my_extension@toolness.com</em:id> + <em:version>1.0</em:version> + <em:type>2</em:type> + + <em:targetApplication> + <Description> + <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> + <em:minVersion>1.5</em:minVersion> + <em:maxVersion>3.0.0.*</em:maxVersion> + </Description> + </em:targetApplication> + + <em:name>Atul's Extension</em:name> + <em:description>My own test extension.</em:description> + <em:creator>Atul Varma</em:creator> + <em:homepageURL>http://www.toolness.com</em:homepage> + </Description> +</RDF>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_xpcom_component/Makefile Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,21 @@ +GECKO_SDK_DIR = ../../mozilla-stuff/dist/sdk +EXT_DIR = ../my_extension/components +EXT_DYLIB = ${EXT_DIR}/libThingyModule.dylib + +all: thingy.dylib + +thingy.dylib: thingy_impl.o thingy_module.o + c++ -bundle thingy_impl.o thingy_module.o -o thingy.dylib -L${GECKO_SDK_DIR}/lib -lnspr4 -lxpcom -lxpcomglue_s + cp thingy.dylib ${EXT_DYLIB} + +thingy_impl.o: thingy.h thingy.xpt thingy_impl.h thingy_impl.cpp + c++ -c thingy_module.cpp thingy_impl.cpp -I${GECKO_SDK_DIR}/include -fvisibility=hidden + +thingy.h: thingy.idl + ${GECKO_SDK_DIR}/bin/xpidl -m header -I${GECKO_SDK_DIR}/idl thingy.idl + +thingy.xpt: thingy.idl + ${GECKO_SDK_DIR}/bin/xpidl -m typelib -I${GECKO_SDK_DIR}/idl thingy.idl + +clean: + rm -f *.o *.xpt *.dylib thingy.h ${EXT_DYLIB}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_xpcom_component/thingy.idl Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,7 @@ +#include "nsISupports.idl" + +[scriptable, uuid(dded991a-6a88-43b1-936b-3898c6ff3b67)] +interface IThingy : nsISupports +{ + long add(in long a, in long b); +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_xpcom_component/thingy_impl.cpp Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,20 @@ +#include "thingy_impl.h" + +NS_IMPL_ISUPPORTS1(_MYCLASS_, IThingy) + +_MYCLASS_::_MYCLASS_() +{ + /* member initializers and constructor code */ +} + +_MYCLASS_::~_MYCLASS_() +{ + /* destructor code */ +} + +/* long add (in long a, in long b); */ +NS_IMETHODIMP _MYCLASS_::Add(PRInt32 a, PRInt32 b, PRInt32 *_retval) +{ + *_retval = a + b + 1; + return NS_OK; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_xpcom_component/thingy_impl.h Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,22 @@ +#include "thingy.h" + +#define MYCLASS_CONTRACTID "@toolness.com/thingy;1" +#define MYCLASS_CLASSNAME "Thingy" +#define MYCLASS_CID \ + {0xd7c743cd, 0x34b0, 0x4290, \ + { 0xb2, 0x13, 0xa3, 0xb6, 0x1d, 0x2b, 0x9f, 0x9b }} + +class _MYCLASS_ : public IThingy +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_ITHINGY + + _MYCLASS_(); + +private: + ~_MYCLASS_(); + +protected: + /* additional members */ +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/my_xpcom_component/thingy_module.cpp Fri Feb 08 14:02:26 2008 -0600 @@ -0,0 +1,16 @@ +#include "nsIGenericFactory.h" +#include "thingy_impl.h" + +NS_GENERIC_FACTORY_CONSTRUCTOR(_MYCLASS_) + +static nsModuleComponentInfo components[] = +{ + { + MYCLASS_CLASSNAME, + MYCLASS_CID, + MYCLASS_CONTRACTID, + _MYCLASS_Constructor, + } +}; + +NS_IMPL_NSGETMODULE( "ThingyModule", components )