Buddy class
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:09:44 +0000 (20:09 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:09 +0000 (17:11 -0400)
Initial buddy class implementation.

Signed-off-by: Anderson Briglia <anderson.briglia@indt.org.br>

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

core/account.pxd
core/buddy.pxd [new file with mode: 0644]
purple.pyx

index 68f7e97..c505c5d 100644 (file)
@@ -17,6 +17,9 @@
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+cdef extern from "glib.h":
+    ctypedef int gboolean
+
 cdef extern from "libpurple/account.h":
     cdef struct _PurpleAccount
     ctypedef _PurpleAccount PurpleAccount
diff --git a/core/buddy.pxd b/core/buddy.pxd
new file mode 100644 (file)
index 0000000..b09aaca
--- /dev/null
@@ -0,0 +1,49 @@
+#
+#  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/>.
+#
+
+cdef extern from "libpurple/purple.h":
+    cdef struct _PurpleBuddy
+    ctypedef _PurpleBuddy PurpleBuddy
+
+    cdef struct _PurpleAccount
+    ctypedef _PurpleAccount PurpleAccount
+
+    PurpleBuddy *purple_buddy_new(PurpleAccount *account,
+            const_char_ptr screenname, const_char_ptr alias)
+
+    const_char_ptr purple_buddy_get_alias_only(PurpleBuddy *buddy)
+    const_char_ptr purple_buddy_get_name(PurpleBuddy *buddy)
+
+
+cdef class Buddy:
+    """ Buddy class """
+    cdef PurpleBuddy *__buddy
+
+    def __cinit__(self, acc, const_char_ptr scr, const_char_ptr alias):
+        self.__buddy = purple_buddy_new(<PurpleAccount *>acc.__account, scr, alias)
+        self.acc = acc
+
+    def get_alias(self):
+        return purple_buddy_get_alias_only(self.__buddy)
+
+    def get_name(self):
+        return purple_buddy_get_name(self.__buddy)
+
+    def get_account(self):
+        return self.acc
index 8a9080c..63d008c 100644 (file)
@@ -199,7 +199,8 @@ class Purple(object):
         c_purple_util_set_user_dir(dir)
     # util_set_user_dir
 
-#include "core/account.pxd"
+include "core/account.pxd"
+include "core/buddy.pxd"
 #include "core/blist.pxd"
 #include "core/connection.pxd"
 #include "core/core.pxd"