Package common :: Module config
[hide private]
[frames] | no frames]

Source Code for Module common.config

  1  # -*- coding:utf-8 -*- 
  2  ## src/common/config.py 
  3  ## 
  4  ## Copyright (C) 2003-2010 Yann Leboulanger <asterix AT lagaule.org> 
  5  ## Copyright (C) 2004-2005 Vincent Hanquez <tab AT snarc.org> 
  6  ## Copyright (C) 2005 Stéphan Kochen <stephan AT kochen.nl> 
  7  ## Copyright (C) 2005-2006 Dimitur Kirov <dkirov AT gmail.com> 
  8  ##                         Alex Mauer <hawke AT hawkesnest.net> 
  9  ##                         Nikos Kouremenos <kourem AT gmail.com> 
 10  ## Copyright (C) 2005-2007 Travis Shirk <travis AT pobox.com> 
 11  ## Copyright (C) 2006 Stefan Bethge <stefan AT lanpartei.de> 
 12  ## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org> 
 13  ## Copyright (C) 2007 James Newton <redshodan AT gmail.com> 
 14  ##                    Julien Pivotto <roidelapluie AT gmail.com> 
 15  ## Copyright (C) 2007-2008 Brendan Taylor <whateley AT gmail.com> 
 16  ##                         Stephan Erb <steve-e AT h3c.de> 
 17  ## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org> 
 18  ## 
 19  ## This file is part of Gajim. 
 20  ## 
 21  ## Gajim is free software; you can redistribute it and/or modify 
 22  ## it under the terms of the GNU General Public License as published 
 23  ## by the Free Software Foundation; version 3 only. 
 24  ## 
 25  ## Gajim is distributed in the hope that it will be useful, 
 26  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 27  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 28  ## GNU General Public License for more details. 
 29  ## 
 30  ## You should have received a copy of the GNU General Public License 
 31  ## along with Gajim. If not, see <http://www.gnu.org/licenses/>. 
 32  ## 
 33   
 34   
 35  import sys 
 36  import re 
 37  import copy 
 38  import defs 
 39   
 40   
 41  ( 
 42  OPT_TYPE, 
 43  OPT_VAL, 
 44  OPT_DESC, 
 45  # If OPT_RESTART is True - we need restart to use our changed option 
 46  # OPT_DESC also should be there 
 47  OPT_RESTART, 
 48  ) = range(4) 
 49   
 50  opt_int = [ 'integer', 0 ] 
 51  opt_str = [ 'string', 0 ] 
 52  opt_bool = [ 'boolean', 0 ] 
 53  opt_color = [ 'color', '^(#[0-9a-fA-F]{6})|()$' ] 
 54  opt_one_window_types = ['never', 'always', 'always_with_roster', 'peracct', 'pertype'] 
 55  opt_treat_incoming_messages = ['', 'chat', 'normal'] 
 56   
57 -class Config:
58 59 DEFAULT_ICONSET = 'dcraven' 60 DEFAULT_MOOD_ICONSET = 'default' 61 DEFAULT_ACTIVITY_ICONSET = 'default' 62 DEFAULT_OPENWITH = 'gnome-open' 63 DEFAULT_BROWSER = 'firefox' 64 DEFAULT_MAILAPP = 'mozilla-thunderbird -compose' 65 DEFAULT_FILE_MANAGER = 'xffm' 66 67 __options = { 68 # name: [ type, default_value, help_string ] 69 'verbose': [ opt_bool, False, '', True ], 70 'autopopup': [ opt_bool, False ], 71 'notify_on_signin': [ opt_bool, True ], 72 'notify_on_signout': [ opt_bool, False ], 73 'notify_on_new_message': [ opt_bool, True ], 74 'autopopupaway': [ opt_bool, False ], 75 'sounddnd': [ opt_bool, False, _('Play sound when user is busy')], 76 'use_notif_daemon': [ opt_bool, True, _('Use D-Bus and Notification-Daemon to show notifications') ], 77 'showoffline': [ opt_bool, False ], 78 'show_only_chat_and_online': [ opt_bool, False, _('Show only online and free for chat contacts in roster.')], 79 'show_transports_group': [ opt_bool, True ], 80 'autoaway': [ opt_bool, True ], 81 'autoawaytime': [ opt_int, 5, _('Time in minutes, after which your status changes to away.') ], 82 'autoaway_message': [ opt_str, _('$S (Away as a result of being idle more than $T min)'), _('$S will be replaced by current status message, $T by autoaway time.') ], 83 'autoxa': [ opt_bool, True ], 84 'autoxatime': [ opt_int, 15, _('Time in minutes, after which your status changes to not available.') ], 85 'autoxa_message': [ opt_str, _('$S (Not available as a result of being idle more than $T min)'), _('$S will be replaced by current status message, $T by autoxa time.') ], 86 'ask_online_status': [ opt_bool, False ], 87 'ask_offline_status': [ opt_bool, False ], 88 'trayicon': [opt_str, 'always', _("When to show systray icon. Can be 'never', 'on_event', 'always'."), True], 89 'iconset': [ opt_str, DEFAULT_ICONSET, '', True ], 90 'mood_iconset': [ opt_str, DEFAULT_MOOD_ICONSET, '', True ], 91 'activity_iconset': [ opt_str, DEFAULT_ACTIVITY_ICONSET, '', True ], 92 'use_transports_iconsets': [ opt_bool, True, '', True ], 93 'inmsgcolor': [ opt_color, '#a40000', _('Incoming nickname color.'), True ], 94 'outmsgcolor': [ opt_color, '#3465a4', _('Outgoing nickname color.'), True ], 95 'inmsgtxtcolor': [ opt_color, '', _('Incoming text color.'), True ], 96 'outmsgtxtcolor': [ opt_color, '#555753', _('Outgoing text color.'), True ], 97 'statusmsgcolor': [ opt_color, '#4e9a06', _('Status message text color.'), True ], 98 'markedmsgcolor': [ opt_color, '#ff8080', '', True ], 99 'urlmsgcolor': [ opt_color, '#204a87', '', True ], 100 'inmsgfont': [ opt_str, '', _('Incoming nickname font.'), True ], 101 'outmsgfont': [ opt_str, '', _('Outgoing nickname font.'), True ], 102 'inmsgtxtfont': [ opt_str, '', _('Incoming text font.'), True ], 103 'outmsgtxtfont': [ opt_str, '', _('Outgoing text font.'), True ], 104 'statusmsgfont': [ opt_str, '', _('Status message text font.'), True ], 105 'collapsed_rows': [ opt_str, '', _('List (space separated) of rows (accounts and groups) that are collapsed.'), True ], 106 'roster_theme': [ opt_str, _('default'), '', True ], 107 'mergeaccounts': [ opt_bool, False, '', True ], 108 'sort_by_show_in_roster': [ opt_bool, True, '', True ], 109 'sort_by_show_in_muc': [ opt_bool, False, '', True ], 110 'use_speller': [ opt_bool, False, ], 111 'ignore_incoming_xhtml': [ opt_bool, False, ], 112 'speller_language': [ opt_str, '', _('Language used by speller')], 113 'print_time': [ opt_str, 'always', _('\'always\' - print time for every message.\n\'sometimes\' - print time every print_ichat_every_foo_minutes minute.\n\'never\' - never print time.')], 114 'print_time_fuzzy': [ opt_int, 0, _('Print time in chats using Fuzzy Clock. Value of fuzziness from 1 to 4, or 0 to disable fuzzyclock. 1 is the most precise clock, 4 the least precise one. This is used only if print_time is \'sometimes\'.') ], 115 'emoticons_theme': [opt_str, 'static', '', True ], 116 'ascii_formatting': [ opt_bool, True, 117 _('Treat * / _ pairs as possible formatting characters.'), True], 118 'show_ascii_formatting_chars': [ opt_bool, True, _('If True, do not ' 119 'remove */_ . So *abc* will be bold but with * * not removed.')], 120 'rst_formatting_outgoing_messages': [ opt_bool, False, 121 _('Uses ReStructured text markup to send HTML, plus ascii formatting if selected. For syntax, see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html (If you want to use this, install docutils)')], 122 'sounds_on': [ opt_bool, True ], 123 # 'aplay', 'play', 'esdplay', 'artsplay' detected first time only 124 'soundplayer': [ opt_str, '' ], 125 'openwith': [ opt_str, DEFAULT_OPENWITH ], 126 'custombrowser': [ opt_str, DEFAULT_BROWSER ], 127 'custommailapp': [ opt_str, DEFAULT_MAILAPP ], 128 'custom_file_manager': [ opt_str, DEFAULT_FILE_MANAGER ], 129 'gc-hpaned-position': [opt_int, 430], 130 'gc_refer_to_nick_char': [opt_str, ',', _('Character to add after nickname when using nick completion (tab) in group chat.')], 131 'gc_proposed_nick_char': [opt_str, '_', _('Character to propose to add after desired nickname when desired nickname is used by someone else in group chat.')], 132 'msgwin-max-state': [opt_bool, False], 133 'msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide 134 'msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide 135 'msgwin-width': [opt_int, 500], 136 'msgwin-height': [opt_int, 440], 137 'chat-msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide 138 'chat-msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide 139 'chat-msgwin-width': [opt_int, 480], 140 'chat-msgwin-height': [opt_int, 440], 141 'gc-msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide 142 'gc-msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide 143 'gc-msgwin-width': [opt_int, 600], 144 'gc-msgwin-height': [opt_int, 440], 145 'single-msg-x-position': [opt_int, 0], 146 'single-msg-y-position': [opt_int, 0], 147 'single-msg-width': [opt_int, 400], 148 'single-msg-height': [opt_int, 280], 149 'roster_x-position': [ opt_int, 0 ], 150 'roster_y-position': [ opt_int, 0 ], 151 'roster_width': [ opt_int, 200 ], 152 'roster_height': [ opt_int, 400 ], 153 'history_window_width': [ opt_int, 650 ], 154 'history_window_height': [ opt_int, 450 ], 155 'history_window_x-position': [ opt_int, 0 ], 156 'history_window_y-position': [ opt_int, 0 ], 157 'latest_disco_addresses': [ opt_str, '' ], 158 'recently_groupchat': [ opt_str, '' ], 159 'time_stamp': [ opt_str, '[%X] ', _('This option let you customize timestamp that is printed in conversation. For exemple "[%H:%M] " will show "[hour:minute] ". See python doc on strftime for full documentation: http://docs.python.org/lib/module-time.html') ], 160 'before_nickname': [ opt_str, '', _('Characters that are printed before the nickname in conversations') ], 161 'after_nickname': [ opt_str, ':', _('Characters that are printed after the nickname in conversations') ], 162 'notify_on_new_gmail_email': [ opt_bool, True ], 163 'notify_on_new_gmail_email_extra': [ opt_bool, False ], 164 'notify_on_new_gmail_email_command': [ opt_str, '', _('Specify the command to run when new mail arrives, e.g.: /usr/bin/getmail -q') ], 165 'use_gpg_agent': [ opt_bool, False ], 166 'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')], 167 'restore_lines': [opt_int, 4, _('How many lines to remember from previous conversation when a chat tab/window is reopened.')], 168 'restore_timeout': [opt_int, 60, _('How many minutes should last lines from previous conversation last.')], 169 'muc_restore_lines': [opt_int, 20, _('How many lines to request to server when entering a groupchat.')], 170 'muc_restore_timeout': [opt_int, 60, _('How many minutes back to request logs when a entering a groupchat.')], 171 'muc_autorejoin_timeout': [opt_int, 1, _('How many seconds to wait before trying to autorejoin to a conference you are being disconnected from. Set to 0 to disable autorejoining.')], 172 'muc_autorejoin_on_kick': [opt_bool, False, 'Should autorejoin be activated when we are being kicked from a conference?'], 173 'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')], 174 'show_roster_on_startup': [opt_bool, True], 175 'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')], 176 'version': [ opt_str, defs.version ], # which version created the config 177 'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'], 178 'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")], 179 'always_english_wikipedia': [opt_bool, False], 180 'always_english_wiktionary': [opt_bool, True], 181 'remote_control': [opt_bool, True, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True], 182 'networkmanager_support': [opt_bool, True, _('If True, listen to D-Bus signals from NetworkManager and change the status of accounts (provided they do not have listen_to_network_manager set to False and they sync with global status) based upon the status of the network connection.'), True], 183 'outgoing_chat_state_notifications': [opt_str, 'all', _('Sent chat state notifications. Can be one of all, composing_only, disabled.')], 184 'displayed_chat_state_notifications': [opt_str, 'all', _('Displayed chat state notifications in chat windows. Can be one of all, composing_only, disabled.')], 185 'autodetect_browser_mailer': [opt_bool, False, '', True], 186 'print_ichat_every_foo_minutes': [opt_int, 5, _('When not printing time for every message (print_time==sometimes), print it every x minutes.')], 187 'confirm_close_muc': [opt_bool, True, _('Ask before closing a group chat tab/window.')], 188 'confirm_close_muc_rooms': [opt_str, '', _('Always ask before closing group chat tab/window in this space separated list of group chat jids.')], 189 'noconfirm_close_muc_rooms': [opt_str, '', _('Never ask before closing group chat tab/window in this space separated list of group chat jids.')], 190 'confirm_close_multiple_tabs': [opt_bool, True, _('Ask before closing tabbed chat window if there are control that can loose data (chat, private chat, groupchat that will not be minimized)')], 191 'notify_on_file_complete': [opt_bool, True], 192 'file_transfers_port': [opt_int, 28011], 193 'ft_add_hosts_to_send': [opt_str, '', _('Comma separated list of hosts that we send, in addition of local interfaces, for File Transfer in case of address translation/port forwarding.')], 194 'conversation_font': [opt_str, ''], 195 'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')], 196 'notify_on_all_muc_messages': [opt_bool, False], 197 'trayicon_notification_on_events': [opt_bool, True, _('Notify of events in the system trayicon.')], 198 'last_save_dir': [opt_str, ''], 199 'last_send_dir': [opt_str, ''], 200 'last_emoticons_dir': [opt_str, ''], 201 'last_sounds_dir': [opt_str, ''], 202 'tabs_position': [opt_str, 'top'], 203 'tabs_always_visible': [opt_bool, False, _('Show tab when only one conversation?')], 204 'tabs_border': [opt_bool, False, _('Show tabbed notebook border in chat windows?')], 205 'tabs_close_button': [opt_bool, True, _('Show close button in tab?')], 206 'esession_modp': [opt_str, '5,14', _('A list of modp groups to use in a Diffie-Hellman, highest preference first, separated by commas. Valid groups are 1, 2, 5, 14, 15, 16, 17 and 18. Higher numbers are more secure, but take longer to calculate when you start a session.')], 207 'chat_avatar_width': [opt_int, 52], 208 'chat_avatar_height': [opt_int, 52], 209 'roster_avatar_width': [opt_int, 32], 210 'roster_avatar_height': [opt_int, 32], 211 'tooltip_avatar_width': [opt_int, 125], 212 'tooltip_avatar_height': [opt_int, 125], 213 'vcard_avatar_width': [opt_int, 200], 214 'vcard_avatar_height': [opt_int, 200], 215 'notification_preview_message': [opt_bool, True, _('Preview new messages in notification popup?')], 216 'notification_position_x': [opt_int, -1], 217 'notification_position_y': [opt_int, -1], 218 'notification_avatar_width': [opt_int, 48], 219 'notification_avatar_height': [opt_int, 48], 220 'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in group chats.')], 221 '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.')], 222 'check_if_gajim_is_default': [opt_bool, True, _('If True, Gajim will check if it\'s the default jabber client on each startup.')], 223 '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.')], 224 '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.'), True], 225 'show_avatars_in_roster': [opt_bool, True, '', True], 226 'show_mood_in_roster': [opt_bool, True, '', True], 227 'show_activity_in_roster': [opt_bool, True, '', True], 228 'show_tunes_in_roster': [opt_bool, True, '', True], 229 'show_location_in_roster': [opt_bool, True, '', True], 230 'avatar_position_in_roster': [opt_str, 'right', _('Define the position of the avatar in roster. Can be left or right'), True], 231 '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.')], 232 'print_status_in_chats': [opt_bool, True, _('If False, Gajim will no longer print status line in chats when a contact changes his or her status and/or his or her status message.')], 233 'print_status_in_muc': [opt_str, 'in_and_out', _('can be "none", "all" or "in_and_out". If "none", Gajim will no longer print status line in groupchats when a member changes his or her status and/or his or her status message. If "all" Gajim will print all status messages. If "in_and_out", Gajim will only print FOO enters/leaves group chat.')], 234 'log_contact_status_changes': [opt_bool, False], 235 'just_connected_bg_color': [opt_str, '#adc3c6', _('Background color of contacts when they just signed in.')], 236 'just_disconnected_bg_color': [opt_str, '#ab6161', _('Background color of contacts when they just signed out.')], 237 'restored_messages_color': [opt_color, '#555753'], 238 'restored_messages_small': [opt_bool, True, _('If True, restored messages will use a smaller font than the default one.')], 239 'hide_avatar_of_transport': [opt_bool, False, _('Don\'t show avatar for the transport itself.')], 240 'roster_window_skip_taskbar': [opt_bool, False, _('Don\'t show roster in the system taskbar.')], 241 'use_urgency_hint': [opt_bool, True, _('If True and installed GTK+ and PyGTK versions are at least 2.8, make the window flash (the default behaviour in most Window Managers) when holding pending events.')], 242 'notification_timeout': [opt_int, 5], 243 'send_sha_in_gc_presence': [opt_bool, True, _('Jabberd1.4 does not like sha info when one join a password protected group chat. Turn this option to False to stop sending sha info in group chat presences.')], 244 'one_message_window': [opt_str, 'always', 245 #always, never, peracct, pertype should not be translated 246 _('Controls the window where new messages are placed.\n\'always\' - All messages are sent to a single window.\n\'always_with_roster\' - Like \'always\' but the messages are in a single window along with the roster.\n\'never\' - All messages get their own window.\n\'peracct\' - Messages for each account are sent to a specific window.\n\'pertype\' - Each message type (e.g., chats vs. groupchats) are sent to a specific window.')], 247 'show_avatar_in_chat': [opt_bool, True, _('If False, you will no longer see the avatar in the chat window.')], 248 'escape_key_closes': [opt_bool, True, _('If True, pressing the escape key closes a tab/window.')], 249 'compact_view': [opt_bool, False, _('Hides the buttons in chat windows.')], 250 'hide_groupchat_banner': [opt_bool, False, _('Hides the banner in a group chat window')], 251 'hide_chat_banner': [opt_bool, False, _('Hides the banner in two persons chat window')], 252 'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the group chat occupants list in group chat window.')], 253 'chat_merge_consecutive_nickname': [opt_bool, False, _('In a chat, show the nickname at the beginning of a line only when it\'s not the same person talking than in previous message.')], 254 'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nickname.')], 255 'use_smooth_scrolling': [opt_bool, True, _('Smooth scroll message in conversation window')], 256 'gc_nicknames_colors': [ opt_str, '#4e9a06:#f57900:#ce5c00:#3465a4:#204a87:#75507b:#5c3566:#c17d11:#8f5902:#ef2929:#cc0000:#a40000', _('List of colors, separated by ":", that will be used to color nicknames in group chats.'), True ], 257 'ctrl_tab_go_to_next_composing': [opt_bool, True, _('Ctrl-Tab go to next composing tab when none is unread.')], 258 'confirm_metacontacts': [ opt_str, '', _('Should we show the confirm metacontacts creation dialog or not? Empty string means we never show the dialog.')], 259 'confirm_block': [ opt_str, '', _('Should we show the confirm block contact dialog or not? Empty string means we never show the dialog.')], 260 'confirm_custom_status': [ opt_str, '', _('Should we show the confirm custom status dialog or not? Empty string means we never show the dialog.')], 261 'enable_negative_priority': [ opt_bool, False, _('If True, you will be able to set a negative priority to your account in account modification window. BE CAREFUL, when you are logged in with a negative priority, you will NOT receive any message from your server.')], 262 'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use Gnome Keyring (if available) to store account passwords.')], 263 'use_kwalletcli': [opt_bool, True, _('If True, Gajim will use KDE Wallet (if kwalletcli is available) to store account passwords.')], 264 'show_contacts_number': [opt_bool, True, _('If True, Gajim will show number of online and total contacts in account and group rows.')], 265 'treat_incoming_messages': [ opt_str, '', _('Can be empty, \'chat\' or \'normal\'. If not empty, treat all incoming messages as if they were of this type')], 266 'scroll_roster_to_last_message': [opt_bool, True, _('If True, Gajim will scroll and select the contact who sent you the last message, if chat window is not already opened.')], 267 'use_latex': [opt_bool, False, _('If True, Gajim will convert string between $$ and $$ to an image using dvips and convert before insterting it in chat window.')], 268 'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')], 269 'max_conversation_lines': [opt_int, 500, _('Maximum number of lines that are printed in conversations. Oldest lines are cleared.')], 270 'attach_notifications_to_systray': [opt_bool, False, _('If True, notification windows from notification-daemon will be attached to systray icon.')], 271 'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')], 272 'latex_png_dpi': [opt_str, '108', _('Change the value to change the size of latex formulas displayed. The higher is larger.') ], 273 'uri_schemes': [opt_str, 'aaa aaas acap cap cid crid data dav dict dns fax file ftp go gopher h323 http https icap im imap info ipp iris iris.beep iris.xpc iris.xpcs iris.lwz ldap mid modem msrp msrps mtqp mupdate news nfs nntp opaquelocktoken pop pres rtsp service shttp sip sips snmp soap.beep soap.beeps tag tel telnet tftp thismessage tip tv urn vemmi xmlrpc.beep xmlrpc.beeps z39.50r z39.50s about cvs daap ed2k feed fish git iax2 irc ircs ldaps magnet mms rsync ssh svn sftp smb webcal', _('Valid uri schemes. Only schemes in this list will be accepted as "real" uri. (mailto and xmpp are handled separately)'), True], 274 'ask_offline_status_on_connection': [ opt_bool, False, _('Ask offline status message to all offline contacts when connection to an accoutn is established. WARNING: This causes a lot of requests to be sent!') ], 275 'shell_like_completion': [ opt_bool, False, _('If True, completion in groupchats will be like a shell auto-completion')], 276 'show_self_contact': [opt_str, 'when_other_resource', _('When is self contact row displayed. Can be "always", "when_other_resource" or "never"'), True], 277 'audio_input_device': [opt_str, 'autoaudiosrc ! volume name=gajim_vol'], 278 'audio_output_device': [opt_str, 'autoaudiosink'], 279 'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'], 280 'video_output_device': [opt_str, 'autovideosink'], 281 'video_framerate': [opt_str, '', _('Optionally fix jingle output video framerate. Example: 10/1 or 25/2')], 282 'video_size': [opt_str, '', _('Optionally resize jingle output video. Example: 320x240')], 283 'audio_input_volume': [opt_int, 50], 284 'audio_output_volume': [opt_int, 50], 285 'use_stun_server': [opt_bool, True, _('If True, Gajim will try to use a STUN server when using jingle. The one in "stun_server" option, or the one given by the jabber server.')], 286 'stun_server': [opt_str, '', _('STUN server to use when using jingle')], 287 'show_affiliation_in_groupchat': [opt_bool, True, _('If True, Gajim will show affiliation of groupchat occupants by adding a colored square to the status icon')], 288 } 289 290 __options_per_key = { 291 'accounts': ({ 292 'name': [ opt_str, '', '', True ], 293 'hostname': [ opt_str, '', '', True ], 294 'anonymous_auth': [ opt_bool, False ], 295 'client_cert': [ opt_str, '', '', True ], 296 'savepass': [ opt_bool, False ], 297 'password': [ opt_str, '' ], 298 'resource': [ opt_str, 'gajim', '', True ], 299 'priority': [ opt_int, 5, '', True ], 300 'adjust_priority_with_status': [ opt_bool, True, _('Priority will change automatically according to your status. Priorities are defined in autopriority_* options.') ], 301 'autopriority_online': [ opt_int, 50], 302 'autopriority_chat': [ opt_int, 50], 303 'autopriority_away': [ opt_int, 40], 304 'autopriority_xa': [ opt_int, 30], 305 'autopriority_dnd': [ opt_int, 20], 306 'autopriority_invisible': [ opt_int, 10], 307 'autoconnect': [ opt_bool, False, '', True ], 308 'autoconnect_as': [ opt_str, 'online', _('Status used to autoconnect as. Can be online, chat, away, xa, dnd, invisible. NOTE: this option is used only if restore_last_status is disabled'), True ], 309 'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ], 310 'autoreconnect': [ opt_bool, True ], 311 'autoauth': [ opt_bool, False, _('If True, Contacts requesting authorization will be automatically accepted.')], 312 'active': [ opt_bool, True, _('If False, this account will be disabled and will not appear in roster window.'), True], 313 'proxy': [ opt_str, '', '', True ], 314 'keyid': [ opt_str, '', '', True ], 315 'gpg_sign_presence': [ opt_bool, True, _('If disabled, don\'t sign presences with GPG key, even if GPG is configured.') ], 316 'keyname': [ opt_str, '', '', True ], 317 'enable_esessions': [opt_bool, True, _('Enable ESessions encryption for this account.')], 318 'autonegotiate_esessions': [opt_bool, True, _('Should Gajim automatically start an encrypted session when possible?')], 319 'connection_types': [ opt_str, 'tls ssl plain', _('Ordered list (space separated) of connection type to try. Can contain tls, ssl or plain')], 320 'warn_when_plaintext_connection': [ opt_bool, True, _('Show a warning dialog before sending password on an plaintext connection.') ], 321 'warn_when_insecure_ssl_connection': [ opt_bool, True, _('Show a warning dialog before using standard SSL library.') ], 322 'warn_when_insecure_password': [ opt_bool, True, _('Show a warning dialog before sending PLAIN password over a plain conenction.') ], 323 'ssl_fingerprint_sha1': [ opt_str, '', '', True ], 324 'ignore_ssl_errors': [ opt_str, '', _('Space separated list of ssl errors to ignore.') ], 325 'use_srv': [ opt_bool, True, '', True ], 326 'use_custom_host': [ opt_bool, False, '', True ], 327 'custom_port': [ opt_int, 5222, '', True ], 328 'custom_host': [ opt_str, '', '', True ], 329 'sync_with_global_status': [ opt_bool, False, ], 330 'no_log_for': [ opt_str, '' ], 331 'minimized_gc': [ opt_str, '' ], 332 'attached_gpg_keys': [ opt_str, '' ], 333 'keep_alives_enabled': [ opt_bool, True, _('Whitespace sent after inactivity')], 334 'ping_alives_enabled': [ opt_bool, True, _('XMPP ping sent after inactivity')], 335 # send keepalive every N seconds of inactivity 336 'keep_alive_every_foo_secs': [ opt_int, 55 ], 337 'ping_alive_every_foo_secs': [ opt_int, 120 ], 338 'time_for_ping_alive_answer': [ opt_int, 60, _('How many seconds to wait for the answer of ping alive packet before we try to reconnect.') ], 339 # try for 1 minutes before giving up (aka. timeout after those seconds) 340 'try_connecting_for_foo_secs': [ opt_int, 60 ], 341 'http_auth': [opt_str, 'ask'], # yes, no, ask 342 'dont_ack_subscription': [opt_bool, False, _('Jabberd2 workaround')], 343 # proxy65 for FT 344 'file_transfer_proxies': [opt_str, 'proxy.eu.jabber.org, proxy.jabber.ru, proxy.jabbim.cz'], 345 'use_ft_proxies': [opt_bool, True, _('If checked, Gajim will use your IP and proxies defined in file_transfer_proxies option for file transfer.'), True], 346 'msgwin-x-position': [opt_int, -1], # Default is to let the wm decide 347 'msgwin-y-position': [opt_int, -1], # Default is to let the wm decide 348 'msgwin-width': [opt_int, 480], 349 'msgwin-height': [opt_int, 440], 350 'listen_to_network_manager': [opt_bool, True], 351 'is_zeroconf': [opt_bool, False], 352 'last_status': [opt_str, 'online'], 353 'last_status_msg': [opt_str, ''], 354 'zeroconf_first_name': [ opt_str, '', '', True ], 355 'zeroconf_last_name': [ opt_str, '', '', True ], 356 'zeroconf_jabber_id': [ opt_str, '', '', True ], 357 'zeroconf_email': [ opt_str, '', '', True ], 358 'use_env_http_proxy': [opt_bool, False], 359 'answer_receipts': [opt_bool, True, _('Answer to receipt requests')], 360 'request_receipt': [opt_bool, True, _('Sent receipt requests')], 361 'publish_tune': [opt_bool, False], 362 'publish_location': [opt_bool, False], 363 'subscribe_mood': [opt_bool, True], 364 'subscribe_activity': [opt_bool, True], 365 'subscribe_tune': [opt_bool, True], 366 'subscribe_nick': [opt_bool, True], 367 'subscribe_location': [opt_bool, True], 368 'ignore_unknown_contacts': [ opt_bool, False ], 369 'send_os_info': [ opt_bool, True ], 370 'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')], 371 'send_idle_time': [ opt_bool, True ], 372 'roster_version': [opt_str, ''], 373 'subscription_request_msg': [opt_str, '', _('Message that is sent to contacts you want to add')], 374 }, {}), 375 'statusmsg': ({ 376 'message': [ opt_str, '' ], 377 'activity': [ opt_str, '' ], 378 'subactivity': [ opt_str, '' ], 379 'activity_text': [ opt_str, '' ], 380 'mood': [ opt_str, '' ], 381 'mood_text': [ opt_str, '' ], 382 }, {}), 383 'defaultstatusmsg': ({ 384 'enabled': [ opt_bool, False ], 385 'message': [ opt_str, '' ], 386 }, {}), 387 'soundevents': ({ 388 'enabled': [ opt_bool, True ], 389 'path': [ opt_str, '' ], 390 }, {}), 391 'proxies': ({ 392 'type': [ opt_str, 'http' ], 393 'host': [ opt_str, '' ], 394 'port': [ opt_int, 3128 ], 395 'useauth': [ opt_bool, False ], 396 'user': [ opt_str, '' ], 397 'pass': [ opt_str, '' ], 398 'bosh_uri': [ opt_str, '' ], 399 'bosh_useproxy': [ opt_bool, False ], 400 'bosh_wait': [ opt_int, 30 ], 401 'bosh_hold': [ opt_int, 2 ], 402 'bosh_content': [ opt_str, 'text/xml; charset=utf-8' ], 403 'bosh_http_pipelining': [ opt_bool, False ], 404 'bosh_wait_for_restart_response': [ opt_bool, False ], 405 }, {}), 406 'themes': ({ 407 'accounttextcolor': [ opt_color, 'black', '', True ], 408 'accountbgcolor': [ opt_color, 'white', '', True ], 409 'accountfont': [ opt_str, '', '', True ], 410 'accountfontattrs': [ opt_str, 'B', '', True ], 411 'grouptextcolor': [ opt_color, 'black', '', True ], 412 'groupbgcolor': [ opt_color, 'white', '', True ], 413 'groupfont': [ opt_str, '', '', True ], 414 'groupfontattrs': [ opt_str, 'I', '', True ], 415 'contacttextcolor': [ opt_color, 'black', '', True ], 416 'contactbgcolor': [ opt_color, 'white', '', True ], 417 'contactfont': [ opt_str, '', '', True ], 418 'contactfontattrs': [ opt_str, '', '', True ], 419 'bannertextcolor': [ opt_color, 'black', '', True ], 420 'bannerbgcolor': [ opt_color, '', '', True ], 421 'bannerfont': [ opt_str, '', '', True ], 422 'bannerfontattrs': [ opt_str, 'B', '', True ], 423 424 # http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html 425 'state_inactive_color': [ opt_color, 'grey62' ], 426 'state_composing_color': [ opt_color, 'green4' ], 427 'state_paused_color': [ opt_color, 'mediumblue' ], 428 'state_gone_color': [ opt_color, 'grey' ], 429 430 # MUC chat states 431 'state_muc_msg_color': [ opt_color, 'mediumblue' ], 432 'state_muc_directed_msg_color': [ opt_color, 'red2' ], 433 }, {}), 434 'contacts': ({ 435 'gpg_enabled': [ opt_bool, False, _('Is OpenPGP enabled for this contact?')], 436 'autonegotiate_esessions': [opt_bool, True, _('Should Gajim automatically start an encrypted session with this contact when possible?')], 437 'speller_language': [ opt_str, '', _('Language for which we want to check misspelled words')], 438 }, {}), 439 'rooms': ({ 440 'speller_language': [ opt_str, '', _('Language for which we want to check misspelled words')], 441 }, {}), 442 'notifications': ({ 443 'event': [opt_str, ''], 444 'recipient_type': [opt_str, 'all'], 445 'recipients': [opt_str, ''], 446 'status': [opt_str, 'all', _('all or space separated status')], 447 'tab_opened': [opt_str, 'both', _("'yes', 'no', or 'both'")], 448 'sound': [opt_str, '', _("'yes', 'no' or ''")], 449 'sound_file': [opt_str, ''], 450 'popup': [opt_str, '', _("'yes', 'no' or ''")], 451 'auto_open': [opt_str, '', _("'yes', 'no' or ''")], 452 'run_command': [opt_bool, False], 453 'command': [opt_str, ''], 454 'systray': [opt_str, '', _("'yes', 'no' or ''")], 455 'roster': [opt_str, '', _("'yes', 'no' or ''")], 456 'urgency_hint': [opt_bool, False], 457 }, {}), 458 'plugins': ({ 459 'active': [opt_bool, False, _('State whether plugins should be activated on exit (this is saved on Gajim exit). This option SHOULD NOT be used to (de)activate plug-ins. Use GUI instead.')], 460 },{}), 461 } 462 463 statusmsg_default = { 464 _('Sleeping'): [ 'ZZZZzzzzzZZZZZ', 'inactive', 'sleeping', '', 'sleepy', '' ], 465 _('Back soon'): [ _('Back in some minutes.'), '', '', '', '', '' ], 466 _('Eating'): [ _("I'm eating, so leave me a message."), 'eating', 'other', '', '', '' ], 467 _('Movie'): [ _("I'm watching a movie."), 'relaxing', 'watching_a_movie', '', '', '' ], 468 _('Working'): [ _("I'm working."), 'working', 'other', '', '', '' ], 469 _('Phone'): [ _("I'm on the phone."), 'talking', 'on_the_phone', '', '', '' ], 470 _('Out'): [ _("I'm out enjoying life."), 'relaxing', 'going_out', '', '', '' ], 471 '_last_online': ['', '', '', '', '', ''], 472 '_last_chat': ['', '', '', '', '', ''], 473 '_last_away': ['', '', '', '', '', ''], 474 '_last_xa': ['', '', '', '', '', ''], 475 '_last_dnd': ['', '', '', '', '', ''], 476 '_last_invisible': ['', '', '', '', '', ''], 477 '_last_offline': ['', '', '', '', '', ''], 478 } 479 480 defaultstatusmsg_default = { 481 'online': [ False, _("I'm available.") ], 482 'chat': [ False, _("I'm free for chat.") ], 483 'away': [ False, _('Be right back.') ], 484 'xa': [ False, _("I'm not available.") ], 485 'dnd': [ False, _('Do not disturb.') ], 486 'invisible': [ False, _('Bye!') ], 487 'offline': [ False, _('Bye!') ], 488 } 489 490 soundevents_default = { 491 'first_message_received': [ True, 'message1.wav' ], 492 'next_message_received_focused': [ True, 'message2.wav' ], 493 'next_message_received_unfocused': [ True, 'message2.wav' ], 494 'contact_connected': [ True, 'connected.wav' ], 495 'contact_disconnected': [ True, 'disconnected.wav' ], 496 'message_sent': [ True, 'sent.wav' ], 497 'muc_message_highlight': [ True, 'gc_message1.wav', _('Sound to play when a group chat message contains one of the words in muc_highlight_words, or when a group chat message contains your nickname.')], 498 'muc_message_received': [ False, 'gc_message2.wav', _('Sound to play when any MUC message arrives.') ], 499 'gmail_received': [ False, 'message1.wav' ], 500 } 501 502 themes_default = { 503 # sorted alphanum 504 _('default'): [ '', '', '', 'B', '', '', '', 'I', '', '', '', '', '', '', 505 '', 'B' ], 506 507 _('green'): [ '', '#94aa8c', '', 'B', '#0000ff', '#eff3e7', 508 '', 'I', '#000000', '', '', '', '', 509 '#94aa8c', '', 'B' ], 510 511 _('grocery'): [ '', '#6bbe18', '', 'B', '#12125a', '#ceefad', 512 '', 'I', '#000000', '#efb26b', '', '', '', 513 '#108abd', '', 'B' ], 514 515 _('human'): [ '', '#996442', '', 'B', '#ab5920', '#e3ca94', 516 '', 'I', '#000000', '', '', '', '', 517 '#996442', '', 'B' ], 518 519 _('marine'): [ '', '#918caa', '', 'B', '', '#e9e7f3', 520 '', 'I', '#000000', '', '', '', '', 521 '#918caa', '', 'B' ], 522 523 } 524
525 - def foreach(self, cb, data = None):
526 for opt in self.__options: 527 cb(data, opt, None, self.__options[opt]) 528 for opt in self.__options_per_key: 529 cb(data, opt, None, None) 530 dict_ = self.__options_per_key[opt][1] 531 for opt2 in dict_.keys(): 532 cb(data, opt2, [opt], None) 533 for opt3 in dict_[opt2]: 534 cb(data, opt3, [opt, opt2], dict_[opt2][opt3])
535
536 - def get_children(self, node=None):
537 """ 538 Tree-like interface 539 """ 540 if node is None: 541 for child, option in self.__options.iteritems(): 542 yield (child, ), option 543 for grandparent in self.__options_per_key: 544 yield (grandparent, ), None 545 elif len(node) == 1: 546 grandparent, = node 547 for parent in self.__options_per_key[grandparent][1]: 548 yield (grandparent, parent), None 549 elif len(node) == 2: 550 grandparent, parent = node 551 children = self.__options_per_key[grandparent][1][parent] 552 for child, option in children.iteritems(): 553 yield (grandparent, parent, child), option 554 else: 555 raise ValueError('Invalid node')
556
557 - def is_valid_int(self, val):
558 try: 559 ival = int(val) 560 except Exception: 561 return None 562 return ival
563
564 - def is_valid_bool(self, val):
565 if val == 'True': 566 return True 567 elif val == 'False': 568 return False 569 else: 570 ival = self.is_valid_int(val) 571 if ival: 572 return True 573 elif ival is None: 574 return None 575 return False 576 return None
577
578 - def is_valid_string(self, val):
579 return val
580
581 - def is_valid(self, type_, val):
582 if not type_: 583 return None 584 if type_[0] == 'boolean': 585 return self.is_valid_bool(val) 586 elif type_[0] == 'integer': 587 return self.is_valid_int(val) 588 elif type_[0] == 'string': 589 return self.is_valid_string(val) 590 else: 591 if re.match(type_[1], val): 592 return val 593 else: 594 return None
595
596 - def set(self, optname, value):
597 if optname not in self.__options: 598 # raise RuntimeError, 'option %s does not exist' % optname 599 return 600 opt = self.__options[optname] 601 value = self.is_valid(opt[OPT_TYPE], value) 602 if value is None: 603 # raise RuntimeError, 'value of %s cannot be None' % optname 604 return 605 606 opt[OPT_VAL] = value
607
608 - def get(self, optname = None):
609 if not optname: 610 return self.__options.keys() 611 if optname not in self.__options: 612 return None 613 return self.__options[optname][OPT_VAL]
614
615 - def get_desc(self, optname):
616 if optname not in self.__options: 617 return None 618 if len(self.__options[optname]) > OPT_DESC: 619 return self.__options[optname][OPT_DESC]
620
621 - def get_restart(self, optname):
622 if optname not in self.__options: 623 return None 624 if len(self.__options[optname]) > OPT_RESTART: 625 return self.__options[optname][OPT_RESTART]
626
627 - def add_per(self, typename, name): # per_group_of_option
628 if typename not in self.__options_per_key: 629 # raise RuntimeError, 'option %s does not exist' % typename 630 return 631 632 opt = self.__options_per_key[typename] 633 if name in opt[1]: 634 # we already have added group name before 635 return 'you already have added %s before' % name 636 opt[1][name] = copy.deepcopy(opt[0])
637
638 - def del_per(self, typename, name, subname = None): # per_group_of_option
639 if typename not in self.__options_per_key: 640 # raise RuntimeError, 'option %s does not exist' % typename 641 return 642 643 opt = self.__options_per_key[typename] 644 if subname is None: 645 del opt[1][name] 646 # if subname is specified, delete the item in the group. 647 elif subname in opt[1][name]: 648 del opt[1][name][subname] 649
650 - def set_per(self, optname, key, subname, value): # per_group_of_option
651 if optname not in self.__options_per_key: 652 # raise RuntimeError, 'option %s does not exist' % optname 653 return 654 if not key: 655 return 656 dict_ = self.__options_per_key[optname][1] 657 if key not in dict_: 658 # raise RuntimeError, '%s is not a key of %s' % (key, dict_) 659 self.add_per(optname, key) 660 obj = dict_[key] 661 if subname not in obj: 662 # raise RuntimeError, '%s is not a key of %s' % (subname, obj) 663 return 664 subobj = obj[subname] 665 value = self.is_valid(subobj[OPT_TYPE], value) 666 if value is None: 667 # raise RuntimeError, '%s of %s cannot be None' % optname 668 return 669 subobj[OPT_VAL] = value 670
671 - def get_per(self, optname, key = None, subname = None): # per_group_of_option
672 if optname not in self.__options_per_key: 673 return None 674 dict_ = self.__options_per_key[optname][1] 675 if not key: 676 return dict_.keys() 677 if key not in dict_: 678 if optname in self.__options_per_key \ 679 and subname in self.__options_per_key[optname][0]: 680 return self.__options_per_key \ 681 [optname][0][subname][1] 682 return None 683 obj = dict_[key] 684 if not subname: 685 return obj 686 if subname not in obj: 687 return None 688 return obj[subname][OPT_VAL] 689
690 - def get_desc_per(self, optname, key = None, subname = None):
691 if optname not in self.__options_per_key: 692 return None 693 dict_ = self.__options_per_key[optname][1] 694 if not key: 695 return None 696 if key not in dict_: 697 return None 698 obj = dict_[key] 699 if not subname: 700 return None 701 if subname not in obj: 702 return None 703 if len(obj[subname]) > OPT_DESC: 704 return obj[subname][OPT_DESC] 705 return None
706
707 - def get_restart_per(self, optname, key = None, subname = None):
708 if optname not in self.__options_per_key: 709 return False 710 dict_ = self.__options_per_key[optname][1] 711 if not key: 712 return False 713 if key not in dict_: 714 return False 715 obj = dict_[key] 716 if not subname: 717 return False 718 if subname not in obj: 719 return False 720 if len(obj[subname]) > OPT_RESTART: 721 return obj[subname][OPT_RESTART] 722 return False
723
724 - def should_log(self, account, jid):
725 """ 726 Should conversations between a local account and a remote jid be logged? 727 """ 728 no_log_for = self.get_per('accounts', account, 'no_log_for') 729 730 if not no_log_for: 731 no_log_for = '' 732 733 no_log_for = no_log_for.split() 734 735 return (account not in no_log_for) and (jid not in no_log_for)
736
737 - def __init__(self):
738 #init default values 739 for event in self.soundevents_default: 740 default = self.soundevents_default[event] 741 self.add_per('soundevents', event) 742 self.set_per('soundevents', event, 'enabled', default[0]) 743 self.set_per('soundevents', event, 'path', default[1]) 744 745 for status in self.defaultstatusmsg_default: 746 default = self.defaultstatusmsg_default[status] 747 self.add_per('defaultstatusmsg', status) 748 self.set_per('defaultstatusmsg', status, 'enabled', default[0]) 749 self.set_per('defaultstatusmsg', status, 'message', default[1])
750