diff options
author | Wojciech Polak <polak@gnu.org> | 2009-07-11 14:59:52 +0200 |
---|---|---|
committer | Wojciech Polak <polak@gnu.org> | 2009-07-11 14:59:52 +0200 |
commit | 181e0c84c1f0bd3d18bc39a9ac6df3c5dcedf3b5 (patch) | |
tree | 870a6799a1b10fb6e11b0b42bb0032fece5787ae /python/libmu_py | |
parent | 8ea94114b3242ab560db0aa6092354b2d327e527 (diff) | |
download | mailutils-181e0c84c1f0bd3d18bc39a9ac6df3c5dcedf3b5.tar.gz mailutils-181e0c84c1f0bd3d18bc39a9ac6df3c5dcedf3b5.tar.bz2 |
Add mailbox.get_uidls() to Python/C++.
* libmu_cpp/mailbox.cc (get_uidls): New method.
* python/libmu_py/mailbox.c (api_mailbox_get_uidls): New function.
* python/mailutils/mailbox.py (get_uidls): New method.
Diffstat (limited to 'python/libmu_py')
-rw-r--r-- | python/libmu_py/mailbox.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/python/libmu_py/mailbox.c b/python/libmu_py/mailbox.c index 8404c73b5..6874f81f6 100644 --- a/python/libmu_py/mailbox.c +++ b/python/libmu_py/mailbox.c @@ -264,6 +264,38 @@ api_mailbox_sync (PyObject *self, PyObject *args) return _ro (PyInt_FromLong (status)); } +static int +uidls_extractor (void *data, PyObject **dst) +{ + struct mu_uidl *uidl = (struct mu_uidl *)data; + + *dst = PyTuple_New (2); + PyTuple_SetItem (*dst, 0, PyInt_FromLong (uidl->msgno)); + PyTuple_SetItem (*dst, 1, PyString_FromString (uidl->uidl)); + return 0; +} + +static PyObject * +api_mailbox_get_uidls (PyObject *self, PyObject *args) +{ + int status; + PyMailbox *py_mbox; + PyObject *py_list; + mu_list_t c_list = NULL; + + if (!PyArg_ParseTuple (args, "O!", &PyMailboxType, &py_mbox)) + return NULL; + + status = mu_mailbox_get_uidls (py_mbox->mbox, &c_list); + + if (c_list) + py_list = mu_py_mulist_to_pylist (c_list, uidls_extractor); + else + py_list = PyTuple_New (0); + + return status_object (status, py_list); +} + static PyObject * api_mailbox_lock (PyObject *self, PyObject *args) { @@ -397,6 +429,9 @@ static PyMethodDef methods[] = { { "sync", (PyCFunction) api_mailbox_sync, METH_VARARGS, "" }, + { "get_uidls", (PyCFunction) api_mailbox_get_uidls, METH_VARARGS, + "" }, + { "lock", (PyCFunction) api_mailbox_lock, METH_VARARGS, "" }, |