comparison browser_side/menu.py @ 242:a25aa882e09a

browser_side: add context menu for contact: - for now only when a blog exists on the current libervia's server - retrieve the server domain with the bridge method getNewAccountDomain - getNewAccountDomain is also used to display the current libervia domain in the dialogs (new contact default domain, messages for invalid contact or group)
author souliane <souliane@mailoo.org>
date Fri, 18 Oct 2013 11:14:55 +0200
parents dec76d4536ad
children 0e7f3944bd27
comparison
equal deleted inserted replaced
241:86055ccf69c3 242:a25aa882e09a
184 self.host.addTab(web_panel, "Web widget") 184 self.host.addTab(web_panel, "Web widget")
185 185
186 def onDisconnect(self): 186 def onDisconnect(self):
187 def confirm_cb(answer): 187 def confirm_cb(answer):
188 if answer: 188 if answer:
189 print "déconnexion" 189 print "disconnection"
190 self.host.bridge.call('disconnect', None) 190 self.host.bridge.call('disconnect', None)
191 _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?") 191 _dialog = dialog.ConfirmDialog(confirm_cb, text="Do you really want to disconnect ?")
192 _dialog.show() 192 _dialog.show()
193 193
194 def onSocialContract(self): 194 def onSocialContract(self):
216 """Q&D contact addition""" 216 """Q&D contact addition"""
217 _dialog = None 217 _dialog = None
218 edit = TextBox() 218 edit = TextBox()
219 219
220 def addContactCb(sender): 220 def addContactCb(sender):
221 if not re.match(r'^.+@.+\..+',edit.getText(), re.IGNORECASE): 221 if not re.match(r'^.+@.+\..+', edit.getText(), re.IGNORECASE):
222 Window.alert('You must enter a valid contact JID (like "contact@libervia.org")') 222 Window.alert('You must enter a valid contact JID (like "contact@%s")' % self.host._defaultDomain)
223 _dialog.show() 223 _dialog.show()
224 else: 224 else:
225 self.host.bridge.call('addContact', None, edit.getText(), '', _dialog.getSelectedGroups() ) 225 self.host.bridge.call('addContact', None, edit.getText(), '', _dialog.getSelectedGroups() )
226 226
227 label = Label("new contact identifier (JID):") 227 label = Label("new contact identifier (JID):")
228 edit.setText('@libervia.org') 228 edit.setText('@%s' % self.host._defaultDomain)
229 edit.setWidth('100%') 229 edit.setWidth('100%')
230 _dialog = dialog.GroupSelector([label, edit], self.host.contact_panel.getGroups(), [], 230 _dialog = dialog.GroupSelector([label, edit], self.host.contact_panel.getGroups(), [],
231 "Add", addContactCb) 231 "Add", addContactCb)
232 _dialog.setHTML('Adding contact') 232 _dialog.setHTML('Adding contact')
233 _dialog.show() 233 _dialog.show()
283 _dialog = None 283 _dialog = None
284 _edit = None 284 _edit = None
285 285
286 def onOK(sender): 286 def onOK(sender):
287 if not _edit.getText(): 287 if not _edit.getText():
288 Window.alert('You must enter a room jid in the form libervia@conference.libervia.org') 288 Window.alert('You must enter a room jid in the form room@chat.%s' % self.host._defaultDomain)
289 if self.host.whoami: 289 if self.host.whoami:
290 nick = self.host.whoami.node 290 nick = self.host.whoami.node
291 self.host.bridge.call('joinMUC', None, _edit.getText(), nick) 291 self.host.bridge.call('joinMUC', None, _edit.getText(), nick)
292 _dialog.hide() 292 _dialog.hide()
293 293
323 def onTarotGame(self): 323 def onTarotGame(self):
324 #Window.alert("Tarot selected") 324 #Window.alert("Tarot selected")
325 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot") 325 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot")
326 def onPlayersSelected(other_players): 326 def onPlayersSelected(other_players):
327 self.host.bridge.call('launchTarotGame', None, other_players) 327 self.host.bridge.call('launchTarotGame', None, other_players)
328 dialog.ContactsChooser(self.host, onPlayersSelected, 3, text="Please select 3 other players").getContacts() 328 dialog.ContactsChooser(self.host, onPlayersSelected, 3, text="Please select 3 other players").getContacts()
329 329
330 def onXiangqiGame(self): 330 def onXiangqiGame(self):
331 Window.alert("A Xiangqi game is planed, but not available yet") 331 Window.alert("A Xiangqi game is planed, but not available yet")
332 332
333 #Settings menu 333 #Settings menu