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/>.
30 def __init__(self, core, username, protocol_id):
32 self.__username = username
33 self.__protocol = Protocol(self, protocol_id)
35 if self._get_structure() == NULL:
40 cdef account.PurpleAccount *_get_structure(self):
41 return account.purple_accounts_find(self.username, \
44 def __is_connected(self):
46 return account.purple_account_is_connected(self._get_structure())
49 is_connected = property(__is_connected)
51 def __is_connecting(self):
53 return account.purple_account_is_connecting(self._get_structure())
56 is_connecting = property(__is_connecting)
58 def __is_disconnected(self):
60 return account.purple_account_is_disconnected( \
61 self._get_structure())
64 is_disconnected = property(__is_disconnected)
68 core = property(__get_core)
70 def __get_exists(self):
72 exists = property(__get_exists)
74 def __get_username(self):
75 cdef char *username = NULL
77 username = <char *> account.purple_account_get_username( \
78 self._get_structure())
84 return self.__username
85 username = property(__get_username)
87 def __get_protocol_id(self):
88 cdef char *protocol_id = NULL
90 protocol_id = <char *> account.purple_account_get_protocol_id( \
91 self._get_structure())
97 return self.protocol_id
98 protocol_id = property(__get_protocol_id)
100 def __get_password(self):
101 cdef char *password = NULL
103 password = <char *> account.purple_account_get_password( \
104 self._get_structure())
111 password = property(__get_password)
113 def __get_alias(self):
114 cdef char *alias = NULL
116 alias = <char *> account.purple_account_get_alias(self._get_structure())
123 alias = property(__get_alias)
125 def __get_user_info(self):
126 cdef char *user_info = NULL
128 user_info = <char *> account.purple_account_get_user_info(self._get_structure())
135 user_info = property(__get_user_info)
137 def __get_remember_password(self):
139 return account.purple_account_get_remember_password( \
140 self._get_structure())
143 remember_password = property(__get_remember_password)
145 def __get_enabled(self):
147 return account.purple_account_get_enabled(self._get_structure(), \
151 enabled = property(__get_enabled)
153 def set_username(self, username):
155 Sets the account's username.
157 @param username The username
158 @return True if successful, False if account doesn't exists
161 account.purple_account_set_username(self._get_structure(), \
167 def set_protocol_id(self, protocol_id):
169 Sets the account's protocol ID.
171 @param protocol_id The protocol ID
172 @return True if successful, False if account doesn't exists
175 self.__protocol._set_protocol_id(protocol_id)
180 def set_password(self, password):
182 Sets the account's password.
184 @param password The password
185 @return True if successful, False if account doesn't exists
188 account.purple_account_set_password(self._get_structure(), \
194 def set_alias(self, alias):
196 Sets the account's alias
198 @param alias The alias
199 @return True if successful, False if account doesn't exists
202 account.purple_account_set_alias(self._get_structure(), \
208 def set_user_info(self, user_info):
210 Sets the account's user information
212 @param user_info The user information
213 @return True if successful, False if account doesn't exists
216 account.purple_account_set_user_info(self._get_structure(), \
222 def set_remember_password(self, remember_password):
224 Sets whether or not this account should save its password.
226 @param remember_password True if should remember the password,
228 @return True if successful, False if account doesn't exists
231 account.purple_account_set_remember_password( \
232 self._get_structure(), remember_password)
237 def set_enabled(self, value):
239 Sets wheter or not this account is enabled.
241 @param value True if it is enabled, or False otherwise
242 @return True if successful, False if account doesn't exists
245 account.purple_account_set_enabled(self._get_structure(), \
246 self.core.ui_name, bool(value))
253 Creates a new account.
255 @return True if successful, False if account already exists
260 account.purple_account_new(self.username, self.protocol_id)
266 Connects to an account.
268 @return True if successful, False if account doesn't exists
271 account.purple_account_connect(self._get_structure())
276 def disconnect(self):
278 Disconnects from an account.
280 @return True if successful, False if account doesn't exists
283 account.purple_account_disconnect(self._get_structure())