2005-04-14 09:28:59 +02:00
## common/config.py
##
2006-02-24 22:53:05 +01:00
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
## Copyright (C) 2003-2006 Nikos Kouremenos <nkour@jabber.org>
## Copyright (C) 2004-2005 Vincent Hanquez <tab@snarc.org>
## Copyright (C) 2005 Dimitur Kirov <dkirov@gmail.com>
## Copyright (C) 2005 Travis Shirk <travis@pobox.com>
## Copyright (C) 2005 Norman Rasmussen <norman@rasmussen.co.za>
2005-04-14 09:28:59 +02:00
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
2005-04-18 16:05:30 +02:00
import sre
2005-04-14 09:28:59 +02:00
import copy
2005-12-05 12:13:08 +01:00
import i18n
2005-05-21 18:01:52 +02:00
_ = i18n . _
2005-04-14 09:28:59 +02:00
OPT_TYPE = 0
OPT_VAL = 1
2005-09-03 14:28:30 +02:00
OPT_DESC = 2
2005-04-14 09:28:59 +02:00
opt_int = [ ' integer ' , 0 ]
opt_str = [ ' string ' , 0 ]
opt_bool = [ ' boolean ' , 0 ]
2005-09-16 23:32:57 +02:00
opt_color = [ ' color ' , ' ^(#[0-9a-fA-F] {6} )|()$ ' ]
2005-12-29 02:31:47 +01:00
opt_one_window_types = [ ' never ' , ' always ' , ' peracct ' , ' pertype ' ]
2005-04-14 09:28:59 +02:00
class Config :
__options = {
2006-02-08 03:26:54 +01:00
# name: [ type, default_value, help_string ]
2005-05-28 20:20:27 +02:00
' verbose ' : [ opt_bool , False ] ,
2005-04-16 16:50:26 +02:00
' alwaysauth ' : [ opt_bool , False ] ,
' autopopup ' : [ opt_bool , False ] ,
2005-05-21 15:53:09 +02:00
' notify_on_signin ' : [ opt_bool , True ] ,
' notify_on_signout ' : [ opt_bool , False ] ,
2005-07-21 23:03:36 +02:00
' notify_on_new_message ' : [ opt_bool , True ] ,
2005-04-16 16:50:26 +02:00
' autopopupaway ' : [ opt_bool , False ] ,
2005-11-21 11:36:56 +01:00
' use_notif_daemon ' : [ opt_bool , True , _ ( ' Use DBus and Notification-Daemon to show notifications ' ) ] ,
2005-04-16 16:50:26 +02:00
' ignore_unknown_contacts ' : [ opt_bool , False ] ,
' showoffline ' : [ opt_bool , False ] ,
' autoaway ' : [ opt_bool , True ] ,
2005-09-04 20:56:06 +02:00
' autoawaytime ' : [ opt_int , 5 , _ ( ' Time in minutes, after which your status changes to away. ' ) ] ,
2005-08-07 11:14:50 +02:00
' autoaway_message ' : [ opt_str , _ ( ' Away as a result of being idle ' ) ] ,
2005-04-16 16:50:26 +02:00
' autoxa ' : [ opt_bool , True ] ,
2005-09-04 20:56:06 +02:00
' autoxatime ' : [ opt_int , 15 , _ ( ' Time in minutes, after which your status changes to not available. ' ) ] ,
2005-08-07 11:14:50 +02:00
' autoxa_message ' : [ opt_str , _ ( ' Not available as a result of being idle ' ) ] ,
2005-04-16 16:50:26 +02:00
' ask_online_status ' : [ opt_bool , False ] ,
' ask_offline_status ' : [ opt_bool , False ] ,
2005-06-30 21:23:41 +02:00
' last_status_msg_online ' : [ opt_str , ' ' ] ,
' last_status_msg_chat ' : [ opt_str , ' ' ] ,
' last_status_msg_away ' : [ opt_str , ' ' ] ,
' last_status_msg_xa ' : [ opt_str , ' ' ] ,
' last_status_msg_dnd ' : [ opt_str , ' ' ] ,
' last_status_msg_invisible ' : [ opt_str , ' ' ] ,
' last_status_msg_offline ' : [ opt_str , ' ' ] ,
2005-04-16 16:50:26 +02:00
' trayicon ' : [ opt_bool , True ] ,
2005-12-12 16:12:15 +01:00
' iconset ' : [ opt_str , ' dcraven ' ] ,
2005-05-25 19:13:50 +02:00
' use_transports_iconsets ' : [ opt_bool , True ] ,
2005-06-11 16:37:59 +02:00
' inmsgcolor ' : [ opt_color , ' #a34526 ' ] ,
' outmsgcolor ' : [ opt_color , ' #164e6f ' ] ,
2005-04-14 09:28:59 +02:00
' statusmsgcolor ' : [ opt_color , ' #1eaa1e ' ] ,
2005-06-16 21:14:07 +02:00
' markedmsgcolor ' : [ opt_color , ' #ff8080 ' ] ,
2005-12-26 00:48:08 +01:00
' urlmsgcolor ' : [ opt_color , ' #0000ff ' ] ,
2005-05-18 18:30:59 +02:00
' collapsed_rows ' : [ opt_str , ' ' ] ,
2005-10-29 18:56:33 +02:00
' roster_theme ' : [ opt_str , ' green ' ] ,
2005-04-16 16:50:26 +02:00
' saveposition ' : [ opt_bool , True ] ,
' mergeaccounts ' : [ opt_bool , False ] ,
2005-05-29 20:41:13 +02:00
' sort_by_show ' : [ opt_bool , True ] ,
2005-05-26 02:07:49 +02:00
' use_speller ' : [ opt_bool , False ] ,
2005-04-14 09:28:59 +02:00
' print_time ' : [ opt_str , ' always ' ] ,
2005-04-16 16:50:26 +02:00
' useemoticons ' : [ opt_bool , True ] ,
2006-03-02 17:05:52 +01:00
' ascii_formatting ' : [ opt_bool , True ,
_ ( ' Treat * / _ pairs as possible formatting characters. ' ) ] ,
' show_ascii_formatting_chars ' : [ opt_bool , False , _ ( ' If True, do not '
' remove */_ . So *abc* will be bold but with * * not removed. ' ) ] ,
2005-04-16 16:50:26 +02:00
' sounds_on ' : [ opt_bool , True ] ,
2005-08-09 13:34:36 +02:00
# 'aplay', 'play', 'esdplay', 'artsplay' detected first time only
' soundplayer ' : [ opt_str , ' ' ] ,
2005-04-14 09:28:59 +02:00
' openwith ' : [ opt_str , ' gnome-open ' ] ,
' custombrowser ' : [ opt_str , ' firefox ' ] ,
' custommailapp ' : [ opt_str , ' mozilla-thunderbird -compose ' ] ,
2005-08-09 17:30:45 +02:00
' custom_file_manager ' : [ opt_str , ' xffm ' ] ,
2005-07-21 16:55:54 +02:00
' gc-hpaned-position ' : [ opt_int , 540 ] ,
2005-06-17 00:18:46 +02:00
' gc_refer_to_nick_char ' : [ opt_str , ' , ' ] ,
2005-11-18 18:47:52 +01:00
' gc_proposed_nick_char ' : [ opt_str , ' _ ' ] ,
2006-01-08 05:31:02 +01:00
' msgwin-x-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
' msgwin-y-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
2006-01-25 14:34:02 +01:00
' msgwin-width ' : [ opt_int , 480 ] ,
' msgwin-height ' : [ opt_int , 440 ] ,
2006-01-12 06:45:30 +01:00
' chat-msgwin-x-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
' chat-msgwin-y-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
2006-01-25 14:34:02 +01:00
' chat-msgwin-width ' : [ opt_int , 480 ] ,
' chat-msgwin-height ' : [ opt_int , 440 ] ,
2006-01-12 06:45:30 +01:00
' gc-msgwin-x-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
' gc-msgwin-y-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
2006-01-25 14:34:02 +01:00
' gc-msgwin-width ' : [ opt_int , 480 ] ,
' gc-msgwin-height ' : [ opt_int , 440 ] ,
2006-01-12 06:45:30 +01:00
' single-msg-x-position ' : [ opt_int , 0 ] ,
' single-msg-y-position ' : [ opt_int , 0 ] ,
' single-msg-width ' : [ opt_int , 400 ] ,
' single-msg-height ' : [ opt_int , 280 ] ,
2005-07-21 23:19:08 +02:00
' roster_x-position ' : [ opt_int , 0 ] ,
' roster_y-position ' : [ opt_int , 0 ] ,
' roster_width ' : [ opt_int , 150 ] ,
' roster_height ' : [ opt_int , 400 ] ,
2005-04-14 09:28:59 +02:00
' latest_disco_addresses ' : [ opt_str , ' ' ] ,
' recently_groupchat ' : [ opt_str , ' ' ] ,
' before_time ' : [ opt_str , ' [ ' ] ,
' after_time ' : [ opt_str , ' ] ' ] ,
2005-07-24 22:34:39 +02:00
' before_nickname ' : [ opt_str , ' ' ] ,
' after_nickname ' : [ opt_str , ' : ' ] ,
2005-04-24 14:18:49 +02:00
' send_os_info ' : [ opt_bool , True ] ,
Merged revisions 5017-5020,5022-5029 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r5017 | asterix | 2006-01-06 01:55:51 -0700 (Fri, 06 Jan 2006) | 2 lines
use escape for pango markup
........
r5018 | asterix | 2006-01-06 02:21:39 -0700 (Fri, 06 Jan 2006) | 2 lines
missing new contacts function
........
r5019 | asterix | 2006-01-06 11:03:07 -0700 (Fri, 06 Jan 2006) | 2 lines
handle the click on toggle_gpg_encryption menuitem
........
r5020 | asterix | 2006-01-06 11:14:14 -0700 (Fri, 06 Jan 2006) | 2 lines
use the saved size even if a chat window is already opened
........
r5022 | asterix | 2006-01-07 03:43:47 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now resume filetransfert
........
r5023 | asterix | 2006-01-07 03:56:31 -0700 (Sat, 07 Jan 2006) | 2 lines
[Knuckles] Google E-Mail Notification
........
r5024 | asterix | 2006-01-07 04:02:16 -0700 (Sat, 07 Jan 2006) | 2 lines
better string
........
r5025 | asterix | 2006-01-07 04:14:32 -0700 (Sat, 07 Jan 2006) | 2 lines
fix a TB
........
r5026 | asterix | 2006-01-07 05:36:55 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now drag a file on a contact in the roster to send him a file
........
r5027 | asterix | 2006-01-07 06:26:28 -0700 (Sat, 07 Jan 2006) | 2 lines
contact.groups is always a list, even if emtpy
........
r5028 | asterix | 2006-01-07 06:54:30 -0700 (Sat, 07 Jan 2006) | 2 lines
make all buttons insensitive on a category row in disco
........
r5029 | asterix | 2006-01-07 07:19:25 -0700 (Sat, 07 Jan 2006) | 2 lines
auto open groupchat configuration window when we create a new room
........
2006-01-07 18:25:35 +01:00
' notify_on_new_gmail_email ' : [ opt_bool , True ] ,
2005-04-16 16:50:26 +02:00
' usegpg ' : [ opt_bool , False ] ,
2005-08-30 23:10:14 +02:00
' use_gpg_agent ' : [ opt_bool , False ] ,
2005-09-04 20:51:16 +02:00
' change_roster_title ' : [ opt_bool , True , _ ( ' Add * and [n] in roster title? ' ) ] ,
' restore_lines ' : [ opt_int , 4 , _ ( ' How many lines to remember from previous conversation when a chat tab/window is reopened. ' ) ] ,
' restore_timeout ' : [ opt_int , 60 , _ ( ' How many minutes should last lines from previous conversation last. ' ) ] ,
2005-09-17 13:34:39 +02:00
' send_on_ctrl_enter ' : [ opt_bool , False , _ ( ' Send message on Ctrl+Enter and with Enter make new line (Mirabilis ICQ Client default behaviour). ' ) ] ,
2005-06-06 01:20:06 +02:00
' show_roster_on_startup ' : [ opt_bool , True ] ,
2005-11-21 17:50:28 +01:00
' key_up_lines ' : [ opt_int , 25 , _ ( ' How many lines to store for Ctrl+KeyUP. ' ) ] ,
2005-09-04 20:51:16 +02:00
' version ' : [ opt_str , ' 0.9 ' ] , # which version created the config
2005-09-20 20:36:28 +02:00
' always_compact_view_chat ' : [ opt_bool , False , _ ( ' Use compact view when you open a chat window ' ) ] ,
' always_compact_view_gc ' : [ opt_bool , False , _ ( ' Use compact view when you open a group chat window ' ) ] ,
2005-08-05 17:42:55 +02:00
' search_engine ' : [ opt_str , ' http://www.google.com/search?&q= %s &sourceid=gajim ' ] ,
2005-09-03 15:48:25 +02:00
' dictionary_url ' : [ opt_str , ' WIKTIONARY ' , _ ( " Either custom url with %s in it where %s is the word/phrase or ' WIKTIONARY ' which means use wiktionary. " ) ] ,
2005-07-17 22:26:43 +02:00
' always_english_wikipedia ' : [ opt_bool , False ] ,
2005-11-10 00:05:11 +01:00
' always_english_wiktionary ' : [ opt_bool , True ] ,
2005-11-19 22:45:34 +01:00
' remote_control ' : [ opt_bool , True , _ ( ' If checked, Gajim can be controlled remotely using gajim-remote. ' ) ] ,
2005-08-08 20:06:58 +02:00
' chat_state_notifications ' : [ opt_str , ' all ' ] , # 'all', 'composing_only', 'disabled'
2006-01-20 14:54:02 +01:00
' autodetect_browser_mailer ' : [ opt_bool , False ] ,
2005-08-05 01:11:55 +02:00
' print_ichat_every_foo_minutes ' : [ opt_int , 5 ] ,
2005-09-03 15:48:25 +02:00
' confirm_close_muc ' : [ opt_bool , True , _ ( ' Ask before closing a group chat tab/window. ' ) ] ,
2005-08-01 17:00:47 +02:00
' notify_on_file_complete ' : [ opt_bool , True ] , # notif. on file complete
2005-08-03 23:10:59 +02:00
' file_transfers_port ' : [ opt_int , 28011 ] , # port, used for file transfers
2005-09-03 15:48:25 +02:00
' ft_override_host_to_send ' : [ opt_str , ' ' , _ ( ' Overrides the host we send for File Transfer in case of address translation/port forwarding. ' ) ] ,
2005-08-12 00:06:26 +02:00
' conversation_font ' : [ opt_str , ' ' ] ,
2005-09-03 15:48:25 +02:00
' use_kib_mib ' : [ opt_bool , False , _ ( ' IEC standard says KiB = 1024 bytes, KB = 1000 bytes. ' ) ] ,
2005-08-09 21:56:49 +02:00
' notify_on_all_muc_messages ' : [ opt_bool , False ] ,
2005-08-11 20:23:39 +02:00
' trayicon_notification_on_new_messages ' : [ opt_bool , True ] ,
2005-08-23 15:22:14 +02:00
' last_save_dir ' : [ opt_str , ' ' ] ,
' last_send_dir ' : [ opt_str , ' ' ] ,
' last_emoticons_dir ' : [ opt_str , ' ' ] ,
' last_sounds_dir ' : [ opt_str , ' ' ] ,
2005-09-04 20:54:41 +02:00
' tabs_position ' : [ opt_str , ' top ' ] ,
2005-09-03 15:48:25 +02:00
' tabs_always_visible ' : [ opt_bool , False , _ ( ' Show tab when only one conversation? ' ) ] ,
' tabs_border ' : [ opt_bool , False , _ ( ' Show tab border if one conversation? ' ) ] ,
' tabs_close_button ' : [ opt_bool , True , _ ( ' Show close button in tab? ' ) ] ,
2005-11-08 14:04:59 +01:00
' chat_avatar_width ' : [ opt_int , 52 ] ,
' chat_avatar_height ' : [ opt_int , 52 ] ,
2005-11-17 00:10:48 +01:00
' roster_avatar_width ' : [ opt_int , 32 ] ,
' roster_avatar_height ' : [ opt_int , 32 ] ,
2006-02-06 14:42:23 +01:00
' tooltip_avatar_width ' : [ opt_int , 125 ] ,
' tooltip_avatar_height ' : [ opt_int , 125 ] ,
2006-01-21 22:11:29 +01:00
' notification_position_x ' : [ opt_int , - 1 ] ,
' notification_position_y ' : [ opt_int , - 1 ] ,
2006-01-17 10:01:59 +01:00
' notification_avatar_width ' : [ opt_int , 48 ] ,
' notification_avatar_height ' : [ opt_int , 48 ] ,
2005-10-30 16:01:57 +01:00
' muc_highlight_words ' : [ opt_str , ' ' , _ ( ' A semicolon-separated list of words that will be highlighted in multi-user chat. ' ) ] ,
2005-10-04 14:43:32 +02:00
' 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. ' ) ] ,
2005-09-07 23:12:30 +02:00
' set_xmpp://_handler_everytime ' : [ opt_bool , False , _ ( ' If True, Gajim registers for xmpp:// on each startup. ' ) ] ,
2005-09-08 04:08:31 +02:00
' 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. ' ) ] ,
2005-11-06 15:30:17 +01:00
' 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 ' ) ] ,
2005-11-08 14:04:59 +01:00
' show_avatars_in_roster ' : [ opt_bool , True ] ,
2005-12-02 20:59:39 +01:00
' 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. ' ) ] ,
2005-12-28 04:20:11 +01:00
#FIXME: remove you and make it Gajim will not; and/or his or *her* status messages
2005-11-12 15:15:32 +01:00
' 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. ' ) ] ,
2005-11-28 22:15:23 +01:00
' log_contact_status_changes ' : [ opt_bool , False ] ,
2005-11-24 01:17:28 +01:00
' restored_messages_color ' : [ opt_str , ' grey ' ] ,
2005-12-02 14:10:02 +01:00
' hide_avatar_of_transport ' : [ opt_bool , False ] ,
2005-12-27 21:27:02 +01:00
' roster_window_skip_taskbar ' : [ opt_bool , False ] ,
2005-12-30 22:37:36 +01:00
' 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. ' ) ] ,
' notification_timeout ' : [ opt_int , 5 ] ,
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 21:06:26 +01:00
' send_sha_in_gc_presence ' : [ opt_bool , True , _ ( ' Jabberd1.4 does not like sha info when one join a password protected room. Turn this option to False to stop sending sha info in groupchat presences ' ) ] ,
2006-01-11 09:44:38 +01:00
' one_message_window ' : [ opt_str , ' always ' ,
2005-12-28 04:20:11 +01:00
_ ( ' Controls the window where new messages are placed. \n \' always \' - All messages are sent to a single window. \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. Note, changing this option requires restarting Gajim before the changes will take effect ' ) ] ,
2006-01-08 06:05:16 +01:00
' show_avatar_in_chat ' : [ opt_bool , True , _ ( ' If False, you will no longer see the avatar in the chat window ' ) ] ,
2006-02-03 08:32:44 +01:00
' escape_key_closes ' : [ opt_bool , True , _ ( ' If True, pressing the escape key closes a tab/window ' ) ] ,
2005-04-14 09:28:59 +02:00
}
__options_per_key = {
' accounts ' : ( {
2005-04-16 16:50:26 +02:00
' name ' : [ opt_str , ' ' ] ,
' hostname ' : [ opt_str , ' ' ] ,
' savepass ' : [ opt_bool , False ] ,
2005-04-14 09:28:59 +02:00
' password ' : [ opt_str , ' ' ] ,
2005-04-16 16:50:26 +02:00
' resource ' : [ opt_str , ' gajim ' ] ,
2005-04-14 09:28:59 +02:00
' priority ' : [ opt_int , 5 ] ,
2005-07-22 23:51:56 +02:00
' autoconnect ' : [ opt_bool , False ] ,
2005-09-06 08:18:35 +02:00
' autoreconnect ' : [ opt_bool , True ] ,
2005-09-08 01:55:40 +02:00
' active ' : [ opt_bool , True ] ,
2005-06-08 17:48:53 +02:00
' proxy ' : [ opt_str , ' ' ] ,
2005-04-14 09:28:59 +02:00
' keyid ' : [ opt_str , ' ' ] ,
' keyname ' : [ opt_str , ' ' ] ,
2005-05-30 13:01:08 +02:00
' usessl ' : [ opt_bool , False ] ,
2005-09-16 17:19:01 +02:00
' use_srv ' : [ opt_bool , True ] ,
2005-06-14 12:26:01 +02:00
' use_custom_host ' : [ opt_bool , False ] ,
' custom_port ' : [ opt_int , 5222 ] ,
' custom_host ' : [ opt_str , ' ' ] ,
2005-04-16 16:50:26 +02:00
' savegpgpass ' : [ opt_bool , False ] ,
2005-04-14 09:28:59 +02:00
' gpgpassword ' : [ opt_str , ' ' ] ,
2005-06-15 12:00:08 +02:00
' sync_with_global_status ' : [ opt_bool , False ] ,
2005-04-14 09:28:59 +02:00
' no_log_for ' : [ opt_str , ' ' ] ,
2005-05-29 23:34:01 +02:00
' attached_gpg_keys ' : [ opt_str , ' ' ] ,
2005-06-26 01:25:17 +02:00
' keep_alives_enabled ' : [ opt_bool , True ] ,
2005-09-02 23:13:52 +02:00
# send keepalive every N seconds of inactivity
2005-07-25 02:32:02 +02:00
' keep_alive_every_foo_secs ' : [ opt_int , 55 ] ,
2005-06-26 01:25:17 +02:00
# try for 2 minutes before giving up (aka. timeout after those seconds)
2005-07-25 02:32:02 +02:00
' try_connecting_for_foo_secs ' : [ opt_int , 60 ] ,
2005-06-29 10:28:12 +02:00
' max_stanza_per_sec ' : [ opt_int , 5 ] ,
2005-08-05 15:29:39 +02:00
' http_auth ' : [ opt_str , ' ask ' ] , # yes, no, ask
2005-08-11 22:27:23 +02:00
# proxy65 for FT
' file_transfer_proxies ' : [ opt_str ,
2006-01-17 23:53:23 +01:00
' proxy.jabber.org, proxy65.jabber.autocom.pl, proxy.jabber.cd.chalmers.se, proxy.netlab.cz, proxy65.jabber.ccc.de ' ] ,
2006-01-08 05:31:02 +01:00
' msgwin-x-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
' msgwin-y-position ' : [ opt_int , - 1 ] , # Default is to let the window manager decide
2006-01-25 14:34:02 +01:00
' msgwin-width ' : [ opt_int , 480 ] ,
' msgwin-height ' : [ opt_int , 440 ] ,
2005-04-15 13:37:56 +02:00
} , { } ) ,
' statusmsg ' : ( {
' message ' : [ opt_str , ' ' ] ,
} , { } ) ,
2005-04-16 16:50:26 +02:00
' emoticons ' : ( {
' path ' : [ opt_str , ' ' ] ,
} , { } ) ,
' soundevents ' : ( {
' enabled ' : [ opt_bool , True ] ,
' path ' : [ opt_str , ' ' ] ,
} , { } ) ,
2005-06-08 17:48:53 +02:00
' proxies ' : ( {
' type ' : [ opt_str , ' http ' ] ,
' host ' : [ opt_str , ' ' ] ,
' port ' : [ opt_int , 3128 ] ,
' user ' : [ opt_str , ' ' ] ,
2005-06-09 00:05:45 +02:00
' pass ' : [ opt_str , ' ' ] ,
2005-06-08 17:48:53 +02:00
} , { } ) ,
2005-08-09 16:53:33 +02:00
' ft_proxies65_cache ' : ( {
2005-08-06 22:18:44 +02:00
' host ' : [ opt_str , ' ' ] ,
' port ' : [ opt_str , ' 7777 ' ] ,
' jid ' : [ opt_str , ' ' ] ,
} , { } ) ,
2005-06-14 00:11:09 +02:00
' themes ' : ( {
2005-09-19 17:23:18 +02:00
' accounttextcolor ' : [ opt_color , ' black ' ] ,
' accountbgcolor ' : [ opt_color , ' white ' ] ,
2005-09-17 10:29:35 +02:00
' accountfont ' : [ opt_str , ' ' ] ,
2005-09-19 17:23:18 +02:00
' accountfontattrs ' : [ opt_str , ' B ' ] ,
' grouptextcolor ' : [ opt_color , ' black ' ] ,
' groupbgcolor ' : [ opt_color , ' white ' ] ,
2005-09-17 10:29:35 +02:00
' groupfont ' : [ opt_str , ' ' ] ,
2005-09-19 17:23:18 +02:00
' groupfontattrs ' : [ opt_str , ' I ' ] ,
' contacttextcolor ' : [ opt_color , ' black ' ] ,
' contactbgcolor ' : [ opt_color , ' white ' ] ,
2005-09-17 10:29:35 +02:00
' contactfont ' : [ opt_str , ' ' ] ,
' contactfontattrs ' : [ opt_str , ' ' ] ,
2005-09-19 17:23:18 +02:00
' bannertextcolor ' : [ opt_color , ' black ' ] ,
' bannerbgcolor ' : [ opt_color , ' ' ] ,
2006-03-01 12:03:56 +01:00
' bannerfont ' : [ opt_str , ' ' ] ,
' bannerfontattrs ' : [ opt_str , ' B ' ] ,
2005-09-05 02:08:52 +02:00
# http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html
# FIXME: not black but the default color from gtk+ theme
' state_active_color ' : [ opt_color , ' black ' ] ,
' state_inactive_color ' : [ opt_color , ' grey62 ' ] ,
' state_composing_color ' : [ opt_color , ' green4 ' ] ,
' state_paused_color ' : [ opt_color , ' mediumblue ' ] ,
' state_gone_color ' : [ opt_color , ' grey ' ] ,
2005-09-14 02:51:26 +02:00
# MUC chat states
' state_muc_msg ' : [ opt_color , ' mediumblue ' ] ,
' state_muc_directed_msg ' : [ opt_color , ' red2 ' ] ,
2005-06-14 00:11:09 +02:00
} , { } ) ,
2005-04-14 09:28:59 +02:00
}
2005-04-16 16:50:26 +02:00
emoticons_default = {
2005-04-16 17:01:06 +02:00
' :-) ' : ' ../data/emoticons/smile.png ' ,
' (@) ' : ' ../data/emoticons/pussy.png ' ,
' 8) ' : ' ../data/emoticons/coolglasses.png ' ,
' :( ' : ' ../data/emoticons/unhappy.png ' ,
' :) ' : ' ../data/emoticons/smile.png ' ,
' :/ ' : ' ../data/emoticons/frowning.png ' ,
' (}) ' : ' ../data/emoticons/hugleft.png ' ,
' :$ ' : ' ../data/emoticons/blush.png ' ,
' (Y) ' : ' ../data/emoticons/yes.png ' ,
' :-@ ' : ' ../data/emoticons/angry.png ' ,
' :-D ' : ' ../data/emoticons/biggrin.png ' ,
' (U) ' : ' ../data/emoticons/brheart.png ' ,
' (F) ' : ' ../data/emoticons/flower.png ' ,
' :-[ ' : ' ../data/emoticons/bat.png ' ,
' :> ' : ' ../data/emoticons/biggrin.png ' ,
' (T) ' : ' ../data/emoticons/phone.png ' ,
' :-S ' : ' ../data/emoticons/frowning.png ' ,
' :-P ' : ' ../data/emoticons/tongue.png ' ,
' (H) ' : ' ../data/emoticons/coolglasses.png ' ,
' (D) ' : ' ../data/emoticons/drink.png ' ,
' :-O ' : ' ../data/emoticons/oh.png ' ,
' (C) ' : ' ../data/emoticons/coffee.png ' ,
' ( { ) ' : ' ../data/emoticons/hugright.png ' ,
' (*) ' : ' ../data/emoticons/star.png ' ,
' B-) ' : ' ../data/emoticons/coolglasses.png ' ,
' (Z) ' : ' ../data/emoticons/boy.png ' ,
' (E) ' : ' ../data/emoticons/mail.png ' ,
' (N) ' : ' ../data/emoticons/no.png ' ,
' (P) ' : ' ../data/emoticons/photo.png ' ,
' (K) ' : ' ../data/emoticons/kiss.png ' ,
2005-11-13 21:47:15 +01:00
' :-* ' : ' ../data/emoticons/kiss.png ' ,
' :* ' : ' ../data/emoticons/kiss.png ' ,
2005-04-16 17:01:06 +02:00
' (R) ' : ' ../data/emoticons/rainbow.png ' ,
' :-| ' : ' ../data/emoticons/stare.png ' ,
' ;-) ' : ' ../data/emoticons/wink.png ' ,
' ;-( ' : ' ../data/emoticons/cry.png ' ,
' (6) ' : ' ../data/emoticons/devil.png ' ,
2005-11-13 21:47:15 +01:00
' >:) ' : ' ../data/emoticons/devil.png ' ,
' >:-) ' : ' ../data/emoticons/devil.png ' ,
2005-04-16 17:01:06 +02:00
' (L) ' : ' ../data/emoticons/heart.png ' ,
2005-11-13 21:47:15 +01:00
' <3 ' : ' ../data/emoticons/heart.png ' ,
2005-04-16 17:01:06 +02:00
' (W) ' : ' ../data/emoticons/brflower.png ' ,
' :| ' : ' ../data/emoticons/stare.png ' ,
' :O ' : ' ../data/emoticons/oh.png ' ,
' ;) ' : ' ../data/emoticons/wink.png ' ,
' ;( ' : ' ../data/emoticons/cry.png ' ,
' :S ' : ' ../data/emoticons/frowning.png ' ,
' ; \' -( ' : ' ../data/emoticons/cry.png ' ,
' :-( ' : ' ../data/emoticons/unhappy.png ' ,
' 8-) ' : ' ../data/emoticons/coolglasses.png ' ,
' (B) ' : ' ../data/emoticons/beer.png ' ,
' :D ' : ' ../data/emoticons/biggrin.png ' ,
' (8) ' : ' ../data/emoticons/music.png ' ,
' :@ ' : ' ../data/emoticons/angry.png ' ,
' B) ' : ' ../data/emoticons/coolglasses.png ' ,
' :-$ ' : ' ../data/emoticons/blush.png ' ,
' : \' ( ' : ' ../data/emoticons/cry.png ' ,
' :-> ' : ' ../data/emoticons/biggrin.png ' ,
' :[ ' : ' ../data/emoticons/bat.png ' ,
' (I) ' : ' ../data/emoticons/lamp.png ' ,
' :P ' : ' ../data/emoticons/tongue.png ' ,
' ( % ) ' : ' ../data/emoticons/cuffs.png ' ,
' (S) ' : ' ../data/emoticons/moon.png ' ,
2005-04-16 16:50:26 +02:00
}
statusmsg_default = {
2005-07-06 14:19:04 +02:00
_ ( ' Sleeping ' ) : ' ZZZZzzzzzZZZZZ ' ,
2005-06-06 12:51:24 +02:00
_ ( ' Back soon ' ) : _ ( ' Back in some minutes. ' ) ,
_ ( ' Eating ' ) : _ ( " I ' m eating, so leave me a message. " ) ,
_ ( ' Movie ' ) : _ ( " I ' m watching a movie. " ) ,
_ ( ' Working ' ) : _ ( " I ' m working. " ) ,
_ ( ' Phone ' ) : _ ( " I ' m on the phone. " ) ,
_ ( ' Out ' ) : _ ( " I ' m out enjoying life " ) ,
2005-04-16 16:50:26 +02:00
}
soundevents_default = {
2005-05-07 22:23:55 +02:00
' first_message_received ' : [ True , ' ../data/sounds/message1.wav ' ] ,
' next_message_received ' : [ True , ' ../data/sounds/message2.wav ' ] ,
' contact_connected ' : [ True , ' ../data/sounds/connected.wav ' ] ,
' contact_disconnected ' : [ True , ' ../data/sounds/disconnected.wav ' ] ,
' message_sent ' : [ True , ' ../data/sounds/sent.wav ' ] ,
2005-10-04 14:43:32 +02:00
' 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. ' ) ] ,
' 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) ' ) ] ,
2005-04-16 16:50:26 +02:00
}
2005-06-14 00:11:09 +02:00
themes_default = {
2005-10-29 18:56:33 +02:00
# sorted alphanum
2006-01-26 00:47:15 +01:00
_ ( ' green ' ) : [ ' ' , ' #94aa8c ' , ' ' , ' B ' , ' #0000ff ' , ' #eff3e7 ' ,
' ' , ' I ' , ' #000000 ' , ' ' , ' ' , ' ' , ' ' ,
2005-10-29 18:56:33 +02:00
' #94aa8c ' ] ,
2006-01-26 00:47:15 +01:00
_ ( ' grocery ' ) : [ ' ' , ' #6bbe18 ' , ' ' , ' B ' , ' #12125a ' , ' #ceefad ' ,
' ' , ' I ' , ' #000000 ' , ' #efb26b ' , ' ' , ' ' , ' ' ,
2005-10-31 17:19:12 +01:00
' #108abd ' ] ,
2006-01-26 00:47:15 +01:00
_ ( ' human ' ) : [ ' ' , ' #996442 ' , ' ' , ' B ' , ' #ab5920 ' , ' #e3ca94 ' ,
' ' , ' I ' , ' #000000 ' , ' ' , ' ' , ' ' , ' ' ,
2005-06-14 00:11:09 +02:00
' #996442 ' ] ,
2005-10-29 18:56:33 +02:00
2006-01-26 00:47:15 +01:00
_ ( ' marine ' ) : [ ' ' , ' #918caa ' , ' ' , ' B ' , ' ' , ' #e9e7f3 ' ,
' ' , ' I ' , ' #000000 ' , ' ' , ' ' , ' ' , ' ' ,
2005-10-29 18:56:33 +02:00
' #918caa ' ] ,
2005-10-31 17:19:12 +01:00
_ ( ' plain ' ) : [ ' ' , ' ' , ' ' , ' B ' , ' ' , ' ' , ' ' , ' I ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' ] ,
2005-10-29 18:56:33 +02:00
2005-06-14 00:11:09 +02:00
}
2005-08-06 22:18:44 +02:00
2005-08-09 16:53:33 +02:00
ft_proxies65_default = {
2005-08-06 22:18:44 +02:00
' proxy.jabber.org ' : [ ' 208.245.212.98 ' , ' 7777 ' , ' proxy.jabber.org ' ] ,
2005-08-08 14:09:29 +02:00
' proxy65.jabber.autocom.pl ' : [ ' 213.134.161.52 ' , ' 7777 ' , ' proxy65.jabber.autocom.pl ' ] ,
2005-08-09 16:53:33 +02:00
' proxy.jabber.cd.chalmers.se ' : [ ' 129.16.79.37 ' , ' 7777 ' , ' proxy.jabber.cd.chalmers.se ' ] ,
2005-08-23 16:29:12 +02:00
' proxy.netlab.cz ' : [ ' 82.119.241.3 ' , ' 7777 ' , ' proxy.netlab.cz ' ] ,
2005-09-17 13:26:15 +02:00
' proxy65.jabber.ccc.de ' : [ ' 217.10.10.196 ' , ' 7777 ' , ' proxy65.jabber.ccc.de ' ] ,
2005-08-06 22:18:44 +02:00
}
2005-06-14 00:11:09 +02:00
2005-04-27 01:53:11 +02:00
def foreach ( self , cb , data = None ) :
2005-04-14 09:28:59 +02:00
for opt in self . __options :
2005-04-27 00:17:47 +02:00
cb ( data , opt , None , self . __options [ opt ] )
2005-04-14 09:28:59 +02:00
for opt in self . __options_per_key :
2005-04-27 00:17:47 +02:00
cb ( data , opt , None , None )
2005-04-14 09:28:59 +02:00
dict = self . __options_per_key [ opt ] [ 1 ]
for opt2 in dict . keys ( ) :
2005-04-27 00:17:47 +02:00
cb ( data , opt2 , [ opt ] , None )
2005-04-14 09:28:59 +02:00
for opt3 in dict [ opt2 ] :
2005-04-27 00:17:47 +02:00
cb ( data , opt3 , [ opt , opt2 ] , dict [ opt2 ] [ opt3 ] )
2005-04-14 09:28:59 +02:00
def is_valid_int ( self , val ) :
try :
ival = int ( val )
except :
2005-04-27 01:41:20 +02:00
return None
return ival
2005-04-14 09:28:59 +02:00
def is_valid_bool ( self , val ) :
2005-04-27 01:41:20 +02:00
if val == ' True ' :
return True
elif val == ' False ' :
return False
else :
ival = self . is_valid_int ( val )
if ival :
return True
2005-08-05 12:26:10 +02:00
elif ival is None :
2005-05-26 23:09:01 +02:00
return None
2005-04-27 01:41:20 +02:00
return False
2005-06-09 17:31:29 +02:00
return None
2005-04-14 09:28:59 +02:00
def is_valid_string ( self , val ) :
2005-04-27 01:41:20 +02:00
return val
2005-06-09 17:31:29 +02:00
2005-04-14 09:28:59 +02:00
def is_valid ( self , type , val ) :
2005-05-01 00:24:45 +02:00
if not type :
return None
2005-04-14 09:28:59 +02:00
if type [ 0 ] == ' boolean ' :
return self . is_valid_bool ( val )
elif type [ 0 ] == ' integer ' :
return self . is_valid_int ( val )
elif type [ 0 ] == ' string ' :
return self . is_valid_string ( val )
else :
2005-04-27 01:41:20 +02:00
if sre . match ( type [ 1 ] , val ) :
return val
else :
return None
2005-04-14 09:28:59 +02:00
def set ( self , optname , value ) :
if not self . __options . has_key ( optname ) :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, 'option %s does not exist' % optname
return
2005-04-14 09:28:59 +02:00
opt = self . __options [ optname ]
2005-04-27 01:41:20 +02:00
value = self . is_valid ( opt [ OPT_TYPE ] , value )
2005-08-05 12:26:10 +02:00
if value is None :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, 'value of %s cannot be None' % optname
return
2005-06-09 17:31:29 +02:00
2005-04-14 09:28:59 +02:00
opt [ OPT_VAL ] = value
2005-06-09 17:31:29 +02:00
2005-04-17 00:12:41 +02:00
def get ( self , optname = None ) :
if not optname :
return self . __options . keys ( )
2005-04-16 16:50:26 +02:00
if not self . __options . has_key ( optname ) :
2005-04-14 09:28:59 +02:00
return None
2005-04-16 16:50:26 +02:00
return self . __options [ optname ] [ OPT_VAL ]
2005-09-03 14:28:30 +02:00
def get_desc ( self , optname ) :
if not self . __options . has_key ( optname ) :
return None
if len ( self . __options [ optname ] ) > OPT_DESC :
return self . __options [ optname ] [ OPT_DESC ]
2005-04-14 09:28:59 +02:00
2005-04-19 01:55:13 +02:00
def add_per ( self , typename , name ) : # per_group_of_option
2005-04-14 09:28:59 +02:00
if not self . __options_per_key . has_key ( typename ) :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, 'option %s does not exist' % typename
return
2005-04-14 09:28:59 +02:00
opt = self . __options_per_key [ typename ]
2005-04-27 01:41:20 +02:00
if opt [ 1 ] . has_key ( name ) :
2005-08-05 12:26:10 +02:00
# we already have added group name before
2005-08-05 12:30:22 +02:00
return ' you already have added %s before ' % name
2005-04-14 09:28:59 +02:00
opt [ 1 ] [ name ] = copy . deepcopy ( opt [ 0 ] )
2005-09-09 22:51:22 +02:00
def del_per ( self , typename , name , subname = None ) : # per_group_of_option
2005-04-14 09:28:59 +02:00
if not self . __options_per_key . has_key ( typename ) :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, 'option %s does not exist' % typename
return
2005-08-06 23:19:16 +02:00
2005-04-14 09:28:59 +02:00
opt = self . __options_per_key [ typename ]
2005-09-10 11:30:46 +02:00
if subname is None :
2005-09-09 22:51:22 +02:00
del opt [ 1 ] [ name ]
# if subname is specified, delete the item in the group.
elif opt [ 1 ] [ name ] . has_key ( subname ) :
del opt [ 1 ] [ name ] [ subname ]
2005-04-14 09:28:59 +02:00
2005-04-19 01:55:13 +02:00
def set_per ( self , optname , key , subname , value ) : # per_group_of_option
2005-04-14 09:28:59 +02:00
if not self . __options_per_key . has_key ( optname ) :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, 'option %s does not exist' % optname
return
2005-04-14 09:28:59 +02:00
dict = self . __options_per_key [ optname ] [ 1 ]
if not dict . has_key ( key ) :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, '%s is not a key of %s' % (key, dict)
return
2005-04-14 09:28:59 +02:00
obj = dict [ key ]
if not obj . has_key ( subname ) :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, '%s is not a key of %s' % (subname, obj)
return
2005-04-14 09:28:59 +02:00
subobj = obj [ subname ]
2005-04-27 01:41:20 +02:00
value = self . is_valid ( subobj [ OPT_TYPE ] , value )
2005-08-05 12:26:10 +02:00
if value is None :
2005-08-06 01:47:41 +02:00
# raise RuntimeError, '%s of %s cannot be None' % optname
return
2005-04-14 09:28:59 +02:00
subobj [ OPT_VAL ] = value
2005-06-09 17:31:29 +02:00
2005-04-19 01:55:13 +02:00
def get_per ( self , optname , key = None , subname = None ) : # per_group_of_option
2005-04-14 09:42:26 +02:00
if not self . __options_per_key . has_key ( optname ) :
2005-04-14 09:28:59 +02:00
return None
2005-04-14 09:42:26 +02:00
dict = self . __options_per_key [ optname ] [ 1 ]
2005-04-14 09:28:59 +02:00
if not key :
return dict . keys ( )
if not dict . has_key ( key ) :
return None
obj = dict [ key ]
if not subname :
return obj
if not obj . has_key ( subname ) :
return None
2005-04-14 13:06:58 +02:00
return obj [ subname ] [ OPT_VAL ]
2005-04-14 09:28:59 +02:00
def __init__ ( self ) :
2005-04-16 16:50:26 +02:00
#init default values
2005-04-16 17:01:06 +02:00
for event in self . soundevents_default :
default = self . soundevents_default [ event ]
self . add_per ( ' soundevents ' , event )
2005-08-05 12:26:10 +02:00
self . set_per ( ' soundevents ' , event , ' enabled ' , default [ 0 ] )
2005-04-16 17:01:06 +02:00
self . set_per ( ' soundevents ' , event , ' path ' , default [ 1 ] )
2005-08-06 22:18:44 +02:00
# set initial cache values for proxie65 hosts
2005-08-09 16:53:33 +02:00
for proxy in self . ft_proxies65_default :
default = self . ft_proxies65_default [ proxy ]
self . add_per ( ' ft_proxies65_cache ' , proxy )
self . set_per ( ' ft_proxies65_cache ' , proxy , ' host ' , default [ 0 ] )
self . set_per ( ' ft_proxies65_cache ' , proxy , ' port ' , default [ 1 ] )
self . set_per ( ' ft_proxies65_cache ' , proxy , ' jid ' , default [ 2 ] )
2005-04-14 09:28:59 +02:00
return