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

« back to all changes in this revision

Viewing changes to pyopenchange/pymapistore_module.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
 
   Python interface to mapistore
5
 
 
6
 
   Copyright (C) Julien Kerihuel 2010-2011.
7
 
 
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.
12
 
   
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.
17
 
   
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/>.
20
 
*/
21
 
 
22
 
#include <Python.h>
23
 
#include "pyopenchange/pymapistore.h"
24
 
#include "pyopenchange/pymapi.h"
25
 
 
26
 
void initmapistore(void);
27
 
 
28
 
static PyObject *py_mapistore_set_mapping_path(PyObject *mod, PyObject *args)
29
 
{
30
 
        const char      *mapping_path;
31
 
        
32
 
        if (!PyArg_ParseTuple(args, "s", &mapping_path)) {
33
 
                return NULL;
34
 
        }
35
 
 
36
 
        return PyInt_FromLong(mapistore_set_mapping_path(mapping_path));
37
 
}
38
 
 
39
 
static PyObject *py_mapistore_set_database_path(PyObject *mod, PyObject *args)
40
 
{
41
 
        const char      *db_path;
42
 
        
43
 
        if (!PyArg_ParseTuple(args, "s", &db_path)) {
44
 
                return NULL;
45
 
        }
46
 
 
47
 
        return PyInt_FromLong(mapistore_set_database_path(db_path));
48
 
}
49
 
 
50
 
static PyObject *py_mapistore_set_named_properties_database_path(PyObject *mod, PyObject *args)
51
 
{
52
 
        const char      *db_path;
53
 
        
54
 
        if (!PyArg_ParseTuple(args, "s", &db_path)) {
55
 
                return NULL;
56
 
        }
57
 
 
58
 
        return PyInt_FromLong(mapistore_set_named_properties_database_path(db_path));
59
 
}
60
 
 
61
 
static PyObject *py_mapistore_errstr(PyObject *mod, PyObject *args)
62
 
{
63
 
        int             ret;
64
 
 
65
 
        if (!PyArg_ParseTuple(args, "k", &ret)) {
66
 
                return NULL;
67
 
        }
68
 
 
69
 
        return PyString_FromString(mapistore_errstr(ret));
70
 
}
71
 
 
72
 
static PyMethodDef py_mapistore_global_methods[] = {
73
 
        { "set_mapping_path", (PyCFunction)py_mapistore_set_mapping_path, METH_VARARGS },
74
 
        { "set_database_path", (PyCFunction)py_mapistore_set_database_path, METH_VARARGS },
75
 
        { "set_named_properties_database_path", (PyCFunction)py_mapistore_set_named_properties_database_path, METH_VARARGS },
76
 
        { "errstr", (PyCFunction)py_mapistore_errstr, METH_VARARGS },
77
 
        { NULL },
78
 
};
79
 
 
80
 
void initmapistore(void)
81
 
{
82
 
        PyObject        *m;
83
 
 
84
 
        if (PyType_Ready(&PyMAPIStore) < 0) {
85
 
                return;
86
 
        }
87
 
 
88
 
        if (PyType_Ready(&PyMAPIStoreFolder) < 0) {
89
 
                return;
90
 
        }
91
 
 
92
 
        m = Py_InitModule3("mapistore", py_mapistore_global_methods,
93
 
                           "An interface to OpenChange MAPIStore");
94
 
        if (m == NULL) {
95
 
                return;
96
 
        }
97
 
 
98
 
        PyModule_AddObject(m, "MDB_ROOT_FOLDER", PyInt_FromLong((int)MDB_ROOT_FOLDER));
99
 
        PyModule_AddObject(m, "MDB_DEFERRED_ACTIONS", PyInt_FromLong((int)MDB_DEFERRED_ACTIONS));
100
 
        PyModule_AddObject(m, "MDB_SPOOLER_QUEUE", PyInt_FromLong((int)MDB_SPOOLER_QUEUE));
101
 
        PyModule_AddObject(m, "MDB_TODO_SEARCH", PyInt_FromLong((int)MDB_TODO_SEARCH));
102
 
        PyModule_AddObject(m, "MDB_IPM_SUBTREE", PyInt_FromLong((int)MDB_IPM_SUBTREE));
103
 
        PyModule_AddObject(m, "MDB_INBOX", PyInt_FromLong((int)MDB_INBOX));
104
 
        PyModule_AddObject(m, "MDB_OUTBOX", PyInt_FromLong((int)MDB_OUTBOX));
105
 
        PyModule_AddObject(m, "MDB_SENT_ITEMS", PyInt_FromLong((int)MDB_SENT_ITEMS));
106
 
        PyModule_AddObject(m, "MDB_DELETED_ITEMS", PyInt_FromLong((int)MDB_DELETED_ITEMS));
107
 
        PyModule_AddObject(m, "MDB_COMMON_VIEWS", PyInt_FromLong((int)MDB_COMMON_VIEWS));
108
 
        PyModule_AddObject(m, "MDB_SCHEDULE", PyInt_FromLong((int)MDB_SCHEDULE));
109
 
        PyModule_AddObject(m, "MDB_SEARCH", PyInt_FromLong((int)MDB_SEARCH));
110
 
        PyModule_AddObject(m, "MDB_VIEWS", PyInt_FromLong((int)MDB_VIEWS));
111
 
        PyModule_AddObject(m, "MDB_SHORTCUTS", PyInt_FromLong((int)MDB_SHORTCUTS));
112
 
        PyModule_AddObject(m, "MDB_REMINDERS", PyInt_FromLong((int)MDB_REMINDERS));
113
 
        PyModule_AddObject(m, "MDB_CALENDAR", PyInt_FromLong((int)MDB_CALENDAR));
114
 
        PyModule_AddObject(m, "MDB_CONTACTS", PyInt_FromLong((int)MDB_CONTACTS));
115
 
        PyModule_AddObject(m, "MDB_JOURNAL", PyInt_FromLong((int)MDB_JOURNAL));
116
 
        PyModule_AddObject(m, "MDB_NOTES", PyInt_FromLong((int)MDB_NOTES));
117
 
        PyModule_AddObject(m, "MDB_TASKS", PyInt_FromLong((int)MDB_TASKS));
118
 
        PyModule_AddObject(m, "MDB_DRAFTS", PyInt_FromLong((int)MDB_DRAFTS));
119
 
        PyModule_AddObject(m, "MDB_TRACKED_MAIL", PyInt_FromLong((int)MDB_TRACKED_MAIL));
120
 
        PyModule_AddObject(m, "MDB_SYNC_ISSUES", PyInt_FromLong((int)MDB_SYNC_ISSUES));
121
 
        PyModule_AddObject(m, "MDB_CONFLICTS", PyInt_FromLong((int)MDB_CONFLICTS));
122
 
        PyModule_AddObject(m, "MDB_LOCAL_FAILURES", PyInt_FromLong((int)MDB_LOCAL_FAILURES));
123
 
        PyModule_AddObject(m, "MDB_SERVER_FAILURES", PyInt_FromLong((int)MDB_SERVER_FAILURES));
124
 
        PyModule_AddObject(m, "MDB_JUNK_EMAIL", PyInt_FromLong((int)MDB_JUNK_EMAIL));
125
 
        PyModule_AddObject(m, "MDB_RSS_FEEDS", PyInt_FromLong((int)MDB_RSS_FEEDS));
126
 
        PyModule_AddObject(m, "MDB_CONVERSATION_ACT", PyInt_FromLong((int)MDB_CONVERSATION_ACT));
127
 
        PyModule_AddObject(m, "MDB_LAST_SPECIALFOLDER", PyInt_FromLong((int)MDB_LAST_SPECIALFOLDER));
128
 
        PyModule_AddObject(m, "MDB_CUSTOM", PyInt_FromLong((int)MDB_CUSTOM));
129
 
 
130
 
        PyModule_AddObject(m, "DEL_MESSAGES", PyInt_FromLong(0x1));
131
 
        PyModule_AddObject(m, "DEL_FOLDERS", PyInt_FromLong(0x4));
132
 
        PyModule_AddObject(m, "DELETE_HARD_DELETE", PyInt_FromLong(0x10));
133
 
 
134
 
        PyModule_AddObject(m, "MAPISTORE_FOLDER", PyInt_FromLong(MAPISTORE_FOLDER));
135
 
        PyModule_AddObject(m, "MAPISTORE_MESSAGE", PyInt_FromLong(MAPISTORE_MESSAGE));
136
 
 
137
 
        PyModule_AddObject(m, "FOLDER_GENERIC", PyInt_FromLong(FOLDER_GENERIC));
138
 
        PyModule_AddObject(m, "FOLDER_SEARCH", PyInt_FromLong(FOLDER_SEARCH));
139
 
 
140
 
        Py_INCREF(&PyMAPIStore);
141
 
        PyModule_AddObject(m, "mapistore", (PyObject *)&PyMAPIStore);
142
 
 
143
 
        Py_INCREF((PyObject *)&PyMAPIStoreFolder);
144
 
        PyModule_AddObject(m, "Folder", (PyObject *)&PyMAPIStoreFolder);
145
 
}