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