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/>.
21 ctypedef char const_char "const char"
25 cdef void __group_node_cb(blist.PurpleBlistNode *node, object callback):
26 cdef blist.PurpleGroup *group = <blist.PurpleGroup *>node
27 cdef char *c_name = NULL
29 c_name = <char *> blist.purple_group_get_name(group)
35 currentsize = blist.purple_blist_get_group_size(group, False)
36 totalsize = blist.purple_blist_get_group_size(group, True)
37 online = blist.purple_blist_get_group_online_count(group)
39 callback(node.type, name, totalsize, currentsize, online)
41 cdef void __contact_node_cb(blist.PurpleBlistNode *node, object callback):
42 cdef blist.PurpleContact *contact = <blist.PurpleContact *>node
43 cdef char *c_alias = NULL
45 c_alias = <char *> blist.purple_contact_get_alias(contact)
51 callback(node.type, alias, contact.totalsize, contact.currentsize, \
54 cdef void __buddy_node_cb(blist.PurpleBlistNode *node, object callback):
55 cdef blist.PurpleBuddy *buddy = <blist.PurpleBuddy *>node
56 cdef char *c_name = NULL
57 cdef char *c_alias = NULL
59 c_name = <char *> blist.purple_buddy_get_name(buddy)
65 c_alias = <char *> blist.purple_buddy_get_alias_only(buddy)
71 callback(node.type, name, alias)
73 cdef void __chat_node_cb(blist.PurpleBlistNode *node, object callback):
74 cdef blist.PurpleChat *chat = <blist.PurpleChat *>node
75 cdef char *c_name = NULL
77 c_name = <char *> blist.purple_chat_get_name(chat)
83 callback(node.type, name)
85 cdef void __other_node_cb(blist.PurpleBlistNode *node, object callback):
88 cdef void new_list(blist.PurpleBuddyList *list):
90 Sets UI-specific data on a buddy list.
92 debug.purple_debug_info("blist", "%s", "new-list\n")
93 if "new-list" in blist_cbs:
94 (<object> blist_cbs["new-list"])("new-list: TODO")
96 cdef void new_node(blist.PurpleBlistNode *node):
98 Sets UI-specific data on a node.
100 debug.purple_debug_info("blist", "%s", "new-node\n")
101 if "new-node" in blist_cbs:
102 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
103 __group_node_cb(node, blist_cbs["new-node"])
104 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
105 __contact_node_cb(node, blist_cbs["new-node"])
106 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
107 __buddy_node_cb(node, blist_cbs["new-node"])
108 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
109 __chat_node_cb(node, blist_cbs["new-node"])
110 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
111 __other_node_cb(node, blist_cbs["new-node"])
113 cdef void show(blist.PurpleBuddyList *list):
115 The core will call this when it's finished doing its core stuff.
117 debug.purple_debug_info("blist", "%s", "show\n")
118 if "show" in blist_cbs:
119 (<object> blist_cbs["show"])("show: TODO")
121 cdef void update(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
123 This will update a node in the buddy list.
125 debug.purple_debug_info("blist", "%s", "update\n")
126 if "update" in blist_cbs:
127 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
128 __group_node_cb(node, blist_cbs["update"])
129 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
130 __contact_node_cb(node, blist_cbs["update"])
131 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
132 __buddy_node_cb(node, blist_cbs["update"])
133 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
134 __chat_node_cb(node, blist_cbs["update"])
135 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
136 __other_node_cb(node, blist_cbs["update"])
138 cdef void remove(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
140 This removes a node from the list.
142 debug.purple_debug_info("blist", "%s", "remove\n")
143 if "remove" in blist_cbs:
144 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
145 __group_node_cb(node, blist_cbs["remove"])
146 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
147 __contact_node_cb(node, blist_cbs["remove"])
148 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
149 __buddy_node_cb(node, blist_cbs["remove"])
150 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
151 __chat_node_cb(node, blist_cbs["remove"])
152 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
153 __other_node_cb(node, blist_cbs["remove"])
155 cdef void destroy(blist.PurpleBuddyList *list):
157 When the list gets destroyed, this gets called to destroy the UI.
159 debug.purple_debug_info("blist", "%s", "destroy\n")
160 if "destroy" in blist_cbs:
161 (<object> blist_cbs["destroy"])("destroy: TODO")
163 cdef void set_visible(blist.PurpleBuddyList *list, glib.gboolean show):
165 Hides or unhides the buddy list.
167 debug.purple_debug_info("blist", "%s", "set-visible\n")
168 if "set-visible" in blist_cbs:
169 (<object> blist_cbs["set-visible"])("set-visible: TODO")
171 cdef void request_add_buddy(account.PurpleAccount *c_account, \
172 const_char *c_buddy_username, const_char *c_buddy_group, \
173 const_char *c_buddy_alias):
175 Requests from the user information needed to add a buddy to the buddy
178 debug.purple_debug_info("blist", "%s", "request-add-buddy\n")
180 username = account.purple_account_get_username(c_account)
181 protocol_id = account.purple_account_get_protocol_id(c_account)
184 buddy_username = <char *> c_buddy_username
186 buddy_username = None
189 buddy_group = <char *> c_buddy_group
194 buddy_alias = <char *> c_buddy_alias
198 if "request-add-buddy" in blist_cbs:
199 (<object> blist_cbs["request-add-buddy"])( \
200 (username, protocol_id), buddy_username, buddy_group, buddy_alias)
202 cdef void request_add_chat(account.PurpleAccount *acc, \
203 blist.PurpleGroup *group, const_char *alias, const_char *name):
207 debug.purple_debug_info("blist", "%s", "request-add-chat\n")
208 if "request-add-chat" in blist_cbs:
209 (<object> blist_cbs["request-add-chat"])("request-add-chat: TODO")
211 cdef void request_add_group():
215 debug.purple_debug_info("blist", "%s", "request-add-group\n")
216 if "request-add-group" in blist_cbs:
217 (<object>blist_cbs["request-add-group"])("request-add-group: TODO")