summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-19 02:27:40 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-19 02:27:40 +0200
commit495758a73e125e59921092c893c6e32ba7091fe1 (patch)
treebfaf7696d3452722d1c464cd733157ebc04bdd1a
parentba5fe7122586d8b382bf78f1e1cb5dbe4293c27b (diff)
downloadsamba-495758a73e125e59921092c893c6e32ba7091fe1.tar.gz
samba-495758a73e125e59921092c893c6e32ba7091fe1.tar.bz2
samba-495758a73e125e59921092c893c6e32ba7091fe1.zip
Fix COM compilation, add framework for COM python module.
-rw-r--r--source4/lib/com/com.h2
-rw-r--r--source4/lib/com/config.mk9
-rw-r--r--source4/lib/com/main.c22
-rw-r--r--source4/lib/com/pycom.c70
-rw-r--r--source4/lib/com/rot.c1
5 files changed, 82 insertions, 22 deletions
diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h
index 2074bd11ca..5d594ad41b 100644
--- a/source4/lib/com/com.h
+++ b/source4/lib/com/com.h
@@ -47,4 +47,6 @@ WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_if
WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip);
NTSTATUS com_init(void);
+typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid);
+
#endif /* __SAMBA_COM_H__ */
diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk
index 5c8e98dc46..c5c5a35003 100644
--- a/source4/lib/com/config.mk
+++ b/source4/lib/com/config.mk
@@ -1,9 +1,10 @@
[SUBSYSTEM::COM]
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBEVENTS LIBNDR
COM_OBJ_FILES = $(addprefix lib/com/, tables.o rot.o main.o)
[SUBSYSTEM::DCOM]
-PUBLIC_DEPENDENCIES = com DCOM_PROXY_DCOM RPC_NDR_REMACT \
+PUBLIC_DEPENDENCIES = COM DCOM_PROXY_DCOM RPC_NDR_REMACT \
RPC_NDR_OXIDRESOLVER
DCOM_OBJ_FILES = $(addprefix lib/com/dcom/, main.o tables.o)
@@ -13,3 +14,9 @@ SUBSYSTEM = COM
INIT_FUNCTION = com_simple_init
com_simple_OBJ_FILES = lib/com/classes/simple.o
+
+[PYTHON::pycom]
+LIBRARY_REALNAME = samba/com.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = COM
+
+pycom_OBJ_FILES = lib/com/pycom.o
diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c
index 882b479cfe..bcc5fa393a 100644
--- a/source4/lib/com/main.c
+++ b/source4/lib/com/main.c
@@ -42,7 +42,7 @@ WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_if
int i;
struct GUID classfact_iid;
- GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &classfact_iid);
+ GUID_from_string(NDR_ICLASSFACTORY_UUID, &classfact_iid);
/* Obtain class object */
error = com_get_class_object(ctx, clsid, &classfact_iid, (struct IUnknown **)&factory);
@@ -88,23 +88,3 @@ WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct
return IUnknown_QueryInterface(iu, ctx, iid, ip);
}
-
-NTSTATUS com_init(void)
-{
- static BOOL initialized = False;
-
- init_module_fn static_init[] = STATIC_com_MODULES;
- init_module_fn *shared_init;
-
- if (initialized) return NT_STATUS_OK;
- initialized = True;
-
- shared_init = load_samba_modules(NULL, "com");
-
- run_init_functions(static_init);
- run_init_functions(shared_init);
-
- talloc_free(shared_init);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/com/pycom.c b/source4/lib/com/pycom.c
new file mode 100644
index 0000000000..b6d6b772a8
--- /dev/null
+++ b/source4/lib/com/pycom.c
@@ -0,0 +1,70 @@
+/*
+ Unix SMB/CIFS implementation.
+ Python bindings for COM library.
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include <Python.h>
+#include "lib/com/com.h"
+
+static PyObject *py_get_class_object(PyObject *self, PyObject *args)
+{
+ char *s_clsid, *s_iid;
+ struct GUID clsid, iid;
+ struct IUnknown *object;
+
+ if (!PyArg_ParseTuple(args, "ss", &s_clsid, &s_iid))
+ return NULL;
+
+ status = GUID_from_string(s_clsid, &clsid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_FromNTSTATUS(status);
+ return NULL;
+ }
+
+ status = GUID_from_string(s_iid, &iid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_FromNTSTATUS(status);
+ return NULL;
+ }
+
+ error = com_get_class_object(ctx, &clsid, &iid, &object);
+ if (!W_ERROR_IS_OK(error)) {
+ PyErr_FromWERROR(error);
+ return NULL;
+ }
+
+ /* FIXME: Magic, integrate with stubs generated by pidl. */
+
+ return Py_None;
+}
+
+static struct PyMethodDef com_methods[] = {
+ { "get_class_object", (PyCFunction)py_get_class_object, METH_VARARGS, "S.get_class_object(clsid, iid) -> instance" },
+ { NULL },
+};
+
+void initcom(void)
+{
+ PyObject *m;
+
+ /* FIXME: Initialize COM context and attach it to m. */
+
+ m = Py_InitModule3("com", com_methods, "Simple COM implementation");
+ if (m == NULL)
+ return;
+}
diff --git a/source4/lib/com/rot.c b/source4/lib/com/rot.c
index 34a5671f5b..0180a92f1b 100644
--- a/source4/lib/com/rot.c
+++ b/source4/lib/com/rot.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
+#include "lib/com/com.h"
struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid)
{