Added majority of libpurple functions used by pidgin-carman.
[python-purple] / conversation.pxd
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 cdef class Conversation:
21     """ Conversation class """
22     cdef PurpleConversation *__conv
23
24     def __cinit__(self):
25         c_purple_conversations_init()
26
27     def conversation_new(self, type, acc, const_char_ptr name):
28         self.__conv = c_purple_conversation_new(type, <PurpleAccount*>acc.__account, name)
29
30     def conversation_set_ui_ops(self):
31         cdef PurpleConversationUiOps c_conv_ui_ops
32         c_conv_ui_ops.create_conversation = NULL
33         c_conv_ui_ops.destroy_conversation = NULL
34         c_conv_ui_ops.write_chat = NULL
35         c_conv_ui_ops.write_im = NULL
36         c_conv_ui_ops.write_conv = NULL
37         c_conv_ui_ops.chat_add_users = NULL
38         c_conv_ui_ops.chat_rename_user = NULL
39         c_conv_ui_ops.chat_remove_users = NULL
40         c_conv_ui_ops.chat_update_user = NULL
41         c_conv_ui_ops.present = NULL
42         c_conv_ui_ops.has_focus = NULL
43         c_conv_ui_ops.custom_smiley_add = NULL
44         c_conv_ui_ops.custom_smiley_write = NULL
45         c_conv_ui_ops.custom_smiley_close = NULL
46         c_conv_ui_ops.send_confirm = NULL
47
48         c_purple_conversation_set_ui_ops(self.__conv, &c_conv_ui_ops)
49
50     def conversation_write(self, const_char_ptr message):
51         c_purple_conv_im_send(c_purple_conversation_get_im_data(self.__conv), message)
52
53     def conversation_destroy(self):
54         c_purple_conversation_destroy(self.__conv)
55
56     def conversation_get_handle(self):
57         c_purple_conversations_get_handle()
58
59     def send_message(self, buddy, const_char_ptr message):
60         self.conversation_new(1, buddy.account, buddy.name)
61         self.conversation_set_ui_ops()
62         self.conversation_write(message)