Mercurial > libervia-web
annotate src/browser/sat_browser/chat.py @ 928:ee243d48100e
pages (common): added common hierarchy for reusable pages (blog is the first)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 16 Apr 2017 18:24:24 +0200 |
parents | 0c0551967bdf |
children | 5d9f6d25c586 |
rev | line source |
---|---|
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
818 | 5 # Copyright (C) 2011-2016 Jérôme Poisson <goffi@goffi.org> |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
10 # (at your option) any later version. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
15 # GNU Affero General Public License for more details. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
20 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
21 log = getLogger(__name__) |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
22 |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
23 # from sat_frontends.tools.games import SYMBOLS |
784
f3cd261ea12f
browser side: workaround for a pyjamas bug which freeze the browser in some case with addURLToText regex
Goffi <goffi@goffi.org>
parents:
779
diff
changeset
|
24 from sat_browser import strings |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
25 from sat_frontends.tools import jid |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
26 from sat_frontends.quick_frontend import quick_widgets, quick_games, quick_menus |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
27 from sat_frontends.quick_frontend.quick_chat import QuickChat |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
28 |
33 | 29 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from pyjamas.ui.VerticalPanel import VerticalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
32 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
33 from pyjamas.ui.HTMLPanel import HTMLPanel |
673
e489218886d7
browser_side: add attribute "merge_resources" to ContactsPanel to display the MUC occupants + override Chat.replaceUser and Chat.removeUser
souliane <souliane@mailoo.org>
parents:
672
diff
changeset
|
34 from pyjamas import DOM |
779
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
709
diff
changeset
|
35 from pyjamas import Window |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
36 |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
37 from datetime import datetime |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
38 |
467 | 39 import html_tools |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
40 import libervia_widget |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
41 import base_panel |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
42 import contact_panel |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
43 import editor_widget |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
44 from constants import Const as C |
467 | 45 import plugin_xep_0085 |
672
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
46 import game_tarot |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
47 import game_radiocol |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
48 |
279
2d6bd975a72d
browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents:
276
diff
changeset
|
49 |
624
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
50 unicode = str # FIXME: pyjamas workaround |
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
51 |
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
52 |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
53 class MessageWidget(HTMLPanel): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
54 |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
55 def __init__(self, mess_data): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
56 """ |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
57 @param mess_data(quick_chat.Message, None): message data |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
58 None: used only for non text widgets (e.g.: focus separator) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
59 """ |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
60 self.mess_data = mess_data |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
61 mess_data.widgets.add(self) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
62 _msg_class = [] |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
63 if mess_data.type == C.MESS_TYPE_INFO: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
64 markup = "<span class='{msg_class}'>{msg}</span>" |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
65 |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
66 if mess_data.extra.get('info_type') == 'me': |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
67 _msg_class.append('chatTextMe') |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
68 else: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
69 _msg_class.append('chatTextInfo') |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
70 # FIXME: following code was in printInfo before refactoring |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
71 # seems to be used only in radiocol |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
72 # elif type_ == 'link': |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
73 # _wid = HTML(msg) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
74 # _wid.setStyleName('chatTextInfo-link') |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
75 # if link_cb: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
76 # _wid.addClickListener(link_cb) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
77 else: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
78 markup = "<span class='chat_text_timestamp'>{timestamp}</span> <span class='chat_text_nick'>{nick}</span> <span class='{msg_class}'>{msg}</span>" |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
79 _msg_class.append("chat_text_msg") |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
80 if mess_data.own_mess: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
81 _msg_class.append("chat_text_mymess") |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
82 |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
83 xhtml = mess_data.main_message_xhtml |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
84 _date = datetime.fromtimestamp(float(mess_data.timestamp)) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
85 HTMLPanel.__init__(self, markup.format( |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
86 timestamp = _date.strftime("%H:%M"), |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
87 nick = "[{}]".format(html_tools.html_sanitize(mess_data.nick)), |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
88 msg_class = ' '.join(_msg_class), |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
89 msg = strings.addURLToText(html_tools.html_sanitize(mess_data.main_message)) if not xhtml else html_tools.inlineRoot(xhtml) # FIXME: images and external links must be removed according to preferences |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
90 )) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
91 if mess_data.type != C.MESS_TYPE_INFO: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
92 self.setStyleName('chatText') |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
93 |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
206
diff
changeset
|
94 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
95 class Chat(QuickChat, libervia_widget.LiberviaWidget, KeyboardHandler): |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
96 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
97 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
98 """Panel used for conversation (one 2 one or group chat) |
496
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
99 |
19 | 100 @param host: SatWebFrontend instance |
467 | 101 @param target: entity (jid.JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
102 @param type: one2one for simple conversation, group for MUC |
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
103 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
104 QuickChat.__init__(self, host, target, type_, profiles=profiles) |
34 | 105 self.vpanel = VerticalPanel() |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
206
diff
changeset
|
106 self.vpanel.setSize('100%', '100%') |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
534
diff
changeset
|
107 |
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
534
diff
changeset
|
108 # FIXME: temporary dirty initialization to display the OTR state |
663
423182fea41c
browser_side: fixes OTR using the new resource system and proper triggers (send and receive message) or listener (presence update)
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
109 header_info = host.plugins['otr'].getInfoTextForUser(target) if (type_ == C.CHAT_ONE2ONE and 'otr' in host.plugins) else None |
536
048ae7314156
browser_side: temporary way to display the OTR state in the LiberviaWidget header
souliane <souliane@mailoo.org>
parents:
534
diff
changeset
|
110 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
111 libervia_widget.LiberviaWidget.__init__(self, host, title=unicode(target.bare), info=header_info, selectable=True) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
112 self._body = AbsolutePanel() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
113 self._body.setStyleName('chatPanel_body') |
33 | 114 chat_area = HorizontalPanel() |
115 chat_area.setStyleName('chatArea') | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
116 if type_ == C.CHAT_GROUP: |
673
e489218886d7
browser_side: add attribute "merge_resources" to ContactsPanel to display the MUC occupants + override Chat.replaceUser and Chat.removeUser
souliane <souliane@mailoo.org>
parents:
672
diff
changeset
|
117 self.occupants_panel = contact_panel.ContactsPanel(host, merge_resources=False, |
671
2201ff543a05
browser_side: replace ContactsPanel and ContactBox init "parent" attribute with "host" + menus bound to the avatar can be parameterized
souliane <souliane@mailoo.org>
parents:
663
diff
changeset
|
118 contacts_style="muc_contact", |
2201ff543a05
browser_side: replace ContactsPanel and ContactBox init "parent" attribute with "host" + menus bound to the avatar can be parameterized
souliane <souliane@mailoo.org>
parents:
663
diff
changeset
|
119 contacts_menus=(C.MENU_JID_CONTEXT), |
2201ff543a05
browser_side: replace ContactsPanel and ContactBox init "parent" attribute with "host" + menus bound to the avatar can be parameterized
souliane <souliane@mailoo.org>
parents:
663
diff
changeset
|
120 contacts_display=('resource',)) |
660
267761bf7f08
browser side (contact list): ContactPanels is used instead of OccupantsList in MUC:
Goffi <goffi@goffi.org>
parents:
652
diff
changeset
|
121 chat_area.add(self.occupants_panel) |
673
e489218886d7
browser_side: add attribute "merge_resources" to ContactsPanel to display the MUC occupants + override Chat.replaceUser and Chat.removeUser
souliane <souliane@mailoo.org>
parents:
672
diff
changeset
|
122 DOM.setAttribute(chat_area.getWidgetTd(self.occupants_panel), "className", "occupantsPanelCell") |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
123 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword) |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
124 self.presenceListener = self.onPresenceUpdate |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
125 self.host.addListener('presence', self.presenceListener, [C.PROF_KEY_NONE]) |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
126 self.avatarListener = self.onAvatarUpdate |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
127 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE]) |
779
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
709
diff
changeset
|
128 Window.addWindowResizeListener(self) |
872
fa29524774d6
browser (chat): use new style bridge call for mucLeave
Goffi <goffi@goffi.org>
parents:
834
diff
changeset
|
129 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
130 self._body.add(chat_area) |
33 | 131 self.content = AbsolutePanel() |
132 self.content.setStyleName('chatContent') | |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
133 self.content_scroll = base_panel.ScrollPanelWrapper(self.content) |
34 | 134 chat_area.add(self.content_scroll) |
135 chat_area.setCellWidth(self.content_scroll, '100%') | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
136 self.vpanel.add(self._body) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
137 self.vpanel.setCellHeight(self._body, '100%') |
84 | 138 self.addStyleName('chatPanel') |
34 | 139 self.setWidget(self.vpanel) |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
140 self.chat_state_machine = plugin_xep_0085.ChatStateMachine(self.host, unicode(self.target)) |
696
c2f22ca12e23
browser and server side: remove unibox
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
141 |
c2f22ca12e23
browser and server side: remove unibox
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
142 self.message_box = editor_widget.MessageBox(self.host) |
c2f22ca12e23
browser and server side: remove unibox
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
143 self.message_box.onSelectedChange(self) |
c2f22ca12e23
browser and server side: remove unibox
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
144 self.message_box.addKeyboardListener(self) |
c2f22ca12e23
browser and server side: remove unibox
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
145 self.vpanel.add(self.message_box) |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
146 self.postInit() |
696
c2f22ca12e23
browser and server side: remove unibox
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
147 |
779
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
709
diff
changeset
|
148 def onWindowResized(self, width=None, height=None): |
833
4db064a70fc7
browser (chat): fixes resize callback for one2one conversation
souliane <souliane@mailoo.org>
parents:
818
diff
changeset
|
149 if self.type == C.CHAT_GROUP: |
4db064a70fc7
browser (chat): fixes resize callback for one2one conversation
souliane <souliane@mailoo.org>
parents:
818
diff
changeset
|
150 ideal_height = self.content_scroll.getOffsetHeight() |
4db064a70fc7
browser (chat): fixes resize callback for one2one conversation
souliane <souliane@mailoo.org>
parents:
818
diff
changeset
|
151 self.occupants_panel.setHeight("%s%s" % (ideal_height, "px")) |
779
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
709
diff
changeset
|
152 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
153 @property |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
154 def target(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
155 # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickChat |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
156 # FIXME: must remove this when either pyjamas is fixed, or we use an alternative |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
157 if self.type == C.CHAT_GROUP: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
158 return self.current_target.bare |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
159 return self.current_target |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
160 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
161 @property |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
162 def profile(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
163 # FIXME: for unknow reason, pyjamas doesn't use the method inherited from QuickWidget |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
164 # FIXME: must remove this when either pyjamas is fixed, or we use an alternative |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
165 assert len(self.profiles) == 1 and not self.PROFILES_MULTIPLE and not self.PROFILES_ALLOW_NONE |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
166 return list(self.profiles)[0] |
195 | 167 |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
168 @property |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
169 def plugin_menu_context(self): |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
170 return (C.MENU_ROOM,) if self.type == C.CHAT_GROUP else (C.MENU_SINGLE,) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
171 |
499
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
172 def onKeyDown(self, sender, keycode, modifiers): |
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
173 if keycode == KEY_ENTER: |
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
174 self.host.showWarning(None, None) |
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
175 else: |
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
176 self.host.showWarning(*self.getWarningData()) |
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
177 |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
178 def getWarningData(self): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
179 if self.type not in [C.CHAT_ONE2ONE, C.CHAT_GROUP]: |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
180 raise Exception("Unmanaged type !") |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
181 if self.type == C.CHAT_ONE2ONE: |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
182 msg = "This message will be sent to your contact <span class='warningTarget'>%s</span>" % self.target |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
183 elif self.type == C.CHAT_GROUP: |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
184 msg = "This message will be sent to all the participants of the multi-user room <span class='warningTarget'>%s</span>" % self.target |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
185 return ("ONE2ONE" if self.type == C.CHAT_ONE2ONE else "GROUP", msg) |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
186 |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
187 def onTextEntered(self, text): |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
872
diff
changeset
|
188 self.host.messageSend(self.target, |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
872
diff
changeset
|
189 {'': text}, |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
872
diff
changeset
|
190 {}, |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
872
diff
changeset
|
191 C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
872
diff
changeset
|
192 {}, |
663
423182fea41c
browser_side: fixes OTR using the new resource system and proper triggers (send and receive message) or listener (presence update)
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
193 errback=self.host.sendError, |
423182fea41c
browser_side: fixes OTR using the new resource system and proper triggers (send and receive message) or listener (presence update)
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
194 profile_key=C.PROF_KEY_NONE |
423182fea41c
browser_side: fixes OTR using the new resource system and proper triggers (send and receive message) or listener (presence update)
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
195 ) |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
196 self.chat_state_machine._onEvent("active") |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
197 |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
198 def onPresenceUpdate(self, entity, show, priority, statuses, profile): |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
199 """Update entity's presence status |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
200 |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
201 @param entity(jid.JID): entity updated |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
202 @param show: availability |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
203 @parap priority: resource's priority |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
204 @param statuses: dict of statuses |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
205 @param profile: %(doc_profile)s |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
206 """ |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
207 assert self.type == C.CHAT_GROUP |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
208 if entity.bare != self.target: |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
209 return |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
210 self.update(entity) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
211 |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
212 def onAvatarUpdate(self, entity, hash_, profile): |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
213 """Called on avatar update events |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
214 |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
215 @param jid_: jid of the entity with updated avatar |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
216 @param hash_: hash of the avatar |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
217 @param profile: %(doc_profile)s |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
218 """ |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
219 assert self.type == C.CHAT_GROUP |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
220 if entity.bare != self.target: |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
221 return |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
222 self.update(entity) |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
223 |
179
8475a29d7214
closing a group chat widget now leave the muc room (bug 11)
Goffi <goffi@goffi.org>
parents:
178
diff
changeset
|
224 def onQuit(self): |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
225 libervia_widget.LiberviaWidget.onQuit(self) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
226 if self.type == C.CHAT_GROUP: |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
227 self.host.removeListener('presence', self.presenceListener) |
872
fa29524774d6
browser (chat): use new style bridge call for mucLeave
Goffi <goffi@goffi.org>
parents:
834
diff
changeset
|
228 self.host.bridge.mucLeave(self.target.bare, profile=C.PROF_KEY_NONE) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
229 |
709
78e4a79fbb5e
browser_side: fix updating OTR icons when state or trust has changed
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
230 def newMessage(self, from_jid, target, msg, type_, extra, profile): |
78e4a79fbb5e
browser_side: fix updating OTR icons when state or trust has changed
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
231 header_info = extra.pop('header_info', None) |
78e4a79fbb5e
browser_side: fix updating OTR icons when state or trust has changed
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
232 if header_info: |
78e4a79fbb5e
browser_side: fix updating OTR icons when state or trust has changed
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
233 self.setHeaderInfo(header_info) |
78e4a79fbb5e
browser_side: fix updating OTR icons when state or trust has changed
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
234 QuickChat.newMessage(self, from_jid, target, msg, type_, extra, profile) |
78e4a79fbb5e
browser_side: fix updating OTR icons when state or trust has changed
souliane <souliane@mailoo.org>
parents:
697
diff
changeset
|
235 |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
236 def _onHistoryPrinted(self): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
237 """Refresh or scroll down the focus after the history is printed""" |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
238 self.printMessages(clear=False) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
239 super(Chat, self)._onHistoryPrinted() |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
240 |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
241 def printMessages(self, clear=True): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
242 """generate message widgets |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
243 |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
244 @param clear(bool): clear message before printing if true |
35 | 245 """ |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
246 if clear: |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
247 # FIXME: clear is not handler |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
248 pass |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
249 for message in self.messages.itervalues(): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
250 self.appendMessage(message) |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
251 |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
252 def createMessage(self, message): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
253 self.appendMessage(message) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
254 |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
255 def appendMessage(self, message): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
256 self.content.add(MessageWidget(message)) |
34 | 257 self.content_scroll.scrollToBottom() |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
258 |
834
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
259 def notify(self, contact="somebody", msg=""): |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
260 """Notify the user of a new message if primitivus doesn't have the focus. |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
261 |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
262 @param contact (unicode): contact who wrote to the users |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
263 @param msg (unicode): the message that has been received |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
264 """ |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
265 self.host.notification.notify(contact, msg) |
2491898b3041
browser (chat, notification): remove the textual alerts counter, merge it with the favicon counter
souliane <souliane@mailoo.org>
parents:
833
diff
changeset
|
266 |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
267 # def printDayChange(self, day): |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
268 # """Display the day on a new line. |
808
9e1e6d5241f9
browser_side: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents:
807
diff
changeset
|
269 |
914
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
270 # @param day(unicode): day to display (or not if this method is not overwritten) |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
271 # """ |
0c0551967bdf
server, browser: partial Libervia fix
Goffi <goffi@goffi.org>
parents:
909
diff
changeset
|
272 # self.printInfo("* " + day) |
808
9e1e6d5241f9
browser_side: restore printing the day change while displaying history
souliane <souliane@mailoo.org>
parents:
807
diff
changeset
|
273 |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
274 def setTitle(self, title=None, extra=None): |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
275 """Refresh the title of this Chat dialog |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
276 |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
277 @param title (unicode): main title or None to use default |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
278 @param suffix (unicode): extra title (e.g. for chat states) or None |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
279 """ |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
280 if title is None: |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
281 title = unicode(self.target.bare) |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
282 if extra: |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
283 title += ' %s' % extra |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
284 libervia_widget.LiberviaWidget.setTitle(self, title) |
407
6a6551de4414
browser_side: display chat states (with symbols) for MUC participants
souliane <souliane@mailoo.org>
parents:
404
diff
changeset
|
285 |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
286 def update(self, entity=None): |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
287 """Update one or all entities. |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
288 |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
289 @param entity (jid.JID): entity to update |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
290 """ |
687
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
291 states = self.getEntityStates(self.target) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
292 if self.type == C.CHAT_ONE2ONE: # only update the chat title |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
293 self.setTitle(extra=' '.join([u'({})'.format(value) for value in states.values()])) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
294 else: |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
295 if entity is None: # rebuild all the occupants list |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
296 nicks = list(self.occupants) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
297 nicks.sort() |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
298 self.occupants_panel.setList([jid.newResource(self.target, nick) for nick in nicks]) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
299 else: # add, remove or update only one occupant |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
300 contact_list = self.host.contact_lists[self.profile] |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
301 show = contact_list.getCache(entity, C.PRESENCE_SHOW) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
302 if show == C.PRESENCE_UNAVAILABLE or show is None: |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
303 self.occupants_panel.removeContactBox(entity) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
304 else: |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
305 box = self.occupants_panel.updateContactBox(entity) |
3845a086f0b3
browser_side: update ContactList, Chat, ContactsPanel, ContactBox, ContactLabel to update the display using listeners as it is done in quick_frontend:
souliane <souliane@mailoo.org>
parents:
685
diff
changeset
|
306 box.states.setHTML(u''.join(states.values())) |
684
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
307 |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
308 if 'chat_state' in states.keys(): # start/stop sending "composing" state from now |
e876f493dccc
browser_side: follow changes made on quick_frontend for chat states and MUC symbols + minor fixes following the refactorisation:
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
309 self.chat_state_machine.started = not not states['chat_state'] |
33 | 310 |
779
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
709
diff
changeset
|
311 self.onWindowResized() # be sure to set the good height |
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
709
diff
changeset
|
312 |
672
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
313 def addGamePanel(self, widget): |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
314 """Insert a game panel to this Chat dialog. |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
315 |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
316 @param widget (Widget): the game panel |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
317 """ |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
318 self.vpanel.insert(widget, 0) |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
319 self.vpanel.setCellHeight(widget, widget.getHeight()) |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
320 |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
321 def removeGamePanel(self, widget): |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
322 """Remove the game panel from this Chat dialog. |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
323 |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
324 @param widget (Widget): the game panel |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
325 """ |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
326 self.vpanel.remove(widget) |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
327 |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
328 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
329 quick_widgets.register(QuickChat, Chat) |
672
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
330 quick_widgets.register(quick_games.Tarot, game_tarot.TarotPanel) |
b39a9eddfe56
browser_side: fixes room games:
souliane <souliane@mailoo.org>
parents:
671
diff
changeset
|
331 quick_widgets.register(quick_games.Radiocol, game_radiocol.RadioColPanel) |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
624
diff
changeset
|
332 libervia_widget.LiberviaWidget.addDropKey("CONTACT", lambda host, item: host.displayWidget(Chat, jid.JID(item), dropped=True)) |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
333 quick_menus.QuickMenusManager.addDataCollector(C.MENU_ROOM, {'room_jid': 'target'}) |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
334 quick_menus.QuickMenusManager.addDataCollector(C.MENU_SINGLE, {'jid': 'target'}) |