ability to connect to a host that require a PCKS certificate that is encrypted.
[gajim.git] / src / common / config.py
blob84562468f10f66da9139be132e4555c4e5c17777
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>
19 ## This file is part of Gajim.
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.
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.
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/>.
35 import sys
36 import re
37 import copy
38 import defs
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)
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_show_roster_on_startup = ['always', 'never', 'last_state']
56 opt_treat_incoming_messages = ['', 'chat', 'normal']
58 class Config:
60 DEFAULT_ICONSET = 'dcraven'
61 DEFAULT_MOOD_ICONSET = 'default'
62 DEFAULT_ACTIVITY_ICONSET = 'default'
63 DEFAULT_OPENWITH = 'xdg-open'
64 DEFAULT_BROWSER = 'firefox'
65 DEFAULT_MAILAPP = 'mozilla-thunderbird -compose'
66 DEFAULT_FILE_MANAGER = 'xffm'
68 __options = {
69 # name: [ type, default_value, help_string ]
70 'verbose': [ opt_bool, False, '', True ],
71 'autopopup': [ opt_bool, False ],
72 'notify_on_signin': [ opt_bool, True ],
73 'notify_on_signout': [ opt_bool, False ],
74 'notify_on_new_message': [ opt_bool, True ],
75 'autopopupaway': [ opt_bool, False ],
76 'sounddnd': [ opt_bool, False, _('Play sound when user is busy')],
77 'use_notif_daemon': [ opt_bool, True, _('Use D-Bus and Notification-Daemon to show notifications') ],
78 'showoffline': [ opt_bool, False ],
79 'show_only_chat_and_online': [ opt_bool, False, _('Show only online and free for chat contacts in roster.')],
80 'show_transports_group': [ opt_bool, True ],
81 'autoaway': [ opt_bool, True ],
82 'autoawaytime': [ opt_int, 5, _('Time in minutes, after which your status changes to away.') ],
83 '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.') ],
84 'autoxa': [ opt_bool, True ],
85 'autoxatime': [ opt_int, 15, _('Time in minutes, after which your status changes to not available.') ],
86 '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.') ],
87 'ask_online_status': [ opt_bool, False ],
88 'ask_offline_status': [ opt_bool, False ],
89 'trayicon': [opt_str, 'always', _("When to show notification area icon. Can be 'never', 'on_event', 'always'."), False],
90 'allow_hide_roster': [opt_bool, False, _("Allow to hide the roster window even if the tray icon is not shown."), False],
91 'iconset': [ opt_str, DEFAULT_ICONSET, '', True ],
92 'mood_iconset': [ opt_str, DEFAULT_MOOD_ICONSET, '', True ],
93 'activity_iconset': [ opt_str, DEFAULT_ACTIVITY_ICONSET, '', True ],
94 'use_transports_iconsets': [ opt_bool, True, '', True ],
95 'inmsgcolor': [ opt_color, '#a40000', _('Incoming nickname color.'), True ],
96 'outmsgcolor': [ opt_color, '#3465a4', _('Outgoing nickname color.'), True ],
97 'inmsgtxtcolor': [ opt_color, '', _('Incoming text color.'), True ],
98 'outmsgtxtcolor': [ opt_color, '#555753', _('Outgoing text color.'), True ],
99 'statusmsgcolor': [ opt_color, '#4e9a06', _('Status message text color.'), True ],
100 'markedmsgcolor': [ opt_color, '#ff8080', '', True ],
101 'urlmsgcolor': [ opt_color, '#204a87', '', True ],
102 'inmsgfont': [ opt_str, '', _('Incoming nickname font.'), True ],
103 'outmsgfont': [ opt_str, '', _('Outgoing nickname font.'), True ],
104 'inmsgtxtfont': [ opt_str, '', _('Incoming text font.'), True ],
105 'outmsgtxtfont': [ opt_str, '', _('Outgoing text font.'), True ],
106 'statusmsgfont': [ opt_str, '', _('Status message text font.'), True ],
107 'collapsed_rows': [ opt_str, '', _('List (space separated) of rows (accounts and groups) that are collapsed.'), True ],
108 'roster_theme': [ opt_str, _('default'), '', True ],
109 'mergeaccounts': [ opt_bool, False, '', True ],
110 'sort_by_show_in_roster': [ opt_bool, True, '', True ],
111 'sort_by_show_in_muc': [ opt_bool, False, '', True ],
112 'use_speller': [ opt_bool, False, ],
113 'ignore_incoming_xhtml': [ opt_bool, False, ],
114 'speller_language': [ opt_str, '', _('Language used by speller')],
115 '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.')],
116 '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\'.') ],
117 'emoticons_theme': [opt_str, 'static', '', True ],
118 'ascii_formatting': [ opt_bool, True,
119 _('Treat * / _ pairs as possible formatting characters.'), True],
120 'show_ascii_formatting_chars': [ opt_bool, True, _('If True, do not '
121 'remove */_ . So *abc* will be bold but with * * not removed.')],
122 'rst_formatting_outgoing_messages': [ opt_bool, False,
123 _('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)')],
124 'sounds_on': [ opt_bool, True ],
125 # 'aplay', 'play', 'esdplay', 'artsplay' detected first time only
126 'soundplayer': [ opt_str, '' ],
127 'openwith': [ opt_str, DEFAULT_OPENWITH ],
128 'custombrowser': [ opt_str, DEFAULT_BROWSER ],
129 'custommailapp': [ opt_str, DEFAULT_MAILAPP ],
130 'custom_file_manager': [ opt_str, DEFAULT_FILE_MANAGER ],
131 'gc-hpaned-position': [opt_int, 430],
132 'gc_refer_to_nick_char': [opt_str, ',', _('Character to add after nickname when using nick completion (tab) in group chat.')],
133 '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.')],
134 'msgwin-max-state': [opt_bool, False],
135 'msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
136 'msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
137 'msgwin-width': [opt_int, 500],
138 'msgwin-height': [opt_int, 440],
139 'chat-msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
140 'chat-msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
141 'chat-msgwin-width': [opt_int, 480],
142 'chat-msgwin-height': [opt_int, 440],
143 'gc-msgwin-x-position': [opt_int, -1], # Default is to let the window manager decide
144 'gc-msgwin-y-position': [opt_int, -1], # Default is to let the window manager decide
145 'gc-msgwin-width': [opt_int, 600],
146 'gc-msgwin-height': [opt_int, 440],
147 'single-msg-x-position': [opt_int, 0],
148 'single-msg-y-position': [opt_int, 0],
149 'single-msg-width': [opt_int, 400],
150 'single-msg-height': [opt_int, 280],
151 'save-roster-position': [opt_bool, True, _('If true, Gajim will save roster position when hiding roster, and restore it when showing roster.')],
152 'roster_x-position': [ opt_int, 0 ],
153 'roster_y-position': [ opt_int, 0 ],
154 'roster_width': [ opt_int, 200 ],
155 'roster_height': [ opt_int, 400 ],
156 'history_window_width': [ opt_int, 650 ],
157 'history_window_height': [ opt_int, 450 ],
158 'history_window_x-position': [ opt_int, 0 ],
159 'history_window_y-position': [ opt_int, 0 ],
160 'latest_disco_addresses': [ opt_str, '' ],
161 'recently_groupchat': [ opt_str, '' ],
162 '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') ],
163 'before_nickname': [ opt_str, '', _('Characters that are printed before the nickname in conversations') ],
164 'after_nickname': [ opt_str, ':', _('Characters that are printed after the nickname in conversations') ],
165 'notify_on_new_gmail_email': [ opt_bool, True ],
166 'notify_on_new_gmail_email_extra': [ opt_bool, False ],
167 'notify_on_new_gmail_email_command': [ opt_str, '', _('Specify the command to run when new mail arrives, e.g.: /usr/bin/getmail -q') ],
168 'use_gpg_agent': [ opt_bool, False ],
169 'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')],
170 'restore_lines': [opt_int, 4, _('How many lines to remember from previous conversation when a chat tab/window is reopened.')],
171 'restore_timeout': [opt_int, 60, _('How many minutes should last lines from previous conversation last.')],
172 'muc_restore_lines': [opt_int, 20, _('How many lines to request to server when entering a groupchat. -1 means no limit')],
173 'muc_restore_timeout': [opt_int, 60, _('How many minutes back to request logs when a entering a groupchat. -1 means no limit')],
174 '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.')],
175 'muc_autorejoin_on_kick': [opt_bool, False, _('Should autorejoin be activated when we are being kicked from a conference?')],
176 'send_on_ctrl_enter': [opt_bool, False, _('Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour).')],
177 'last_roster_visible': [opt_bool, True],
178 'key_up_lines': [opt_int, 25, _('How many lines to store for Ctrl+KeyUP.')],
179 'version': [ opt_str, defs.version ], # which version created the config
180 'search_engine': [opt_str, 'http://www.google.com/search?&q=%s&sourceid=gajim'],
181 'dictionary_url': [opt_str, 'WIKTIONARY', _("Either custom url with %s in it where %s is the word/phrase or 'WIKTIONARY' which means use wiktionary.")],
182 'always_english_wikipedia': [opt_bool, False],
183 'always_english_wiktionary': [opt_bool, True],
184 'remote_control': [opt_bool, True, _('If checked, Gajim can be controlled remotely using gajim-remote.'), True],
185 '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],
186 'outgoing_chat_state_notifications': [opt_str, 'all', _('Sent chat state notifications. Can be one of all, composing_only, disabled.')],
187 'displayed_chat_state_notifications': [opt_str, 'all', _('Displayed chat state notifications in chat windows. Can be one of all, composing_only, disabled.')],
188 'autodetect_browser_mailer': [opt_bool, False, '', True],
189 'print_ichat_every_foo_minutes': [opt_int, 5, _('When not printing time for every message (print_time==sometimes), print it every x minutes.')],
190 'confirm_close_muc': [opt_bool, True, _('Ask before closing a group chat tab/window.')],
191 'confirm_close_muc_rooms': [opt_str, '', _('Always ask before closing group chat tab/window in this space separated list of group chat jids.')],
192 'noconfirm_close_muc_rooms': [opt_str, '', _('Never ask before closing group chat tab/window in this space separated list of group chat jids.')],
193 '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)')],
194 'notify_on_file_complete': [opt_bool, True],
195 'file_transfers_port': [opt_int, 28011],
196 '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.')],
197 'conversation_font': [opt_str, ''],
198 'use_kib_mib': [opt_bool, False, _('IEC standard says KiB = 1024 bytes, KB = 1000 bytes.')],
199 'notify_on_all_muc_messages': [opt_bool, False],
200 'trayicon_notification_on_events': [opt_bool, True, _('Notify of events in the notification area.')],
201 'last_save_dir': [opt_str, ''],
202 'last_send_dir': [opt_str, ''],
203 'last_emoticons_dir': [opt_str, ''],
204 'last_sounds_dir': [opt_str, ''],
205 'tabs_position': [opt_str, 'top'],
206 'tabs_always_visible': [opt_bool, False, _('Show tab when only one conversation?')],
207 'tabs_border': [opt_bool, False, _('Show tabbed notebook border in chat windows?')],
208 'tabs_close_button': [opt_bool, True, _('Show close button in tab?')],
209 '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.')],
210 'chat_avatar_width': [opt_int, 52],
211 'chat_avatar_height': [opt_int, 52],
212 'roster_avatar_width': [opt_int, 32],
213 'roster_avatar_height': [opt_int, 32],
214 'tooltip_avatar_width': [opt_int, 125],
215 'tooltip_avatar_height': [opt_int, 125],
216 'vcard_avatar_width': [opt_int, 200],
217 'vcard_avatar_height': [opt_int, 200],
218 'notification_preview_message': [opt_bool, True, _('Preview new messages in notification popup?')],
219 'notification_position_x': [opt_int, -1],
220 'notification_position_y': [opt_int, -1],
221 'notification_avatar_width': [opt_int, 48],
222 'notification_avatar_height': [opt_int, 48],
223 'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in group chats.')],
224 '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 notification icon is used.')],
225 'check_if_gajim_is_default': [opt_bool, True, _('If True, Gajim will check if it\'s the default jabber client on each startup.')],
226 '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.')],
227 '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],
228 'show_avatars_in_roster': [opt_bool, True, '', True],
229 'show_mood_in_roster': [opt_bool, True, '', True],
230 'show_activity_in_roster': [opt_bool, True, '', True],
231 'show_tunes_in_roster': [opt_bool, True, '', True],
232 'show_location_in_roster': [opt_bool, True, '', True],
233 'avatar_position_in_roster': [opt_str, 'right', _('Define the position of the avatar in roster. Can be left or right'), True],
234 '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.')],
235 '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.')],
236 '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.')],
237 'log_contact_status_changes': [opt_bool, False],
238 'log_xhtml_messages': [opt_bool, False, _('Log XHTML messages instead of plain text messages.')],
239 'just_connected_bg_color': [opt_str, '#adc3c6', _('Background color of contacts when they just signed in.')],
240 'just_disconnected_bg_color': [opt_str, '#ab6161', _('Background color of contacts when they just signed out.')],
241 'restored_messages_color': [opt_color, '#555753'],
242 'restored_messages_small': [opt_bool, True, _('If True, restored messages will use a smaller font than the default one.')],
243 'hide_avatar_of_transport': [opt_bool, False, _('Don\'t show avatar for the transport itself.')],
244 'roster_window_skip_taskbar': [opt_bool, False, _('Don\'t show roster in the system taskbar.')],
245 '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.')],
246 'notification_timeout': [opt_int, 5],
247 '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.')],
248 'one_message_window': [opt_str, 'always',
249 #always, never, peracct, pertype should not be translated
250 _('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.')],
251 'show_roster_on_startup':[opt_str, 'always', _('Show roster on startup.\n\'always\' - Always show roster.\n\'never\' - Never show roster.\n\'last_state\' - Restore the last state roster.')],
252 'show_avatar_in_chat': [opt_bool, True, _('If False, you will no longer see the avatar in the chat window.')],
253 'escape_key_closes': [opt_bool, True, _('If True, pressing the escape key closes a tab/window.')],
254 'compact_view': [opt_bool, False, _('Hides the buttons in chat windows.')],
255 'hide_groupchat_banner': [opt_bool, False, _('Hides the banner in a group chat window')],
256 'hide_chat_banner': [opt_bool, False, _('Hides the banner in two persons chat window')],
257 'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the group chat occupants list in group chat window.')],
258 '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.')],
259 'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nickname.')],
260 'use_smooth_scrolling': [opt_bool, True, _('Smooth scroll message in conversation window')],
261 '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 ],
262 'ctrl_tab_go_to_next_composing': [opt_bool, True, _('Ctrl-Tab go to next composing tab when none is unread.')],
263 'confirm_metacontacts': [ opt_str, '', _('Should we show the confirm metacontacts creation dialog or not? Empty string means we never show the dialog.')],
264 'confirm_block': [ opt_str, '', _('Should we show the confirm block contact dialog or not? Empty string means we never show the dialog.')],
265 'confirm_custom_status': [ opt_str, '', _('Should we show the confirm custom status dialog or not? Empty string means we never show the dialog.')],
266 '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.')],
267 'use_gnomekeyring': [opt_bool, True, _('If True, Gajim will use Gnome Keyring (if available) to store account passwords.')],
268 'use_kwalletcli': [opt_bool, True, _('If True, Gajim will use KDE Wallet (if kwalletcli is available) to store account passwords.')],
269 'show_contacts_number': [opt_bool, True, _('If True, Gajim will show number of online and total contacts in account and group rows.')],
270 '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')],
271 '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.')],
272 '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.')],
273 'change_status_window_timeout': [opt_int, 15, _('Time of inactivity needed before the change status window closes down.')],
274 'max_conversation_lines': [opt_int, 500, _('Maximum number of lines that are printed in conversations. Oldest lines are cleared.')],
275 'attach_notifications_to_systray': [opt_bool, False, _('If True, notification windows from notification-daemon will be attached to notification icon.')],
276 'check_idle_every_foo_seconds': [opt_int, 2, _('Choose interval between 2 checks of idleness.')],
277 'latex_png_dpi': [opt_str, '108', _('Change the value to change the size of latex formulas displayed. The higher is larger.') ],
278 'uri_schemes': [opt_str, 'aaa:// aaas:// acap:// cap:// cid: crid:// data: dav: dict:// dns: fax: file:/ ftp:// geo: go: gopher:// h323: http:// https:// iax: 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: prospero:// rtsp:// service: shttp:// sip: sips: sms: snmp:// soap.beep:// soap.beeps:// tag: tel: telnet:// tftp:// thismessage:/ tip:// tv: urn:// vemmi:// xmlrpc.beep:// xmlrpc.beeps:// z39.50r:// z39.50s:// about: apt: 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],
279 '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!') ],
280 'shell_like_completion': [ opt_bool, False, _('If True, completion in groupchats will be like a shell auto-completion')],
281 'show_self_contact': [opt_str, 'when_other_resource', _('When is self contact row displayed. Can be "always", "when_other_resource" or "never"'), True],
282 'audio_input_device': [opt_str, 'autoaudiosrc ! volume name=gajim_vol'],
283 'audio_output_device': [opt_str, 'autoaudiosink'],
284 'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'],
285 'video_output_device': [opt_str, 'autovideosink'],
286 'video_framerate': [opt_str, '', _('Optionally fix jingle output video framerate. Example: 10/1 or 25/2')],
287 'video_size': [opt_str, '', _('Optionally resize jingle output video. Example: 320x240')],
288 'audio_input_volume': [opt_int, 50],
289 'audio_output_volume': [opt_int, 50],
290 '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.')],
291 'stun_server': [opt_str, '', _('STUN server to use when using jingle')],
292 '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')],
295 __options_per_key = {
296 'accounts': ({
297 'name': [ opt_str, '', '', True ],
298 'hostname': [ opt_str, '', '', True ],
299 'anonymous_auth': [ opt_bool, False ],
300 'client_cert': [ opt_str, '', '', True ],
301 'client_cert_encrypted': [ opt_bool, False, '', False ],
302 'savepass': [ opt_bool, False ],
303 'password': [ opt_str, '' ],
304 'resource': [ opt_str, 'gajim', '', True ],
305 'priority': [ opt_int, 5, '', True ],
306 'adjust_priority_with_status': [ opt_bool, True, _('Priority will change automatically according to your status. Priorities are defined in autopriority_* options.') ],
307 'autopriority_online': [ opt_int, 50],
308 'autopriority_chat': [ opt_int, 50],
309 'autopriority_away': [ opt_int, 40],
310 'autopriority_xa': [ opt_int, 30],
311 'autopriority_dnd': [ opt_int, 20],
312 'autopriority_invisible': [ opt_int, 10],
313 'autoconnect': [ opt_bool, False, '', True ],
314 '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 ],
315 'restore_last_status': [ opt_bool, False, _('If enabled, restore the last status that was used.') ],
316 'autoreconnect': [ opt_bool, True ],
317 'autoauth': [ opt_bool, False, _('If True, Contacts requesting authorization will be automatically accepted.')],
318 'active': [ opt_bool, True, _('If False, this account will be disabled and will not appear in roster window.'), True],
319 'proxy': [ opt_str, '', '', True ],
320 'keyid': [ opt_str, '', '', True ],
321 'gpg_sign_presence': [ opt_bool, True, _('If disabled, don\'t sign presences with GPG key, even if GPG is configured.') ],
322 'keyname': [ opt_str, '', '', True ],
323 'enable_esessions': [opt_bool, True, _('Enable ESessions encryption for this account.')],
324 'autonegotiate_esessions': [opt_bool, True, _('Should Gajim automatically start an encrypted session when possible?')],
325 'connection_types': [ opt_str, 'tls ssl plain', _('Ordered list (space separated) of connection type to try. Can contain tls, ssl or plain')],
326 'warn_when_plaintext_connection': [ opt_bool, True, _('Show a warning dialog before sending password on an plaintext connection.') ],
327 'warn_when_insecure_ssl_connection': [ opt_bool, True, _('Show a warning dialog before using standard SSL library.') ],
328 'warn_when_insecure_password': [ opt_bool, True, _('Show a warning dialog before sending PLAIN password over a plain connection.') ],
329 'ssl_fingerprint_sha1': [ opt_str, '', '', True ],
330 'ignore_ssl_errors': [ opt_str, '', _('Space separated list of ssl errors to ignore.') ],
331 'use_srv': [ opt_bool, True, '', True ],
332 'use_custom_host': [ opt_bool, False, '', True ],
333 'custom_port': [ opt_int, 5222, '', True ],
334 'custom_host': [ opt_str, '', '', True ],
335 'sync_with_global_status': [ opt_bool, False, ],
336 'no_log_for': [ opt_str, '' ],
337 'minimized_gc': [ opt_str, '' ],
338 'attached_gpg_keys': [ opt_str, '' ],
339 'keep_alives_enabled': [ opt_bool, True, _('Whitespace sent after inactivity')],
340 'ping_alives_enabled': [ opt_bool, True, _('XMPP ping sent after inactivity')],
341 # send keepalive every N seconds of inactivity
342 'keep_alive_every_foo_secs': [ opt_int, 55 ],
343 'ping_alive_every_foo_secs': [ opt_int, 120 ],
344 '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.') ],
345 # try for 1 minutes before giving up (aka. timeout after those seconds)
346 'try_connecting_for_foo_secs': [ opt_int, 60 ],
347 'http_auth': [opt_str, 'ask'], # yes, no, ask
348 'dont_ack_subscription': [opt_bool, False, _('Jabberd2 workaround')],
349 # proxy65 for FT
350 'file_transfer_proxies': [opt_str, 'proxy.eu.jabber.org, proxy.jabber.ru, proxy.jabbim.cz'],
351 '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],
352 'msgwin-x-position': [opt_int, -1], # Default is to let the wm decide
353 'msgwin-y-position': [opt_int, -1], # Default is to let the wm decide
354 'msgwin-width': [opt_int, 480],
355 'msgwin-height': [opt_int, 440],
356 'listen_to_network_manager': [opt_bool, True],
357 'is_zeroconf': [opt_bool, False],
358 'last_status': [opt_str, 'online'],
359 'last_status_msg': [opt_str, ''],
360 'zeroconf_first_name': [ opt_str, '', '', True ],
361 'zeroconf_last_name': [ opt_str, '', '', True ],
362 'zeroconf_jabber_id': [ opt_str, '', '', True ],
363 'zeroconf_email': [ opt_str, '', '', True ],
364 'use_env_http_proxy': [opt_bool, False],
365 'answer_receipts': [opt_bool, True, _('Answer to receipt requests')],
366 'request_receipt': [opt_bool, True, _('Sent receipt requests')],
367 'publish_tune': [opt_bool, False],
368 'publish_location': [opt_bool, False],
369 'subscribe_mood': [opt_bool, True],
370 'subscribe_activity': [opt_bool, True],
371 'subscribe_tune': [opt_bool, True],
372 'subscribe_nick': [opt_bool, True],
373 'subscribe_location': [opt_bool, True],
374 'ignore_unknown_contacts': [ opt_bool, False ],
375 'send_os_info': [ opt_bool, True, _("Allow Gajim to send information about the operating system you are running.") ],
376 'send_time_info': [ opt_bool, True, _("Allow Gajim to send your local time.") ],
377 'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
378 'send_idle_time': [ opt_bool, True ],
379 'roster_version': [opt_str, ''],
380 'subscription_request_msg': [opt_str, '', _('Message that is sent to contacts you want to add')],
381 'last_archiving_time': [opt_str, '1970-01-01T00:00:00Z', _('Last time we syncronized with logs from server.')],
382 }, {}),
383 'statusmsg': ({
384 'message': [ opt_str, '' ],
385 'activity': [ opt_str, '' ],
386 'subactivity': [ opt_str, '' ],
387 'activity_text': [ opt_str, '' ],
388 'mood': [ opt_str, '' ],
389 'mood_text': [ opt_str, '' ],
390 }, {}),
391 'defaultstatusmsg': ({
392 'enabled': [ opt_bool, False ],
393 'message': [ opt_str, '' ],
394 }, {}),
395 'soundevents': ({
396 'enabled': [ opt_bool, True ],
397 'path': [ opt_str, '' ],
398 }, {}),
399 'proxies': ({
400 'type': [ opt_str, 'http' ],
401 'host': [ opt_str, '' ],
402 'port': [ opt_int, 3128 ],
403 'useauth': [ opt_bool, False ],
404 'user': [ opt_str, '' ],
405 'pass': [ opt_str, '' ],
406 'bosh_uri': [ opt_str, '' ],
407 'bosh_useproxy': [ opt_bool, False ],
408 'bosh_wait': [ opt_int, 30 ],
409 'bosh_hold': [ opt_int, 2 ],
410 'bosh_content': [ opt_str, 'text/xml; charset=utf-8' ],
411 'bosh_http_pipelining': [ opt_bool, False ],
412 'bosh_wait_for_restart_response': [ opt_bool, False ],
413 }, {}),
414 'themes': ({
415 'accounttextcolor': [ opt_color, 'black', '', True ],
416 'accountbgcolor': [ opt_color, 'white', '', True ],
417 'accountfont': [ opt_str, '', '', True ],
418 'accountfontattrs': [ opt_str, 'B', '', True ],
419 'grouptextcolor': [ opt_color, 'black', '', True ],
420 'groupbgcolor': [ opt_color, 'white', '', True ],
421 'groupfont': [ opt_str, '', '', True ],
422 'groupfontattrs': [ opt_str, 'I', '', True ],
423 'contacttextcolor': [ opt_color, 'black', '', True ],
424 'contactbgcolor': [ opt_color, 'white', '', True ],
425 'contactfont': [ opt_str, '', '', True ],
426 'contactfontattrs': [ opt_str, '', '', True ],
427 'bannertextcolor': [ opt_color, 'black', '', True ],
428 'bannerbgcolor': [ opt_color, '', '', True ],
429 'bannerfont': [ opt_str, '', '', True ],
430 'bannerfontattrs': [ opt_str, 'B', '', True ],
432 # http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html
433 'state_inactive_color': [ opt_color, 'grey62' ],
434 'state_composing_color': [ opt_color, 'green4' ],
435 'state_paused_color': [ opt_color, 'mediumblue' ],
436 'state_gone_color': [ opt_color, 'grey' ],
438 # MUC chat states
439 'state_muc_msg_color': [ opt_color, 'mediumblue' ],
440 'state_muc_directed_msg_color': [ opt_color, 'red2' ],
441 }, {}),
442 'contacts': ({
443 'gpg_enabled': [ opt_bool, False, _('Is OpenPGP enabled for this contact?')],
444 'autonegotiate_esessions': [opt_bool, True, _('Should Gajim automatically start an encrypted session with this contact when possible?')],
445 'speller_language': [ opt_str, '', _('Language for which we want to check misspelled words')],
446 }, {}),
447 'rooms': ({
448 'speller_language': [ opt_str, '', _('Language for which we want to check misspelled words')],
449 }, {}),
450 'plugins': ({
451 '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.')],
452 },{}),
455 statusmsg_default = {
456 _('Sleeping'): [ 'ZZZZzzzzzZZZZZ', 'inactive', 'sleeping', '', 'sleepy', '' ],
457 _('Back soon'): [ _('Back in some minutes.'), '', '', '', '', '' ],
458 _('Eating'): [ _("I'm eating, so leave me a message."), 'eating', 'other', '', '', '' ],
459 _('Movie'): [ _("I'm watching a movie."), 'relaxing', 'watching_a_movie', '', '', '' ],
460 _('Working'): [ _("I'm working."), 'working', 'other', '', '', '' ],
461 _('Phone'): [ _("I'm on the phone."), 'talking', 'on_the_phone', '', '', '' ],
462 _('Out'): [ _("I'm out enjoying life."), 'relaxing', 'going_out', '', '', '' ],
463 '_last_online': ['', '', '', '', '', ''],
464 '_last_chat': ['', '', '', '', '', ''],
465 '_last_away': ['', '', '', '', '', ''],
466 '_last_xa': ['', '', '', '', '', ''],
467 '_last_dnd': ['', '', '', '', '', ''],
468 '_last_invisible': ['', '', '', '', '', ''],
469 '_last_offline': ['', '', '', '', '', ''],
472 defaultstatusmsg_default = {
473 'online': [ False, _("I'm available.") ],
474 'chat': [ False, _("I'm free for chat.") ],
475 'away': [ False, _('Be right back.') ],
476 'xa': [ False, _("I'm not available.") ],
477 'dnd': [ False, _('Do not disturb.') ],
478 'invisible': [ False, _('Bye!') ],
479 'offline': [ False, _('Bye!') ],
482 soundevents_default = {
483 'first_message_received': [ True, 'message1.wav' ],
484 'next_message_received_focused': [ True, 'message2.wav' ],
485 'next_message_received_unfocused': [ True, 'message2.wav' ],
486 'contact_connected': [ True, 'connected.wav' ],
487 'contact_disconnected': [ True, 'disconnected.wav' ],
488 'message_sent': [ True, 'sent.wav' ],
489 '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.')],
490 'muc_message_received': [ False, 'gc_message2.wav', _('Sound to play when any MUC message arrives.') ],
491 'gmail_received': [ False, 'message1.wav' ],
494 themes_default = {
495 # sorted alphanum
496 _('default'): [ '', '', '', 'B', '', '', '', 'I', '', '', '', '', '', '',
497 '', 'B' ],
499 _('green'): [ '', '#94aa8c', '', 'B', '#0000ff', '#eff3e7',
500 '', 'I', '#000000', '', '', '', '',
501 '#94aa8c', '', 'B' ],
503 _('grocery'): [ '', '#6bbe18', '', 'B', '#12125a', '#ceefad',
504 '', 'I', '#000000', '#efb26b', '', '', '',
505 '#108abd', '', 'B' ],
507 _('human'): [ '', '#996442', '', 'B', '#ab5920', '#e3ca94',
508 '', 'I', '#000000', '', '', '', '',
509 '#996442', '', 'B' ],
511 _('marine'): [ '', '#918caa', '', 'B', '', '#e9e7f3',
512 '', 'I', '#000000', '', '', '', '',
513 '#918caa', '', 'B' ],
517 def foreach(self, cb, data = None):
518 for opt in self.__options:
519 cb(data, opt, None, self.__options[opt])
520 for opt in self.__options_per_key:
521 cb(data, opt, None, None)
522 dict_ = self.__options_per_key[opt][1]
523 for opt2 in dict_.keys():
524 cb(data, opt2, [opt], None)
525 for opt3 in dict_[opt2]:
526 cb(data, opt3, [opt, opt2], dict_[opt2][opt3])
528 def get_children(self, node=None):
530 Tree-like interface
532 if node is None:
533 for child, option in self.__options.iteritems():
534 yield (child, ), option
535 for grandparent in self.__options_per_key:
536 yield (grandparent, ), None
537 elif len(node) == 1:
538 grandparent, = node
539 for parent in self.__options_per_key[grandparent][1]:
540 yield (grandparent, parent), None
541 elif len(node) == 2:
542 grandparent, parent = node
543 children = self.__options_per_key[grandparent][1][parent]
544 for child, option in children.iteritems():
545 yield (grandparent, parent, child), option
546 else:
547 raise ValueError('Invalid node')
549 def is_valid_int(self, val):
550 try:
551 ival = int(val)
552 except Exception:
553 return None
554 return ival
556 def is_valid_bool(self, val):
557 if val == 'True':
558 return True
559 elif val == 'False':
560 return False
561 else:
562 ival = self.is_valid_int(val)
563 if ival:
564 return True
565 elif ival is None:
566 return None
567 return False
568 return None
570 def is_valid_string(self, val):
571 return val
573 def is_valid(self, type_, val):
574 if not type_:
575 return None
576 if type_[0] == 'boolean':
577 return self.is_valid_bool(val)
578 elif type_[0] == 'integer':
579 return self.is_valid_int(val)
580 elif type_[0] == 'string':
581 return self.is_valid_string(val)
582 else:
583 if re.match(type_[1], val):
584 return val
585 else:
586 return None
588 def set(self, optname, value):
589 if optname not in self.__options:
590 # raise RuntimeError, 'option %s does not exist' % optname
591 return
592 opt = self.__options[optname]
593 value = self.is_valid(opt[OPT_TYPE], value)
594 if value is None:
595 # raise RuntimeError, 'value of %s cannot be None' % optname
596 return
598 opt[OPT_VAL] = value
600 def get(self, optname = None):
601 if not optname:
602 return self.__options.keys()
603 if optname not in self.__options:
604 return None
605 return self.__options[optname][OPT_VAL]
607 def get_desc(self, optname):
608 if optname not in self.__options:
609 return None
610 if len(self.__options[optname]) > OPT_DESC:
611 return self.__options[optname][OPT_DESC]
613 def get_restart(self, optname):
614 if optname not in self.__options:
615 return None
616 if len(self.__options[optname]) > OPT_RESTART:
617 return self.__options[optname][OPT_RESTART]
619 def add_per(self, typename, name): # per_group_of_option
620 if typename not in self.__options_per_key:
621 # raise RuntimeError, 'option %s does not exist' % typename
622 return
624 opt = self.__options_per_key[typename]
625 if name in opt[1]:
626 # we already have added group name before
627 return 'you already have added %s before' % name
628 opt[1][name] = copy.deepcopy(opt[0])
630 def del_per(self, typename, name, subname = None): # per_group_of_option
631 if typename not in self.__options_per_key:
632 # raise RuntimeError, 'option %s does not exist' % typename
633 return
635 opt = self.__options_per_key[typename]
636 if subname is None:
637 del opt[1][name]
638 # if subname is specified, delete the item in the group.
639 elif subname in opt[1][name]:
640 del opt[1][name][subname]
642 def set_per(self, optname, key, subname, value): # per_group_of_option
643 if optname not in self.__options_per_key:
644 # raise RuntimeError, 'option %s does not exist' % optname
645 return
646 if not key:
647 return
648 dict_ = self.__options_per_key[optname][1]
649 if key not in dict_:
650 # raise RuntimeError, '%s is not a key of %s' % (key, dict_)
651 self.add_per(optname, key)
652 obj = dict_[key]
653 if subname not in obj:
654 # raise RuntimeError, '%s is not a key of %s' % (subname, obj)
655 return
656 subobj = obj[subname]
657 value = self.is_valid(subobj[OPT_TYPE], value)
658 if value is None:
659 # raise RuntimeError, '%s of %s cannot be None' % optname
660 return
661 subobj[OPT_VAL] = value
663 def get_per(self, optname, key = None, subname = None): # per_group_of_option
664 if optname not in self.__options_per_key:
665 return None
666 dict_ = self.__options_per_key[optname][1]
667 if not key:
668 return dict_.keys()
669 if key not in dict_:
670 if optname in self.__options_per_key \
671 and subname in self.__options_per_key[optname][0]:
672 return self.__options_per_key \
673 [optname][0][subname][1]
674 return None
675 obj = dict_[key]
676 if not subname:
677 return obj
678 if subname not in obj:
679 return None
680 return obj[subname][OPT_VAL]
682 def get_desc_per(self, optname, key = None, subname = None):
683 if optname not in self.__options_per_key:
684 return None
685 dict_ = self.__options_per_key[optname][1]
686 if not key:
687 return None
688 if key not in dict_:
689 return None
690 obj = dict_[key]
691 if not subname:
692 return None
693 if subname not in obj:
694 return None
695 if len(obj[subname]) > OPT_DESC:
696 return obj[subname][OPT_DESC]
697 return None
699 def get_restart_per(self, optname, key = None, subname = None):
700 if optname not in self.__options_per_key:
701 return False
702 dict_ = self.__options_per_key[optname][1]
703 if not key:
704 return False
705 if key not in dict_:
706 return False
707 obj = dict_[key]
708 if not subname:
709 return False
710 if subname not in obj:
711 return False
712 if len(obj[subname]) > OPT_RESTART:
713 return obj[subname][OPT_RESTART]
714 return False
716 def should_log(self, account, jid):
718 Should conversations between a local account and a remote jid be logged?
720 no_log_for = self.get_per('accounts', account, 'no_log_for')
722 if not no_log_for:
723 no_log_for = ''
725 no_log_for = no_log_for.split()
727 return (account not in no_log_for) and (jid not in no_log_for)
729 def __init__(self):
730 #init default values
731 for event in self.soundevents_default:
732 default = self.soundevents_default[event]
733 self.add_per('soundevents', event)
734 self.set_per('soundevents', event, 'enabled', default[0])
735 self.set_per('soundevents', event, 'path', default[1])
737 for status in self.defaultstatusmsg_default:
738 default = self.defaultstatusmsg_default[status]
739 self.add_per('defaultstatusmsg', status)
740 self.set_per('defaultstatusmsg', status, 'enabled', default[0])
741 self.set_per('defaultstatusmsg', status, 'message', default[1])