gpointer data;
} PurpleGLibIOClosure;
-static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
+static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition,
+ gpointer data)
{
PurpleGLibIOClosure *closure = data;
PurpleInputCondition purple_cond = 0;
return TRUE;
}
-static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
+guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
gpointer data)
{
PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1);
g_io_channel_unref(channel);
return closure->result;
}
-
-static PurpleEventLoopUiOps glib_eventloops =
-{
- g_timeout_add,
- g_source_remove,
- glib_input_add,
- g_source_remove,
- NULL,
-#if GLIB_CHECK_VERSION(2,14,0)
- g_timeout_add_seconds,
-#else
- NULL,
-#endif
-
- /* padding */
- NULL,
- NULL,
- NULL
-};
-/*** End of the eventloop functions. ***/
-
-/*** Conversation uiops ***/
-/* FIXME: Revisit this function. Is it needed? How it should be more general?*/
-static void
-write_conv(PurpleConversation *conv, const char *who, const char *alias,
- const char *message, PurpleMessageFlags flags, time_t mtime)
-{
- const char *name;
- if (alias && *alias)
- name = alias;
- else if (who && *who)
- name = who;
- else
- name = NULL;
-
- printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv),
- purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)),
- name, message);
-}
-
-static PurpleConversationUiOps conv_uiops =
-{
- NULL, /* create_conversation */
- NULL, /* destroy_conversation */
- NULL, /* write_chat */
- NULL, /* write_im */
- write_conv, /* write_conv */
- NULL, /* chat_add_users */
- NULL, /* chat_rename_user */
- NULL, /* chat_remove_users */
- NULL, /* chat_update_user */
- NULL, /* present */
- NULL, /* has_focus */
- NULL, /* custom_smiley_add */
- NULL, /* custom_smiley_write */
- NULL, /* custom_smiley_close */
- NULL, /* send_confirm */
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-/* FIXME: Is this a valid struct? */
-static void ui_init(void)
-{
- /**
- * This should initialize the UI components for all the modules. Here we
- * just initialize the UI for conversations.
- */
- purple_conversations_set_ui_ops(&conv_uiops);
-}
-
-static PurpleCoreUiOps core_uiops =
-{
- NULL,
- NULL,
- ui_init,
- NULL,
-
- /* padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-void set_uiops(void)
-{
- purple_core_set_ui_ops(&core_uiops);
- purple_eventloop_set_ui_ops(&glib_eventloops);
-}
ctypedef long int time_t
cdef extern from "libpurple/core.h":
+ ctypedef struct PurpleCoreUiOps:
+ void (*ui_prefs_init) ()
+ void (*debug_ui_init) ()
+ void (*ui_init) ()
+ void (*quit) ()
+ GHashTable (*get_ui_info) ()
+
gboolean c_purple_core_init "purple_core_init" (const_char_ptr ui_name)
void c_purple_core_quit "purple_core_quit" ()
+ void c_purple_core_set_ui_ops "purple_core_set_ui_ops" (PurpleCoreUiOps *ops)
gboolean c_purple_core_ensure_single_instance "purple_core_ensure_single_instance" ()
cdef extern from "libpurple/debug.h":
void c_purple_debug "purple_debug" (PurpleDebugLevel level, const_char_ptr category, const_char_ptr format)
void c_purple_debug_set_enabled "purple_debug_set_enabled" (gboolean debug_enabled)
+cdef extern from "libpurple/eventloop.h":
+ ctypedef enum PurpleInputCondition:
+ PURPLE_INPUT_READ
+ PURPLE_INPUT_WRITE
+
+ ctypedef void (*PurpleInputFunction) (gpointer , gint, PurpleInputCondition)
+
+ ctypedef struct PurpleEventLoopUiOps:
+ guint (*timeout_add) (guint interval, GSourceFunc function, gpointer data)
+ gboolean (*timeout_remove) (guint handle)
+ guint (*input_add) (int fd, PurpleInputCondition cond, PurpleInputFunction func, gpointer user_data)
+ gboolean (*input_remove) (guint handle)
+ int (*input_get_error) (int fd, int *error)
+ guint (*timeout_add_seconds)(guint interval, GSourceFunc function, gpointer data)
+
+ void c_purple_eventloop_set_ui_ops "purple_eventloop_set_ui_ops" (PurpleEventLoopUiOps *ops)
+
cdef extern from "libpurple/plugin.h":
void c_purple_plugins_add_search_path "purple_plugins_add_search_path" (const_char_ptr path)
+cdef extern from "libpurple/prefs.h":
+ void c_purple_prefs_rename "purple_prefs_rename" (const_char_ptr oldname, const_char_ptr newname)
+ const_char_ptr c_purple_prefs_get_string "purple_prefs_get_string" (const_char_ptr name)
+ gboolean c_purple_prefs_load "purple_prefs_load" ()
+
cdef extern from "libpurple/util.h":
void c_purple_util_set_user_dir "purple_util_set_user_dir" (char *dir)
cdef extern from "c_purple.h":
void set_uiops()
+ guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function, gpointer data)
+
+cdef void ui_init():
+ pass
class Purple(object):
def __init__(self):
+ cdef PurpleCoreUiOps c_core_ui_ops
+ c_core_ui_ops.ui_prefs_init = NULL
+ c_core_ui_ops.debug_ui_init = NULL
+ c_core_ui_ops.ui_init = ui_init
+ c_core_ui_ops.quit = NULL
+ c_core_ui_ops.get_ui_info = NULL
+
+ cdef PurpleEventLoopUiOps c_eventloop_ui_ops
+ c_eventloop_ui_ops.timeout_add = g_timeout_add
+ c_eventloop_ui_ops.timeout_remove = g_source_remove
+ c_eventloop_ui_ops.input_add = glib_input_add
+ c_eventloop_ui_ops.input_remove = g_source_remove
+ c_eventloop_ui_ops.input_get_error = NULL
+ c_eventloop_ui_ops.timeout_add_seconds = NULL
+
self.DEFAULT_PATH = "/home/user/MyDocs/Carman"
self.APP_NAME = "carman-purple-python"
self.util_set_user_dir(self.DEFAULT_PATH)
self.plugin_add_search_path(self.DEFAULT_PATH)
- set_uiops()
+ c_purple_core_set_ui_ops(&c_core_ui_ops)
+ c_purple_eventloop_set_ui_ops(&c_eventloop_ui_ops)
ret = self.core_init(self.APP_NAME)
if ret is False:
c_purple_plugins_add_search_path(path)
# plugin_add_search_path
+ def prefs_rename(self, old_name, new_name):
+ c_purple_prefs_rename(old_name, new_name)
+ # prefs_rename
+
+ def prefs_get_string(self, name):
+ return c_purple_prefs_get_string(name)
+ # prefs_get_string
+
+ def prefs_load(self):
+ return c_purple_prefs_load()
+ # prefs_load
+
def util_set_user_dir(self, dir):
c_purple_util_set_user_dir(dir)
# util_set_user_dir
#include "core/blist.pxd"
#include "core/connection.pxd"
#include "core/core.pxd"
-#include "core/eventloop.pxd"
#include "core/idle.pxd"
#include "core/pounce.pxd"
-#include "core/prefs.pxd"