comparison src/browser/sat_browser/contact_list.py @ 909:e8b133b77aa4

browser, server: update to get compatibility with 0.7-dev (not finished): Q&D update to restore compatibility - version changed to 0.7D - contact list has been modified to be compatible with changes, but it doesn't take profit of improvment yet - messageSend partially work, there is a disconnection and an error in console logs when sending a message - message are not received yet
author Goffi <goffi@goffi.org>
date Tue, 09 Aug 2016 01:07:15 +0200
parents f8a7a046ff9c
children 997cf25e785c
comparison
equal deleted inserted replaced
908:f38b8be94131 909:e8b133b77aa4
61 61
62 def __init__(self, parent): 62 def __init__(self, parent):
63 VerticalPanel.__init__(self) 63 VerticalPanel.__init__(self)
64 self.setStyleName('groupPanel') 64 self.setStyleName('groupPanel')
65 self._parent = parent 65 self._parent = parent
66 self._groups = set() 66
67 @property
68 def _groups(self):
69 return self._parent.contact_list._groups
67 70
68 def add(self, group): 71 def add(self, group):
69 if group in self._groups: 72 if group in self._groups:
70 log.warning("trying to add an already existing group") 73 log.warning("trying to add an already existing group")
71 return 74 return
97 if isinstance(wid, GroupLabel) and wid.group == group: 100 if isinstance(wid, GroupLabel) and wid.group == group:
98 return wid 101 return wid
99 return None 102 return None
100 103
101 def getGroups(self): 104 def getGroups(self):
102 return self._groups 105 return set([g for g in self._groups if g is not None])
103 106
104 107
105 class ContactTitleLabel(libervia_widget.DragLabel, Label, ClickHandler): 108 class ContactTitleLabel(libervia_widget.DragLabel, Label, ClickHandler):
106 109
107 def __init__(self, host, text): 110 def __init__(self, host, text):
116 119
117 120
118 class ContactList(SimplePanel, QuickContactList): 121 class ContactList(SimplePanel, QuickContactList):
119 """Manage the contacts and groups""" 122 """Manage the contacts and groups"""
120 123
121 def __init__(self, host): 124 def __init__(self, host, target, on_click=None, on_change=None, user_data=None, profiles=None):
122 QuickContactList.__init__(self, host, C.PROF_KEY_NONE) 125 QuickContactList.__init__(self, host, C.PROF_KEY_NONE)
126 self.contact_list = self.host.contact_list
123 SimplePanel.__init__(self) 127 SimplePanel.__init__(self)
124 self.host = host 128 self.host = host
125 self.scroll_panel = ScrollPanel() 129 self.scroll_panel = ScrollPanel()
126 self.scroll_panel.addStyleName("gwt-ScrollPanel") # XXX: no class is set by Pyjamas 130 self.scroll_panel.addStyleName("gwt-ScrollPanel") # XXX: no class is set by Pyjamas
127 self.vPanel = VerticalPanel() 131 self.vPanel = VerticalPanel()
144 Window.addWindowResizeListener(self) 148 Window.addWindowResizeListener(self)
145 149
146 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword) 150 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
147 self.avatarListener = self.onAvatarUpdate 151 self.avatarListener = self.onAvatarUpdate
148 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE]) 152 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE])
153 self.postInit()
149 154
150 @property 155 @property
151 def profile(self): 156 def profile(self):
152 return C.PROF_KEY_NONE 157 return C.PROF_KEY_NONE
153 158
154 def onDelete(self): 159 def onDelete(self):
155 QuickContactList.onDelete(self) 160 QuickContactList.onDelete(self)
156 self.host.removeListener('avatar', self.avatarListener) 161 self.host.removeListener('avatar', self.avatarListener)
157 162
158 def update(self): 163 def update(self, entities=None, type_=None, profile=None):
159 # XXX: as update is slow, we avoid many updates on profile plugs 164 # XXX: as update is slow, we avoid many updates on profile plugs
160 # and do them all at once at the end 165 # and do them all at once at the end
161 if not self.host._profile_plugged: 166 if not self.host._profile_plugged: # FIXME: should not be necessary anymore (done in QuickFrontend)
162 return 167 return
163 ### GROUPS ### 168 ### GROUPS ###
164 _keys = self._groups.keys() 169 _keys = self.contact_list._groups.keys()
165 try: 170 try:
166 # XXX: Pyjamas doesn't do the set casting if None is present 171 # XXX: Pyjamas doesn't do the set casting if None is present
167 _keys.remove(None) 172 _keys.remove(None)
168 except (KeyError, ValueError): # XXX: error raised depend on pyjama's compilation options 173 except (KeyError, ValueError): # XXX: error raised depend on pyjama's compilation options
169 pass 174 pass
175 self._group_panel.add(group) 180 self._group_panel.add(group)
176 for group in removed_groups: 181 for group in removed_groups:
177 self._group_panel.remove(group) 182 self._group_panel.remove(group)
178 183
179 ### JIDS ### 184 ### JIDS ###
180 to_show = [jid_ for jid_ in self.roster_entities if self.entityToShow(jid_) and jid_ != self.whoami.bare] 185 to_show = [jid_ for jid_ in self.contact_list.roster if self.contact_list.entityToShow(jid_) and jid_ != self.contact_list.whoami.bare]
181 to_show.sort() 186 to_show.sort()
182 187
183 self._contacts_panel.setList(to_show) 188 self._contacts_panel.setList(to_show)
184 189
185 def onWindowResized(self, width, height): 190 def onWindowResized(self, width, height):
195 if contact_jid == contact_box.jid: 200 if contact_jid == contact_box.jid:
196 return True 201 return True
197 return False 202 return False
198 203
199 def getGroups(self): 204 def getGroups(self):
200 return self.groups.keys() 205 return self._group_panel.getGroups()
201 206
202 def onMouseMove(self, sender, x, y): 207 def onMouseMove(self, sender, x, y):
203 pass 208 pass
204 209
205 def onMouseDown(self, sender, x, y): 210 def onMouseDown(self, sender, x, y):