~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to pymapi/pymapi.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
   OpenChange MAPI implementation.
3
 
 
4
 
   Copyright (C) Jelmer Vernooij <jelmer@openchange.org> 2008.
5
 
 
6
 
   This program is free software; you can redistribute it and/or modify
7
 
   it under the terms of the GNU General Public License as published by
8
 
   the Free Software Foundation; either version 3 of the License, or
9
 
   (at your option) any later version.
10
 
   
11
 
   This program is distributed in the hope that it will be useful,
12
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
   GNU General Public License for more details.
15
 
   
16
 
   You should have received a copy of the GNU General Public License
17
 
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 */
19
 
 
20
 
#include "pymapi/pymapi.h"
21
 
 
22
 
void initmapi(void);
23
 
 
24
 
static PyObject *py_get_proptag_value(PyObject *mod, PyObject *args)
25
 
{
26
 
        char *propname;
27
 
        if (!PyArg_ParseTuple(args, "s", &propname))
28
 
                return NULL;
29
 
 
30
 
        return PyInt_FromLong(get_proptag_value(propname));
31
 
}
32
 
 
33
 
static PyObject *py_get_proptag_name(PyObject *mod, PyObject *args)
34
 
{
35
 
        uint32_t proptag;
36
 
        const char *name;
37
 
        if (!PyArg_ParseTuple(args, "i", &proptag))
38
 
                return NULL;
39
 
 
40
 
        name = get_proptag_name(proptag);
41
 
        if (name == NULL)
42
 
                return Py_None;
43
 
        return PyString_FromString(name);
44
 
}
45
 
 
46
 
static PyObject *py_get_importance(PyObject *mod, PyObject *args)
47
 
{
48
 
        uint32_t importance;
49
 
        const char *name;
50
 
        if (!PyArg_ParseTuple(args, "i", &importance))
51
 
                return NULL;
52
 
 
53
 
        name = get_importance(importance);
54
 
        if (name == NULL)
55
 
                return Py_None;
56
 
        return PyString_FromString(name);
57
 
}
58
 
 
59
 
static PyObject *py_get_task_status(PyObject *mod, PyObject *args)
60
 
{
61
 
        uint32_t task_status;
62
 
        const char *name;
63
 
        if (!PyArg_ParseTuple(args, "i", &task_status))
64
 
                return NULL;
65
 
 
66
 
        name = get_task_status(task_status);
67
 
        if (name == NULL)
68
 
                return Py_None;
69
 
        return PyString_FromString(name);
70
 
}
71
 
 
72
 
static PyMethodDef mapi_methods[] = {
73
 
        { "get_proptag_value", (PyCFunction)py_get_proptag_value, METH_VARARGS, NULL },
74
 
        { "get_proptag_name", (PyCFunction)py_get_proptag_name, METH_VARARGS, NULL },
75
 
        { "get_importance", (PyCFunction)py_get_importance, METH_VARARGS, NULL },
76
 
        { "get_task_status", (PyCFunction)py_get_task_status, METH_VARARGS, NULL },
77
 
        { NULL }
78
 
};
79
 
 
80
 
void initmapi(void)
81
 
{
82
 
        PyObject *m;
83
 
 
84
 
        if (PyType_Ready(&PyMapiSessionType) < 0)
85
 
                return;
86
 
 
87
 
        if (PyType_Ready(&PyMapiObjectType) < 0)
88
 
                return;
89
 
 
90
 
        if (PyType_Ready(&PyMapiMsgStoreType) < 0)
91
 
                return;
92
 
 
93
 
        m = Py_InitModule3("mapi", mapi_methods, "MAPI/RPC Python bindings");
94
 
        if (m == NULL)
95
 
                return;
96
 
 
97
 
        Py_INCREF((PyObject *)&PyMapiSessionType);
98
 
        PyModule_AddObject(m, "Session", (PyObject *)&PyMapiSessionType);
99
 
 
100
 
        Py_INCREF((PyObject *)&PyMapiObjectType);
101
 
        PyModule_AddObject(m, "Object", (PyObject *)&PyMapiObjectType);
102
 
 
103
 
        Py_INCREF((PyObject *)&PyMapiMsgStoreType);
104
 
        PyModule_AddObject(m, "MessageStore", (PyObject *)&PyMapiMsgStoreType);
105
 
}