diff options
| -rw-r--r-- | webclient/lib/alias.js | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/webclient/lib/alias.js b/webclient/lib/alias.js index 78fc4f4..f582587 100644 --- a/webclient/lib/alias.js +++ b/webclient/lib/alias.js @@ -138,22 +138,40 @@ var Alias = { }, /** - * Get the home node of a contact - * @param contact jquery object + * Get the home node of a user + * @param {String} owner The owner's JID */ - getHome: function(contact) { - var name = Base64.encode(Alias.getID(contact)) + '@' + server_component; - var iq = $iq({type : 'get', to : name}).c('query', {xmlns : 'alias:query', type:'content'}); - Alias.connection.sendIQ(iq, Alias.onHome); + getHome: function(owner) { + var objectName = MD5.hexdigest(owner); + Alias.getObject(objectName, owner); }, - + + /** + * Get the content of an object + * @param {String} object The hash identifying the requested object + * @param {String} owner The owner's JID + */ + getObject: function(object, owner) { + var name = Base64.encode(owner) + '@' + server_component; + var iq = $iq({type : 'get', to : name}).c('query', { + xmlns : 'alias:iq:object', + type : 'get', + node : object + }); + Alias.connection.sendIQ(iq, Alias.onObject); + }, + /** - * Called when receiving home node, display in the main div - * @param iq XML object + * Decrypt and display a received object + * @param {XMLElement} iq The received iq stanza from the component */ - onHome: function(iq) { - var content = $(iq).find('content').text(); - $('#main').html(content); + onObject: function(iq) { + var query = $(iq).find('query'); + var encryptedKey = query.find('key').text(); + var key = this.rsa.decrypt(encryptedKey); + var encryptedContent = query.find('content').text(); + var content = sjcl.decrypt(key, encryptedContent); + $('#profile').html(content); }, /** @@ -192,7 +210,9 @@ var Alias = { // init tooltip contact.tipTip({ - content: "<ul><li>Jid: " + jid + "</li><li><a>Start Chat</a></li></ul>", + content: "<ul><li>Jid: " + jid + + '</li><li><a href="'+ jid + +'" class="chat-link">Start Chat</a></li></ul>', defaultPosition: "right", keepAlive: true }); @@ -433,13 +453,16 @@ $(document).ready(function(){ $('.roster-contact').live('click', function(){ var jid = Alias.getID($(this)); - var name = Alias.getName($(this)); + Alias.getHome(jid); + }); + + $('.chat-link').live('click', function(event) { + event.preventDefault(); + var jid = $(this).attr('href'); var id = Alias.jid_to_id(jid); - if ( !$('#tabs').tabs('exist','#chat-' + id) ) { Alias.addChatTab(jid); } - $('#tabs').tabs('select', '#chat-' + id ); $('#chat-' + id + ' input').focus(); }); |
