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 from protocol import Protocol
32 def __init__(self, core, username, protocol_id):
34 self.__username = username
35 self.__protocol = Protocol(self, protocol_id)
37 if self._get_structure() == NULL:
42 cdef account.PurpleAccount *_get_structure(self):
43 return account.purple_accounts_find(self.username, \
46 def __is_connected(self):
48 return account.purple_account_is_connected(self._get_structure())
51 is_connected = property(__is_connected)
53 def __is_connecting(self):
55 return account.purple_account_is_connecting(self._get_structure())
58 is_connecting = property(__is_connecting)
60 def __is_disconnected(self):
62 return account.purple_account_is_disconnected( \
63 self._get_structure())
66 is_disconnected = property(__is_disconnected)
70 core = property(__get_core)
72 def __get_exists(self):
74 exists = property(__get_exists)
76 def __get_username(self):
77 cdef char *username = NULL
79 username = <char *> account.purple_account_get_username( \
80 self._get_structure())
86 return self.__username
87 username = property(__get_username)
89 def __get_protocol_id(self):
90 cdef char *protocol_id = NULL
92 protocol_id = <char *> account.purple_account_get_protocol_id( \
93 self._get_structure())
99 return self.protocol_id
100 protocol_id = property(__get_protocol_id)
102 def __get_password(self):
103 cdef char *password = NULL
105 password = <char *> account.purple_account_get_password( \
106 self._get_structure())
113 password = property(__get_password)
115 def __get_alias(self):
116 cdef char *alias = NULL
118 alias = <char *> account.purple_account_get_alias(self._get_structure())
125 alias = property(__get_alias)
127 def __get_user_info(self):
128 cdef char *user_info = NULL
130 user_info = <char *> account.purple_account_get_user_info(self._get_structure())
137 user_info = property(__get_user_info)
139 def __get_remember_password(self):
141 return account.purple_account_get_remember_password( \
142 self._get_structure())
145 remember_password = property(__get_remember_password)
147 def __get_enabled(self):
149 return account.purple_account_get_enabled(self._get_structure(), \
153 enabled = property(__get_enabled)
155 def set_username(self, username):
157 Sets the account's username.
159 @param username The username
160 @return True if successful, False if account doesn't exists
163 account.purple_account_set_username(self._get_structure(), \
169 def set_protocol_id(self, protocol_id):
171 Sets the account's protocol ID.
173 @param protocol_id The protocol ID
174 @return True if successful, False if account doesn't exists
177 self.__protocol._set_protocol_id(protocol_id)
182 def set_password(self, password):
184 Sets the account's password.
186 @param password The password
187 @return True if successful, False if account doesn't exists
190 account.purple_account_set_password(self._get_structure(), \
196 def set_alias(self, alias):
198 Sets the account's alias
200 @param alias The alias
201 @return True if successful, False if account doesn't exists
204 account.purple_account_set_alias(self._get_structure(), \
210 def set_user_info(self, user_info):
212 Sets the account's user information
214 @param user_info The user information
215 @return True if successful, False if account doesn't exists
218 account.purple_account_set_user_info(self._get_structure(), \
224 def set_remember_password(self, remember_password):
226 Sets whether or not this account should save its password.
228 @param remember_password True if should remember the password,
230 @return True if successful, False if account doesn't exists
233 account.purple_account_set_remember_password( \
234 self._get_structure(), remember_password)
239 def set_enabled(self, value):
241 Sets wheter or not this account is enabled.
243 @param value True if it is enabled, or False otherwise
244 @return True if successful, False if account doesn't exists
247 account.purple_account_set_enabled(self._get_structure(), \
248 self.core.ui_name, bool(value))
255 Creates a new account.
257 @return True if successful, False if account already exists
262 account.purple_account_new(self.username, self.protocol_id)
268 Connects to an account.
270 @return True if successful, False if account doesn't exists
273 account.purple_account_connect(self._get_structure())
278 def disconnect(self):
280 Disconnects from an account.
282 @return True if successful, False if account doesn't exists
285 account.purple_account_disconnect(self._get_structure())