2 # Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
4 # This file is part of python-purple.
6 # python-purple is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # python-purple is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ctypedef char const_char "const char"
27 cdef void __group_node_cb(blist.PurpleBlistNode *node, object callback):
28 cdef blist.PurpleGroup *group = <blist.PurpleGroup *>node
29 cdef char *c_name = NULL
31 c_name = <char *> blist.c_purple_group_get_name(group)
37 currentsize = blist.c_purple_blist_get_group_size(group, False)
38 totalsize = blist.c_purple_blist_get_group_size(group, True)
39 online = blist.c_purple_blist_get_group_online_count(group)
42 callback(node.type, name, totalsize, currentsize, online)
46 cdef void __contact_node_cb(blist.PurpleBlistNode *node, object callback):
47 cdef blist.PurpleContact *contact = <blist.PurpleContact *>node
48 cdef char *c_alias = NULL
50 c_alias = <char *> blist.c_purple_contact_get_alias(contact)
57 callback(node.type, alias, contact.totalsize, contact.currentsize, \
62 cdef void __buddy_node_cb(blist.PurpleBlistNode *node, object callback):
63 cdef blist.PurpleBuddy *buddy = <blist.PurpleBuddy *>node
64 cdef char *c_name = NULL
65 cdef char *c_alias = NULL
67 c_name = <char *> blist.c_purple_buddy_get_name(buddy)
73 c_alias = <char *> blist.c_purple_buddy_get_alias_only(buddy)
80 callback(node.type, name, alias)
84 cdef void __chat_node_cb(blist.PurpleBlistNode *node, object callback):
85 cdef blist.PurpleChat *chat = <blist.PurpleChat *>node
86 cdef char *c_name = NULL
88 c_name = <char *> blist.c_purple_chat_get_name(chat)
95 callback(node.type, name)
99 cdef void __other_node_cb(blist.PurpleBlistNode *node, object callback):
105 cdef void new_list (blist.PurpleBuddyList *list):
106 debug.c_purple_debug_info("blist", "%s", "new_list\n")
108 (<object>blist_cbs["new_list"])("new_list")
112 cdef void new_node (blist.PurpleBlistNode *node):
113 debug.c_purple_debug_info("blist", "%s", "new_node\n")
115 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
116 __group_node_cb(node, blist_cbs["new_node"])
117 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
118 __contact_node_cb(node, blist_cbs["new_node"])
119 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
120 __buddy_node_cb(node, blist_cbs["new_node"])
121 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
122 __chat_node_cb(node, blist_cbs["new_node"])
123 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
124 __other_node_cb(node, blist_cbs["new_node"])
128 cdef void show (blist.PurpleBuddyList *list):
129 debug.c_purple_debug_info("blist", "%s", "show\n")
131 (<object>blist_cbs["show"])("show: TODO")
135 cdef void update (blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
136 debug.c_purple_debug_info("blist", "%s", "update\n")
138 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
139 __group_node_cb(node, blist_cbs["update"])
140 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
141 __contact_node_cb(node, blist_cbs["update"])
142 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
143 __buddy_node_cb(node, blist_cbs["update"])
144 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
145 __chat_node_cb(node, blist_cbs["update"])
146 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
147 __other_node_cb(node, blist_cbs["update"])
151 cdef void remove (blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
152 debug.c_purple_debug_info("blist", "%s", "remove\n")
154 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
155 __group_node_cb(node, blist_cbs["remove"])
156 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
157 __contact_node_cb(node, blist_cbs["remove"])
158 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
159 __buddy_node_cb(node, blist_cbs["remove"])
160 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
161 __chat_node_cb(node, blist_cbs["remove"])
162 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
163 __other_node_cb(node, blist_cbs["remove"])
167 cdef void destroy (blist.PurpleBuddyList *list):
168 debug.c_purple_debug_info("blist", "%s", "destroy\n")
170 (<object>blist_cbs["destroy"])("destroy: TODO")
174 cdef void set_visible (blist.PurpleBuddyList *list, glib.gboolean show):
175 debug.c_purple_debug_info("blist", "%s", "set-visible\n")
177 (<object>blist_cbs["set_visible"])("set-visible: TODO")
181 cdef void request_add_buddy (account.PurpleAccount *acc,
182 const_char *username, const_char *group,
184 debug.c_purple_debug_info("blist", "%s", "request-add-buddy\n")
186 (<object>blist_cbs["request-add-buddy"])("request-add-buddy: TODO")
190 cdef void request_add_chat (account.PurpleAccount *acc,
191 blist.PurpleGroup *group, const_char *alias,
193 debug.c_purple_debug_info("blist", "%s", "request_add_chat\n")
195 (<object>blist_cbs["request-add-chat"])("request-add-chat: TODO")
199 cdef void request_add_group ():
200 debug.c_purple_debug_info("blist", "%s", "request_add_group\n")
202 (<object>blist_cbs["request-add-chat"])("request-add-group: TODO")