From 7b3a84e1d328964d372cd4d3f891ab0d4619adfd Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:53:15 +0000 Subject: [PATCH 1/1] Adding function __set_protocol_options Adding function __set_protocol_options to set the config's options to account's protocol Signed-off-by: Ragner Magalhaes git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1366 596f6dd7-e928-0410-a184-9e12fd12cf7e --- account.pyx | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/account.pyx b/account.pyx index 97374ea..4b3af4b 100644 --- a/account.pyx +++ b/account.pyx @@ -177,7 +177,53 @@ cdef class Account: return po - protocol_options = property(_get_protocol_options) + def _set_protocol_options(self, po): + cdef glib.GList *iter + cdef accountopt.PurpleAccountOption *option + cdef prefs.PurplePrefType type + cdef const_char *str_value + cdef const_char *setting + cdef int int_value + cdef glib.gboolean bool_value + + if self.c_account == NULL: + return + + po = {} + + iter = self.c_prpl_info.protocol_options + + while iter: + + option = iter.data + type = accountopt.c_purple_account_option_get_type(option) + setting = accountopt.c_purple_account_option_get_setting(option) + + sett = str( setting) + + if type == prefs.PURPLE_PREF_STRING: + + str_value = po[sett] + account.c_purple_account_set_string(self.c_account, setting, str_value) + + elif type == prefs.PURPLE_PREF_INT: + + int_value = int(po[sett]) + account.c_purple_account_set_int(self.c_account, setting, int_value) + + elif type == prefs.PURPLE_PREF_BOOLEAN: + + bool_value = bool(po[sett]) + account.c_purple_account_set_bool(self.c_account, setting, bool_value) + + elif type == prefs.PURPLE_PREF_STRING_LIST: + + str_value = po[sett] + account.c_purple_account_set_string(self.c_account, setting, str_value) + + iter = iter.next + + protocol_options = property(_get_protocol_options, _set_protocol_options) def _get_protocol_labels(self): cdef glib.GList *iter -- 1.7.9.5