diff options
-rw-r--r-- | source3/python/py_spoolss.c | 5 | ||||
-rw-r--r-- | source3/python/py_spoolss_jobs.c | 86 | ||||
-rw-r--r-- | source3/python/py_spoolss_jobs_conv.c | 84 | ||||
-rw-r--r-- | source3/python/py_spoolss_proto.h | 11 | ||||
-rw-r--r-- | source3/python/samba-head.patch | 21 | ||||
-rwxr-xr-x | source3/python/setup.py.in | 2 |
6 files changed, 199 insertions, 10 deletions
diff --git a/source3/python/py_spoolss.c b/source3/python/py_spoolss.c index e1d6d47345..b1c70f9d4e 100644 --- a/source3/python/py_spoolss.c +++ b/source3/python/py_spoolss.c @@ -186,6 +186,11 @@ Set the form given by the dictionary argument. { "deleteform", spoolss_deleteform, METH_VARARGS | METH_KEYWORDS, "Delete a form" }, + /* Job related methods */ + + { "enumjobs", spoolss_enumjobs, METH_VARARGS | METH_KEYWORDS, + "Enumerate jobs" }, + { NULL } }; diff --git a/source3/python/py_spoolss_jobs.c b/source3/python/py_spoolss_jobs.c new file mode 100644 index 0000000000..e049d82a33 --- /dev/null +++ b/source3/python/py_spoolss_jobs.c @@ -0,0 +1,86 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 2002 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "python/py_spoolss.h" + +/* Enumerate jobs */ + +PyObject *spoolss_enumjobs(PyObject *self, PyObject *args, PyObject *kw) +{ + spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; + WERROR werror; + PyObject *result; + int level = 1; + uint32 i, needed, num_jobs; + static char *kwlist[] = {"level", NULL}; + JOB_INFO_CTR ctr; + + /* Parse parameters */ + + if (!PyArg_ParseTupleAndKeywords(args, kw, "|i", kwlist, &level)) + return NULL; + + /* Call rpc function */ + + werror = cli_spoolss_enumjobs( + hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, level, 0, + 1000, &num_jobs, &ctr); + + if (W_ERROR_V(werror) == ERRinsufficientbuffer) + werror = cli_spoolss_enumjobs( + hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol, + level, 0, 1000, &num_jobs, &ctr); + + /* Return value */ + + result = Py_None; + + if (!W_ERROR_IS_OK(werror)) + goto done; + + result = PyList_New(num_jobs); + + switch (level) { + case 1: + for (i = 0; i < num_jobs; i++) { + PyObject *value; + + py_from_JOB_INFO_1(&value, &ctr.job.job_info_1[i]); + + PyList_SetItem(result, i, value); + } + + break; + case 2: + for(i = 0; i < num_jobs; i++) { + PyObject *value; + + py_from_JOB_INFO_2(&value, &ctr.job.job_info_2[i]); + + PyList_SetItem(result, i, value); + } + + break; + } + + done: + Py_INCREF(result); + return result; +} diff --git a/source3/python/py_spoolss_jobs_conv.c b/source3/python/py_spoolss_jobs_conv.c new file mode 100644 index 0000000000..7db8a5c5af --- /dev/null +++ b/source3/python/py_spoolss_jobs_conv.c @@ -0,0 +1,84 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 2002 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "python/py_spoolss.h" +#include "python/py_conv.h" + +struct pyconv py_JOB_INFO_1[] = { + { "jobid", PY_UINT32, offsetof(JOB_INFO_1, jobid) }, + { "printer_name", PY_UNISTR, offsetof(JOB_INFO_1, printername) }, + { "server_name", PY_UNISTR, offsetof(JOB_INFO_1, machinename) }, + { "user_name", PY_UNISTR, offsetof(JOB_INFO_1, username) }, + { "document_name", PY_UNISTR, offsetof(JOB_INFO_1, document) }, + { "data_type", PY_UNISTR, offsetof(JOB_INFO_1, datatype) }, + { "text_status", PY_UNISTR, offsetof(JOB_INFO_1, text_status) }, + { "status", PY_UINT32, offsetof(JOB_INFO_1, status) }, + { "priority", PY_UINT32, offsetof(JOB_INFO_1, priority) }, + { "position", PY_UINT32, offsetof(JOB_INFO_1, position) }, + { "total_pages", PY_UINT32, offsetof(JOB_INFO_1, totalpages) }, + { "pages_printed", PY_UINT32, offsetof(JOB_INFO_1, pagesprinted) }, + { NULL } +}; + +struct pyconv py_JOB_INFO_2[] = { + { "jobid", PY_UINT32, offsetof(JOB_INFO_2, jobid) }, + { "printer_name", PY_UNISTR, offsetof(JOB_INFO_2, printername) }, + { "server_name", PY_UNISTR, offsetof(JOB_INFO_2, machinename) }, + { "user_name", PY_UNISTR, offsetof(JOB_INFO_2, username) }, + { "document_name", PY_UNISTR, offsetof(JOB_INFO_2, document) }, + { "notify_name", PY_UNISTR, offsetof(JOB_INFO_2, notifyname) }, + { "data_type", PY_UNISTR, offsetof(JOB_INFO_2, datatype) }, + { "print_processor", PY_UNISTR, offsetof(JOB_INFO_2, printprocessor) }, + { "parameters", PY_UNISTR, offsetof(JOB_INFO_2, parameters) }, + { "driver_name", PY_UNISTR, offsetof(JOB_INFO_2, drivername) }, + { "text_status", PY_UNISTR, offsetof(JOB_INFO_2, text_status) }, + { "status", PY_UINT32, offsetof(JOB_INFO_2, status) }, + { "priority", PY_UINT32, offsetof(JOB_INFO_2, priority) }, + { "position", PY_UINT32, offsetof(JOB_INFO_2, position) }, + { "start_time", PY_UINT32, offsetof(JOB_INFO_2, starttime) }, + { "until_time", PY_UINT32, offsetof(JOB_INFO_2, untiltime) }, + { "total_pages", PY_UINT32, offsetof(JOB_INFO_2, totalpages) }, + { "size", PY_UINT32, offsetof(JOB_INFO_2, size) }, + { "time_elapsed", PY_UINT32, offsetof(JOB_INFO_2, timeelapsed) }, + { "pages_printed", PY_UINT32, offsetof(JOB_INFO_2, pagesprinted) }, + { NULL } +}; + +BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info) +{ + *dict = from_struct(info, py_JOB_INFO_1); + return True; +} + +BOOL py_to_JOB_INFO_1(JOB_INFO_1 *info, PyObject *dict) +{ + return False; +} + +BOOL py_from_JOB_INFO_2(PyObject **dict, JOB_INFO_2 *info) +{ + *dict = from_struct(info, py_JOB_INFO_2); + return True; +} + +BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict) +{ + return False; +} diff --git a/source3/python/py_spoolss_proto.h b/source3/python/py_spoolss_proto.h index 00118aae7d..81d34a2c2d 100644 --- a/source3/python/py_spoolss_proto.h +++ b/source3/python/py_spoolss_proto.h @@ -45,6 +45,17 @@ PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw); BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form); BOOL py_to_FORM(FORM *form, PyObject *dict); +/* The following definitions come from python/py_spoolss_jobs.c */ + +PyObject *spoolss_enumjobs(PyObject *self, PyObject *args, PyObject *kw); + +/* The following definitions come from python/py_spoolss_jobs_conv.c */ + +BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info); +BOOL py_to_JOB_INFO_1(JOB_INFO_1 *info, PyObject *dict); +BOOL py_from_JOB_INFO_2(PyObject **dict, JOB_INFO_2 *info); +BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict); + /* The following definitions come from python/py_spoolss_ports.c */ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw); diff --git a/source3/python/samba-head.patch b/source3/python/samba-head.patch index c8089934b8..59d2a25ae4 100644 --- a/source3/python/samba-head.patch +++ b/source3/python/samba-head.patch @@ -1,11 +1,11 @@ Index: Makefile.in =================================================================== RCS file: /data/cvs/samba/source/Makefile.in,v -retrieving revision 1.470 -diff -u -r1.470 Makefile.in ---- Makefile.in 2002/04/13 11:45:33 1.470 -+++ Makefile.in 2002/04/18 03:34:05 -@@ -787,6 +787,43 @@ +retrieving revision 1.473 +diff -u -r1.473 Makefile.in +--- Makefile.in 2002/04/30 05:44:25 1.473 ++++ Makefile.in 2002/05/07 07:02:43 +@@ -788,6 +788,44 @@ -$(INSTALLCMD) -d ${prefix}/include -$(INSTALLCMD) include/libsmbclient.h ${prefix}/include @@ -19,6 +19,7 @@ diff -u -r1.470 Makefile.in + python/py_spoolss_forms.o python/py_spoolss_forms_conv.o \ + python/py_spoolss_ports.o python/py_spoolss_ports_conv.o \ + python/py_spoolss_drivers.o python/py_spoolss_drivers_conv.o \ ++ python/py_spoolss_jobs.o python/py_spoolss_jobs_conv.o + +PY_LSA_PROTO_OBJ = python/py_lsa.o + @@ -52,11 +53,11 @@ diff -u -r1.470 Makefile.in Index: configure.in =================================================================== RCS file: /data/cvs/samba/source/configure.in,v -retrieving revision 1.300 -diff -u -r1.300 configure.in ---- configure.in 2002/04/11 15:26:58 1.300 -+++ configure.in 2002/04/18 03:34:05 -@@ -2716,7 +2716,7 @@ +retrieving revision 1.302 +diff -u -r1.302 configure.in +--- configure.in 2002/04/24 11:42:46 1.302 ++++ configure.in 2002/05/07 07:02:44 +@@ -2720,7 +2720,7 @@ builddir=`pwd` AC_SUBST(builddir) diff --git a/source3/python/setup.py.in b/source3/python/setup.py.in index 6bc568fa1d..2e0e5def9d 100755 --- a/source3/python/setup.py.in +++ b/source3/python/setup.py.in @@ -96,6 +96,8 @@ setup( samba_srcdir + "python/py_spoolss_printers_conv.c", samba_srcdir + "python/py_spoolss_ports.c", samba_srcdir + "python/py_spoolss_ports_conv.c", + samba_srcdir + "python/py_spoolss_jobs.c", + samba_srcdir + "python/py_spoolss_jobs_conv.c", ], libraries = lib_list, library_dirs = ["/usr/kerberos/lib"], |