Added setup_dist.py.
[python-purple] / purple.pyx
index cabbbae..e69a966 100644 (file)
@@ -55,6 +55,8 @@ include "request_cbs.pxd"
 #include "roomlist_cbs.pxd"
 include "signal_cbs.pxd"
 
+include "util.pxd"
+
 cdef class Purple:
     """ Purple class.
 
@@ -84,16 +86,17 @@ cdef class Purple:
         core.c_purple_core_quit()
 
     cdef void __core_ui_ops_ui_prefs_init(self):
-        debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "core_ui_ops", "ui_prefs_init\n")
+        debug.c_purple_debug_info("core_ui_ops", "%s", "ui_prefs_init\n")
         prefs.c_purple_prefs_load()
 
         prefs.c_purple_prefs_add_none("/carman")
 
     cdef void __core_ui_ops_debug_init(self):
-        debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "core_ui_ops", "debug_ui_init\n")
+        debug.c_purple_debug_info("core_ui_ops", "%s", "debug_ui_init\n")
+        pass
 
     cdef void __core_ui_ops_ui_init(self):
-        debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "core_ui_ops", "ui_init\n")
+        debug.c_purple_debug_info("core_ui_ops", "%s", "ui_init\n")
 
         account.c_purple_accounts_set_ui_ops(&c_account_ui_ops)
         connection.c_purple_connections_set_ui_ops(&c_conn_ui_ops)
@@ -106,7 +109,7 @@ cdef class Purple:
         #roomlist.c_purple_roomlist_set_ui_ops(&c_rlist_ui_ops)
 
     cdef void __core_ui_ops_quit(self):
-        debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "core_ui_ops", "quit\n")
+        debug.c_purple_debug_info("core_ui_ops", "%s", "quit\n")
 
         global c_ui_info
 
@@ -219,12 +222,14 @@ cdef class Purple:
         # initialize purple core
         ret = core.c_purple_core_init(__APP_NAME__)
         if ret is False:
-            debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "main", "Exiting because libpurple initialization failed.\n")
+            debug.c_purple_debug_fatal("main", "%s", "libpurple " \
+                                       "initialization failed.\n")
             return False
 
         # check if there is another instance of libpurple running
         if core.c_purple_core_ensure_single_instance() == False:
-            debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "main", "Exiting because another instance of libpurple is already running.\n")
+            debug.c_purple_debug_fatal("main", "%s", "Another instance of " \
+                                      "libpurple is already running.\n")
             core.c_purple_core_quit()
             return False
 
@@ -240,8 +245,9 @@ cdef class Purple:
 
         return ret
 
-    def add_callback(self, type, name, func):
-        """ Adds a callback 'func' with given name 'name' inside type 'type'.
+    def add_callback(self, type, name, callback):
+        """
+        Adds a callback with given name inside callback's type.
         Example: add_callback("account", "notify-added", notify_added_cb)
         """
         global account_cbs
@@ -256,11 +262,7 @@ cdef class Purple:
           "connection": connection_cbs,
           "conversation": conversation_cbs,
           "notify": notify_cbs,
-          "request": request_cbs }[type][name] = func
-
-    def connect(self):
-        conn = Connection()
-        conn.connect()
+          "request": request_cbs }[type][name] = callback
 
     def signal_connect(self, name=None, cb=None):
         cdef int handle
@@ -276,7 +278,27 @@ cdef class Purple:
         global signal_cbs
         signal_cbs[name] = cb
 
-        if name == "buddy-signed-off":
+        if name == "signed-on":
+            signals.c_purple_signal_connect(
+                    connection.c_purple_connections_get_handle(),
+                    "signed-on", &handle,
+                    <signals.PurpleCallback> signal_signed_on_cb, NULL)
+        elif name == "signed-off":
+            signals.c_purple_signal_connect(
+                    connection.c_purple_connections_get_handle(),
+                    "signed-off", &handle,
+                    <signals.PurpleCallback> signal_signed_off_cb, NULL)
+        elif name == "connection-error":
+            signals.c_purple_signal_connect(
+                    connection.c_purple_connections_get_handle(),
+                    "connection-error", &handle,
+                    <signals.PurpleCallback> signal_connection_error_cb, NULL)
+        elif name == "buddy-signed-on":
+            signals.c_purple_signal_connect(
+                    blist.c_purple_blist_get_handle(),
+                    "buddy-signed-on", &handle,
+                    <signals.PurpleCallback> signal_buddy_signed_on_cb, NULL)
+        elif name == "buddy-signed-off":
             signals.c_purple_signal_connect(
                     blist.c_purple_blist_get_handle(),
                     "buddy-signed-off", &handle,
@@ -329,8 +351,9 @@ cdef class Purple:
         else:
             return None
 
+include "plugin.pyx"
 include "proxy.pyx"
 include "account.pyx"
 include "buddy.pyx"
-include "connection.pyx"
+#include "connection.pyx"
 include "conversation.pyx"