Updated callback strings to comply with libpurple.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:50:59 +0000 (20:50 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:14 +0000 (17:11 -0400)
FIXES:
 - Updated callback strings (replaced underscores with minus symbol).
 - Now all UiOps callbacks are added using add_callback(type, name, func).
 - Updated changes on nullclient-ecore.py.
 - Added receiving-xmlnode example on nullclient-ecore.py.
 - Removed deprecated nullclient.py

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@1359 596f6dd7-e928-0410-a184-9e12fd12cf7e

account_cbs.pxd
blist_cbs.pxd
connection_cbs.pxd
conversation_cbs.pxd
notify_cbs.pxd
nullclient-ecore.py
nullclient.py [deleted file]
purple.pyx
request_cbs.pxd

index e2c2d7b..238ecc6 100644 (file)
@@ -28,18 +28,18 @@ cdef void notify_added (account.PurpleAccount *account,
                         const_char *remote_user, const_char *id,
                         const_char *alias, const_char *message):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
                         const_char *remote_user, const_char *id,
                         const_char *alias, const_char *message):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
-                         "notify_added\n")
+                         "notify-added\n")
     try:
     try:
-        (<object>account_cbs["notify_added"])("notify_added")
+        (<object>account_cbs["notify-added"])("notify-added: TODO")
     except KeyError:
         pass
 
 cdef void status_changed (account.PurpleAccount *account,
                           status.PurpleStatus *status):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
     except KeyError:
         pass
 
 cdef void status_changed (account.PurpleAccount *account,
                           status.PurpleStatus *status):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
-                         "status_changed\n")
+                         "status-changed\n")
     try:
     try:
-        (<object>account_cbs["status_changed"])("status_changed")
+        (<object>account_cbs["status-changed"])("status-changed: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -47,9 +47,9 @@ cdef void request_add (account.PurpleAccount *account,
                        const_char *remote_user, const_char *id,
                        const_char *alias, const_char *message):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
                        const_char *remote_user, const_char *id,
                        const_char *alias, const_char *message):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
-                         "request_add\n")
+                         "request-add\n")
     try:
     try:
-        (<object>account_cbs["request_add"])("request_add")
+        (<object>account_cbs["request-add"])("request-add: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -61,17 +61,17 @@ cdef void *request_authorize (account.PurpleAccount *account,
                               account.PurpleAccountRequestAuthorizationCb deny_cb,
                               void *user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
                               account.PurpleAccountRequestAuthorizationCb deny_cb,
                               void *user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
-                         "request_authorize\n")
+                         "request-authorize\n")
     try:
     try:
-        (<object>account_cbs["request_authorize"])("request_authorize")
+        (<object>account_cbs["request-authorize"])("request-authorize: TODO")
         return NULL
     except KeyError:
         pass
 
 cdef void close_account_request (void *ui_handle):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
         return NULL
     except KeyError:
         pass
 
 cdef void close_account_request (void *ui_handle):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "account",
-                         "close_account_request\n")
+                         "close-account-request\n")
     try:
     try:
-        (<object>account_cbs["close_account_request"])("close_account_request")
+        (<object>account_cbs["close-account-request"])("close-account-request: TODO")
     except KeyError:
         pass
     except KeyError:
         pass
index 01f68ed..52847dc 100644 (file)
@@ -128,7 +128,7 @@ cdef void new_node (blist.PurpleBlistNode *node):
 cdef void show (blist.PurpleBuddyList *list):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "show\n")
     try:
 cdef void show (blist.PurpleBuddyList *list):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "show\n")
     try:
-        (<object>blist_cbs["show"])("show")
+        (<object>blist_cbs["show"])("show: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -168,23 +168,23 @@ cdef void remove (blist.PurpleBuddyList *list, blist.PurpleBlistNode *node):
 cdef void destroy (blist.PurpleBuddyList *list):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "destroy\n")
     try:
 cdef void destroy (blist.PurpleBuddyList *list):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "destroy\n")
     try:
-        (<object>blist_cbs["destroy"])("destroy")
+        (<object>blist_cbs["destroy"])("destroy: TODO")
     except KeyError:
         pass
 
 cdef void set_visible (blist.PurpleBuddyList *list, glib.gboolean show):
     except KeyError:
         pass
 
 cdef void set_visible (blist.PurpleBuddyList *list, glib.gboolean show):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "set_visible\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "set-visible\n")
     try:
     try:
-        (<object>blist_cbs["set_visible"])("set_visible")
+        (<object>blist_cbs["set_visible"])("set-visible: TODO")
     except KeyError:
         pass
 
 cdef void request_add_buddy (account.PurpleAccount *acc,
                              const_char *username, const_char *group,
                              const_char *alias):
     except KeyError:
         pass
 
 cdef void request_add_buddy (account.PurpleAccount *acc,
                              const_char *username, const_char *group,
                              const_char *alias):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "request_add_buddy\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "request-add-buddy\n")
     try:
     try:
-        (<object>blist_cbs["request_add_buddy"])("request_add_buddy")
+        (<object>blist_cbs["request-add-buddy"])("request-add-buddy: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -193,13 +193,13 @@ cdef void request_add_chat (account.PurpleAccount *acc,
                             const_char *name):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "request_add_chat\n")
     try:
                             const_char *name):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "request_add_chat\n")
     try:
-        (<object>blist_cbs["request_add_chat"])("request_add_chat")
+        (<object>blist_cbs["request-add-chat"])("request-add-chat: TODO")
     except KeyError:
         pass
 
 cdef void request_add_group ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "request_add_group\n")
     try:
     except KeyError:
         pass
 
 cdef void request_add_group ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "blist", "request_add_group\n")
     try:
-        (<object>blist_cbs["request_add_chat"])("request_add_group")
+        (<object>blist_cbs["request-add-chat"])("request-add-group: TODO")
     except KeyError:
         pass
     except KeyError:
         pass
index ea707e6..fd0d05a 100644 (file)
@@ -27,9 +27,9 @@ cdef extern from *:
 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",
 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")
+                         "connect-progress\n")
     try:
     try:
-        (<object>connection_cbs["connect_progress"])(<char *>text, step, step_count)
+        (<object>connection_cbs["connect-progress"])(<char *>text, step, step_count)
     except KeyError:
         pass
 
     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:
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "connected\n")
     try:
-        (<object>connection_cbs["connected"])()
+        (<object>connection_cbs["connected"])("connected: TODO")
     except KeyError:
         pass
 
     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:
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "disconnected\n")
     try:
-        (<object>connection_cbs["disconnected"])()
+        (<object>connection_cbs["disconnected"])("disconnected: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -53,32 +53,32 @@ cdef void notice (connection.PurpleConnection *gc, const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "notice\n")
     try:
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                          "notice\n")
     try:
-        (<object>connection_cbs["notice"])("notice")
+        (<object>connection_cbs["notice"])("notice: TODO")
     except KeyError:
         pass
 
 cdef void report_disconnect (connection.PurpleConnection *gc,
                              const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
     except KeyError:
         pass
 
 cdef void report_disconnect (connection.PurpleConnection *gc,
                              const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
-                         "report_disconnect\n")
+                         "report-disconnect\n")
     try:
     try:
-        (<object>connection_cbs["report_disconnect"])(<char *>text)
+        (<object>connection_cbs["report-disconnect"])(<char *>text)
     except KeyError:
         pass
 
 cdef void network_connected ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
     except KeyError:
         pass
 
 cdef void network_connected ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
-                         "network_connected\n")
+                         "network-connected\n")
     try:
     try:
-        (<object>connection_cbs["network_connected"])("network_connected")
+        (<object>connection_cbs["network-connected"])("network-connected: TODO")
     except KeyError:
         pass
 
 cdef void network_disconnected ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
     except KeyError:
         pass
 
 cdef void network_disconnected ():
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
-                         "network_disconnected\n")
+                         "network-disconnected\n")
     try:
     try:
-        (<object>connection_cbs["network_disconnected"])("network_disconnected")
+        (<object>connection_cbs["network-disconnected"])("network-disconnected: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -86,7 +86,7 @@ cdef void report_disconnect_reason (connection.PurpleConnection *gc,
                                     connection.PurpleConnectionError reason,
                                     const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
                                     connection.PurpleConnectionError reason,
                                     const_char *text):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "connection",
-                         "report_disconnect_reason\n")
+                         "report-disconnect-reason\n")
 
     reason_string = {
         0: 'Network error',
 
     reason_string = {
         0: 'Network error',
@@ -108,6 +108,6 @@ cdef void report_disconnect_reason (connection.PurpleConnection *gc,
         16: 'Other error' }[reason]
 
     try:
         16: 'Other error' }[reason]
 
     try:
-        (<object>connection_cbs["report_disconnect_reason"])(reason_string, <char *>text)
+        (<object>connection_cbs["report-disconnect-reason"])(reason_string, <char *>text)
     except KeyError:
         pass
     except KeyError:
         pass
index 9cbb6ba..1a4aefe 100644 (file)
@@ -28,7 +28,7 @@ conversation_cbs = {}
 
 cdef void create_conversation (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
 
 cdef void create_conversation (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "create_conversation\n")
+                         "create-conversation\n")
     cdef char *c_name = NULL
 
     c_name = <char *> conversation.c_purple_conversation_get_name(conv)
     cdef char *c_name = NULL
 
     c_name = <char *> conversation.c_purple_conversation_get_name(conv)
@@ -40,15 +40,15 @@ cdef void create_conversation (conversation.PurpleConversation *conv):
     type = conversation.c_purple_conversation_get_type(conv)
 
     try:
     type = conversation.c_purple_conversation_get_type(conv)
 
     try:
-        (<object>conversation_cbs["create_conversation"])(name, type)
+        (<object>conversation_cbs["create-conversation"])(name, type)
     except KeyError:
         pass
 
 cdef void destroy_conversation (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
     except KeyError:
         pass
 
 cdef void destroy_conversation (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "destroy_conversation\n")
+                         "destroy-conversation\n")
     try:
     try:
-        (<object>conversation_cbs["destroy_conversation"])("destroy_conversation")
+        (<object>conversation_cbs["destroy-conversation"])("destroy-conversation: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -56,16 +56,16 @@ cdef void write_chat (conversation.PurpleConversation *conv, const_char *who,
                       const_char *message, conversation.PurpleMessageFlags flags,
                       time_t mtime):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
                       const_char *message, conversation.PurpleMessageFlags flags,
                       time_t mtime):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "write_chat\n")
+                         "write-chat\n")
     try:
     try:
-        (<object>conversation_cbs["write_chat"])("write_chat")
+        (<object>conversation_cbs["write-chat"])("write-chat: TODO")
     except KeyError:
         pass
 
 cdef void write_im (conversation.PurpleConversation *conv, const_char *who,
                     const_char *message, conversation.PurpleMessageFlags flags,
                     time_t mtime):
     except KeyError:
         pass
 
 cdef void write_im (conversation.PurpleConversation *conv, const_char *who,
                     const_char *message, conversation.PurpleMessageFlags flags,
                     time_t mtime):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation", "write_im\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation", "write-im\n")
     cdef account.PurpleAccount *acc = conversation.c_purple_conversation_get_account(conv)
     cdef char *c_username = NULL
 
     cdef account.PurpleAccount *acc = conversation.c_purple_conversation_get_account(conv)
     cdef char *c_username = NULL
 
@@ -81,7 +81,7 @@ cdef void write_im (conversation.PurpleConversation *conv, const_char *who,
         sender = None
 
     try:
         sender = None
 
     try:
-        (<object>conversation_cbs["write_im"])(username, sender, <char *> message)
+        (<object>conversation_cbs["write-im"])(username, sender, <char *> message)
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -89,18 +89,18 @@ cdef void write_conv (conversation.PurpleConversation *conv, const_char *name,
                       const_char *alias, const_char *message,
                       conversation.PurpleMessageFlags flags, time_t mtime):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
                       const_char *alias, const_char *message,
                       conversation.PurpleMessageFlags flags, time_t mtime):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "write_conv\n")
+                         "write-conv\n")
     try:
     try:
-        (<object>conversation_cbs["write_conv"])("write_conv")
+        (<object>conversation_cbs["write-conv"])("write-conv: TODO")
     except KeyError:
         pass
 
 cdef void chat_add_users (conversation.PurpleConversation *conv,
                           glib.GList *cbuddies, glib.gboolean new_arrivals):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
     except KeyError:
         pass
 
 cdef void chat_add_users (conversation.PurpleConversation *conv,
                           glib.GList *cbuddies, glib.gboolean new_arrivals):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "chat_add_users\n")
+                         "chat-add-users\n")
     try:
     try:
-        (<object>conversation_cbs["chat_add_users"])("chat_add_users")
+        (<object>conversation_cbs["chat-add-users"])("chat-add-users: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -108,27 +108,27 @@ cdef void chat_rename_user (conversation.PurpleConversation *conv,
                             const_char *old_name, const_char *new_name,
                             const_char *new_alias):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
                             const_char *old_name, const_char *new_name,
                             const_char *new_alias):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "chat_rename_user\n")
+                         "chat-rename-user\n")
     try:
     try:
-        (<object>conversation_cbs["chat_rename_user"])("chat_rename_user")
+        (<object>conversation_cbs["chat-rename-user"])("chat-rename-user: TODO")
     except KeyError:
         pass
 
 cdef void chat_remove_users (conversation.PurpleConversation *conv,
                              glib.GList *users):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
     except KeyError:
         pass
 
 cdef void chat_remove_users (conversation.PurpleConversation *conv,
                              glib.GList *users):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "chat_remove_users\n")
+                         "chat-remove-users\n")
     try:
     try:
-        (<object>conversation_cbs["chat_remove_users"])("chat_remove_users")
+        (<object>conversation_cbs["chat-remove-users"])("chat-remove-users: TODO")
     except KeyError:
         pass
 
 cdef void chat_update_user (conversation.PurpleConversation *conv,
                             const_char *user):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
     except KeyError:
         pass
 
 cdef void chat_update_user (conversation.PurpleConversation *conv,
                             const_char *user):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "chat_update_user\n")
+                         "chat-update-user\n")
     try:
     try:
-        (<object>conversation_cbs["chat_update_user"])("chat_update_user")
+        (<object>conversation_cbs["chat-update-user"])("chat-update-user: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -136,15 +136,15 @@ cdef void present (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
                          "present\n")
     try:
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
                          "present\n")
     try:
-        (<object>conversation_cbs["present"])("present")
+        (<object>conversation_cbs["present"])("present: TODO")
     except KeyError:
         pass
 
 cdef glib.gboolean has_focus (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
     except KeyError:
         pass
 
 cdef glib.gboolean has_focus (conversation.PurpleConversation *conv):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "has_focus\n")
+                         "has-focus\n")
     try:
     try:
-        (<object>conversation_cbs["has_focus"])("has_focus")
+        (<object>conversation_cbs["has-focus"])("has-focus: TODO")
         return False
     except KeyError:
         return False
         return False
     except KeyError:
         return False
@@ -152,9 +152,9 @@ cdef glib.gboolean has_focus (conversation.PurpleConversation *conv):
 cdef glib.gboolean custom_smiley_add (conversation.PurpleConversation *conv,
                                       const_char *smile, glib.gboolean remote):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
 cdef glib.gboolean custom_smiley_add (conversation.PurpleConversation *conv,
                                       const_char *smile, glib.gboolean remote):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "custom_smiley_add\n")
+                         "custom-smiley-add\n")
     try:
     try:
-        (<object>conversation_cbs["custom_smiley_add"])("custom_smiley_add")
+        (<object>conversation_cbs["custom-smiley-add"])("custom-smiley-add: TODO")
         return False
     except KeyError:
         return False
         return False
     except KeyError:
         return False
@@ -163,9 +163,9 @@ cdef void custom_smiley_write (conversation.PurpleConversation *conv,
                                const_char *smile, const_guchar *data,
                                glib.gsize size):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
                                const_char *smile, const_guchar *data,
                                glib.gsize size):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "custom_smiley_write\n")
+                         "custom-smiley-write\n")
     try:
     try:
-        (<object>conversation_cbs["custom_smiley_write"])("custom_smiley_write")
+        (<object>conversation_cbs["custom-smiley-write"])("custom-smiley-write: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -173,17 +173,17 @@ cdef void custom_smiley_write (conversation.PurpleConversation *conv,
 cdef void custom_smiley_close (conversation.PurpleConversation *conv,
                                const_char *smile):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
 cdef void custom_smiley_close (conversation.PurpleConversation *conv,
                                const_char *smile):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "custom_smiley_close\n")
+                         "custom-smiley-close\n")
     try:
     try:
-        (<object>conversation_cbs["custom_smiley_close"])("custom_smiley_close")
+        (<object>conversation_cbs["custom-smiley-close"])("custom-smiley-close: TODO")
     except KeyError:
         pass
 
 cdef void send_confirm (conversation.PurpleConversation *conv,
                         const_char *message):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
     except KeyError:
         pass
 
 cdef void send_confirm (conversation.PurpleConversation *conv,
                         const_char *message):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "conversation",
-                         "send_confirm\n")
+                         "send-confirm\n")
     try:
     try:
-        (<object>conversation_cbs["send_confirm"])("send_confirm")
+        (<object>conversation_cbs["send-confirm"])("send-confirm: TODO")
     except KeyError:
         pass
     except KeyError:
         pass
index d029ef9..ed6dbd6 100644 (file)
@@ -27,17 +27,17 @@ cdef extern from *:
 
 cdef void *notify_message (notify.PurpleNotifyMsgType type, const_char *title,
                            const_char *primary, const_char *secondary):
 
 cdef void *notify_message (notify.PurpleNotifyMsgType type, const_char *title,
                            const_char *primary, const_char *secondary):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_message\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify-message\n")
     try:
     try:
-        (<object>notify_cbs["notify_message"])("notify_message")
+        (<object>notify_cbs["notify-message"])("notify-message: TODO")
     except KeyError:
         pass
 
 cdef void *notify_email (connection.PurpleConnection *gc, const_char *subject,
                          const_char *_from, const_char *to, const_char *url):
     except KeyError:
         pass
 
 cdef void *notify_email (connection.PurpleConnection *gc, const_char *subject,
                          const_char *_from, const_char *to, const_char *url):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_email\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify-email\n")
     try:
     try:
-        (<object>notify_cbs["notify_email"])("notify_email")
+        (<object>notify_cbs["notify-email"])("notify-email: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -45,17 +45,17 @@ cdef void *notify_emails (connection.PurpleConnection *gc, size_t count,
                           glib.gboolean detailed, const_char **subjects,
                           const_char **froms, const_char **tos,
                           const_char **urls):
                           glib.gboolean detailed, const_char **subjects,
                           const_char **froms, const_char **tos,
                           const_char **urls):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_emails\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify-emails\n")
     try:
     try:
-        (<object>notify_cbs["notify_emails"])("notify_emails")
+        (<object>notify_cbs["notify-emails"])("notify-emails: TODO")
     except KeyError:
         pass
 
 cdef void *notify_formatted (const_char *title, const_char *primary,
                              const_char *secondary, const_char *text):
     except KeyError:
         pass
 
 cdef void *notify_formatted (const_char *title, const_char *primary,
                              const_char *secondary, const_char *text):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_formatted\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify-formatted\n")
     try:
     try:
-        (<object>notify_cbs["notify_formatted"])("notify_formatted")
+        (<object>notify_cbs["notify-formatted"])("notify-formatted: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -65,9 +65,9 @@ cdef void *notify_searchresults (connection.PurpleConnection *gc,
                                  notify.PurpleNotifySearchResults *results,
                                  glib.gpointer user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify",
                                  notify.PurpleNotifySearchResults *results,
                                  glib.gpointer user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify",
-                         "notify_searchresults\n")
+                         "notify-searchresults\n")
     try:
     try:
-        (<object>notify_cbs["notify_searchresults"])("notify_searchresults")
+        (<object>notify_cbs["notify-searchresults"])("notify-searchresults: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -75,30 +75,30 @@ cdef void notify_searchresults_new_rows (connection.PurpleConnection *gc,
                             notify.PurpleNotifySearchResults *results,
                             void *data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify",
                             notify.PurpleNotifySearchResults *results,
                             void *data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify",
-                         "notify_searchresults_new_rows\n")
+                         "notify-searchresults-new-rows\n")
     try:
     try:
-        (<object>notify_cbs["notify_searchresults_new_rows"])("notify_searchresults_new_rows")
+        (<object>notify_cbs["notify-searchresults-new-rows"])("notify-searchresults-new-rows: TODO")
     except KeyError:
         pass
 
 cdef void *notify_userinfo (connection.PurpleConnection *gc, const_char *who,
                             notify.PurpleNotifyUserInfo *user_info):
     except KeyError:
         pass
 
 cdef void *notify_userinfo (connection.PurpleConnection *gc, const_char *who,
                             notify.PurpleNotifyUserInfo *user_info):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_userinfo\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify-userinfo\n")
     try:
     try:
-        (<object>notify_cbs["notify_userinfo"])("notify_userinfo")
+        (<object>notify_cbs["notify-userinfo"])("notify-userinfo: TODO")
     except KeyError:
         pass
 
 cdef void *notify_uri (const_char *uri):
     except KeyError:
         pass
 
 cdef void *notify_uri (const_char *uri):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_uri\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify-uri\n")
     try:
     try:
-        (<object>notify_cbs["notify_uri"])("notify_uri")
+        (<object>notify_cbs["notify-uri"])("notify-uri: TODO")
     except KeyError:
         pass
 
 cdef void close_notify (notify.PurpleNotifyType type, void *ui_handle):
     except KeyError:
         pass
 
 cdef void close_notify (notify.PurpleNotifyType type, void *ui_handle):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "close_notify\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "close-notify\n")
     try:
     try:
-        (<object>notify_cbs["close_notify"])("close_notify")
+        (<object>notify_cbs["close-notify"])("close-notify: TODO")
     except KeyError:
         pass
     except KeyError:
         pass
index 50e21a0..0af42a8 100644 (file)
@@ -1,94 +1,16 @@
+#!/usr/bin/env python
+
 import etk
 import ecore
 import purple
 import etk
 import ecore
 import purple
-
-cbs = {}
-conn_cbs = {}
-conv_cbs = {}
-notify_cbs = {}
-request_cbs = {}
-
-def account_callback(name):
-    print "---- account callback example: %s" % name
-
-def blist_callback(name):
-    print "---- blist callback example: %s" % name
-
-def conn_callback(name):
-    print "---- connection callback example: %s" % name
-
-def conn_progress_cb(data):
-    return "Connection in progress..."
-
-#conn_cbs["connect_progress"] = conn_progress_cb
-#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
-
-cbs["connection"] = conn_cbs
-
-def conv_callback(name):
-    print "---- conversation callback example: %s" % name
-
-#conv_cbs["create_conversation"] = conv_callback
-#conv_cbs["destroy_conversation"] = conv_callback
-conv_cbs["write_chat"] = conv_callback
-conv_cbs["write_conv"] = conv_callback
-#conv_cbs["write_im"] = conv_callback
-conv_cbs["chat_add_users"] = conv_callback
-conv_cbs["chat_rename_user"] = conv_callback
-conv_cbs["chat_remove_users"] = conv_callback
-conv_cbs["chat_update_user"] = conv_callback
-conv_cbs["present"] = conv_callback
-conv_cbs["has_focus"] = conv_callback
-conv_cbs["custom_smiley_add"] = conv_callback
-conv_cbs["custom_smiley_write"] = conv_callback
-conv_cbs["custom_smiley_close"] = conv_callback
-conv_cbs["send_confirm"] = conv_callback
-
-cbs["conversation"] = conv_cbs
-
-def notify_callback(name):
-    print "----  notify callback example: %s" % name
-
-notify_cbs["notify_message"] = notify_callback
-notify_cbs["notify_email"] = notify_callback
-notify_cbs["notify_emails"] = notify_callback
-notify_cbs["notify_formatted"] = notify_callback
-notify_cbs["notify_searchresults"] = notify_callback
-notify_cbs["notify_searchresults_new_rows"] = notify_callback
-notify_cbs["notify_userinfo"] = notify_callback
-notify_cbs["notify_uri"] = notify_callback
-notify_cbs["close_notify"] = notify_callback
-
-cbs["notify"] = notify_cbs
-
-def request_callback(name):
-    print "---- request callback example: %s" % name
-
-request_cbs["request_input"] = request_callback
-request_cbs["request_choice"] = request_callback
-request_cbs["request_action"] = request_callback
-request_cbs["request_fields"] = request_callback
-request_cbs["request_file"] = request_callback
-request_cbs["close_request"] = request_callback
-request_cbs["request_folder"] = request_callback
-
-cbs["request"] = request_cbs
+from xml.dom import minidom
 
 class MainWindow:
     def __init__(self, quit_cb):
 
 class MainWindow:
     def __init__(self, quit_cb):
-        global conv_cbs
-        global signal_cbs
         self.bt_cbs = {}
         self.new_acc_bt_cbs = {}
         self.send_cbs = {}
         self.quit_cb = quit_cb
         self.bt_cbs = {}
         self.new_acc_bt_cbs = {}
         self.send_cbs = {}
         self.quit_cb = quit_cb
-        conv_cbs["write_im"] = self._write_im_cb
 
     def init_window(self):
         # Main vbox
 
     def init_window(self):
         # Main vbox
@@ -147,7 +69,6 @@ class MainWindow:
 
         self._window = etk.Window(title="NullClient-Etk", size_request=(600, 600), child=vbox)
         self._window.on_destroyed(self.quit_cb)
 
         self._window = etk.Window(title="NullClient-Etk", size_request=(600, 600), child=vbox)
         self._window.on_destroyed(self.quit_cb)
-        self.set_global_callbacks()
         self._window.show_all()
 
     def login_window(self, pointer):
         self._window.show_all()
 
     def login_window(self, pointer):
@@ -161,12 +82,6 @@ class MainWindow:
                 child=vbox_login)
         self.login_win.show_all()
 
                 child=vbox_login)
         self.login_win.show_all()
 
-    def set_global_callbacks(self):
-        global cbs
-        cbs["connection"]["connect_progress"] = self._purple_conn_status_cb
-        cbs["connection"]["disconnected"] = self._purple_disconnected_status_cb
-        cbs["connection"]["connected"] = self._purple_connected_cb
-
     def _conn_bt_cb(self, pointer):
         if self.bt_cbs.has_key("on_clicked"):
             self.bt_cbs["on_clicked"](self.login_password.text)
     def _conn_bt_cb(self, pointer):
         if self.bt_cbs.has_key("on_clicked"):
             self.bt_cbs["on_clicked"](self.login_password.text)
@@ -196,11 +111,6 @@ class MainWindow:
         if self.new_acc_bt_cbs.has_key("on_clicked"):
             self.new_acc_bt_cbs["on_clicked"]()
 
         if self.new_acc_bt_cbs.has_key("on_clicked"):
             self.new_acc_bt_cbs["on_clicked"]()
 
-    def _purple_conn_status_cb(self, txt, step, step_count):
-            self.lstatus.text = txt
-
-    def _purple_connected_cb(self):
-        self.lstatus.text = "Connected"
 
     def new_buddy(self, b):
             if [b] not in self.blistmodel.elements:
 
     def new_buddy(self, b):
             if [b] not in self.blistmodel.elements:
@@ -213,9 +123,6 @@ class MainWindow:
         if [a] not in self.accslistmodel.elements:
             self.accslistmodel.append([a])
 
         if [a] not in self.accslistmodel.elements:
             self.accslistmodel.append([a])
 
-    def _purple_disconnected_status_cb(self):
-        self.lstatus.text = "Disconnected"
-
     def set_panel_text(self, txt):
         self.txt_area = txt
 
     def set_panel_text(self, txt):
         self.txt_area = txt
 
@@ -235,38 +142,26 @@ class MainWindow:
         if callable(cb):
             self.quit_cb = cb
 
         if callable(cb):
             self.quit_cb = cb
 
-    def _write_im_cb(self, sender, alias, message):
-        if alias:
-            self.txt_area.text += alias + ": " + message + "<br> "
-        else:
-            self.txt_area.text += sender + ": " + message + "<br> "
-        self._window.show_all()
-
+    def show(self):
+        if self._window:
+            self._window.show_all()
 
 
-class NullClientPurple:
+class NullClientPurple(object):
     def __init__(self):
     def __init__(self):
-        self.p = purple.Purple(debug_enabled=False)
+        self.purple = purple.Purple(debug_enabled=False)
         self.window = MainWindow(self.quit)
         self.buddies = {} #all buddies
         self.conversations = {}
         self.protocol_id = "prpl-jabber"
         self.account = None
         self.window = MainWindow(self.quit)
         self.buddies = {} #all buddies
         self.conversations = {}
         self.protocol_id = "prpl-jabber"
         self.account = None
-        self.accs = None
-
 
 
-        self.p.add_account_cb("notify_added", account_callback)
-        self.p.add_account_cb("status_changed", account_callback)
-        self.p.add_account_cb("request_add", account_callback)
-        self.p.add_account_cb("request_authorize", account_callback)
-        self.p.add_account_cb("close_account_request", account_callback)
+        self.purple.add_callback("blist", "update", self.__purple_update_blist_cb)
+        self.purple.add_callback("connection", "connect-progress", self.__purple_conn_progress_cb)
+        self.purple.add_callback("connection", "connected", self.__purple_connected_cb)
+        self.purple.add_callback("connection", "disconnected", self.__purple_disconnected_cb)
+        self.purple.add_callback("conversation", "write-im", self.__purple_write_im_cb)
 
 
-        self.p.add_blist_cb("set_visible", blist_callback)
-        self.p.add_blist_cb("request_add_buddy", blist_callback)
-        self.p.add_blist_cb("request_add_chat", blist_callback)
-        self.p.add_blist_cb("request_add_group", blist_callback)
-        self.p.add_blist_cb("update", self._purple_update_blist_cb)
-
-        self.p.purple_init(cbs)
+        self.purple.purple_init()
 
         #Initializing UI
         self.window.add_bt_conn_cb(self.connect)
 
         #Initializing UI
         self.window.add_bt_conn_cb(self.connect)
@@ -274,7 +169,7 @@ class NullClientPurple:
         self.window.add_account_cb(self.add_account)
         self.window.init_window()
 
         self.window.add_account_cb(self.add_account)
         self.window.init_window()
 
-    def _purple_update_blist_cb(self, type, name=None, alias=None, \
+    def __purple_update_blist_cb(self, type, name=None, alias=None, \
                                 totalsize=None, currentsize=None, \
                                 online=None):
         if self.account and name != None and type == 2:
                                 totalsize=None, currentsize=None, \
                                 online=None):
         if self.account and name != None and type == 2:
@@ -285,38 +180,61 @@ class NullClientPurple:
             elif self.buddies[name].online:
                 self.window.new_buddy(name)
 
             elif self.buddies[name].online:
                 self.window.new_buddy(name)
 
-    def _purple_signal_buddy_signed_off_cb(self, name, alias):
+    def __purple_conn_progress_cb(self, text, step, step_count):
+        if self.window:
+            self.window.lstatus.text = text
+
+    def __purple_connected_cb(self, *data):
+        if self.window:
+            self.window.lstatus.text = "Connected"
+
+    def __purple_disconnected_cb(self, *data):
+        if self.window:
+            self.window.lstatus.text = "Disconnected"
+
+    def __purple_write_im_cb(self, sender, alias, message):
+        if self.window:
+            if alias:
+                self.window.txt_area.text += alias + ": " + message + "<br> "
+            else:
+                self.window.txt_area.text += sender + ": " + message + "<br> "
+            self.window.show()
+
+    def __purple_signal_buddy_signed_off_cb(self, name, alias):
         if self.buddies.has_key(name):
             self.buddies[name] = None
             self.buddies.pop(name)
             print "[DEBUG]: Buddy removed!"
         self.window.remove_buddy(name)
 
         if self.buddies.has_key(name):
             self.buddies[name] = None
             self.buddies.pop(name)
             print "[DEBUG]: Buddy removed!"
         self.window.remove_buddy(name)
 
-    def _purple_create_conv_cb(self, name, type):
-        bname = name.split("/")[0]
-        if bname in self.buddies and not self.conversations.has_key(name):
-            conv = purple.Conversation()
-            conv.initialize(self.account, "IM", bname)
-            self.conversations[bname] = conv
+    def __purple_signal_jabber_receiving_xmlnode_cb(self, message):
+    xml = minidom.parse(message)
+
+    for msg in xml.getElementsByTagName("message"):
+        who = msg.getAttribute("from")
+        for geoloc in msg.getElementsByTagNameNS("http://jabber.org/protocol/geoloc", "geoloc"):
+            lat = geoloc.getElementsByTagName("lat")[0].childNodes[0].nodeValue
+            lon = geoloc.getElementsByTagName("lon")[0].childNodes[0].nodeValue
+            print "who: %s lat: %s lon: %s" % (who, lat, lon)
+
+    def add_account(self):
+        username = "carmanplugintest@gmail.com"
+        host = "172.18.216.211"
+        port = 8080
+        self.purple.account_add(username, self.protocol_id, host, port)
+        for account in self.purple.accounts.keys():
+            self.window.new_account(account)
 
     def connect(self, password):
         username_acc = self.window.selected_accs()
         if username_acc:
 
     def connect(self, password):
         username_acc = self.window.selected_accs()
         if username_acc:
-            self.account = self.p.account_verify(username_acc)
+            self.account = self.purple.account_verify(username_acc)
             self.account.get_protocol_options()
             self.account.set_enabled("carman-purple-python", True)
             self.account.password = password
             self.account.get_protocol_options()
             self.account.set_enabled("carman-purple-python", True)
             self.account.password = password
-            self.p.connect()
-            self.p.signal_connect("buddy-signed-off", self._purple_signal_buddy_signed_off_cb)
-
-    def add_account(self):
-        username = "carmanplugintest@gmail.com"
-        host = "172.18.216.211"
-        port = 8080
-        self.p.account_add(username, self.protocol_id, host, port)
-        self.accs = self.p.accounts
-        for acc in self.accs.keys():
-            self.window.new_account(acc)
+            self.purple.connect()
+            self.purple.signal_connect("buddy-signed-off", self.__purple_signal_buddy_signed_off_cb)
+            self.purple.signal_connect("jabber-receiving-xmlnode", self.__purple_signal_jabber_receiving_xmlnode_cb)
 
     def send_msg(self, name, msg):
         if not self.conversations.has_key(name):
 
     def send_msg(self, name, msg):
         if not self.conversations.has_key(name):
@@ -331,7 +249,7 @@ class NullClientPurple:
             self.conversations[i].destroy()
             self.conversations[i] = None
         self.conversations = None
             self.conversations[i].destroy()
             self.conversations[i] = None
         self.conversations = None
-        self.p.destroy()
+        self.purple.destroy()
         ecore.main_loop_quit()
 
 if __name__ == '__main__':
         ecore.main_loop_quit()
 
 if __name__ == '__main__':
diff --git a/nullclient.py b/nullclient.py
deleted file mode 100644 (file)
index a79f3da..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-import purple
-import ecore
-import getpass
-import sys
-from xml.dom import minidom
-
-cbs = {}
-acc_cbs = {}
-blist_cbs = {}
-conn_cbs = {}
-conv_cbs = {}
-notify_cbs = {}
-request_cbs = {}
-
-def account_callback(name):
-    print "---- account callback example: %s" % name
-
-acc_cbs["notify_added"] = account_callback
-acc_cbs["status_changed"] = account_callback
-acc_cbs["request_add"] = account_callback
-acc_cbs["request_authorize"] = account_callback
-acc_cbs["close_account_request"] = account_callback
-
-cbs["account"] = acc_cbs
-
-def blist_callback(name):
-    print "---- blist callback example: %s" % name
-
-blist_cbs["new_list"] = blist_callback
-blist_cbs["show"] = blist_callback
-blist_cbs["destroy"] = blist_callback
-blist_cbs["set_visible"] = blist_callback
-blist_cbs["request_add_buddy"] = blist_callback
-blist_cbs["request_add_chat"] = blist_callback
-blist_cbs["request_add_group"] = blist_callback
-
-def new_node_cb(type, name=None, totalsize=None, currentsize=None, online=None):
-    if type == 0:
-        print "---- blist callback: new node (group): %s (%s/%s) (%s online)" % \
-                (name, totalsize, currentsize, online)
-    elif type == 1:
-        print "---- blist callback: new node (contact): %s (%s/%s) (%s online)" % \
-                (name, totalsize, currentsize, online)
-    elif type == 2: # totalsize = alias
-        print "---- blist callback: new node (buddy): %s (%s)" % (name, totalsize)
-    elif type == 3:
-        print "---- blist callback: new node (chat): %s" % alias
-    elif type == 4:
-        print "---- blist callback: new node (other type)"
-    else:
-        print "---- blist callback: new node (unknown type %s)" % type
-
-def update_cb(type, name=None, totalsize=None, currentsize=None, online=None):
-    if type == 0:
-        print "---- blist callback: update (group): %s (%s/%s) (%s online)" % \
-                (name, totalsize, currentsize, online)
-    elif type == 1:
-        print "---- blist callback: update (contact): %s (%s/%s) (%s online)" % \
-                (name, totalsize, currentsize, online)
-    elif type == 2: # totalsize = alias
-        print "---- blist callback: update (buddy): %s (%s)" % \
-                (name, totalsize)
-    elif type == 3:
-        print "---- blist callback: update (chat): %s" % alias
-    elif type == 4:
-        print "---- blist callback: update (other type)"
-    else:
-        print "---- blist callback: update (unknown type %s)" % type
-
-def remove_cb(type, name=None, totalsize=None, currentsize=None, online=None):
-    if type == 0:
-        print "---- blist callback: remove (group): %s (%s/%s) (%s online)" % \
-                (name, totalsize, currentsize, online)
-    elif type == 1:
-        print "---- blist callback: remove (contact): %s (%s/%s) (%s online)" % \
-                (name, totalsize, currentsize, online)
-    elif type == 2: # totalsize = alias
-        print "---- blist callback: remove (buddy): %s (%s)" % \
-                (name, totalsize)
-    elif type == 3:
-        print "---- blist callback: remove (chat): %s" % alias
-    elif type == 4:
-        print "---- blist callback: remove (other type)"
-    else:
-        print "---- blist callback: remove (unknown type %s)" % type
-
-blist_cbs["new_node"] = new_node_cb
-blist_cbs["update"] = update_cb
-blist_cbs["remove"] = remove_cb
-
-cbs["blist"] = blist_cbs
-
-def conn_callback(name):
-    print "---- connection callback example: %s" % name
-
-conn_cbs["notice"] = conn_callback
-conn_cbs["network_connected"] = conn_callback
-conn_cbs["network_disconnected"] = 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
-
-def conv_callback(name):
-    print "---- conversation callback example: %s" % name
-
-def write_im_cb(name, message):
-    print "---- (conversation) write_im: %s %s" % (name, message)
-
-conv_cbs["create_conversation"] = conv_callback
-conv_cbs["destroy_conversation"] = conv_callback
-conv_cbs["write_chat"] = conv_callback
-conv_cbs["write_im"] = write_im_cb
-conv_cbs["write_conv"] = conv_callback
-conv_cbs["chat_add_users"] = conv_callback
-conv_cbs["chat_rename_user"] = conv_callback
-conv_cbs["chat_remove_users"] = conv_callback
-conv_cbs["chat_update_user"] = conv_callback
-conv_cbs["present"] = conv_callback
-conv_cbs["has_focus"] = conv_callback
-conv_cbs["custom_smiley_add"] = conv_callback
-conv_cbs["custom_smiley_write"] = conv_callback
-conv_cbs["custom_smiley_close"] = conv_callback
-conv_cbs["send_confirm"] = conv_callback
-
-cbs["conversation"] = conv_cbs
-
-def notify_callback(name):
-    print "----  notify callback example: %s" % name
-
-notify_cbs["notify_message"] = notify_callback
-notify_cbs["notify_email"] = notify_callback
-notify_cbs["notify_emails"] = notify_callback
-notify_cbs["notify_formatted"] = notify_callback
-notify_cbs["notify_searchresults"] = notify_callback
-notify_cbs["notify_searchresults_new_rows"] = notify_callback
-notify_cbs["notify_userinfo"] = notify_callback
-notify_cbs["notify_uri"] = notify_callback
-notify_cbs["close_notify"] = notify_callback
-
-cbs["notify"] = notify_cbs
-
-def request_callback(name):
-    print "---- request callback example: %s" % name
-
-request_cbs["request_input"] = request_callback
-request_cbs["request_choice"] = request_callback
-request_cbs["request_action"] = request_callback
-request_cbs["request_fields"] = request_callback
-request_cbs["request_file"] = request_callback
-request_cbs["close_request"] = request_callback
-request_cbs["request_folder"] = request_callback
-
-cbs["request"] = request_cbs
-
-def buddy_signed_off_cb(name):
-    print "---- (signal) sign off from buddy %s" % name
-
-def receiving_im_msg_cb(sender, name, message):
-    print "---- (signal) receiving IM message from %s: %s" % (name, message)
-    return False
-
-def jabber_received_xmlnode_cb(message):
-    xml = minidom.parse(message)
-
-    for msg in xml.getElementsByTagName("message"):
-        who = msg.getAttribute("from")
-        for geoloc in msg.getElementsByTagNameNS("http://jabber.org/protocol/geoloc", "geoloc"):
-            lat = geoloc.getElementsByTagName("lat")[0].childNodes[0].nodeValue
-            lon = geoloc.getElementsByTagName("lon")[0].childNodes[0].nodeValue
-            print "who: %s lat: %s lon: %s" % (who, lat, lon)
-
-class NullClient:
-    def __init__(self):
-        self.p = purple.Purple(debug_enabled=False)
-        self.account = None
-        self.protocol_id = "prpl-jabber"
-
-    def execute(self):
-        global cbs
-        self.p.purple_init(cbs)
-
-    def new_account(self, username, password):
-        self.account = purple.Account(username, self.protocol_id)
-        self.account.password = password
-
-        self.account.proxy.set_type(purple.ProxyInfoType().HTTP)
-        self.account.proxy.set_host("172.18.216.211")
-        self.account.proxy.set_port(8080)
-
-        self.account.get_protocol_options()
-
-        self.account.set_enabled("carman-purple-python", True)
-    def get_buddies(self):
-        buddies = self.account.get_buddies_online()
-        print buddies
-
-def getuser():
-    sys.stdout.write("GTalk account: ")
-    username = sys.stdin.readline()
-    return username[:-1]
-
-def getpassword():
-    return getpass.getpass()
-
-if __name__ == '__main__':
-    client = NullClient()
-    client.execute()
-    client.p.signal_connect("buddy-signed-off", buddy_signed_off_cb)
-    client.p.signal_connect("receiving-im-msg", receiving_im_msg_cb)
-    client.p.signal_connect("jabber-receiving-xmlnode", jabber_received_xmlnode_cb)
-    username = getuser()
-    password = getpassword()
-
-    client.p.connect()
-    ecore.timer_add(20, client.get_buddies)
-    ecore.main_loop_begin()
index 54be931..cabbbae 100644 (file)
@@ -137,20 +137,9 @@ cdef class Purple:
         glib.g_main_context_iteration(NULL, False)
         return True
 
         glib.g_main_context_iteration(NULL, False)
         return True
 
-    def purple_init(self, callbacks_dict=None):
+    def purple_init(self):
         """ Initializes libpurple """
 
         """ Initializes libpurple """
 
-        if callbacks_dict is not None:
-            global connection_cbs
-            global conversation_cbs
-            global notify_cbs
-            global request_cbs
-
-            connection_cbs = callbacks_dict["connection"]
-            conversation_cbs = callbacks_dict["conversation"]
-            notify_cbs = callbacks_dict["notify"]
-            request_cbs = callbacks_dict["request"]
-
         c_account_ui_ops.notify_added = notify_added
         c_account_ui_ops.status_changed = status_changed
         c_account_ui_ops.request_add = request_add
         c_account_ui_ops.notify_added = notify_added
         c_account_ui_ops.status_changed = status_changed
         c_account_ui_ops.request_add = request_add
@@ -251,13 +240,23 @@ cdef class Purple:
 
         return ret
 
 
         return ret
 
-    def add_account_cb(self, name, func):
+    def add_callback(self, type, name, func):
+        """ Adds a callback 'func' with given name 'name' inside type 'type'.
+        Example: add_callback("account", "notify-added", notify_added_cb)
+        """
         global account_cbs
         global account_cbs
-        account_cbs[name] = func
-
-    def add_blist_cb(self, name, func):
         global blist_cbs
         global blist_cbs
-        blist_cbs[name] = func
+        global connection_cbs
+        global conversation_cbs
+        global notify_cbs
+        global request_cbs
+
+        { "account": account_cbs,
+          "blist": blist_cbs,
+          "connection": connection_cbs,
+          "conversation": conversation_cbs,
+          "notify": notify_cbs,
+          "request": request_cbs }[type][name] = func
 
     def connect(self):
         conn = Connection()
 
     def connect(self):
         conn = Connection()
index 3057bdc..22bbc40 100644 (file)
@@ -35,9 +35,9 @@ cdef void *request_input (const_char *title, const_char *primary,
                           account.PurpleAccount *account, const_char *who,
                           conversation.PurpleConversation *conv,
                           void *user_data):
                           account.PurpleAccount *account, const_char *who,
                           conversation.PurpleConversation *conv,
                           void *user_data):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request", "request_input\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request", "request-input\n")
     try:
     try:
-        (<object>request_cbs["request_input"])("request_input")
+        (<object>request_cbs["request-input"])("request-input: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -50,9 +50,9 @@ cdef void *request_choice (const_char *title, const_char *primary,
                            conversation.PurpleConversation *conv,
                            void *user_data, va_list choices):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
                            conversation.PurpleConversation *conv,
                            void *user_data, va_list choices):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
-                         "request_choice\n")
+                         "request-choice\n")
     try:
     try:
-        (<object>request_cbs["request_choice"])("request_choice")
+        (<object>request_cbs["request-choice"])("request-choice: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -63,9 +63,9 @@ cdef void *request_action (const_char *title, const_char *primary,
                            void *user_data, size_t action_count,
                            va_list actions):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
                            void *user_data, size_t action_count,
                            va_list actions):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
-                         "request_action\n")
+                         "request-action\n")
     try:
     try:
-        (<object>request_cbs["request_action"])("request_action")
+        (<object>request_cbs["request-action"])("request-action: TODo")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -78,9 +78,9 @@ cdef void *request_fields (const_char *title, const_char *primary,
                            conversation.PurpleConversation *conv,
                            void *user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
                            conversation.PurpleConversation *conv,
                            void *user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
-                         "request_fields\n")
+                         "request-fields\n")
     try:
     try:
-        (<object>request_cbs["request_fields"])("request_fields")
+        (<object>request_cbs["request-fields"])("request-fields: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -90,16 +90,16 @@ cdef void *request_file (const_char *title, const_char *filename,
                          account.PurpleAccount *account, const_char *who,
                          conversation.PurpleConversation *conv,
                          void *user_data):
                          account.PurpleAccount *account, const_char *who,
                          conversation.PurpleConversation *conv,
                          void *user_data):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request", "request_file\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request", "request-file\n")
     try:
     try:
-        (<object>request_cbs["request_file"])("request_file")
+        (<object>request_cbs["request-file"])("request-file: TODO")
     except KeyError:
         pass
 
 cdef void close_request (request.PurpleRequestType type, void *ui_handle):
     except KeyError:
         pass
 
 cdef void close_request (request.PurpleRequestType type, void *ui_handle):
-    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request", "close_request\n")
+    debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request", "close-request\n")
     try:
     try:
-        (<object>request_cbs["close_request"])("close_request")
+        (<object>request_cbs["close-request"])("close-request: TODO")
     except KeyError:
         pass
 
     except KeyError:
         pass
 
@@ -111,8 +111,8 @@ cdef void *request_folder (const_char *title, const_char *dirname,
                            conversation.PurpleConversation *conv,
                            void *user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
                            conversation.PurpleConversation *conv,
                            void *user_data):
     debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "request",
-                         "request_folder\n")
+                         "request-folder\n")
     try:
     try:
-        (<object>request_cbs["request_folder"])("request_folder")
+        (<object>request_cbs["request-folder"])("request-folder: TODO")
     except KeyError:
         pass
     except KeyError:
         pass