[xiph-commits] r15079 - in trunk/oggPusher: . firefox-extension firefox-extension/chrome/content firefox-extension/components xpcom-sample xpcom-sample/src

nithin at svn.xiph.org nithin at svn.xiph.org
Fri Jun 27 18:09:59 PDT 2008


Author: nithin
Date: 2008-06-27 18:09:58 -0700 (Fri, 27 Jun 2008)
New Revision: 15079

Added:
   trunk/oggPusher/firefox-extension/components/
   trunk/oggPusher/firefox-extension/components/IMyComponent.xpt
   trunk/oggPusher/firefox-extension/components/MyComponent.so
   trunk/oggPusher/xpcom-sample/
   trunk/oggPusher/xpcom-sample/MyComponentTest.html
   trunk/oggPusher/xpcom-sample/MyComponentTest.js
   trunk/oggPusher/xpcom-sample/README.txt
   trunk/oggPusher/xpcom-sample/src/
   trunk/oggPusher/xpcom-sample/src/IMyComponent.h
   trunk/oggPusher/xpcom-sample/src/IMyComponent.idl
   trunk/oggPusher/xpcom-sample/src/IMyComponent.xpt
   trunk/oggPusher/xpcom-sample/src/Makefile
   trunk/oggPusher/xpcom-sample/src/MyComponent.cpp
   trunk/oggPusher/xpcom-sample/src/MyComponent.h
   trunk/oggPusher/xpcom-sample/src/MyComponent.so
   trunk/oggPusher/xpcom-sample/src/MyComponentModule.cpp
Modified:
   trunk/oggPusher/firefox-extension/chrome/content/op_Window.js
   trunk/oggPusher/oggPusher.xpi
Log:
Trying A Sample XPCOM

Modified: trunk/oggPusher/firefox-extension/chrome/content/op_Window.js
===================================================================
--- trunk/oggPusher/firefox-extension/chrome/content/op_Window.js	2008-06-27 22:07:19 UTC (rev 15078)
+++ trunk/oggPusher/firefox-extension/chrome/content/op_Window.js	2008-06-28 01:09:58 UTC (rev 15079)
@@ -12,6 +12,24 @@
          		var path = fp.file.path;
 			parent.document.getElementById("file-path").value = path;
                 }
-         }
+         },
+	 myComponentTestGo:function()
+	 {
+		alert("Start of MyComponentTestGo()");
+        	try {
+               		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                	const cid = "@mydomain.com/XPCOMSample/MyComponent;1";
+                	obj = Components.classes[cid].createInstance();
+                	obj = obj.QueryInterface(Components.interfaces.IMyComponent);
+        	} 
+		catch (err) 
+		{
+	               	alert(err);
+        	        return;
+        	}
+        	var res = obj.Add(3, 4);
+        	alert('Performing 3+4. Returned ' + res + '.');
+	}
+
 }
 

Added: trunk/oggPusher/firefox-extension/components/IMyComponent.xpt
===================================================================
(Binary files differ)


Property changes on: trunk/oggPusher/firefox-extension/components/IMyComponent.xpt
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/oggPusher/firefox-extension/components/MyComponent.so
===================================================================
(Binary files differ)


Property changes on: trunk/oggPusher/firefox-extension/components/MyComponent.so
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/oggPusher/oggPusher.xpi
===================================================================
(Binary files differ)

Added: trunk/oggPusher/xpcom-sample/MyComponentTest.html
===================================================================
--- trunk/oggPusher/xpcom-sample/MyComponentTest.html	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/MyComponentTest.html	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,7 @@
+<HTML>
+<SCRIPT SRC="MyComponentTest.js"></SCRIPT>
+<BODY>
+<BUTTON ONCLICK="MyComponentTestGo();">Go</BUTTON>
+</BODY>
+</HTML>
+

Added: trunk/oggPusher/xpcom-sample/MyComponentTest.js
===================================================================
--- trunk/oggPusher/xpcom-sample/MyComponentTest.js	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/MyComponentTest.js	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,13 @@
+function MyComponentTestGo() {
+	try {
+		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+		const cid = "@mydomain.com/XPCOMSample/MyComponent;1";
+		obj = Components.classes[cid].createInstance();
+		obj = obj.QueryInterface(Components.interfaces.IMyComponent);
+	} catch (err) {
+		alert(err);
+		return;
+	}
+	var res = obj.Add(3, 4);
+	alert('Performing 3+4. Returned ' + res + '.');
+}

Added: trunk/oggPusher/xpcom-sample/README.txt
===================================================================
--- trunk/oggPusher/xpcom-sample/README.txt	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/README.txt	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,8 @@
+This is the sample code for the "Creating a C++ XPCOM component" tutorial
+found at http://www.iosart.com/firefox/xpcom/.
+
+Author: Alex Sirota <alex at elbrus.com>
+
+
+
+

Added: trunk/oggPusher/xpcom-sample/src/IMyComponent.h
===================================================================
--- trunk/oggPusher/xpcom-sample/src/IMyComponent.h	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/src/IMyComponent.h	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,91 @@
+/*
+ * DO NOT EDIT.  THIS FILE IS GENERATED FROM IMyComponent.idl
+ */
+
+#ifndef __gen_IMyComponent_h__
+#define __gen_IMyComponent_h__
+
+
+#ifndef __gen_nsISupports_h__
+#include "nsISupports.h"
+#endif
+
+/* For IDL files that don't want to include root IDL files. */
+#ifndef NS_NO_VTABLE
+#define NS_NO_VTABLE
+#endif
+
+/* starting interface:    IMyComponent */
+#define IMYCOMPONENT_IID_STR "166ff10a-ea3c-490a-8c39-d453431bce3a"
+
+#define IMYCOMPONENT_IID \
+  {0x166ff10a, 0xea3c, 0x490a, \
+    { 0x8c, 0x39, 0xd4, 0x53, 0x43, 0x1b, 0xce, 0x3a }}
+
+class NS_NO_VTABLE NS_SCRIPTABLE IMyComponent : public nsISupports {
+ public: 
+
+  NS_DECLARE_STATIC_IID_ACCESSOR(IMYCOMPONENT_IID)
+
+  /* long Add (in long a, in long b); */
+  NS_SCRIPTABLE NS_IMETHOD Add(PRInt32 a, PRInt32 b, PRInt32 *_retval) = 0;
+
+};
+
+  NS_DEFINE_STATIC_IID_ACCESSOR(IMyComponent, IMYCOMPONENT_IID)
+
+/* Use this macro when declaring classes that implement this interface. */
+#define NS_DECL_IMYCOMPONENT \
+  NS_SCRIPTABLE NS_IMETHOD Add(PRInt32 a, PRInt32 b, PRInt32 *_retval); 
+
+/* Use this macro to declare functions that forward the behavior of this interface to another object. */
+#define NS_FORWARD_IMYCOMPONENT(_to) \
+  NS_SCRIPTABLE NS_IMETHOD Add(PRInt32 a, PRInt32 b, PRInt32 *_retval) { return _to Add(a, b, _retval); } 
+
+/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
+#define NS_FORWARD_SAFE_IMYCOMPONENT(_to) \
+  NS_SCRIPTABLE NS_IMETHOD Add(PRInt32 a, PRInt32 b, PRInt32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Add(a, b, _retval); } 
+
+#if 0
+/* Use the code below as a template for the implementation class for this interface. */
+
+/* Header file */
+class _MYCLASS_ : public IMyComponent
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_IMYCOMPONENT
+
+  _MYCLASS_();
+
+private:
+  ~_MYCLASS_();
+
+protected:
+  /* additional members */
+};
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1(_MYCLASS_, IMyComponent)
+
+_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)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* End of implementation class template. */
+#endif
+
+
+#endif /* __gen_IMyComponent_h__ */

Added: trunk/oggPusher/xpcom-sample/src/IMyComponent.idl
===================================================================
--- trunk/oggPusher/xpcom-sample/src/IMyComponent.idl	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/src/IMyComponent.idl	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,8 @@
+#include "nsISupports.idl"
+
+[scriptable, uuid(166ff10a-ea3c-490a-8c39-d453431bce3a)]
+interface IMyComponent : nsISupports
+{
+  long Add(in long a, in long b);
+};
+

Added: trunk/oggPusher/xpcom-sample/src/IMyComponent.xpt
===================================================================
(Binary files differ)


Property changes on: trunk/oggPusher/xpcom-sample/src/IMyComponent.xpt
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/oggPusher/xpcom-sample/src/Makefile
===================================================================
--- trunk/oggPusher/xpcom-sample/src/Makefile	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/src/Makefile	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,30 @@
+CXX   = c++
+CPPFLAGS +=     -fno-rtti              \
+		-fno-exceptions        \
+		-shared  	       \
+ 
+# Change this to point at your Gecko SDK directory. 
+GECKO_SDK_PATH = $(shell pkg-config --variable=sdkdir libxul)
+ 
+# GCC only define which allows us to not have to #include mozilla-config 
+# in every .cpp file.  If your not using GCC remove this line and add 
+# #include "mozilla-config.h" to each of your .cpp files. 
+#GECKO_CONFIG_INCLUDE = -include mozilla-config.h 
+ 
+#GECKO_DEFINES  =  -DXPCOM_GLUE
+ 
+GECKO_INCLUDES = $(shell pkg-config --cflags libxul)
+ 
+GECKO_LDFLAGS =  -L$(GECKO_SDK_PATH)/lib -lxpcom -lnspr4 -Wl,-z,-defs
+
+FILES = MyComponent.cpp MyComponentModule.cpp 
+
+TARGET = MyComponent.so
+
+build: 
+	$(CXX) -Wall -Os -o $(TARGET)  $(GECKO_INCLUDES) $(CPPFLAGS) $(CXXFLAGS) $(FILES) /usr/lib/xulrunner-devel-1.9/lib/libxpcomglue_s.a $(GECKO_LDFLAGS)
+	chmod +x $(TARGET)
+	strip $(TARGET)
+ 
+clean: 
+	rm $(TARGET)

Added: trunk/oggPusher/xpcom-sample/src/MyComponent.cpp
===================================================================
--- trunk/oggPusher/xpcom-sample/src/MyComponent.cpp	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/src/MyComponent.cpp	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,21 @@
+#include "MyComponent.h"
+
+NS_IMPL_ISUPPORTS1(MyComponent, IMyComponent)
+
+MyComponent::MyComponent()
+{
+  /* member initializers and constructor code */
+}
+
+MyComponent::~MyComponent()
+{
+  /* destructor code */
+}
+
+/* long Add (in long a, in long b); */
+NS_IMETHODIMP MyComponent::Add(PRInt32 a, PRInt32 b, PRInt32 *_retval)
+{
+	*_retval = a + b;
+	return NS_OK;
+}
+

Added: trunk/oggPusher/xpcom-sample/src/MyComponent.h
===================================================================
--- trunk/oggPusher/xpcom-sample/src/MyComponent.h	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/src/MyComponent.h	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,22 @@
+#ifndef _MY_COMPONENT_H_
+#define _MY_COMPONENT_H_
+
+#include "IMyComponent.h"
+
+#define MY_COMPONENT_CONTRACTID "@mydomain.com/XPCOMSample/MyComponent;1"
+#define MY_COMPONENT_CLASSNAME "A Simple XPCOM Sample"
+#define MY_COMPONENT_CID {0x166ff10a, 0xea3c, 0x490a, {0x8c, 0x39, 0xd4, 0x53, 0x43, 0x1b, 0xce, 0x3a}}
+/* Header file */
+class MyComponent : public IMyComponent
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_IMYCOMPONENT
+
+  MyComponent();
+  virtual ~MyComponent();
+  /* additional members */
+};
+
+
+#endif //_MY_COMPONENT_H_

Added: trunk/oggPusher/xpcom-sample/src/MyComponent.so
===================================================================
(Binary files differ)


Property changes on: trunk/oggPusher/xpcom-sample/src/MyComponent.so
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: trunk/oggPusher/xpcom-sample/src/MyComponentModule.cpp
===================================================================
--- trunk/oggPusher/xpcom-sample/src/MyComponentModule.cpp	                        (rev 0)
+++ trunk/oggPusher/xpcom-sample/src/MyComponentModule.cpp	2008-06-28 01:09:58 UTC (rev 15079)
@@ -0,0 +1,17 @@
+#include "nsIGenericFactory.h"
+#include "MyComponent.h"
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(MyComponent)
+
+static nsModuleComponentInfo components[] =
+{
+    {
+       MY_COMPONENT_CLASSNAME, 
+       MY_COMPONENT_CID,
+       MY_COMPONENT_CONTRACTID,
+       MyComponentConstructor,
+    }
+};
+
+NS_IMPL_NSGETMODULE("MyComponentsModule", components) 
+



More information about the commits mailing list