Added startdocprinter and enddocprinter.
authorTim Potter <tpot@samba.org>
Mon, 13 May 2002 01:55:04 +0000 (01:55 +0000)
committerTim Potter <tpot@samba.org>
Mon, 13 May 2002 01:55:04 +0000 (01:55 +0000)
source/python/py_spoolss.c
source/python/py_spoolss_jobs.c
source/python/py_spoolss_jobs_conv.c
source/python/py_spoolss_proto.h

index 323b3c3b6fe564f0fe074069dc7f8c528e3cd90a..a8372fd2134c82663bea1b9d46d3965dffa42549 100644 (file)
@@ -205,6 +205,14 @@ Set the form given by the dictionary argument.
            METH_VARARGS | METH_KEYWORDS,
           "Notify spooler that a page is about to be printed." },
 
+        { "startdocprinter", spoolss_startdocprinter, 
+           METH_VARARGS | METH_KEYWORDS,
+          "Notify spooler that a document is about to be printed." },
+
+        { "enddocprinter", spoolss_enddocprinter, 
+           METH_VARARGS | METH_KEYWORDS,
+          "Notify spooler that a document is about to be printed." },
+
        { NULL }
 
 };
index 2cab6c0b280b5b1226245c920b12638bcf7b4f34..3d2295b88e8bc295cb207b082fecd98117568315 100644 (file)
@@ -213,3 +213,139 @@ PyObject *spoolss_endpageprinter(PyObject *self, PyObject *args, PyObject *kw)
        Py_INCREF(Py_None);
        return Py_None;
 }
+
+/* Start doc printer.  This notifies the spooler that a document is about to be
+   printed on the specified printer. */
+
+PyObject *spoolss_startdocprinter(PyObject *self, PyObject *args, PyObject *kw)
+{
+       spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
+       WERROR werror;
+       static char *kwlist[] = { "document_info", NULL };
+       PyObject *doc_info, *obj;
+       uint32 level, jobid;
+       char *document_name = NULL, *output_file = NULL, *data_type = NULL;
+
+       /* Parse parameters */
+
+       if (!PyArg_ParseTupleAndKeywords(args, kw, "O!", kwlist,
+               &PyDict_Type, &doc_info))
+               return NULL;
+       
+       /* Check document_info parameter */
+
+       if ((obj = PyDict_GetItemString(doc_info, "level"))) {
+
+               if (!PyInt_Check(obj)) {
+                       PyErr_SetString(spoolss_error,
+                                       "level not an integer");
+                       return NULL;
+               }
+
+               level = PyInt_AsLong(obj);
+
+               /* Only level 1 supported by Samba! */
+
+               if (level != 1) {
+                       PyErr_SetString(spoolss_error,
+                                       "unsupported info level");
+                       return NULL;
+               }
+
+       } else {
+               PyErr_SetString(spoolss_error, "no info level present");
+               return NULL;
+       }
+
+       if ((obj = PyDict_GetItemString(doc_info, "document_name"))) {
+
+               if (!PyString_Check(obj) && obj != Py_None) {
+                       PyErr_SetString(spoolss_error,
+                                       "document_name not a string");
+                       return NULL;
+               }
+               
+               if (PyString_Check(obj))
+                       document_name = PyString_AsString(obj);
+
+       } else {
+               PyErr_SetString(spoolss_error, "no document_name present");
+               return NULL;
+       }
+
+       if ((obj = PyDict_GetItemString(doc_info, "output_file"))) {
+
+               if (!PyString_Check(obj) && obj != Py_None) {
+                       PyErr_SetString(spoolss_error,
+                                       "output_file not a string");
+                       return NULL;
+               }
+               
+               if (PyString_Check(obj))
+                       output_file = PyString_AsString(obj);
+
+       } else {
+               PyErr_SetString(spoolss_error, "no output_file present");
+               return NULL;
+       }
+
+       if ((obj = PyDict_GetItemString(doc_info, "data_type"))) {
+               
+               if (!PyString_Check(obj) && obj != Py_None) {
+                       PyErr_SetString(spoolss_error,
+                                       "data_type not a string");
+                       return NULL;
+               }
+
+               if (PyString_Check(obj))
+                       data_type = PyString_AsString(obj);
+
+       } else {
+               PyErr_SetString(spoolss_error, "no data_type present");
+               return NULL;
+       }
+
+       /* Call rpc function */
+       
+       werror = cli_spoolss_startdocprinter(
+               hnd->cli, hnd->mem_ctx, &hnd->pol, document_name,
+               output_file, data_type, &jobid);
+
+       if (!W_ERROR_IS_OK(werror)) {
+               PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
+               return NULL;
+       }
+       
+       /* The return value is zero for an error (where does the status
+          code come from now??) and the return value is the jobid
+          allocated for the new job. */
+
+       return Py_BuildValue("i", jobid);
+}
+
+/* End doc printer.  This notifies the spooler that a document has finished
+   being printed on the specified printer. */
+
+PyObject *spoolss_enddocprinter(PyObject *self, PyObject *args, PyObject *kw)
+{
+       spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
+       WERROR werror;
+       static char *kwlist[] = { NULL };
+
+       /* Parse parameters */
+
+       if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
+               return NULL;
+       
+       /* Call rpc function */
+       
+       werror = cli_spoolss_enddocprinter(hnd->cli, hnd->mem_ctx, &hnd->pol);
+
+       if (!W_ERROR_IS_OK(werror)) {
+               PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
+               return NULL;
+       }
+       
+       Py_INCREF(Py_None);
+       return Py_None;
+}
index 7db8a5c5afe02f2d73cd2398dc6203791d7eaa47..5ac36379ba391fd333569e1bc32cd423abc71407 100644 (file)
@@ -61,6 +61,13 @@ struct pyconv py_JOB_INFO_2[] = {
        { NULL }
 };
 
+struct pyconv py_DOC_INFO_1[] = {
+       { "document_name", PY_UNISTR, offsetof(DOC_INFO_1, docname) },
+       { "output_file", PY_UNISTR, offsetof(DOC_INFO_1, outputfile) },
+       { "data_type", PY_UNISTR, offsetof(DOC_INFO_1, datatype) },
+       { NULL }
+};
+
 BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info)
 {
        *dict = from_struct(info, py_JOB_INFO_1);
@@ -82,3 +89,16 @@ BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict)
 {
        return False;
 }
+
+BOOL py_from_DOC_INFO_1(PyObject **dict, DOC_INFO_1 *info)
+{
+       *dict = from_struct(info, py_DOC_INFO_1);
+       return True;
+}
+
+BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict)
+{
+       to_struct(info, dict, py_DOC_INFO_1);
+       return True;
+}
+
index bd540305515cd03aeaef5e3d82f2db0816d84d36..ae9abf53515754198405b89c8930128d0301915c 100644 (file)
@@ -52,6 +52,8 @@ PyObject *spoolss_setjob(PyObject *self, PyObject *args, PyObject *kw);
 PyObject *spoolss_getjob(PyObject *self, PyObject *args, PyObject *kw);
 PyObject *spoolss_startpageprinter(PyObject *self, PyObject *args, PyObject *kw);
 PyObject *spoolss_endpageprinter(PyObject *self, PyObject *args, PyObject *kw);
+PyObject *spoolss_startdocprinter(PyObject *self, PyObject *args, PyObject *kw);
+PyObject *spoolss_enddocprinter(PyObject *self, PyObject *args, PyObject *kw);
 
 /* The following definitions come from python/py_spoolss_jobs_conv.c  */
 
@@ -59,6 +61,8 @@ 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);
+BOOL py_from_DOC_INFO_1(PyObject **dict, DOC_INFO_1 *info);
+BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict);
 
 /* The following definitions come from python/py_spoolss_ports.c  */