summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2009-07-11 14:59:52 +0200
committerWojciech Polak <polak@gnu.org>2009-07-11 14:59:52 +0200
commit181e0c84c1f0bd3d18bc39a9ac6df3c5dcedf3b5 (patch)
tree870a6799a1b10fb6e11b0b42bb0032fece5787ae /python
parent8ea94114b3242ab560db0aa6092354b2d327e527 (diff)
downloadmailutils-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')
-rw-r--r--python/libmu_py/mailbox.c35
-rw-r--r--python/mailutils/mailbox.py7
2 files changed, 42 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,
"" },
diff --git a/python/mailutils/mailbox.py b/python/mailutils/mailbox.py
index fff8cc5c6..a872d9a22 100644
--- a/python/mailutils/mailbox.py
+++ b/python/mailutils/mailbox.py
@@ -103,6 +103,13 @@ class MailboxBase:
if status:
raise MailboxError (status)
+ def get_uidls (self):
+ """Get UIDL list."""
+ status, uidls = mailbox.get_uidls (self.mbox)
+ if status:
+ raise MailboxError (status)
+ return uidls
+
def lock (self):
"""Lock the mailbox."""
status = mailbox.lock (self.mbox)

Return to:

Send suggestions and report system problems to the System administrator.