Updated changes made on python-purple branch.
[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     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
31                          "create-conversation\n")
32     cdef char *c_name = NULL
33
34     c_name = <char *> conversation.c_purple_conversation_get_name(conv)
35     if c_name == NULL:
36         name = None
37     else:
38         name = c_name
39
40     type = conversation.c_purple_conversation_get_type(conv)
41
42     try:
43         (<object>conversation_cbs["create-conversation"])(name, type)
44     except KeyError:
45         pass
46
47 cdef void destroy_conversation (conversation.PurpleConversation *conv):
48     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
49                          "destroy-conversation\n")
50     try:
51         (<object>conversation_cbs["destroy-conversation"])("destroy-conversation: TODO")
52     except KeyError:
53         pass
54
55 cdef void write_chat (conversation.PurpleConversation *conv, const_char *who,
56                       const_char *message, conversation.PurpleMessageFlags flags,
57                       time_t mtime):
58     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
59                          "write-chat\n")
60     try:
61         (<object>conversation_cbs["write-chat"])("write-chat: TODO")
62     except KeyError:
63         pass
64
65 cdef void write_im (conversation.PurpleConversation *conv, const_char *who,
66                     const_char *c_message, conversation.PurpleMessageFlags flags,
67                     time_t mtime):
68     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation", "write-im\n")
69     cdef account.PurpleAccount *acc = conversation.c_purple_conversation_get_account(conv)
70     cdef blist.PurpleBuddy *buddy = NULL
71     cdef char *c_username = NULL
72     cdef char *c_sender_alias = NULL
73
74     c_username = <char *> account.c_purple_account_get_username(acc)
75     if c_username:
76         username = c_username
77     else:
78         username = None
79
80     if who:
81         sender = <char *> who
82         buddy = blist.c_purple_find_buddy(acc, <char *> who)
83         c_sender_alias = <char *> blist.c_purple_buddy_get_alias_only(buddy)
84     else:
85         sender = None
86
87     if c_sender_alias:
88         sender_alias = c_sender_alias
89     else:
90         sender_alias = None
91
92     if c_message:
93         message = <char *> c_message
94     else:
95         message = None
96
97     try:
98         (<object>conversation_cbs["write-im"])(username, sender, \
99                                                sender_alias, message)
100     except KeyError:
101         pass
102
103 cdef void write_conv (conversation.PurpleConversation *conv, const_char *name,
104                       const_char *alias, const_char *message,
105                       conversation.PurpleMessageFlags flags, time_t mtime):
106     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
107                          "write-conv\n")
108     try:
109         (<object>conversation_cbs["write-conv"])("write-conv: TODO")
110     except KeyError:
111         pass
112
113 cdef void chat_add_users (conversation.PurpleConversation *conv,
114                           glib.GList *cbuddies, glib.gboolean new_arrivals):
115     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
116                          "chat-add-users\n")
117     try:
118         (<object>conversation_cbs["chat-add-users"])("chat-add-users: TODO")
119     except KeyError:
120         pass
121
122 cdef void chat_rename_user (conversation.PurpleConversation *conv,
123                             const_char *old_name, const_char *new_name,
124                             const_char *new_alias):
125     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
126                          "chat-rename-user\n")
127     try:
128         (<object>conversation_cbs["chat-rename-user"])("chat-rename-user: TODO")
129     except KeyError:
130         pass
131
132 cdef void chat_remove_users (conversation.PurpleConversation *conv,
133                              glib.GList *users):
134     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
135                          "chat-remove-users\n")
136     try:
137         (<object>conversation_cbs["chat-remove-users"])("chat-remove-users: TODO")
138     except KeyError:
139         pass
140
141 cdef void chat_update_user (conversation.PurpleConversation *conv,
142                             const_char *user):
143     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
144                          "chat-update-user\n")
145     try:
146         (<object>conversation_cbs["chat-update-user"])("chat-update-user: TODO")
147     except KeyError:
148         pass
149
150 cdef void present (conversation.PurpleConversation *conv):
151     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
152                          "present\n")
153     try:
154         (<object>conversation_cbs["present"])("present: TODO")
155     except KeyError:
156         pass
157
158 cdef glib.gboolean has_focus (conversation.PurpleConversation *conv):
159     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
160                          "has-focus\n")
161     try:
162         (<object>conversation_cbs["has-focus"])("has-focus: TODO")
163         return False
164     except KeyError:
165         return False
166
167 cdef glib.gboolean custom_smiley_add (conversation.PurpleConversation *conv,
168                                       const_char *smile, glib.gboolean remote):
169     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
170                          "custom-smiley-add\n")
171     try:
172         (<object>conversation_cbs["custom-smiley-add"])("custom-smiley-add: TODO")
173         return False
174     except KeyError:
175         return False
176
177 cdef void custom_smiley_write (conversation.PurpleConversation *conv,
178                                const_char *smile, const_guchar *data,
179                                glib.gsize size):
180     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
181                          "custom-smiley-write\n")
182     try:
183         (<object>conversation_cbs["custom-smiley-write"])("custom-smiley-write: TODO")
184     except KeyError:
185         pass
186
187
188 cdef void custom_smiley_close (conversation.PurpleConversation *conv,
189                                const_char *smile):
190     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
191                          "custom-smiley-close\n")
192     try:
193         (<object>conversation_cbs["custom-smiley-close"])("custom-smiley-close: TODO")
194     except KeyError:
195         pass
196
197 cdef void send_confirm (conversation.PurpleConversation *conv,
198                         const_char *message):
199     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
200                          "send-confirm\n")
201     try:
202         (<object>conversation_cbs["send-confirm"])("send-confirm: TODO")
203     except KeyError:
204         pass