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/>.
28 ctypedef char const_char "const char"
38 def __init__(self, id):
41 if self._get_structure() != NULL:
46 cdef plugin.PurplePlugin *_get_structure(self):
47 return plugin.purple_plugins_find_with_id(self.__id)
49 def __get_exists(self):
51 exists = property(__get_exists)
55 id = property(__get_id)
58 cdef char *name = NULL
60 name = <char *> plugin.purple_plugin_get_name(self._get_structure())
66 name = property(__get_name)
68 def __get_options_labels(self):
69 cdef prpl.PurplePluginProtocolInfo *prpl_info
71 cdef accountopt.PurpleAccountOption *option
72 cdef prefs.PurplePrefType type
73 cdef const_char *label_name
74 cdef const_char *setting
79 prpl_info = plugin.PURPLE_PLUGIN_PROTOCOL_INFO(self._get_structure())
83 iter = prpl_info.protocol_options
87 option = <accountopt.PurpleAccountOption *> iter.data
88 type = accountopt.purple_account_option_get_type(option)
89 label_name = accountopt.purple_account_option_get_text(option)
90 setting = accountopt.purple_account_option_get_setting(option)
92 sett = str(<char *> setting)
93 label = str(<char *> label_name)
100 options_labels = property(__get_options_labels)
102 def __get_options_values(self):
103 cdef prpl.PurplePluginProtocolInfo *prpl_info
104 cdef glib.GList *iter
105 cdef accountopt.PurpleAccountOption *option
106 cdef prefs.PurplePrefType type
107 cdef const_char *str_value
108 cdef const_char *setting
110 cdef glib.gboolean bool_value
112 if not self.__exists:
115 prpl_info = plugin.PURPLE_PLUGIN_PROTOCOL_INFO(self._get_structure())
119 iter = prpl_info.protocol_options
123 option = <accountopt.PurpleAccountOption *> iter.data
124 type = accountopt.purple_account_option_get_type(option)
125 setting = accountopt.purple_account_option_get_setting(option)
127 sett = str(<char *> setting)
129 if type == prefs.PURPLE_PREF_STRING:
130 str_value = accountopt.purple_account_option_get_default_string(option)
131 # Hack to set string "" as default value when the
132 # protocol's option is NULL
133 if str_value == NULL:
135 val = str(<char *> str_value)
137 elif type == prefs.PURPLE_PREF_INT:
138 int_value = accountopt.purple_account_option_get_default_int(option)
141 elif type == prefs.PURPLE_PREF_BOOLEAN:
142 bool_value = accountopt.purple_account_option_get_default_bool(option)
144 val = bool(bool_value)
146 elif type == prefs.PURPLE_PREF_STRING_LIST:
147 str_value = accountopt.purple_account_option_get_default_list_value(option)
149 val = str(<char *> str_value)
156 options_values = property(__get_options_values)