2 # Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
4 # This file is part of python-purple.
6 # python-purple is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # python-purple is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 cdef class Conversation:
23 """ Conversation class """
24 cdef conversation.PurpleConversation *__conv
30 conversation.c_purple_conversations_init()
34 def __get_account(self):
36 def __set_account(self, acc):
38 account = property(__get_account, __set_account)
42 def __set_name(self, name):
44 name = property(__get_name, __set_name)
46 def initialize(self, acc, type, char *name):
47 cdef account.PurpleAccount *c_account
51 c_account = account.c_purple_accounts_find(acc[0], acc[1])
57 conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_UNKNOWN,\
58 c_account, self.__name)
61 conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_IM,\
62 <account.PurpleAccount*> c_account, self.__name)
65 conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_CHAT,\
66 c_account, self.__name)
69 conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_MISC,\
70 c_account, self.__name)
73 conversation.c_purple_conversation_new(conversation.PURPLE_CONV_TYPE_ANY,\
74 c_account, self.__name)
76 def conversation_set_ui_ops(self):
77 cdef conversation.PurpleConversationUiOps c_conv_ui_ops
78 c_conv_ui_ops.create_conversation = NULL
79 c_conv_ui_ops.destroy_conversation = NULL
80 c_conv_ui_ops.write_chat = NULL
81 c_conv_ui_ops.write_im = NULL
82 c_conv_ui_ops.write_conv = NULL
83 c_conv_ui_ops.chat_add_users = NULL
84 c_conv_ui_ops.chat_rename_user = NULL
85 c_conv_ui_ops.chat_remove_users = NULL
86 c_conv_ui_ops.chat_update_user = NULL
87 c_conv_ui_ops.present = NULL
88 c_conv_ui_ops.has_focus = NULL
89 c_conv_ui_ops.custom_smiley_add = NULL
90 c_conv_ui_ops.custom_smiley_write = NULL
91 c_conv_ui_ops.custom_smiley_close = NULL
92 c_conv_ui_ops.send_confirm = NULL
94 conversation.c_purple_conversation_set_ui_ops(self.__conv, &c_conv_ui_ops)
96 def write(self, char *message):
98 conversation.c_purple_conv_im_send(conversation.c_purple_conversation_get_im_data(self.__conv), message)
100 def get_handle(self):
101 conversation.c_purple_conversations_get_handle()
104 print "[DEBUG]: Destroy conversation: %s" % self.__name
106 conversation.c_purple_conversation_destroy(self.__conv)