Commit 3da2859b authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Migrate app.config.get()

parent 58e4a29a
......@@ -403,7 +403,7 @@ def add_actions(self):
act = Gio.SimpleAction.new_stateful(
'merge', None,
GLib.Variant.new_boolean(app.config.get('mergeaccounts')))
GLib.Variant.new_boolean(app.settings.get('mergeaccounts')))
act.connect('change-state', app_actions.on_merge_accounts)
self.add_action(act)
......
......@@ -121,7 +121,7 @@ def __init__(self, parent_win, contact, acct, session, resource=None):
self.toggle_emoticons()
if not app.config.get('hide_chat_banner'):
if not app.settings.get('hide_chat_banner'):
self.xml.banner_eventbox.set_no_show_all(False)
self.xml.sendfile_button.set_action_name(
......@@ -275,7 +275,7 @@ def add_actions(self):
video.action.connect('change-state', self._on_video)
self.parent_win.window.add_action(video.action)
default_chatstate = app.config.get('send_chatstate_default')
default_chatstate = app.settings.get('send_chatstate_default')
chatstate = app.config.get_per(
'contacts', self.contact.jid, 'send_chatstate', default_chatstate)
......@@ -702,8 +702,8 @@ def update_audio(self):
hbox = self.xml.audio_buttons_hbox
if self.jingle['audio'].state == self.JINGLE_STATE_CONNECTED:
# Set volume from config
input_vol = app.config.get('audio_input_volume')
output_vol = app.config.get('audio_output_volume')
input_vol = app.settings.get('audio_input_volume')
output_vol = app.settings.get('audio_output_volume')
input_vol = max(min(input_vol, 100), 0)
output_vol = max(min(output_vol, 100), 0)
self.xml.mic_hscale.set_value(input_vol)
......@@ -857,7 +857,7 @@ def draw_banner_text(self):
cs = app.contacts.get_combined_chatstate(
self.account, self.contact.jid)
if app.config.get('show_chatstate_in_banner'):
if app.settings.get('show_chatstate_in_banner'):
chatstate = helpers.get_uf_chatstate(cs)
label_text = '<span>%s</span><span size="x-small" weight="light"> %s</span>' % \
......@@ -912,7 +912,7 @@ def on_jingle_button_toggled(self, state, jingle_type):
if jingle_type == 'video':
video_hbox = self.xml.video_hbox
video_hbox.set_no_show_all(False)
if app.config.get('video_see_self'):
if app.settings.get('video_see_self'):
fixed = self.xml.outgoing_fixed
fixed.set_no_show_all(False)
video_hbox.show_all()
......@@ -1155,7 +1155,7 @@ def allow_shutdown(self, method, on_yes, on_no, _on_minimize):
on_yes(self)
def show_avatar(self):
if not app.config.get('show_avatar_in_chat'):
if not app.settings.get('show_avatar_in_chat'):
return
scale = self.parent_win.window.get_scale_factor()
......@@ -1310,8 +1310,8 @@ def read_queue(self):
self.redraw_after_event_removed(jid)
if self.contact.show in ('offline', 'error'):
show_offline = app.config.get('showoffline')
show_transports = app.config.get('show_transports_group')
show_offline = app.settings.get('showoffline')
show_transports = app.settings.get('show_transports_group')
if (not show_transports and app.jid_is_transport(jid)) or \
(not show_offline and typ == 'chat' and \
len(app.contacts.get_contacts(self.account, jid)) < 2):
......@@ -1346,7 +1346,7 @@ def update_status_display(self, name, uf_show, status):
self.update_ui()
self.parent_win.redraw_tab(self)
if not app.config.get('print_status_in_chats'):
if not app.settings.get('print_status_in_chats'):
return
if status:
......@@ -1407,7 +1407,7 @@ def _got_file_request(self, file_props):
"""
Show an InfoBar on top of control
"""
if app.config.get('use_kib_mib'):
if app.settings.get('use_kib_mib'):
units = GLib.FormatSizeFlags.IEC_UNITS
else:
units = GLib.FormatSizeFlags.DEFAULT
......
......@@ -612,7 +612,7 @@ def set_encryption_menu_icon(self):
Gtk.IconSize.MENU)
def set_speller(self):
if not app.is_installed('GSPELL') or not app.config.get('use_speller'):
if not app.is_installed('GSPELL') or not app.settings.get('use_speller'):
return
gspell_lang = self.get_speller_language()
......@@ -634,7 +634,7 @@ def get_speller_language(self):
per_type, self.contact.jid, 'speller_language')
if not lang:
# use the default one
lang = app.config.get('speller_language')
lang = app.settings.get('speller_language')
if not lang:
lang = i18n.LANG
gspell_lang = Gspell.language_lookup(lang)
......@@ -737,7 +737,7 @@ def _on_message_textview_paste_event(self, _texview):
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
image = clipboard.wait_for_image()
if image is not None:
if not app.config.get('confirm_paste_image'):
if not app.settings.get('confirm_paste_image'):
self._paste_event_confirmed(True, image)
return
NewConfirmationCheckDialog(
......@@ -905,7 +905,7 @@ def _on_message_textview_key_press_event(self, widget, event):
send_message = False
else:
is_ctrl_enter = bool(event_state & Gdk.ModifierType.CONTROL_MASK)
send_message = is_ctrl_enter == app.config.get('send_on_ctrl_enter')
send_message = is_ctrl_enter == app.settings.get('send_on_ctrl_enter')
if send_message and not app.account_is_available(self.account):
# we are not connected
......@@ -1056,7 +1056,7 @@ def save_message(self, message, msg_type):
size = len(history)
scroll = pos != size
# we don't want size of the buffer to grow indefinitely
max_size = app.config.get('key_up_lines')
max_size = app.settings.get('key_up_lines')
for _i in range(size - max_size + 1):
if pos == 0:
break
......@@ -1206,7 +1206,7 @@ def toggle_emoticons(self):
"""
Hide show emoticons_button
"""
if app.config.get('emoticons_theme'):
if app.settings.get('emoticons_theme'):
self.xml.emoticons_button.set_no_show_all(False)
self.xml.emoticons_button.show()
else:
......@@ -1214,7 +1214,7 @@ def toggle_emoticons(self):
self.xml.emoticons_button.hide()
def set_emoticon_popover(self):
if not app.config.get('emoticons_theme'):
if not app.settings.get('emoticons_theme'):
return
if not self.parent_win:
......
......@@ -63,7 +63,7 @@ def execute(self, expression):
@classmethod
def spawn(cls, processor, expression):
command_system_execute = app.config.get('command_system_execute')
command_system_execute = app.settings.get('command_system_execute')
if command_system_execute:
pipes = dict(stdout=PIPE, stderr=PIPE)
directory = expanduser(cls.DIRECTORY)
......
......@@ -574,7 +574,7 @@ def _idle_state_changed(self, monitor):
self._update_status()
return
if not app.config.get(f'auto{state}'):
if not app.settings.get(f'auto{state}'):
return
if (state in ('away', 'xa') and self._status == 'online' or
......
......@@ -193,7 +193,7 @@ def change_status(self, show, msg, auto=False):
idle_time = None
if auto:
if app.is_installed('IDLE') and app.config.get('autoaway'):
if app.is_installed('IDLE') and app.settings.get('autoaway'):
idle_sec = idle.Monitor.get_idle_sec()
idle_time = time.strftime(
'%Y-%m-%dT%H:%M:%SZ',
......
......@@ -220,7 +220,7 @@ def handle_incoming_msg_event(self, msg_obj):
else:
self.sound_event = 'next_message_received_unfocused'
if app.config.get('notification_preview_message'):
if app.settings.get('notification_preview_message'):
self.popup_text = msg_obj.msgtxt
if self.popup_text and (self.popup_text.startswith('/me ') or \
self.popup_text.startswith('/me\n')):
......@@ -243,24 +243,24 @@ def handle_incoming_msg_event(self, msg_obj):
'%(n_msgs)i unread messages from %(nickname)s',
num_unread) % {'nickname': nick, 'n_msgs': num_unread}
if app.config.get('notify_on_new_message'):
if self.first_unread or (app.config.get('autopopup_chat_opened') \
if app.settings.get('notify_on_new_message'):
if self.first_unread or (app.settings.get('autopopup_chat_opened') \
and not self.control_focused):
if app.config.get('autopopupaway'):
if app.settings.get('autopopupaway'):
# always show notification
self.do_popup = True
if app.connections[self.conn.name].status in ('online', 'chat'):
# we're online or chat
self.do_popup = True
if msg_obj.properties.attention and not app.config.get(
if msg_obj.properties.attention and not app.settings.get(
'ignore_incoming_attention'):
self.popup_timeout = 0
self.do_popup = True
else:
self.popup_timeout = app.config.get('notification_timeout')
self.popup_timeout = app.settings.get('notification_timeout')
if msg_obj.properties.attention and not app.config.get(
if msg_obj.properties.attention and not app.settings.get(
'ignore_incoming_attention') and app.config.get_per('soundevents',
'attention_received', 'enabled'):
self.sound_event = 'attention_received'
......@@ -304,17 +304,18 @@ def handle_incoming_gc_msg_event(self, msg_obj):
if self.control is not None:
self.control_focused = self.control.has_focus()
if app.config.get('notify_on_new_message'):
if app.settings.get('notify_on_new_message'):
contact = app.contacts.get_groupchat_contact(self.account,
self.jid)
notify_for_muc = sound == 'highlight' or contact.can_notify()
if not notify_for_muc:
self.do_popup = False
elif self.control_focused:
self.do_popup = False
elif app.config.get('autopopupaway'):
elif app.settings.get('autopopupaway'):
# always show notification
self.do_popup = True
......@@ -325,7 +326,7 @@ def handle_incoming_gc_msg_event(self, msg_obj):
self.popup_msg_type = 'gc_msg'
self.popup_event_type = _('New Group Chat Message')
if app.config.get('notification_preview_message'):
if app.settings.get('notification_preview_message'):
self.popup_text = msg_obj.msgtxt
if self.popup_text and (self.popup_text.startswith('/me ') or
self.popup_text.startswith('/me\n')):
......@@ -408,7 +409,7 @@ def handle_incoming_pres_event(self, pres_obj):
self.show = pres_obj.show
self.popup_timeout = app.config.get('notification_timeout')
self.popup_timeout = app.settings.get('notification_timeout')
nick = i18n.direction_mark + app.get_name_from_jid(account, self.jid)
if event == 'status_change':
......
......@@ -268,7 +268,7 @@ def can_notify(self):
if not self.is_groupchat:
raise ValueError
all_ = app.config.get('notify_on_all_muc_messages')
all_ = app.settings.get('notify_on_all_muc_messages')
room = app.config.get_per('rooms', self.jid, 'notify_on_all_messages')
return all_ or room
......@@ -960,7 +960,7 @@ def get_nearby_family_and_big_brother(self, family, account):
(nearby_family, big_brother_jid, big_brother_account)
"""
if common.app.config.get('mergeaccounts'):
if common.app.settings.get('mergeaccounts'):
# group all together
nearby_family = family
else:
......
......@@ -436,7 +436,7 @@ def get_contact_dict_for_account(account):
return contacts_dict
def play_sound(event):
if not app.config.get('sounds_on'):
if not app.settings.get('sounds_on'):
return
path_to_soundfile = app.config.get_per('soundevents', event, 'path')
play_sound_file(path_to_soundfile)
......@@ -667,9 +667,9 @@ def allow_showing_notification(account,
option that need to be True e.g.: notify_on_signing is_first_message: set it
to false when it's not the first message
"""
if type_ and (not app.config.get(type_) or not is_first_message):
if type_ and (not app.settings.get(type_) or not is_first_message):
return False
if app.config.get('autopopupaway'):
if app.settings.get('autopopupaway'):
return True
if app.connections[account].status in ('online', 'chat'):
return True
......@@ -679,15 +679,15 @@ def allow_popup_window(account):
"""
Is it allowed to popup windows?
"""
autopopup = app.config.get('autopopup')
autopopupaway = app.config.get('autopopupaway')
autopopup = app.settings.get('autopopup')
autopopupaway = app.settings.get('autopopupaway')
if autopopup and (autopopupaway or \
app.connections[account].status in ('online', 'chat')):
return True
return False
def allow_sound_notification(account, sound_event):
if (app.config.get('sounddnd') or
if (app.settings.get('sounddnd') or
app.connections[account].status != 'dnd' and
app.config.get_per('soundevents', sound_event, 'enabled')):
return True
......@@ -902,9 +902,9 @@ def get_sync_threshold(jid, archive_info):
disco_info = app.logger.get_last_disco_info(jid)
if archive_info is None or archive_info.sync_threshold is None:
if disco_info is not None and disco_info.muc_is_members_only:
threshold = app.config.get('private_room_sync_threshold')
threshold = app.settings.get('private_room_sync_threshold')
else:
threshold = app.config.get('public_room_sync_threshold')
threshold = app.settings.get('public_room_sync_threshold')
app.logger.set_archive_infos(jid, sync_threshold=threshold)
return threshold
return archive_info.sync_threshold
......@@ -983,7 +983,7 @@ def copy(self):
def save_roster_position(window):
if not app.config.get('save-roster-position'):
if not app.settings.get('save-roster-position'):
return
if app.is_display(Display.WAYLAND):
return
......@@ -1401,7 +1401,7 @@ def warn_about_plain_connection(account, connection_types):
def get_idle_status_message(state, status_message):
message = app.config.get(f'auto{state}_message')
message = app.settings.get(f'auto{state}_message')
if not message:
message = status_message
else:
......@@ -1409,7 +1409,7 @@ def get_idle_status_message(state, status_message):
message = message.replace('$T', '%(time)s')
message = message % {
'status': status_message,
'time': app.config.get(f'auto{state}time')
'time': app.settings.get(f'auto{state}time')
}
return message
......@@ -1434,9 +1434,9 @@ def ask_for_status_message(status, signin=False):
return True
if signin:
return app.config.get('ask_online_status')
return app.settings.get('ask_online_status')
if status == 'offline':
return app.config.get('ask_offline_status')
return app.settings.get('ask_offline_status')
return app.config.get('always_ask_for_status_message')
return app.settings.get('always_ask_for_status_message')
......@@ -370,7 +370,7 @@ def _listen_host(self):
sha_str = helpers.get_auth_sha(self.file_props.sid, sender,
receiver)
self.file_props.sha_str = sha_str
port = app.config.get('file_transfers_port')
port = app.settings.get('file_transfers_port')
fingerprint = None
if self.use_security:
fingerprint = 'server'
......
......@@ -95,8 +95,8 @@ def setup_stream(self, on_src_pad_added):
# due to bad controlling-mode
params = {'controlling-mode': self.session.weinitiate, 'debug': False}
if app.config.get('use_stun_server'):
stun_server = app.config.get('stun_server')
if app.settings.get('use_stun_server'):
stun_server = app.settings.get('stun_server')
if not stun_server and self.session.connection._stun_servers:
stun_server = self.session.connection._stun_servers[0]['host']
if stun_server:
......@@ -117,7 +117,7 @@ def is_ready(self):
return JingleContent.is_ready(self) and self.candidates_ready
def make_bin_from_config(self, config_key, pipeline, text):
pipeline = pipeline % app.config.get(config_key)
pipeline = pipeline % app.settings.get(config_key)
try:
gst_bin = Gst.parse_bin_from_description(pipeline, True)
return gst_bin
......@@ -432,7 +432,7 @@ def setup_stream(self):
bus.enable_sync_message_emission()
def do_setup(self, self_display_sink, other_sink):
if app.config.get('video_see_self'):
if app.settings.get('video_see_self'):
tee = '! tee name=split ! queue name=self-display-queue split. ! queue name=network-queue'
else:
tee = ''
......@@ -441,7 +441,7 @@ def do_setup(self, self_display_sink, other_sink):
'%%s %s' % tee,
_("video input"))
self.pipeline.add(self.src_bin)
if app.config.get('video_see_self'):
if app.settings.get('video_see_self'):
self.pipeline.add(self_display_sink)
self_display_queue = self.src_bin.get_by_name('self-display-queue')
self_display_queue.get_static_pad('src').link_maybe_ghosting(self_display_sink.get_static_pad('sink'))
......
......@@ -190,7 +190,7 @@ def _add_local_ips_as_candidates(self):
return
if not self.connection:
return
port = int(app.config.get('file_transfers_port'))
port = int(app.settings.get('file_transfers_port'))
#type preference of connection type. XEP-0260 section 2.2
type_preference = 126
priority = (2**16) * type_preference
......@@ -285,8 +285,8 @@ def _add_additional_candidates(self):
type_preference = 126
priority = (2**16) * type_preference
additional_ip_cand = []
port = int(app.config.get('file_transfers_port'))
ft_add_hosts = app.config.get('ft_add_hosts_to_send')
port = int(app.settings.get('file_transfers_port'))
ft_add_hosts = app.settings.get('ft_add_hosts_to_send')
if ft_add_hosts:
hosts = [e.strip() for e in ft_add_hosts.split(',')]
......
......@@ -439,7 +439,7 @@ def _get_timeout():
"""
returns the timeout in epoch
"""
timeout = app.config.get('restore_timeout')
timeout = app.settings.get('restore_timeout')
now = int(time.time())
if timeout > 0:
......@@ -796,7 +796,7 @@ def get_last_conversation_lines(self, account, jid, pending):
returns a list of namedtuples
"""
restore = app.config.get('restore_lines')
restore = app.settings.get('restore_lines')
if restore <= 0:
return []
......
......@@ -201,7 +201,7 @@ def __init__(self, con):
# a list of all commands exposed: node -> command class
self._commands = {}
if app.config.get('remote_commands'):
if app.settings.get('remote_commands'):
for cmdobj in (ChangeStatusCommand,):
self._commands[cmdobj.commandnode] = cmdobj
......
......@@ -135,7 +135,7 @@ def _bookmark_2_event_received(self, _con, _stanza, properties):
NetworkEvent('bookmarks-received', account=self._account))
def pass_disco(self, info):
if app.config.get('dev_force_bookmark_2'):
if app.settings.get('dev_force_bookmark_2'):
self._log.info('Forcing Bookmark 2 usage, '
'without server conversion support: %s', info.jid)
self._conversion_2 = True
......
......@@ -260,7 +260,7 @@ def _send_socks5_info(self, file_props):
sha_str = helpers.get_auth_sha(file_props.sid, sender, receiver)
file_props.sha_str = sha_str
port = app.config.get('file_transfers_port')
port = app.settings.get('file_transfers_port')
listener = app.socks5queue.start_listener(
port,
sha_str,
......@@ -320,7 +320,7 @@ def _add_local_ips_as_streamhosts_to_query(self, query, file_props):
my_ips.append(addr[4][0])
sender = file_props.sender
port = app.config.get('file_transfers_port')
port = app.settings.get('file_transfers_port')
self._add_streamhosts_to_query(query, sender, port, my_ips)
except socket.gaierror:
from gajim.common.connection_handlers_events import InformationEvent
......@@ -329,8 +329,8 @@ def _add_local_ips_as_streamhosts_to_query(self, query, file_props):
def _add_addiditional_streamhosts_to_query(self, query, file_props):
sender = file_props.sender
port = app.config.get('file_transfers_port')
ft_add_hosts_to_send = app.config.get('ft_add_hosts_to_send')
port = app.settings.get('file_transfers_port')
ft_add_hosts_to_send = app.settings.get('ft_add_hosts_to_send')
add_hosts = []
if ft_add_hosts_to_send:
add_hosts = [e.strip() for e in ft_add_hosts_to_send.split(',')]
......@@ -387,7 +387,7 @@ def success(_gupnp, _proto, ext_ip, _re, ext_port,
local_ip, local_port, _desc):
log.debug('Got GUPnP-IGD answer: external: %s:%s, internal: %s:%s',
ext_ip, ext_port, local_ip, local_port)
if local_port != app.config.get('file_transfers_port'):
if local_port != app.settings.get('file_transfers_port'):
sender = file_props.sender
receiver = file_props.receiver
sha_str = helpers.get_auth_sha(file_props.sid,
......@@ -429,7 +429,7 @@ def no_upnp_reply():
self.ok_id = app.gupnp_igd.connect('mapped-external-port', success)
self.fail_id = app.gupnp_igd.connect('error-mapping-port', fail)
port = app.config.get('file_transfers_port')
port = app.settings.get('file_transfers_port')
self.no_gupnp_reply_id = GLib.timeout_add_seconds(10, no_upnp_reply)
app.gupnp_igd.add_port('TCP',
0,
......
......@@ -339,10 +339,10 @@ def set_keyboard_activity(self, contact: ContactT) -> None:
@staticmethod
def _get_chatstate_setting(contact):
if contact.is_groupchat:
default = app.config.get('send_chatstate_muc_default')
default = app.settings.get('send_chatstate_muc_default')
return app.config.get_per(
'rooms', contact.jid, 'send_chatstate', default)
default = app.config.get('send_chatstate_default')
default = app.settings.get('send_chatstate_default')
return app.config.get_per(
'contacts', contact.jid, 'send_chatstate', default)
......
......@@ -539,7 +539,7 @@ def _log_muc_event(self, event_name, properties):
'muc-user-status-show-changed']:
return
if (not app.config.get('log_contact_status_changes') or
if (not app.settings.get('log_contact_status_changes') or
not helpers.should_log(self._account, properties.jid)):
return
......
......@@ -227,7 +227,7 @@ def _is_resource_known(contact_list):
return contact_list[0].show not in ('not in roster', 'offline')
def _log_presence(self, properties):
if not app.config.get('log_contact_status_changes'):
if not app.settings.get('log_contact_status_changes'):
return
if not should_log(self._account, properties.jid.getBare()):
return
......@@ -373,7 +373,7 @@ def get_presence(self, to=None, typ=None, priority=None,
if (idle_time and
app.is_installed('IDLE') and
app.config.get('autoaway')):
app.settings.get('autoaway')):
idle_sec = idle.Monitor.get_idle_sec()
time_ = time.strftime('%Y-%m-%dT%H:%M:%SZ',
time.gmtime(time.time() - idle_sec))
......
......@@ -107,7 +107,7 @@ def delete_password(account_name):
def get_password(account_name):
if app.config.get('use_keyring'):
if app.settings.get('use_keyring'):
return SecretPasswordStorage.get_password(account_name)
return ConfigPasswordStorage.get_password(account_name)
......@@ -119,7 +119,7 @@ def save_password(account_name, password):
if not app.config.get_per('accounts', account_name, 'savepass'):
return True
if app.config.get('use_keyring'):
if app.settings.get('use_keyring'):
return SecretPasswordStorage.save_password(account_name, password)
return ConfigPasswordStorage.save_password(account_name, password)
......@@ -128,6 +128,6 @@ def delete_password(account_name):
if account_name in app.connections:
app.connections[account_name].password = None
if app.config.get('use_keyring'):
if app.settings.get('use_keyring'):
return SecretPasswordStorage.delete_password(account_name)
return ConfigPasswordStorage.delete_password(account_name)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment