2
OpenChange MAPI implementation.
4
Python interface to mapistore folder
6
Copyright (C) Julien Kerihuel 2011.
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include "pyopenchange/mapistore/pymapistore.h"
24
#include "gen_ndr/exchange.h"
26
static void py_MAPIStoreFolder_dealloc(PyObject *_self)
28
PyMAPIStoreFolderObject *self = (PyMAPIStoreFolderObject *)_self;
30
Py_DECREF(self->context);
34
static PyObject *py_MAPIStoreFolder_create_folder(PyMAPIStoreFolderObject *self, PyObject *args, PyObject *kwargs)
37
/* PyMAPIStoreFolderObject *folder; */
38
char *kwnames[] = { "name", "description", "foldertype", "flags" };
40
const char *desc = NULL;
41
uint16_t foldertype = FOLDER_GENERIC;
42
uint16_t flags = NONE;
45
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|shh", kwnames, &name, &desc, &foldertype, &flags)) {
49
/* Step 1. Check if the folder already exists */
50
ret = mapistore_folder_get_child_fid_by_name(self->context->mstore_ctx,
51
self->context->context_id,
52
self->context->folder_object,
54
if (ret == MAPISTORE_SUCCESS) {
55
if (flags != OPEN_IF_EXISTS) {
56
PyErr_MAPIStore_IS_ERR_RAISE(MAPISTORE_ERR_EXIST);
61
/* TODO: Complete the implementation */
66
static PyObject *py_MAPIStoreFolder_get_fid(PyMAPIStoreFolderObject *self, void *closure)
68
return PyLong_FromLongLong(self->fid);
71
static PyObject *py_MAPIStoreFolder_get_child_count(PyMAPIStoreFolderObject *self, PyObject *args, PyObject *kwargs)
74
enum mapistore_table_type table_type;
75
char *kwnames[] = { "table_type" };
78
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwnames, &table_type)) {
82
retval = mapistore_folder_get_child_count(self->context->mstore_ctx, self->context->context_id,
83
(self->folder_object ? self->folder_object :
84
self->context->folder_object), table_type, &RowCount);
85
if (retval != MAPISTORE_SUCCESS) {
86
return PyInt_FromLong(-1);
89
return PyInt_FromLong(RowCount);
92
static PyMethodDef mapistore_folder_methods[] = {
93
{ "create_folder", (PyCFunction)py_MAPIStoreFolder_create_folder, METH_VARARGS|METH_KEYWORDS },
94
{ "get_child_count", (PyCFunction)py_MAPIStoreFolder_get_child_count, METH_VARARGS|METH_KEYWORDS },
98
static PyGetSetDef mapistore_folder_getsetters[] = {
99
{ (char *)"fid", (getter)py_MAPIStoreFolder_get_fid, NULL, NULL },
103
PyTypeObject PyMAPIStoreFolder = {
104
PyObject_HEAD_INIT(NULL) 0,
105
.tp_name = "mapistore folder",
106
.tp_basicsize = sizeof (PyMAPIStoreFolderObject),
107
.tp_methods = mapistore_folder_methods,
108
.tp_getset = mapistore_folder_getsetters,
109
.tp_doc = "mapistore folder object",
110
.tp_dealloc = (destructor)py_MAPIStoreFolder_dealloc,
111
.tp_flags = Py_TPFLAGS_DEFAULT,