summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/tabs/basetabs.py15
-rw-r--r--poezio/tabs/muctab.py4
-rw-r--r--poezio/windows/data_forms.py49
3 files changed, 43 insertions, 25 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 98f4c977..3a898129 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -431,17 +431,20 @@ class ChatTab(Tab):
"""
plugin_commands = {}
plugin_keys = {}
+ message_type = 'chat'
def __init__(self, core, jid=''):
Tab.__init__(self, core)
self.name = jid
self.text_win = None
+ self.remote_wants_chatstates = False
+ self.directed_presence = None
self._text_buffer = TextBuffer()
self.chatstate = None # can be "active", "composing", "paused", "gone", "inactive"
# We keep a reference of the event that will set our chatstate to "paused", so that
# we can delete it or change it if we need to
self.timed_event_paused = None
# Keeps the last sent message to complete it easily in completion_correct, and to replace it.
- self.last_sent_message = None
+ self.last_sent_message = {}
self.key_func['M-v'] = self.move_separator
self.key_func['M-h'] = self.scroll_separator
self.key_func['M-/'] = self.last_words_completion
@@ -474,6 +477,10 @@ class ChatTab(Tab):
def is_muc(self):
return False
+ @property
+ def general_jid(self):
+ return NotImplementedError
+
def load_logs(self, log_nb):
logs = logger.get_logs(safeJID(self.name).bare, log_nb)
return logs
@@ -573,11 +580,15 @@ class ChatTab(Tab):
self._text_buffer.messages = []
self.text_win.rebuild_everything(self._text_buffer)
+ def check_send_chat_state(self):
+ "If we should send a chat state"
+ return True
+
def send_chat_state(self, state, always_send=False):
"""
Send an empty chatstate message
"""
- if not self.is_muc or self.joined:
+ if self.check_send_chat_state():
if state in ('active', 'inactive', 'gone') and self.inactive and not always_send:
return
if (config.get_by_tabname('send_chat_states', self.general_jid)
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index 2942ba77..ce43dd0e 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -208,6 +208,10 @@ class MucTab(ChatTab):
def is_muc(self):
return True
+ def check_send_chat_state(self):
+ "If we should send a chat state"
+ return self.joined
+
@property
def last_connection(self):
last_message = self._text_buffer.last_message
diff --git a/poezio/windows/data_forms.py b/poezio/windows/data_forms.py
index 129abe9c..a14418d7 100644
--- a/poezio/windows/data_forms.py
+++ b/poezio/windows/data_forms.py
@@ -22,15 +22,9 @@ class FieldInput(object):
self._field = field
self.color = get_theme().COLOR_NORMAL_TEXT
- def set_color(self, color):
- self.color = color
- self.refresh()
-
def update_field_value(self, value):
raise NotImplementedError
- def resize(self, height, width, y, x):
- self._resize(height, width, y, x)
def is_dummy(self):
return False
@@ -48,6 +42,20 @@ class FieldInput(object):
"""
return ''
+class FieldInputMixin(FieldInput, Win):
+ "Mix both FieldInput and Win"
+ def __init__(self, field):
+ FieldInput.__init__(self, field)
+ Win.__init__(self)
+
+ def resize(self, height, width, y, x):
+ self._resize(height, width, y, x)
+
+ def set_color(self, color):
+ self.color = color
+ self.refresh()
+
+
class ColoredLabel(Win):
def __init__(self, text):
self.text = text
@@ -69,13 +77,12 @@ class ColoredLabel(Win):
self._refresh()
-class DummyInput(FieldInput, Win):
+class DummyInput(FieldInputMixin):
"""
Used for fields that do not require any input ('fixed')
"""
def __init__(self, field):
- FieldInput.__init__(self, field)
- Win.__init__(self)
+ FieldInputMixin.__init__(self, field)
def do_command(self, *args, **kwargs):
return
@@ -86,10 +93,9 @@ class DummyInput(FieldInput, Win):
def is_dummy(self):
return True
-class BooleanWin(FieldInput, Win):
+class BooleanWin(FieldInputMixin):
def __init__(self, field):
- FieldInput.__init__(self, field)
- Win.__init__(self)
+ FieldInputMixin.__init__(self, field)
self.last_key = 'KEY_RIGHT'
self.value = bool(field.get_value())
@@ -120,10 +126,9 @@ class BooleanWin(FieldInput, Win):
def get_help_message(self):
return '← and →: change the value between True and False'
-class TextMultiWin(FieldInput, Win):
+class TextMultiWin(FieldInputMixin):
def __init__(self, field):
- FieldInput.__init__(self, field)
- Win.__init__(self)
+ FieldInputMixin.__init__(self, field)
options = field.get_value()
if isinstance(options, list):
self.options = options
@@ -197,10 +202,9 @@ class TextMultiWin(FieldInput, Win):
help_msg = 'Enter: finish editing this entry.'
return help_msg
-class ListMultiWin(FieldInput, Win):
+class ListMultiWin(FieldInputMixin):
def __init__(self, field):
- FieldInput.__init__(self, field)
- Win.__init__(self)
+ FieldInputMixin.__init__(self, field)
values = field.get_value() or []
self.options = [[option, True if option['value'] in values else False]\
for option in field.get_options()]
@@ -243,10 +247,9 @@ class ListMultiWin(FieldInput, Win):
def get_help_message(self):
return '←, →: Switch between the value. Space: select or unselect a value'
-class ListSingleWin(FieldInput, Win):
+class ListSingleWin(FieldInputMixin):
def __init__(self, field):
- FieldInput.__init__(self, field)
- Win.__init__(self)
+ FieldInputMixin.__init__(self, field)
# the option list never changes
self.options = field.get_options()
# val_pos is the position of the currently selected option
@@ -288,9 +291,9 @@ class ListSingleWin(FieldInput, Win):
def get_help_message(self):
return '←, →: Select a value amongst the others'
-class TextSingleWin(FieldInput, Input):
+class TextSingleWin(FieldInputMixin, Input):
def __init__(self, field):
- FieldInput.__init__(self, field)
+ FieldInputMixin.__init__(self, field)
Input.__init__(self)
self.text = field.get_value() if isinstance(field.get_value(), str)\
else ""