[Commits] [SCM] claws branch, master, updated. 3.9.2-53-g4c94b22
holger at claws-mail.org
holger at claws-mail.org
Sat Jul 27 18:02:17 CEST 2013
The branch master of project "claws" (Claws Mail) has been updated
via 4c94b229454fc50aada030922807eb6c616e6a67 (commit)
via 6485c26de2ee8e935cfde0af28e57f8d14fc41b4 (commit)
via 50f5bc8ce3277cd63e6c9902819f5bdcc7d1f3b4 (commit)
via d17846613422b6615ad1f97820b6df3ec7c6e052 (commit)
via 3887eb3fd30f291fd162a5c33fac282033d727eb (commit)
via 7ba87228ec8165e64eff7cb0e97d85d085faca0c (commit)
via 8617c2715305c5711da997f6cfde70a18a517a96 (commit)
via c6ac8058d4662ebe84b2e368fb358a6541a9d20f (commit)
via 04f289b96ae90e40069a5f948ad82c82328d2f9f (commit)
via c3da82f8aadef115aa11d22aaa5d9de1061589eb (commit)
via 7281a023775c5083bc39e20400d452aabdddcb39 (commit)
via d31687969e1b8a8c9581fff4a400c0b38543fc73 (commit)
via 8002fdaec00b0ba3698ceeedbb7b55830463dfbf (commit)
from 74b05b3fac3f123064130c9bc8ae885948399032 (commit)
- Log -----------------------------------------------------------------
commit 4c94b229454fc50aada030922807eb6c616e6a67
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 17:25:54 2013 +0200
Python plugin: Let Account objects compare equal if they refer to the same account
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index 56c7c7b..9d42aa1 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -52,6 +52,16 @@ static void Account_dealloc(clawsmail_AccountObject* self)
self->ob_type->tp_free((PyObject*)self);
}
+static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObject *obj2)
+{
+ if(obj1->account->account_id < obj2->account->account_id)
+ return -1;
+ else if(obj1->account->account_id > obj2->account->account_id)
+ return 1;
+ else
+ return 0;
+}
+
static PyObject* Account_str(PyObject *self)
{
PyObject *str;
@@ -106,7 +116,7 @@ static PyTypeObject clawsmail_AccountType = {
0, /* tp_print*/
0, /* tp_getattr*/
0, /* tp_setattr*/
- 0, /* tp_compare*/
+ (cmpfunc)Account_compare, /* tp_compare*/
0, /* tp_repr*/
0, /* tp_as_number*/
0, /* tp_as_sequence*/
commit 6485c26de2ee8e935cfde0af28e57f8d14fc41b4
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 17:13:37 2013 +0200
Python plugin: Add accessor to Account object for compose window
diff --git a/src/plugins/python/composewindowtype.c b/src/plugins/python/composewindowtype.c
index de87be6..bf5b0a6 100644
--- a/src/plugins/python/composewindowtype.c
+++ b/src/plugins/python/composewindowtype.c
@@ -24,6 +24,7 @@
#include <glib/gi18n.h>
#include "composewindowtype.h"
+#include "accounttype.h"
#include "clawsmailmodule.h"
#include "foldertype.h"
@@ -446,6 +447,15 @@ static PyObject* ComposeWindow_set_modified(clawsmail_ComposeWindowObject *self,
return Py_None;
}
+static PyObject* get_account(clawsmail_ComposeWindowObject *self, void *closure)
+{
+ if(self->compose->account) {
+ return clawsmail_account_new(self->compose->account);
+ }
+ Py_RETURN_NONE;
+}
+
+
static PyMethodDef ComposeWindow_methods[] = {
{"set_subject", (PyCFunction)ComposeWindow_set_subject, METH_VARARGS,
"set_subject(text) - set subject to text\n"
@@ -548,6 +558,13 @@ static PyMemberDef ComposeWindow_members[] = {
{NULL}
};
+static PyGetSetDef ComposeWindow_getset[] = {
+ {"account", (getter)get_account, (setter)NULL,
+ "account - the account corresponding to this compose window", NULL},
+
+ {NULL}
+};
+
static PyTypeObject clawsmail_ComposeWindowType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
@@ -580,7 +597,7 @@ static PyTypeObject clawsmail_ComposeWindowType = {
0, /* tp_iternext */
ComposeWindow_methods, /* tp_methods */
ComposeWindow_members, /* tp_members */
- 0, /* tp_getset */
+ ComposeWindow_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
commit 50f5bc8ce3277cd63e6c9902819f5bdcc7d1f3b4
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 17:03:03 2013 +0200
Python plugin: Make fwdinfo accessible in compose window object
diff --git a/src/plugins/python/composewindowtype.c b/src/plugins/python/composewindowtype.c
index a7d0ae6..de87be6 100644
--- a/src/plugins/python/composewindowtype.c
+++ b/src/plugins/python/composewindowtype.c
@@ -42,6 +42,7 @@ typedef struct {
PyObject *ui_manager;
PyObject *text;
PyObject *replyinfo;
+ PyObject *fwdinfo;
Compose *compose;
} clawsmail_ComposeWindowObject;
@@ -50,6 +51,7 @@ static void ComposeWindow_dealloc(clawsmail_ComposeWindowObject* self)
Py_XDECREF(self->ui_manager);
Py_XDECREF(self->text);
Py_XDECREF(self->replyinfo);
+ Py_XDECREF(self->fwdinfo);
self->ob_type->tp_free((PyObject*)self);
}
@@ -81,6 +83,7 @@ static void composewindow_set_compose(clawsmail_ComposeWindowObject *self, Compo
store_py_object(&(self->text), get_gobj_from_address(compose->text));
store_py_object(&(self->replyinfo), clawsmail_messageinfo_new(compose->replyinfo));
+ store_py_object(&(self->fwdinfo), clawsmail_messageinfo_new(compose->fwdinfo));
}
static int ComposeWindow_init(clawsmail_ComposeWindowObject *self, PyObject *args, PyObject *kwds)
@@ -539,6 +542,9 @@ static PyMemberDef ComposeWindow_members[] = {
{"replyinfo", T_OBJECT_EX, offsetof(clawsmail_ComposeWindowObject, replyinfo), 0,
"replyinfo - The MessageInfo object of the message that is being replied to, or None"},
+ {"forwardinfo", T_OBJECT_EX, offsetof(clawsmail_ComposeWindowObject, fwdinfo), 0,
+ "forwardinfo - The MessageInfo object of the message that is being forwarded, or None"},
+
{NULL}
};
commit d17846613422b6615ad1f97820b6df3ec7c6e052
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 16:46:57 2013 +0200
Python plugin: Make it possible to query current and default account
diff --git a/src/plugins/python/clawsmailmodule.c b/src/plugins/python/clawsmailmodule.c
index d983c6e..ec1f223 100644
--- a/src/plugins/python/clawsmailmodule.c
+++ b/src/plugins/python/clawsmailmodule.c
@@ -625,6 +625,29 @@ static PyObject* copy_messages(PyObject *self, PyObject *args)
return move_or_copy_messages(self, args, FALSE);
}
+static PyObject* get_current_account(PyObject *self, PyObject *args)
+{
+ PrefsAccount *account;
+ account = account_get_cur_account();
+ if(account) {
+ return clawsmail_account_new(account);
+ }
+ else
+ Py_RETURN_NONE;
+}
+
+static PyObject* get_default_account(PyObject *self, PyObject *args)
+{
+ PrefsAccount *account;
+ account = account_get_default();
+ if(account) {
+ return clawsmail_account_new(account);
+ }
+ else
+ Py_RETURN_NONE;
+}
+
+
static PyMethodDef ClawsMailMethods[] = {
/* public */
{"get_mainwindow_action_group", get_mainwindow_action_group, METH_NOARGS,
@@ -731,6 +754,16 @@ static PyMethodDef ClawsMailMethods[] = {
"\n"
"Get a tuple of Account objects representing all accounts that are defined in Claws Mail."},
+ {"get_current_account", get_current_account, METH_NOARGS,
+ "get_current_account() - get the current account\n"
+ "\n"
+ "Return the object representing the currently selected account."},
+
+ {"get_default_account", get_default_account, METH_NOARGS,
+ "get_default_account() - get the default account\n"
+ "\n"
+ "Return the object representing the default account."},
+
/* private */
{"__gobj", private_wrap_gobj, METH_VARARGS,
"__gobj(ptr) - transforms a C GObject pointer into a PyGObject\n"
commit 3887eb3fd30f291fd162a5c33fac282033d727eb
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 16:46:43 2013 +0200
Python plugin: Include information about default account
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index d82717a..56c7c7b 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -75,6 +75,14 @@ static PyObject* get_address(clawsmail_AccountObject *self, void *closure)
return self->address;
}
+static PyObject* get_is_default(clawsmail_AccountObject *self, void *closure)
+{
+ if(self->account->is_default)
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
static PyGetSetDef Account_getset[] = {
{"account_name", (getter)get_account_name, (setter)NULL,
"account_name - name of the account", NULL},
@@ -82,6 +90,9 @@ static PyGetSetDef Account_getset[] = {
{"address", (getter)get_address, (setter)NULL,
"address - address of the account", NULL},
+ {"is_default", (getter)get_is_default, (setter)NULL,
+ "is_default - whether this account is the default account", NULL},
+
{NULL}
};
commit 7ba87228ec8165e64eff7cb0e97d85d085faca0c
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 16:34:47 2013 +0200
Python plugin: Add folder properties
So far, only the default account is accessible
diff --git a/src/plugins/python/Makefile.am b/src/plugins/python/Makefile.am
index bb213fc..4f72a91 100644
--- a/src/plugins/python/Makefile.am
+++ b/src/plugins/python/Makefile.am
@@ -13,6 +13,8 @@ python_la_SOURCES = \
clawsmailmodule.h \
composewindowtype.c \
composewindowtype.h \
+ folderpropertiestype.c \
+ folderpropertiestype.h \
foldertype.c \
foldertype.h \
messageinfotype.c \
diff --git a/src/plugins/python/clawsmailmodule.c b/src/plugins/python/clawsmailmodule.c
index e21f280..d983c6e 100644
--- a/src/plugins/python/clawsmailmodule.c
+++ b/src/plugins/python/clawsmailmodule.c
@@ -27,6 +27,7 @@
#include "nodetype.h"
#include "composewindowtype.h"
+#include "folderpropertiestype.h"
#include "foldertype.h"
#include "messageinfotype.h"
#include "accounttype.h"
@@ -786,6 +787,7 @@ PyMODINIT_FUNC initclawsmail(void)
ok = ok && cmpy_add_folder(cm_module);
ok = ok && cmpy_add_messageinfo(cm_module);
ok = ok && cmpy_add_account(cm_module);
+ ok = ok && cmpy_add_folderproperties(cm_module);
/* initialize misc things */
if(ok)
diff --git a/src/plugins/python/folderpropertiestype.c b/src/plugins/python/folderpropertiestype.c
new file mode 100644
index 0000000..0eed08b
--- /dev/null
+++ b/src/plugins/python/folderpropertiestype.c
@@ -0,0 +1,140 @@
+/* Python plugin for Claws-Mail
+ * Copyright (C) 2013 Holger Berndt <hb at claws-mail.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+# include "claws-features.h"
+#endif
+
+#include "folderpropertiestype.h"
+#include "accounttype.h"
+
+#include <structmember.h>
+
+typedef struct {
+ PyObject_HEAD
+ FolderItemPrefs *folderitem_prefs;
+} clawsmail_FolderPropertiesObject;
+
+static int FolderProperties_init(clawsmail_FolderPropertiesObject *self, PyObject *args, PyObject *kwds)
+{
+ self->folderitem_prefs = NULL;
+ return 0;
+}
+
+static void FolderProperties_dealloc(clawsmail_FolderPropertiesObject* self)
+{
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject* get_default_account(clawsmail_FolderPropertiesObject *self, void *closure)
+{
+ if(self->folderitem_prefs && self->folderitem_prefs->enable_default_account) {
+ PrefsAccount *account;
+ account = account_find_from_id(self->folderitem_prefs->default_account);
+ if(account) {
+ return clawsmail_account_new(account);
+ }
+ }
+ Py_RETURN_NONE;
+}
+
+static PyGetSetDef FolderProperties_getset[] = {
+ {"default_account", (getter)get_default_account, (setter)NULL,
+ "default_account - the default account when composing from this folder", NULL},
+
+ {NULL}
+};
+
+static PyTypeObject clawsmail_FolderPropertiesType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size*/
+ "clawsmail.FolderProperties", /* tp_name*/
+ sizeof(clawsmail_FolderPropertiesObject), /* tp_basicsize*/
+ 0, /* tp_itemsize*/
+ (destructor)FolderProperties_dealloc, /* tp_dealloc*/
+ 0, /* tp_print*/
+ 0, /* tp_getattr*/
+ 0, /* tp_setattr*/
+ 0, /* tp_compare*/
+ 0, /* tp_repr*/
+ 0, /* tp_as_number*/
+ 0, /* tp_as_sequence*/
+ 0, /* tp_as_mapping*/
+ 0, /* tp_hash */
+ 0, /* tp_call*/
+ 0, /* tp_str*/
+ 0, /* tp_getattro*/
+ 0, /* tp_setattro*/
+ 0, /* tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /* tp_flags*/
+ "FolderProperties objects.\n\n" /* tp_doc */
+ "Do not construct objects of this type yourself.",
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ FolderProperties_getset, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)FolderProperties_init, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+
+gboolean cmpy_add_folderproperties(PyObject *module)
+{
+ clawsmail_FolderPropertiesType.tp_new = PyType_GenericNew;
+ if(PyType_Ready(&clawsmail_FolderPropertiesType) < 0)
+ return FALSE;
+
+ Py_INCREF(&clawsmail_FolderPropertiesType);
+ return (PyModule_AddObject(module, "FolderProperties", (PyObject*)&clawsmail_FolderPropertiesType) == 0);
+}
+
+static gboolean update_members(clawsmail_FolderPropertiesObject *self, FolderItemPrefs *folderitem_prefs)
+{
+ self->folderitem_prefs = folderitem_prefs;
+ return TRUE;
+}
+
+PyObject* clawsmail_folderproperties_new(FolderItemPrefs *folderitem_prefs)
+{
+ clawsmail_FolderPropertiesObject *ff;
+
+ if(!folderitem_prefs)
+ return NULL;
+
+ ff = (clawsmail_FolderPropertiesObject*) PyObject_CallObject((PyObject*) &clawsmail_FolderPropertiesType, NULL);
+ if(!ff)
+ return NULL;
+
+ if(update_members(ff, folderitem_prefs))
+ return (PyObject*)ff;
+ else {
+ Py_XDECREF(ff);
+ return NULL;
+ }
+}
diff --git a/src/plugins/python/folderpropertiestype.h b/src/plugins/python/folderpropertiestype.h
new file mode 100644
index 0000000..3330c3d
--- /dev/null
+++ b/src/plugins/python/folderpropertiestype.h
@@ -0,0 +1,32 @@
+/* Python plugin for Claws-Mail
+ * Copyright (C) 2013 Holger Berndt <hb at claws-mail.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FOLDERPROPERTIESTYPE_H
+#define FOLDERPROPERTIESTYPE_H
+
+#include <glib.h>
+#include <Python.h>
+
+#include "folder_item_prefs.h"
+
+
+gboolean cmpy_add_folderproperties(PyObject *module);
+
+PyObject* clawsmail_folderproperties_new(FolderItemPrefs *folderitem_prefs);
+
+
+#endif /* FOLDERPROPERTIESTYPE_H */
diff --git a/src/plugins/python/foldertype.c b/src/plugins/python/foldertype.c
index ccf5806..3b578c5 100644
--- a/src/plugins/python/foldertype.c
+++ b/src/plugins/python/foldertype.c
@@ -23,6 +23,7 @@
#include <glib/gi18n.h>
#include "foldertype.h"
+#include "folderpropertiestype.h"
#include "messageinfotype.h"
#include <structmember.h>
@@ -33,6 +34,7 @@ typedef struct {
PyObject *name;
PyObject *path;
PyObject *mailbox_name;
+ PyObject *properties;
FolderItem *folderitem;
} clawsmail_FolderObject;
@@ -42,6 +44,7 @@ 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);
}
@@ -101,6 +104,11 @@ static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *k
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->properties = clawsmail_folderproperties_new(folderitem->prefs);
+ }
+ else {
+ Py_INCREF(Py_None);
+ self->properties = Py_None;
}
return 0;
@@ -156,6 +164,12 @@ static PyObject* Folder_get_messages(clawsmail_FolderObject *self, PyObject *arg
return retval;
}
+static PyObject* get_properties(clawsmail_FolderObject *self, void *closure)
+{
+ Py_INCREF(self->properties);
+ return self->properties;
+}
+
static PyMethodDef Folder_methods[] = {
{"get_identifier", (PyCFunction)Folder_get_identifier, METH_NOARGS,
"get_identifier() - get identifier\n"
@@ -181,6 +195,14 @@ static PyMemberDef Folder_members[] = {
{NULL}
};
+static PyGetSetDef Folder_getset[] = {
+ {"properties", (getter)get_properties, (setter)NULL,
+ "properties - folder properties object", NULL},
+
+ {NULL}
+};
+
+
static PyTypeObject clawsmail_FolderType = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size*/
@@ -216,7 +238,7 @@ static PyTypeObject clawsmail_FolderType = {
0, /* tp_iternext */
Folder_methods, /* tp_methods */
Folder_members, /* tp_members */
- 0, /* tp_getset */
+ Folder_getset, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
commit 8617c2715305c5711da997f6cfde70a18a517a96
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 13:12:25 2013 +0200
Python plugin: Remove unused account methods
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index 337bebf..d82717a 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -75,10 +75,6 @@ static PyObject* get_address(clawsmail_AccountObject *self, void *closure)
return self->address;
}
-static PyMethodDef Account_methods[] = {
- {NULL}
-};
-
static PyGetSetDef Account_getset[] = {
{"account_name", (getter)get_account_name, (setter)NULL,
"account_name - name of the account", NULL},
@@ -119,7 +115,7 @@ static PyTypeObject clawsmail_AccountType = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- Account_methods, /* tp_methods */
+ 0, /* tp_methods */
0, /* tp_members */
Account_getset, /* tp_getset */
0, /* tp_base */
commit c6ac8058d4662ebe84b2e368fb358a6541a9d20f
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 27 13:11:06 2013 +0200
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 ba4f758..337bebf 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 */
commit 04f289b96ae90e40069a5f948ad82c82328d2f9f
Author: Holger Berndt <hb at claws-mail.org>
Date: Thu Jul 25 22:29:43 2013 +0200
Python plugin: Add account address
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
index 2163cf3..ba4f758 100644
--- a/src/plugins/python/accounttype.c
+++ b/src/plugins/python/accounttype.c
@@ -27,6 +27,7 @@
typedef struct {
PyObject_HEAD
PyObject *account_name;
+ PyObject *address;
PrefsAccount *account;
} clawsmail_AccountObject;
@@ -35,6 +36,9 @@ static int Account_init(clawsmail_AccountObject *self, PyObject *args, PyObject
Py_INCREF(Py_None);
self->account_name = Py_None;
+ Py_INCREF(Py_None);
+ self->address = Py_None;
+
self->account = NULL;
return 0;
}
@@ -43,6 +47,7 @@ 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);
}
@@ -64,7 +69,10 @@ static PyMethodDef Account_methods[] = {
static PyMemberDef Account_members[] = {
{"account_name", T_OBJECT_EX, offsetof(clawsmail_AccountObject, account_name), 0,
- "account name - name of the corresponding account"},
+ "account name - name of the account"},
+
+ {"address", T_OBJECT_EX, offsetof(clawsmail_AccountObject, address), 0,
+ "address - address of the account"},
{NULL}
};
@@ -125,18 +133,26 @@ gboolean cmpy_add_account(PyObject *module)
static gboolean update_members(clawsmail_AccountObject *self, PrefsAccount *account)
{
- PyObject *str;
+ if(account->account_name) {
+ Py_XDECREF(self->account_name);
+ self->account_name = PyString_FromString(account->account_name);
+ if(!self->account_name)
+ goto err;
+ }
- str = PyString_FromString(account->account_name);
- if(!str)
- goto err;
- self->account_name = str;
+ 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;
}
commit c3da82f8aadef115aa11d22aaa5d9de1061589eb
Author: Holger Berndt <hb at claws-mail.org>
Date: Sun Jul 21 14:10:46 2013 +0200
Python plugin: Add accessor to accounts, and an Account object
diff --git a/src/plugins/python/Makefile.am b/src/plugins/python/Makefile.am
index bee41ec..bb213fc 100644
--- a/src/plugins/python/Makefile.am
+++ b/src/plugins/python/Makefile.am
@@ -7,6 +7,8 @@ plugin_LTLIBRARIES = python.la
endif
python_la_SOURCES = \
+ accounttype.c \
+ accounttype.h \
clawsmailmodule.c \
clawsmailmodule.h \
composewindowtype.c \
diff --git a/src/plugins/python/accounttype.c b/src/plugins/python/accounttype.c
new file mode 100644
index 0000000..2163cf3
--- /dev/null
+++ b/src/plugins/python/accounttype.c
@@ -0,0 +1,160 @@
+/* Python plugin for Claws-Mail
+ * Copyright (C) 2013 Holger Berndt <hb at claws-mail.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+# include "claws-features.h"
+#endif
+
+#include "accounttype.h"
+
+#include <structmember.h>
+
+typedef struct {
+ PyObject_HEAD
+ PyObject *account_name;
+ PrefsAccount *account;
+} clawsmail_AccountObject;
+
+static int Account_init(clawsmail_AccountObject *self, PyObject *args, PyObject *kwds)
+{
+ Py_INCREF(Py_None);
+ self->account_name = Py_None;
+
+ self->account = NULL;
+ return 0;
+}
+
+
+static void Account_dealloc(clawsmail_AccountObject* self)
+{
+ Py_XDECREF(self->account_name);
+
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+static PyObject* Account_str(PyObject *self)
+{
+ PyObject *str;
+ str = PyString_FromString("Account: ");
+ if(str == NULL)
+ return NULL;
+ PyString_ConcatAndDel(&str, PyObject_GetAttrString(self, "account_name"));
+
+ return str;
+}
+
+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 corresponding account"},
+
+ {NULL}
+};
+
+static PyTypeObject clawsmail_AccountType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size*/
+ "clawsmail.Account", /* tp_name*/
+ sizeof(clawsmail_AccountObject), /* tp_basicsize*/
+ 0, /* tp_itemsize*/
+ (destructor)Account_dealloc, /* tp_dealloc*/
+ 0, /* tp_print*/
+ 0, /* tp_getattr*/
+ 0, /* tp_setattr*/
+ 0, /* tp_compare*/
+ 0, /* tp_repr*/
+ 0, /* tp_as_number*/
+ 0, /* tp_as_sequence*/
+ 0, /* tp_as_mapping*/
+ 0, /* tp_hash */
+ 0, /* tp_call*/
+ Account_str, /* tp_str*/
+ 0, /* tp_getattro*/
+ 0, /* tp_setattro*/
+ 0, /* tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /* tp_flags*/
+ "Account objects.\n\n" /* tp_doc */
+ "Do not construct objects of this type yourself.",
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Account_methods, /* tp_methods */
+ Account_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Account_init, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+
+gboolean cmpy_add_account(PyObject *module)
+{
+ clawsmail_AccountType.tp_new = PyType_GenericNew;
+ if(PyType_Ready(&clawsmail_AccountType) < 0)
+ return FALSE;
+
+ Py_INCREF(&clawsmail_AccountType);
+ return (PyModule_AddObject(module, "Account", (PyObject*)&clawsmail_AccountType) == 0);
+}
+
+static gboolean update_members(clawsmail_AccountObject *self, PrefsAccount *account)
+{
+ PyObject *str;
+
+ str = PyString_FromString(account->account_name);
+ if(!str)
+ goto err;
+ self->account_name = str;
+
+ self->account = account;
+
+ return TRUE;
+err:
+ Py_XDECREF(self->account_name);
+ return FALSE;
+}
+
+PyObject* clawsmail_account_new(PrefsAccount *account)
+{
+ clawsmail_AccountObject *ff;
+
+ if(!account)
+ return NULL;
+
+ ff = (clawsmail_AccountObject*) PyObject_CallObject((PyObject*) &clawsmail_AccountType, NULL);
+ if(!ff)
+ return NULL;
+
+ if(update_members(ff, account))
+ return (PyObject*)ff;
+ else {
+ Py_XDECREF(ff);
+ return NULL;
+ }
+}
diff --git a/src/plugins/python/accounttype.h b/src/plugins/python/accounttype.h
new file mode 100644
index 0000000..808faba
--- /dev/null
+++ b/src/plugins/python/accounttype.h
@@ -0,0 +1,31 @@
+/* Python plugin for Claws-Mail
+ * Copyright (C) 2013 Holger Berndt <hb at claws-mail.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ACCOUNTTYPE_H
+#define ACCOUNTTYPE_H
+
+#include <glib.h>
+#include <Python.h>
+
+#include "account.h"
+
+gboolean cmpy_add_account(PyObject *module);
+
+PyObject* clawsmail_account_new(PrefsAccount *account);
+
+
+#endif /* ACCOUNTTYPE_H */
diff --git a/src/plugins/python/clawsmailmodule.c b/src/plugins/python/clawsmailmodule.c
index 0efc52e..e21f280 100644
--- a/src/plugins/python/clawsmailmodule.c
+++ b/src/plugins/python/clawsmailmodule.c
@@ -29,6 +29,7 @@
#include "composewindowtype.h"
#include "foldertype.h"
#include "messageinfotype.h"
+#include "accounttype.h"
#include <pygobject.h>
#include <pygtk/pygtk.h>
@@ -40,6 +41,7 @@
#include "toolbar.h"
#include "prefs_common.h"
#include "common/tags.h"
+#include "account.h"
#include <glib.h>
@@ -434,6 +436,33 @@ static PyObject* get_tags(PyObject *self, PyObject *args)
return tags_tuple;
}
+static PyObject* get_accounts(PyObject *self, PyObject *args)
+{
+ PyObject *accounts_tuple;
+ GList *accounts_list;
+ GList *walk;
+
+ accounts_list = account_get_list();
+
+ accounts_tuple = PyTuple_New(g_list_length(accounts_list));
+ if(accounts_tuple) {
+ PyObject *account_object;
+ Py_ssize_t iAccount;
+
+ iAccount = 0;
+ for(walk = accounts_list; walk; walk = walk->next) {
+ account_object = clawsmail_account_new(walk->data);
+ if(account_object == NULL) {
+ Py_DECREF(accounts_tuple);
+ return NULL;
+ }
+ PyTuple_SET_ITEM(accounts_tuple, iAccount++, account_object);
+ }
+ }
+
+ return accounts_tuple;
+}
+
static PyObject* make_sure_tag_exists(PyObject *self, PyObject *args)
{
int retval;
@@ -696,7 +725,12 @@ static PyMethodDef ClawsMailMethods[] = {
"Raises a KeyError exception if the tag does not exist.\n"
"Raises a ValueError exception if the old or new tag name is a reserved name."},
- /* private */
+ {"get_accounts", get_accounts, METH_NOARGS,
+ "get_accounts() - get a tuple of all accounts that Claws Mail knows about\n"
+ "\n"
+ "Get a tuple of Account objects representing all accounts that are defined in Claws Mail."},
+
+ /* private */
{"__gobj", private_wrap_gobj, METH_VARARGS,
"__gobj(ptr) - transforms a C GObject pointer into a PyGObject\n"
"\n"
@@ -751,6 +785,7 @@ PyMODINIT_FUNC initclawsmail(void)
ok = ok && cmpy_add_composewindow(cm_module);
ok = ok && cmpy_add_folder(cm_module);
ok = ok && cmpy_add_messageinfo(cm_module);
+ ok = ok && cmpy_add_account(cm_module);
/* initialize misc things */
if(ok)
commit 7281a023775c5083bc39e20400d452aabdddcb39
Author: Holger Berndt <hb at claws-mail.org>
Date: Sun Jul 21 12:45:28 2013 +0200
Python plugin: Indent fix
diff --git a/src/plugins/python/composewindowtype.c b/src/plugins/python/composewindowtype.c
index 110296b..a7d0ae6 100644
--- a/src/plugins/python/composewindowtype.c
+++ b/src/plugins/python/composewindowtype.c
@@ -17,7 +17,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
-#include "claws-features.h"
+# include "claws-features.h"
#endif
#include <glib.h>
commit d31687969e1b8a8c9581fff4a400c0b38543fc73
Author: Holger Berndt <hb at claws-mail.org>
Date: Sun Jul 21 12:44:27 2013 +0200
Python plugin: Const fix and better description of MessageInfo objects
diff --git a/src/plugins/python/messageinfotype.c b/src/plugins/python/messageinfotype.c
index 77d5724..b5809f4 100644
--- a/src/plugins/python/messageinfotype.c
+++ b/src/plugins/python/messageinfotype.c
@@ -214,7 +214,7 @@ static PyObject* remove_tag(PyObject *self, PyObject *args)
static PyObject* get_header(PyObject *self, PyObject *args)
{
int retval;
- const char *header_str;
+ char *header_str;
char *header_str_dup;
MsgInfo *msginfo;
gchar header_content[HEADER_CONTENT_SIZE];
@@ -353,7 +353,8 @@ static PyTypeObject clawsmail_MessageInfoType = {
0, /* tp_as_buffer*/
Py_TPFLAGS_DEFAULT, /* tp_flags*/
"A MessageInfo represents" /* tp_doc */
- "a single message.",
+ " a single message.\n\n"
+ "Do not construct objects of this type yourself.",
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
commit 8002fdaec00b0ba3698ceeedbb7b55830463dfbf
Author: Holger Berndt <hb at claws-mail.org>
Date: Sat Jul 20 12:41:12 2013 +0200
Python plugin: Fix typo
diff --git a/src/plugins/python/clawsmailmodule.c b/src/plugins/python/clawsmailmodule.c
index c34283e..0efc52e 100644
--- a/src/plugins/python/clawsmailmodule.c
+++ b/src/plugins/python/clawsmailmodule.c
@@ -744,7 +744,7 @@ PyMODINIT_FUNC initclawsmail(void)
/* add module member "compose_window" set to None */
Py_INCREF(Py_None);
- PyModule_AddObject(cm_module, "compose window", Py_None);
+ PyModule_AddObject(cm_module, "compose_window", Py_None);
/* initialize classes */
ok = ok && cmpy_add_node(cm_module);
-----------------------------------------------------------------------
Summary of changes:
src/plugins/python/Makefile.am | 4 +
src/plugins/python/accounttype.c | 205 ++++++++++++++++++++
src/plugins/python/{nodetype.h => accounttype.h} | 15 +-
src/plugins/python/clawsmailmodule.c | 74 +++++++-
src/plugins/python/composewindowtype.c | 27 +++-
src/plugins/python/folderpropertiestype.c | 140 +++++++++++++
...{composewindowtype.h => folderpropertiestype.h} | 15 +-
src/plugins/python/foldertype.c | 24 +++-
src/plugins/python/messageinfotype.c | 5 +-
9 files changed, 488 insertions(+), 21 deletions(-)
create mode 100644 src/plugins/python/accounttype.c
copy src/plugins/python/{nodetype.h => accounttype.h} (74%)
create mode 100644 src/plugins/python/folderpropertiestype.c
copy src/plugins/python/{composewindowtype.h => folderpropertiestype.h} (69%)
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list