annotate libervia.py @ 14:9bf8ed012adc

- Group microblog management, first draft - Bad connexion issue fixed
author Goffi <goffi@goffi.org>
date Thu, 07 Apr 2011 22:27:36 +0200
parents 0110d4e1d816
children 099c05a0dcab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
3
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Libervia: a Salut à Toi frontend
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
7
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
12
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU Affero General Public License for more details.
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
17
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU Affero General Public License
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
21
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import pyjd # this is dummy in pyjs
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from pyjamas.ui.SimplePanel import SimplePanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.RootPanel import RootPanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.VerticalPanel import VerticalPanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from pyjamas.ui.HorizontalPanel import HorizontalPanel
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
27 from pyjamas.ui.HTMLPanel import HTMLPanel
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
28 from pyjamas.ui.Grid import Grid
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.Label import Label
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui import HasAlignment
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.MenuBar import MenuBar
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.MenuItem import MenuItem
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
33 from pyjamas.ui.AutoComplete import AutoCompleteTextBox
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
34 from pyjamas.ui.DropWidget import DropWidget
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas import Window
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from pyjamas.JSONService import JSONProxy
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
37 from pyjamas.ui.KeyboardListener import KEY_ENTER
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from register import RegisterPanel, RegisterBox
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
39 from pyjamas import DOM
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
40 from contact import ContactPanel
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
41 from datetime import datetime
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
42
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
43
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
44 class LiberviaJsonProxy(JSONProxy):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
45 def __init__(self, *args, **kwargs):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
46 JSONProxy.__init__(self, *args, **kwargs)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.handler=self
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.cb={}
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
49
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
50 def call(self, method, cb, *args):
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
51 if cb:
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
52 self.cb[method] = cb
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
53 self.callMethod(method,args)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
54
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
55 def onRemoteResponse(self, response, request_info):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
56 if self.cb.has_key(request_info.method):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
57 self.cb[request_info.method](response)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
58 del self.cb[request_info.method]
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
59
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
60 def onRemoteError(self, code, errobj, request_info):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
61 if code != 0:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
62 Window.alert("Internal server error")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
63 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
64 if isinstance(errobj['message'],dict):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
65 Window.alert("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString']))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
66 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
67 Window.alert("Error: %s" % errobj['message'])
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
68
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
69 class RegisterCall(LiberviaJsonProxy):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
70 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
71 LiberviaJsonProxy.__init__(self, "/register_api",
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
72 ["isRegistered","isConnected","connect"])
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
73 self.handler=self
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
74 self.cb={}
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
75
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
76 class BridgeCall(LiberviaJsonProxy):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
77 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
78 LiberviaJsonProxy.__init__(self, "/json_api",
14
9bf8ed012adc - Group microblog management, first draft
Goffi <goffi@goffi.org>
parents: 13
diff changeset
79 ["getContacts", "sendMblog", "getMblogNodes"])
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
80
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
81 class BridgeSignals(LiberviaJsonProxy):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
82 def __init__(self):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
83 LiberviaJsonProxy.__init__(self, "/json_signal_api",
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
84 ["getSignals"])
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
85
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
86 class MenuCmd:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
87
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
88 def __init__(self, object, handler):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
89 self._object = object
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
90 self._handler = handler
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
91
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
92 def execute(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
93 handler = getattr(self._object, self._handler)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
94 handler()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
95
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
96 class Menu(SimplePanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
97
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
98 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
99 SimplePanel.__init__(self)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
100
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
101 menu_general = MenuBar(vertical=True)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
102 menu_general.addItem("Properties", MenuCmd(self, "onProperties"))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
103
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
104 menu_games = MenuBar(vertical=True)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
105 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
106 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
107
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
108 menubar = MenuBar(vertical=False)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
109 menubar.addItem(MenuItem("General", menu_general))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
110 menubar.addItem(MenuItem("Games", True, menu_games))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
111 self.add(menubar)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
112
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
113 def onProperties(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
114 Window.alert("Properties selected")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
115
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
116 def onTarotGame(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
117 Window.alert("Tarot selected")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
118
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
119 def onXiangqiGame(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
120 Window.alert("Xiangqi selected")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
121
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
122 class MagicBox(AutoCompleteTextBox):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
123
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
124 def __init__(self, host):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
125 AutoCompleteTextBox.__init__(self)
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
126 self.host = host
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
127
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
128 def addKey(self, key):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
129 self.getCompletionItems().completions.append(key)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
130
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
131 def onKeyPress(self, sender, keycode, modifiers):
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
132 if keycode == KEY_ENTER and not self.visible:
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
133 self.host.bridge.call('sendMblog', None, self.getText())
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
134 self.setText('')
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
135
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
136 def complete(self):
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
137 #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
138 #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
139 return AutoCompleteTextBox.complete(self)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
140
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
141 class EmptyPanel(DropWidget, SimplePanel):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
142 """Empty dropable panel"""
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
143
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
144 def __init__(self, host, data):
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
145 SimplePanel.__init__(self)
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
146 self.host = host
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
147 self.data = data
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
148 _panel = HTMLPanel("&nbsp;")
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
149 self.add(_panel)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
150 self.setHeight('100%')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
151 DropWidget.__init__(self)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
152
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
153 def onDragEnter(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
154 self.addStyleName('dragover')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
155 DOM.eventPreventDefault(event)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
156
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
157 def onDragLeave(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
158 self.removeStyleName('dragover')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
159
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
160 def onDragOver(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
161 DOM.eventPreventDefault(event)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
162
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
163 def onDrop(self, event):
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
164 print "Empty Panel: onDrop"
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
165 dt = event.dataTransfer
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
166 #'text', 'text/plain', and 'Text' are equivalent.
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
167 try:
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
168 item = dt.getData("text/plain")
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
169 item_type = dt.getData("type")
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
170 print "message: %s" % item
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
171 print "type: %s" % item_type
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
172 except:
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
173 print "no message found"
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
174 item='&nbsp;'
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
175 item_type = None
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
176 DOM.eventPreventDefault(event)
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
177 _mblog = MicroblogPanel(self.host, item)
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
178 if item_type=="GROUP":
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
179 _mblog.setAcceptedGroup(item)
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
180 self.host.mpanels.insert(0,_mblog)
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
181 self.host.middle_panel.changePanel(self.data,self.host.mpanels[0])
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
182
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
183
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
184
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
185 class MicroblogEntry(SimplePanel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
186
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
187 def __init__(self, body, author, timestamp):
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
188 SimplePanel.__init__(self)
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
189
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
190 _datetime = datetime.fromtimestamp(timestamp)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
191
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
192 panel = HTMLPanel("<div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div><div class='mb_entry_body'>%(body)s</div>" %
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
193 {"author": author,
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
194 "timestamp": _datetime,
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
195 "body": body}
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
196 )
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
197 panel.setStyleName('microblogEntry')
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
198 self.add(panel)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
199
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
200
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
201 class MicroblogPanel(VerticalPanel):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
202
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
203 def __init__(self,host, title='&nbsp;', accept_all=False):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
204 self.host = host
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
205 self.accept_all = accept_all
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
206 title=title.replace('<','&lt;').replace('>','&gt;')
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
207 VerticalPanel.__init__(self)
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
208 self.accepted_groups = []
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
209 _class = ['mb_panel_header']
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
210 if title == '&nbsp;':
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
211 _class.append('empty_header')
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
212 self.add(HTMLPanel("<div class='%s'>%s</div>" % (','.join(_class),title)))
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
213 self.setStyleName('microblogPanel')
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
214
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
215 def addEntry(self, text, author=None, timestamp=None):
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
216 """Add an entry to the panel
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
217 @param text: main text of the entry
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
218 @param author: who wrote the entry
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
219 @param date: when the entry was written"""
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
220 _entry = MicroblogEntry(text, author, timestamp)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
221 self.add(_entry)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
222
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
223 def setAcceptedGroup(self, group):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
224 """Set the group which can be displayed in this panel
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
225 @param group: string of the group, or list of string
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
226 """
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
227 if isinstance(group, list):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
228 self.accepted_groups.extend(group)
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
229 else:
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
230 self.accepted_groups.append(group)
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
231
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
232 def isJidAccepted(self, jid):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
233 """Tell if a jid is actepted and show in this panel
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
234 @param jid: jid
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
235 @return: True if the jid is accepted"""
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
236 if self.accept_all:
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
237 return True
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
238 for group in self.accepted_groups:
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
239 if self.host.contactPanel.isContactInGroup(group, jid):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
240 return True
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
241 return False
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
242
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
243
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
244 class MiddlePannel(HorizontalPanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
245
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
246 def __init__(self, host):
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
247 self.host=host
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
248 HorizontalPanel.__init__(self)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
249 self._left = self.host.contactPanel
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
250 self._right = Grid(1,3)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
251 self._right.setWidth('100%')
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
252 self._right.setHeight('100%')
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
253 self.add(self._left)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
254 self.setCellWidth(self._left, "15%")
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
255 self.add(self._right)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
256 self.setCellWidth(self._right, "85%")
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
257 self.setHeight('100%')
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
258
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
259 def changePanel(self, idx, panel):
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
260 print "panel:",panel
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
261 print "idx:",idx
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
262 self._right.setWidget(0,idx,panel)
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
263
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
264 class MainPanel(VerticalPanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
265
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
266 def __init__(self, host):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
267 self.host=host
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
268 VerticalPanel.__init__(self)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
269
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
270 self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
271 self.setVerticalAlignment(HasAlignment.ALIGN_TOP)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
272
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
273 menu = Menu()
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
274 magic_box = host.magicBox
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
275 self.middle_panel = MiddlePannel(self.host)
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
276 self.middle_panel.setWidth('100%')
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
277
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
278 self.add(menu)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
279 self.add(magic_box)
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
280 self.add(self.middle_panel)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
281
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
282 self.setCellHeight(menu, "5%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
283 self.setCellHeight(magic_box, "5%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
284 self.setCellVerticalAlignment(magic_box, HasAlignment.ALIGN_CENTER)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
285 self.setCellHorizontalAlignment(magic_box, HasAlignment.ALIGN_CENTER)
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
286 self.setCellHeight(self.middle_panel, "90%")
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
287 self.setCellWidth(self.middle_panel, "100%")
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
288
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
289 self.setWidth("100%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
290 self.setHeight("100%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
291
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
292 class SatWebFrontend:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
293 def onModuleLoad(self):
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
294 self.bridge = BridgeCall()
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
295 self.bridge_signals = BridgeSignals()
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
296 self.magicBox = MagicBox(self)
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
297 self.magicBox.addKey("@@: ")
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
298 self.contactPanel = ContactPanel(self)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
299 self.panel = MainPanel(self)
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
300 self.middle_panel = self.panel.middle_panel
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
301 self.mpanels = [MicroblogPanel(self, accept_all=True)]
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
302 self.middle_panel.changePanel(1,self.mpanels[0])
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
303 self.middle_panel.changePanel(0,EmptyPanel(self, 0))
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
304 self.middle_panel.changePanel(2,EmptyPanel(self, 2))
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
305 self._dialog = None
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
306 RootPanel().add(self.panel)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
307 self._register = RegisterCall()
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
308 self._register.call('isRegistered',self._isRegisteredCB)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
309
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
310 def _isRegisteredCB(self, registered):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
311 if not registered:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
312 self._dialog = RegisterBox(self.logged,centered=True)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
313 self._dialog.show()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
314 else:
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
315 self._register.call('isConnected', self._isConnectedCB)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
316
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
317 def _isConnectedCB(self, connected):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
318 if not connected:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
319 self._register.call('connect',self.logged)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
320 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
321 self.logged()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
322
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
323 def logged(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
324 if self._dialog:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
325 self._dialog.hide()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
326 del self._dialog # don't work if self._dialog is None
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
327
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
328 #it's time to fill the page
11
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
329 self.bridge.call('getContacts', self._getContactsCB)
331c093e4eb3 magicBox is now able to send global microblog
Goffi <goffi@goffi.org>
parents: 9
diff changeset
330 self.bridge_signals.call('getSignals', self._getSignalsCB)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
331
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
332 def _getContactsCB(self, contacts_data):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
333 for contact in contacts_data:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
334 jid, attributes, groups = contact
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
335 self.contactPanel.addContact(jid, attributes, groups)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
336
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
337 def _getSignalsCB(self, signal_data):
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
338 bridge_signals = BridgeSignals()
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
339 bridge_signals.call('getSignals', self._getSignalsCB)
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
340 print('Got signal ==> name: %s, params: %s' % (signal_data[0],signal_data[1]))
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
341 name,args = signal_data
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
342 if name == 'personalEvent':
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
343 self._personalEventCb(*args)
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
344
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
345 ## Signals callbacks ##
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
346
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
347 def _personalEventCb(self, sender, event_type, data, profile):
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
348 if event_type == "MICROBLOG":
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
349 if not data.has_key('content'):
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
350 print ("WARNING: No content found in microblog data")
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
351 return
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
352 for panel in self.mpanels:
13
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
353 if isinstance(panel,MicroblogPanel) and panel.isJidAccepted(sender):
0110d4e1d816 microblog panel filtering
Goffi <goffi@goffi.org>
parents: 11
diff changeset
354 print "sender:",sender
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
355 content = data['content']
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
356 author = data.get('author')
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
357 print "timestamp: %s" % data.get('timestamp')
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
358 timestamp = float(data.get('timestamp',0)) #XXX: int doesn't work here
4
7325e787c22b personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents: 2
diff changeset
359 panel.addEntry(content, author, timestamp)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
360
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
361 if __name__ == '__main__':
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
362 pyjd.setup("http://localhost:8080/libervia.html")
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
363 app = SatWebFrontend()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
364 app.onModuleLoad()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
365 pyjd.run()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
366