# HG changeset patch # User Goffi # Date 1306433621 -7200 # Node ID 72c51a4839cce190255e24cf76a24d066467a1fb # Parent f1d2eb9b25239b33a4f8f4a54091df57bae90016 MUC group joining diff -r f1d2eb9b2523 -r 72c51a4839cc browser_side/panels.py --- a/browser_side/panels.py Thu May 26 19:15:44 2011 +0200 +++ b/browser_side/panels.py Thu May 26 20:13:41 2011 +0200 @@ -29,10 +29,13 @@ from pyjamas.ui.TabPanel import TabPanel from pyjamas.ui.HTMLPanel import HTMLPanel from pyjamas.ui.Grid import Grid +from pyjamas.ui.DialogBox import DialogBox from pyjamas.ui.AutoComplete import AutoCompleteTextBox from pyjamas.ui.MenuBar import MenuBar from pyjamas.ui.MenuItem import MenuItem from pyjamas.ui.Label import Label +from pyjamas.ui.TextBox import TextBox +from pyjamas.ui.Button import Button from pyjamas.ui.HTML import HTML from pyjamas.ui.Frame import Frame from pyjamas.ui.DropWidget import DropWidget @@ -72,12 +75,16 @@ menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract")) menu_general.addItem("About", MenuCmd(self, "onAbout")) + menu_group = MenuBar(vertical=True) + menu_group.addItem("join room", MenuCmd(self, "onJoinRoom")) + menu_games = MenuBar(vertical=True) menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame")) menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame")) menubar = MenuBar(vertical=False) menubar.addItem(MenuItem("General", menu_general)) + menubar.addItem(MenuItem("Groups", menu_group)) menubar.addItem(MenuItem("Games", True, menu_games)) self.add(menubar) @@ -101,6 +108,40 @@ _dialog = dialog.InfoDialog("About", _about) _dialog.show() + #Group menu + def onJoinRoom(self): + _dialog = None + _edit = None + + def onOK(sender): + if not _edit.getText(): + Window.alert('You must enter a room jid in the form libervia@conference.libervia.org') + if self.host.whoami: + nick = self.host.whoami.node + self.host.bridge.call('joinMUC', None, _edit.getText(), nick) + _dialog.hide() + + def onCancel(sender): + _dialog.hide() + + _main_panel = VerticalPanel() + _label = Label("Discussion room:") + _edit = TextBox() + _edit.setText('libervia@conference.tazar.int') + hpanel = HorizontalPanel() + hpanel.add(_label) + hpanel.add(_edit) + _main_panel.add(hpanel) + button_panel = HorizontalPanel() + button_panel.add(Button("Join", onOK)) + button_panel.add(Button("Cancel", onCancel)) + _main_panel.add(button_panel) + _dialog = DialogBox(centered=True) + _dialog.setHTML('Group discussions') + _dialog.setWidget(_main_panel) + _dialog.show() + + #Game menu def onTarotGame(self): diff -r f1d2eb9b2523 -r 72c51a4839cc libervia.py --- a/libervia.py Thu May 26 19:15:44 2011 +0200 +++ b/libervia.py Thu May 26 20:13:41 2011 +0200 @@ -65,8 +65,8 @@ class BridgeCall(LiberviaJsonProxy): def __init__(self): LiberviaJsonProxy.__init__(self, "/json_api", - ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", - "getPresenceStatus", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", + ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus", + "joinMUC", "getRoomJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards"]) class BridgeSignals(LiberviaJsonProxy): diff -r f1d2eb9b2523 -r 72c51a4839cc libervia.tac --- a/libervia.tac Thu May 26 19:15:44 2011 +0200 +++ b/libervia.tac Thu May 26 20:13:41 2011 +0200 @@ -187,6 +187,16 @@ return {} return self.sat_host.bridge.getHistory(from_jid, to_jid, size) + def jsonrpc_joinMUC(self, room_jid, nick): + """Join a Multi-User Chat room""" + profile = ISATSession(self.session).profile + try: + room_jid = JID(room_jid) + except: + warning('Invalid room jid') + return + self.sat_host.bridge.joinMUC(room_jid.host, room_jid.user, nick, profile) + def jsonrpc_getRoomJoined(self): """Return list of room already joined by user""" profile = ISATSession(self.session).profile @@ -360,10 +370,12 @@ login: %(login)s password: %(password)s +Your Jabber ID (JID) is: %(jid)s + Any feedback welcome Cheers -Goffi""" % { 'login': login, 'password': password }).encode('utf-8') +Goffi""" % { 'login': login, 'password': password, 'jid':"%s@%s" % (login, _NEW_ACCOUNT_DOMAIN) }).encode('utf-8') msg = MIMEText(body, 'plain', 'UTF-8') msg['Subject'] = 'Libervia account created' msg['From'] = _email_from @@ -382,7 +394,6 @@ d = sendmail(_email_host, _email_from, email, msg.as_string()) d.addCallbacks(email_ok, email_ko) - print "rturn REGISTRATION" return "REGISTRATION" def __cleanWaiting(self, login):