diff options
-rw-r--r-- | src/common.py | 1 | ||||
-rw-r--r-- | src/connection.py | 1 | ||||
-rw-r--r-- | src/core.py | 19 | ||||
-rw-r--r-- | src/keyboard.py | 2 | ||||
-rw-r--r-- | src/logger.py | 1 | ||||
-rw-r--r-- | src/multiuserchat.py | 4 | ||||
-rw-r--r-- | src/roster.py | 2 | ||||
-rw-r--r-- | src/tabs.py | 28 | ||||
-rw-r--r-- | src/theming.py | 11 | ||||
-rw-r--r-- | src/user.py | 5 | ||||
-rw-r--r-- | src/windows.py | 16 |
11 files changed, 40 insertions, 50 deletions
diff --git a/src/common.py b/src/common.py index 11a09b93..7e1c0642 100644 --- a/src/common.py +++ b/src/common.py @@ -15,7 +15,6 @@ import os import mimetypes import hashlib import subprocess -import curses import time import shlex diff --git a/src/connection.py b/src/connection.py index 7246ae1e..f407dfe9 100644 --- a/src/connection.py +++ b/src/connection.py @@ -15,7 +15,6 @@ log = logging.getLogger(__name__) from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) -import sys import getpass import sleekxmpp diff --git a/src/core.py b/src/core.py index f92e2730..afdd1c14 100644 --- a/src/core.py +++ b/src/core.py @@ -8,7 +8,6 @@ from gettext import gettext as _ import os -import re import sys import time import curses @@ -44,8 +43,7 @@ from plugin_manager import PluginManager from data_forms import DataFormsTab from config import config, options from logger import logger -from user import User -from roster import Roster, RosterGroup, roster +from roster import roster from contact import Contact, Resource from text_buffer import TextBuffer from keyboard import read_char @@ -381,6 +379,8 @@ class Core(object): if not contact.get_highest_priority_resource(): # No resource left: that was the last one self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x191}offline' % (jid.bare)) self.information('\x193}%s \x195}is \x191}offline' % (resource.get_jid().bare), "Roster") + if isinstance(self.current_tab(), tabs.RosterInfoTab): + self.refresh_window() def on_got_online(self, presence): jid = presence['from'] @@ -403,9 +403,14 @@ class Core(object): # No connected resource yet: the user's just connecting if time.time() - self.connection_time > 12: # We do not display messages if we recently logged in - self.information("\x193}%s \x195}is \x194}online\x195} (\x190}%s\x195})" % (resource.get_jid().bare, status), "Roster") + if status_message: + self.information("\x193}%s \x195}is \x194}online\x195} (\x19o%s\x195})" % (resource.get_jid().bare, status_message), "Roster") + else: + self.information("\x193}%s \x195}is \x194}online\x195}" % resource.get_jid().bare, "Roster") self.add_information_message_to_conversation_tab(jid.bare, '\x195}%s is \x194}online' % (jid.bare)) contact.add_resource(resource) + if isinstance(self.current_tab(), tabs.RosterInfoTab): + self.refresh_window() def add_information_message_to_conversation_tab(self, jid, msg): """ @@ -1219,7 +1224,9 @@ class Core(object): self.xmpp.plugin['xep_0030'].get_items(jid=server, block=False, callback=list_tab.on_muc_list_item_received) def command_theme(self, arg): - theming.reload_theme() + warning = theming.reload_theme() + if warning: + self.information(warning, 'Warning') self.refresh_window() def command_win(self, arg): @@ -1286,7 +1293,6 @@ class Core(object): the_input.auto_completion(items, '') else: # we are writing the server: complete the server - serv = jid.server serv_list = [] for tab in self.tabs: if isinstance(tab, tabs.MucTab): @@ -1295,7 +1301,6 @@ class Core(object): return True def completion_list(self, the_input): - txt = the_input.get_text() muc_serv_list = [] for tab in self.tabs: # TODO, also from an history if isinstance(tab, tabs.MucTab) and\ diff --git a/src/keyboard.py b/src/keyboard.py index 99173f40..c8f4b60c 100644 --- a/src/keyboard.py +++ b/src/keyboard.py @@ -12,8 +12,6 @@ of the time ONE char, but may be longer if it's a keyboard shortcut, like ^A, M-a or KEY_RESIZE) """ -import time - def get_next_byte(s): """ Read the next byte of the utf-8 char diff --git a/src/logger.py b/src/logger.py index e8a29a3f..bd24eb3b 100644 --- a/src/logger.py +++ b/src/logger.py @@ -5,7 +5,6 @@ # Poezio is free software: you can redistribute it and/or modify # it under the terms of the zlib license. See the COPYING file. -import sys from os import environ, makedirs import os from datetime import datetime diff --git a/src/multiuserchat.py b/src/multiuserchat.py index ac910837..f537c2c1 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -11,8 +11,6 @@ Add some facilities that are not available on the XEP_0045 sleek plugin """ -import sleekxmpp - from xml.etree import cElementTree as ET import logging @@ -68,7 +66,7 @@ def leave_groupchat(xmpp, jid, own_nick, msg): try: xmpp.plugin['xep_0045'].leaveMUC(jid, own_nick, msg) except KeyError: - log.debug("WARNING: in muc.leave_groupchat: could not leave the room") + log.debug("muc.leave_groupchat: could not leave the room %s" % jid) def set_user_role(xmpp, jid, nick, reason, role): """ diff --git a/src/roster.py b/src/roster.py index 4ef2da1b..df84d4d8 100644 --- a/src/roster.py +++ b/src/roster.py @@ -14,7 +14,7 @@ log = logging.getLogger(__name__) from config import config from os import path as p -from contact import Contact, Resource +from contact import Contact from sleekxmpp.xmlstream.stanzabase import JID class Roster(object): diff --git a/src/tabs.py b/src/tabs.py index eaa7c375..e5df2e7d 100644 --- a/src/tabs.py +++ b/src/tabs.py @@ -24,7 +24,6 @@ from gettext import gettext as _ import windows import curses import difflib -import text_buffer import string import common import core @@ -40,7 +39,7 @@ from theming import get_theme from sleekxmpp.xmlstream.stanzabase import JID from config import config from roster import RosterGroup, roster -from contact import Contact, Resource +from contact import Contact from text_buffer import TextBuffer from user import User from os import getenv, path @@ -119,13 +118,12 @@ class Tab(object): @state.setter def state(self, value): if not value in STATE_COLORS: - log.debug("WARNING: invalid value for tab state") - return + log.debug("Invalid value for tab state: %s" % value) elif STATE_PRIORITY[value] < STATE_PRIORITY[self._state] and \ value != 'current': - log.debug("WARNING: did not set status because of lower priority") - return - self._state = value + log.debug("Did not set status because of lower priority, asked: %s, kept: %s" % (value, self.state)) + else: + self._state = value @staticmethod def resize(scr): @@ -568,9 +566,9 @@ class MucTab(ChatTab): """ args = arg.split() if len(args): - msg = ' '.join(args) + arg = ' '.join(args) else: - msg = None + arg = None if self.joined: muc.leave_groupchat(self.core.xmpp, self.name, self.own_nick, arg) self.add_message(_("\x195}You left the chatroom\x193}")) @@ -938,7 +936,7 @@ class MucTab(ChatTab): self.add_message('\x194}%(spec)s \x19%(color)d}%(nick)s\x195} joined the room' % {'nick':from_nick, 'color':color, 'spec':get_theme().CHAR_JOIN}) else: self.add_message('\x194}%(spec)s \x19%(color)d}%(nick)s \x195}(\x194}%(jid)s\x195}) joined the room' % {'spec':get_theme().CHAR_JOIN, 'nick':from_nick, 'color':color, 'jid':jid.full}) - self.core.on_user_rejoined_private_conversation(room.name, from_nick) + self.core.on_user_rejoined_private_conversation(self.name, from_nick) def on_user_nick_change(self, presence, user, from_nick, from_room): new_nick = presence.find('{%s}x/{%s}item' % (NS_MUC_USER, NS_MUC_USER)).attrib['nick'] @@ -1355,12 +1353,12 @@ class PrivateTab(ChatTab): """ self.activate() tab = self.core.get_tab_by_name(JID(self.name).bare, MucTab) - color = None - if tab: + color = 3 + if tab and config.get('display_user_color_in_join_part', ''): user = tab.get_user_by_name(nick) if user: - color = user.color - self.add_message('\x194}%(spec)s \x19%(color)d}%(nick)s\x195} joined the room' % {'nick':nick, 'color': color or 3, 'spec':get_theme().CHAR_JOIN}) + color = user.color[0] + self.add_message('\x194}%(spec)s \x19%(color)d}%(nick)s\x195} joined the room' % {'nick':nick, 'color': color, 'spec':get_theme().CHAR_JOIN}) if self.core.current_tab() is self: self.refresh() self.core.doupdate() @@ -1468,6 +1466,7 @@ class RosterInfoTab(Tab): self.core.information(_('No JID specified'), 'Error') return self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') + self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') def command_name(self, args): """ @@ -1695,7 +1694,6 @@ class RosterInfoTab(Tab): else: jid = args[0] self.core.xmpp.sendPresence(pto=jid, ptype='subscribed') - self.core.xmpp.sendPresence(pto=jid, ptype='subscribe') def refresh(self): if self.need_resize: diff --git a/src/theming.py b/src/theming.py index 4bfdad42..0a7ab22d 100644 --- a/src/theming.py +++ b/src/theming.py @@ -240,16 +240,17 @@ def reload_theme(): os.makedirs(themes_dir) except OSError: pass - theme_name = config.get('theme', '') - if not theme_name: + theme_name = config.get('theme', 'default') + global theme + if theme_name == 'default' or not theme_name.strip(): + theme = Theme() return try: file_path = os.path.join(themes_dir, theme_name)+'.py' log.debug('Theme file to load: %s' %(file_path,)) new_theme = imp.load_source('theme', os.path.join(themes_dir, theme_name)+'.py') - except: # TODO warning: theme not found - return - global theme + except: + return 'Theme not found' theme = new_theme.theme if __name__ == '__main__': diff --git a/src/user.py b/src/user.py index 5867e1f3..0d29569f 100644 --- a/src/user.py +++ b/src/user.py @@ -10,10 +10,7 @@ Define the user class. An user is a MUC participant, not a roster contact (see contact.py) """ -import curses - -from random import randrange, choice -from config import config +from random import choice from datetime import timedelta, datetime from theming import get_theme diff --git a/src/windows.py b/src/windows.py index 1ff8f858..9fa3e705 100644 --- a/src/windows.py +++ b/src/windows.py @@ -14,26 +14,23 @@ A Tab (see tab.py) is composed of multiple Windows from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) -from os.path import isfile import logging log = logging.getLogger(__name__) -import shlex import curses import string from config import config from threading import RLock -from contact import Contact, Resource -from roster import RosterGroup, roster +from contact import Contact +from roster import RosterGroup from poopt import cut_text from sleekxmpp.xmlstream.stanzabase import JID import core -import common import wcwidth import singleton import collections @@ -1472,11 +1469,9 @@ class RosterWin(Win): if not resource: # There's no online resource presence = 'unavailable' - folder = ' ' nb = '' else: presence = resource.get_presence() - folder = '[+]' if contact._folded else '[-]' nb = ' (%s)' % (contact.get_nb_resources(),) color = RosterWin.color_show[presence] if contact.get_name(): @@ -1520,11 +1515,11 @@ class ContactInfoWin(Win): """ draw the contact information """ + resource = contact.get_highest_priority_resource() if contact: jid = contact.get_bare_jid() else: jid = jid or resource.get_jid().full - resource = contact.get_highest_priority_resource() if resource: presence = resource.get_presence() else: @@ -1533,10 +1528,11 @@ class ContactInfoWin(Win): self.finish_line(get_theme().COLOR_INFORMATION_BAR) self.addstr(1, 0, 'Subscription: %s' % (contact.get_subscription(),)) if contact.get_ask(): + self.addstr(' ') if contact.get_ask() == 'asked': - self.addstr(' Ask: %s' % (contact.get_ask(),), to_curses_attr(get_theme().COLOR_HIGHLIGHT_NICK)) + self.addstr('Ask: %s' % (contact.get_ask(),), to_curses_attr(get_theme().COLOR_HIGHLIGHT_NICK)) else: - self.addstr(' Ask: %s' % (contact.get_ask(),)) + self.addstr('Ask: %s' % (contact.get_ask(),)) self.finish_line() |