mirror of
https://github.com/samba-team/samba.git
synced 2025-12-07 20:23:50 +03:00
Added startdocprinter and enddocprinter.
This commit is contained in:
@@ -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 }
|
||||
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user