summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2010-04-08 17:34:49 +0200
committerWojciech Polak <polak@gnu.org>2010-04-08 17:34:49 +0200
commit1a374c8cbea21dabe2f7db123a559576531238db (patch)
tree9f73937ae604b2ba5ea090a54422953254187847 /python
parentd8ab03b03566831cb5dfe8caf4a1e1b77106a342 (diff)
downloadmailutils-1a374c8cbea21dabe2f7db123a559576531238db.tar.gz
mailutils-1a374c8cbea21dabe2f7db123a559576531238db.tar.bz2
Reflect recent RFC compatibility changes in Python/C++.
* examples/python/mimetest.py: Update. * include/mailutils/cpp/message.h (get_attachment_name): Overload. * libmu_cpp/message.cc (Message::get_attachment_name): Overload. * python/libmu_py/message.c (api_message_get_attachment_name): Update. * python/mailutils/message.py (Message.get_attachment_name): Add optional charset parameter. Return (name, lang) tuple.
Diffstat (limited to 'python')
-rw-r--r--python/libmu_py/message.c20
-rw-r--r--python/mailutils/message.py6
2 files changed, 16 insertions, 10 deletions
diff --git a/python/libmu_py/message.c b/python/libmu_py/message.c
index fc71cbf0e..58f9c5bae 100644
--- a/python/libmu_py/message.c
+++ b/python/libmu_py/message.c
@@ -282,14 +282,22 @@ api_message_get_attachment_name (PyObject *self, PyObject *args)
{
int status;
char *name = NULL;
+ char *charset = NULL;
+ char *lang = NULL;
+ PyObject *py_ret;
PyMessage *py_msg;
- if (!PyArg_ParseTuple (args, "O!", &PyMessageType, &py_msg))
+ if (!PyArg_ParseTuple (args, "O!|z", &PyMessageType, &py_msg, &charset))
return NULL;
- /* FIXME: CS/Lang info is ignored */
- status = mu_message_aget_attachment_name (py_msg->msg, &name, NULL);
- return status_object (status, PyString_FromString (name ? name : ""));
+ status = mu_message_aget_decoded_attachment_name (py_msg->msg, charset,
+ &name, &lang);
+
+ py_ret = PyTuple_New (3);
+ PyTuple_SetItem (py_ret, 0, PyInt_FromLong (status));
+ PyTuple_SetItem (py_ret, 1, PyString_FromString (name ? name : ""));
+ PyTuple_SetItem (py_ret, 2, lang ? PyString_FromString (lang) : Py_None);
+ return _ro (py_ret);
}
static PyObject *
@@ -314,12 +322,10 @@ static PyObject *
api_message_unencapsulate (PyObject *self, PyObject *args)
{
int status;
- char *filename = NULL;
PyMessage *py_msg;
PyMessage *py_unen = PyMessage_NEW ();
- if (!PyArg_ParseTuple (args, "O!|s", &PyMessageType, &py_msg,
- &filename))
+ if (!PyArg_ParseTuple (args, "O!", &PyMessageType, &py_msg))
return NULL;
Py_INCREF (py_unen);
diff --git a/python/mailutils/message.py b/python/mailutils/message.py
index 0f4744a78..89aa984d4 100644
--- a/python/mailutils/message.py
+++ b/python/mailutils/message.py
@@ -138,11 +138,11 @@ class Message:
raise MessageError (status)
return uidl
- def get_attachment_name (self):
- status, name = message.get_attachment_name (self.msg)
+ def get_attachment_name (self, charset=None):
+ status, name, lang = message.get_attachment_name (self.msg, charset)
if status:
raise MessageError (status)
- return name
+ return name, lang
def save_attachment (self, filename = ''):
status = message.save_attachment (self.msg, filename)

Return to:

Send suggestions and report system problems to the System administrator.