Mercurial > libervia-web
annotate src/browser/sat_browser/contact_panel.py @ 715:b2465423c76e
revert change on setup.py that was commited by accident
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 28 Jul 2015 22:22:10 +0200 |
parents | e86490a7c76e |
children | 102bab805ec1 |
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:
323
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
685 | 5 # Copyright (C) 2011, 2012, 2013, 2014, 2015 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:
323
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:
323
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:
323
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:
323
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:
323
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:
323
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:
323
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:
323
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:
323
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:
323
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 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
20 """ Contacts / jids related panels """ |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
21 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
22 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
23 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
24 log = getLogger(__name__) |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
25 from sat_frontends.tools import jid |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
26 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from pyjamas.ui.VerticalPanel import VerticalPanel |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
28 |
467 | 29 import html_tools |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
30 import contact_widget |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
412
diff
changeset
|
31 from constants import Const as C |
20 | 32 |
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
|
33 |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
34 class ContactsPanel(VerticalPanel): |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
35 """ContactList graphic representation |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
36 |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
37 Special features like popup menu panel or changing the contact states must be done in a sub-class. |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
38 """ |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
39 |
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:
671
diff
changeset
|
40 def __init__(self, host, merge_resources=True, contacts_click=None, |
692
7a9c7b9f6a28
browser_side: use host.default_muc instead of C.DEFAULT_MUC
souliane <souliane@mailoo.org>
parents:
687
diff
changeset
|
41 contacts_style=None, contacts_menus=None, |
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:
671
diff
changeset
|
42 contacts_display=C.CONTACT_DEFAULT_DISPLAY): |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
43 """ |
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:
660
diff
changeset
|
44 |
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:
660
diff
changeset
|
45 @param host (SatWebFrontend): host instance |
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:
671
diff
changeset
|
46 @param merge_resources (bool): if True, the entities sharing the same |
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:
671
diff
changeset
|
47 bare JID will also share the same contact box. |
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:
660
diff
changeset
|
48 @param contacts_click (callable): click callback for the contact boxes |
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:
660
diff
changeset
|
49 @param contacts_style (unicode): CSS style name for the contact boxes |
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:
660
diff
changeset
|
50 @param contacts_menus (tuple): define the menu types that fit this |
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:
660
diff
changeset
|
51 contact panel, with values from the menus type constants. |
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:
660
diff
changeset
|
52 @param contacts_display (tuple): prioritize the display methods of the |
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:
660
diff
changeset
|
53 contact's label with values in ("jid", "nick", "bare", "resource") |
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:
660
diff
changeset
|
54 """ |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
55 VerticalPanel.__init__(self) |
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:
660
diff
changeset
|
56 self.host = host |
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:
671
diff
changeset
|
57 self.merge_resources = merge_resources |
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:
660
diff
changeset
|
58 self._contacts = {} # entity jid to ContactBox map |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
59 self.click_listener = None |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
60 |
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:
660
diff
changeset
|
61 if contacts_click is not None: |
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:
660
diff
changeset
|
62 self.onClick = contacts_click |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
63 |
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:
660
diff
changeset
|
64 self.contacts_style = contacts_style |
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:
660
diff
changeset
|
65 self.contacts_menus = contacts_menus |
660
267761bf7f08
browser side (contact list): ContactPanels is used instead of OccupantsList in MUC:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
66 self.contacts_display = contacts_display |
267761bf7f08
browser side (contact list): ContactPanels is used instead of OccupantsList in MUC:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
67 |
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:
671
diff
changeset
|
68 def _key(self, contact_jid): |
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:
671
diff
changeset
|
69 """Return internal key for this contact. |
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:
671
diff
changeset
|
70 |
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:
671
diff
changeset
|
71 @param contact_jid (jid.JID): contact JID |
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:
671
diff
changeset
|
72 @return: jid.JID |
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:
671
diff
changeset
|
73 """ |
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:
671
diff
changeset
|
74 return contact_jid.bare if self.merge_resources else contact_jid |
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:
671
diff
changeset
|
75 |
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:
676
diff
changeset
|
76 def clear(self): |
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:
676
diff
changeset
|
77 """Clear all contacts.""" |
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:
676
diff
changeset
|
78 self._contacts.clear() |
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:
676
diff
changeset
|
79 VerticalPanel.clear(self) |
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:
676
diff
changeset
|
80 |
660
267761bf7f08
browser side (contact list): ContactPanels is used instead of OccupantsList in MUC:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
81 def setList(self, jids): |
267761bf7f08
browser side (contact list): ContactPanels is used instead of OccupantsList in MUC:
Goffi <goffi@goffi.org>
parents:
648
diff
changeset
|
82 """set all contacts in the list in one shot. |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
83 |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
84 @param jids (list[jid.JID]): jids to display (the order is kept) |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
85 @param name (unicode): optional name of the contact |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
86 """ |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
87 current_jids = [box.jid for box in self.children if isinstance(box, contact_widget.ContactBox)] |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
88 if current_jids == jids: |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
89 # the display doesn't change |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
90 return |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
91 for contact_jid in set(current_jids).difference(jids): |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
92 self.removeContactBox(contact_jid) |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
93 current_index = 0 |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
94 insert_count = 0 |
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:
671
diff
changeset
|
95 for contact_jid in jids: |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
96 try: |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
97 if current_jids[current_index] == contact_jid: |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
98 current_index += 1 |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
99 continue |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
100 except IndexError: |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
101 pass |
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:
671
diff
changeset
|
102 assert isinstance(contact_jid, jid.JID) |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
103 self.updateContactBox(contact_jid, current_index + insert_count) |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
104 insert_count += 1 |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
105 |
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
106 def getContactBox(self, contact_jid): |
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
|
107 """Get the contact box for the given contact. |
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
|
108 |
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
|
109 @param contact_jid (jid.JID): contact JID |
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
|
110 @return: ContactBox or 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
|
111 """ |
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
|
112 try: |
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
|
113 return self._contacts[self._key(contact_jid)] |
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
|
114 except KeyError: |
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
|
115 return 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
|
116 |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
117 def updateContactBox(self, contact_jid, index=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
|
118 """Add a contact or update it if it already exists. |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
119 |
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:
671
diff
changeset
|
120 @param contact_jid (jid.JID): contact JID |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
121 @param index (int): insertion index if the contact is added |
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:
671
diff
changeset
|
122 @return: ContactBox |
647
e0021d571eef
browser side: moved ContactBox, ContactsPanel, ContactLabeland ContactMenuBar to base_widget/base_panels so they can be reused outside of contact_list module
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
123 """ |
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
|
124 box = self.getContactBox(contact_jid) |
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
|
125 if box: |
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 box.update() |
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 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
|
128 entity = contact_jid.bare if self.merge_resources else contact_jid |
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
|
129 box = contact_widget.ContactBox(self.host, entity, |
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:
660
diff
changeset
|
130 style_name=self.contacts_style, |
676
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
131 display=self.contacts_display, |
849ffb24d5bf
browser side: menus refactorisation:
Goffi <goffi@goffi.org>
parents:
673
diff
changeset
|
132 plugin_menu_context=self.contacts_menus) |
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:
671
diff
changeset
|
133 self._contacts[self._key(contact_jid)] = box |
695
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
134 if index: |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
135 VerticalPanel.insert(self, box, index) |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
136 else: |
e86490a7c76e
browser_side: don't rebuild the whole list on contact list update
souliane <souliane@mailoo.org>
parents:
692
diff
changeset
|
137 VerticalPanel.append(self, box) |
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
|
138 return box |
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:
671
diff
changeset
|
139 |
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
|
140 def removeContactBox(self, contact_jid): |
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
|
141 """Remove a contact. |
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:
671
diff
changeset
|
142 |
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:
671
diff
changeset
|
143 @param contact_jid (jid.JID): contact JID |
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:
671
diff
changeset
|
144 """ |
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
|
145 box = self._contacts.pop(self._key(contact_jid), 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
|
146 if box: |
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
|
147 VerticalPanel.remove(self, box) |