Adding Classes Plugin and PluginInfo
[python-purple] / conversation.pyx
1 #
2 #  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
3 #
4 #  This file is part of python-purple.
5 #
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.
10 #
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.
15 #
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/>.
18 #
19
20 cimport purple
21
22 cdef class Conversation:
23     """ Conversation class """
24     cdef conversation.PurpleConversation *__conv
25
26     def __init__(self):
27         conversation.c_purple_conversations_init()
28
29     def conversation_new(self, type, acc, char *name):
30         self.__conv = conversation.c_purple_conversation_new(type, <account.PurpleAccount*>acc.__account, name)
31
32     def conversation_set_ui_ops(self):
33         cdef conversation.PurpleConversationUiOps c_conv_ui_ops
34         c_conv_ui_ops.create_conversation = NULL
35         c_conv_ui_ops.destroy_conversation = NULL
36         c_conv_ui_ops.write_chat = NULL
37         c_conv_ui_ops.write_im = NULL
38         c_conv_ui_ops.write_conv = NULL
39         c_conv_ui_ops.chat_add_users = NULL
40         c_conv_ui_ops.chat_rename_user = NULL
41         c_conv_ui_ops.chat_remove_users = NULL
42         c_conv_ui_ops.chat_update_user = NULL
43         c_conv_ui_ops.present = NULL
44         c_conv_ui_ops.has_focus = NULL
45         c_conv_ui_ops.custom_smiley_add = NULL
46         c_conv_ui_ops.custom_smiley_write = NULL
47         c_conv_ui_ops.custom_smiley_close = NULL
48         c_conv_ui_ops.send_confirm = NULL
49
50         conversation.c_purple_conversation_set_ui_ops(self.__conv, &c_conv_ui_ops)
51
52     def conversation_write(self, char *message):
53         conversation.c_purple_conv_im_send(conversation.c_purple_conversation_get_im_data(self.__conv), message)
54
55     def conversation_destroy(self):
56         conversation.c_purple_conversation_destroy(self.__conv)
57
58     def conversation_get_handle(self):
59         conversation.c_purple_conversations_get_handle()
60
61     def send_message(self, buddy, char *message):
62         self.conversation_new(1, buddy.account, buddy.name)
63         self.conversation_set_ui_ops()
64         self.conversation_write(message)