Fixed connection callbacks arguments used by nullclient.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:35:59 +0000 (20:35 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:12 +0000 (17:11 -0400)
FIXES:
 - Fixed connection callbacks arguments used by nullclient.

Signed-off-by: Bruno Abinader <bruno.abinader@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1322 596f6dd7-e928-0410-a184-9e12fd12cf7e

connection_cbs.pxd
nullclient.py

index 58b58ad..ea707e6 100644 (file)
@@ -29,7 +29,7 @@ cdef void connect_progress (connection.PurpleConnection *gc, const_char *text,
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "connect_progress\n")
     try:
-        (<object>connection_cbs["connect_progress"])("connect_progress")
+        (<object>connection_cbs["connect_progress"])(<char *>text, step, step_count)
     except KeyError:
         pass
 
@@ -37,7 +37,7 @@ cdef void connected (connection.PurpleConnection *gc):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "connected\n")
     try:
-        (<object>connection_cbs["connected"])("connected")
+        (<object>connection_cbs["connected"])()
     except KeyError:
         pass
 
@@ -45,7 +45,7 @@ cdef void disconnected (connection.PurpleConnection *gc):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "disconnected\n")
     try:
-        (<object>connection_cbs["disconnected"])("disconnected")
+        (<object>connection_cbs["disconnected"])()
     except KeyError:
         pass
 
@@ -62,7 +62,7 @@ cdef void report_disconnect (connection.PurpleConnection *gc,
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "report_disconnect\n")
     try:
-        (<object>connection_cbs["report_disconnect"])("report_disconnect")
+        (<object>connection_cbs["report_disconnect"])(<char *>text)
     except KeyError:
         pass
 
@@ -87,7 +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")
+
+    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
index 1e2a422..bd428d0 100644 (file)
@@ -42,14 +42,30 @@ cbs["blist"] = blist_cbs
 def conn_callback(name):
     print "---- connection callback example: %s" % name
 
-conn_cbs["connect_progress"] = conn_callback
-conn_cbs["connected"] = conn_callback
-conn_cbs["disconnected"] = conn_callback
 conn_cbs["notice"] = conn_callback
-conn_cbs["report_disconnect"] = conn_callback
 conn_cbs["network_connected"] = conn_callback
 conn_cbs["network_disconnected"] = conn_callback
-conn_cbs["report_disconnect_reason"] = conn_callback
+
+def connect_progress_cb(text, step, step_count):
+    print "---- connection status: %s [%s/%s]" % (text, step, step_count)
+
+def connected_cb():
+    print "---- connection status: Connected"
+
+def disconnected_cb():
+    print "---- connection status: Disconnected"
+
+def report_disconnect_cb(text):
+    print "---- %s" % text
+
+def report_disconnect_reason_cb(reason, text):
+    print "---- %s (%s)" % (text, reason)
+
+conn_cbs["connect_progress"] = connect_progress_cb
+conn_cbs["connected"] = connected_cb
+conn_cbs["disconnected"] = disconnected_cb
+conn_cbs["report_disconnect"] = report_disconnect_cb
+conn_cbs["report_disconnect_reason"] = report_disconnect_reason_cb
 
 cbs["connection"] = conn_cbs