Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
e7bc06ca
by Philipp Hörist at 2019-10-23T20:05:48Z
-
23448095
by Philipp Hörist at 2019-10-23T20:05:48Z
5 changed files:
- gajim/chat_control.py
- gajim/chat_control_base.py
- gajim/common/logger.py
- gajim/common/modules/receipts.py
- gajim/conversation_textview.py
Changes:
| ... | ... | @@ -1262,6 +1262,7 @@ class ChatControl(ChatControlBase): |
| 1262 | 1262 |
old_kind=local_old_kind,
|
| 1263 | 1263 |
xhtml=xhtml,
|
| 1264 | 1264 |
additional_data=additional_data,
|
| 1265 |
+ marker=row.marker,
|
|
| 1265 | 1266 |
error=row.error)
|
| 1266 | 1267 |
if row.message.startswith('/me ') or row.message.startswith('/me\n'):
|
| 1267 | 1268 |
local_old_kind = None
|
| ... | ... | @@ -991,7 +991,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 991 | 991 |
old_kind=None, xhtml=None,
|
| 992 | 992 |
displaymarking=None, msg_log_id=None,
|
| 993 | 993 |
message_id=None, correct_id=None, additional_data=None,
|
| 994 |
- encrypted=None, error=None):
|
|
| 994 |
+ encrypted=None, marker=None, error=None):
|
|
| 995 | 995 |
"""
|
| 996 | 996 |
Print 'chat' type messages
|
| 997 | 997 |
correct_id = (message_id, correct_id)
|
| ... | ... | @@ -1017,7 +1017,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 1017 | 1017 |
subject, old_kind, xhtml,
|
| 1018 | 1018 |
displaymarking=displaymarking, message_id=message_id,
|
| 1019 | 1019 |
correct_id=correct_id, additional_data=additional_data,
|
| 1020 |
- encrypted=encrypted, error=error)
|
|
| 1020 |
+ encrypted=encrypted, marker=marker, error=error)
|
|
| 1021 | 1021 |
|
| 1022 | 1022 |
if restored:
|
| 1023 | 1023 |
return
|
| ... | ... | @@ -195,12 +195,17 @@ def _convert_common_error(common_error): |
| 195 | 195 |
def _adapt_common_error(common_error):
|
| 196 | 196 |
return common_error.serialize()
|
| 197 | 197 |
|
| 198 |
+def _convert_marker(marker):
|
|
| 199 |
+ return 'received' if marker == 0 else 'displayed'
|
|
| 200 |
+ |
|
| 198 | 201 |
sqlite.register_converter('disco_info', _convert_disco_info)
|
| 199 | 202 |
sqlite.register_adapter(DiscoInfo, _adapt_disco_info)
|
| 200 | 203 |
|
| 201 | 204 |
sqlite.register_converter('common_error', _convert_common_error)
|
| 202 | 205 |
sqlite.register_adapter(CommonError, _adapt_common_error)
|
| 203 | 206 |
|
| 207 |
+sqlite.register_converter('marker', _convert_marker)
|
|
| 208 |
+ |
|
| 204 | 209 |
|
| 205 | 210 |
class Logger:
|
| 206 | 211 |
def __init__(self):
|
| ... | ... | @@ -799,7 +804,7 @@ class Logger: |
| 799 | 804 |
|
| 800 | 805 |
sql = '''
|
| 801 | 806 |
SELECT time, kind, message, error as "error [common_error]",
|
| 802 |
- subject, additional_data
|
|
| 807 |
+ subject, additional_data, marker as "marker [marker]"
|
|
| 803 | 808 |
FROM logs NATURAL JOIN jids WHERE jid IN ({jids}) AND
|
| 804 | 809 |
kind IN ({kinds}) AND time > get_timeout()
|
| 805 | 810 |
ORDER BY time DESC, log_line_id DESC LIMIT ? OFFSET ?
|
| ... | ... | @@ -1480,6 +1485,38 @@ class Logger: |
| 1480 | 1485 |
self._con.execute(sql, (error, account_id, jid_id, message_id))
|
| 1481 | 1486 |
self._timeout_commit()
|
| 1482 | 1487 |
|
| 1488 |
+ def set_marker(self, account_jid, jid, message_id, state):
|
|
| 1489 |
+ """
|
|
| 1490 |
+ Update the marker state of the corresponding message
|
|
| 1491 |
+ |
|
| 1492 |
+ :param account_jid: The jid of the account
|
|
| 1493 |
+ |
|
| 1494 |
+ :param jid: The jid that belongs to the avatar
|
|
| 1495 |
+ |
|
| 1496 |
+ :param message_id: The id of the message
|
|
| 1497 |
+ |
|
| 1498 |
+ :param state: The state, 'received' or 'displayed'
|
|
| 1499 |
+ |
|
| 1500 |
+ """
|
|
| 1501 |
+ if state not in ('received', 'displayed'):
|
|
| 1502 |
+ raise ValueError('Invalid marker state')
|
|
| 1503 |
+ |
|
| 1504 |
+ account_id = self.get_jid_id(account_jid)
|
|
| 1505 |
+ try:
|
|
| 1506 |
+ jid_id = self.get_jid_id(str(jid))
|
|
| 1507 |
+ except ValueError:
|
|
| 1508 |
+ # Unknown JID
|
|
| 1509 |
+ return
|
|
| 1510 |
+ |
|
| 1511 |
+ state = 0 if state == 'received' else 1
|
|
| 1512 |
+ |
|
| 1513 |
+ sql = '''
|
|
| 1514 |
+ UPDATE logs SET marker = ?
|
|
| 1515 |
+ WHERE account_id = ? AND jid_id = ? AND message_id = ?
|
|
| 1516 |
+ '''
|
|
| 1517 |
+ self._con.execute(sql, (state, account_id, jid_id, message_id))
|
|
| 1518 |
+ self._timeout_commit()
|
|
| 1519 |
+ |
|
| 1483 | 1520 |
def set_avatar_sha(self, account_jid, jid, sha=None):
|
| 1484 | 1521 |
"""
|
| 1485 | 1522 |
Set the avatar sha of a jid on an account
|
| ... | ... | @@ -68,6 +68,11 @@ class Receipts(BaseModule): |
| 68 | 68 |
if not properties.is_muc_pm:
|
| 69 | 69 |
jid.setBare()
|
| 70 | 70 |
|
| 71 |
+ app.logger.set_marker(app.get_jid_from_account(self._account),
|
|
| 72 |
+ jid,
|
|
| 73 |
+ properties.receipt.id,
|
|
| 74 |
+ 'received')
|
|
| 75 |
+ |
|
| 71 | 76 |
app.nec.push_incoming_event(
|
| 72 | 77 |
NetworkEvent('receipt-received',
|
| 73 | 78 |
account=self._account,
|
| ... | ... | @@ -405,13 +405,13 @@ class ConversationTextview(GObject.GObject): |
| 405 | 405 |
line = self._get_message_line(id_)
|
| 406 | 406 |
if line is None:
|
| 407 | 407 |
return
|
| 408 |
- line.show_receipt_icon()
|
|
| 408 |
+ line.set_receipt()
|
|
| 409 | 409 |
|
| 410 | 410 |
def show_error(self, id_, error):
|
| 411 | 411 |
line = self._get_message_line(id_)
|
| 412 | 412 |
if line is None:
|
| 413 | 413 |
return
|
| 414 |
- line.show_error_icon(to_user_string(error))
|
|
| 414 |
+ line.set_error(to_user_string(error))
|
|
| 415 | 415 |
|
| 416 | 416 |
def show_focus_out_line(self):
|
| 417 | 417 |
if not self.allow_focus_out_line:
|
| ... | ... | @@ -915,7 +915,7 @@ class ConversationTextview(GObject.GObject): |
| 915 | 915 |
other_tags_for_name=None, other_tags_for_time=None, other_tags_for_text=None,
|
| 916 | 916 |
subject=None, old_kind=None, xhtml=None, graphics=True,
|
| 917 | 917 |
displaymarking=None, message_id=None, correct_id=None, additional_data=None,
|
| 918 |
- encrypted=None, error=None):
|
|
| 918 |
+ encrypted=None, marker=None, error=None):
|
|
| 919 | 919 |
"""
|
| 920 | 920 |
Print 'chat' type messages
|
| 921 | 921 |
"""
|
| ... | ... | @@ -1047,11 +1047,14 @@ class ConversationTextview(GObject.GObject): |
| 1047 | 1047 |
message_line = MessageLine(message_id, tim, message_icons, new_mark)
|
| 1048 | 1048 |
|
| 1049 | 1049 |
if corrected:
|
| 1050 |
- message_line.show_correction_icon(
|
|
| 1050 |
+ message_line.set_correction(
|
|
| 1051 | 1051 |
self.corrected_text_list[message_id])
|
| 1052 | 1052 |
|
| 1053 | 1053 |
if error is not None:
|
| 1054 |
- message_line.show_error_icon(to_user_string(error))
|
|
| 1054 |
+ message_line.set_error(to_user_string(error))
|
|
| 1055 |
+ |
|
| 1056 |
+ if marker is not None:
|
|
| 1057 |
+ message_line.set_receipt()
|
|
| 1055 | 1058 |
|
| 1056 | 1059 |
if index is None:
|
| 1057 | 1060 |
# New Message
|
| ... | ... | @@ -1307,16 +1310,22 @@ class MessageLine: |
| 1307 | 1310 |
self.id = id_
|
| 1308 | 1311 |
self.timestamp = timestamp
|
| 1309 | 1312 |
self.start_mark = start_mark
|
| 1313 |
+ self._has_receipt = False
|
|
| 1310 | 1314 |
self._message_icons = message_icons
|
| 1311 | 1315 |
|
| 1312 |
- def show_receipt_icon(self):
|
|
| 1316 |
+ @property
|
|
| 1317 |
+ def has_receipt(self):
|
|
| 1318 |
+ return self._has_receipt
|
|
| 1319 |
+ |
|
| 1320 |
+ def set_receipt(self):
|
|
| 1321 |
+ self._has_receipt = True
|
|
| 1313 | 1322 |
self._message_icons.set_receipt_icon_visible(True)
|
| 1314 | 1323 |
|
| 1315 |
- def show_correction_icon(self, tooltip):
|
|
| 1324 |
+ def set_correction(self, tooltip):
|
|
| 1316 | 1325 |
self._message_icons.set_correction_icon_visible(True)
|
| 1317 | 1326 |
self._message_icons.set_correction_tooltip(tooltip)
|
| 1318 | 1327 |
|
| 1319 |
- def show_error_icon(self, tooltip):
|
|
| 1328 |
+ def set_error(self, tooltip):
|
|
| 1320 | 1329 |
self._message_icons.set_error_icon_visible(True)
|
| 1321 | 1330 |
self._message_icons.set_error_tooltip(tooltip)
|
| 1322 | 1331 |
|