root/branches/gajim_0.9.1/src/common/config.py

Revision 4854, 20.6 kB (checked in by nk, 3 years ago)

[greblus] preferences window now can control the color of URLs

  • Property svn:eol-style set to LF
Line 
1##      common/config.py
2##
3## Contributors for this file:
4##      - Yann Le Boulanger <asterix@lagaule.org>
5##      - Nikos Kouremenos <nkour@jabber.org>
6##      - Dimitur Kirov <dkirov@gmail.com>
7##      - Travis Shirk <travis@pobox.com>
8##
9## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
10##                         Vincent Hanquez <tab@snarc.org>
11## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
12##                    Vincent Hanquez <tab@snarc.org>
13##                    Nikos Kouremenos <nkour@jabber.org>
14##                    Dimitur Kirov <dkirov@gmail.com>
15##                    Travis Shirk <travis@pobox.com>
16##                    Norman Rasmussen <norman@rasmussen.co.za>
17##
18## This program is free software; you can redistribute it and/or modify
19## it under the terms of the GNU General Public License as published
20## by the Free Software Foundation; version 2 only.
21##
22## This program is distributed in the hope that it will be useful,
23## but WITHOUT ANY WARRANTY; without even the implied warranty of
24## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25## GNU General Public License for more details.
26##
27
28
29import sre
30import copy
31import i18n
32_ = i18n._
33
34OPT_TYPE = 0
35OPT_VAL = 1
36OPT_DESC = 2
37
38opt_int = [ 'integer', 0 ]
39opt_str = [ 'string', 0 ]
40opt_bool = [ 'boolean', 0 ]
41opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ]
42
43class Config:
44
45        __options = {
46                # name: [ type, value ]
47                'verbose': [ opt_bool, False ],
48                'alwaysauth': [ opt_bool, False ],
49                'autopopup': [ opt_bool, False ],
50                'notify_on_signin': [ opt_bool, True ],
51                'notify_on_signout': [ opt_bool, False ],
52                'notify_on_new_message': [ opt_bool, True ],
53                'autopopupaway': [ opt_bool, False ],
54                'use_notif_daemon': [ opt_bool, True , _('Use DBus and Notification-Daemon to show notifications') ],
55                'ignore_unknown_contacts': [ opt_bool, False ],
56                'showoffline': [ opt_bool, False ],
57                'autoaway': [ opt_bool, True ],
58                'autoawaytime': [ opt_int, 5, _('Time in minutes, after which your status changes to away.') ],
59                'autoaway_message': [ opt_str, _('Away as a result of being idle') ],
60                'autoxa': [ opt_bool, True ],
61                'autoxatime': [ opt_int, 15, _('Time in minutes, after which your status changes to not available.') ],
62                'autoxa_message': [ opt_str, _('Not available as a result of being idle') ],
63                'ask_online_status': [ opt_bool, False ],
64                'ask_offline_status': [ opt_bool, False ],
65                'last_status_msg_online': [ opt_str, '' ],
66                'last_status_msg_chat': [ opt_str, '' ],
67                'last_status_msg_away': [ opt_str, '' ],
68                'last_status_msg_xa': [ opt_str, '' ],
69                'last_status_msg_dnd': [ opt_str, '' ],
70                'last_status_msg_invisible': [ opt_str, '' ],
71                'last_status_msg_offline': [ opt_str, '' ],
72                'trayicon': [ opt_bool, True ],
73                'iconset': [ opt_str, 'dcraven' ],
74                'use_transports_iconsets': [ opt_bool, True ],
75                'inmsgcolor': [ opt_color, '#a34526' ],
76                'outmsgcolor': [ opt_color, '#164e6f' ],
77                'statusmsgcolor': [ opt_color, '#1eaa1e' ],
78                'markedmsgcolor': [ opt_color, '#ff8080' ],
79                'urlmsgcolor': [ opt_color, '#0000ff' ],
80                'collapsed_rows': [ opt_str, '' ],
81                'roster_theme': [ opt_str, 'green' ],
82                'saveposition': [ opt_bool, True ],
83                'mergeaccounts': [ opt_bool, False ],
84                'sort_by_show': [ opt_bool, True ],
85                'usetabbedchat': [ opt_bool, True ],
86                'use_speller': [ opt_bool, False ],
87                'print_time': [ opt_str, 'always' ],
88                'useemoticons': [ opt_bool, True ],
89                'show_ascii_formatting_chars': [ opt_bool, False , _('If True, do not remove */_ . So *abc* will be bold but with * * not removed.')],
90                'sounds_on': [ opt_bool, True ],
91                # 'aplay', 'play', 'esdplay', 'artsplay' detected first time only
92                'soundplayer': [ opt_str, '' ],
93                'openwith': [ opt_str, 'gnome-open' ],
94                'custombrowser': [ opt_str, 'firefox' ],
95                'custommailapp': [ opt_str, 'mozilla-thunderbird -compose' ],
96                'custom_file_manager': [ opt_str, 'xffm' ],
97                'gc-x-position': [opt_int, 0],
98                'gc-y-position': [opt_int, 0],
99                'gc-width': [opt_int, 675],
100                'gc-height': [opt_int, 400],
101                'gc-hpaned-position': [opt_int, 540],
102                'gc_refer_to_nick_char': [opt_str, ','],
103                'gc_proposed_nick_char': [opt_str, '_'],
104                'chat-x-position': [opt_int, 0],
105                'chat-y-position': [opt_int, 0],
106                'chat-width': [opt_int, 480],
107                'chat-height': [opt_int, 440],
108                'single_msg-x-position': [opt_int, 0],
109                'single_msg-y-position': [opt_int, 0],
110                'single_msg-width': [opt_int, 400],
111                'single_msg-height': [opt_int, 280],
112                'roster_x-position': [ opt_int, 0 ],
113                'roster_y-position': [ opt_int, 0 ],
114                'roster_width': [ opt_int, 150 ],
115                'roster_height': [ opt_int, 400 ],
116                'latest_disco_addresses': [ opt_str, '' ],
117                'recently_groupchat': [ opt_str, '' ],
118                'before_time': [ opt_str, '[' ],
119                'after_time': [ opt_str, ']' ],
120                'before_nickname': [ opt_str, '' ],
121                'after_nickname': [ opt_str, ':' ],
122                'send_os_info': [ opt_bool, True ],
123                'usegpg': [ opt_bool, False ],
124                'use_gpg_agent': [ opt_bool, False ],
125                'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')],
126                'restore_lines': [opt_int, 4, _('How many lines to remember from previous conversation when a chat tab/window is reopened.')],
127                'restore_timeout': [opt_int, 60, _('How many minutes should last lines from previous conversation last.')],
128                'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')],
129                'show_roster_on_startup': [opt_bool, True],
130                'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')],
131                'version': [ opt_str, '0.9' ], # which version created the config
132                'always_compact_view_chat': [opt_bool, False, _('Use compact view when you open a chat window')],
133                'always_compact_view_gc': [opt_bool, False, _('Use compact view when you open a group chat window')],
134                'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'],
135                'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")],
136                'always_english_wikipedia': [opt_bool, False],
137                'always_english_wiktionary': [opt_bool, True],
138                'remote_control': [opt_bool, True, _('If checked, Gajim can be controlled remotely using gajim-remote.')],
139                'chat_state_notifications': [opt_str, 'all'], # 'all', 'composing_only', 'disabled'
140                'autodetect_browser_mailer': [opt_bool, True],
141                'print_ichat_every_foo_minutes': [opt_int, 5],
142                'confirm_close_muc': [opt_bool, True, _('Ask before closing a group chat tab/window.')],
143                'notify_on_file_complete': [opt_bool, True], # notif. on file complete
144                'file_transfers_port': [opt_int, 28011],  # port, used for file transfers
145                'ft_override_host_to_send': [opt_str, '', _('Overrides the host we send for File Transfer in case of address translation/port forwarding.')], 
146                'conversation_font': [opt_str, ''],
147                'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')],
148                'notify_on_all_muc_messages': [opt_bool, False],
149                'trayicon_notification_on_new_messages': [opt_bool, True],
150                'last_save_dir': [opt_str, ''],
151                'last_send_dir': [opt_str, ''],
152                'last_emoticons_dir': [opt_str, ''],
153                'last_sounds_dir': [opt_str, ''],
154                'tabs_position': [opt_str, 'top'],
155                'tabs_always_visible': [opt_bool, False, _('Show tab when only one conversation?')],
156                'tabs_border': [opt_bool, False, _('Show tab border if one conversation?')],
157                'tabs_close_button': [opt_bool, True, _('Show close button in tab?')],
158                'chat_avatar_width': [opt_int, 52],
159                'chat_avatar_height': [opt_int, 52],
160                'roster_avatar_width': [opt_int, 32],
161                'roster_avatar_height': [opt_int, 32],
162                'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in multi-user chat.')],
163                'quit_on_roster_x_button': [opt_bool, False, _('If True, quits Gajim when X button of Window Manager is clicked. This setting is taken into account only if trayicon is used.')],
164                'set_xmpp://_handler_everytime': [opt_bool, False, _('If True, Gajim registers for xmpp:// on each startup.')],
165                'show_unread_tab_icon': [opt_bool, False, _('If True, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')],
166                'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window')],
167                'show_avatars_in_roster': [opt_bool, True],
168                'ask_avatars_on_startup': [opt_bool, True, _('If True, Gajim will ask for avatar each contact that did not have an avatar last time or has one cached that is too old.')],
169                #FIXME: remvoe you and make it Gajim will not; and/or his or *her* status messages
170                'print_status_in_chats': [opt_bool, True, _('If False, you will no longer see status line in chats when a contact changes his or her status and/or his status message.')],
171                'log_contact_status_changes': [opt_bool, False],
172                'restored_messages_color': [opt_str, 'grey'],
173                'hide_avatar_of_transport': [opt_bool, False],
174        }
175
176        __options_per_key = {
177                'accounts': ({
178                        'name': [ opt_str, '' ],
179                        'hostname': [ opt_str, '' ],
180                        'savepass': [ opt_bool, False ],
181                        'password': [ opt_str, '' ],
182                        'resource': [ opt_str, 'gajim' ],
183                        'priority': [ opt_int, 5 ],
184                        'autoconnect': [ opt_bool, False ],
185                        'autoreconnect': [ opt_bool, True ],
186                        'active': [ opt_bool, True],
187                        'proxy': [ opt_str, '' ],
188                        'keyid': [ opt_str, '' ],
189                        'keyname': [ opt_str, '' ],
190                        'usessl': [ opt_bool, False ],
191                        'use_srv': [ opt_bool, True ],
192                        'use_custom_host': [ opt_bool, False ],
193                        'custom_port': [ opt_int, 5222 ],
194                        'custom_host': [ opt_str, '' ],
195                        'savegpgpass': [ opt_bool, False ],
196                        'gpgpassword': [ opt_str, '' ],
197                        'sync_with_global_status': [ opt_bool, False ],
198                        'no_log_for': [ opt_str, '' ],
199                        'attached_gpg_keys': [ opt_str, '' ],
200                        'keep_alives_enabled': [ opt_bool, True],
201                        # send keepalive every N seconds of inactivity
202                        'keep_alive_every_foo_secs': [ opt_int, 55 ],
203                        # try for 2 minutes before giving up (aka. timeout after those seconds)
204                        'try_connecting_for_foo_secs': [ opt_int, 60 ],
205                        'max_stanza_per_sec': [ opt_int, 5],
206                        'http_auth': [opt_str, 'ask'], # yes, no, ask
207                        # proxy65 for FT
208                        'file_transfer_proxies': [opt_str, 
209                        'proxy.jabber.org, proxy65.jabber.autocom.pl, proxy.jabber.cd.chalmers.se, proxy.netlab.cz, proxy65.jabber.ccc.de, proxy65.unstable.nl'] 
210                }, {}),
211                'statusmsg': ({
212                        'message': [ opt_str, '' ],
213                }, {}),
214                'emoticons': ({
215                        'path': [ opt_str, '' ],
216                }, {}),
217                'soundevents': ({
218                        'enabled': [ opt_bool, True ],
219                        'path': [ opt_str, '' ],
220                }, {}),
221                'proxies': ({
222                        'type': [ opt_str, 'http' ],
223                        'host': [ opt_str, '' ],
224                        'port': [ opt_int, 3128 ],
225                        'user': [ opt_str, '' ],
226                        'pass': [ opt_str, '' ],
227                }, {}),
228                'ft_proxies65_cache': ({
229                        'host': [ opt_str, ''],
230                        'port': [ opt_str, '7777'],
231                        'jid': [ opt_str, ''],
232                }, {}),
233                'themes': ({
234                        'accounttextcolor': [ opt_color, 'black' ],
235                        'accountbgcolor': [ opt_color, 'white' ],
236                        'accountfont': [ opt_str, '' ],
237                        'accountfontattrs': [ opt_str, 'B' ],
238                        'grouptextcolor': [ opt_color, 'black' ],
239                        'groupbgcolor': [ opt_color, 'white' ],
240                        'groupfont': [ opt_str, '' ],
241                        'groupfontattrs': [ opt_str, 'I' ],
242                        'contacttextcolor': [ opt_color, 'black' ],
243                        'contactbgcolor': [ opt_color, 'white' ],
244                        'contactfont': [ opt_str, '' ],
245                        'contactfontattrs': [ opt_str, '' ],
246                        'bannertextcolor': [ opt_color, 'black' ],
247                        'bannerbgcolor': [ opt_color, '' ],
248
249                        # http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html
250                        # FIXME: not black but the default color from gtk+ theme
251                        'state_active_color': [ opt_color, 'black' ],
252                        'state_inactive_color': [ opt_color, 'grey62' ],
253                        'state_composing_color': [ opt_color, 'green4' ],
254                        'state_paused_color': [ opt_color, 'mediumblue' ],
255                        'state_gone_color': [ opt_color, 'grey' ],
256
257                        # MUC chat states
258                        'state_muc_msg': [ opt_color, 'mediumblue' ],
259                        'state_muc_directed_msg': [ opt_color, 'red2' ],
260                }, {}),
261        }
262
263        emoticons_default = {
264                ':-)': '../data/emoticons/smile.png',
265                '(@)': '../data/emoticons/pussy.png',
266                '8)': '../data/emoticons/coolglasses.png',
267                ':(': '../data/emoticons/unhappy.png',
268                ':)': '../data/emoticons/smile.png',
269                ':/': '../data/emoticons/frowning.png',
270                '(})': '../data/emoticons/hugleft.png',
271                ':$': '../data/emoticons/blush.png',
272                '(Y)': '../data/emoticons/yes.png',
273                ':-@': '../data/emoticons/angry.png',
274                ':-D': '../data/emoticons/biggrin.png',
275                '(U)': '../data/emoticons/brheart.png',
276                '(F)': '../data/emoticons/flower.png',
277                ':-[': '../data/emoticons/bat.png',
278                ':>': '../data/emoticons/biggrin.png',
279                '(T)': '../data/emoticons/phone.png',
280                ':-S': '../data/emoticons/frowning.png',
281                ':-P': '../data/emoticons/tongue.png',
282                '(H)': '../data/emoticons/coolglasses.png',
283                '(D)': '../data/emoticons/drink.png',
284                ':-O': '../data/emoticons/oh.png',
285                '(C)': '../data/emoticons/coffee.png',
286                '({)': '../data/emoticons/hugright.png',
287                '(*)': '../data/emoticons/star.png',
288                'B-)': '../data/emoticons/coolglasses.png',
289                '(Z)': '../data/emoticons/boy.png',
290                '(E)': '../data/emoticons/mail.png',
291                '(N)': '../data/emoticons/no.png',
292                '(P)': '../data/emoticons/photo.png',
293                '(K)': '../data/emoticons/kiss.png',
294                ':-*': '../data/emoticons/kiss.png',
295                ':*': '../data/emoticons/kiss.png',
296                '(R)': '../data/emoticons/rainbow.png',
297                ':-|': '../data/emoticons/stare.png',
298                ';-)': '../data/emoticons/wink.png',
299                ';-(': '../data/emoticons/cry.png',
300                '(6)': '../data/emoticons/devil.png',
301                '>:)': '../data/emoticons/devil.png',
302                '>:-)': '../data/emoticons/devil.png',
303                '(L)': '../data/emoticons/heart.png',
304                '<3': '../data/emoticons/heart.png',
305                '(W)': '../data/emoticons/brflower.png',
306                ':|': '../data/emoticons/stare.png',
307                ':O': '../data/emoticons/oh.png',
308                ';)': '../data/emoticons/wink.png',
309                ';(': '../data/emoticons/cry.png',
310                ':S': '../data/emoticons/frowning.png',
311                ';\'-(': '../data/emoticons/cry.png',
312                ':-(': '../data/emoticons/unhappy.png',
313                '8-)': '../data/emoticons/coolglasses.png',
314                '(B)': '../data/emoticons/beer.png',
315                ':D': '../data/emoticons/biggrin.png',
316                '(8)': '../data/emoticons/music.png',
317                ':@': '../data/emoticons/angry.png',
318                'B)': '../data/emoticons/coolglasses.png',
319                ':-$': '../data/emoticons/blush.png',
320                ':\'(': '../data/emoticons/cry.png',
321                ':->': '../data/emoticons/biggrin.png',
322                ':[': '../data/emoticons/bat.png',
323                '(I)': '../data/emoticons/lamp.png',
324                ':P': '../data/emoticons/tongue.png',
325                '(%)': '../data/emoticons/cuffs.png',
326                '(S)': '../data/emoticons/moon.png',
327        }
328
329        statusmsg_default = {
330                _('Sleeping'): 'ZZZZzzzzzZZZZZ',
331                _('Back soon'): _('Back in some minutes.'),
332                _('Eating'): _("I'm eating, so leave me a message."),
333                _('Movie'): _("I'm watching a movie."),
334                _('Working'): _("I'm working."),
335                _('Phone'): _("I'm on the phone."),
336                _('Out'): _("I'm out enjoying life"),
337        }
338
339        soundevents_default = {
340                'first_message_received': [ True, '../data/sounds/message1.wav' ],
341                'next_message_received': [ True, '../data/sounds/message2.wav' ],
342                'contact_connected': [ True, '../data/sounds/connected.wav' ],
343                'contact_disconnected': [ True, '../data/sounds/disconnected.wav' ],
344                'message_sent': [ True, '../data/sounds/sent.wav' ],
345                'muc_message_highlight': [ True, '../data/sounds/gc_message1.wav', _('Sound to play when a MUC message contains one of the words in muc_highlight_words, or when a MUC message contains your nickname.')],
346                'muc_message_received': [ True, '../data/sounds/gc_message2.wav', _('Sound to play when any MUC message arrives. (This setting is taken into account only if notify_on_all_muc_messages is True)') ],
347        }
348
349        themes_default = {
350                # sorted alphanum
351                _('green'): [ '#ffffff', '#94aa8c', '', 'B', '#0000ff', '#eff3e7',
352                                        '', 'I', '#000000', '#ffffff', '', '', '#ffffff',
353                                        '#94aa8c' ],
354               
355                _('grocery'): [ '#ffffff', '#6bbe18', '', 'B', '#12125a', '#ceefad',
356                                        '', 'I', '#000000', '#efb26b', '', '', '#ffffff',
357                                        '#108abd' ],
358               
359                _('human'): [ '#ffffff', '#996442', '', 'B', '#ab5920', '#e3ca94',
360                                        '', 'I', '#000000', '#ffffff', '', '', '#ffffff',
361                                        '#996442' ],
362                                       
363                _('marine'): [ '#ffffff', '#918caa', '', 'B', '#0000ff', '#e9e7f3',
364                                        '', 'I', '#000000', '#ffffff', '', '', '#ffffff',
365                                        '#918caa' ],
366               
367                _('plain'): [ '', '', '', 'B', '', '','', 'I', '', '', '', '', '','' ],
368               
369        }
370       
371        ft_proxies65_default = {
372                'proxy.jabber.org': [ '208.245.212.98', '7777', 'proxy.jabber.org' ],
373                'proxy65.jabber.autocom.pl': ['213.134.161.52', '7777', 'proxy65.jabber.autocom.pl'],
374                'proxy.jabber.cd.chalmers.se': ['129.16.79.37', '7777', 'proxy.jabber.cd.chalmers.se'],
375                'proxy.netlab.cz': ['82.119.241.3', '7777', 'proxy.netlab.cz'],
376                'proxy65.jabber.ccc.de': ['217.10.10.196', '7777', 'proxy65.jabber.ccc.de'],
377                'proxy65.unstable.nl': ['84.107.143.192', '7777', 'proxy65.unstable.nl'],
378        }
379
380        def foreach(self, cb, data = None):
381                for opt in self.__options:
382                        cb(data, opt, None, self.__options[opt])
383                for opt in self.__options_per_key:
384                        cb(data, opt, None, None)
385                        dict = self.__options_per_key[opt][1]
386                        for opt2 in dict.keys():
387                                cb(data, opt2, [opt], None)
388                                for opt3 in dict[opt2]:
389                                        cb(data, opt3, [opt, opt2], dict[opt2][opt3])
390
391        def is_valid_int(self, val):
392                try:
393                        ival = int(val)
394                except:
395                        return None
396                return ival
397
398        def is_valid_bool(self, val):
399                if val == 'True':
400                        return True
401                elif val == 'False':
402                        return False
403                else:
404                        ival = self.is_valid_int(val)
405                        if ival:
406                                return True
407                        elif ival is None:
408                                return None
409                        return False
410                return None
411
412        def is_valid_string(self, val):
413                return val
414
415        def is_valid(self, type, val):
416                if not type:
417                        return None
418                if type[0] == 'boolean':
419                        return self.is_valid_bool(val)
420                elif type[0] == 'integer':
421                        return self.is_valid_int(val)
422                elif type[0] == 'string':
423                        return self.is_valid_string(val)
424                else:
425                        if sre.match(type[1], val):
426                                return val
427                        else:
428                                return None
429
430        def set(self, optname, value):
431                if not self.__options.has_key(optname):
432#                       raise RuntimeError, 'option %s does not exist' % optname
433                        return
434                opt = self.__options[optname]
435                value = self.is_valid(opt[OPT_TYPE], value)
436                if value is None:
437#                       raise RuntimeError, 'value of %s cannot be None' % optname
438                        return
439
440                opt[OPT_VAL] = value
441
442        def get(self, optname = None):
443                if not optname:
444                        return self.__options.keys()
445                if not self.__options.has_key(optname):
446                        return None
447                return self.__options[optname][OPT_VAL]
448               
449        def get_desc(self, optname):
450                if not self.__options.has_key(optname):
451                        return None
452                if len(self.__options[optname]) > OPT_DESC:
453                        return self.__options[optname][OPT_DESC]
454
455        def add_per(self, typename, name): # per_group_of_option
456                if not self.__options_per_key.has_key(typename):
457#                       raise RuntimeError, 'option %s does not exist' % typename
458                        return
459               
460                opt = self.__options_per_key[typename]
461                if opt[1].has_key(name):
462                        # we already have added group name before
463                        return 'you already have added %s before' % name
464                opt[1][name] = copy.deepcopy(opt[0])
465
466        def del_per(self, typename, name, subname = None): # per_group_of_option
467                if not self.__options_per_key.has_key(typename):
468#                       raise RuntimeError, 'option %s does not exist' % typename
469                        return
470
471                opt = self.__options_per_key[typename]
472                if subname is None:
473                        del opt[1][name]
474                # if subname is specified, delete the item in the group.       
475                elif opt[1][name].has_key(subname):
476                        del opt[1][name][subname]
477
478        def set_per(self, optname, key, subname, value): # per_group_of_option
479                if not self.__options_per_key.has_key(optname):
480#                       raise RuntimeError, 'option %s does not exist' % optname
481                        return
482                dict = self.__options_per_key[optname][1]
483                if not dict.has_key(key):
484#                       raise RuntimeError, '%s is not a key of %s' % (key, dict)
485                        return
486                obj = dict[key]
487                if not obj.has_key(subname):
488#                       raise RuntimeError, '%s is not a key of %s' % (subname, obj)
489                        return
490                subobj = obj[subname]
491                value = self.is_valid(subobj[OPT_TYPE], value)
492                if value is None:
493#                       raise RuntimeError, '%s of %s cannot be None' % optname
494                        return
495                subobj[OPT_VAL] = value
496
497        def get_per(self, optname, key = None, subname = None): # per_group_of_option
498                if not self.__options_per_key.has_key(optname):
499                        return None
500                dict = self.__options_per_key[optname][1]
501                if not key:
502                        return dict.keys()
503                if not dict.has_key(key):
504                        return None
505                obj = dict[key]
506                if not subname:
507                        return obj
508                if not obj.has_key(subname):
509                        return None
510                return obj[subname][OPT_VAL]
511
512        def __init__(self):
513                #init default values
514                for event in self.soundevents_default:
515                        default = self.soundevents_default[event]
516                        self.add_per('soundevents', event)
517                        self.set_per('soundevents', event, 'enabled', default[0])
518                        self.set_per('soundevents', event, 'path', default[1])
519
520                # set initial cache values for proxie65 hosts
521                for proxy in self.ft_proxies65_default:
522                        default = self.ft_proxies65_default[proxy]
523                        self.add_per('ft_proxies65_cache', proxy)
524                  Â