Removed deprecated code from Purple class.
[python-purple] / blist_cbs.pxd
1 #
2 #  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
3 #
4 #  This file is part of python-purple.
5 #
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.
10 #
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.
15 #
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/>.
18 #
19
20 cimport purple
21
22 cdef extern from *:
23     ctypedef char const_char "const char"
24
25 blist_cbs = {}
26
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
30
31     c_name = <char *> blist.c_purple_group_get_name(group)
32     if c_name == NULL:
33         name = None
34     else:
35         name = c_name
36
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)
40
41     callback(node.type, name, totalsize, currentsize, online)
42
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
46
47     c_alias = <char *> blist.c_purple_contact_get_alias(contact)
48     if c_alias == NULL:
49         alias = None
50     else:
51         alias = c_alias
52
53     callback(node.type, alias, contact.totalsize, contact.currentsize, \
54              contact.online)
55
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
60
61     c_name = <char *> blist.c_purple_buddy_get_name(buddy)
62     if c_name == NULL:
63         name = None
64     else:
65         name = c_name
66
67     c_alias = <char *> blist.c_purple_buddy_get_alias_only(buddy)
68     if c_alias == NULL:
69         alias = None
70     else:
71         alias = c_alias
72
73     callback(node.type, name, alias)
74
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
78
79     c_name = <char *> blist.c_purple_chat_get_name(chat)
80     if c_name == NULL:
81         name = None
82     else:
83         name = c_name
84
85     callback(node.type, name)
86
87 cdef void __other_node_cb(blist.PurpleBlistNode *node, object callback):
88     callback(node.type)
89
90 cdef void new_list(blist.PurpleBuddyList *list):
91     """
92     Sets UI-specific data on a buddy list.
93     """
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")
97
98 cdef void new_node(blist.PurpleBlistNode *node):
99     """
100     Sets UI-specific data on a node.
101     """
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"])
114
115 cdef void show(blist.PurpleBuddyList *list):
116     """
117     The core will call this when it's finished doing its core stuff.
118     """
119     debug.purple_debug_info("blist", "%s", "show\n")
120     if blist_cbs.has_key("show"):
121         (<object> blist_cbs["show"])("show: TODO")
122
123 cdef void update(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
124     """
125     This will update a node in the buddy list.
126     """
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"])
139
140 cdef void remove(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
141     """
142     This removes a node from the list.
143     """
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"])
156
157 cdef void destroy(blist.PurpleBuddyList *list):
158     """
159     When the list gets destroyed, this gets called to destroy the UI.
160     """
161     debug.purple_debug_info("blist", "%s", "destroy\n")
162     if blist_cbs.has_key("destroy"):
163         (<object> blist_cbs["destroy"])("destroy: TODO")
164
165 cdef void set_visible(blist.PurpleBuddyList *list, glib.gboolean show):
166     """
167     Hides or unhides the buddy list.
168     """
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")
172
173 cdef void request_add_buddy(account.PurpleAccount *acc, \
174         const_char *username, const_char *group, const_char *alias):
175     """
176     TODO
177     """
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")
181
182 cdef void request_add_chat(account.PurpleAccount *acc, \
183         blist.PurpleGroup *group, const_char *alias, const_char *name):
184     """
185     TODO
186     """
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")
190
191 cdef void request_add_group():
192     """
193     TODO
194     """
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")