1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Merge branch 'master' into plugins

Conflicts:
	.travis.yml
	Makefile.am
	configure-plugins
	configure.ac
	src/plugins/plugins.c
	src/plugins/plugins.h
	src/plugins/python_api.c
	src/plugins/python_plugins.c
This commit is contained in:
James Booth 2016-03-11 00:15:26 +00:00
commit 5b2390e20f
5 changed files with 104 additions and 8 deletions

View File

@ -3,8 +3,7 @@ install:
- lsb_release -a
- uname -a
- sudo apt-get update
- sudo apt-get -y install libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr2-dev libgpgme11-dev autoconf-archive expect-dev tcl-dev
- sudo apt-get -y install libtool python-dev lua5.2 liblua5.2-dev ruby-dev
- sudo apt-get -y install libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr2-dev libgpgme11-dev autoconf-archive expect-dev tcl-dev libtool python-dev lua5.2 liblua5.2-dev ruby-dev
- git clone git://github.com/boothj5/libmesode.git
- cd libmesode
- mkdir m4

View File

@ -42,6 +42,9 @@ AS_IF([test "x$PLATFORM" = xcygwin],
AS_IF([test "x$PLATFORM" = xosx],
[AC_DEFINE([PLATFORM_OSX], [1], [OSx])])
### Environment variables
AC_ARG_VAR([PYTHON_FRAMEWORK], [Set base directory for Python Framework])
### Options
AC_ARG_ENABLE([notifications],
[AS_HELP_STRING([--enable-notifications], [enable desktop notifications])])
@ -131,6 +134,11 @@ fi
if test "x$enable_plugins" = xno; then
AM_CONDITIONAL([BUILD_PYTHON_API], [false])
elif test "x$enable_python_plugins" != xno; then
AS_IF([test "x$PLATFORM" = xosx], [
AS_IF([test "x$PYTHON_FRAMEWORK" = x], [ PYTHON_FRAMEWORK="/Library/Frameworks/Python.framework" ])
AC_MSG_NOTICE([Symlinking Python.framework to $PYTHON_FRAMEWORK])
rm -f Python.framework
ln -s $PYTHON_FRAMEWORK Python.framework ])
AC_CHECK_PROG(PYTHON_CONFIG_EXISTS, python-config, yes, no)
if test "$PYTHON_CONFIG_EXISTS" == "yes"; then
AX_PYTHON_DEVEL
@ -144,6 +152,7 @@ elif test "x$enable_python_plugins" != xno; then
AC_MSG_NOTICE([Python development package not found, Python plugin support disabled.])
fi
fi
AS_IF([test "x$PLATFORM" = xosx], [rm -f Python.framework])
else
AM_CONDITIONAL([BUILD_PYTHON_API], [false])
fi
@ -334,10 +343,10 @@ AC_CHECK_HEADERS([ncurses.h], [], [])
AM_CFLAGS="-Wall -Wno-deprecated-declarations"
AS_IF([test "x$PACKAGE_STATUS" = xdevelopment],
[AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"])
AM_LDFLAGS="$AM_LDFLAGS $PYTHON_LDFLAGS $RUBY_LDFLAGS $LUA_LIB -export-dynamic"
AM_LDFLAGS="$AM_LDFLAGS $RUBY_LDFLAGS $LUA_LIB -export-dynamic"
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $PYTHON_CPPFLAGS $RUBY_CFLAGS $LUA_INCLUDE"
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\""
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $RUBY_LIBS $LIBS"
LIBS="$glib_LIBS $curl_LIBS $libnotify_LIBS $PYTHON_LIBS $PYTHON_LDFLAGS $RUBY_LIBS $LIBS"
AC_SUBST(AM_LDFLAGS)
AC_SUBST(AM_CFLAGS)

View File

@ -130,6 +130,12 @@ main(int argc, char **argv)
g_print("C plugins: Disabled\n");
#endif
#ifdef PROF_HAVE_PYTHON
g_print("Python plugins: Enabled\n");
#else
g_print("Python plugins: Disabled\n");
#endif
return 0;
}

View File

@ -45,7 +45,10 @@
static PyObject*
python_api_cons_alert(PyObject *self, PyObject *args)
{
allow_python_threads();
api_cons_alert();
disable_python_threads();
return Py_BuildValue("");
}
@ -56,7 +59,10 @@ python_api_cons_show(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
allow_python_threads();
api_cons_show(message);
disable_python_threads();
return Py_BuildValue("");
}
@ -70,7 +76,24 @@ python_api_cons_show_themed(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "zzzs", &group, &key, &def, &message)) {
return Py_BuildValue("");
}
allow_python_threads();
api_cons_show_themed(group, key, def, message);
disable_python_threads();
return Py_BuildValue("");
}
static PyObject*
python_api_cons_bad_cmd_usage(PyObject *self, PyObject *args)
{
const char *cmd = NULL;
if (!PyArg_ParseTuple(args, "s", &cmd)) {
return Py_BuildValue("");
}
allow_python_threads();
api_cons_bad_cmd_usage(cmd);
disable_python_threads();
return Py_BuildValue("");
}
@ -133,8 +156,10 @@ python_api_register_command(PyObject *self, PyObject *args)
}
c_examples[len] = NULL;
allow_python_threads();
api_register_command(command_name, min_args, max_args, c_synopsis,
description, c_arguments, c_examples, p_callback, python_command_callback);
disable_python_threads();
}
return Py_BuildValue("");
@ -151,7 +176,9 @@ python_api_register_timed(PyObject *self, PyObject *args)
}
if (p_callback && PyCallable_Check(p_callback)) {
allow_python_threads();
api_register_timed(p_callback, interval_seconds, python_timed_callback);
disable_python_threads();
}
return Py_BuildValue("");
@ -178,7 +205,10 @@ python_api_register_ac(PyObject *self, PyObject *args)
}
c_items[len] = NULL;
allow_python_threads();
autocompleters_add(key, c_items);
disable_python_threads();
return Py_BuildValue("");
}
@ -193,7 +223,9 @@ python_api_notify(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
allow_python_threads();
api_notify(message, category, timeout_ms);
disable_python_threads();
return Py_BuildValue("");
}
@ -206,7 +238,9 @@ python_api_send_line(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
allow_python_threads();
api_send_line(line);
disable_python_threads();
return Py_BuildValue("");
}
@ -214,7 +248,9 @@ python_api_send_line(PyObject *self, PyObject *args)
static PyObject *
python_api_get_current_recipient(PyObject *self, PyObject *args)
{
allow_python_threads();
char *recipient = api_get_current_recipient();
disable_python_threads();
if (recipient) {
return Py_BuildValue("s", recipient);
} else {
@ -225,7 +261,9 @@ python_api_get_current_recipient(PyObject *self, PyObject *args)
static PyObject *
python_api_get_current_muc(PyObject *self, PyObject *args)
{
allow_python_threads();
char *room = api_get_current_muc();
disable_python_threads();
if (room) {
return Py_BuildValue("s", room);
} else {
@ -233,6 +271,19 @@ python_api_get_current_muc(PyObject *self, PyObject *args)
}
}
static PyObject*
python_api_current_win_is_console(PyObject *self, PyObject *args)
{
allow_python_threads();
int res = api_current_win_is_console();
disable_python_threads();
if (res) {
return Py_BuildValue("O", Py_True);
} else {
return Py_BuildValue("O", Py_False);
}
}
static PyObject *
python_api_log_debug(PyObject *self, PyObject *args)
{
@ -240,7 +291,10 @@ python_api_log_debug(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
allow_python_threads();
api_log_debug(message);
disable_python_threads();
return Py_BuildValue("");
}
@ -251,7 +305,11 @@ python_api_log_info(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
allow_python_threads();
api_log_info(message);
disable_python_threads();
return Py_BuildValue("");
}
@ -262,7 +320,11 @@ python_api_log_warning(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
allow_python_threads();
api_log_warning(message);
disable_python_threads();
return Py_BuildValue("");
}
@ -273,7 +335,10 @@ python_api_log_error(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &message)) {
return Py_BuildValue("");
}
allow_python_threads();
api_log_error(message);
disable_python_threads();
return Py_BuildValue("");
}
@ -285,7 +350,11 @@ python_api_win_exists(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
if (api_win_exists(tag)) {
allow_python_threads();
gboolean exists = api_win_exists(tag);
disable_python_threads();
if (exists) {
return Py_BuildValue("i", 1);
} else {
return Py_BuildValue("i", 0);
@ -303,7 +372,9 @@ python_api_win_create(PyObject *self, PyObject *args)
}
if (p_callback && PyCallable_Check(p_callback)) {
allow_python_threads();
api_win_create(tag, p_callback, NULL, python_window_callback);
disable_python_threads();
}
return Py_BuildValue("");
@ -318,7 +389,10 @@ python_api_win_focus(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
allow_python_threads();
api_win_focus(tag);
disable_python_threads();
return Py_BuildValue("");
}
@ -332,7 +406,10 @@ python_api_win_show(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
allow_python_threads();
api_win_show(tag, line);
disable_python_threads();
return Py_BuildValue("");
}
@ -349,7 +426,10 @@ python_api_win_show_themed(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
allow_python_threads();
api_win_show_themed(tag, group, key, def, line);
disable_python_threads();
return Py_BuildValue("");
}
@ -424,6 +504,7 @@ static PyMethodDef apiMethods[] = {
{ "cons_alert", python_api_cons_alert, METH_NOARGS, "Highlight the console window in the status bar." },
{ "cons_show", python_api_cons_show, METH_VARARGS, "Print a line to the console." },
{ "cons_show_themed", python_api_cons_show_themed, METH_VARARGS, "Print a themed line to the console" },
{ "cons_bad_cmd_usage", python_api_cons_bad_cmd_usage, METH_VARARGS, "Show invalid command message in console" },
{ "register_command", python_api_register_command, METH_VARARGS, "Register a command." },
{ "register_timed", python_api_register_timed, METH_VARARGS, "Register a timed function." },
{ "register_ac", python_api_register_ac, METH_VARARGS, "Register an autocompleter." },
@ -431,6 +512,7 @@ static PyMethodDef apiMethods[] = {
{ "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
{ "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
{ "get_current_muc", python_api_get_current_muc, METH_VARARGS, "Return the jid of the room of the current window." },
{ "current_win_is_console", python_api_current_win_is_console, METH_VARARGS, "Returns whether the current window is the console." },
{ "log_debug", python_api_log_debug, METH_VARARGS, "Log a debug message" },
{ "log_info", python_api_log_info, METH_VARARGS, "Log an info message" },
{ "log_warning", python_api_log_warning, METH_VARARGS, "Log a warning message" },

View File

@ -42,18 +42,18 @@
#include "plugins/python_plugins.h"
#include "ui/ui.h"
//static PyThreadState *thread_state;
static PyThreadState *thread_state;
void
allow_python_threads()
{
// thread_state = PyEval_SaveThread();
thread_state = PyEval_SaveThread();
}
void
disable_python_threads()
{
// PyEval_RestoreThread(thread_state);
PyEval_RestoreThread(thread_state);
}
void