2 -- Copyright (C) 2008 Matthew Wild
3 -- Copyright (C) 2008 Waqas Hussain
5 -- This program is free software; you can redistribute it and/or
6 -- modify it under the terms of the GNU General Public License
7 -- as published by the Free Software Foundation; either version 2
8 -- of the License, or (at your option) any later version.
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 local datamanager = require "util.datamanager";
\r
23 local st = require "util.stanza";
\r
24 local datetime = require "util.datetime";
\r
25 local ipairs = ipairs;
\r
27 module "offlinemanager"
\r
29 function store(node, host, stanza)
\r
30 stanza.attr.stamp = datetime.datetime();
\r
31 stanza.attr.stamp_legacy = datetime.legacy();
\r
32 return datamanager.list_append(node, host, "offline", st.preserialize(stanza));
\r
35 function load(node, host)
\r
36 local data = datamanager.list_load(node, host, "offline");
\r
37 if not data then return; end
\r
38 for k, v in ipairs(data) do
\r
39 local stanza = st.deserialize(v);
\r
40 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203
\r
41 stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated)
\r
42 stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil;
\r
48 function deleteAll(node, host)
\r
49 return datamanager.list_store(node, host, "offline", nil);
\r