Mercurial > libervia-web
diff libervia.py @ 28:258dfaa1035f
browser side:
- roomJoined signal added and open a new tab
- name refactoring
- connected contact are saved
- launchTarotGame method used
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 07 May 2011 23:58:57 +0200 |
parents | 0ce2a57b34ca |
children | e70521e6d803 |
line wrap: on
line diff
--- a/libervia.py Sat May 07 23:54:21 2011 +0200 +++ b/libervia.py Sat May 07 23:58:57 2011 +0200 @@ -70,7 +70,7 @@ class BridgeCall(LiberviaJsonProxy): def __init__(self): LiberviaJsonProxy.__init__(self, "/json_api", - ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus"]) + ["getContacts", "sendMessage", "sendMblog", "getMblogNodes", "getProfileJid", "getHistory", "getPresenceStatus", "launchTarotGame"]) class BridgeSignals(LiberviaJsonProxy): def __init__(self): @@ -79,6 +79,7 @@ class UniBox(AutoCompleteTextBox): + """This text box is used as a main typing point, for message, microblog, etc""" def __init__(self, host): AutoCompleteTextBox.__init__(self) @@ -141,7 +142,7 @@ type = "STATUS" else: target = txt[1:_end] #only one target group is managed for the moment - if not target in self.host.contactPanel.getGroups(): + if not target in self.host.contact_panel.getGroups(): target = None elif self.host.selected == None: type = "STATUS" @@ -189,10 +190,10 @@ self.bridge = BridgeCall() self.bridge_signals = BridgeSignals() self.selected = None - self.uniBox = UniBox(self) - self.uniBox.addKey("@@: ") - self.statusPanel = StatusPanel(self) - self.contactPanel = ContactPanel(self) + self.uni_box = UniBox(self) + self.uni_box.addKey("@@: ") + self.status_panel = StatusPanel(self) + self.contact_panel = ContactPanel(self) self.panel = MainPanel(self) self.discuss_panel = self.panel.discuss_panel self.tab_panel = self.panel.tab_panel @@ -240,7 +241,7 @@ def _getContactsCB(self, contacts_data): for contact in contacts_data: jid, attributes, groups = contact - self.contactPanel.addContact(jid, attributes, groups) + self.contact_panel.addContact(jid, attributes, groups) def _getSignalsCB(self, signal_data): bridge_signals = BridgeSignals() @@ -253,6 +254,8 @@ self._newMessageCb(*args) elif name == 'presenceUpdate': self._presenceUpdateCb(*args) + elif name == 'roomJoined': + self._roomJoinedCb(*args) def _getProfileJidCB(self, jid): self.whoami = JID(jid) @@ -288,17 +291,27 @@ def _presenceUpdateCb(self, entity, show, priority, statuses): _entity = JID(entity) - #XXX: QnD way to only get our status + #XXX: QnD way to get our status if self.whoami and self.whoami.bare == _entity.bare and statuses: - self.statusPanel.changeStatus(statuses.values()[0]) + self.status_panel.changeStatus(statuses.values()[0]) + if not self.whoami or self.whoami.bare != _entity.bare: + self.contact_panel.setConnected(_entity.bare, _entity.resource, show, priority, statuses) + + def _roomJoinedCb(self, room_id, room_service, room_nicks, user_nick, profile): + print "roomJoined" + print room_id + _target = JID("%s@%s" % (room_id,room_service)) + if room_id.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :) + self.tab_panel.add(ChatPanel(self, _target), "Tarot") + else: + self.tab_panel.add(ChatPanel(self, _target), str(_target)) + def _getPresenceStatusCB(self, presence_data): - #XXX we are only interested in our own presence so far - if self.whoami and presence_data.has_key(self.whoami.bare): - myjid = self.whoami.bare - if presence_data[myjid]: - args = presence_data[myjid].values()[0] - self._presenceUpdateCb(myjid, *args) + for entity in presence_data: + for resource in presence_data[entity]: + args = presence_data[entity][resource] + self._presenceUpdateCb("%s/%s" % (entity, resource), *args) if __name__ == '__main__': pyjd.setup("http://localhost:8080/libervia.html")