annotate browser_side/contact.py @ 51:9f19e16187ff

browser side: HTML sanitization
author Goffi <goffi@goffi.org>
date Thu, 26 May 2011 23:03:45 +0200
parents 7cabe3c1a5f2
children f25c4077f6b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Libervia: a Salut à Toi frontend
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
7
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
12
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU Affero General Public License for more details.
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
17
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU Affero General Public License
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
21
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import pyjd # this is dummy in pyjs
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from pyjamas.ui.SimplePanel import SimplePanel
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.VerticalPanel import VerticalPanel
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.HorizontalPanel import HorizontalPanel
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from pyjamas.ui.Label import Label
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from pyjamas import Window
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas import DOM
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
29
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
30 from pyjamas.dnd import makeDraggable
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
31 from pyjamas.ui.DragWidget import DragWidget, DragContainer
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 17
diff changeset
32 from jid import JID
51
9f19e16187ff browser side: HTML sanitization
Goffi <goffi@goffi.org>
parents: 47
diff changeset
33 from tools import html_sanitize
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
34
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
35 class DragLabel(DragWidget):
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
36
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
37 def __init__(self, text, type):
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
38 DragWidget.__init__(self)
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
39 self._text = text
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
40 self._type = type
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
41
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
42 def onDragStart(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
43 print "onDragStart"
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
44 dt = event.dataTransfer
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
45 #self.addMessage('types is %s' % dt.getTypes())
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
46 dt.setData('Text', self._text)
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
47 dt.setData('type', self._type)
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
48 #self.addMessage('after setting, len is %s' % len(dt.dataStore.items))
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
49 #self.addMessage('types is %s' % dt.getTypes())
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
50 dt.setDragImage(self.getElement(), 15, 15)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
51 #dt.effectAllowed = 'copy'
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
52 #self.addMessage('mode is %s' % dt.dataStore.items.mode)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
53
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
54 def onDragEnd(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
55 print "onDragEnd"
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
56 #self.addMessage('Drag ended')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
57 #self.addMessage('mode is %s' % dt._data.mode)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
58
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
59 def addMessage(self, message):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
60 print "addMessage"
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
61 #parent = self.getParent()
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
62 #while not hasattr(parent, 'addMessage'):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
63 # parent = parent.getParent()
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 2
diff changeset
64 #parent.addMessage(message)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
65
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
66 class GroupLabel(DragLabel, Label):
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
67 def __init__(self, group):
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
68 self.group = group
51
9f19e16187ff browser side: HTML sanitization
Goffi <goffi@goffi.org>
parents: 47
diff changeset
69 Label.__init__(self, html_sanitize(group)) #, Element=DOM.createElement('div')
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
70 self.setStyleName('group')
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
71 DragLabel.__init__(self, group, "GROUP")
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
72
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
73
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 17
diff changeset
74 class ContactLabel(DragLabel, Label):
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
75 def __init__(self, jid, name=None):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
76 if not name:
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
77 name=jid
51
9f19e16187ff browser side: HTML sanitization
Goffi <goffi@goffi.org>
parents: 47
diff changeset
78 Label.__init__(self, html_sanitize(name))
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
79 self.jid=jid
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
80 self.setStyleName('contact')
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 17
diff changeset
81 DragLabel.__init__(self, jid, "CONTACT")
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
82
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
83 class GroupList(VerticalPanel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
84
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
85 def __init__(self, parent):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
86 VerticalPanel.__init__(self)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self._parent = parent
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
88
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
89 def add(self, group):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
90 _item = GroupLabel(group)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
91 _item.addMouseListener(self._parent)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
92 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer")
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
93 VerticalPanel.add(self, _item)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
94
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
95 class ContactList(VerticalPanel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
96
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
97 def __init__(self):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
98 VerticalPanel.__init__(self)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
99 self.contacts=[]
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
100
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def __iter__(self):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
102 return self.contacts.__iter__()
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
103
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
104 def add(self, jid, name=None):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
105 _item = ContactLabel(jid, name)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
106 DOM.setStyleAttribute(_item.getElement(), "cursor", "pointer")
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
107 VerticalPanel.add(self, _item)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
108 self.contacts.append(_item)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
109
47
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
110 def setState(self, jid, state):
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
111 """Change the appearance of the contact, according to the state
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
112 @param jid: jid which need to change state
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
113 @param state: 'unavailable' if not connected, else presence like RFC6121 #4.7.2.1"""
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
114 _item = None
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
115 for contact in self.contacts:
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
116 if contact.jid == jid:
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
117 _item = contact
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
118 break
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
119 if _item:
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
120 if state == 'unavailable':
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
121 _item.removeStyleName('contactConnected')
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
122 else:
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
123 _item.addStyleName('contactConnected')
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
124
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
125 class ContactTitleLabel(DragLabel, Label):
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
126 def __init__(self, text):
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
127 Label.__init__(self, text) #, Element=DOM.createElement('div')
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
128 self.setStyleName('contactTitle')
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 17
diff changeset
129 DragLabel.__init__(self, text, "CONTACT_TITLE")
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
130
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
131 class ContactPanel(SimplePanel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
132 """Manage the contacts and groups"""
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
133
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
134 def __init__(self, host):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
135 SimplePanel.__init__(self)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
136 self.host = host
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
137 self.groups={}
28
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
138 self.connected = {} #jid connected as key and their status
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
139
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
140 self.vPanel = VerticalPanel()
16
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
141 _title = ContactTitleLabel('Contacts')
099c05a0dcab browser side: microblog panel improvments
Goffi <goffi@goffi.org>
parents: 13
diff changeset
142 DOM.setStyleAttribute(_title.getElement(), "cursor", "pointer")
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
143
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
144 self._contactList = ContactList()
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
145 self._contactList.setStyleName('contactList')
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
146 self._groupList = GroupList(self)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
147 self._groupList.setStyleName('groupList')
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
148
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
149 self.vPanel.add(_title)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
150 self.vPanel.add(self._groupList)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
151 self.vPanel.add(self._contactList)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
152 self.add(self.vPanel)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
153 self.setStyleName('contactBox')
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
154
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
155 def addContact(self, jid, attributes, groups):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
156 """Add a contact to the panel
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
157 @param jid: jid
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
158 @attributes: cf SàT Bridge API's newContact
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
159 @param groups: list of groups"""
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
160 for group in groups:
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
161 if not self.groups.has_key(group):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
162 self.groups[group] = set()
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
163 self._groupList.add(group)
28
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
164 self.host.uni_box.addKey("@%s: " % group)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
165 self.groups[group].add(jid)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
166 self._contactList.add(jid)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
167
28
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
168 def setConnected(self, jid, resource, availability, priority, statuses):
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
169 """Set connection status"""
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
170 if availability=='unavailable':
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
171 if self.connected.has_key(jid):
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
172 if self.connected[jid].has_key(resource):
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
173 del self.connected[jid][resource]
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
174 if not self.connected[jid]:
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
175 del self.connected[jid]
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
176 else:
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
177 if not self.connected.has_key(jid):
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
178 self.connected[jid] = {}
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
179 self.connected[jid][resource] = (availability, priority, statuses)
47
7cabe3c1a5f2 browser side: connected contacts now appear differently
Goffi <goffi@goffi.org>
parents: 33
diff changeset
180 self._contactList.setState(jid, availability)
28
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
181
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
182 def getConnected(self):
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 28
diff changeset
183 """return a list of all jid (bare jid) connected"""
28
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
184 return self.connected.keys()
258dfaa1035f browser side:
Goffi <goffi@goffi.org>
parents: 22
diff changeset
185
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
186 def isContactInGroup(self, group, contact_jid):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
187 """Test if the contact_jid is in the group
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
188 @param group: string of single group, or list of string
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
189 @param contact_jid: jid to test
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
190 @return: True if contact_jid is in on of the groups"""
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
191 if self.groups.has_key(group) and contact_jid in self.groups[group]:
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
192 return True
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
193 return False
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 6
diff changeset
194
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
195 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
196 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
197
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
198 def onMouseMove(self, sender, x, y):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
199 pass
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
200
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
201 def onMouseDown(self, sender, x, y):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
202 pass
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
203
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
204 def onMouseUp(self, sender, x, y):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
205 pass
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
206
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
207 def onMouseEnter(self, sender):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
208 if isinstance(sender, GroupLabel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
209 for contact in self._contactList:
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
210 if contact.jid in self.groups[sender.group]:
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
211 contact.addStyleName("selected")
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
212
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
213 def onMouseLeave(self, sender):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
214 if isinstance(sender, GroupLabel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
215 for contact in self._contactList:
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
216 if contact.jid in self.groups[sender.group]:
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
diff changeset
217 contact.removeStyleName("selected")