00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "python/py_spoolss.h"
00022
00023
00024
00025 PyObject *spoolss_hnd_enumjobs(PyObject *self, PyObject *args, PyObject *kw)
00026 {
00027 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00028 WERROR werror;
00029 PyObject *result;
00030 int level = 1;
00031 uint32 i, num_jobs;
00032 static char *kwlist[] = {"level", NULL};
00033 JOB_INFO_CTR ctr;
00034
00035
00036
00037 if (!PyArg_ParseTupleAndKeywords(args, kw, "|i", kwlist, &level))
00038 return NULL;
00039
00040
00041
00042 werror = rpccli_spoolss_enumjobs(
00043 hnd->cli, hnd->mem_ctx, &hnd->pol, level, 0, 1000,
00044 &num_jobs, &ctr);
00045
00046
00047
00048 result = Py_None;
00049
00050 if (!W_ERROR_IS_OK(werror)) {
00051 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00052 goto done;
00053 }
00054
00055 result = PyList_New(num_jobs);
00056
00057 switch (level) {
00058 case 1:
00059 for (i = 0; i < num_jobs; i++) {
00060 PyObject *value;
00061
00062 py_from_JOB_INFO_1(&value, &ctr.job.job_info_1[i]);
00063
00064 PyList_SetItem(result, i, value);
00065 }
00066
00067 break;
00068 case 2:
00069 for(i = 0; i < num_jobs; i++) {
00070 PyObject *value;
00071
00072 py_from_JOB_INFO_2(&value, &ctr.job.job_info_2[i]);
00073
00074 PyList_SetItem(result, i, value);
00075 }
00076
00077 break;
00078 }
00079
00080 done:
00081 Py_INCREF(result);
00082 return result;
00083 }
00084
00085
00086
00087 PyObject *spoolss_hnd_setjob(PyObject *self, PyObject *args, PyObject *kw)
00088 {
00089 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00090 WERROR werror;
00091 uint32 level = 0, command, jobid;
00092 static char *kwlist[] = {"jobid", "command", "level", NULL};
00093
00094
00095
00096 if (!PyArg_ParseTupleAndKeywords(
00097 args, kw, "ii|i", kwlist, &jobid, &command, &level))
00098 return NULL;
00099
00100
00101
00102 werror = rpccli_spoolss_setjob(
00103 hnd->cli, hnd->mem_ctx, &hnd->pol, jobid, level, command);
00104
00105 if (!W_ERROR_IS_OK(werror)) {
00106 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00107 return NULL;
00108 }
00109
00110 Py_INCREF(Py_None);
00111 return Py_None;
00112 }
00113
00114
00115
00116 PyObject *spoolss_hnd_getjob(PyObject *self, PyObject *args, PyObject *kw)
00117 {
00118 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00119 WERROR werror;
00120 PyObject *result;
00121 uint32 level = 1, jobid;
00122 static char *kwlist[] = {"jobid", "level", NULL};
00123 JOB_INFO_CTR ctr;
00124
00125
00126
00127 if (!PyArg_ParseTupleAndKeywords(
00128 args, kw, "i|i", kwlist, &jobid, &level))
00129 return NULL;
00130
00131
00132
00133 werror = rpccli_spoolss_getjob(
00134 hnd->cli, hnd->mem_ctx, &hnd->pol, jobid, level, &ctr);
00135
00136 if (!W_ERROR_IS_OK(werror)) {
00137 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00138 return NULL;
00139 }
00140
00141 switch(level) {
00142 case 1:
00143 py_from_JOB_INFO_1(&result, &ctr.job.job_info_1[0]);
00144 break;
00145 case 2:
00146 py_from_JOB_INFO_2(&result, &ctr.job.job_info_2[0]);
00147 break;
00148 }
00149
00150 return result;
00151 }
00152
00153
00154
00155
00156 PyObject *spoolss_hnd_startpageprinter(PyObject *self, PyObject *args, PyObject *kw)
00157 {
00158 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00159 WERROR werror;
00160 static char *kwlist[] = { NULL };
00161
00162
00163
00164 if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
00165 return NULL;
00166
00167
00168
00169 werror = rpccli_spoolss_startpageprinter(
00170 hnd->cli, hnd->mem_ctx, &hnd->pol);
00171
00172 if (!W_ERROR_IS_OK(werror)) {
00173 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00174 return NULL;
00175 }
00176
00177 Py_INCREF(Py_None);
00178 return Py_None;
00179 }
00180
00181
00182
00183
00184 PyObject *spoolss_hnd_endpageprinter(PyObject *self, PyObject *args, PyObject *kw)
00185 {
00186 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00187 WERROR werror;
00188 static char *kwlist[] = { NULL };
00189
00190
00191
00192 if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
00193 return NULL;
00194
00195
00196
00197 werror = rpccli_spoolss_endpageprinter(
00198 hnd->cli, hnd->mem_ctx, &hnd->pol);
00199
00200 if (!W_ERROR_IS_OK(werror)) {
00201 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00202 return NULL;
00203 }
00204
00205 Py_INCREF(Py_None);
00206 return Py_None;
00207 }
00208
00209
00210
00211
00212 PyObject *spoolss_hnd_startdocprinter(PyObject *self, PyObject *args, PyObject *kw)
00213 {
00214 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00215 WERROR werror;
00216 static char *kwlist[] = { "document_info", NULL };
00217 PyObject *info, *obj;
00218 uint32 level, jobid;
00219 char *document_name = NULL, *output_file = NULL, *data_type = NULL;
00220
00221
00222
00223 if (!PyArg_ParseTupleAndKeywords(
00224 args, kw, "O!", kwlist, &PyDict_Type, &info))
00225 return NULL;
00226
00227
00228
00229 if (!get_level_value(info, &level)) {
00230 PyErr_SetString(spoolss_error, "invalid info level");
00231 return NULL;
00232 }
00233
00234 if (level != 1) {
00235 PyErr_SetString(spoolss_error, "unsupported info level");
00236 return NULL;
00237 }
00238
00239 if ((obj = PyDict_GetItemString(info, "document_name"))) {
00240
00241 if (!PyString_Check(obj) && obj != Py_None) {
00242 PyErr_SetString(spoolss_error,
00243 "document_name not a string");
00244 return NULL;
00245 }
00246
00247 if (PyString_Check(obj))
00248 document_name = PyString_AsString(obj);
00249
00250 } else {
00251 PyErr_SetString(spoolss_error, "no document_name present");
00252 return NULL;
00253 }
00254
00255 if ((obj = PyDict_GetItemString(info, "output_file"))) {
00256
00257 if (!PyString_Check(obj) && obj != Py_None) {
00258 PyErr_SetString(spoolss_error,
00259 "output_file not a string");
00260 return NULL;
00261 }
00262
00263 if (PyString_Check(obj))
00264 output_file = PyString_AsString(obj);
00265
00266 } else {
00267 PyErr_SetString(spoolss_error, "no output_file present");
00268 return NULL;
00269 }
00270
00271 if ((obj = PyDict_GetItemString(info, "data_type"))) {
00272
00273 if (!PyString_Check(obj) && obj != Py_None) {
00274 PyErr_SetString(spoolss_error,
00275 "data_type not a string");
00276 return NULL;
00277 }
00278
00279 if (PyString_Check(obj))
00280 data_type = PyString_AsString(obj);
00281
00282 } else {
00283 PyErr_SetString(spoolss_error, "no data_type present");
00284 return NULL;
00285 }
00286
00287
00288
00289 werror = rpccli_spoolss_startdocprinter(
00290 hnd->cli, hnd->mem_ctx, &hnd->pol, document_name,
00291 output_file, data_type, &jobid);
00292
00293 if (!W_ERROR_IS_OK(werror)) {
00294 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00295 return NULL;
00296 }
00297
00298
00299
00300
00301
00302 return Py_BuildValue("i", jobid);
00303 }
00304
00305
00306
00307
00308 PyObject *spoolss_hnd_enddocprinter(PyObject *self, PyObject *args, PyObject *kw)
00309 {
00310 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00311 WERROR werror;
00312 static char *kwlist[] = { NULL };
00313
00314
00315
00316 if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist))
00317 return NULL;
00318
00319
00320
00321 werror = rpccli_spoolss_enddocprinter(
00322 hnd->cli, hnd->mem_ctx, &hnd->pol);
00323
00324 if (!W_ERROR_IS_OK(werror)) {
00325 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00326 return NULL;
00327 }
00328
00329 Py_INCREF(Py_None);
00330 return Py_None;
00331 }
00332
00333
00334
00335 PyObject *spoolss_hnd_writeprinter(PyObject *self, PyObject *args, PyObject *kw)
00336 {
00337 spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
00338 WERROR werror;
00339 static char *kwlist[] = { "data", NULL };
00340 PyObject *data;
00341 uint32 num_written;
00342
00343
00344
00345 if (!PyArg_ParseTupleAndKeywords(
00346 args, kw, "O!", kwlist, &PyString_Type, &data))
00347 return NULL;
00348
00349
00350
00351 werror = rpccli_spoolss_writeprinter(
00352 hnd->cli, hnd->mem_ctx, &hnd->pol, PyString_Size(data),
00353 PyString_AsString(data), &num_written);
00354
00355 if (!W_ERROR_IS_OK(werror)) {
00356 PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
00357 return NULL;
00358 }
00359
00360 Py_INCREF(Py_None);
00361 return Py_None;
00362 }
00363
00364 PyObject *spoolss_hnd_addjob(PyObject *self, PyObject *args, PyObject *kw)
00365 {
00366 PyErr_SetString(spoolss_error, "Not implemented");
00367 return NULL;
00368 }