[Commits] [SCM] claws branch, master, updated. 3.9.2-65-g0fbf9f9
holger at claws-mail.org
holger at claws-mail.org
Thu Aug 8 23:37:40 CEST 2013
The branch master of project "claws" (Claws Mail) has been updated
via 0fbf9f9b9d79af5523eb8fe0c90970d897da6946 (commit)
via 7154ef9813b0a69edc4a2c7771fc78091a782e4f (commit)
via 710fd469103d9f7743eb2ae9fb454c368e95b9e8 (commit)
via fedafd759f96e5c6c6936fe2863309caea7a508e (commit)
via f65c7ad408262d2510300c74471bb8809f1cdd91 (commit)
from 929d5936e9ac020f19d5d703f0a52438ffab4738 (commit)
- Log -----------------------------------------------------------------
commit 0fbf9f9b9d79af5523eb8fe0c90970d897da6946
Author: Holger Berndt <hb at claws-mail.org>
Date: Thu Aug 8 23:32:11 2013 +0200
Python plugin: MessageInfo: Create Python objects for members on the fly
diff --git a/src/plugins/python/messageinfotype.c b/src/plugins/python/messageinfotype.c
index b5809f4..2cf6ed0 100644
--- a/src/plugins/python/messageinfotype.c
+++ b/src/plugins/python/messageinfotype.c
@@ -38,54 +38,30 @@
typedef struct {
PyObject_HEAD
- PyObject *from;
- PyObject *to;
- PyObject *cc;
- PyObject *subject;
- PyObject *msgid;
- PyObject *filepath;
MsgInfo *msginfo;
} clawsmail_MessageInfoObject;
static void MessageInfo_dealloc(clawsmail_MessageInfoObject* self)
{
- Py_XDECREF(self->from);
- Py_XDECREF(self->to);
- Py_XDECREF(self->cc);
- Py_XDECREF(self->subject);
- Py_XDECREF(self->msgid);
self->ob_type->tp_free((PyObject*)self);
}
static int MessageInfo_init(clawsmail_MessageInfoObject *self, PyObject *args, PyObject *kwds)
{
- Py_INCREF(Py_None);
- self->from = Py_None;
-
- Py_INCREF(Py_None);
- self->to = Py_None;
-
- Py_INCREF(Py_None);
- self->cc = Py_None;
-
- Py_INCREF(Py_None);
- self->subject = Py_None;
-
- Py_INCREF(Py_None);
- self->msgid = Py_None;
-
return 0;
}
-static PyObject* MessageInfo_str(PyObject *self)
+static PyObject* MessageInfo_str(clawsmail_MessageInfoObject *self)
{
- PyObject *str;
- str = PyString_FromString("MessageInfo: ");
- PyString_ConcatAndDel(&str, PyObject_GetAttrString(self, "From"));
- PyString_ConcatAndDel(&str, PyString_FromString(" / "));
- PyString_ConcatAndDel(&str, PyObject_GetAttrString(self, "Subject"));
- return str;
+ if(self->msginfo) {
+ gchar *From;
+ gchar *Subject;
+ From = self->msginfo->from ? self->msginfo->from : "";
+ Subject = self->msginfo->subject ? self->msginfo->subject : "";
+ return PyString_FromFormat("MessageInfo: %s / %s", From, Subject);
+ }
+ Py_RETURN_NONE;
}
static PyObject *py_boolean_return_value(gboolean val)
@@ -249,6 +225,55 @@ static PyObject* get_header(PyObject *self, PyObject *args)
}
}
+static PyObject* get_From(clawsmail_MessageInfoObject *self, void *closure)
+{
+ if(self->msginfo && self->msginfo->from)
+ return PyString_FromString(self->msginfo->from);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_To(clawsmail_MessageInfoObject *self, void *closure)
+{
+ if(self->msginfo && self->msginfo->to)
+ return PyString_FromString(self->msginfo->to);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_Cc(clawsmail_MessageInfoObject *self, void *closure)
+{
+ if(self->msginfo && self->msginfo->cc)
+ return PyString_FromString(self->msginfo->cc);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_Subject(clawsmail_MessageInfoObject *self, void *closure)
+{
+ if(self->msginfo && self->msginfo->subject)
+ return PyString_FromString(self->msginfo->subject);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_MessageID(clawsmail_MessageInfoObject *self, void *closure)
+{
+ if(self->msginfo && self->msginfo->msgid)
+ return PyString_FromString(self->msginfo->msgid);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_FilePath(clawsmail_MessageInfoObject *self, void *closure)
+{
+ if(self->msginfo) {
+ gchar *filepath;
+ filepath = procmsg_get_message_file_path(self->msginfo);
+ if(filepath) {
+ PyObject *retval;
+ retval = PyString_FromString(filepath);
+ g_free(filepath);
+ return retval;
+ }
+ }
+ Py_RETURN_NONE;
+}
static PyMethodDef MessageInfo_methods[] = {
{"is_new", is_new, METH_NOARGS,
@@ -308,28 +333,29 @@ static PyMethodDef MessageInfo_methods[] = {
{NULL}
};
-static PyMemberDef MessageInfo_members[] = {
- { "From", T_OBJECT_EX, offsetof(clawsmail_MessageInfoObject, from), 0,
- "From - the From header of the message" },
+static PyGetSetDef MessageInfo_getset[] = {
+ { "From", (getter)get_From, (setter)NULL,
+ "From - the From header of the message", NULL},
- { "To", T_OBJECT_EX, offsetof(clawsmail_MessageInfoObject, to), 0,
- "To - the To header of the message" },
+ { "To", (getter)get_To, (setter)NULL,
+ "To - the To header of the message", NULL },
- { "Cc", T_OBJECT_EX, offsetof(clawsmail_MessageInfoObject, cc), 0,
- "Cc - the Cc header of the message" },
+ { "Cc", (getter)get_Cc, (setter)NULL,
+ "Cc - the Cc header of the message", NULL },
- {"Subject", T_OBJECT_EX, offsetof(clawsmail_MessageInfoObject, subject), 0,
- "Subject - the subject header of the message"},
+ {"Subject", (getter)get_Subject, (setter)NULL,
+ "Subject - the subject header of the message", NULL},
- {"MessageID", T_OBJECT_EX, offsetof(clawsmail_MessageInfoObject, msgid), 0,
- "MessageID - the Message-ID header of the message"},
+ {"MessageID", (getter)get_MessageID, (setter)NULL,
+ "MessageID - the Message-ID header of the message", NULL},
- {"FilePath", T_OBJECT_EX, offsetof(clawsmail_MessageInfoObject, filepath), 0,
- "FilePath - path and filename of the message"},
+ {"FilePath", (getter)get_FilePath, (setter)NULL,
+ "FilePath - path and filename of the message", NULL},
{NULL}
};
+
static PyTypeObject clawsmail_MessageInfoType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size*/
@@ -347,7 +373,7 @@ static PyTypeObject clawsmail_MessageInfoType = {
0, /* tp_as_mapping*/
0, /* tp_hash */
0, /* tp_call*/
- MessageInfo_str, /* tp_str*/
+ (reprfunc)MessageInfo_str, /* tp_str*/
0, /* tp_getattro*/
0, /* tp_setattro*/
0, /* tp_as_buffer*/
@@ -362,8 +388,8 @@ static PyTypeObject clawsmail_MessageInfoType = {
0, /* tp_iter */
0, /* tp_iternext */
MessageInfo_methods, /* tp_methods */
- MessageInfo_members, /* tp_members */
- 0, /* tp_getset */
+ 0, /* tp_members */
+ MessageInfo_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -384,45 +410,6 @@ gboolean cmpy_add_messageinfo(PyObject *module)
return (PyModule_AddObject(module, "MessageInfo", (PyObject*)&clawsmail_MessageInfoType) == 0);
}
-#define MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(fis, pms) \
- do { \
- if(fis) { \
- PyObject *str; \
- str = PyString_FromString(fis); \
- if(str) { \
- int retval; \
- retval = PyObject_SetAttrString((PyObject*)ff, pms, str); \
- Py_DECREF(str); \
- if(retval == -1) \
- goto err; \
- } \
- } \
- } while(0)
-
-static gboolean update_members(clawsmail_MessageInfoObject *ff, MsgInfo *msginfo)
-{
- gchar *filepath;
-
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(msginfo->from, "From");
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(msginfo->to, "To");
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(msginfo->cc, "Cc");
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(msginfo->subject, "Subject");
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(msginfo->msgid, "MessageID");
-
- filepath = procmsg_get_message_file_path(msginfo);
- if(filepath) {
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER(filepath, "FilePath");
- g_free(filepath);
- }
- else {
- MSGINFO_STRING_TO_PYTHON_MESSAGEINFO_MEMBER("", "FilePath");
- }
-
- return TRUE;
-err:
- return FALSE;
-}
-
PyObject* clawsmail_messageinfo_new(MsgInfo *msginfo)
{
clawsmail_MessageInfoObject *ff;
@@ -435,13 +422,7 @@ PyObject* clawsmail_messageinfo_new(MsgInfo *msginfo)
return NULL;
ff->msginfo = msginfo;
-
- if(update_members(ff, msginfo))
- return (PyObject*)ff;
- else {
- Py_XDECREF(ff);
- return NULL;
- }
+ return (PyObject*)ff;
}
PyTypeObject* clawsmail_messageinfo_get_type_object()
commit 7154ef9813b0a69edc4a2c7771fc78091a782e4f
Author: Holger Berndt <hb at claws-mail.org>
Date: Thu Aug 8 23:26:22 2013 +0200
Python plugin: Account: Harden string representation
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index d50f252..6239ead 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -53,7 +53,9 @@ static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObjec
static PyObject* Account_str(clawsmail_AccountObject *self)
{
- return PyString_FromFormat("Account: %s", self->account->account_name);
+ if(self->account && self->account->account_name)
+ return PyString_FromFormat("Account: %s", self->account->account_name);
+ Py_RETURN_NONE;
}
static PyObject* get_account_name(clawsmail_AccountObject *self, void *closure)
commit 710fd469103d9f7743eb2ae9fb454c368e95b9e8
Author: Holger Berndt <hb at claws-mail.org>
Date: Thu Aug 8 00:28:43 2013 +0200
Python plugin: Folder: Add identifier property
diff --git a/src/plugins/python/foldertype.c b/src/plugins/python/foldertype.c
index 10a19b4..3afd0cc 100644
--- a/src/plugins/python/foldertype.c
+++ b/src/plugins/python/foldertype.c
@@ -145,6 +145,22 @@ static PyObject* get_mailbox_name(clawsmail_FolderObject *self, void *closure)
Py_RETURN_NONE;
}
+static PyObject* get_identifier(clawsmail_FolderObject *self, void *closure)
+{
+ if(self->folderitem) {
+ gchar *id;
+ id = folder_item_get_identifier(self->folderitem);
+ if(id) {
+ PyObject *retval;
+ retval = PyString_FromString(id);
+ g_free(id);
+ return retval;
+ }
+ }
+ Py_RETURN_NONE;
+}
+
+
static PyObject* get_properties(clawsmail_FolderObject *self, void *closure)
{
Py_INCREF(self->properties);
@@ -170,6 +186,9 @@ static PyGetSetDef Folder_getset[] = {
{"path", (getter)get_path, (setter)NULL,
"path - path of folder", NULL},
+ {"identifier", (getter)get_identifier, (setter)NULL,
+ "identifier - identifier of folder", NULL},
+
{"mailbox_name", (getter)get_mailbox_name, (setter)NULL,
"mailbox_name - name of the corresponding mailbox", NULL},
commit fedafd759f96e5c6c6936fe2863309caea7a508e
Author: Holger Berndt <hb at claws-mail.org>
Date: Thu Aug 8 00:21:41 2013 +0200
Python plugin: Folder: Create Python objects for members on the fly
diff --git a/src/plugins/python/foldertype.c b/src/plugins/python/foldertype.c
index 3b578c5..10a19b4 100644
--- a/src/plugins/python/foldertype.c
+++ b/src/plugins/python/foldertype.c
@@ -31,9 +31,6 @@
typedef struct {
PyObject_HEAD
- PyObject *name;
- PyObject *path;
- PyObject *mailbox_name;
PyObject *properties;
FolderItem *folderitem;
} clawsmail_FolderObject;
@@ -41,28 +38,10 @@ typedef struct {
static void Folder_dealloc(clawsmail_FolderObject* self)
{
- Py_XDECREF(self->name);
- Py_XDECREF(self->path);
- Py_XDECREF(self->mailbox_name);
Py_XDECREF(self->properties);
self->ob_type->tp_free((PyObject*)self);
}
-#define FOLDERITEM_STRING_TO_PYTHON_FOLDER_MEMBER(self,fis, pms) \
- do { \
- if(fis) { \
- PyObject *str; \
- str = PyString_FromString(fis); \
- if(str) { \
- int retval; \
- retval = PyObject_SetAttrString((PyObject*)self, pms, str); \
- Py_DECREF(str); \
- if(retval == -1) \
- goto err; \
- } \
- } \
- } while(0)
-
static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *kwds)
{
const char *ss = NULL;
@@ -73,15 +52,6 @@ static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *k
if(!PyArg_ParseTuple(args, "|sb", &ss, &create))
return -1;
- Py_INCREF(Py_None);
- self->name = Py_None;
-
- Py_INCREF(Py_None);
- self->path = Py_None;
-
- Py_INCREF(Py_None);
- self->mailbox_name = Py_None;
-
if(ss) {
if(create == 0) {
folderitem = folder_find_item_from_identifier(ss);
@@ -99,30 +69,20 @@ static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *k
}
}
- if(folderitem) {
- FOLDERITEM_STRING_TO_PYTHON_FOLDER_MEMBER(self, folderitem->name, "name");
- FOLDERITEM_STRING_TO_PYTHON_FOLDER_MEMBER(self, folderitem->path, "path");
- FOLDERITEM_STRING_TO_PYTHON_FOLDER_MEMBER(self, folderitem->folder->name, "mailbox_name");
- self->folderitem = folderitem;
+ self->folderitem = folderitem;
+ if(folderitem)
self->properties = clawsmail_folderproperties_new(folderitem->prefs);
- }
else {
Py_INCREF(Py_None);
self->properties = Py_None;
}
return 0;
-
- err:
- return -1;
}
-static PyObject* Folder_str(PyObject *self)
+static PyObject* Folder_str(clawsmail_FolderObject *self)
{
- PyObject *str;
- str = PyString_FromString("Folder: ");
- PyString_ConcatAndDel(&str, PyObject_GetAttrString(self, "name"));
- return str;
+ return PyString_FromFormat("Folder: %s", self->folderitem->name);
}
static PyObject* Folder_get_identifier(clawsmail_FolderObject *self, PyObject *args)
@@ -164,6 +124,27 @@ static PyObject* Folder_get_messages(clawsmail_FolderObject *self, PyObject *arg
return retval;
}
+static PyObject* get_name(clawsmail_FolderObject *self, void *closure)
+{
+ if(self->folderitem && self->folderitem->name)
+ return PyString_FromString(self->folderitem->name);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_path(clawsmail_FolderObject *self, void *closure)
+{
+ if(self->folderitem && self->folderitem->path)
+ return PyString_FromString(self->folderitem->path);
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_mailbox_name(clawsmail_FolderObject *self, void *closure)
+{
+ if(self->folderitem && self->folderitem->folder && self->folderitem->folder->name)
+ return PyString_FromString(self->folderitem->folder->name);
+ Py_RETURN_NONE;
+}
+
static PyObject* get_properties(clawsmail_FolderObject *self, void *closure)
{
Py_INCREF(self->properties);
@@ -182,20 +163,16 @@ static PyMethodDef Folder_methods[] = {
{NULL}
};
-static PyMemberDef Folder_members[] = {
- {"name", T_OBJECT_EX, offsetof(clawsmail_FolderObject, name), 0,
- "name - name of folder"},
-
- {"path", T_OBJECT_EX, offsetof(clawsmail_FolderObject, path), 0,
- "path - path of folder"},
+static PyGetSetDef Folder_getset[] = {
+ {"name", (getter)get_name, (setter)NULL,
+ "name - name of folder", NULL},
- {"mailbox_name", T_OBJECT_EX, offsetof(clawsmail_FolderObject, mailbox_name), 0,
- "mailbox_name - name of the corresponding mailbox"},
+ {"path", (getter)get_path, (setter)NULL,
+ "path - path of folder", NULL},
- {NULL}
-};
+ {"mailbox_name", (getter)get_mailbox_name, (setter)NULL,
+ "mailbox_name - name of the corresponding mailbox", NULL},
-static PyGetSetDef Folder_getset[] = {
{"properties", (getter)get_properties, (setter)NULL,
"properties - folder properties object", NULL},
@@ -220,7 +197,7 @@ static PyTypeObject clawsmail_FolderType = {
0, /* tp_as_mapping*/
0, /* tp_hash */
0, /* tp_call*/
- Folder_str, /* tp_str*/
+ (reprfunc)Folder_str, /* tp_str*/
0, /* tp_getattro*/
0, /* tp_setattro*/
0, /* tp_as_buffer*/
@@ -237,7 +214,7 @@ static PyTypeObject clawsmail_FolderType = {
0, /* tp_iter */
0, /* tp_iternext */
Folder_methods, /* tp_methods */
- Folder_members, /* tp_members */
+ 0, /* tp_members */
Folder_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
commit f65c7ad408262d2510300c74471bb8809f1cdd91
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Aug 3 18:07:17 2013 +0200
Python plugin: Account: Create Python objects for members on the fly
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index 9d42aa1..d50f252 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -26,19 +26,11 @@
typedef struct {
PyObject_HEAD
- PyObject *account_name;
- PyObject *address;
PrefsAccount *account;
} clawsmail_AccountObject;
static int Account_init(clawsmail_AccountObject *self, PyObject *args, PyObject *kwds)
{
- Py_INCREF(Py_None);
- self->account_name = Py_None;
-
- Py_INCREF(Py_None);
- self->address = Py_None;
-
self->account = NULL;
return 0;
}
@@ -46,9 +38,6 @@ static int Account_init(clawsmail_AccountObject *self, PyObject *args, PyObject
static void Account_dealloc(clawsmail_AccountObject* self)
{
- Py_XDECREF(self->account_name);
- Py_XDECREF(self->address);
-
self->ob_type->tp_free((PyObject*)self);
}
@@ -62,35 +51,30 @@ static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObjec
return 0;
}
-static PyObject* Account_str(PyObject *self)
+static PyObject* Account_str(clawsmail_AccountObject *self)
{
- PyObject *str;
- str = PyString_FromString("Account: ");
- if(str == NULL)
- return NULL;
- PyString_ConcatAndDel(&str, PyObject_GetAttrString(self, "account_name"));
-
- return str;
+ return PyString_FromFormat("Account: %s", self->account->account_name);
}
static PyObject* get_account_name(clawsmail_AccountObject *self, void *closure)
{
- Py_INCREF(self->account_name);
- return self->account_name;
+ if(self->account && self->account->account_name)
+ return PyString_FromString(self->account->account_name);
+ Py_RETURN_NONE;
}
static PyObject* get_address(clawsmail_AccountObject *self, void *closure)
{
- Py_INCREF(self->address);
- return self->address;
+ if(self->account && self->account->address)
+ return PyString_FromString(self->account->address);
+ Py_RETURN_NONE;
}
static PyObject* get_is_default(clawsmail_AccountObject *self, void *closure)
{
if(self->account->is_default)
Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ Py_RETURN_FALSE;
}
static PyGetSetDef Account_getset[] = {
@@ -123,7 +107,7 @@ static PyTypeObject clawsmail_AccountType = {
0, /* tp_as_mapping*/
0, /* tp_hash */
0, /* tp_call*/
- Account_str, /* tp_str*/
+ (reprfunc)Account_str, /* tp_str*/
0, /* tp_getattro*/
0, /* tp_setattro*/
0, /* tp_as_buffer*/
@@ -160,31 +144,6 @@ gboolean cmpy_add_account(PyObject *module)
return (PyModule_AddObject(module, "Account", (PyObject*)&clawsmail_AccountType) == 0);
}
-static gboolean update_members(clawsmail_AccountObject *self, PrefsAccount *account)
-{
- if(account->account_name) {
- Py_XDECREF(self->account_name);
- self->account_name = PyString_FromString(account->account_name);
- if(!self->account_name)
- goto err;
- }
-
- if(account->address) {
- Py_XDECREF(self->address);
- self->address = PyString_FromString(account->address);
- if(!self->address)
- goto err;
- }
-
- self->account = account;
-
- return TRUE;
-err:
- Py_XDECREF(self->account_name);
- Py_XDECREF(self->address);
- return FALSE;
-}
-
PyObject* clawsmail_account_new(PrefsAccount *account)
{
clawsmail_AccountObject *ff;
@@ -196,10 +155,6 @@ PyObject* clawsmail_account_new(PrefsAccount *account)
if(!ff)
return NULL;
- if(update_members(ff, account))
- return (PyObject*)ff;
- else {
- Py_XDECREF(ff);
- return NULL;
- }
+ ff->account = account;
+ return (PyObject*)ff;
}
-----------------------------------------------------------------------
Summary of changes:
src/plugins/python/accounttype.c | 71 +++-----------
src/plugins/python/foldertype.c | 108 ++++++++++-----------
src/plugins/python/messageinfotype.c | 171 +++++++++++++++-------------------
3 files changed, 142 insertions(+), 208 deletions(-)
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list