Simplifyed definitions call, moved signal callback example to Cython code.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:22:58 +0000 (20:22 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:10 +0000 (17:11 -0400)
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 <bruno.abinader@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1298 596f6dd7-e928-0410-a184-9e12fd12cf7e

account.pyx
buddy.pyx
c_purple.c
c_purple.h
connection.pyx
conversation.pyx
libpurple/account.pxd
libpurple/connection.pxd
libpurple/prpl.pxd [new file with mode: 0644]
libpurple/purple.pxd [new file with mode: 0644]
purple.pyx

index 503a87c..421f1ec 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-cimport glib
-
-cimport account
-cimport blist
-cimport savedstatuses
-cimport status
+cimport purple
 
 cdef class Account:
     """ Account class """
index 9224737..d12fd58 100644 (file)
--- a/buddy.pyx
+++ b/buddy.pyx
@@ -17,7 +17,7 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-cimport blist
+cimport purple
 
 cdef class Buddy:
     """ Buddy class """
index fab5c9f..1130a5b 100644 (file)
@@ -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);
-}
index 9c69c9c..84aa659 100644 (file)
@@ -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);
index 2e9a8f4..19da891 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-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, <signals.PurpleCallback> signed_on_cb, NULL)
index 5b8cb04..c13578a 100644 (file)
@@ -17,7 +17,7 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-cimport conversation
+cimport purple
 
 cdef class Conversation:
     """ Conversation class """
index 964c21d..0cfd6f7 100644 (file)
@@ -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
index d0a3633..510307c 100644 (file)
@@ -17,6 +17,8 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+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 (file)
index 0000000..854aeea
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+#
+
+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 (file)
index 0000000..010cf34
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+#
+
+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
index 3ddd512..29594c0 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-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