X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=conversation_cbs.pxd;h=573ef15a5ca05203bf5d97450e05265f5e70b3a3;hp=87218be947f5d5695d84ff9ec6d3070d8fa943bc;hb=7752e0f4a14a32ede02b8b86c83d9510338a59ed;hpb=7381856ac5ae6c571217363736a97b42291b328d diff --git a/conversation_cbs.pxd b/conversation_cbs.pxd index 87218be..573ef15 100644 --- a/conversation_cbs.pxd +++ b/conversation_cbs.pxd @@ -31,27 +31,28 @@ cdef void create_conversation(conversation.PurpleConversation *conv): Called when a conv is created (but before the conversation-created signal is emitted). """ - debug.c_purple_debug_info("conversation", "%s", "create-conversation\n") + debug.purple_debug_info("conversation", "%s", "create-conversation\n") cdef char *c_name = NULL - c_name = conversation.c_purple_conversation_get_name(conv) + c_name = conversation.purple_conversation_get_name(conv) if c_name == NULL: name = None else: name = c_name - type = conversation.c_purple_conversation_get_type(conv) + type = conversation.purple_conversation_get_type(conv) - if conversation_cbs.has_key("create-conversation"): + if "create-conversation" in conversation_cbs: ( conversation_cbs["create-conversation"])(name, type) cdef void destroy_conversation(conversation.PurpleConversation *conv): """ Called just before a conv is freed. """ - debug.c_purple_debug_info("conversation", "%s", "destroy-conversation\n") - if conversation_cbs.has_key("destroy-conversation"): - ( conversation_cbs["destroy-conversation"])("destroy-conversation: TODO") + debug.purple_debug_info("conversation", "%s", "destroy-conversation\n") + if "destroy-conversation" in conversation_cbs: + ( conversation_cbs["destroy-conversation"]) \ + ("destroy-conversation: TODO") cdef void write_chat(conversation.PurpleConversation *conv, const_char *who, \ const_char *message, conversation.PurpleMessageFlags flags, \ @@ -61,8 +62,8 @@ cdef void write_chat(conversation.PurpleConversation *conv, const_char *who, \ back to using write_conv. @see purple_conv_chat_write() """ - debug.c_purple_debug_info("conversation", "%s", "write-chat\n") - if conversation_cbs.has_key("write-chat"): + debug.purple_debug_info("conversation", "%s", "write-chat\n") + if "write-chat" in conversation_cbs: ( conversation_cbs["write-chat"])("write-chat: TODO") cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \ @@ -73,27 +74,29 @@ cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \ will fall back to using write_conv. @see purple_conv_im_write() """ - debug.c_purple_debug_info("conversation", "%s", "write-im\n") - cdef account.PurpleAccount *acc = conversation.c_purple_conversation_get_account(conv) + debug.purple_debug_info("conversation", "%s", "write-im\n") + cdef account.PurpleAccount *acc = \ + conversation.purple_conversation_get_account(conv) cdef blist.PurpleBuddy *buddy = NULL cdef char *c_username = NULL cdef char *c_sender_alias = NULL - c_username = account.c_purple_account_get_username(acc) + c_username = account.purple_account_get_username(acc) if c_username: username = c_username else: username = None - if who: - sender = who - buddy = blist.c_purple_find_buddy(acc, who) - c_sender_alias = blist.c_purple_buddy_get_alias_only(buddy) - else: - sender = None + if who == NULL: + who = conversation.purple_conversation_get_name(conv) + + sender = who + buddy = blist.purple_find_buddy(acc, who) + if buddy: + c_sender_alias = blist.purple_buddy_get_alias_only(buddy) if c_sender_alias: - sender_alias = c_sender_alias + sender_alias = unicode(c_sender_alias, 'utf-8') else: sender_alias = None @@ -102,9 +105,15 @@ cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \ else: message = None - if conversation_cbs.has_key("write-im"): + # FIXME: Maybe we need add more purple flags in the future + if flags & conversation.PURPLE_MESSAGE_SEND: + flag = "SEND" + else: + flag = "RECV" + + if "write-im" in conversation_cbs: ( conversation_cbs["write-im"])(username, sender, \ - sender_alias, message) + sender_alias, message, flag) cdef void write_conv(conversation.PurpleConversation *conv, const_char *name, \ const_char *alias, const_char *message, \ @@ -117,8 +126,8 @@ cdef void write_conv(conversation.PurpleConversation *conv, const_char *name, \ and your users will hate you. @see purple_conversation_write() """ - debug.c_purple_debug_info("conversation", "%s", "write-conv\n") - if conversation_cbs.has_key("write-conv"): + debug.purple_debug_info("conversation", "%s", "write-conv\n") + if "write-conv" in conversation_cbs: ( conversation_cbs["write-conv"])("write-conv: TODO") cdef void chat_add_users(conversation.PurpleConversation *conv, \ @@ -131,8 +140,8 @@ cdef void chat_add_users(conversation.PurpleConversation *conv, \ conversation by purple_conv_chat_add_users().) @see purple_conv_chat_add_users() """ - debug.c_purple_debug_info("conversation", "%s", "chat-add-users\n") - if conversation_cbs.has_key("chat-add-users"): + debug.purple_debug_info("conversation", "%s", "chat-add-users\n") + if "chat-add-users" in conversation_cbs: ( conversation_cbs["chat-add-users"])("chat-add-users: TODO") cdef void chat_rename_user(conversation.PurpleConversation *conv, \ @@ -144,9 +153,10 @@ cdef void chat_rename_user(conversation.PurpleConversation *conv, \ @param new_alias new_name's new_alias, if they have one. @see purple_conv_chat_rename_user() """ - debug.c_purple_debug_info("conversation", "%s", "chat-rename-user\n") - if conversation_cbs.has_key("chat-rename-user"): - ( conversation_cbs["chat-rename-user"])("chat-rename-user: TODO") + debug.purple_debug_info("conversation", "%s", "chat-rename-user\n") + if "chat-rename-user" in conversation_cbs: + ( conversation_cbs["chat-rename-user"]) \ + ("chat-rename-user: TODO") cdef void chat_remove_users(conversation.PurpleConversation *conv, \ glib.GList *users): @@ -154,9 +164,10 @@ cdef void chat_remove_users(conversation.PurpleConversation *conv, \ Remove users from a chat. @param users A GList of const char *s. """ - debug.c_purple_debug_info("conversation", "%s", "chat-remove-users\n") - if conversation_cbs.has_key("chat-remove-users"): - ( conversation_cbs["chat-remove-users"])("chat-remove-users: TODO") + debug.purple_debug_info("conversation", "%s", "chat-remove-users\n") + if "chat-remove-users" in conversation_cbs: + ( conversation_cbs["chat-remove-users"]) \ + ("chat-remove-users: TODO") cdef void chat_update_user(conversation.PurpleConversation *conv, \ const_char *user): @@ -164,17 +175,18 @@ cdef void chat_update_user(conversation.PurpleConversation *conv, \ Called when a user's flags are changed. @see purple_conv_chat_user_set_flags() """ - debug.c_purple_debug_info("conversation", "%s", "chat-update-user\n") - if conversation_cbs.has_key("chat-update-user"): - ( conversation_cbs["chat-update-user"])("chat-update-user: TODO") + debug.purple_debug_info("conversation", "%s", "chat-update-user\n") + if "chat-update-user" in conversation_cbs: + ( conversation_cbs["chat-update-user"]) \ + ("chat-update-user: TODO") cdef void present(conversation.PurpleConversation *conv): """ Present this conversation to the user; for example, by displaying the IM dialog. """ - debug.c_purple_debug_info("conversation", "%s", "present\n") - if conversation_cbs.has_key("present"): + debug.purple_debug_info("conversation", "%s", "present\n") + if "present" in conversation_cbs: ( conversation_cbs["present"])("present: TODO") cdef glib.gboolean has_focus(conversation.PurpleConversation *conv): @@ -182,8 +194,8 @@ cdef glib.gboolean has_focus(conversation.PurpleConversation *conv): If this UI has a concept of focus (as in a windowing system) and this conversation has the focus, return TRUE; otherwise, return FALSE. """ - debug.c_purple_debug_info("conversation", "%s", "has-focus\n") - if conversation_cbs.has_key("has-focus"): + debug.purple_debug_info("conversation", "%s", "has-focus\n") + if "has-focus" in conversation_cbs: ( conversation_cbs["has-focus"])("has-focus: TODO") return False @@ -192,9 +204,10 @@ cdef glib.gboolean custom_smiley_add(conversation.PurpleConversation *conv, \ """ Custom smileys (add). """ - debug.c_purple_debug_info("conversation", "%s", "custom-smiley-add\n") - if conversation_cbs.has_key("custom-smiley-add"): - ( conversation_cbs["custom-smiley-add"])("custom-smiley-add: TODO") + debug.purple_debug_info("conversation", "%s", "custom-smiley-add\n") + if "custom-smiley-add" in conversation_cbs: + ( conversation_cbs["custom-smiley-add"]) \ + ("custom-smiley-add: TODO") return False cdef void custom_smiley_write(conversation.PurpleConversation *conv, \ @@ -202,18 +215,20 @@ cdef void custom_smiley_write(conversation.PurpleConversation *conv, \ """ Custom smileys (write). """ - debug.c_purple_debug_info("conversation", "%s", "custom-smiley-write\n") - if conversation_cbs.has_key("custom-smiley-write"): - ( conversation_cbs["custom-smiley-write"])("custom-smiley-write: TODO") + debug.purple_debug_info("conversation", "%s", "custom-smiley-write\n") + if "custom-smiley-write" in conversation_cbs: + ( conversation_cbs["custom-smiley-write"]) \ + ("custom-smiley-write: TODO") cdef void custom_smiley_close(conversation.PurpleConversation *conv, \ const_char *smile): """ Custom smileys (close). """ - debug.c_purple_debug_info("conversation", "%s", "custom-smiley-close\n") - if conversation_cbs.has_key("custom-smiley-close"): - ( conversation_cbs["custom-smiley-close"])("custom-smiley-close: TODO") + debug.purple_debug_info("conversation", "%s", "custom-smiley-close\n") + if "custom-smiley-close" in conversation_cbs: + ( conversation_cbs["custom-smiley-close"]) \ + ("custom-smiley-close: TODO") cdef void send_confirm(conversation.PurpleConversation *conv, \ const_char *message): @@ -222,6 +237,6 @@ cdef void send_confirm(conversation.PurpleConversation *conv, \ arrange for the message to be sent if the user accepts. If this field is NULL, libpurple will fall back to using purple_request_action(). """ - debug.c_purple_debug_info("conversation", "%s", "send-confirm\n") - if conversation_cbs.has_key("send-confirm"): + debug.purple_debug_info("conversation", "%s", "send-confirm\n") + if "send-confirm" in conversation_cbs: ( conversation_cbs["send-confirm"])("send-confirm: TODO")