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/>.
30 def __init__(self, id):
33 if self._get_structure() != NULL:
38 cdef plugin.PurplePlugin *_get_structure(self):
39 return plugin.purple_plugins_find_with_id(self.__id)
41 def __get_exists(self):
43 exists = property(__get_exists)
47 id = property(__get_id)
50 cdef char *name = NULL
52 name = <char *> plugin.purple_plugin_get_name(self._get_structure())
58 name = property(__get_name)
60 def __get_options_labels(self):
61 cdef prpl.PurplePluginProtocolInfo *prpl_info
63 cdef accountopt.PurpleAccountOption *option
64 cdef prefs.PurplePrefType type
65 cdef const_char *label_name
66 cdef const_char *setting
71 prpl_info = plugin.PURPLE_PLUGIN_PROTOCOL_INFO(self._get_structure())
75 iter = prpl_info.protocol_options
79 option = <accountopt.PurpleAccountOption *> iter.data
80 type = accountopt.purple_account_option_get_type(option)
81 label_name = accountopt.purple_account_option_get_text(option)
82 setting = accountopt.purple_account_option_get_setting(option)
84 sett = str(<char *> setting)
85 label = str(<char *> label_name)
92 options_labels = property(__get_options_labels)
94 def __get_options_values(self):
95 cdef prpl.PurplePluginProtocolInfo *prpl_info
97 cdef accountopt.PurpleAccountOption *option
98 cdef prefs.PurplePrefType type
99 cdef const_char *str_value
100 cdef const_char *setting
102 cdef glib.gboolean bool_value
104 if not self.__exists:
107 prpl_info = plugin.PURPLE_PLUGIN_PROTOCOL_INFO(self._get_structure())
111 iter = prpl_info.protocol_options
115 option = <accountopt.PurpleAccountOption *> iter.data
116 type = accountopt.purple_account_option_get_type(option)
117 setting = accountopt.purple_account_option_get_setting(option)
119 sett = str(<char *> setting)
121 if type == prefs.PURPLE_PREF_STRING:
122 str_value = accountopt.purple_account_option_get_default_string(option)
123 # Hack to set string "" as default value when the
124 # protocol's option is NULL
125 if str_value == NULL:
127 val = str(<char *> str_value)
129 elif type == prefs.PURPLE_PREF_INT:
130 int_value = accountopt.purple_account_option_get_default_int(option)
133 elif type == prefs.PURPLE_PREF_BOOLEAN:
134 bool_value = accountopt.purple_account_option_get_default_bool(option)
136 val = bool(bool_value)
138 elif type == prefs.PURPLE_PREF_STRING_LIST:
139 str_value = accountopt.purple_account_option_get_default_list_value(option)
141 val = str(<char *> str_value)
148 options_values = property(__get_options_values)