Annotate

core/offlinemanager.lua @ 286:7e4908d4bdf6

Merge with Waqas changes to mod_saslauth.
author Tobias Markmann <tm@ayena.de>
date Sat, 15 Nov 2008 19:25:51 +0100
parent 267:6303b7454ad0
child 519:cccd610a0ef9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
249
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local datamanager = require "util.datamanager";
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 local st = require "util.stanza";
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4 local datetime = require "util.datetime";
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 local ipairs = ipairs;
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 module "offlinemanager"
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 function store(node, host, stanza)
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 stanza.attr.stamp = datetime.datetime();
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11 stanza.attr.stamp_legacy = datetime.legacy();
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 return datamanager.list_append(node, host, "offline", st.preserialize(stanza));
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 end
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 function load(node, host)
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 local data = datamanager.list_load(node, host, "offline");
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 if not data then return; end
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 for k, v in ipairs(data) do
267
6303b7454ad0 Some bugs fixed
Waqas Hussain <waqas20@gmail.com>
parents: 249
diff changeset
19 local stanza = st.deserialize(v);
249
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 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
21 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
22 stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 data[k] = stanza;
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24 end
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
25 return data;
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
26 end
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28 function deleteAll(node, host)
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29 return datamanager.list_store(node, host, "offline", nil);
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30 end
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31
1fc47cf5d144 Added basic offline message support
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 return _M;