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"
22 ctypedef glib.guchar const_guchar "const guchar"
23 ctypedef long int time_t
27 cdef void create_conversation(conversation.PurpleConversation *conv):
29 Called when a conv is created (but before the conversation-created
32 debug.purple_debug_info("conversation", "%s", "create-conversation\n")
33 cdef char *c_name = NULL
35 c_name = <char *> conversation.purple_conversation_get_name(conv)
41 type = conversation.purple_conversation_get_type(conv)
43 if "create-conversation" in conversation_cbs:
44 (<object> conversation_cbs["create-conversation"])(name, type)
46 cdef void destroy_conversation(conversation.PurpleConversation *conv):
48 Called just before a conv is freed.
50 debug.purple_debug_info("conversation", "%s", "destroy-conversation\n")
51 if "destroy-conversation" in conversation_cbs:
52 (<object> conversation_cbs["destroy-conversation"]) \
53 ("destroy-conversation: TODO")
55 cdef void write_chat(conversation.PurpleConversation *conv, const_char *who, \
56 const_char *message, conversation.PurpleMessageFlags flags, \
59 Write a message to a chat. If this field is NULL, libpurple will fall
60 back to using write_conv.
61 @see purple_conv_chat_write()
63 debug.purple_debug_info("conversation", "%s", "write-chat\n")
64 if "write-chat" in conversation_cbs:
65 (<object> conversation_cbs["write-chat"])("write-chat: TODO")
67 cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \
68 const_char *c_message, conversation.PurpleMessageFlags flags, \
71 Write a message to an IM conversation. If this field is NULL, libpurple
72 will fall back to using write_conv.
73 @see purple_conv_im_write()
75 debug.purple_debug_info("conversation", "%s", "write-im\n")
76 cdef account.PurpleAccount *acc = \
77 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
82 c_username = <char *> account.purple_account_get_username(acc)
89 who = conversation.purple_conversation_get_name(conv)
92 buddy = blist.purple_find_buddy(acc, <char *> who)
94 c_sender_alias = <char *> blist.purple_buddy_get_alias_only(buddy)
97 sender_alias = unicode(c_sender_alias, 'utf-8')
102 message = <char *> c_message
106 # FIXME: Maybe we need add more purple flags in the future
107 if (<int>flags & conversation.PURPLE_MESSAGE_SEND):
112 if "write-im" in conversation_cbs:
113 (<object> conversation_cbs["write-im"])(username, sender, \
114 sender_alias, message, flag)
116 cdef void write_conv(conversation.PurpleConversation *conv, const_char *name, \
117 const_char *alias, const_char *message, \
118 conversation.PurpleMessageFlags flags, time_t mtime):
120 Write a message to a conversation. This is used rather than the chat- or
121 im-specific ops for errors, system messages (such as "x is now known as
122 y"), and as the fallback if write_im and write_chat are not implemented.
123 It should be implemented, or the UI will miss conversation error messages
124 and your users will hate you.
125 @see purple_conversation_write()
127 debug.purple_debug_info("conversation", "%s", "write-conv\n")
128 if "write-conv" in conversation_cbs:
129 (<object> conversation_cbs["write-conv"])("write-conv: TODO")
131 cdef void chat_add_users(conversation.PurpleConversation *conv, \
132 glib.GList *cbuddies, glib.gboolean new_arrivals):
134 Add cbuddies to a chat.
135 @param cbuddies A GList of PurpleConvChatBuddy structs.
136 @param new_arrivals Wheter join notices should be shown.
137 (Join notices are actually written to the
138 conversation by purple_conv_chat_add_users().)
139 @see purple_conv_chat_add_users()
141 debug.purple_debug_info("conversation", "%s", "chat-add-users\n")
142 if "chat-add-users" in conversation_cbs:
143 (<object> conversation_cbs["chat-add-users"])("chat-add-users: TODO")
145 cdef void chat_rename_user(conversation.PurpleConversation *conv, \
146 const_char *old_name, const_char *new_name,
147 const_char *new_alias):
149 Rename the user in this chat name old_name to new_name. (The rename
150 message is written to the conversation by libpurple.)
151 @param new_alias new_name's new_alias, if they have one.
152 @see purple_conv_chat_rename_user()
154 debug.purple_debug_info("conversation", "%s", "chat-rename-user\n")
155 if "chat-rename-user" in conversation_cbs:
156 (<object> conversation_cbs["chat-rename-user"]) \
157 ("chat-rename-user: TODO")
159 cdef void chat_remove_users(conversation.PurpleConversation *conv, \
162 Remove users from a chat.
163 @param users A GList of const char *s.
165 debug.purple_debug_info("conversation", "%s", "chat-remove-users\n")
166 if "chat-remove-users" in conversation_cbs:
167 (<object> conversation_cbs["chat-remove-users"]) \
168 ("chat-remove-users: TODO")
170 cdef void chat_update_user(conversation.PurpleConversation *conv, \
173 Called when a user's flags are changed.
174 @see purple_conv_chat_user_set_flags()
176 debug.purple_debug_info("conversation", "%s", "chat-update-user\n")
177 if "chat-update-user" in conversation_cbs:
178 (<object> conversation_cbs["chat-update-user"]) \
179 ("chat-update-user: TODO")
181 cdef void present(conversation.PurpleConversation *conv):
183 Present this conversation to the user; for example, by displaying the IM
186 debug.purple_debug_info("conversation", "%s", "present\n")
187 if "present" in conversation_cbs:
188 (<object> conversation_cbs["present"])("present: TODO")
190 cdef glib.gboolean has_focus(conversation.PurpleConversation *conv):
192 If this UI has a concept of focus (as in a windowing system) and this
193 conversation has the focus, return TRUE; otherwise, return FALSE.
195 debug.purple_debug_info("conversation", "%s", "has-focus\n")
196 if "has-focus" in conversation_cbs:
197 (<object> conversation_cbs["has-focus"])("has-focus: TODO")
200 cdef glib.gboolean custom_smiley_add(conversation.PurpleConversation *conv, \
201 const_char *smile, glib.gboolean remote):
203 Custom smileys (add).
205 debug.purple_debug_info("conversation", "%s", "custom-smiley-add\n")
206 if "custom-smiley-add" in conversation_cbs:
207 (<object> conversation_cbs["custom-smiley-add"]) \
208 ("custom-smiley-add: TODO")
211 cdef void custom_smiley_write(conversation.PurpleConversation *conv, \
212 const_char *smile, const_guchar *data, glib.gsize size):
214 Custom smileys (write).
216 debug.purple_debug_info("conversation", "%s", "custom-smiley-write\n")
217 if "custom-smiley-write" in conversation_cbs:
218 (<object> conversation_cbs["custom-smiley-write"]) \
219 ("custom-smiley-write: TODO")
221 cdef void custom_smiley_close(conversation.PurpleConversation *conv, \
224 Custom smileys (close).
226 debug.purple_debug_info("conversation", "%s", "custom-smiley-close\n")
227 if "custom-smiley-close" in conversation_cbs:
228 (<object> conversation_cbs["custom-smiley-close"]) \
229 ("custom-smiley-close: TODO")
231 cdef void send_confirm(conversation.PurpleConversation *conv, \
232 const_char *message):
234 Prompt the user for confirmation to send mesage. This function should
235 arrange for the message to be sent if the user accepts. If this field
236 is NULL, libpurple will fall back to using purple_request_action().
238 debug.purple_debug_info("conversation", "%s", "send-confirm\n")
239 if "send-confirm" in conversation_cbs:
240 (<object> conversation_cbs["send-confirm"])("send-confirm: TODO")