X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=signal_cbs.pxd;h=b1bb26d776dedde8301898b1d7d3be405b98b7a2;hp=8155b745634759f90cadc8490035ed3e1eedb51d;hb=1ebedbc8928e2e85faccc07f84da6b422040fb3e;hpb=445c387d8067391f329186a13ce482dbb3c64c80 diff --git a/signal_cbs.pxd b/signal_cbs.pxd index 8155b74..b1bb26d 100644 --- a/signal_cbs.pxd +++ b/signal_cbs.pxd @@ -21,6 +21,105 @@ cimport purple signal_cbs = {} +cdef void signal_signed_on_cb (connection.PurpleConnection *gc, \ + glib.gpointer null): + cdef account.PurpleAccount *acc = connection.c_purple_connection_get_account(gc) + cdef char *c_username = NULL + cdef char *c_protocol_id = NULL + + c_username = account.c_purple_account_get_username(acc) + if c_username == NULL: + username = None + else: + username = c_username + + c_protocol_id = account.c_purple_account_get_protocol_id(acc) + if c_protocol_id == NULL: + protocol_id = None + else: + protocol_id = c_protocol_id + + try: + ( signal_cbs["signed-on"])(username, protocol_id) + except KeyError: + pass + +cdef void signal_signed_off_cb (connection.PurpleConnection *gc, \ + glib.gpointer null): + cdef account.PurpleAccount *acc = connection.c_purple_connection_get_account(gc) + cdef char *c_username = NULL + cdef char *c_protocol_id = NULL + + c_username = account.c_purple_account_get_username(acc) + if c_username == NULL: + username = None + else: + username = c_username + + c_protocol_id = account.c_purple_account_get_protocol_id(acc) + if c_protocol_id == NULL: + protocol_id = None + else: + protocol_id = c_protocol_id + + try: + ( signal_cbs["signed-off"])(username, protocol_id) + except KeyError: + pass + +cdef void signal_connection_error_cb (connection.PurpleConnection *gc, \ + connection.PurpleConnectionError err, char *c_desc): + + short_desc = { + 0: "Network error", + 1: "Invalid username", + 2: "Authentication failed", + 3: "Authentication impossible", + 4: "No SSL support", + 5: "Encryption error", + 6: "Name in use", + 7: "Invalid settings", + 8: "SSL certificate not provided", + 9: "SSL certificate untrusted", + 10: "SSL certificate expired", + 11: "SSL certificate not activated", + 12: "SSL certificate hostname mismatch", + 13: "SSL certificate fingerprint mismatch", + 14: "SSL certificate self signed", + 15: "SSL certificate other error", + 16: "Other error" }[err] + + if c_desc == NULL: + desc = None + else: + desc = c_desc + + try: + ( signal_cbs["connection-error"])(short_desc, desc) + except KeyError: + pass + +cdef void signal_buddy_signed_on_cb (blist.PurpleBuddy *buddy): + cdef char *c_name = NULL + cdef char *c_alias = NULL + + c_name = blist.c_purple_buddy_get_name(buddy) + if c_name == NULL: + name = None + else: + name = c_name + + c_alias = blist.c_purple_buddy_get_alias_only(buddy) + if c_alias == NULL: + alias = None + else: + alias = c_alias + + try: + ( signal_cbs["buddy-signed-on"])(name, alias) + except KeyError: + pass + cdef void signal_buddy_signed_off_cb (blist.PurpleBuddy *buddy): cdef char *c_name = NULL cdef char *c_alias = NULL