X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=connection_cbs.pxd;h=501f39ee5ed8bbee7aeba203a58ff88905e1bd01;hp=b30016eabcbb0ec126338eb382be0c8689e7c400;hb=7752e0f4a14a32ede02b8b86c83d9510338a59ed;hpb=3d9932a4f305fc45e781e6d1620a864f569f3556 diff --git a/connection_cbs.pxd b/connection_cbs.pxd index b30016e..501f39e 100644 --- a/connection_cbs.pxd +++ b/connection_cbs.pxd @@ -34,16 +34,17 @@ cdef void connect_progress(connection.PurpleConnection *gc, const_char *text, \ of what is happening, as well as which a step out of step_count has been reached (which might be displayed as a progress bar). """ - debug.c_purple_debug_info("connection", "%s", "connect-progress\n") - if connection_cbs.has_key("connect-progress"): - ( connection_cbs["connect-progress"])( text, step, step_count) + debug.purple_debug_info("connection", "%s", "connect-progress\n") + if "connect-progress" in connection_cbs: + ( connection_cbs["connect-progress"]) \ + ( text, step, step_count) cdef void connected(connection.PurpleConnection *gc): """ Called when a connection is established (just before the signed-on signal). """ - debug.c_purple_debug_info("connection", "%s", "connected\n") - if connection_cbs.has_key("connected"): + debug.purple_debug_info("connection", "%s", "connected\n") + if "connected" in connection_cbs: ( connection_cbs["connected"])("connected: TODO") cdef void disconnected(connection.PurpleConnection *gc): @@ -51,8 +52,8 @@ cdef void disconnected(connection.PurpleConnection *gc): Called when a connection is ended (between the signing-off and signed-off signal). """ - debug.c_purple_debug_info("connection", "%s", "disconnected\n") - if connection_cbs.has_key("disconnected"): + debug.purple_debug_info("connection", "%s", "disconnected\n") + if "disconnected" in connection_cbs: ( connection_cbs["disconnected"])("disconnected: TODO") cdef void notice(connection.PurpleConnection *gc, const_char *text): @@ -61,8 +62,8 @@ cdef void notice(connection.PurpleConnection *gc, const_char *text): implements this as a no-op; purple_connection_notice(), which uses this operation, is not used by any of the protocols shipped with libpurple.) """ - debug.c_purple_debug_info("connection", "%s", "notice\n") - if connection_cbs.has_key("notice"): + debug.purple_debug_info("connection", "%s", "notice\n") + if "notice" in connection_cbs: ( connection_cbs["notice"])("notice: TODO") cdef void report_disconnect(connection.PurpleConnection *gc, const_char *text): @@ -74,8 +75,8 @@ cdef void report_disconnect(connection.PurpleConnection *gc, const_char *text): @deprecated in favour of PurpleConnectionUiOps.report_disconnect_reason. """ - debug.c_purple_debug_info("connection", "%s", "report-disconnect\n") - if connection_cbs.has_key("report-disconnect"): + debug.purple_debug_info("connection", "%s", "report-disconnect\n") + if "report-disconnect" in connection_cbs: ( connection_cbs["report-disconnect"])( text) cdef void network_connected(): @@ -84,8 +85,8 @@ cdef void network_connected(): is active. On Linux, this uses Network Manager if available; on Windows, it uses Win32's network change notification infrastructure. """ - debug.c_purple_debug_info("connection", "%s", "network-connected\n") - if connection_cbs.has_key("network-connected"): + debug.purple_debug_info("connection", "%s", "network-connected\n") + if "network-connected" in connection_cbs: ( connection_cbs["network-connected"])() cdef void network_disconnected(): @@ -93,12 +94,12 @@ cdef void network_disconnected(): Called when libpurple discovers that the computer's network connection has gone away. """ - debug.c_purple_debug_info("connection", "%s", "network-disconnected\n") - if connection_cbs.has_key("network-disconnected"): + debug.purple_debug_info("connection", "%s", "network-disconnected\n") + if "network-disconnected" in connection_cbs: ( connection_cbs["network-disconnected"])() cdef void report_disconnect_reason(connection.PurpleConnection *gc, \ - connection.PurpleConnectionError reason, const_char *text): + connection.PurpleConnectionError reason, const_char *c_text): """ Called when an error causes a connection to be disconnected. Called before disconnected. This op is intended to replace report_disconnect. @@ -111,7 +112,7 @@ cdef void report_disconnect_reason(connection.PurpleConnection *gc, \ @see purple_connection_error_reason @since 2.3.0 """ - debug.c_purple_debug_info("connection", "%s", "report-disconnect-reason\n") + debug.purple_debug_info("connection", "%s", "report-disconnect-reason\n") reason_string = { 0: 'Network error', @@ -132,5 +133,11 @@ cdef void report_disconnect_reason(connection.PurpleConnection *gc, \ 15: 'Certificate error (other)', 16: 'Other error' }[reason] - if connection_cbs.has_key("report-disconnect-reason"): - ( connection_cbs["report-disconnect-reason"])(reason_string, text) + if c_text: + text = c_text + else: + text = None + + if "report-disconnect-reason" in connection_cbs: + ( connection_cbs["report-disconnect-reason"]) \ + (reason_string, text)