Mercurial > eldonilo > lightstring
comparison plugins/im.js @ 106:c06ec02217ee
many changes
| author | Sonny Piers <sonny@fastmail.net> |
|---|---|
| date | Tue, 26 Jun 2012 12:02:14 +0200 |
| parents | f23e4741a7c5 |
| children | 5cb4733c5189 |
comparison
equal
deleted
inserted
replaced
| 105:fb50311997b5 | 106:c06ec02217ee |
|---|---|
| 17 */ | 17 */ |
| 18 | 18 |
| 19 ////// | 19 ////// |
| 20 //IM// | 20 //IM// |
| 21 ////// | 21 ////// |
| 22 Lightstring.plugins['message'] = { | 22 Lightstring.plugins['im'] = { |
| 23 stanzas: { | 23 stanzas: { |
| 24 normalMessage: function(aTo, aSubject, aText) { | 24 normal: function(aTo, aSubject, aText) { |
| 25 return "<message type='normal' to='" + aTo + "'><subject>" + aSubject + "</subject><body>" + aText + "</body></message>"; | 25 return( |
| 26 "<message type='normal' to='" + aTo + "'>" + | |
| 27 "<subject>" + aSubject + "</subject>" + | |
| 28 "<body>" + aText + "</body>" + | |
| 29 "</message>" | |
| 30 ); | |
| 26 }, | 31 }, |
| 27 chatMessage: function(aTo, aText) { | 32 chat: function(aTo, aText, aReceipt) { |
| 28 return "<message type='chat' to='" + aTo + "'><body>" + aText + "</body></message>"; | 33 var message = Lightstring.parse( |
| 29 } | 34 "<message type='chat' to='" + aTo + "'>" + |
| 35 "<body>" + aText + "</body>" + | |
| 36 "</message>" | |
| 37 ); | |
| 38 | |
| 39 if (aReceipt) { | |
| 40 var receipt = document.createElement('request'); | |
| 41 receipt.setAttribute('xmlns', 'urn:xmpp:receipts'); | |
| 42 message.appendChild(receipt); | |
| 43 message.setAttribute('id', Lightstring.newId()); | |
| 44 } | |
| 45 | |
| 46 return message; | |
| 47 }, | |
| 48 received: function(aTo, aId) { | |
| 49 var message = Lightstring.parse( | |
| 50 "<message to='" + aTo + "'>" + | |
| 51 "<received xmlns='urn:xmpp:receipts' id='" + aId + "'/>" + | |
| 52 "</message>" | |
| 53 ); | |
| 54 return message; | |
| 55 }, | |
| 56 read: function(aTo, aId) { | |
| 57 var message = Lightstring.parse( | |
| 58 "<message to='" + aTo + "'>" + | |
| 59 "<read xmlns='urn:xmpp:receipts' id='" + aId + "'/>" + | |
| 60 "</message>" | |
| 61 ); | |
| 62 return message; | |
| 63 }, | |
| 30 } | 64 } |
| 31 }; | 65 }; |
