Mercurial > eldonilo > lightstring
annotate 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 |
rev | line source |
---|---|
30
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 'use strict'; |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 /** |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 Copyright (c) 2011, Sonny Piers <sonny at fastmail dot net> |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 Permission to use, copy, modify, and/or distribute this software for any |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 purpose with or without fee is hereby granted, provided that the above |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 copyright notice and this permission notice appear in all copies. |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 */ |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 ////// |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 //IM// |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 ////// |
106 | 22 Lightstring.plugins['im'] = { |
46 | 23 stanzas: { |
106 | 24 normal: function(aTo, aSubject, aText) { |
25 return( | |
26 "<message type='normal' to='" + aTo + "'>" + | |
27 "<subject>" + aSubject + "</subject>" + | |
28 "<body>" + aText + "</body>" + | |
29 "</message>" | |
30 ); | |
46 | 31 }, |
106 | 32 chat: function(aTo, aText, aReceipt) { |
33 var message = Lightstring.parse( | |
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
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 } |
1506992c33e2
Split plugins.js into multiple plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 }; |