port python plugin to python3. based on patch by Raphael Michel
This commit is contained in:
parent
aaff9087b6
commit
b0542c38f3
14 changed files with 123 additions and 128 deletions
2
AUTHORS
2
AUTHORS
|
@ -330,4 +330,4 @@ contributors (in addition to the above; based on Changelog)
|
||||||
Alexander Lyons Harkness
|
Alexander Lyons Harkness
|
||||||
Jakub Kiciński
|
Jakub Kiciński
|
||||||
Jean Delvare
|
Jean Delvare
|
||||||
|
Raphael Michel
|
||||||
|
|
23
configure.ac
23
configure.ac
|
@ -1324,7 +1324,7 @@ fi
|
||||||
|
|
||||||
dnl Python *********************************************************************
|
dnl Python *********************************************************************
|
||||||
missing_python=""
|
missing_python=""
|
||||||
AM_PATH_PYTHON([2.5], [
|
AM_PATH_PYTHON([3.5], [
|
||||||
AC_PATH_PROG(PYTHON_CONFIG, python$PYTHON_VERSION-config)
|
AC_PATH_PROG(PYTHON_CONFIG, python$PYTHON_VERSION-config)
|
||||||
if test x"$PYTHON_CONFIG" = x"" ; then
|
if test x"$PYTHON_CONFIG" = x"" ; then
|
||||||
AC_PATH_PROG(PYTHON_CONFIG, python-config)
|
AC_PATH_PROG(PYTHON_CONFIG, python-config)
|
||||||
|
@ -1340,11 +1340,15 @@ AM_PATH_PYTHON([2.5], [
|
||||||
missing_python="python-config"
|
missing_python="python-config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0, HAVE_PYGOBJ=yes, HAVE_PYGOBJ=no)
|
||||||
|
AC_SUBST(PYGOBJECT_LIBS)
|
||||||
|
AC_SUBST(PYGOBJECT_CFLAGS)
|
||||||
|
|
||||||
if test x"$HAVE_PYTHON" = xyes; then
|
if test x"$HAVE_PYTHON" = xyes; then
|
||||||
_save_libs="$LIBS"
|
_save_libs="$LIBS"
|
||||||
if test x"$platform_win32" = xno; then
|
if test x"$platform_win32" = xno; then
|
||||||
# libpython.so
|
# libpython.so
|
||||||
PYTHON_SHARED_LIB="libpython${PYTHON_VERSION}.so"
|
PYTHON_SHARED_LIB="libpython${PYTHON_VERSION}m.so"
|
||||||
AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl"])
|
AC_CHECK_LIB(dl, dlopen, [LIBS="-ldl"])
|
||||||
AC_MSG_CHECKING([whether to dlopen $PYTHON_SHARED_LIB works])
|
AC_MSG_CHECKING([whether to dlopen $PYTHON_SHARED_LIB works])
|
||||||
AC_RUN_IFELSE(
|
AC_RUN_IFELSE(
|
||||||
|
@ -1352,7 +1356,7 @@ AM_PATH_PYTHON([2.5], [
|
||||||
[#include <dlfcn.h>
|
[#include <dlfcn.h>
|
||||||
#define PYTHON_SO_FILE "${PYTHON_SHARED_LIB}"
|
#define PYTHON_SO_FILE "${PYTHON_SHARED_LIB}"
|
||||||
],
|
],
|
||||||
[if (!dlopen(PYTHON_SO_FILE, RTLD_NOW | RTLD_GLOBAL)) return 1; return 0;])
|
[if (!dlopen(PYTHON_SO_FILE, RTLD_NOW | RTLD_GLOBAL)) { return 1; } else { return 0; }])
|
||||||
],
|
],
|
||||||
[found_libpython_so="yes"],
|
[found_libpython_so="yes"],
|
||||||
[found_libpython_so="no"],
|
[found_libpython_so="no"],
|
||||||
|
@ -1368,12 +1372,6 @@ AM_PATH_PYTHON([2.5], [
|
||||||
fi
|
fi
|
||||||
LIBS="$_save_libs";
|
LIBS="$_save_libs";
|
||||||
fi
|
fi
|
||||||
if test x"$HAVE_PYTHON" = xyes; then
|
|
||||||
PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= 2.10.3, [AC_DEFINE(ENABLE_PYTHON, [1], [Enable Python support])], HAVE_PYTHON=no)
|
|
||||||
if test x"$HAVE_PYTHON" = xno; then
|
|
||||||
missing_python="pygtk-2.0 >= 2.10.3"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
], [
|
], [
|
||||||
HAVE_PYTHON=no
|
HAVE_PYTHON=no
|
||||||
missing_python="python interpreter"
|
missing_python="python interpreter"
|
||||||
|
@ -1381,8 +1379,8 @@ AM_PATH_PYTHON([2.5], [
|
||||||
AC_SUBST(PYTHON_SHARED_LIB)
|
AC_SUBST(PYTHON_SHARED_LIB)
|
||||||
AC_SUBST(PYTHON_CFLAGS)
|
AC_SUBST(PYTHON_CFLAGS)
|
||||||
AC_SUBST(PYTHON_LIBS)
|
AC_SUBST(PYTHON_LIBS)
|
||||||
AC_SUBST(PYGTK_CFLAGS)
|
AC_SUBST(PYGOBJECT_CFLAGS)
|
||||||
AC_SUBST(PYGTK_LIBS)
|
AC_SUBST(PYGOBJECT_LIBS)
|
||||||
|
|
||||||
dnl libnotify ******************************************************************
|
dnl libnotify ******************************************************************
|
||||||
PKG_CHECK_MODULES(libnotify, libnotify >= 0.4.3, HAVE_LIBNOTIFY=yes, HAVE_LIBNOTIFY=no)
|
PKG_CHECK_MODULES(libnotify, libnotify >= 0.4.3, HAVE_LIBNOTIFY=yes, HAVE_LIBNOTIFY=no)
|
||||||
|
@ -1824,6 +1822,9 @@ if test x"$enable_python_plugin" != xno; then
|
||||||
if test x"$HAVE_PYTHON" = xno; then
|
if test x"$HAVE_PYTHON" = xno; then
|
||||||
dependencies_missing="$missing_python $dependencies_missing"
|
dependencies_missing="$missing_python $dependencies_missing"
|
||||||
fi
|
fi
|
||||||
|
if test x"$HAVE_PYGOBJ" = xno; then
|
||||||
|
dependencies_missing="pygobject-3.0 $dependencies_missing"
|
||||||
|
fi
|
||||||
|
|
||||||
if test x"$dependencies_missing" = x; then
|
if test x"$dependencies_missing" = x; then
|
||||||
PLUGINS="$PLUGINS python"
|
PLUGINS="$PLUGINS python"
|
||||||
|
|
|
@ -224,6 +224,7 @@ static char *CONTRIBS_LIST[] = {
|
||||||
"Bram Metsch",
|
"Bram Metsch",
|
||||||
"Hanno Meyer-Thurow",
|
"Hanno Meyer-Thurow",
|
||||||
"George Michaelson",
|
"George Michaelson",
|
||||||
|
"Raphael Michel",
|
||||||
"Florian Mickler",
|
"Florian Mickler",
|
||||||
"Neill Miller",
|
"Neill Miller",
|
||||||
"Suzuki Mio",
|
"Suzuki Mio",
|
||||||
|
|
|
@ -40,7 +40,7 @@ python_la_LDFLAGS = \
|
||||||
-avoid-version -module \
|
-avoid-version -module \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(GTK_LIBS) \
|
$(GTK_LIBS) \
|
||||||
$(PYGTK_LIBS) \
|
$(PYGOBJECT_LIBS) \
|
||||||
$(PYTHON_LIBS)
|
$(PYTHON_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ python_la_CPPFLAGS = \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
$(GTK_CFLAGS) \
|
$(GTK_CFLAGS) \
|
||||||
$(ENCHANT_CFLAGS) \
|
$(ENCHANT_CFLAGS) \
|
||||||
|
$(PYGOBJECT_CFLAGS) \
|
||||||
$(PYTHON_CFLAGS) \
|
$(PYTHON_CFLAGS) \
|
||||||
$(PYGTK_CFLAGS) \
|
|
||||||
-DPYTHON_SHARED_LIB="\"$(PYTHON_SHARED_LIB)\"" \
|
-DPYTHON_SHARED_LIB="\"$(PYTHON_SHARED_LIB)\"" \
|
||||||
-DENABLE_PYTHON \
|
-DENABLE_PYTHON \
|
||||||
-fno-strict-aliasing
|
-fno-strict-aliasing
|
||||||
|
|
|
@ -38,7 +38,7 @@ static int Account_init(clawsmail_AccountObject *self, PyObject *args, PyObject
|
||||||
|
|
||||||
static void Account_dealloc(clawsmail_AccountObject* self)
|
static void Account_dealloc(clawsmail_AccountObject* self)
|
||||||
{
|
{
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObject *obj2)
|
static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObject *obj2)
|
||||||
|
@ -54,21 +54,21 @@ static int Account_compare(clawsmail_AccountObject *obj1, clawsmail_AccountObjec
|
||||||
static PyObject* Account_str(clawsmail_AccountObject *self)
|
static PyObject* Account_str(clawsmail_AccountObject *self)
|
||||||
{
|
{
|
||||||
if(self->account && self->account->account_name)
|
if(self->account && self->account->account_name)
|
||||||
return PyString_FromFormat("Account: %s", self->account->account_name);
|
return PyUnicode_FromFormat("Account: %s", self->account->account_name);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_account_name(clawsmail_AccountObject *self, void *closure)
|
static PyObject* get_account_name(clawsmail_AccountObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->account && self->account->account_name)
|
if(self->account && self->account->account_name)
|
||||||
return PyString_FromString(self->account->account_name);
|
return PyUnicode_FromString(self->account->account_name);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_address(clawsmail_AccountObject *self, void *closure)
|
static PyObject* get_address(clawsmail_AccountObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->account && self->account->address)
|
if(self->account && self->account->address)
|
||||||
return PyString_FromString(self->account->address);
|
return PyUnicode_FromString(self->account->address);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,7 @@ static PyGetSetDef Account_getset[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject clawsmail_AccountType = {
|
static PyTypeObject clawsmail_AccountType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /* ob_size*/
|
|
||||||
"clawsmail.Account", /* tp_name*/
|
"clawsmail.Account", /* tp_name*/
|
||||||
sizeof(clawsmail_AccountObject), /* tp_basicsize*/
|
sizeof(clawsmail_AccountObject), /* tp_basicsize*/
|
||||||
0, /* tp_itemsize*/
|
0, /* tp_itemsize*/
|
||||||
|
@ -102,7 +101,7 @@ static PyTypeObject clawsmail_AccountType = {
|
||||||
0, /* tp_print*/
|
0, /* tp_print*/
|
||||||
0, /* tp_getattr*/
|
0, /* tp_getattr*/
|
||||||
0, /* tp_setattr*/
|
0, /* tp_setattr*/
|
||||||
(cmpfunc)Account_compare, /* tp_compare*/
|
0, /* tp_compare*/
|
||||||
0, /* tp_repr*/
|
0, /* tp_repr*/
|
||||||
0, /* tp_as_number*/
|
0, /* tp_as_number*/
|
||||||
0, /* tp_as_sequence*/
|
0, /* tp_as_sequence*/
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
#define NO_IMPORT_PYGOBJECT
|
#define NO_IMPORT_PYGOBJECT
|
||||||
#include <pygobject.h>
|
#include <pygobject.h>
|
||||||
#define NO_IMPORT_PYGTK
|
|
||||||
#include <pygtk/pygtk.h>
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -325,9 +323,9 @@ static PyObject* get_folder_tree(PyObject *self, PyObject *args)
|
||||||
if(PyTuple_Size(args) == 0) {
|
if(PyTuple_Size(args) == 0) {
|
||||||
result = get_folder_tree_from_account_name(NULL);
|
result = get_folder_tree_from_account_name(NULL);
|
||||||
}
|
}
|
||||||
else if(PyString_Check(arg)){
|
else if(PyBytes_Check(arg)){
|
||||||
const char *str;
|
const char *str;
|
||||||
str = PyString_AsString(arg);
|
str = PyBytes_AsString(arg);
|
||||||
if(!str)
|
if(!str)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -904,21 +902,33 @@ static gboolean add_miscstuff(PyObject *module)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct PyModuleDef moduledef = {
|
||||||
|
PyModuleDef_HEAD_INIT,
|
||||||
|
"clawsmail",
|
||||||
|
"This module can be used to access some of Claws Mail's data structures\n"
|
||||||
|
"in order to extend or modify the user interface or automate repetitive tasks.\n"
|
||||||
|
"\n"
|
||||||
|
"Whenever possible, the interface works with standard GTK+ widgets\n"
|
||||||
|
"via the PyGTK bindings, so you can refer to the GTK+ / PyGTK documentation\n"
|
||||||
|
"to find out about all possible options.\n"
|
||||||
|
"\n"
|
||||||
|
"The interface to Claws Mail in this module is extended on a 'as-needed' basis.\n"
|
||||||
|
"If you're missing something specific, try contacting the author.",
|
||||||
|
0,
|
||||||
|
ClawsMailMethods,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC initclawsmail(void)
|
PyMODINIT_FUNC initclawsmail(void)
|
||||||
{
|
{
|
||||||
gboolean ok = TRUE;
|
gboolean ok = TRUE;
|
||||||
|
|
||||||
/* create module */
|
/* create module */
|
||||||
cm_module = Py_InitModule3("clawsmail", ClawsMailMethods,
|
|
||||||
"This module can be used to access some of Claws Mail's data structures\n"
|
cm_module = PyModule_Create(&moduledef);
|
||||||
"in order to extend or modify the user interface or automate repetitive tasks.\n"
|
|
||||||
"\n"
|
|
||||||
"Whenever possible, the interface works with standard GTK+ widgets\n"
|
|
||||||
"via the PyGTK bindings, so you can refer to the GTK+ / PyGTK documentation\n"
|
|
||||||
"to find out about all possible options.\n"
|
|
||||||
"\n"
|
|
||||||
"The interface to Claws Mail in this module is extended on a 'as-needed' basis.\n"
|
|
||||||
"If you're missing something specific, try contacting the author.");
|
|
||||||
|
|
||||||
/* add module member "compose_window" set to None */
|
/* add module member "compose_window" set to None */
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
@ -937,6 +947,7 @@ PyMODINIT_FUNC initclawsmail(void)
|
||||||
/* initialize misc things */
|
/* initialize misc things */
|
||||||
if(ok)
|
if(ok)
|
||||||
add_miscstuff(cm_module);
|
add_miscstuff(cm_module);
|
||||||
|
return cm_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ static void ComposeWindow_dealloc(clawsmail_ComposeWindowObject* self)
|
||||||
Py_XDECREF(self->text);
|
Py_XDECREF(self->text);
|
||||||
Py_XDECREF(self->replyinfo);
|
Py_XDECREF(self->replyinfo);
|
||||||
Py_XDECREF(self->fwdinfo);
|
Py_XDECREF(self->fwdinfo);
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flush_gtk_queue(void)
|
static void flush_gtk_queue(void)
|
||||||
|
@ -337,7 +337,7 @@ static PyObject* ComposeWindow_set_header_list(clawsmail_ComposeWindowObject *se
|
||||||
/* check that we got a list of tuples with two elements */
|
/* check that we got a list of tuples with two elements */
|
||||||
element = PyList_GET_ITEM(headerlist, iEl);
|
element = PyList_GET_ITEM(headerlist, iEl);
|
||||||
if(!element || !PyObject_TypeCheck(element, &PyTuple_Type) || (PyTuple_Size(element) != 2)) {
|
if(!element || !PyObject_TypeCheck(element, &PyTuple_Type) || (PyTuple_Size(element) != 2)) {
|
||||||
PyErr_SetString(PyExc_LookupError, "Argument to set_header_list() must be a list of tuples with two strings");
|
PyErr_SetString(PyExc_LookupError, "Argument to set_header_list() must be a list of tuples with two bytestrings");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,8 +345,8 @@ static PyObject* ComposeWindow_set_header_list(clawsmail_ComposeWindowObject *se
|
||||||
headerfield = PyTuple_GetItem(element, 0);
|
headerfield = PyTuple_GetItem(element, 0);
|
||||||
headercontent = PyTuple_GetItem(element, 1);
|
headercontent = PyTuple_GetItem(element, 1);
|
||||||
if(!headerfield || !headercontent
|
if(!headerfield || !headercontent
|
||||||
|| !PyObject_TypeCheck(headerfield, &PyString_Type) || !PyObject_TypeCheck(headercontent, &PyString_Type)) {
|
|| !PyObject_TypeCheck(headerfield, &PyBytes_Type) || !PyObject_TypeCheck(headercontent, &PyBytes_Type)) {
|
||||||
PyErr_SetString(PyExc_LookupError, "Argument to set_header_list() must be a list of tuples with two strings");
|
PyErr_SetString(PyExc_LookupError, "Argument to set_header_list() must be a list of tuples with two bytestrings");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,10 +381,10 @@ static PyObject* ComposeWindow_set_header_list(clawsmail_ComposeWindowObject *se
|
||||||
/* set header field */
|
/* set header field */
|
||||||
editable = GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(headerentry->combo)));
|
editable = GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(headerentry->combo)));
|
||||||
gtk_editable_delete_text(editable, 0, -1);
|
gtk_editable_delete_text(editable, 0, -1);
|
||||||
gtk_editable_insert_text(editable, PyString_AsString(headerfield), -1, &pos);
|
gtk_editable_insert_text(editable, PyBytes_AsString(headerfield), -1, &pos);
|
||||||
|
|
||||||
/* set header content */
|
/* set header content */
|
||||||
gtk_entry_set_text(GTK_ENTRY(headerentry->entry), PyString_AsString(headercontent));
|
gtk_entry_set_text(GTK_ENTRY(headerentry->entry), PyBytes_AsString(headercontent));
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
@ -438,7 +438,7 @@ static PyObject* ComposeWindow_save_message_to(clawsmail_ComposeWindowObject *se
|
||||||
if(!PyArg_ParseTuple(args, "O", &arg))
|
if(!PyArg_ParseTuple(args, "O", &arg))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if(PyString_Check(arg)) {
|
if(PyBytes_Check(arg)) {
|
||||||
GtkEditable *editable;
|
GtkEditable *editable;
|
||||||
gint pos;
|
gint pos;
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ static PyObject* ComposeWindow_save_message_to(clawsmail_ComposeWindowObject *se
|
||||||
|
|
||||||
editable = GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(self->compose->savemsg_combo)));
|
editable = GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(self->compose->savemsg_combo)));
|
||||||
gtk_editable_delete_text(editable, 0, -1);
|
gtk_editable_delete_text(editable, 0, -1);
|
||||||
gtk_editable_insert_text(editable, PyString_AsString(arg), -1, &pos);
|
gtk_editable_insert_text(editable, PyBytes_AsString(arg), -1, &pos);
|
||||||
}
|
}
|
||||||
else if(clawsmail_folder_check(arg)) {
|
else if(clawsmail_folder_check(arg)) {
|
||||||
GtkEditable *editable;
|
GtkEditable *editable;
|
||||||
|
@ -672,8 +672,7 @@ static PyGetSetDef ComposeWindow_getset[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject clawsmail_ComposeWindowType = {
|
static PyTypeObject clawsmail_ComposeWindowType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /*ob_size*/
|
|
||||||
"clawsmail.ComposeWindow", /*tp_name*/
|
"clawsmail.ComposeWindow", /*tp_name*/
|
||||||
sizeof(clawsmail_ComposeWindowObject), /*tp_basicsize*/
|
sizeof(clawsmail_ComposeWindowObject), /*tp_basicsize*/
|
||||||
0, /*tp_itemsize*/
|
0, /*tp_itemsize*/
|
||||||
|
|
|
@ -38,7 +38,7 @@ static int FolderProperties_init(clawsmail_FolderPropertiesObject *self, PyObjec
|
||||||
|
|
||||||
static void FolderProperties_dealloc(clawsmail_FolderPropertiesObject* self)
|
static void FolderProperties_dealloc(clawsmail_FolderPropertiesObject* self)
|
||||||
{
|
{
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_default_account(clawsmail_FolderPropertiesObject *self, void *closure)
|
static PyObject* get_default_account(clawsmail_FolderPropertiesObject *self, void *closure)
|
||||||
|
@ -61,8 +61,7 @@ static PyGetSetDef FolderProperties_getset[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject clawsmail_FolderPropertiesType = {
|
static PyTypeObject clawsmail_FolderPropertiesType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /* ob_size*/
|
|
||||||
"clawsmail.FolderProperties", /* tp_name*/
|
"clawsmail.FolderProperties", /* tp_name*/
|
||||||
sizeof(clawsmail_FolderPropertiesObject), /* tp_basicsize*/
|
sizeof(clawsmail_FolderPropertiesObject), /* tp_basicsize*/
|
||||||
0, /* tp_itemsize*/
|
0, /* tp_itemsize*/
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef struct {
|
||||||
static void Folder_dealloc(clawsmail_FolderObject* self)
|
static void Folder_dealloc(clawsmail_FolderObject* self)
|
||||||
{
|
{
|
||||||
Py_XDECREF(self->properties);
|
Py_XDECREF(self->properties);
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *kwds)
|
static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *kwds)
|
||||||
|
@ -83,7 +83,7 @@ static int Folder_init(clawsmail_FolderObject *self, PyObject *args, PyObject *k
|
||||||
|
|
||||||
static PyObject* Folder_str(clawsmail_FolderObject *self)
|
static PyObject* Folder_str(clawsmail_FolderObject *self)
|
||||||
{
|
{
|
||||||
return PyString_FromFormat("Folder: %s", self->folderitem->name);
|
return PyUnicode_FromFormat("Folder: %s", self->folderitem->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* Folder_get_identifier(clawsmail_FolderObject *self, PyObject *args)
|
static PyObject* Folder_get_identifier(clawsmail_FolderObject *self, PyObject *args)
|
||||||
|
@ -128,14 +128,14 @@ static PyObject* Folder_get_messages(clawsmail_FolderObject *self, PyObject *arg
|
||||||
static PyObject* get_name(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_name(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->folderitem && self->folderitem->name)
|
if(self->folderitem && self->folderitem->name)
|
||||||
return PyString_FromString(self->folderitem->name);
|
return PyUnicode_FromString(self->folderitem->name);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_mailbox_name(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_mailbox_name(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->folderitem && self->folderitem->folder && self->folderitem->folder->name)
|
if(self->folderitem && self->folderitem->folder && self->folderitem->folder->name)
|
||||||
return PyString_FromString(self->folderitem->folder->name);
|
return PyUnicode_FromString(self->folderitem->folder->name);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ static PyObject* get_identifier(clawsmail_FolderObject *self, void *closure)
|
||||||
id = folder_item_get_identifier(self->folderitem);
|
id = folder_item_get_identifier(self->folderitem);
|
||||||
if(id) {
|
if(id) {
|
||||||
PyObject *retval;
|
PyObject *retval;
|
||||||
retval = PyString_FromString(id);
|
retval = PyUnicode_FromString(id);
|
||||||
g_free(id);
|
g_free(id);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ static PyObject* get_path(clawsmail_FolderObject *self, void *closure)
|
||||||
path = folder_item_get_path(self->folderitem);
|
path = folder_item_get_path(self->folderitem);
|
||||||
if(path) {
|
if(path) {
|
||||||
PyObject *retval;
|
PyObject *retval;
|
||||||
retval = PyString_FromString(path);
|
retval = PyUnicode_FromString(path);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -187,70 +187,70 @@ static PyObject* get_properties(clawsmail_FolderObject *self, void *closure)
|
||||||
static PyObject* get_num_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->total_msgs);
|
return PyLong_FromLong(self->folderitem->total_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_new_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_new_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->new_msgs);
|
return PyLong_FromLong(self->folderitem->new_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_unread_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_unread_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->unread_msgs);
|
return PyLong_FromLong(self->folderitem->unread_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_marked_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_marked_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->marked_msgs);
|
return PyLong_FromLong(self->folderitem->marked_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_locked_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_locked_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->locked_msgs);
|
return PyLong_FromLong(self->folderitem->locked_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_unread_marked_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_unread_marked_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->unreadmarked_msgs);
|
return PyLong_FromLong(self->folderitem->unreadmarked_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_ignored_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_ignored_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->ignored_msgs);
|
return PyLong_FromLong(self->folderitem->ignored_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_watched_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_watched_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->watched_msgs);
|
return PyLong_FromLong(self->folderitem->watched_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_replied_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_replied_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->replied_msgs);
|
return PyLong_FromLong(self->folderitem->replied_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_num_forwarded_messages(clawsmail_FolderObject *self, void *closure)
|
static PyObject* get_num_forwarded_messages(clawsmail_FolderObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self && self->folderitem)
|
if(self && self->folderitem)
|
||||||
return PyInt_FromLong(self->folderitem->forwarded_msgs);
|
return PyLong_FromLong(self->folderitem->forwarded_msgs);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,8 +324,7 @@ static PyGetSetDef Folder_getset[] = {
|
||||||
|
|
||||||
|
|
||||||
static PyTypeObject clawsmail_FolderType = {
|
static PyTypeObject clawsmail_FolderType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /* ob_size*/
|
|
||||||
"clawsmail.Folder", /* tp_name*/
|
"clawsmail.Folder", /* tp_name*/
|
||||||
sizeof(clawsmail_FolderObject), /* tp_basicsize*/
|
sizeof(clawsmail_FolderObject), /* tp_basicsize*/
|
||||||
0, /* tp_itemsize*/
|
0, /* tp_itemsize*/
|
||||||
|
|
|
@ -41,20 +41,20 @@ static int Mailbox_init(clawsmail_MailboxObject *self, PyObject *args, PyObject
|
||||||
static void Mailbox_dealloc(clawsmail_MailboxObject* self)
|
static void Mailbox_dealloc(clawsmail_MailboxObject* self)
|
||||||
{
|
{
|
||||||
self->folder = NULL;
|
self->folder = NULL;
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* Mailbox_str(clawsmail_MailboxObject *self)
|
static PyObject* Mailbox_str(clawsmail_MailboxObject *self)
|
||||||
{
|
{
|
||||||
if(self->folder && self->folder->name)
|
if(self->folder && self->folder->name)
|
||||||
return PyString_FromFormat("Mailbox: %s", self->folder->name);
|
return PyUnicode_FromFormat("Mailbox: %s", self->folder->name);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_name(clawsmail_MailboxObject *self, void *closure)
|
static PyObject* get_name(clawsmail_MailboxObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->folder && self->folder->name)
|
if(self->folder && self->folder->name)
|
||||||
return PyString_FromString(self->folder->name);
|
return PyUnicode_FromString(self->folder->name);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ static PyGetSetDef Mailbox_getset[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyTypeObject clawsmail_MailboxType = {
|
static PyTypeObject clawsmail_MailboxType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /* ob_size*/
|
|
||||||
"clawsmail.Mailbox", /* tp_name*/
|
"clawsmail.Mailbox", /* tp_name*/
|
||||||
sizeof(clawsmail_MailboxObject), /* tp_basicsize*/
|
sizeof(clawsmail_MailboxObject), /* tp_basicsize*/
|
||||||
0, /* tp_itemsize*/
|
0, /* tp_itemsize*/
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef struct {
|
||||||
|
|
||||||
static void MessageInfo_dealloc(clawsmail_MessageInfoObject* self)
|
static void MessageInfo_dealloc(clawsmail_MessageInfoObject* self)
|
||||||
{
|
{
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MessageInfo_init(clawsmail_MessageInfoObject *self, PyObject *args, PyObject *kwds)
|
static int MessageInfo_init(clawsmail_MessageInfoObject *self, PyObject *args, PyObject *kwds)
|
||||||
|
@ -58,7 +58,7 @@ static PyObject* MessageInfo_str(clawsmail_MessageInfoObject *self)
|
||||||
gchar *Subject;
|
gchar *Subject;
|
||||||
From = self->msginfo->from ? self->msginfo->from : "";
|
From = self->msginfo->from ? self->msginfo->from : "";
|
||||||
Subject = self->msginfo->subject ? self->msginfo->subject : "";
|
Subject = self->msginfo->subject ? self->msginfo->subject : "";
|
||||||
return PyString_FromFormat("MessageInfo: %s / %s", From, Subject);
|
return PyUnicode_FromFormat("MessageInfo: %s / %s", From, Subject);
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
@ -229,35 +229,35 @@ static PyObject* get_header(PyObject *self, PyObject *args)
|
||||||
static PyObject* get_From(clawsmail_MessageInfoObject *self, void *closure)
|
static PyObject* get_From(clawsmail_MessageInfoObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->msginfo && self->msginfo->from)
|
if(self->msginfo && self->msginfo->from)
|
||||||
return PyString_FromString(self->msginfo->from);
|
return PyUnicode_FromString(self->msginfo->from);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_To(clawsmail_MessageInfoObject *self, void *closure)
|
static PyObject* get_To(clawsmail_MessageInfoObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->msginfo && self->msginfo->to)
|
if(self->msginfo && self->msginfo->to)
|
||||||
return PyString_FromString(self->msginfo->to);
|
return PyUnicode_FromString(self->msginfo->to);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_Cc(clawsmail_MessageInfoObject *self, void *closure)
|
static PyObject* get_Cc(clawsmail_MessageInfoObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->msginfo && self->msginfo->cc)
|
if(self->msginfo && self->msginfo->cc)
|
||||||
return PyString_FromString(self->msginfo->cc);
|
return PyUnicode_FromString(self->msginfo->cc);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_Subject(clawsmail_MessageInfoObject *self, void *closure)
|
static PyObject* get_Subject(clawsmail_MessageInfoObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->msginfo && self->msginfo->subject)
|
if(self->msginfo && self->msginfo->subject)
|
||||||
return PyString_FromString(self->msginfo->subject);
|
return PyUnicode_FromString(self->msginfo->subject);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject* get_MessageID(clawsmail_MessageInfoObject *self, void *closure)
|
static PyObject* get_MessageID(clawsmail_MessageInfoObject *self, void *closure)
|
||||||
{
|
{
|
||||||
if(self->msginfo && self->msginfo->msgid)
|
if(self->msginfo && self->msginfo->msgid)
|
||||||
return PyString_FromString(self->msginfo->msgid);
|
return PyUnicode_FromString(self->msginfo->msgid);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ static PyObject* get_FilePath(clawsmail_MessageInfoObject *self, void *closure)
|
||||||
filepath = procmsg_get_message_file_path(self->msginfo);
|
filepath = procmsg_get_message_file_path(self->msginfo);
|
||||||
if(filepath) {
|
if(filepath) {
|
||||||
PyObject *retval;
|
PyObject *retval;
|
||||||
retval = PyString_FromString(filepath);
|
retval = PyUnicode_FromString(filepath);
|
||||||
g_free(filepath);
|
g_free(filepath);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -426,8 +426,7 @@ static PyGetSetDef MessageInfo_getset[] = {
|
||||||
|
|
||||||
|
|
||||||
static PyTypeObject clawsmail_MessageInfoType = {
|
static PyTypeObject clawsmail_MessageInfoType = {
|
||||||
PyObject_HEAD_INIT(NULL)
|
PyVarObject_HEAD_INIT(NULL, 0)
|
||||||
0, /* ob_size*/
|
|
||||||
"clawsmail.MessageInfo", /* tp_name*/
|
"clawsmail.MessageInfo", /* tp_name*/
|
||||||
sizeof(clawsmail_MessageInfoObject), /* tp_basicsize*/
|
sizeof(clawsmail_MessageInfoObject), /* tp_basicsize*/
|
||||||
0, /* tp_itemsize*/
|
0, /* tp_itemsize*/
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#ifdef ENABLE_PYTHON
|
#ifdef ENABLE_PYTHON
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <pygobject.h>
|
#include <pygobject.h>
|
||||||
#include <pygtk/pygtk.h>
|
|
||||||
#endif // ENABLE_PYTHON
|
#endif // ENABLE_PYTHON
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
@ -82,7 +81,7 @@ capture_stdin(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
/* Return an empty string.
|
/* Return an empty string.
|
||||||
* This is what read() returns when hitting EOF. */
|
* This is what read() returns when hitting EOF. */
|
||||||
return PyString_FromString("");
|
return PyUnicode_FromString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -123,6 +122,27 @@ is_blacklisted(void)
|
||||||
}
|
}
|
||||||
#endif // ENABLE_PYTHON
|
#endif // ENABLE_PYTHON
|
||||||
|
|
||||||
|
static struct PyModuleDef moduledef = {
|
||||||
|
PyModuleDef_HEAD_INIT,
|
||||||
|
"parasite",
|
||||||
|
NULL,
|
||||||
|
-1,
|
||||||
|
parasite_python_methods,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
PyMODINIT_FUNC
|
||||||
|
parasite_python_module_init(void)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_PYTHON
|
||||||
|
return PyModule_Create(&moduledef);
|
||||||
|
#endif // ENABLE_PYTHON
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
parasite_python_init(char **error)
|
parasite_python_init(char **error)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +174,6 @@ parasite_python_init(char **error)
|
||||||
|
|
||||||
sigaction(SIGINT, &old_sigint, NULL);
|
sigaction(SIGINT, &old_sigint, NULL);
|
||||||
|
|
||||||
Py_InitModule("parasite", parasite_python_methods);
|
|
||||||
if(PyRun_SimpleString(
|
if(PyRun_SimpleString(
|
||||||
"import parasite\n"
|
"import parasite\n"
|
||||||
"import sys\n"
|
"import sys\n"
|
||||||
|
@ -185,41 +204,11 @@ parasite_python_init(char **error)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pygobject_init(-1, -1, -1)) {
|
pygtk = PyImport_ImportModule("gi");
|
||||||
dlclose(python_dlhandle);
|
|
||||||
python_dlhandle = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pygtk = PyImport_ImportModule("gtk");
|
if (pygtk == NULL)
|
||||||
|
|
||||||
if (pygtk != NULL)
|
|
||||||
{
|
{
|
||||||
PyObject *module_dict = PyModule_GetDict(pygtk);
|
*error = g_strdup("Parasite: Could not import gi");
|
||||||
PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This seems to be NULL when we're running a PyGTK program.
|
|
||||||
* We really need to find out why.
|
|
||||||
*/
|
|
||||||
if (cobject != NULL)
|
|
||||||
{
|
|
||||||
if (PyCObject_Check(cobject)) {
|
|
||||||
_PyGtk_API = (struct _PyGtk_FunctionStruct*)
|
|
||||||
PyCObject_AsVoidPtr(cobject);
|
|
||||||
}
|
|
||||||
#if PY_VERSION_HEX >= 0x02070000
|
|
||||||
else if (PyCapsule_IsValid(cobject, "gtk._gtk._PyGtk_API")) {
|
|
||||||
_PyGtk_API = (struct _PyGtk_FunctionStruct*)PyCapsule_GetPointer(cobject, "gtk._gtk._PyGtk_API");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else {
|
|
||||||
*error = g_strdup("Parasite: Could not find _PyGtk_API object");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*error = g_strdup("Parasite: Could not import gtk");
|
|
||||||
dlclose(python_dlhandle);
|
dlclose(python_dlhandle);
|
||||||
python_dlhandle = NULL;
|
python_dlhandle = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -294,7 +283,7 @@ parasite_python_run(const char *command,
|
||||||
if (obj != NULL && obj != Py_None) {
|
if (obj != NULL && obj != Py_None) {
|
||||||
PyObject *repr = PyObject_Repr(obj);
|
PyObject *repr = PyObject_Repr(obj);
|
||||||
if (repr != NULL) {
|
if (repr != NULL) {
|
||||||
char *string = PyString_AsString(repr);
|
char *string = PyBytes_AsString(repr);
|
||||||
|
|
||||||
if (stdout_logger != NULL) {
|
if (stdout_logger != NULL) {
|
||||||
stdout_logger(string, user_data);
|
stdout_logger(string, user_data);
|
||||||
|
|
|
@ -24,10 +24,12 @@
|
||||||
#define _GTKPARASITE_PYTHON_MODULE_H_
|
#define _GTKPARASITE_PYTHON_MODULE_H_
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
|
|
||||||
typedef void (*ParasitePythonLogger)(const char *text, gpointer user_data);
|
typedef void (*ParasitePythonLogger)(const char *text, gpointer user_data);
|
||||||
|
|
||||||
|
PyMODINIT_FUNC parasite_python_module_init(void);
|
||||||
int parasite_python_init(char **error);
|
int parasite_python_init(char **error);
|
||||||
void parasite_python_done(void);
|
void parasite_python_done(void);
|
||||||
void parasite_python_run(const char *command,
|
void parasite_python_run(const char *command,
|
||||||
|
|
|
@ -595,9 +595,9 @@ static PyObject *get_StringIO_instance(void)
|
||||||
PyObject *class_StringIO = NULL;
|
PyObject *class_StringIO = NULL;
|
||||||
PyObject *inst_StringIO = NULL;
|
PyObject *inst_StringIO = NULL;
|
||||||
|
|
||||||
module_StringIO = PyImport_ImportModule("cStringIO");
|
module_StringIO = PyImport_ImportModule("io");
|
||||||
if(!module_StringIO) {
|
if(!module_StringIO) {
|
||||||
debug_print("Error getting traceback: Could not import module cStringIO\n");
|
debug_print("Error getting traceback: Could not import module io\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ static char* get_exception_information(PyObject *inst_StringIO)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = g_strdup(PyString_AsString(result_getvalue));
|
retval = g_strdup(PyBytes_AsString(result_getvalue));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
@ -686,6 +686,10 @@ gint plugin_init(gchar **error)
|
||||||
if(!make_sure_directories_exist(error))
|
if(!make_sure_directories_exist(error))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
/* register moduke */
|
||||||
|
PyImport_AppendInittab("clawsmail", initclawsmail);
|
||||||
|
PyImport_AppendInittab("parasite", parasite_python_module_init);
|
||||||
|
|
||||||
/* initialize python interpreter */
|
/* initialize python interpreter */
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
|
|
||||||
|
@ -694,13 +698,6 @@ gint plugin_init(gchar **error)
|
||||||
* an error occurred. */
|
* an error occurred. */
|
||||||
inst_StringIO = get_StringIO_instance();
|
inst_StringIO = get_StringIO_instance();
|
||||||
|
|
||||||
/* initialize Claws Mail Python module */
|
|
||||||
initclawsmail();
|
|
||||||
if(PyErr_Occurred()) {
|
|
||||||
*error = get_exception_information(inst_StringIO);
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(PyRun_SimpleString("import clawsmail") == -1) {
|
if(PyRun_SimpleString("import clawsmail") == -1) {
|
||||||
*error = g_strdup("Error importing the clawsmail module");
|
*error = g_strdup("Error importing the clawsmail module");
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Reference in a new issue