Software /
code /
prosody
Annotate
core/offlinemanager.lua @ 3455:67cdc0366d46
util.logger: Remove support for the 'log_sources' option, to remove a dependency on configmanager. I think the equivalent of log_sources can be done with the advanced logging config.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 22 Aug 2010 18:45:58 +0100 |
parent | 2923:b7049746bd29 |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
1 -- Prosody IM |
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
267
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
267
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
267
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
267
diff
changeset
|
9 |
249
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 local datamanager = require "util.datamanager"; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 local st = require "util.stanza"; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 local datetime = require "util.datetime"; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 local ipairs = ipairs; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 module "offlinemanager" |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 function store(node, host, stanza) |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 stanza.attr.stamp = datetime.datetime(); |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 stanza.attr.stamp_legacy = datetime.legacy(); |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 return datamanager.list_append(node, host, "offline", st.preserialize(stanza)); |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 end |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 function load(node, host) |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 local data = datamanager.list_load(node, host, "offline"); |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 if not data then return; end |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 for k, v in ipairs(data) do |
267 | 28 local stanza = st.deserialize(v); |
249
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
31 stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 data[k] = stanza; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 end |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 return data; |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
35 end |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 function deleteAll(node, host) |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 return datamanager.list_store(node, host, "offline", nil); |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 end |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 |
1fc47cf5d144
Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 return _M; |