From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:09:44 +0000 (+0000) Subject: Buddy class X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=d03f737f2c481d446070051654c3607d89c1469c;ds=sidebyside Buddy class Initial buddy class implementation. Signed-off-by: Anderson Briglia git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1276 596f6dd7-e928-0410-a184-9e12fd12cf7e --- diff --git a/core/account.pxd b/core/account.pxd index 68f7e97..c505c5d 100644 --- a/core/account.pxd +++ b/core/account.pxd @@ -17,6 +17,9 @@ # along with this program. If not, see . # +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 index 0000000..b09aaca --- /dev/null +++ b/core/buddy.pxd @@ -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 . +# + +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(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 diff --git a/purple.pyx b/purple.pyx index 8a9080c..63d008c 100644 --- a/purple.pyx +++ b/purple.pyx @@ -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"