Replaced c_purple* with purple* for most files.
[python-purple] / conversation_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     ctypedef glib.guchar const_guchar "const guchar"
25     ctypedef long int time_t
26
27 conversation_cbs = {}
28
29 cdef void create_conversation(conversation.PurpleConversation *conv):
30     """
31     Called when a conv is created (but before the conversation-created
32     signal is emitted).
33     """
34     debug.purple_debug_info("conversation", "%s", "create-conversation\n")
35     cdef char *c_name = NULL
36
37     c_name = <char *> conversation.purple_conversation_get_name(conv)
38     if c_name == NULL:
39         name = None
40     else:
41         name = c_name
42
43     type = conversation.purple_conversation_get_type(conv)
44
45     if conversation_cbs.has_key("create-conversation"):
46         (<object> conversation_cbs["create-conversation"])(name, type)
47
48 cdef void destroy_conversation(conversation.PurpleConversation *conv):
49     """
50     Called just before a conv is freed.
51     """
52     debug.purple_debug_info("conversation", "%s", "destroy-conversation\n")
53     if conversation_cbs.has_key("destroy-conversation"):
54         (<object> conversation_cbs["destroy-conversation"])("destroy-conversation: TODO")
55
56 cdef void write_chat(conversation.PurpleConversation *conv, const_char *who, \
57         const_char *message, conversation.PurpleMessageFlags flags, \
58         time_t mtime):
59     """
60     Write a message to a chat. If this field is NULL, libpurple will fall
61     back to using write_conv.
62     @see purple_conv_chat_write()
63     """
64     debug.purple_debug_info("conversation", "%s", "write-chat\n")
65     if conversation_cbs.has_key("write-chat"):
66         (<object> conversation_cbs["write-chat"])("write-chat: TODO")
67
68 cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \
69         const_char *c_message, conversation.PurpleMessageFlags flags, \
70         time_t mtime):
71     """
72     Write a message to an IM conversation. If this field is NULL, libpurple
73     will fall back to using write_conv.
74     @see purple_conv_im_write()
75     """
76     debug.purple_debug_info("conversation", "%s", "write-im\n")
77     cdef account.PurpleAccount *acc = conversation.purple_conversation_get_account(conv)
78     cdef blist.PurpleBuddy *buddy = NULL
79     cdef char *c_username = NULL
80     cdef char *c_sender_alias = NULL
81
82     c_username = <char *> account.purple_account_get_username(acc)
83     if c_username:
84         username = c_username
85     else:
86         username = None
87
88     if who:
89         sender = <char *> who
90         buddy = blist.purple_find_buddy(acc, <char *> who)
91         c_sender_alias = <char *> blist.purple_buddy_get_alias_only(buddy)
92     else:
93         sender = None
94
95     if c_sender_alias:
96         sender_alias = c_sender_alias
97     else:
98         sender_alias = None
99
100     if c_message:
101         message = <char *> c_message
102     else:
103         message = None
104
105     if conversation_cbs.has_key("write-im"):
106         (<object> conversation_cbs["write-im"])(username, sender, \
107                                                 sender_alias, message)
108
109 cdef void write_conv(conversation.PurpleConversation *conv, const_char *name, \
110         const_char *alias, const_char *message, \
111         conversation.PurpleMessageFlags flags, time_t mtime):
112     """
113     Write a message to a conversation. This is used rather than the chat- or
114     im-specific ops for errors, system messages (such as "x is now known as
115     y"), and as the fallback if write_im and write_chat are not implemented.
116     It should be implemented, or the UI will miss conversation error messages
117     and your users will hate you.
118     @see purple_conversation_write()
119     """
120     debug.purple_debug_info("conversation", "%s", "write-conv\n")
121     if conversation_cbs.has_key("write-conv"):
122         (<object> conversation_cbs["write-conv"])("write-conv: TODO")
123
124 cdef void chat_add_users(conversation.PurpleConversation *conv, \
125         glib.GList *cbuddies, glib.gboolean new_arrivals):
126     """
127     Add cbuddies to a chat.
128     @param cbuddies  A GList of PurpleConvChatBuddy structs.
129     @param new_arrivals  Wheter join notices should be shown.
130                          (Join notices are actually written to the
131                          conversation by purple_conv_chat_add_users().)
132     @see purple_conv_chat_add_users()
133     """
134     debug.purple_debug_info("conversation", "%s", "chat-add-users\n")
135     if conversation_cbs.has_key("chat-add-users"):
136         (<object> conversation_cbs["chat-add-users"])("chat-add-users: TODO")
137
138 cdef void chat_rename_user(conversation.PurpleConversation *conv, \
139         const_char *old_name, const_char *new_name,
140         const_char *new_alias):
141     """
142     Rename the user in this chat name old_name to new_name. (The rename
143     message is written to the conversation by libpurple.)
144     @param new_alias  new_name's new_alias, if they have one.
145     @see purple_conv_chat_rename_user()
146     """
147     debug.purple_debug_info("conversation", "%s", "chat-rename-user\n")
148     if conversation_cbs.has_key("chat-rename-user"):
149         (<object> conversation_cbs["chat-rename-user"])("chat-rename-user: TODO")
150
151 cdef void chat_remove_users(conversation.PurpleConversation *conv, \
152         glib.GList *users):
153     """
154     Remove users from a chat.
155     @param  users  A GList of const char *s.
156     """
157     debug.purple_debug_info("conversation", "%s", "chat-remove-users\n")
158     if conversation_cbs.has_key("chat-remove-users"):
159         (<object> conversation_cbs["chat-remove-users"])("chat-remove-users: TODO")
160
161 cdef void chat_update_user(conversation.PurpleConversation *conv, \
162         const_char *user):
163     """
164     Called when a user's flags are changed.
165     @see purple_conv_chat_user_set_flags()
166     """
167     debug.purple_debug_info("conversation", "%s", "chat-update-user\n")
168     if conversation_cbs.has_key("chat-update-user"):
169         (<object> conversation_cbs["chat-update-user"])("chat-update-user: TODO")
170
171 cdef void present(conversation.PurpleConversation *conv):
172     """
173     Present this conversation to the user; for example, by displaying the IM
174     dialog.
175     """
176     debug.purple_debug_info("conversation", "%s", "present\n")
177     if conversation_cbs.has_key("present"):
178         (<object> conversation_cbs["present"])("present: TODO")
179
180 cdef glib.gboolean has_focus(conversation.PurpleConversation *conv):
181     """
182     If this UI has a concept of focus (as in a windowing system) and this
183     conversation has the focus, return TRUE; otherwise, return FALSE.
184     """
185     debug.purple_debug_info("conversation", "%s", "has-focus\n")
186     if conversation_cbs.has_key("has-focus"):
187         (<object> conversation_cbs["has-focus"])("has-focus: TODO")
188     return False
189
190 cdef glib.gboolean custom_smiley_add(conversation.PurpleConversation *conv, \
191         const_char *smile, glib.gboolean remote):
192     """
193     Custom smileys (add).
194     """
195     debug.purple_debug_info("conversation", "%s", "custom-smiley-add\n")
196     if conversation_cbs.has_key("custom-smiley-add"):
197         (<object> conversation_cbs["custom-smiley-add"])("custom-smiley-add: TODO")
198     return False
199
200 cdef void custom_smiley_write(conversation.PurpleConversation *conv, \
201         const_char *smile, const_guchar *data, glib.gsize size):
202     """
203     Custom smileys (write).
204     """
205     debug.purple_debug_info("conversation", "%s", "custom-smiley-write\n")
206     if conversation_cbs.has_key("custom-smiley-write"):
207         (<object> conversation_cbs["custom-smiley-write"])("custom-smiley-write: TODO")
208
209 cdef void custom_smiley_close(conversation.PurpleConversation *conv, \
210         const_char *smile):
211     """
212     Custom smileys (close).
213     """
214     debug.purple_debug_info("conversation", "%s", "custom-smiley-close\n")
215     if conversation_cbs.has_key("custom-smiley-close"):
216         (<object> conversation_cbs["custom-smiley-close"])("custom-smiley-close: TODO")
217
218 cdef void send_confirm(conversation.PurpleConversation *conv, \
219         const_char *message):
220     """
221     Prompt the user for confirmation to send mesage. This function should
222     arrange for the message to be sent if the user accepts. If this field
223     is NULL, libpurple will fall back to using purple_request_action().
224     """
225     debug.purple_debug_info("conversation", "%s", "send-confirm\n")
226     if conversation_cbs.has_key("send-confirm"):
227         (<object> conversation_cbs["send-confirm"])("send-confirm: TODO")