Commit 102cab76 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Hand-written version of linphone_core_iterate() in the Python wrapper.

It adds a loop to peek Windows messages to prevent a deadlock in the
MoveWindow function.
parent 9c3f4771
......@@ -115,6 +115,7 @@ blacklisted_functions = [
'lp_config_section_to_dict'
]
hand_written_functions = [
'linphone_core_iterate',
'linphone_core_new',
'linphone_core_new_with_config'
]
......
......@@ -177,3 +177,26 @@ static PyObject * pylinphone_Core_class_method_new_with_config(PyObject *cls, Py
Py_DECREF(self);
return pyret;
}
static PyObject * pylinphone_Core_instance_method_iterate(PyObject *self, PyObject *args) {
LinphoneCore *native_ptr = pylinphone_Core_get_native_ptr(self);
if (native_ptr == NULL) {
PyErr_SetString(PyExc_TypeError, "Invalid linphone.Core instance");
return NULL;
}
pylinphone_trace(1, "[PYLINPHONE] >>> %s(%p [%p])", __FUNCTION__, self, native_ptr);
linphone_core_iterate(native_ptr);
#ifdef WIN32
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, 1)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
#endif
pylinphone_trace(-1, "[PYLINPHONE] <<< %s -> None", __FUNCTION__);
Py_RETURN_NONE;
}
......@@ -701,6 +701,7 @@ class LinphoneModule(object):
c['class_has_user_data'] = False
c['class_type_methods'] = []
c['class_type_hand_written_methods'] = []
c['class_instance_hand_written_methods'] = []
c['class_object_members'] = ''
if c['class_name'] == 'Core':
c['class_object_members'] = "\tPyObject *vtable_dict;"
......@@ -738,13 +739,15 @@ class LinphoneModule(object):
method_name = xml_instance_method.get('name')
if method_name in blacklisted_functions:
continue
method_name = method_name.replace(c['class_c_function_prefix'], '')
if method_name in self.internal_instance_method_names:
continue
m = {}
m['method_name'] = method_name
m['method_xml_node'] = xml_instance_method
c['class_instance_methods'].append(m)
m['method_name'] = method_name.replace(c['class_c_function_prefix'], '')
if method_name in hand_written_functions:
c['class_instance_hand_written_methods'].append(m)
else:
m['method_xml_node'] = xml_instance_method
c['class_instance_methods'].append(m)
c['class_properties'] = []
xml_properties = xml_class.findall("./properties/property")
for xml_property in xml_properties:
......
......@@ -22,6 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <linphone/linphonecore_utils.h>
#include <stdarg.h>
#ifdef WIN32
#include <windows.h>
#endif
#ifdef _MSC_VER
#define PYLINPHONE_INLINE __inline
......@@ -53,6 +56,9 @@ static PyObject * pylinphone_{{class_name}}_new_from_native_ptr(PyTypeObject *ty
{{#class_type_hand_written_methods}}
static PyObject * pylinphone_{{class_name}}_class_method_{{method_name}}(PyObject *cls, PyObject *args);
{{/class_type_hand_written_methods}}
{{#class_instance_hand_written_methods}}
static PyObject * pylinphone_{{class_name}}_instance_method_{{method_name}}(PyObject *self, PyObject *args);
{{/class_instance_hand_written_methods}}
{{/classes}}
{{#events}}
......@@ -103,6 +109,9 @@ static PyMethodDef pylinphone_{{class_name}}_instance_methods[] = {
{ "{{method_name}}", pylinphone_{{class_name}}_class_method_{{method_name}}, METH_VARARGS | METH_CLASS, "" },
{{/class_type_methods}}
/* Instance methods */
{{#class_instance_hand_written_methods}}
{ "{{method_name}}", pylinphone_{{class_name}}_instance_method_{{method_name}}, METH_VARARGS, "" },
{{/class_instance_hand_written_methods}}
{{#class_instance_methods}}
{ "{{method_name}}", pylinphone_{{class_name}}_instance_method_{{method_name}}, METH_VARARGS, "" },
{{/class_instance_methods}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment