#
# 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 purple
cdef extern from *:
ctypedef char const_char "const char"
blist_cbs = {}
cdef void __group_node_cb(blist.PurpleBlistNode *node, object callback):
cdef blist.PurpleGroup *group = node
cdef char *c_name = NULL
c_name = blist.purple_group_get_name(group)
if c_name == NULL:
name = None
else:
name = c_name
currentsize = blist.purple_blist_get_group_size(group, False)
totalsize = blist.purple_blist_get_group_size(group, True)
online = blist.purple_blist_get_group_online_count(group)
callback(node.type, name, totalsize, currentsize, online)
cdef void __contact_node_cb(blist.PurpleBlistNode *node, object callback):
cdef blist.PurpleContact *contact = node
cdef char *c_alias = NULL
c_alias = blist.purple_contact_get_alias(contact)
if c_alias == NULL:
alias = None
else:
alias = c_alias
callback(node.type, alias, contact.totalsize, contact.currentsize, \
contact.online)
cdef void __buddy_node_cb(blist.PurpleBlistNode *node, object callback):
cdef blist.PurpleBuddy *buddy = node
cdef char *c_name = NULL
cdef char *c_alias = NULL
c_name = blist.purple_buddy_get_name(buddy)
if c_name == NULL:
name = None
else:
name = c_name
c_alias = blist.purple_buddy_get_alias_only(buddy)
if c_alias == NULL:
alias = None
else:
alias = c_alias
callback(node.type, name, alias)
cdef void __chat_node_cb(blist.PurpleBlistNode *node, object callback):
cdef blist.PurpleChat *chat = node
cdef char *c_name = NULL
c_name = blist.purple_chat_get_name(chat)
if c_name == NULL:
name = None
else:
name = c_name
callback(node.type, name)
cdef void __other_node_cb(blist.PurpleBlistNode *node, object callback):
callback(node.type)
cdef void new_list(blist.PurpleBuddyList *list):
"""
Sets UI-specific data on a buddy list.
"""
debug.purple_debug_info("blist", "%s", "new-list\n")
if blist_cbs.has_key("new-list"):
(