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)
41 callback(node.type, name, totalsize, currentsize, online)
43 cdef void __contact_node_cb(blist.PurpleBlistNode *node, object callback):
44 cdef blist.PurpleContact *contact = <blist.PurpleContact *>node
45 cdef char *c_alias = NULL
47 c_alias = <char *> blist.c_purple_contact_get_alias(contact)
53 callback(node.type, alias, contact.totalsize, contact.currentsize, \
56 cdef void __buddy_node_cb(blist.PurpleBlistNode *node, object callback):
57 cdef blist.PurpleBuddy *buddy = <blist.PurpleBuddy *>node
58 cdef char *c_name = NULL
59 cdef char *c_alias = NULL
61 c_name = <char *> blist.c_purple_buddy_get_name(buddy)
67 c_alias = <char *> blist.c_purple_buddy_get_alias_only(buddy)
73 callback(node.type, name, alias)
75 cdef void __chat_node_cb(blist.PurpleBlistNode *node, object callback):
76 cdef blist.PurpleChat *chat = <blist.PurpleChat *>node
77 cdef char *c_name = NULL
79 c_name = <char *> blist.c_purple_chat_get_name(chat)
85 callback(node.type, name)
87 cdef void __other_node_cb(blist.PurpleBlistNode *node, object callback):
90 cdef void new_list(blist.PurpleBuddyList *list):
92 Sets UI-specific data on a buddy list.
94 debug.purple_debug_info("blist", "%s", "new-list\n")
95 if blist_cbs.has_key("new-list"):
96 (<object> blist_cbs["new-list"])("new-list: TODO")
98 cdef void new_node(blist.PurpleBlistNode *node):
100 Sets UI-specific data on a node.
102 debug.purple_debug_info("blist", "%s", "new-node\n")
103 if blist_cbs.has_key("new-node"):
104 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
105 __group_node_cb(node, blist_cbs["new-node"])
106 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
107 __contact_node_cb(node, blist_cbs["new-node"])
108 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
109 __buddy_node_cb(node, blist_cbs["new-node"])
110 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
111 __chat_node_cb(node, blist_cbs["new-node"])
112 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
113 __other_node_cb(node, blist_cbs["new-node"])
115 cdef void show(blist.PurpleBuddyList *list):
117 The core will call this when it's finished doing its core stuff.
119 debug.purple_debug_info("blist", "%s", "show\n")
120 if blist_cbs.has_key("show"):
121 (<object> blist_cbs["show"])("show: TODO")
123 cdef void update(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
125 This will update a node in the buddy list.
127 debug.purple_debug_info("blist", "%s", "update\n")
128 if blist_cbs.has_key("update"):
129 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
130 __group_node_cb(node, blist_cbs["update"])
131 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
132 __contact_node_cb(node, blist_cbs["update"])
133 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
134 __buddy_node_cb(node, blist_cbs["update"])
135 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
136 __chat_node_cb(node, blist_cbs["update"])
137 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
138 __other_node_cb(node, blist_cbs["update"])
140 cdef void remove(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
142 This removes a node from the list.
144 debug.purple_debug_info("blist", "%s", "remove\n")
145 if blist_cbs.has_key("remove"):
146 if node.type == blist.PURPLE_BLIST_GROUP_NODE:
147 __group_node_cb(node, blist_cbs["remove"])
148 elif node.type == blist.PURPLE_BLIST_CONTACT_NODE:
149 __contact_node_cb(node, blist_cbs["remove"])
150 elif node.type == blist.PURPLE_BLIST_BUDDY_NODE:
151 __buddy_node_cb(node, blist_cbs["remove"])
152 elif node.type == blist.PURPLE_BLIST_CHAT_NODE:
153 __chat_node_cb(node, blist_cbs["remove"])
154 elif node.type == blist.PURPLE_BLIST_OTHER_NODE:
155 __other_node_cb(node, blist_cbs["remove"])
157 cdef void destroy(blist.PurpleBuddyList *list):
159 When the list gets destroyed, this gets called to destroy the UI.
161 debug.purple_debug_info("blist", "%s", "destroy\n")
162 if blist_cbs.has_key("destroy"):
163 (<object> blist_cbs["destroy"])("destroy: TODO")
165 cdef void set_visible(blist.PurpleBuddyList *list, glib.gboolean show):
167 Hides or unhides the buddy list.
169 debug.purple_debug_info("blist", "%s", "set-visible\n")
170 if blist_cbs.has_key("set-visible"):
171 (<object> blist_cbs["set-visible"])("set-visible: TODO")
173 cdef void request_add_buddy(account.PurpleAccount *acc, \
174 const_char *username, const_char *group, const_char *alias):
178 debug.purple_debug_info("blist", "%s", "request-add-buddy\n")
179 if blist_cbs.has_key("request-add-buddy"):
180 (<object> blist_cbs["request-add-buddy"])("request-add-buddy: TODO")
182 cdef void request_add_chat(account.PurpleAccount *acc, \
183 blist.PurpleGroup *group, const_char *alias, const_char *name):
187 debug.purple_debug_info("blist", "%s", "request-add-chat\n")
188 if blist_cbs.has_key("request-add-chat"):
189 (<object> blist_cbs["request-add-chat"])("request-add-chat: TODO")
191 cdef void request_add_group():
195 debug.purple_debug_info("blist", "%s", "request-add-group\n")
196 if blist_cbs.has_key("request-add-chat"):
197 (<object>blist_cbs["request-add-chat"])("request-add-group: TODO")