From: Holger Berndt Date: Sat, 27 Jul 2013 11:11:06 +0000 (+0200) Subject: Python plugin: Make account name and address read-only attributes X-Git-Tag: 3.9.3~89 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=c6ac8058d4662ebe84b2e368fb358a6541a9d20f Python plugin: Make account name and address read-only attributes --- diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c index ba4f758e5..337bebfa4 100644 --- a/src/plugins/python/accounttype.c +++ b/src/plugins/python/accounttype.c @@ -63,16 +63,28 @@ static PyObject* Account_str(PyObject *self) return str; } +static PyObject* get_account_name(clawsmail_AccountObject *self, void *closure) +{ + Py_INCREF(self->account_name); + return self->account_name; +} + +static PyObject* get_address(clawsmail_AccountObject *self, void *closure) +{ + Py_INCREF(self->address); + return self->address; +} + static PyMethodDef Account_methods[] = { {NULL} }; -static PyMemberDef Account_members[] = { - {"account_name", T_OBJECT_EX, offsetof(clawsmail_AccountObject, account_name), 0, - "account name - name of the account"}, +static PyGetSetDef Account_getset[] = { + {"account_name", (getter)get_account_name, (setter)NULL, + "account_name - name of the account", NULL}, - {"address", T_OBJECT_EX, offsetof(clawsmail_AccountObject, address), 0, - "address - address of the account"}, + {"address", (getter)get_address, (setter)NULL, + "address - address of the account", NULL}, {NULL} }; @@ -108,8 +120,8 @@ static PyTypeObject clawsmail_AccountType = { 0, /* tp_iter */ 0, /* tp_iternext */ Account_methods, /* tp_methods */ - Account_members, /* tp_members */ - 0, /* tp_getset */ + 0, /* tp_members */ + Account_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */