diff options
Diffstat (limited to 'poezio/core')
-rw-r--r-- | poezio/core/commands.py | 6 | ||||
-rw-r--r-- | poezio/core/completions.py | 6 | ||||
-rw-r--r-- | poezio/core/core.py | 60 | ||||
-rw-r--r-- | poezio/core/handlers.py | 30 |
4 files changed, 52 insertions, 50 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py index d07c2e1e..3cd65207 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -424,8 +424,8 @@ class CommandCore: tab.password = password tab.join() - if config.get('synchronise_open_rooms') and room not in self.core.bookmarks: - method = 'remote' if config.get( + if config.getbool('synchronise_open_rooms') and room not in self.core.bookmarks: + method = 'remote' if config.getbool( 'use_remote_bookmarks') else 'local' await self._add_bookmark( room=room, @@ -472,7 +472,7 @@ class CommandCore: room, nick = self._parse_join_jid(args[0] if args else '') password = args[2] if len(args) > 2 else None - method = 'remote' if config.get('use_remote_bookmarks') else 'local' + method = 'remote' if config.getbool('use_remote_bookmarks') else 'local' autojoin = (method == 'local' or (len(args) > 1 and args[1].lower() == 'true')) diff --git a/poezio/core/completions.py b/poezio/core/completions.py index 88ed57b3..9b218c9a 100644 --- a/poezio/core/completions.py +++ b/poezio/core/completions.py @@ -82,7 +82,7 @@ class CompletionCore: def theme(self, the_input): """ Completion for /theme""" - themes_dir = config.get('themes_dir') + themes_dir = config.getstr('themes_dir') themes_dir = Path(themes_dir).expanduser( ) if themes_dir else xdg.DATA_HOME / 'themes' try: @@ -220,7 +220,7 @@ class CompletionCore: nicks = [tab.own_nick] if tab else [] default = os.environ.get('USER') if os.environ.get( 'USER') else 'poezio' - nick = config.get('default_nick') + nick = config.getstr('default_nick') if not nick: if default not in nicks: nicks.append(default) @@ -436,7 +436,7 @@ class CompletionCore: nicks = [tab.own_nick] if tab else [] default = os.environ.get('USER') if os.environ.get( 'USER') else 'poezio' - nick = config.get('default_nick') + nick = config.getstr('default_nick') if not nick: if default not in nicks: nicks.append(default) diff --git a/poezio/core/core.py b/poezio/core/core.py index 6372dd3e..93ea5c5b 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -95,9 +95,9 @@ class Core: self.connection_time = time.time() self.last_stream_error = None self.stdscr = None - status = config.get('status') + status = config.getstr('status') status = POSSIBLE_SHOW.get(status, None) - self.status = Status(show=status, message=config.get('status_message')) + self.status = Status(show=status, message=config.getstr('status_message')) self.running = True self.xmpp = connection.Connection() self.xmpp.core = self @@ -115,7 +115,7 @@ class Core: self.information_buffer = TextBuffer() self.information_win_size = cast( int, - config.get('info_win_height', section='var'), + config.getint('info_win_height', section='var'), ) self.information_win = windows.TextWin(300) self.information_buffer.add_window(self.information_win) @@ -134,10 +134,10 @@ class Core: self.tabs = Tabs(self.events) self.previous_tab_nb = 0 - own_nick = config.get('default_nick') + own_nick = config.getstr('default_nick') own_nick = own_nick or self.xmpp.boundjid.user own_nick = own_nick or os.environ.get('USER') - own_nick = own_nick or 'poezio' + own_nick = own_nick or 'poezio_user' self.own_nick = own_nick self.size = SizeManager(self) @@ -292,12 +292,12 @@ class Core: for name, handler in xmpp_event_handlers: self.xmpp.add_event_handler(name, handler) - if config.get('enable_avatars'): + if config.getbool('enable_avatars'): self.xmpp.add_event_handler("vcard_avatar_update", self.handler.on_vcard_avatar) self.xmpp.add_event_handler("avatar_metadata_publish", self.handler.on_0084_avatar) - if config.get('enable_user_nick'): + if config.getbool('enable_user_nick'): self.xmpp.add_event_handler("user_nick_publish", self.handler.on_nick_received) all_stanzas = Callback('custom matcher', connection.MatchAll(None), @@ -513,7 +513,7 @@ class Core: """ Load the plugins on startup. """ - plugins = config.get('plugins_autoload') + plugins = config.getstr('plugins_autoload') if ':' in plugins: for plugin in plugins.split(':'): self.plugin_manager.load(plugin, unload_first=False) @@ -609,7 +609,7 @@ class Core: except ValueError: pass else: - if self.tabs.current_tab.nb == nb and config.get( + if self.tabs.current_tab.nb == nb and config.getbool( 'go_to_previous_tab_on_alt_number'): self.go_to_previous_tab() else: @@ -722,9 +722,9 @@ class Core: work. If you try to do anything else, your |, [, <<, etc will be interpreted as normal command arguments, not shell special tokens. """ - if config.get('exec_remote'): + if config.getbool('exec_remote'): # We just write the command in the fifo - fifo_path = config.get('remote_fifo_path') + fifo_path = config.getstr('remote_fifo_path') filename = os.path.join(fifo_path, 'poezio.fifo') if not self.remote_fifo: try: @@ -818,7 +818,7 @@ class Core: or to use it when joining a new muc) """ self.status = Status(show=pres, message=msg) - if config.get('save_status'): + if config.getbool('save_status'): ok = config.silent_set('status', pres if pres else '') msg = msg.replace('\n', '|') if msg else '' ok = ok and config.silent_set('status_message', msg) @@ -1040,7 +1040,7 @@ class Core: returns False if it could not move the tab, True otherwise """ return self.tabs.insert_tab(old_pos, new_pos, - config.get('create_gaps')) + config.getbool('create_gaps')) ### Move actions (e.g. go to next room) ### @@ -1308,7 +1308,7 @@ class Core: tab.on_close() del tab.key_func # Remove self references del tab.commands # and make the object collectable - self.tabs.delete(tab, gap=config.get('create_gaps')) + self.tabs.delete(tab, gap=config.getbool('create_gaps')) logger.close(tab.name) if was_current: self.tabs.current_tab.on_gain_focus() @@ -1342,13 +1342,13 @@ class Core: """ Displays an informational message in the "Info" buffer """ - filter_types = config.get('information_buffer_type_filter').split(':') + filter_types = config.getlist('information_buffer_type_filter') if typ.lower() in filter_types: log.debug( 'Did not show the message:\n\t%s> %s \n\tdue to ' 'information_buffer_type_filter configuration', typ, msg) return False - filter_messages = config.get('filter_info_messages').split(':') + filter_messages = config.getlist('filter_info_messages') for words in filter_messages: if words and words in msg: log.debug( @@ -1364,11 +1364,11 @@ class Core: nick_color=color ) ) - popup_on = config.get('information_buffer_popup_on').split() + popup_on = config.getlist('information_buffer_popup_on') if isinstance(self.tabs.current_tab, tabs.RosterInfoTab): self.refresh_window() elif typ != '' and typ.lower() in popup_on: - popup_time = config.get('popup_time') + (nb_lines - 1) * 2 + popup_time = config.getint('popup_time') + (nb_lines - 1) * 2 self._pop_information_win_up(nb_lines, popup_time) else: if self.information_win_size != 0: @@ -1553,7 +1553,7 @@ class Core: """ Enable/disable the left panel. """ - enabled = config.get('enable_vertical_tab_list') + enabled = config.getbool('enable_vertical_tab_list') if not config.silent_set('enable_vertical_tab_list', str(not enabled)): self.information('Unable to write in the config file', 'Error') self.call_for_resize() @@ -1576,14 +1576,14 @@ class Core: Resize the GlobalInfoBar only once at each resize """ height, width = self.stdscr.getmaxyx() - if config.get('enable_vertical_tab_list'): + if config.getbool('enable_vertical_tab_list'): if self.size.core_degrade_x: return try: height, _ = self.stdscr.getmaxyx() truncated_win = self.stdscr.subwin( - height, config.get('vertical_tab_list_size'), 0, 0) + height, config.getint('vertical_tab_list_size'), 0, 0) except: log.error('Curses error on infobar resize', exc_info=True) return @@ -1609,11 +1609,13 @@ class Core: # the screen that they can occupy, and we draw the tab list on the # remaining space, on the left height, width = self.stdscr.getmaxyx() - if (config.get('enable_vertical_tab_list') + if (config.getbool('enable_vertical_tab_list') and not self.size.core_degrade_x): try: - scr = self.stdscr.subwin(0, - config.get('vertical_tab_list_size')) + scr = self.stdscr.subwin( + 0, + config.getint('vertical_tab_list_size') + ) except: log.error('Curses error on resize', exc_info=True) return @@ -1623,7 +1625,7 @@ class Core: self.resize_global_info_bar() self.resize_global_information_win() for tab in self.tabs: - if config.get('lazy_resize'): + if config.getbool('lazy_resize'): tab.need_resize = True else: tab.resize() @@ -1691,7 +1693,7 @@ class Core: def join_initial_rooms(self, bookmarks: List[Bookmark]): """Join all rooms given in the iterator `bookmarks`""" for bm in bookmarks: - if not (bm.autojoin or config.get('open_all_bookmarks')): + if not (bm.autojoin or config.getbool('open_all_bookmarks')): continue tab = self.tabs.by_name_and_class(bm.jid, tabs.MucTab) nick = bm.nick if bm.nick else self.own_nick @@ -1710,7 +1712,7 @@ class Core: self.bookmarks.available_storage['private'] = private self.bookmarks.available_storage['pep'] = pep_ - if not self.xmpp.anon and config.get('use_remote_bookmarks'): + if not self.xmpp.anon and config.getbool('use_remote_bookmarks'): try: await self.bookmarks.get_remote(self.xmpp, self.information) except IqError as error: @@ -1746,9 +1748,9 @@ class Core: msg = 'To provide a password in order to join the room, type "/join / password" (replace "password" by the real password)' tab.add_message(InfoMessage(msg), typ=2) if code == '409': - if config.get('alternative_nickname') != '': + if config.getstr('alternative_nickname') != '': if not tab.joined: - tab.own_nick += config.get('alternative_nickname') + tab.own_nick += config.getstr('alternative_nickname') tab.join() else: if not tab.joined: diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index ec714915..5fffbef8 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -94,7 +94,7 @@ class HandlerCore: rostertab.check_saslexternal(features) rostertab.check_blocking(features) self.core.check_blocking(features) - if (config.get('enable_carbons') + if (config.getbool('enable_carbons') and 'urn:xmpp:carbons:2' in features): self.core.xmpp.plugin['xep_0280'].enable() await self.core.check_bookmark_storage(features) @@ -230,7 +230,7 @@ class HandlerCore: if password: msg += ". The password is \"%s\"." % password self.core.information(msg, 'Info') - if 'invite' in config.get('beep_on').split(): + if 'invite' in config.getlist('beep_on'): curses.beep() logger.log_roster_change(inviter.full, 'invited you to %s' % jid.full) self.core.pending_invites[jid.bare] = inviter.full @@ -261,7 +261,7 @@ class HandlerCore: msg += "\nreason: %s" % reason self.core.information(msg, 'Info') - if 'invite' in config.get('beep_on').split(): + if 'invite' in config.getlist('beep_on'): curses.beep() self.core.pending_invites[room.bare] = inviter.full @@ -353,7 +353,7 @@ class HandlerCore: if conv_jid.bare in roster: remote_nick = roster[conv_jid.bare].name # check for a received nick - if not remote_nick and config.get('enable_user_nick'): + if not remote_nick and config.getbool('enable_user_nick'): if message.xml.find( '{http://jabber.org/protocol/nick}nick') is not None: remote_nick = message['nick']['nick'] @@ -425,7 +425,7 @@ class HandlerCore: typ=1, ) - if not own and 'private' in config.get('beep_on').split(): + if not own and 'private' in config.getlist('beep_on'): if not config.get_by_tabname('disable_beep', conv_jid.bare): curses.beep() if self.core.tabs.current_tab is not conversation: @@ -646,7 +646,7 @@ class HandlerCore: current.input.refresh() self.core.doupdate() - if 'message' in config.get('beep_on').split(): + if 'message' in config.getlist('beep_on'): if (not config.get_by_tabname('disable_beep', room_from) and self.core.own_nick != message['from'].resource): curses.beep() @@ -731,7 +731,7 @@ class HandlerCore: else: tab.last_remote_message = datetime.now() - if not sent and 'private' in config.get('beep_on').split(): + if not sent and 'private' in config.getlist('beep_on'): if not config.get_by_tabname('disable_beep', jid.full): curses.beep() if tab is self.core.tabs.current_tab: @@ -1095,14 +1095,14 @@ class HandlerCore: """ When we are disconnected from remote server """ - if 'disconnect' in config.get('beep_on').split(): + if 'disconnect' in config.getlist('beep_on'): curses.beep() # Stop the ping plugin. It would try to send stanza on regular basis self.core.xmpp.plugin['xep_0199'].disable_keepalive() msg_typ = 'Error' if not self.core.legitimate_disconnect else 'Info' self.core.information("Disconnected from server%s." % (event and ": %s" % event or ""), msg_typ) - if self.core.legitimate_disconnect or not config.get( - 'auto_reconnect', True): + if self.core.legitimate_disconnect or not config.getbool( + 'auto_reconnect'): return if (self.core.last_stream_error and self.core.last_stream_error[1]['condition'] in ( @@ -1166,7 +1166,7 @@ class HandlerCore: self.core.xmpp.get_roster() roster.update_contact_groups(self.core.xmpp.boundjid.bare) # send initial presence - if config.get('send_initial_presence'): + if config.getbool('send_initial_presence'): pres = self.core.xmpp.make_presence() pres['show'] = self.core.status.show pres['status'] = self.core.status.message @@ -1176,7 +1176,7 @@ class HandlerCore: # join all the available bookmarks. As of yet, this is just the local ones self.core.join_initial_rooms(self.core.bookmarks.local()) - if config.get('enable_user_nick'): + if config.getbool('enable_user_nick'): self.core.xmpp.plugin['xep_0172'].publish_nick( nick=self.core.own_nick, callback=dumb_callback) asyncio.ensure_future(self.core.xmpp.plugin['xep_0115'].update_caps()) @@ -1464,9 +1464,9 @@ class HandlerCore: """ Check the server certificate using the slixmpp ssl_cert event """ - if config.get('ignore_certificate'): + if config.getbool('ignore_certificate'): return - cert = config.get('certificate') + cert = config.getstr('certificate') # update the cert representation when it uses the old one if cert and ':' not in cert: cert = ':'.join( @@ -1608,7 +1608,7 @@ def _composing_tab_state(tab, state): else: return # should not happen - show = config.get('show_composing_tabs').lower() + show = config.getstr('show_composing_tabs').lower() show = show in values if tab.state != 'composing' and state == 'composing': |