Mercurial > libervia-web
annotate src/browser/sat_browser/contact_list.py @ 909:e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Q&D update to restore compatibility
- version changed to 0.7D
- contact list has been modified to be compatible with changes, but it doesn't take profit of improvment yet
- messageSend partially work, there is a disconnection and an error in console logs when sending a message
- message are not received yet
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 09 Aug 2016 01:07:15 +0200 |
parents | f8a7a046ff9c |
children | 997cf25e785c |
rev | line source |
---|---|
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
669c531a857e
signals handling and first draft of microblogging
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 |
818 | 5 # Copyright (C) 2011-2016 Jérôme Poisson <goffi@goffi.org> |
2
669c531a857e
signals handling and first draft of microblogging
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. |
2
669c531a857e
signals handling and first draft of microblogging
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. |
2
669c531a857e
signals handling and first draft of microblogging
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/>. |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
20 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
21 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
22 log = getLogger(__name__) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
23 from sat_frontends.quick_frontend.quick_contact_list import QuickContactList |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 from pyjamas.ui.SimplePanel import SimplePanel |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
25 from pyjamas.ui.ScrollPanel import ScrollPanel |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from pyjamas.ui.VerticalPanel import VerticalPanel |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
27 from pyjamas.ui.ClickListener import ClickHandler |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 from pyjamas.ui.Label import Label |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 from pyjamas import Window |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from pyjamas import DOM |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
32 from constants import Const as C |
733
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
33 from sat_frontends.tools import jid |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
34 import libervia_widget |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
35 import contact_panel |
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:
641
diff
changeset
|
36 import blog |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
37 import chat |
242
a25aa882e09a
browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
38 |
614
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
39 unicode = str # XXX: pyjama doesn't manage unicode |
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
40 |
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
41 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
42 class GroupLabel(libervia_widget.DragLabel, Label, ClickHandler): |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
43 def __init__(self, host, group): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
44 """ |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
45 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
46 @param host (SatWebFrontend) |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
47 @param group (unicode): group name |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
48 """ |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
49 self.group = group |
451 | 50 Label.__init__(self, group) # , Element=DOM.createElement('div') |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
51 self.setStyleName('group') |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
52 libervia_widget.DragLabel.__init__(self, group, "GROUP", host) |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
53 ClickHandler.__init__(self) |
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
54 self.addClickListener(self) |
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
55 |
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
56 def onClick(self, sender): |
748
0d5889b9313c
browser side: fixed group panel drop and contact_list click on GroupLabel
Goffi <goffi@goffi.org>
parents:
733
diff
changeset
|
57 self.host.displayWidget(blog.Blog, (self.group,)) |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
58 |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
59 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
60 class GroupPanel(VerticalPanel): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 def __init__(self, parent): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 VerticalPanel.__init__(self) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
64 self.setStyleName('groupPanel') |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 self._parent = parent |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
66 |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
67 @property |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
68 def _groups(self): |
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
69 return self._parent.contact_list._groups |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 def add(self, group): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
72 if group in self._groups: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
73 log.warning("trying to add an already existing group") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
74 return |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
75 _item = GroupLabel(self._parent.host, group) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 _item.addMouseListener(self._parent) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer") |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
78 index = 0 |
459
36f27d1e64b2
browser_side: avoid warning "list comprehension redefines 'group' from line XXX"
souliane <souliane@mailoo.org>
parents:
455
diff
changeset
|
79 for group_ in [child.group for child in self.getChildren()]: |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
80 if group_ > group: |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
81 break |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
82 index += 1 |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
83 VerticalPanel.insert(self, _item, index) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
84 self._groups.add(group) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
85 |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
86 def remove(self, group): |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
87 for wid in self: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
88 if isinstance(wid, GroupLabel) and wid.group == group: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
89 VerticalPanel.remove(self, wid) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
90 self._groups.remove(group) |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
91 return |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
92 log.warning("Trying to remove a non existent group") |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
93 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
94 def getGroupBox(self, group): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
95 """get the widget of a group |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
96 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
97 @param group (unicode): the group |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
98 @return: GroupLabel instance if present, else None""" |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
99 for wid in self: |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
100 if isinstance(wid, GroupLabel) and wid.group == group: |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
101 return wid |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
102 return None |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
103 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
104 def getGroups(self): |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
105 return set([g for g in self._groups if g is not None]) |
242
a25aa882e09a
browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
106 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
107 |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
108 class ContactTitleLabel(libervia_widget.DragLabel, Label, ClickHandler): |
634
16a5da120b7f
browser side (contact list): Contact list improvments:
Goffi <goffi@goffi.org>
parents:
633
diff
changeset
|
109 |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
110 def __init__(self, host, text): |
451 | 111 Label.__init__(self, text) # , Element=DOM.createElement('div') |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
112 self.setStyleName('contactTitle') |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
647
diff
changeset
|
113 libervia_widget.DragLabel.__init__(self, text, "CONTACT_TITLE", host) |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
114 ClickHandler.__init__(self) |
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
115 self.addClickListener(self) |
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
116 |
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
117 def onClick(self, sender): |
766
dd70db1c48dc
browser_side (contact_list): fixes click on the "Contacts" button above the roster
souliane <souliane@mailoo.org>
parents:
754
diff
changeset
|
118 self.host.displayWidget(blog.Blog, ()) |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
119 |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
120 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
121 class ContactList(SimplePanel, QuickContactList): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 """Manage the contacts and groups""" |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
123 |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
124 def __init__(self, host, target, on_click=None, on_change=None, user_data=None, profiles=None): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
125 QuickContactList.__init__(self, host, C.PROF_KEY_NONE) |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
126 self.contact_list = self.host.contact_list |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 SimplePanel.__init__(self) |
634
16a5da120b7f
browser side (contact list): Contact list improvments:
Goffi <goffi@goffi.org>
parents:
633
diff
changeset
|
128 self.host = host |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
129 self.scroll_panel = ScrollPanel() |
779
fc941d0d97f8
browser_side: fixed ContactsPanel scrolling
souliane <souliane@mailoo.org>
parents:
766
diff
changeset
|
130 self.scroll_panel.addStyleName("gwt-ScrollPanel") # XXX: no class is set by Pyjamas |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 self.vPanel = VerticalPanel() |
200
0f5c2f799913
browser side: clicking on the contacts list (contact item, group or the "contacts" main title) open a discussion or microblog
Goffi <goffi@goffi.org>
parents:
196
diff
changeset
|
132 _title = ContactTitleLabel(host, 'Contacts') |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
133 DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer") |
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
|
134 |
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
|
135 def on_click(contact_jid): |
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
|
136 self.host.displayWidget(chat.Chat, contact_jid, type_=C.CHAT_ONE2ONE) |
754
d3fa1e8904cf
browser_side: display the number of alerts for each contact and not only a symbol (*) + favicon displays the total number of waiting messages
souliane <souliane@mailoo.org>
parents:
748
diff
changeset
|
137 self.removeAlerts(contact_jid, True) |
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
|
138 |
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
|
139 self._contacts_panel = contact_panel.ContactsPanel(host, contacts_click=on_click, contacts_menus=(C.MENU_JID_CONTEXT, C.MENU_ROSTER_JID_CONTEXT)) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
140 self._group_panel = GroupPanel(self) |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
141 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 self.vPanel.add(_title) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
143 self.vPanel.add(self._group_panel) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
144 self.vPanel.add(self._contacts_panel) |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
145 self.scroll_panel.add(self.vPanel) |
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
146 self.add(self.scroll_panel) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
147 self.setStyleName('contactList') |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
148 Window.addWindowResizeListener(self) |
624
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
622
diff
changeset
|
149 |
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
622
diff
changeset
|
150 # 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) |
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
622
diff
changeset
|
151 self.avatarListener = self.onAvatarUpdate |
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
622
diff
changeset
|
152 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE]) |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
153 self.postInit() |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
154 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
155 @property |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
156 def profile(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
157 return C.PROF_KEY_NONE |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
158 |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
159 def onDelete(self): |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
160 QuickContactList.onDelete(self) |
624
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
622
diff
changeset
|
161 self.host.removeListener('avatar', self.avatarListener) |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
162 |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
163 def update(self, entities=None, type_=None, profile=None): |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
697
diff
changeset
|
164 # XXX: as update is slow, we avoid many updates on profile plugs |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
697
diff
changeset
|
165 # and do them all at once at the end |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
166 if not self.host._profile_plugged: # FIXME: should not be necessary anymore (done in QuickFrontend) |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
697
diff
changeset
|
167 return |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
168 ### GROUPS ### |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
169 _keys = self.contact_list._groups.keys() |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
170 try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
171 # XXX: Pyjamas doesn't do the set casting if None is present |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
172 _keys.remove(None) |
592
c66f7227848e
browser side: fixed an error catch in contact_list module (raised error depend on pyama's compilation options)
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
173 except (KeyError, ValueError): # XXX: error raised depend on pyjama's compilation options |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
174 pass |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
175 current_groups = set(_keys) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
176 shown_groups = self._group_panel.getGroups() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
177 new_groups = current_groups.difference(shown_groups) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
178 removed_groups = shown_groups.difference(current_groups) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
179 for group in new_groups: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
180 self._group_panel.add(group) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
181 for group in removed_groups: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
182 self._group_panel.remove(group) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
183 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
184 ### JIDS ### |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
185 to_show = [jid_ for jid_ in self.contact_list.roster if self.contact_list.entityToShow(jid_) and jid_ != self.contact_list.whoami.bare] |
630 | 186 to_show.sort() |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
187 |
660
267761bf7f08
browser side (contact list): ContactPanels is used instead of OccupantsList in MUC:
Goffi <goffi@goffi.org>
parents:
658
diff
changeset
|
188 self._contacts_panel.setList(to_show) |
630 | 189 |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
190 def onWindowResized(self, width, height): |
654
40c72f3b7638
browser_side: MainPanel is now based on a DockPanel, which allows to use less tables and also to remove some "window resized" listeners
souliane <souliane@mailoo.org>
parents:
651
diff
changeset
|
191 ideal_height = height - DOM.getAbsoluteTop(self.getElement()) - 5 |
658
476d8d9973d3
browser_side: the contact list's height needs a window resize after it's been added or when the tab bar display is changed
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
192 tab_panel = self.host.panel.tab_panel |
476d8d9973d3
browser_side: the contact list's height needs a window resize after it's been added or when the tab bar display is changed
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
193 if tab_panel.getWidgetCount() > 1: |
476d8d9973d3
browser_side: the contact list's height needs a window resize after it's been added or when the tab bar display is changed
souliane <souliane@mailoo.org>
parents:
654
diff
changeset
|
194 ideal_height -= tab_panel.getTabBar().getOffsetHeight() |
290
3216c8d5432b
browser_side: set the ideal height for the contact panel size when displayed in the unibox panel
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
195 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px")) |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
196 |
54
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
197 def isContactInRoster(self, contact_jid): |
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
198 """Test if the contact is in our roster list""" |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
199 for contact_box in self._contacts_panel: |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
200 if contact_jid == contact_box.jid: |
54
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
201 return True |
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
202 return False |
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
203 |
21
77c2e48efa29
browser side: a warning message now show who will receive the message entered in UniBox, with a color depending on how many people will be able to see it
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
204 def getGroups(self): |
909
e8b133b77aa4
browser, server: update to get compatibility with 0.7-dev (not finished):
Goffi <goffi@goffi.org>
parents:
818
diff
changeset
|
205 return self._group_panel.getGroups() |
21
77c2e48efa29
browser side: a warning message now show who will receive the message entered in UniBox, with a color depending on how many people will be able to see it
Goffi <goffi@goffi.org>
parents:
19
diff
changeset
|
206 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 def onMouseMove(self, sender, x, y): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 pass |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
209 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 def onMouseDown(self, sender, x, y): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 pass |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 def onMouseUp(self, sender, x, y): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 pass |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 def onMouseEnter(self, sender): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 if isinstance(sender, GroupLabel): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
218 jids = self.getGroupData(sender.group, "jids") |
787
b2a75a103aac
browser side (contact list): fixed a traceback on mouse enter/leave + bad attribute name
Goffi <goffi@goffi.org>
parents:
779
diff
changeset
|
219 for contact in self._contacts_panel.getBoxes(): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
220 if contact.jid in jids: |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
221 contact.label.addStyleName("selected") |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
222 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
223 def onMouseLeave(self, sender): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
224 if isinstance(sender, GroupLabel): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
225 jids = self.getGroupData(sender.group, "jids") |
787
b2a75a103aac
browser side (contact list): fixed a traceback on mouse enter/leave + bad attribute name
Goffi <goffi@goffi.org>
parents:
779
diff
changeset
|
226 for contact in self._contacts_panel.getBoxes(): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
227 if contact.jid in jids: |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
228 contact.label.removeStyleName("selected") |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
229 |
638
63697f082e8a
browser side: fixed use of profile for listeners
Goffi <goffi@goffi.org>
parents:
637
diff
changeset
|
230 def onAvatarUpdate(self, jid_, hash_, profile): |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
231 """Called on avatar update events |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
232 |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
233 @param jid_: jid of the entity with updated avatar |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
234 @param hash_: hash of the avatar |
638
63697f082e8a
browser side: fixed use of profile for listeners
Goffi <goffi@goffi.org>
parents:
637
diff
changeset
|
235 @param profile: %(doc_profile)s |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
236 """ |
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
|
237 box = self._contacts_panel.getContactBox(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
|
238 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
|
239 box.update() |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
240 |
640
75715f5c95e3
browser side(contact list): added nick listener
Goffi <goffi@goffi.org>
parents:
639
diff
changeset
|
241 def onNickUpdate(self, jid_, new_nick, profile): |
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
|
242 box = self._contacts_panel.getContactBox(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
|
243 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
|
244 box.update() |
640
75715f5c95e3
browser side(contact list): added nick listener
Goffi <goffi@goffi.org>
parents:
639
diff
changeset
|
245 |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
246 def offlineContactsToShow(self): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
247 """Tell if offline contacts should be visible according to the user settings |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
248 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
249 @return: boolean |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
250 """ |
633
617f7a5c5312
browser side (contact list): use of c.bool for parameter conversion
Goffi <goffi@goffi.org>
parents:
630
diff
changeset
|
251 return C.bool(self.host.getCachedParam('General', C.SHOW_OFFLINE_CONTACTS)) |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
252 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
253 def emtyGroupsToShow(self): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
254 """Tell if empty groups should be visible according to the user settings |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
255 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
256 @return: boolean |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
257 """ |
633
617f7a5c5312
browser side (contact list): use of c.bool for parameter conversion
Goffi <goffi@goffi.org>
parents:
630
diff
changeset
|
258 return C.bool(self.host.getCachedParam('General', C.SHOW_EMPTY_GROUPS)) |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
259 |
639
8da4735a3c81
browser side (contact list): fixed forgotten profile argument in presence listener
Goffi <goffi@goffi.org>
parents:
638
diff
changeset
|
260 def onPresenceUpdate(self, entity, show, priority, statuses, profile): |
8da4735a3c81
browser side (contact list): fixed forgotten profile argument in presence listener
Goffi <goffi@goffi.org>
parents:
638
diff
changeset
|
261 QuickContactList.onPresenceUpdate(self, entity, show, priority, statuses, profile) |
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
|
262 box = self._contacts_panel.getContactBox(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
|
263 if box: # box doesn't exist for MUC bare entity, don't create it |
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
|
264 box.update() |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
265 |
600
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
266 |
601
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
267 class JIDList(list): |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
268 """JID-friendly list implementation for Pyjamas""" |
600
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
269 |
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
270 def __contains__(self, item): |
601
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
271 """Tells if the list contains the given item. |
600
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
272 |
601
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
273 @param item (object): element to check |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
274 @return: bool |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
275 """ |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
276 # Since our JID doesn't inherit from str/unicode, without this method |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
277 # the test would return True only when the objects references are the |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
278 # same. Tests have shown that the other iterable "set" and "dict" don't |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
279 # need this hack to reproduce the Twisted's behavior. |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
280 for other in self: |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
281 if other == item: |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
282 return True |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
283 return False |
748
0d5889b9313c
browser side: fixed group panel drop and contact_list click on GroupLabel
Goffi <goffi@goffi.org>
parents:
733
diff
changeset
|
284 |
733
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
285 def index(self, item): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
286 i = 0 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
287 for other in self: |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
288 if other == item: |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
289 return i |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
290 i += 1 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
291 raise ValueError("JIDList.index(%(item)s): %(item)s not in list" % {"item": item}) |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
292 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
293 class JIDSet(set): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
294 """JID set implementation for Pyjamas""" |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
295 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
296 def __contains__(self, item): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
297 return __containsJID(self, item) |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
298 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
299 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
300 class JIDDict(dict): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
301 """JID dict implementation for Pyjamas (a dict with JID keys)""" |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
302 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
303 def __contains__(self, item): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
304 return __containsJID(self, item) |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
305 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
306 def keys(self): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
307 return JIDSet(dict.keys(self)) |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
308 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
309 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
310 def __containsJID(iterable, item): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
311 """Tells if the given item is in the iterable, works with JID. |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
312 |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
313 @param iterable(object): list, set or another iterable object |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
314 @param item (object): element |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
315 @return: bool |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
316 """ |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
317 # Pyjamas JID-friendly implementation of the "in" operator. Since our JID |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
318 # doesn't inherit from str, without this method the test would return True |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
319 # only when the objects references are the same. |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
320 if isinstance(item, jid.JID): |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
321 return hash(item) in [hash(other) for other in iterable if isinstance(other, jid.JID)] |
66beef5b943d
browser_side: add functions JIDSet and JIDDict
souliane <souliane@mailoo.org>
parents:
716
diff
changeset
|
322 return super(type(iterable), iterable).__contains__(iterable, item) |