1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Started adding ruby api

This commit is contained in:
James Booth 2013-08-18 16:20:52 +01:00
parent 722bbfad23
commit a1a01b8cd4
28 changed files with 528 additions and 74 deletions

5
.gitignore vendored
View File

@ -18,6 +18,7 @@ Makefile.in
aclocal.m4 aclocal.m4
autom4te.cache/ autom4te.cache/
src/config.h src/config.h
src/prof_config.h
src/config.h.in src/config.h.in
config.status config.status
configure configure
@ -30,3 +31,7 @@ core
bugs/ bugs/
*.pyc *.pyc
TODO TODO
_configs.sed
gource.sh
*_fingerprints.txt
*_key.txt

View File

@ -26,8 +26,10 @@ profanity_SOURCES = \
src/plugins/api.h src/plugins/api.c \ src/plugins/api.h src/plugins/api.c \
src/plugins/callbacks.h src/plugins/callbacks.c \ src/plugins/callbacks.h src/plugins/callbacks.c \
src/plugins/python_plugins.h src/plugins/python_plugins.c \ src/plugins/python_plugins.h src/plugins/python_plugins.c \
src/plugins/python_api.h src/plugins/python_api.c \
src/plugins/c_plugins.h src/plugins/c_plugins.c \ src/plugins/c_plugins.h src/plugins/c_plugins.c \
src/plugins/python_api.h src/plugins/python_api.c src/plugins/ruby_plugins.h src/plugins/ruby_plugins.c \
src/plugins/ruby_api.h src/plugins/ruby_api.c
TESTS = tests/testsuite TESTS = tests/testsuite
check_PROGRAMS = tests/testsuite check_PROGRAMS = tests/testsuite
@ -60,6 +62,8 @@ tests_testsuite_SOURCES = \
src/plugins/python_plugins.h src/plugins/python_plugins.c \ src/plugins/python_plugins.h src/plugins/python_plugins.c \
src/plugins/c_plugins.h src/plugins/c_plugins.c \ src/plugins/c_plugins.h src/plugins/c_plugins.c \
src/plugins/python_api.h src/plugins/python_api.c \ src/plugins/python_api.h src/plugins/python_api.c \
src/plugins/ruby_plugins.h src/plugins/ruby_plugins.c \
src/plugins/ruby_api.h src/plugins/ruby_api.c \
tests/test_roster.c tests/test_common.c tests/test_history.c \ tests/test_roster.c tests/test_common.c tests/test_history.c \
tests/test_autocomplete.c tests/testsuite.c tests/test_parser.c \ tests/test_autocomplete.c tests/testsuite.c tests/test_parser.c \
tests/test_jid.c tests/test_jid.c

View File

@ -9,6 +9,7 @@ AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign subdir-objects]) AM_INIT_AUTOMAKE([foreign subdir-objects])
AX_PREFIX_CONFIG_H([src/prof_config.h], [PROF], [src/config.h])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
@ -88,12 +89,19 @@ if test "x$enable_notifications" != xno; then
fi fi
# Default parameters # Default parameters
AM_CFLAGS="-Wall -I/usr/include/python2.7 -I/usr/include/python2.7 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -L/usr/lib/python2.7/config -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions" AM_CFLAGS="-Wall"
# Python
AM_CFLAGS="$AM_CFLAGS -I/usr/include/python2.7 -I/usr/include/python2.7 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -L/usr/lib/python2.7/config -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions"
# Ruby
AM_CFLAGS="$AM_CFLAGS -I/usr/lib/ruby/1.8/x86_64-linux -L/usr/lib/ruby/1.8/x86_64-linux"
if test "x$PACKAGE_STATUS" = xdevelopment; then if test "x$PACKAGE_STATUS" = xdevelopment; then
# AM_CFLAGS="$AM_CFLAGS -Wunused -Werror" # AM_CFLAGS="$AM_CFLAGS -Wunused -Werror"
AM_CFLAGS="$AM_CFLAGS -Wunused" AM_CFLAGS="$AM_CFLAGS -Wunused"
fi fi
LIBS="$LIBS $DEPS_LIBS $NOTIFY_LIBS -lpthread -ldl -lutil -lm -lpython2.7" LIBS="$LIBS $DEPS_LIBS $NOTIFY_LIBS -lpthread -ldl -lutil -lm -lpython2.7 -lruby1.8"
AM_CPPFLAGS="$DEPS_CFLAGS $NOTIFY_CFLAGS" AM_CPPFLAGS="$DEPS_CFLAGS $NOTIFY_CFLAGS"

15
plugins/ruby-test.rb Normal file
View File

@ -0,0 +1,15 @@
module RubyTest
include prof
prof_version = ""
prof_status = ""
def prof_init(version, status)
prof_version = version
prof_status = status
end
def prof_on_start()
prof.cons_show("RubyTest: " + prof_version + " " + prof_status)
end
end

View File

@ -19,7 +19,7 @@
* along with Profanity. If not, see <http://www.gnu.org/licenses/>. * along with Profanity. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
@ -269,7 +269,7 @@ release_is_new(char *found_version)
{ {
int curr_maj, curr_min, curr_patch, found_maj, found_min, found_patch; int curr_maj, curr_min, curr_patch, found_maj, found_min, found_patch;
int parse_curr = sscanf(PACKAGE_VERSION, "%d.%d.%d", &curr_maj, &curr_min, int parse_curr = sscanf(PROF_PACKAGE_VERSION, "%d.%d.%d", &curr_maj, &curr_min,
&curr_patch); &curr_patch);
int parse_found = sscanf(found_version, "%d.%d.%d", &found_maj, &found_min, int parse_found = sscanf(found_version, "%d.%d.%d", &found_maj, &found_min,
&found_patch); &found_patch);

View File

@ -20,15 +20,15 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -23,12 +23,12 @@
#ifndef PREFERENCES_H #ifndef PREFERENCES_H
#define PREFERENCES_H #define PREFERENCES_H
#include "config.h" #include "prof_config.h"
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -20,15 +20,15 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -23,12 +23,12 @@
#ifndef THEME_H #ifndef THEME_H
#define THEME_H #define THEME_H
#include "config.h" #include "prof_config.h"
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -22,7 +22,7 @@
#include <glib.h> #include <glib.h>
#include "config.h" #include "prof_config.h"
#include "profanity.h" #include "profanity.h"
@ -55,8 +55,8 @@ main(int argc, char **argv)
g_option_context_free(context); g_option_context_free(context);
if (version == TRUE) { if (version == TRUE) {
g_print("Profanity, version %s\n", PACKAGE_VERSION); g_print("Profanity, version %s\n", PROF_PACKAGE_VERSION);
g_print("Copyright (C) 2012, 2013 James Booth <%s>.\n", PACKAGE_BUGREPORT); g_print("Copyright (C) 2012, 2013 James Booth <%s>.\n", PROF_PACKAGE_BUGREPORT);
g_print("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"); g_print("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
g_print("\n"); g_print("\n");
g_print("This is free software; you are free to change and redistribute it.\n"); g_print("This is free software; you are free to change and redistribute it.\n");

View File

@ -23,9 +23,11 @@
#include "config/preferences.h" #include "config/preferences.h"
#include "plugins/callbacks.h" #include "plugins/callbacks.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"
#include "plugins/python_api.h"
#include "plugins/python_plugins.h" #include "plugins/python_plugins.h"
#include "plugins/c_plugins.h" #include "plugins/c_plugins.h"
#include "plugins/python_api.h"
#include "plugins/ruby_plugins.h"
#include "plugins/ruby_api.h"
#include "ui/ui.h" #include "ui/ui.h"
@ -37,7 +39,8 @@ plugins_init(void)
{ {
plugins = NULL; plugins = NULL;
python_init(); python_env_init();
ruby_env_init();
// load plugins // load plugins
gchar **plugins_load = prefs_get_plugins(); gchar **plugins_load = prefs_get_plugins();
@ -46,6 +49,7 @@ plugins_init(void)
for (i = 0; i < g_strv_length(plugins_load); i++) for (i = 0; i < g_strv_length(plugins_load); i++)
{ {
gchar *filename = plugins_load[i]; gchar *filename = plugins_load[i];
ProfPlugin *plugin = NULL;
if (g_str_has_suffix(filename, ".py")) { if (g_str_has_suffix(filename, ".py")) {
ProfPlugin *plugin = python_plugin_create(filename); ProfPlugin *plugin = python_plugin_create(filename);
if (plugin != NULL) { if (plugin != NULL) {
@ -61,6 +65,12 @@ plugins_init(void)
plugins = g_slist_append(plugins, plugin); plugins = g_slist_append(plugins, plugin);
cons_show("Loaded C plugin: %s", filename); cons_show("Loaded C plugin: %s", filename);
} }
} else if (g_str_has_suffix(filename, ".rb")) {
ProfPlugin *plugin = ruby_plugin_create(filename);
if (plugin != NULL) {
plugins = g_slist_append(plugins, plugin);
cons_show("Loaded Ruby plugin: %s", filename);
}
} }
} }
@ -68,8 +78,7 @@ plugins_init(void)
GSList *curr = plugins; GSList *curr = plugins;
while (curr != NULL) { while (curr != NULL) {
ProfPlugin *plugin = curr->data; ProfPlugin *plugin = curr->data;
plugin->init_func(plugin, PROF_PACKAGE_VERSION, PROF_PACKAGE_STATUS);
plugin->init_func(plugin, PACKAGE_VERSION, PACKAGE_STATUS);
// TODO well, it should be more of a generic check error here // TODO well, it should be more of a generic check error here
python_check_error(); python_check_error();
curr = g_slist_next(curr); curr = g_slist_next(curr);

View File

@ -23,7 +23,7 @@
#ifndef PYTHON_API_H #ifndef PYTHON_API_H
#define PYTHON_API_H #define PYTHON_API_H
void python_init(void); void python_env_init(void);
void python_api_init(void); void python_api_init(void);
void python_shutdown(void); void python_shutdown(void);

View File

@ -31,7 +31,7 @@
#include "ui/ui.h" #include "ui/ui.h"
void void
python_init(void) python_env_init(void)
{ {
Py_Initialize(); Py_Initialize();
python_check_error(); python_check_error();

183
src/plugins/ruby_api.c Normal file
View File

@ -0,0 +1,183 @@
/*
* ruby_api.c
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity 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.
*
* Profanity 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 Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <Python.h>
#include <ruby.h>
#include <glib.h>
#include "plugins/api.h"
#include "plugins/ruby_api.h"
#include "plugins/callbacks.h"
static PyObject*
ruby_api_cons_alert(PyObject *self, PyObject *args)
{
api_cons_alert();
return Py_BuildValue("");
}
static VALUE
ruby_api_cons_show(VALUE self, const char * const message)
{
if (message != NULL) {
api_cons_show(message);
}
return self;
}
static PyObject*
ruby_api_register_command(PyObject *self, PyObject *args)
{
const char *command_name = NULL;
int min_args = 0;
int max_args = 0;
const char *usage = NULL;
const char *short_help = NULL;
const char *long_help = NULL;
PyObject *p_callback = NULL;
if (!PyArg_ParseTuple(args, "siisssO", &command_name, &min_args, &max_args,
&usage, &short_help, &long_help, &p_callback)) {
return NULL;
}
if (p_callback && PyCallable_Check(p_callback)) {
api_register_command(command_name, min_args, max_args, usage,
short_help, long_help, p_callback, ruby_command_callback);
}
return Py_BuildValue("");
}
static PyObject *
ruby_api_register_timed(PyObject *self, PyObject *args)
{
PyObject *p_callback = NULL;
int interval_seconds = 0;
if (!PyArg_ParseTuple(args, "Oi", &p_callback, &interval_seconds)) {
return NULL;
}
if (p_callback && PyCallable_Check(p_callback)) {
api_register_timed(p_callback, interval_seconds, ruby_timed_callback);
}
return Py_BuildValue("");
}
static PyObject*
ruby_api_notify(PyObject *self, PyObject *args)
{
const char *message = NULL;
const char *category = NULL;
int timeout_ms = 5000;
if (!PyArg_ParseTuple(args, "sis", &message, &timeout_ms, &category)) {
return NULL;
}
api_notify(message, category, timeout_ms);
return Py_BuildValue("");
}
static PyObject*
ruby_api_send_line(PyObject *self, PyObject *args)
{
char *line = NULL;
if (!PyArg_ParseTuple(args, "s", &line)) {
return NULL;
}
api_send_line(line);
return Py_BuildValue("");
}
static PyObject *
ruby_api_get_current_recipient(PyObject *self, PyObject *args)
{
char *recipient = api_get_current_recipient();
if (recipient != NULL) {
return Py_BuildValue("s", recipient);
} else {
return Py_BuildValue("");
}
}
void
ruby_command_callback(PluginCommand *command, gchar **args)
{
PyObject *p_args = NULL;
int num_args = g_strv_length(args);
if (num_args == 0) {
if (command->max_args == 1) {
p_args = Py_BuildValue("(O)", Py_BuildValue(""));
PyObject_CallObject(command->callback, p_args);
Py_XDECREF(p_args);
} else {
PyObject_CallObject(command->callback, p_args);
}
} else if (num_args == 1) {
p_args = Py_BuildValue("(s)", args[0]);
PyObject_CallObject(command->callback, p_args);
Py_XDECREF(p_args);
} else if (num_args == 2) {
p_args = Py_BuildValue("ss", args[0], args[1]);
PyObject_CallObject(command->callback, p_args);
Py_XDECREF(p_args);
} else if (num_args == 3) {
p_args = Py_BuildValue("sss", args[0], args[1], args[2]);
PyObject_CallObject(command->callback, p_args);
Py_XDECREF(p_args);
} else if (num_args == 4) {
p_args = Py_BuildValue("ssss", args[0], args[1], args[2], args[3]);
PyObject_CallObject(command->callback, p_args);
Py_XDECREF(p_args);
} else if (num_args == 5) {
p_args = Py_BuildValue("sssss", args[0], args[1], args[2], args[3], args[4]);
PyObject_CallObject(command->callback, p_args);
Py_XDECREF(p_args);
}
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
}
}
void
ruby_timed_callback(PluginTimedFunction *timed_function)
{
PyObject_CallObject(timed_function->callback, NULL);
}
static VALUE prof_module;
void
ruby_api_init(void)
{
prof_module = rb_define_module("prof");
rb_define_module_function(prof_module, "cons_show", RUBY_METHOD_FUNC(ruby_api_cons_show), 1);
}

33
src/plugins/ruby_api.h Normal file
View File

@ -0,0 +1,33 @@
/*
* ruby_api.h
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity 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.
*
* Profanity 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 Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef RUBY_API_H
#define RUBY_API_H
void ruby_env_init(void);
void ruby_api_init(void);
void ruby_shutdown(void);
void ruby_command_callback(PluginCommand *command, gchar **args);
void ruby_timed_callback(PluginTimedFunction *timed_function);
#endif

155
src/plugins/ruby_plugins.c Normal file
View File

@ -0,0 +1,155 @@
/*
* ruby_plugins.c
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity 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.
*
* Profanity 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 Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <Python.h>
#include <ruby.h>
#include "config/preferences.h"
#include "plugins/api.h"
#include "plugins/callbacks.h"
#include "plugins/plugins.h"
#include "plugins/ruby_api.h"
#include "plugins/ruby_plugins.h"
#include "ui/ui.h"
void
ruby_env_init(void)
{
ruby_init();
ruby_check_error();
ruby_api_init();
ruby_check_error();
// TODO change to use XDG spec
GString *path = g_string_new(Py_GetPath());
g_string_append(path, ":./plugins/");
PySys_SetPath(path->str);
ruby_check_error();
g_string_free(path, TRUE);
}
ProfPlugin *
ruby_plugin_create(const char * const filename)
{
gchar *module_name = g_strndup(filename, strlen(filename) - 3);
PyObject *p_module = PyImport_ImportModule(module_name);
ruby_check_error();
if (p_module != NULL) {
ProfPlugin *plugin = malloc(sizeof(ProfPlugin));
plugin->name = module_name;
plugin->lang = PYTHON;
plugin->module = p_module;
plugin->init_func = ruby_init_hook;
plugin->on_start_func = ruby_on_start_hook;
plugin->on_connect_func = ruby_on_connect_hook;
plugin->on_message_received_func = ruby_on_message_received_hook;
g_free(module_name);
return plugin;
} else {
g_free(module_name);
return NULL;
}
}
void
ruby_init_hook(ProfPlugin *plugin, const char * const version, const char * const status)
{
PyObject *p_args = Py_BuildValue("ss", version, status);
PyObject *p_function;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_init")) {
p_function = PyObject_GetAttrString(p_module, "prof_init");
ruby_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject_CallObject(p_function, p_args);
ruby_check_error();
Py_XDECREF(p_function);
}
}
}
void
ruby_on_start_hook(ProfPlugin *plugin)
{
PyObject *p_function;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_start")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_start");
ruby_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject_CallObject(p_function, NULL);
ruby_check_error();
Py_XDECREF(p_function);
}
}
}
void
ruby_on_connect_hook(ProfPlugin *plugin)
{
PyObject *p_function;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_connect")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_connect");
ruby_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject_CallObject(p_function, NULL);
ruby_check_error();
Py_XDECREF(p_function);
}
}
}
void
ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message)
{
PyObject *p_args = Py_BuildValue("ss", jid, message);
PyObject *p_function;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_message_received")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_message_received");
ruby_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject_CallObject(p_function, p_args);
ruby_check_error();
Py_XDECREF(p_function);
}
}
}
void
ruby_check_error(void)
{
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
}
}
void
ruby_shutdown(void)
{
Py_Finalize();
}

View File

@ -0,0 +1,37 @@
/*
* ruby_plugins.h
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity 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.
*
* Profanity 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 Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef RUBY_PLUGINS_H
#define RUBY_PLUGINS_H
#include "plugins/plugins.h"
ProfPlugin* ruby_plugin_create(const char * const filename);
void ruby_init_hook(ProfPlugin *plugin, const char * const version, const char * const status);
void ruby_on_start_hook(ProfPlugin *plugin);
void ruby_on_connect_hook(ProfPlugin *plugin);
void ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message);
void ruby_check_error(void);
#endif

View File

@ -20,7 +20,7 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <locale.h> #include <locale.h>
#include <signal.h> #include <signal.h>
@ -623,10 +623,10 @@ _init(const int disable_tls, char *log_level)
_create_directories(); _create_directories();
log_level_t prof_log_level = log_level_from_string(log_level); log_level_t prof_log_level = log_level_from_string(log_level);
log_init(prof_log_level); log_init(prof_log_level);
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); log_info("Starting Profanity (%sdev)...", PROF_PACKAGE_VERSION);
} else { } else {
log_info("Starting Profanity (%s)...", PACKAGE_VERSION); log_info("Starting Profanity (%s)...", PROF_PACKAGE_VERSION);
} }
chat_log_init(); chat_log_init();
groupchat_log_init(); groupchat_log_init();

View File

@ -23,9 +23,9 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif
@ -70,7 +70,7 @@ cons_show_word(const char * const word)
void void
cons_debug(const char * const msg, ...) cons_debug(const char * const msg, ...)
{ {
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
va_list arg; va_list arg;
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
@ -167,15 +167,15 @@ cons_about(void)
} else { } else {
win_print_time(console, '-'); win_print_time(console, '-');
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
wprintw(console->win, "Welcome to Profanity, version %sdev\n", PACKAGE_VERSION); wprintw(console->win, "Welcome to Profanity, version %sdev\n", PROF_PACKAGE_VERSION);
} else { } else {
wprintw(console->win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION); wprintw(console->win, "Welcome to Profanity, version %s\n", PROF_PACKAGE_VERSION);
} }
} }
win_print_time(console, '-'); win_print_time(console, '-');
wprintw(console->win, "Copyright (C) 2012, 2013 James Booth <%s>.\n", PACKAGE_BUGREPORT); wprintw(console->win, "Copyright (C) 2012, 2013 James Booth <%s>.\n", PROF_PACKAGE_BUGREPORT);
win_print_time(console, '-'); win_print_time(console, '-');
wprintw(console->win, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"); wprintw(console->win, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
win_print_time(console, '-'); win_print_time(console, '-');
@ -1479,9 +1479,9 @@ _cons_splash_logo(void)
win_print_time(console, '-'); win_print_time(console, '-');
wprintw(console->win, "\n"); wprintw(console->win, "\n");
win_print_time(console, '-'); win_print_time(console, '-');
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
wprintw(console->win, "Version %sdev\n", PACKAGE_VERSION); wprintw(console->win, "Version %sdev\n", PROF_PACKAGE_VERSION);
} else { } else {
wprintw(console->win, "Version %s\n", PACKAGE_VERSION); wprintw(console->win, "Version %s\n", PROF_PACKAGE_VERSION);
} }
} }

View File

@ -20,17 +20,17 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_LIBXSS #ifdef PROF_HAVE_LIBXSS
#include <X11/extensions/scrnsaver.h> #include <X11/extensions/scrnsaver.h>
#endif #endif
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif
@ -61,7 +61,7 @@ static int max_cols = 0;
static char *win_title; static char *win_title;
#ifdef HAVE_LIBXSS #ifdef PROF_HAVE_LIBXSS
static Display *display; static Display *display;
#endif #endif
@ -109,7 +109,7 @@ ui_init(void)
current = console; current = console;
cons_about(); cons_about();
notifier_init(); notifier_init();
#ifdef HAVE_LIBXSS #ifdef PROF_HAVE_LIBXSS
display = XOpenDisplay(0); display = XOpenDisplay(0);
#endif #endif
ui_idle_time = g_timer_new(); ui_idle_time = g_timer_new();
@ -144,7 +144,7 @@ unsigned long
ui_get_idle_time(void) ui_get_idle_time(void)
{ {
// if compiled with libxss, get the x sessions idle time // if compiled with libxss, get the x sessions idle time
#ifdef HAVE_LIBXSS #ifdef PROF_HAVE_LIBXSS
XScreenSaverInfo *info = XScreenSaverAllocInfo(); XScreenSaverInfo *info = XScreenSaverAllocInfo();
if (info != NULL && display != NULL) { if (info != NULL && display != NULL) {
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
@ -1416,8 +1416,8 @@ _ui_draw_win_title(void)
if (prefs_get_boolean(PREF_TITLEBARVERSION)) { if (prefs_get_boolean(PREF_TITLEBARVERSION)) {
g_string_append(version_str, " "); g_string_append(version_str, " ");
g_string_append(version_str, PACKAGE_VERSION); g_string_append(version_str, PROF_PACKAGE_VERSION);
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
g_string_append(version_str, "dev"); g_string_append(version_str, "dev");
} }
} }

View File

@ -21,15 +21,15 @@
*/ */
#define _XOPEN_SOURCE_EXTENDED #define _XOPEN_SOURCE_EXTENDED
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -19,16 +19,16 @@
* along with Profanity. If not, see <http://www.gnu.org/licenses/>. * along with Profanity. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
#ifdef HAVE_LIBNOTIFY #ifdef PROF_HAVE_LIBNOTIFY
#include <libnotify/notify.h> #include <libnotify/notify.h>
#endif #endif
#ifdef PLATFORM_CYGWIN #ifdef PROF_PLATFORM_CYGWIN
#include <windows.h> #include <windows.h>
#endif #endif
@ -40,7 +40,7 @@
void void
notifier_init(void) notifier_init(void)
{ {
#ifdef HAVE_LIBNOTIFY #ifdef PROF_HAVE_LIBNOTIFY
notify_init("Profanity"); notify_init("Profanity");
#endif #endif
} }
@ -48,7 +48,7 @@ notifier_init(void)
void void
notifier_uninit(void) notifier_uninit(void)
{ {
#ifdef HAVE_LIBNOTIFY #ifdef PROF_HAVE_LIBNOTIFY
if (notify_is_initted()) { if (notify_is_initted()) {
notify_uninit(); notify_uninit();
} }
@ -161,7 +161,7 @@ void
notify(const char * const message, int timeout, notify(const char * const message, int timeout,
const char * const category) const char * const category)
{ {
#ifdef HAVE_LIBNOTIFY #ifdef PROF_HAVE_LIBNOTIFY
if (notify_is_initted()) { if (notify_is_initted()) {
NotifyNotification *notification; NotifyNotification *notification;
@ -182,7 +182,7 @@ notify(const char * const message, int timeout,
log_error("Libnotify initialisation error."); log_error("Libnotify initialisation error.");
} }
#endif #endif
#ifdef PLATFORM_CYGWIN #ifdef PROF_PLATFORM_CYGWIN
NOTIFYICONDATA nid; NOTIFYICONDATA nid;
nid.cbSize = sizeof(NOTIFYICONDATA); nid.cbSize = sizeof(NOTIFYICONDATA);
//nid.hWnd = hWnd; //nid.hWnd = hWnd;

View File

@ -20,6 +20,9 @@
* *
*/ */
#ifndef NOTIFIER_H
#define NOTIFIER_H
void notifier_init(void); void notifier_init(void);
void notifier_uninit(void); void notifier_uninit(void);
@ -34,3 +37,5 @@ void notify_subscription(const char * const from);
void notify(const char * const message, int timeout, void notify(const char * const message, int timeout,
const char * const category); const char * const category);
#endif

View File

@ -20,14 +20,14 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -23,14 +23,14 @@
#ifndef UI_H #ifndef UI_H
#define UI_H #define UI_H
#include "config.h" #include "prof_config.h"
#include <wchar.h> #include <wchar.h>
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -20,15 +20,15 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
#ifdef HAVE_NCURSESW_NCURSES_H #ifdef PROF_HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h> #include <ncursesw/ncurses.h>
#elif HAVE_NCURSES_H #elif PROF_HAVE_NCURSES_H
#include <ncurses.h> #include <ncurses.h>
#endif #endif

View File

@ -20,7 +20,7 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -236,8 +236,8 @@ caps_create_query_response_stanza(xmpp_ctx_t * const ctx)
xmpp_stanza_set_attribute(identity, "type", "console"); xmpp_stanza_set_attribute(identity, "type", "console");
GString *name_str = g_string_new("Profanity "); GString *name_str = g_string_new("Profanity ");
g_string_append(name_str, PACKAGE_VERSION); g_string_append(name_str, PROF_PACKAGE_VERSION);
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
g_string_append(name_str, "dev"); g_string_append(name_str, "dev");
} }
xmpp_stanza_set_attribute(identity, "name", name_str->str); xmpp_stanza_set_attribute(identity, "name", name_str->str);

View File

@ -20,7 +20,7 @@
* *
*/ */
#include "config.h" #include "prof_config.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -234,8 +234,8 @@ _iq_handle_version_get(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
xmpp_stanza_t *version = xmpp_stanza_new(ctx); xmpp_stanza_t *version = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(version, "version"); xmpp_stanza_set_name(version, "version");
xmpp_stanza_t *version_txt = xmpp_stanza_new(ctx); xmpp_stanza_t *version_txt = xmpp_stanza_new(ctx);
GString *version_str = g_string_new(PACKAGE_VERSION); GString *version_str = g_string_new(PROF_PACKAGE_VERSION);
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) {
g_string_append(version_str, "dev"); g_string_append(version_str, "dev");
} }
xmpp_stanza_set_text(version_txt, version_str->str); xmpp_stanza_set_text(version_txt, version_str->str);