- def account_add(self, username, protocol_id, host, port):
- if not self.account_verify(username):
- acc = purple.Account(username, protocol_id)
- self.__accounts[username] = acc
- if not account.c_purple_accounts_find(username, protocol_id):
- acc.proxy.set_type(purple.ProxyInfoType().HTTP)
- acc.proxy.set_host(host)
- acc.proxy.set_port(port)
- acc.save_into_xml()
-
- def account_verify(self, acc_username):
- if self.__accounts:
- for username in self.__accounts.keys():
- if acc_username == username:
- return self.__accounts[username]
- else:
- return None
-
-include "plugin.pyx"
+ return account_list
+
+ def accounts_get_all_active(self):
+ '''Returns a list of all enabled accounts.
+
+ @return A list of all enabled accounts.
+ '''
+
+ cdef glib.GList *iter
+ cdef account.PurpleAccount *acc
+ cdef char *username
+ cdef char *protocol_id
+
+ #FIXME: The list is owned by the caller, and must be g_list_free()d
+ # to avoid leaking the nodes.
+
+ iter = account.purple_accounts_get_all_active()
+ account_list = []
+
+ while iter:
+ acc = <account.PurpleAccount *> iter.data
+
+ if <account.PurpleAccount *>acc:
+ username = <char *> account.purple_account_get_username(acc)
+ protocol_id = <char *> account.purple_account_get_protocol_id(acc)
+
+ if username != NULL and protocol_id != NULL:
+ account_list.append(Account(username, \
+ Protocol(protocol_id), self))
+ iter = iter.next
+
+ return account_list
+
+ def protocols_get_all(self):
+ '''Returns a list of all protocols.
+
+ @return A list of all protocols.
+ '''
+
+ cdef glib.GList *iter
+ cdef plugin.PurplePlugin *pp
+
+ iter = plugin.purple_plugins_get_protocols()
+ protocol_list = []
+ while iter:
+ pp = <plugin.PurplePlugin*> iter.data
+ if pp.info and pp.info.name:
+ protocol_list.append(Protocol(pp.info.id))
+ iter = iter.next
+ return protocol_list
+
+ def call_action(self, i):
+ __call_action(i)
+
+include "protocol.pyx"
+#include "plugin.pyx"