Changing __account to c_account.
[python-purple] / connection_cbs.pxd
index ca39432..ea707e6 100644 (file)
@@ -28,34 +28,30 @@ cdef void connect_progress (connection.PurpleConnection *gc, const_char *text,
                             size_t step, size_t step_count):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "connect_progress\n")
-    global connection_cbs
     try:
-        (<object>connection_cbs["connect_progress"])("connect_progress")
+        (<object>connection_cbs["connect_progress"])(<char *>text, step, step_count)
     except KeyError:
         pass
 
 cdef void connected (connection.PurpleConnection *gc):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "connected\n")
-    global connection_cbs
     try:
-        (<object>connection_cbs["connected"])("connected")
+        (<object>connection_cbs["connected"])()
     except KeyError:
         pass
 
 cdef void disconnected (connection.PurpleConnection *gc):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "disconnected\n")
-    global connection_cbs
     try:
-        (<object>connection_cbs["disconnected"])("disconnected")
+        (<object>connection_cbs["disconnected"])()
     except KeyError:
         pass
 
 cdef void notice (connection.PurpleConnection *gc, const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "notice\n")
-    global connection_cbs
     try:
         (<object>connection_cbs["notice"])("notice")
     except KeyError:
@@ -65,16 +61,14 @@ cdef void report_disconnect (connection.PurpleConnection *gc,
                              const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "report_disconnect\n")
-    global connection_cbs
     try:
-        (<object>connection_cbs["report_disconnect"])("report_disconnect")
+        (<object>connection_cbs["report_disconnect"])(<char *>text)
     except KeyError:
         pass
 
 cdef void network_connected ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "network_connected\n")
-    global connection_cbs
     try:
         (<object>connection_cbs["network_connected"])("network_connected")
     except KeyError:
@@ -83,7 +77,6 @@ cdef void network_connected ():
 cdef void network_disconnected ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "network_disconnected\n")
-    global connection_cbs
     try:
         (<object>connection_cbs["network_disconnected"])("network_disconnected")
     except KeyError:
@@ -94,8 +87,27 @@ cdef void report_disconnect_reason (connection.PurpleConnection *gc,
                                     const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "report_disconnect_reason\n")
-    global connection_cbs
+
+    reason_string = {
+        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: 'Certificate not provided',
+        9: 'Certificate untrusted',
+        10: 'Certificate expired',
+        11: 'Certificate not activated',
+        12: 'Certificate hostname mismatch',
+        13: 'Certificate fingerprint mismatch',
+        14: 'Certificate self signed',
+        15: 'Certificate error (other)',
+        16: 'Other error' }[reason]
+
     try:
-        (<object>connection_cbs["report_disconnect_reason"])("report_disconnect_reason")
+        (<object>connection_cbs["report_disconnect_reason"])(reason_string, <char *>text)
     except KeyError:
         pass