Annotate

core/offlinemanager.lua @ 2177:8505e1da5408 sasl

Adding some docu.
author Tobias Markmann <tm@ayena.de>
date Sun, 16 Aug 2009 23:20:02 +0200
parent 1523:841d61be198f
child 2923:b7049746bd29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1523
841d61be198f Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents: 896
diff changeset
1 -- Prosody IM
760
90ce865eebd8 Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents: 759
diff changeset
2 -- Copyright (C) 2008-2009 Matthew Wild
90ce865eebd8 Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents: 759
diff changeset
3 -- Copyright (C) 2008-2009 Waqas Hussain
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 267
diff changeset
4 --
758
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
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
6303b7454ad0 Some bugs fixed
Waqas Hussain <waqas20@gmail.com>
parents: 249
diff changeset
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;