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/>.
24 cdef void signal_signed_on_cb(connection.PurpleConnection *gc, \
27 Emitted when a connection has signed on.
28 @params gc The connection that has signed on.
30 cdef account.PurpleAccount *acc = connection.purple_connection_get_account(gc)
31 cdef char *c_username = NULL
32 cdef char *c_protocol_id = NULL
34 c_username = <char *> account.purple_account_get_username(acc)
35 if c_username == NULL:
40 c_protocol_id = <char *> account.purple_account_get_protocol_id(acc)
41 if c_protocol_id == NULL:
44 protocol_id = c_protocol_id
46 if signal_cbs.has_key("signed-on"):
47 (<object> signal_cbs["signed-on"])(username, protocol_id)
49 cdef void signal_signed_off_cb(connection.PurpleConnection *gc, \
52 Emitted when a connection has signed off.
53 @params gc The connection that has signed off.
55 cdef account.PurpleAccount *acc = connection.purple_connection_get_account(gc)
56 cdef char *c_username = NULL
57 cdef char *c_protocol_id = NULL
59 c_username = <char *> account.purple_account_get_username(acc)
60 if c_username == NULL:
65 c_protocol_id = <char *> account.purple_account_get_protocol_id(acc)
66 if c_protocol_id == NULL:
69 protocol_id = c_protocol_id
71 if signal_cbs.has_key("signed-off"):
72 (<object> signal_cbs["signed-off"])(username, protocol_id)
74 cdef void signal_connection_error_cb(connection.PurpleConnection *gc, \
75 connection.PurpleConnectionError err, char *c_desc):
77 Emitted when a connection error occurs, before signed-off.
78 @params gc The connection on which the error has occured
79 @params err The error that occured
80 @params desc A description of the error, giving more information
85 1: "Invalid username",
86 2: "Authentication failed",
87 3: "Authentication impossible",
89 5: "Encryption error",
91 7: "Invalid settings",
92 8: "SSL certificate not provided",
93 9: "SSL certificate untrusted",
94 10: "SSL certificate expired",
95 11: "SSL certificate not activated",
96 12: "SSL certificate hostname mismatch",
97 13: "SSL certificate fingerprint mismatch",
98 14: "SSL certificate self signed",
99 15: "SSL certificate other error",
100 16: "Other error" }[<int>err]
107 if signal_cbs.has_key("connection-error"):
108 (<object> signal_cbs["connection-error"])(short_desc, desc)
110 cdef void signal_buddy_signed_on_cb(blist.PurpleBuddy *buddy):
112 Emitted when a buddy on your buddy list signs on.
113 @params buddy The buddy that signed on.
115 cdef char *c_name = NULL
116 cdef char *c_alias = NULL
118 c_name = <char *> blist.purple_buddy_get_name(buddy)
124 c_alias = <char *> blist.purple_buddy_get_alias_only(buddy)
130 if signal_cbs.has_key("buddy-signed-on"):
131 (<object> signal_cbs["buddy-signed-on"])(name, alias)
133 cdef void signal_buddy_signed_off_cb(blist.PurpleBuddy *buddy):
135 Emitted when a buddy on your buddy list signs off.
136 @params buddy The buddy that signed off.
138 cdef char *c_name = NULL
139 cdef char *c_alias = NULL
141 c_name = <char *> blist.purple_buddy_get_name(buddy)
147 c_alias = <char *> blist.purple_buddy_get_alias_only(buddy)
153 if signal_cbs.has_key("buddy-signed-off"):
154 (<object> signal_cbs["buddy-signed-off"])(name, alias)
156 cdef glib.gboolean signal_receiving_im_msg_cb(account.PurpleAccount *account, \
157 char **sender, char **message, conversation.PurpleConversation *conv, \
158 conversation.PurpleMessageFlags *flags):
160 Emitted when an IM is received. The callback can replace the name of the
161 sender, the message, or the flags by modifying the pointer to the strings
162 and integer. This can also be used to cancel a message by returning TRUE.
163 @note Make sure to free *sender and *message before you replace them!
164 @returns TRUE if the message should be canceled, or FALSE otherwise.
165 @params account The account the message was received on.
166 @params sender A pointer to the username of the sender.
167 @params message A pointer to the message that was sent.
168 @params conv The IM conversation.
169 @params flags A pointer to the IM message flags.
171 cdef blist.PurpleBuddy *buddy = blist.purple_find_buddy(account, sender[0])
172 cdef char *c_alias = NULL
174 c_alias = <char *> blist.purple_buddy_get_alias_only(buddy)
180 stripped = util.purple_markup_strip_html(message[0])
182 if signal_cbs.has_key("receiving-im-msg"):
183 return (<object> signal_cbs["receiving-im-msg"])(sender[0], alias, stripped)
185 cdef void jabber_receiving_xmlnode_cb(connection.PurpleConnection *gc, \
186 xmlnode.xmlnode **packet, glib.gpointer null):
188 Emitted when jabber receives a XML node.
190 message = xmlnode.xmlnode_to_str(packet[0], NULL)
192 if signal_cbs.has_key("jabber-receiving-xmlnode"):
193 (<object> signal_cbs["jabber-receiving-xmlnode"])(message)