More fixes to BFP.
[python-purple] / account.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 class ProxyType:
21     def __init__(self):
22         self.PROXY_USE_GLOBAL = -1
23         self.PROXY_NONE = 0
24         self.PROXY_HTTP = 1
25         self.PROXY_SOCKS4 = 2
26         self.PROXY_SOCKS5 = 3
27         self.PROXY_USE_ENVVAR = 4
28
29
30 class StatusPrimitive:
31     def __init__(self):
32         self.STAUTS_UNSET = 0
33         self.STATUS_OFFLINE = 1
34         self.STATUS_AVAILABLE = 2
35         self.STATUS_UNAVAILABLE = 3
36         self.STATUS_INVISIBLE = 4
37         self.STATUS_AWAY = 5
38         self.STATUS_EXTENDED_AWAY = 6
39         self.STATUS_MOBILE = 7
40         self.STATUS_TUNE = 8
41         self.STATUS_NUN_PRIMITIVE = 9
42
43 cdef class Account:
44     """ Account class """
45     cdef PurpleAccount *__account
46     cdef PurpleSavedStatus *__sstatus
47
48     def __cinit__(self, const_char_ptr username, const_char_ptr protocol_id):
49         self.__account = c_purple_account_new(username, protocol_id)
50
51     def set_password(self, password):
52         c_purple_account_set_password(self.__account, password)
53
54     def set_enabled(self, ui, value):
55         c_purple_account_set_enabled(self.__account, ui, value)
56
57     def get_acc_username(self):
58         if self.__account:
59             return c_purple_account_get_username(self.__account)
60
61     def get_password(self):
62         if self.__account:
63             return c_purple_account_get_password(self.__account)
64
65     def set_status(self):
66         self.__sstatus = c_purple_savedstatus_new(NULL, StatusPrimitive().STATUS_AVAILABLE)
67         c_purple_savedstatus_activate(self.__sstatus)
68