From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:22:58 +0000 (+0000) Subject: Simplifyed definitions call, moved signal callback example to Cython code. X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=808298462331613626bf941f55b4118295e92824;hp=d88947735d2c204731d80ae6513aeea7463a6e87 Simplifyed definitions call, moved signal callback example to Cython code. FIXES: - Now all .pyx files simply calls "cimport purple" instead of a bunch of cimport's. - Moved signal callback example from c_purple to cython code. Signed-off-by: Bruno Abinader git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1298 596f6dd7-e928-0410-a184-9e12fd12cf7e --- diff --git a/account.pyx b/account.pyx index 503a87c..421f1ec 100644 --- a/account.pyx +++ b/account.pyx @@ -17,12 +17,7 @@ # along with this program. If not, see . # -cimport glib - -cimport account -cimport blist -cimport savedstatuses -cimport status +cimport purple cdef class Account: """ Account class """ diff --git a/buddy.pyx b/buddy.pyx index 9224737..d12fd58 100644 --- a/buddy.pyx +++ b/buddy.pyx @@ -17,7 +17,7 @@ # along with this program. If not, see . # -cimport blist +cimport purple cdef class Buddy: """ Buddy class """ diff --git a/c_purple.c b/c_purple.c index fab5c9f..1130a5b 100644 --- a/c_purple.c +++ b/c_purple.c @@ -76,18 +76,3 @@ guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunctio g_io_channel_unref(channel); return closure->result; } - -static void -signed_on(PurpleConnection *gc, gpointer null) -{ - PurpleAccount *account = purple_connection_get_account(gc); - printf("Account connected: %s %s\n", account->username, account->protocol_id); -} - -void connect_to_signals_for_demonstration_purposes_only(void) -{ - static int handle; - - purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle, - PURPLE_CALLBACK(signed_on), NULL); -} diff --git a/c_purple.h b/c_purple.h index 9c69c9c..84aa659 100644 --- a/c_purple.h +++ b/c_purple.h @@ -20,5 +20,3 @@ guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function, gpointer data); - -void connect_to_signals_for_demonstration_purposes_only(void); diff --git a/connection.pyx b/connection.pyx index 2e9a8f4..19da891 100644 --- a/connection.pyx +++ b/connection.pyx @@ -17,11 +17,21 @@ # along with this program. If not, see . # -cimport connection +cimport purple + +cdef void signed_on_cb (connection.PurpleConnection *gc, glib.gpointer null): + cdef account.PurpleAccount *acc = connection.c_purple_connection_get_account(gc) + print "Account connected: %s %s" % (acc.username, acc.protocol_id) cdef class Connection: """ Connection class """ cdef connection.PurpleConnection *__conn + def __init__(self): + pass + def connect(self): - connect_to_signals_for_demonstration_purposes_only() + cdef int handle + + signals.c_purple_signal_connect(connection.c_purple_connections_get_handle(), + "signed-on", &handle, signed_on_cb, NULL) diff --git a/conversation.pyx b/conversation.pyx index 5b8cb04..c13578a 100644 --- a/conversation.pyx +++ b/conversation.pyx @@ -17,7 +17,7 @@ # along with this program. If not, see . # -cimport conversation +cimport purple cdef class Conversation: """ Conversation class """ diff --git a/libpurple/account.pxd b/libpurple/account.pxd index 964c21d..0cfd6f7 100644 --- a/libpurple/account.pxd +++ b/libpurple/account.pxd @@ -22,6 +22,12 @@ cimport glib cdef extern from "libpurple/account.h": ctypedef struct PurpleAccount: char *username + char *alias + char *password + char *user_info + char *buddy_icon_path + glib.gboolean remember_pass + char *protocol_id ctypedef struct PurpleAccountUiOps: pass diff --git a/libpurple/connection.pxd b/libpurple/connection.pxd index d0a3633..510307c 100644 --- a/libpurple/connection.pxd +++ b/libpurple/connection.pxd @@ -17,6 +17,8 @@ # along with this program. If not, see . # +cimport account + cdef extern from "libpurple/connection.h": ctypedef struct PurpleConnection: pass @@ -24,4 +26,6 @@ cdef extern from "libpurple/connection.h": ctypedef struct PurpleConnectionUiOps: pass + account.PurpleAccount *c_purple_connection_get_account "purple_connection_get_account" (PurpleConnection *gc) + void *c_purple_connections_get_handle "purple_connections_get_handle" () void c_purple_connections_set_ui_ops "purple_connections_set_ui_ops" (PurpleConnectionUiOps *ops) diff --git a/libpurple/prpl.pxd b/libpurple/prpl.pxd new file mode 100644 index 0000000..854aeea --- /dev/null +++ b/libpurple/prpl.pxd @@ -0,0 +1,32 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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. +# +# python-purple 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 this program. If not, see . +# + +cimport blist +cimport conversation +cimport ft +#cimport imgstore +cimport notify +cimport proxy +cimport plugin +cimport roomlist +cimport status +#cimport whiteboard + +cdef extern from "libpurple/prpl.h": + plugin.PurplePlugin *c_purple_find_prpl "purple_find_prpl" (char *id) diff --git a/libpurple/purple.pxd b/libpurple/purple.pxd new file mode 100644 index 0000000..010cf34 --- /dev/null +++ b/libpurple/purple.pxd @@ -0,0 +1,46 @@ +# +# Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia +# +# This file is part of python-purple. +# +# python-purple 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. +# +# python-purple 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 this program. If not, see . +# + +cimport glib + +cimport account +cimport buddyicon +cimport blist +cimport connection +cimport conversation +cimport core +cimport debug +cimport eventloop +cimport ft +cimport idle +cimport notify +cimport plugin +cimport pounce +cimport prefs +cimport proxy +cimport prpl +cimport request +cimport roomlist +cimport signals +cimport status +cimport savedstatuses +cimport util + +cdef extern from "libpurple/purple.h": + pass diff --git a/purple.pyx b/purple.pyx index 3ddd512..29594c0 100644 --- a/purple.pyx +++ b/purple.pyx @@ -17,35 +17,9 @@ # along with this program. If not, see . # -cdef extern from "libpurple/purple.h": - pass - -cimport glib - -cimport account -cimport buddyicon -cimport blist -cimport connection -cimport conversation -cimport core -cimport debug -cimport eventloop -cimport ft -cimport idle -cimport notify -cimport plugin -cimport pounce -cimport prefs -cimport proxy -cimport request -cimport roomlist -cimport signals -cimport status -cimport savedstatuses -cimport util +cimport purple cdef extern from "c_purple.h": - void connect_to_signals_for_demonstration_purposes_only () glib.guint glib_input_add(glib.gint fd, eventloop.PurpleInputCondition condition, eventloop.PurpleInputFunction function, glib.gpointer data) import ecore