mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
Moved form related functions as methods in the policy handle object.
This commit is contained in:
@ -22,6 +22,7 @@
|
|||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "python/py_common.h"
|
#include "python/py_common.h"
|
||||||
#include "python/py_spoolss.h"
|
#include "python/py_spoolss.h"
|
||||||
|
#include "python/py_spoolss_forms.h"
|
||||||
|
|
||||||
/* Exceptions this module can raise */
|
/* Exceptions this module can raise */
|
||||||
|
|
||||||
@ -32,6 +33,35 @@ static void py_policy_hnd_dealloc(PyObject* self)
|
|||||||
PyObject_Del(self);
|
PyObject_Del(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static PyMethodDef spoolss_hnd_methods[] = {
|
||||||
|
|
||||||
|
/* Forms */
|
||||||
|
|
||||||
|
{ "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"Enumerate forms" },
|
||||||
|
|
||||||
|
{ "setform", spoolss_setform, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"Modify properties of a form" },
|
||||||
|
|
||||||
|
{ "addform", spoolss_addform, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"Insert a form" },
|
||||||
|
|
||||||
|
{ "getform", spoolss_getform, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"Fetch form properties" },
|
||||||
|
|
||||||
|
{ "deleteform", spoolss_deleteform, METH_VARARGS | METH_KEYWORDS,
|
||||||
|
"Delete a form" },
|
||||||
|
|
||||||
|
{ NULL }
|
||||||
|
|
||||||
|
};
|
||||||
|
static PyObject *py_policy_hnd_getattr(PyObject *self, char *attrname)
|
||||||
|
{
|
||||||
|
return Py_FindMethod(spoolss_hnd_methods, self, attrname);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *new_policy_hnd_object(struct cli_state *cli,
|
static PyObject *new_policy_hnd_object(struct cli_state *cli,
|
||||||
TALLOC_CTX *mem_ctx, POLICY_HND *pol)
|
TALLOC_CTX *mem_ctx, POLICY_HND *pol)
|
||||||
{
|
{
|
||||||
@ -54,7 +84,7 @@ PyTypeObject spoolss_policy_hnd_type = {
|
|||||||
0,
|
0,
|
||||||
py_policy_hnd_dealloc, /*tp_dealloc*/
|
py_policy_hnd_dealloc, /*tp_dealloc*/
|
||||||
0, /*tp_print*/
|
0, /*tp_print*/
|
||||||
0, /*tp_getattr*/
|
py_policy_hnd_getattr, /*tp_getattr*/
|
||||||
0, /*tp_setattr*/
|
0, /*tp_setattr*/
|
||||||
0, /*tp_compare*/
|
0, /*tp_compare*/
|
||||||
0, /*tp_repr*/
|
0, /*tp_repr*/
|
||||||
@ -1023,26 +1053,6 @@ static PyMethodDef spoolss_methods[] = {
|
|||||||
{ "enumprinters", spoolss_enumprinters, METH_VARARGS | METH_KEYWORDS,
|
{ "enumprinters", spoolss_enumprinters, METH_VARARGS | METH_KEYWORDS,
|
||||||
"Enumerate printers" },
|
"Enumerate printers" },
|
||||||
|
|
||||||
/* Forms */
|
|
||||||
|
|
||||||
{ "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS,
|
|
||||||
"Enumerate forms" },
|
|
||||||
|
|
||||||
{ "setform", spoolss_setform, METH_VARARGS | METH_KEYWORDS,
|
|
||||||
"Modify properties of a form" },
|
|
||||||
|
|
||||||
{ "addform", spoolss_addform, METH_VARARGS | METH_KEYWORDS,
|
|
||||||
"Insert a form" },
|
|
||||||
|
|
||||||
{ "getform", spoolss_getform, METH_VARARGS | METH_KEYWORDS,
|
|
||||||
"Fetch form properties" },
|
|
||||||
|
|
||||||
{ "deleteform", spoolss_deleteform, METH_VARARGS | METH_KEYWORDS,
|
|
||||||
"Delete a form" },
|
|
||||||
|
|
||||||
{ "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS,
|
|
||||||
"Delete a form" },
|
|
||||||
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1081,6 +1091,7 @@ static void const_init(PyObject *dict)
|
|||||||
for (tmp = spoolss_const_vals; tmp->name; tmp++) {
|
for (tmp = spoolss_const_vals; tmp->name; tmp++) {
|
||||||
obj = PyInt_FromLong(tmp->value);
|
obj = PyInt_FromLong(tmp->value);
|
||||||
PyDict_SetItemString(dict, tmp->name, obj);
|
PyDict_SetItemString(dict, tmp->name, obj);
|
||||||
|
Py_DECREF(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,23 +49,19 @@ struct pyconv py_FORM_1[] = {
|
|||||||
|
|
||||||
PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
PyObject *po;
|
spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
|
||||||
spoolss_policy_hnd_object *hnd;
|
|
||||||
WERROR werror;
|
WERROR werror;
|
||||||
PyObject *py_form;
|
PyObject *py_form;
|
||||||
FORM form;
|
FORM form;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
static char *kwlist[] = {"hnd", "form", "level", NULL};
|
static char *kwlist[] = {"form", "level", NULL};
|
||||||
|
|
||||||
/* Parse parameters */
|
/* Parse parameters */
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
args, kw, "O!O!|i", kwlist, &spoolss_policy_hnd_type, &po,
|
args, kw, "O!|i", kwlist, &PyDict_Type, &py_form, &level))
|
||||||
&PyDict_Type, &py_form, &level))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hnd = (spoolss_policy_hnd_object *)po;
|
|
||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
@ -105,25 +101,20 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
PyObject *po;
|
spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
|
||||||
spoolss_policy_hnd_object *hnd;
|
|
||||||
WERROR werror;
|
WERROR werror;
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
char *form_name;
|
char *form_name;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
static char *kwlist[] = {"hnd", "form_name", "level", NULL};
|
static char *kwlist[] = {"form_name", "level", NULL};
|
||||||
uint32 needed;
|
uint32 needed;
|
||||||
FORM_1 form;
|
FORM_1 form;
|
||||||
|
|
||||||
/* Parse parameters */
|
/* Parse parameters */
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "O!s|i", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s|i", kwlist, &form_name, &level))
|
||||||
&spoolss_policy_hnd_type, &po, &form_name,
|
|
||||||
&level))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hnd = (spoolss_policy_hnd_object *)po;
|
|
||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
werror = cli_spoolss_getform(hnd->cli, hnd->mem_ctx, 0, &needed,
|
werror = cli_spoolss_getform(hnd->cli, hnd->mem_ctx, 0, &needed,
|
||||||
@ -156,24 +147,20 @@ PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
PyObject *po;
|
spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
|
||||||
spoolss_policy_hnd_object *hnd;
|
|
||||||
WERROR werror;
|
WERROR werror;
|
||||||
PyObject *py_form;
|
PyObject *py_form;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
static char *kwlist[] = {"hnd", "form_name", "form", "level", NULL};
|
static char *kwlist[] = {"form_name", "form", "level", NULL};
|
||||||
char *form_name;
|
char *form_name;
|
||||||
FORM form;
|
FORM form;
|
||||||
|
|
||||||
/* Parse parameters */
|
/* Parse parameters */
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "O!sO!|i", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO!|i", kwlist,
|
||||||
&spoolss_policy_hnd_type, &po, &form_name,
|
&form_name, &PyDict_Type, &py_form, &level))
|
||||||
&PyDict_Type, &py_form, &level))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hnd = (spoolss_policy_hnd_object *)po;
|
|
||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
to_struct(&form, py_form, py_FORM);
|
to_struct(&form, py_form, py_FORM);
|
||||||
@ -197,22 +184,18 @@ PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
PyObject *po;
|
spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
|
||||||
spoolss_policy_hnd_object *hnd;
|
|
||||||
WERROR werror;
|
WERROR werror;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
static char *kwlist[] = {"hnd", "form_name", "level", NULL};
|
static char *kwlist[] = {"form_name", "level", NULL};
|
||||||
char *form_name;
|
char *form_name;
|
||||||
|
|
||||||
/* Parse parameters */
|
/* Parse parameters */
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
args, kw, "O!s|i", kwlist, &spoolss_policy_hnd_type, &po,
|
args, kw, "s|i", kwlist, &form_name, &level))
|
||||||
&form_name, &level))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hnd = (spoolss_policy_hnd_object *)po;
|
|
||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
werror = cli_spoolss_deleteform(
|
werror = cli_spoolss_deleteform(
|
||||||
@ -232,22 +215,19 @@ PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw)
|
PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
PyObject *po, *result;
|
PyObject *result;
|
||||||
spoolss_policy_hnd_object *hnd;
|
spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
|
||||||
WERROR werror;
|
WERROR werror;
|
||||||
uint32 level = 1, num_forms, needed, i;
|
uint32 level = 1, num_forms, needed, i;
|
||||||
static char *kwlist[] = {"hnd", "level", NULL};
|
static char *kwlist[] = {"level", NULL};
|
||||||
FORM_1 *forms;
|
FORM_1 *forms;
|
||||||
|
|
||||||
/* Parse parameters */
|
/* Parse parameters */
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
args, kw, "O!|i", kwlist, &spoolss_policy_hnd_type,
|
args, kw, "|i", kwlist, &level))
|
||||||
&po, &level))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
hnd = (spoolss_policy_hnd_object *)po;
|
|
||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
werror = cli_spoolss_enumforms(
|
werror = cli_spoolss_enumforms(
|
||||||
|
Reference in New Issue
Block a user