# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-cimport purple
+cimport account
+cimport accountopt
+cimport blist
+cimport plugin
+cimport prefs
+cimport prpl
+cimport savedstatuses
+cimport server
+cimport status
cdef class Account:
"""
cdef char *id = NULL
cdef char *name = NULL
+ status_types = []
if self.__exists:
- status_types = []
iter = account.purple_account_get_status_types(self._get_structure())
while iter:
c_statustype = <status.PurpleStatusType *> iter.data
name = <char *> status.purple_status_type_get_name(c_statustype)
status_types.append((id, name))
iter = iter.next
- return status_types
- else:
- return None
+
+ return status_types
status_types = property(__get_status_types)
sett = str(<char *> setting)
- if not po.has_key(sett):
+ if sett not in po:
iter = iter.next
continue
cdef blist.PurpleBuddy *c_buddy = NULL
cdef char *c_alias = NULL
+ buddies_list = []
if self.__exists and \
account.purple_account_is_connected(self._get_structure()):
iter = blist.purple_find_buddies(self._get_structure(), NULL)
- buddies_list = []
while iter:
c_alias = NULL
c_buddy = <blist.PurpleBuddy *> iter.data
buddies_list.append(new_buddy)
iter = iter.next
- return buddies_list
- else:
- return None
+
+ return buddies_list
+
+ def get_buddies(self):
+ """
+ @return Account's buddies list
+ """
+ cdef glib.GSList *iter = NULL
+ cdef blist.PurpleBuddy *c_buddy = NULL
+ cdef char *c_alias = NULL
+
+ buddies_list = []
+ if self.__exists:
+ iter = blist.purple_find_buddies(self._get_structure(), NULL)
+
+ while iter:
+ c_alias = NULL
+ c_buddy = <blist.PurpleBuddy *> iter.data
+
+ name = <char *> blist.purple_buddy_get_name(c_buddy)
+ new_buddy = Buddy(name, self)
+
+ c_alias = <char *> blist.purple_buddy_get_alias_only(c_buddy)
+ if c_alias:
+ new_buddy.set_alias(c_alias)
+
+ buddies_list.append(new_buddy)
+ iter = iter.next
+
+ return buddies_list
def request_add_buddy(self, buddy_username, buddy_alias):
if buddy_alias:
def set_active_status(self, type, msg=None):
cdef status.PurpleStatusType *c_statustype = NULL
cdef savedstatuses.PurpleSavedStatus *c_savedstatus = NULL
+ cdef char* msg_literal = "message"
if self.__exists:
if msg:
account.purple_account_set_status(self._get_structure(),
- <char *> type, True, "message", <char *> msg, NULL)
+ <char *> type, True, msg_literal, <char *> msg, NULL)
else:
account.purple_account_set_status(self._get_structure(),
<char *> type, True, NULL)
return True
else:
return False
+
+include "buddy.pyx"