Mercurial > libervia-web
annotate src/browser/sat_browser/contact_list.py @ 622:2c41ce0c3b3f frontends_multi_profiles
browser_side: fixes a typo (listerner --> listener)
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 20 Feb 2015 22:05:14 +0100 |
parents | 5baca9d46c34 |
children | 9092e624bb27 |
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 |
340 | 5 # Copyright (C) 2011, 2012, 2013, 2014 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 |
62 | 29 from pyjamas.ui.HTML import HTML |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
30 from pyjamas.ui.Image import Image |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from pyjamas import Window |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 from pyjamas import DOM |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
33 from __pyjamas__ import doc |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
35 from sat_frontends.tools import jid |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
36 from constants import Const as C |
467 | 37 import base_widget |
38 import html_tools | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
39 import chat |
616
1c0d5a87c554
browser_side: add and use method displayWidget to harmonize widget's management in Libervia (not completely done, there are some issues)
souliane <souliane@mailoo.org>
parents:
614
diff
changeset
|
40 import blog |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 |
242
a25aa882e09a
browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
42 |
614
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
43 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
|
44 |
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
45 |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
46 def buildPresenceStyle(presence, base_style=None): |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
47 """Return the CSS classname to be used for displaying the given presence information. |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
48 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
49 @param presence (unicode): presence is a value in ('', 'chat', 'away', 'dnd', 'xa') |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
50 @param base_style (unicode): base classname |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
51 @return: unicode |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
52 """ |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
53 if not base_style: |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
54 base_style = "contactLabel" |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
55 return '%s-%s' % (base_style, presence or 'connected') |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
56 |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
57 |
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
58 def setPresenceStyle(widget, presence, base_style=None): |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
59 """ |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
60 Set the CSS style of a contact's element according to its presence. |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
61 |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
62 @param widget (Widget): the UI element of the contact |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
63 @param presence (unicode): a value in ("", "chat", "away", "dnd", "xa"). |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
64 @param base_style (unicode): the base name of the style to apply |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
65 """ |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
66 if not hasattr(widget, 'presence_style'): |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
67 widget.presence_style = None |
510
db3436c85fb1
browser_side: the status menu is now based on GenericMenuBar instead of PopupMenuPanel
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
68 style = buildPresenceStyle(presence, base_style) |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
69 if style == widget.presence_style: |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
70 return |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
71 if widget.presence_style is not None: |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
72 widget.removeStyleName(widget.presence_style) |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
73 widget.addStyleName(style) |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
74 widget.presence_style = style |
370
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
75 |
30d03d9f07e4
browser_side: refactorization of the file tools.py:
souliane <souliane@mailoo.org>
parents:
340
diff
changeset
|
76 |
467 | 77 class GroupLabel(base_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
|
78 def __init__(self, host, group): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
79 """ |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
80 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
81 @param host (SatWebFrontend) |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
82 @param group (unicode): group name |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
83 """ |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
84 self.group = group |
451 | 85 Label.__init__(self, group) # , Element=DOM.createElement('div') |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
86 self.setStyleName('group') |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
592
diff
changeset
|
87 base_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
|
88 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
|
89 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
|
90 |
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
|
91 def onClick(self, sender): |
616
1c0d5a87c554
browser_side: add and use method displayWidget to harmonize widget's management in Libervia (not completely done, there are some issues)
souliane <souliane@mailoo.org>
parents:
614
diff
changeset
|
92 self.host.displayWidget(blog.MicroblogPanel, self.group) |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
93 |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
94 |
485
5911f71acc80
browser side: move contacts list's avatar from right to top
souliane <souliane@mailoo.org>
parents:
480
diff
changeset
|
95 class ContactLabel(HTML): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
96 def __init__(self, jid_, name=None): |
62 | 97 HTML.__init__(self) |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
98 self.name = name or unicode(jid_) |
62 | 99 self.waiting = False |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
100 self.refresh() |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
101 self.setStyleName('contactLabel') |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
103 def refresh(self): |
62 | 104 if self.waiting: |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
105 wait_html = "<b>(*)</b> " |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
106 self.setHTML("%(wait)s%(name)s" % {'wait': wait_html, |
467 | 107 'name': html_tools.html_sanitize(self.name)}) |
62 | 108 |
109 def setMessageWaiting(self, waiting): | |
110 """Show a visual indicator if message are waiting | |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
111 |
62 | 112 @param waiting: True if message are waiting""" |
113 self.waiting = waiting | |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
114 self.refresh() |
62 | 115 |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
116 |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
117 class ContactMenuBar(base_widget.WidgetMenuBar): |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
118 |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
119 def onBrowserEvent(self, event): |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
120 base_widget.WidgetMenuBar.onBrowserEvent(self, event) |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
121 event.stopPropagation() # prevent opening the chat dialog |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
122 |
578
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
123 @classmethod |
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
124 def getCategoryHTML(cls, menu_name_i18n, type_): |
606
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
125 return '<img src="%s"/>' % C.DEFAULT_AVATAR_URL |
578
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
126 |
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
127 def setUrl(self, url): |
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
128 """Set the URL of the contact avatar.""" |
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
129 self.items[0].setHTML('<img src="%s" />' % url) |
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
130 |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
131 |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
132 class ContactBox(VerticalPanel, ClickHandler, base_widget.DragLabel): |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
133 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
134 def __init__(self, host, jid_, name=None, click_listener=None, handle_menu=None): |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
135 """ |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
136 |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
137 @param host (SatWebFrontend) |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
138 @param jid_ (jid.JID): contact JID |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
139 @param name (unicode): contact alias |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
140 @param click_listener (callable): click callback |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
141 @param handle_menu (bool): if True, bind a popup menu to the avatar |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
142 """ |
485
5911f71acc80
browser side: move contacts list's avatar from right to top
souliane <souliane@mailoo.org>
parents:
480
diff
changeset
|
143 VerticalPanel.__init__(self, StyleName='contactBox', VerticalAlignment='middle') |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
592
diff
changeset
|
144 base_widget.DragLabel.__init__(self, jid_, "CONTACT", host) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
145 self.jid = jid_ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
146 self.label = ContactLabel(jid_, name) |
578
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
147 self.avatar = ContactMenuBar(self, host) if handle_menu else Image() |
606
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
600
diff
changeset
|
148 self.updateAvatar(host.getAvatarURL(jid_)) |
578
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
149 self.add(self.avatar) |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
150 self.add(self.label) |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
151 if click_listener: |
485
5911f71acc80
browser side: move contacts list's avatar from right to top
souliane <souliane@mailoo.org>
parents:
480
diff
changeset
|
152 ClickHandler.__init__(self) |
5911f71acc80
browser side: move contacts list's avatar from right to top
souliane <souliane@mailoo.org>
parents:
480
diff
changeset
|
153 self.addClickListener(self) |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
154 self.click_listener = click_listener |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
155 |
498
60be99de3808
browser_side: menus refactorization + handle levels > 2
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
156 def addMenus(self, menu_bar): |
614
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
157 menu_bar.addCachedMenus(C.MENU_ROSTER_JID_CONTEXT, {'jid': unicode(self.jid)}) |
14bdf5394ae9
browser side: fixed jid's public blog menu
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
158 menu_bar.addCachedMenus(C.MENU_JID_CONTEXT, {'jid': unicode(self.jid)}) |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
159 |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
160 def setMessageWaiting(self, waiting): |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
161 """Show a visual indicator if message are waiting |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
162 |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
163 @param waiting: True if message are waiting""" |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
164 self.label.setMessageWaiting(waiting) |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
165 |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
166 def updateAvatar(self, url): |
578
668bb04e9708
browser_side: set the roster contact's contextual menu on the avatar (no extra button)
souliane <souliane@mailoo.org>
parents:
574
diff
changeset
|
167 """Update the avatar. |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
168 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
169 @param url (unicode): image url |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
170 """ |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
171 self.avatar.setUrl(url) |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
172 |
485
5911f71acc80
browser side: move contacts list's avatar from right to top
souliane <souliane@mailoo.org>
parents:
480
diff
changeset
|
173 def onClick(self, sender): |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
174 self.click_listener(self.jid) |
485
5911f71acc80
browser side: move contacts list's avatar from right to top
souliane <souliane@mailoo.org>
parents:
480
diff
changeset
|
175 |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
176 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
177 class GroupPanel(VerticalPanel): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 def __init__(self, parent): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 VerticalPanel.__init__(self) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
181 self.setStyleName('groupPanel') |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 self._parent = parent |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
183 self._groups = set() |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 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
|
189 _item = GroupLabel(self._parent.host, group) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 _item.addMouseListener(self._parent) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
191 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
|
192 index = 0 |
459
36f27d1e64b2
browser_side: avoid warning "list comprehension redefines 'group' from line XXX"
souliane <souliane@mailoo.org>
parents:
455
diff
changeset
|
193 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
|
194 if group_ > group: |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
195 break |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
196 index += 1 |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
197 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
|
198 self._groups.add(group) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
199 |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
200 def remove(self, group): |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
201 for wid in self: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
202 if isinstance(wid, GroupLabel) and wid.group == group: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
203 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
|
204 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
|
205 return |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
206 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
|
207 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
208 def getGroupBox(self, group): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
209 """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
|
210 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
211 @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
|
212 @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
|
213 for wid in self: |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
214 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
|
215 return wid |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
216 return None |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
217 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
218 def getGroups(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
219 return self._groups |
242
a25aa882e09a
browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
220 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
221 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
222 class BaseContactsPanel(VerticalPanel): |
252
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
223 """Class that can be used to represent a contact list, but not necessarily |
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
224 the one that is displayed on the left side. Special features like popup menu |
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
225 panel or changing the contact states must be done in a sub-class.""" |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
226 |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
227 def __init__(self, host, handle_click=False, handle_menu=False): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 VerticalPanel.__init__(self) |
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
|
229 self.host = host |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
230 self.contacts = [] |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
231 self.click_listener = None |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
232 self.handle_menu = handle_menu |
242
a25aa882e09a
browser_side: add context menu for contact:
souliane <souliane@mailoo.org>
parents:
230
diff
changeset
|
233 |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
234 if handle_click: |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
235 def cb(contact_jid): |
616
1c0d5a87c554
browser_side: add and use method displayWidget to harmonize widget's management in Libervia (not completely done, there are some issues)
souliane <souliane@mailoo.org>
parents:
614
diff
changeset
|
236 host.displayWidget(chat.Chat, contact_jid, type_=C.CHAT_ONE2ONE) |
495
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
237 self.click_listener = cb |
587fe75d1b16
browser_side: handle menus of type ROOM, SINGLE and ROSTER_JID
souliane <souliane@mailoo.org>
parents:
485
diff
changeset
|
238 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
239 def add(self, jid_, name=None): |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
240 """Add a contact to the list. |
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
241 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
242 @param jid_ (jid.JID): jid_ of the contact |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
243 @param name (unicode): optional name of the contact |
479
c21ea1fe3593
browser side: small refactoring to prepare displaying avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
467
diff
changeset
|
244 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
245 assert isinstance(jid_, jid.JID) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
246 if jid_ in self.contacts: |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
247 return |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
248 index = 0 |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
249 for contact_ in self.contacts: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
250 if contact_ > jid_: |
255
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
251 break |
da0487f0a2e7
browser_side: small changes to prepare the contact group manager:
souliane <souliane@mailoo.org>
parents:
252
diff
changeset
|
252 index += 1 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
253 self.contacts.insert(index, jid_) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
254 box = ContactBox(self.host, jid_, name, self.click_listener, self.handle_menu) |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
255 VerticalPanel.insert(self, box, index) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
256 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
257 def remove(self, jid_): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
258 box = self.getContactBox(jid_) |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
259 if not box: |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
260 return |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
261 VerticalPanel.remove(self, box) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
262 self.contacts.remove(jid_) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
263 |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
264 def isContactPresent(self, contact_jid): |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
265 """Return True if a contact is present in the panel""" |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
266 return contact_jid in self.contacts |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
267 |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
268 def getContacts(self): |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
269 return self.contacts |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
270 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
271 def getContactBox(self, contact_jid): |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
272 """get the widget of a contact |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
273 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
274 @param contact_jid (jid.JID): the contact |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
275 @return: ContactBox instance if present, else None""" |
600
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
276 assert isinstance(contact_jid, jid.JID) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
277 for wid in self: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
278 if isinstance(wid, ContactBox) and wid.jid == contact_jid: |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
279 return wid |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
280 return None |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
281 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
282 def updateAvatar(self, jid_, url): |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
283 """Update the avatar of the given contact |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
284 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
285 @param jid_ (jid.JID): contact jid |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
286 @param url (unicode): image url |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
287 """ |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
288 try: |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
289 self.getContactBox(jid_).updateAvatar(url) |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
290 except TypeError: |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
291 pass |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
292 |
252
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
293 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
294 class ContactsPanel(BaseContactsPanel): |
252
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
295 """The contact list that is displayed on the left side.""" |
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
296 |
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
297 def __init__(self, host): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
298 BaseContactsPanel.__init__(self, host, handle_click=True, handle_menu=True) |
252
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
299 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
300 def setState(self, jid_, type_, state): |
47
7cabe3c1a5f2
browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
301 """Change the appearance of the contact, according to the state |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
302 @param jid_ (jid.JID): jid.JID which need to change state |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
303 @param type_ (unicode): one of "availability", "messageWaiting" |
62 | 304 @param state: |
305 - for messageWaiting type: | |
306 True if message are waiting | |
307 - for availability type: | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
308 C.PRESENCE_UNAVAILABLE or None if not connected, else presence like RFC6121 #4.7.2.1""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
309 assert type_ in ('availability', 'messageWaiting') |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
310 contact_box = self.getContactBox(jid_) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
311 if not contact_box: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
312 log.warning("No contact box found for {}".format(jid_)) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
313 else: |
252
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
314 if type_ == 'availability': |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
315 if state is None: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
316 state = C.PRESENCE_UNAVAILABLE |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
317 setPresenceStyle(contact_box.label, state) |
252
b77940d8a9bf
browser_side: isolate the basic stuff of ContactList in the new GenericContactList class
souliane <souliane@mailoo.org>
parents:
242
diff
changeset
|
318 elif type_ == 'messageWaiting': |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
319 contact_box.setMessageWaiting(state) |
47
7cabe3c1a5f2
browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents:
33
diff
changeset
|
320 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
321 |
467 | 322 class ContactTitleLabel(base_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
|
323 def __init__(self, host, text): |
451 | 324 Label.__init__(self, text) # , Element=DOM.createElement('div') |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
325 self.setStyleName('contactTitle') |
594
a099990f77a6
browser side: border widgets are now visible on drag start + they float right or left in the cell
Goffi <goffi@goffi.org>
parents:
592
diff
changeset
|
326 base_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
|
327 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
|
328 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
|
329 |
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
|
330 def onClick(self, sender): |
616
1c0d5a87c554
browser_side: add and use method displayWidget to harmonize widget's management in Libervia (not completely done, there are some issues)
souliane <souliane@mailoo.org>
parents:
614
diff
changeset
|
331 self.host.displayWidget(blog.MicroblogPanel, None) |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
332 |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
333 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
334 class ContactList(SimplePanel, QuickContactList): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
335 """Manage the contacts and groups""" |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
336 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
337 def __init__(self, host): |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
338 QuickContactList.__init__(self, host, C.PROF_KEY_NONE) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
339 SimplePanel.__init__(self) |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
340 self.scroll_panel = ScrollPanel() |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
341 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
|
342 _title = ContactTitleLabel(host, 'Contacts') |
16
099c05a0dcab
browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents:
13
diff
changeset
|
343 DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer") |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
344 self._contacts_panel = ContactsPanel(host) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
345 self._contacts_panel.setStyleName('contactPanel') # FIXME: style doesn't exists ! |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
346 self._group_panel = GroupPanel(self) |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
347 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
348 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
|
349 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
|
350 self.vPanel.add(self._contacts_panel) |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
351 self.scroll_panel.add(self.vPanel) |
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
352 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
|
353 self.setStyleName('contactList') |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
354 Window.addWindowResizeListener(self) |
622
2c41ce0c3b3f
browser_side: fixes a typo (listerner --> listener)
souliane <souliane@mailoo.org>
parents:
617
diff
changeset
|
355 host.addListener('avatar', self.onAvatarUpdate) |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
356 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
357 @property |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
358 def profile(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
359 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
|
360 |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
361 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
|
362 QuickContactList.onDelete(self) |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
363 self.host.removeListener('avatar', self.onAvatarUpdate) |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
364 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
365 def update(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
366 ### GROUPS ### |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
367 _keys = self._groups.keys() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
368 try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
369 # 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
|
370 _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
|
371 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
|
372 pass |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
373 current_groups = set(_keys) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
374 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
|
375 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
382 ### JIDS ### |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
383 current_contacts = set(self._cache.keys()) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
384 shown_contacts = set(self._contacts_panel.getContacts()) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
385 new_contacts = current_contacts.difference(shown_contacts) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
386 removed_contacts = shown_contacts.difference(current_contacts) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
387 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
388 for contact in new_contacts: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
389 self._contacts_panel.add(contact) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
390 for contact in removed_contacts: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
391 self._contacts_panel.remove(contact) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
392 |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
393 def onWindowResized(self, width, height): |
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
394 contact_panel_elt = self.getElement() |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
395 # FIXME: still needed ? |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
396 # classname = 'widgetsPanel' if isinstance(self.getParent().getParent(), panels.UniBoxPanel) else 'gwt-TabBar' |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
397 classname = 'gwt-TabBar' |
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
|
398 _elts = doc().getElementsByClassName(classname) |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
399 if not _elts.length: |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
413
diff
changeset
|
400 log.error("no element of class %s found, it should exist !" % classname) |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
401 tab_bar_h = height |
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
402 else: |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
403 tab_bar_h = DOM.getAbsoluteTop(_elts.item(0)) or height # getAbsoluteTop can be 0 if tabBar is hidden |
187
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
404 |
d0503f8f15ef
browser side: scroller added to contacts panel
Goffi <goffi@goffi.org>
parents:
165
diff
changeset
|
405 ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5 |
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
|
406 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
|
407 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
408 # def updateContact(self, jid_s, attributes, groups): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
409 # """Add a contact to the panel if it doesn't exist, update it else |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
410 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
411 # @param jid_s: jid userhost as unicode |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
412 # @param attributes: cf SàT Bridge API's newContact |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
413 # @param groups: list of groups""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
414 # _current_groups = self.getContactGroups(jid_s) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
415 # _new_groups = set(groups) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
416 # _key = "@%s: " |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
417 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
418 # for group in _current_groups.difference(_new_groups): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
419 # # We remove the contact from the groups where he isn't anymore |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
420 # self.groups[group].remove(jid_s) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
421 # if not self.groups[group]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
422 # # The group is now empty, we must remove it |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
423 # del self.groups[group] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
424 # 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
|
425 # if self.host.uni_box: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
426 # self.host.uni_box.removeKey(_key % group) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
427 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
428 # for group in _new_groups.difference(_current_groups): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
429 # # We add the contact to the groups he joined |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
430 # if group not in self.groups.keys(): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
431 # self.groups[group] = set() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
432 # 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
|
433 # if self.host.uni_box: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
434 # self.host.uni_box.addKey(_key % group) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
435 # self.groups[group].add(jid_s) |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
436 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
437 # # We add the contact to contact list, it will check if contact already exists |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
438 # self._contacts_panel.add(jid_s) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
439 # self.updateVisibility([jid_s], self.getContactGroups(jid_s)) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
440 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
441 # def removeContact(self, jid): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
442 # """Remove contacts from groups where he is and contact list""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
443 # self.updateContact(jid, {}, []) # we remove contact from every group |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
444 # self._contacts_panel.remove(jid) |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
445 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
446 # def setConnected(self, jid_s, resource, availability, priority, statuses): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
447 # """Set connection status |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
448 # @param jid_s (unicode): JID userhost as unicode |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
449 # """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
450 # if availability == 'unavailable': |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
451 # if jid_s in self.connected: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
452 # if resource in self.connected[jid_s]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
453 # del self.connected[jid_s][resource] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
454 # if not self.connected[jid_s]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
455 # del self.connected[jid_s] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
456 # else: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
457 # if jid_s not in self.connected: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
458 # self.connected[jid_s] = {} |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
459 # self.connected[jid_s][resource] = (availability, priority, statuses) |
413
7a8991cda2fa
browser_side: display presence with the highest priority
souliane <souliane@mailoo.org>
parents:
372
diff
changeset
|
460 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
461 # # check if the contact is connected with another resource, use the one with highest priority |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
462 # if jid_s in self.connected: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
463 # max_resource = max_priority = None |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
464 # for tmp_resource in self.connected[jid_s]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
465 # if max_priority is None or self.connected[jid_s][tmp_resource][1] >= max_priority: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
466 # max_resource = tmp_resource |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
467 # max_priority = self.connected[jid_s][tmp_resource][1] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
468 # if availability == "unavailable": # do not check the priority here, because 'unavailable' has a dummy one |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
469 # priority = max_priority |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
470 # availability = self.connected[jid_s][max_resource][0] |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
471 # if jid_s not in self.connected or priority >= max_priority: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
472 # # case 1: jid not in self.connected means all resources are disconnected, update with 'unavailable' |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
473 # # case 2: update (or confirm) with the values of the resource which takes precedence |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
474 # self._contacts_panel.setState(jid_s, "availability", availability) |
62 | 475 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
476 # # update the connected contacts chooser live |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
477 # if hasattr(self.host, "room_contacts_chooser") and self.host.room_contacts_chooser is not None: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
478 # self.host.room_contacts_chooser.resetContacts() |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
479 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
480 # self.updateVisibility([jid_s], self.getContactGroups(jid_s)) |
271
d868181d0649
browser_side: update contacts in "group and contact chooser" when the a user connect/disconnect
souliane <souliane@mailoo.org>
parents:
267
diff
changeset
|
481 |
62 | 482 def setContactMessageWaiting(self, jid, waiting): |
483 """Show an visual indicator that contact has send a message | |
484 @param jid: jid of the contact | |
485 @param waiting: True if message are waiting""" | |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
486 self._contacts_panel.setState(jid, "messageWaiting", waiting) |
62 | 487 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
488 # def getConnected(self, filter_muc=False): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
489 # """return a list of all jid (bare jid) connected |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
490 # @param filter_muc: if True, remove the groups from the list |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
491 # """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
492 # contacts = self.connected.keys() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
493 # contacts.sort() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
494 # return contacts if not filter_muc else list(set(contacts).intersection(set(self.getContacts()))) |
28 | 495 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
496 # def getContactGroups(self, contact_jid_s): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
497 # """Get groups where contact is |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
498 # @param group: string of single group, or list of string |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
499 # @param contact_jid_s: jid to test, as unicode |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
500 # """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
501 # result = set() |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
502 # for group in self.groups: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
503 # if self.isContactInGroup(group, contact_jid_s): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
504 # result.add(group) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
505 # return result |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
506 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
507 # def isContactInGroup(self, group, contact_jid): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
508 # """Test if the contact_jid is in the group |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
509 # @param group: string of single group, or list of string |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
510 # @param contact_jid: jid to test |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
511 # @return: True if contact_jid is in on of the groups""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
512 # if group in self.groups and contact_jid in self.groups[group]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
513 # return True |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
514 # return False |
13 | 515 |
54
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
516 def isContactInRoster(self, contact_jid): |
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
517 """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
|
518 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
|
519 if contact_jid == contact_box.jid: |
54
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
520 return True |
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
521 return False |
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
51
diff
changeset
|
522 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
523 # def getContacts(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
524 # return self._contacts_panel.getContacts() |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
525 |
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
|
526 def getGroups(self): |
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
|
527 return self.groups.keys() |
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
|
528 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
529 def onMouseMove(self, sender, x, y): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
530 pass |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
531 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
532 def onMouseDown(self, sender, x, y): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
533 pass |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
534 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
535 def onMouseUp(self, sender, x, y): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
536 pass |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
537 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
538 def onMouseEnter(self, sender): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
539 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
|
540 jids = self.getGroupData(sender.group, "jids") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
541 for contact in self._contacts_panel: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
542 if contact.jid in jids: |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
543 contact.label.addStyleName("selected") |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
200
diff
changeset
|
544 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
545 def onMouseLeave(self, sender): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
546 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
|
547 jids = self.getGroupData(sender.group, "jids") |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
548 for contact in self._contacts_panel: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
549 if contact.jid in jids: |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
550 contact.label.removeStyleName("selected") |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
551 |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
552 def updateAvatar(self, jid_s, url): |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
553 """Update the avatar of the given contact |
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
554 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
555 @param jid_s (unicode): contact jid |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
556 @param url (unicode): image url |
480
50b286866739
browser side: display avatars in the contact panel
souliane <souliane@mailoo.org>
parents:
479
diff
changeset
|
557 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
558 self._contacts_panel.updateAvatar(jid_s, url) |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
559 |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
560 def onAvatarUpdate(self, jid_, hash_, profile): |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
561 """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
|
562 |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
563 @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
|
564 @param hash_: hash of the avatar |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
565 @param profile: should be C.PROF_KEY_NONE |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
566 """ |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
567 self._contacts_panel.updateAvatar(jid_, self.host.getAvatarURL(jid_)) |
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
568 |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
569 def hasVisibleMembers(self, group): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
570 """Tell if the given group actually has visible members |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
571 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
572 @param group (unicode): the group to check |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
573 @return: boolean |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
574 """ |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
575 for jid_ in self.groups[group]: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
576 if self._contacts_panel.getContactBox(jid_).isVisible(): |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
577 return True |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
578 return False |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
579 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
580 def offlineContactsToShow(self): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
581 """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
|
582 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
583 @return: boolean |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
584 """ |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
585 return self.host.getCachedParam('General', C.SHOW_OFFLINE_CONTACTS) == 'true' |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
586 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
587 def emtyGroupsToShow(self): |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
588 """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
|
589 |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
590 @return: boolean |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
591 """ |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
592 return self.host.getCachedParam('General', C.SHOW_EMPTY_GROUPS) == 'true' |
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
593 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
594 def updatePresence(self, entity, show, priority, statuses): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
595 QuickContactList.updatePresence(self, entity, show, priority, statuses) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
596 entity_bare = entity.bare |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
597 show = self.getCache(entity_bare, C.PRESENCE_SHOW) # we use cache to have the show nformation of main resource only |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
598 self._contacts_panel.setState(entity_bare, "availability", show) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
599 |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
600 # def updateVisibility(self, jids, groups): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
601 # """Set the widgets visibility for the given contacts and groups |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
602 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
603 # @param jids (list[unicode]): list of JID |
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
604 # @param groups (list[unicode]): list of groups |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
605 # """ |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
606 # for jid_s in jids: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
607 # try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
608 # self._contacts_panel.getContactBox(jid_s).setVisible(jid_s in self.connected or self.offlineContactsToShow()) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
609 # except TypeError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
610 # log.warning('No box for contact %s: this code line should not be reached' % jid_s) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
611 # for group in groups: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
612 # try: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
613 # self._group_panel.getGroupBox(group).setVisible(self.hasVisibleMembers(group) or self.emtyGroupsToShow()) |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
614 # except TypeError: |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
615 # log.warning('No box for group %s: this code line should not be reached' % group) |
567
ee9c7bd266ad
browser_side: implements "Show offline contacts" and "Show empty groups" parameters
souliane <souliane@mailoo.org>
parents:
518
diff
changeset
|
616 |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
617 # def refresh(self): |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
618 # """Show or hide disconnected contacts and empty groups""" |
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
578
diff
changeset
|
619 # self.updateVisibility(self._contacts_panel.contacts, self.groups.keys()) |
600
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
620 |
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
621 |
601
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
622 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
|
623 """JID-friendly list implementation for Pyjamas""" |
600
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
624 |
32dbbc941123
browser_side: fixes the contact group manager
souliane <souliane@mailoo.org>
parents:
594
diff
changeset
|
625 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
|
626 """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
|
627 |
601
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
628 @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
|
629 @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
|
630 """ |
49ccfc22116c
browser_side: fixes class JIDList, remove JIDSet and JIDDict which are actually not needed
souliane <souliane@mailoo.org>
parents:
600
diff
changeset
|
631 # 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
|
632 # 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
|
633 # 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
|
634 # 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
|
635 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
|
636 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
|
637 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
|
638 return False |