From 331a01e87b796450c4756c69bb88b45b1c46f9d0 Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:45:16 +0000 Subject: [PATCH] Conversation: who added Who variable added to write_im callback. Now, it's possible to know who is sending a message. Take care to check if "who" is not None. Signed-off-by: Anderson Briglia git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1347 596f6dd7-e928-0410-a184-9e12fd12cf7e --- conversation.pyx | 1 + conversation_cbs.pxd | 6 +++++- nullclient-ecore.py | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/conversation.pyx b/conversation.pyx index f743e41..6b44c63 100644 --- a/conversation.pyx +++ b/conversation.pyx @@ -81,4 +81,5 @@ cdef class Conversation: conversation.c_purple_conversations_get_handle() def destroy(self): + print "[DEBUG]: Destroy conversation: %s" % self.name conversation.c_purple_conversation_destroy(self.__conv) diff --git a/conversation_cbs.pxd b/conversation_cbs.pxd index 53729d2..4f8852a 100644 --- a/conversation_cbs.pxd +++ b/conversation_cbs.pxd @@ -56,8 +56,12 @@ 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") + if who: + sender = who + else: + sender = None try: - (conversation_cbs["write_im"])(conv.account.username, message) + (conversation_cbs["write_im"])(conv.account.username, sender, message) except KeyError: pass diff --git a/nullclient-ecore.py b/nullclient-ecore.py index 8825af4..cd99eec 100644 --- a/nullclient-ecore.py +++ b/nullclient-ecore.py @@ -211,8 +211,12 @@ class MainWindow: if callable(cb): self.quit_cb = cb - def _write_im_cb(self, name, message): - self.txt_area.text += str(name) + ": " + str(message) + "
" + def _write_im_cb(self, name, who, message): + if who: + w = who.split("/")[0] + self.txt_area.text += w + ": " + str(message) + "
" + else: + self.txt_area.text += str(name) + ": " + str(message) + "
" self._window.show_all() -- 1.7.9.5