X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=blobdiff_plain;f=purple.pyx;h=26a972fa49733504e05b58b51381b2bb158ca9ef;hp=9601af7ee8d3d2a951c713bd8b0bea7919e9e1e3;hb=d5b85c24f1ac2d3fb582e79c995396c4043e7763;hpb=5d7c705f607003997a097b353d02483b57cb61b9 diff --git a/purple.pyx b/purple.pyx index 9601af7..26a972f 100644 --- a/purple.pyx +++ b/purple.pyx @@ -65,10 +65,7 @@ cdef class Purple: @parm default_path: Full path for libpurple user files. """ - cdef object __accounts - def __init__(self, debug_enabled=True, app_name=__APP_NAME__, default_path=__DEFAULT_PATH__): - self.__accounts = {} if app_name is not __APP_NAME__: __APP_NAME__ = app_name @@ -244,15 +241,15 @@ cdef class Purple: # load pounces pounce.c_purple_pounces_load() - # initialize accounts - self.load_accounts() - return ret def add_callback(self, type, name, callback): """ Adds a callback with given name inside callback's type. - Example: add_callback("account", "notify-added", notify_added_cb) + + @param type Callback type (e.g. "account") + @param name Callback name (e.g. "notify-added") + @param callback Callback to be called """ global account_cbs global blist_cbs @@ -317,45 +314,6 @@ cdef class Purple: jabber, "jabber-receiving-xmlnode", &handle, jabber_receiving_xmlnode_cb, NULL) - def __get_accounts(self): - return self.__accounts - accounts = property(__get_accounts) - - def new_account(self, username, protocol_id): - acc = Account(username, protocol_id) - return acc - - def load_accounts(self): - cdef glib.GList *iter - cdef account.PurpleAccount *acc - iter = account.purple_accounts_get_all() - while iter: - acc = iter.data - if acc: - username = account.purple_account_get_username(acc) - protocol_id = account.purple_account_get_protocol_id(acc) - self.account_add(username.split("/")[0], protocol_id, \ - "172.18.216.211", 8080) - iter = iter.next - - 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.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 - def accounts_get_all(self): cdef glib.GList *iter cdef account.PurpleAccount *acc @@ -378,11 +336,24 @@ cdef class Purple: return account_list -include "plugin.pyx" + def protocols_get_all(self): + cdef glib.GList *iter + cdef plugin.PurplePlugin *pp + + iter = plugin.c_purple_plugins_get_protocols() + protocol_list = [] + while iter: + pp = iter.data + if pp.info and pp.info.name: + protocol_list.append[Protocol(pp.info.id)] + iter = iter.next + return protocol_list + +include "protocol.pyx" +#include "plugin.pyx" include "proxy.pyx" #include "protocol.pyx" include "account.pyx" include "buddy.pyx" #include "connection.pyx" include "conversation.pyx" -