Annotate

mod_csi_battery_saver/mod_csi_battery_saver.lua @ 2746:d3a2f4bdaf09

mod_csi_battery_saver: Add config option for better muc handling
author tmolitor <thilo@eightysoft.de>
date Fri, 18 Aug 2017 22:56:28 +0200
parent 2745:b62cec32680e
child 2747:a688b31295ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
1 -- Copyright (C) 2016 Kim Alvefur
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
2 -- Copyright (C) 2017 Thilo Molitor
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
3 --
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
4
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
5 module:depends"csi"
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
6 module:depends"track_muc_joins"
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
7 local s_match = string.match;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
8 local s_sub = string.sub;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
9 local jid = require "util.jid";
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
10 local new_queue = require "util.queue".new;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
11 local datetime = require "util.datetime";
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
12 local st = require "util.stanza";
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
13
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
14 local xmlns_delay = "urn:xmpp:delay";
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
15
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
16 -- a log id for this module instance
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
17 local id = s_sub(require "util.hashes".sha256(datetime.datetime(), true), 1, 4);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
18
2746
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
19 local filter_muc = module:get_option_boolean("csi_battery_saver_filter_muc", false);
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
20
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
21
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
22 -- Patched version of util.stanza:find() that supports giving stanza names
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
23 -- without their namespace, allowing for every namespace.
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
24 local function find(self, path)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
25 local pos = 1;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
26 local len = #path + 1;
2735
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
27
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
28 repeat
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
29 local xmlns, name, text;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
30 local char = s_sub(path, pos, pos);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
31 if char == "@" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
32 return self.attr[s_sub(path, pos + 1)];
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
33 elseif char == "{" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
34 xmlns, pos = s_match(path, "^([^}]+)}()", pos + 1);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
35 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
36 name, text, pos = s_match(path, "^([^@/#]*)([/#]?)()", pos);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
37 name = name ~= "" and name or nil;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
38 if pos == len then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
39 if text == "#" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
40 local child = xmlns ~= nil and self:get_child(name, xmlns) or self:child_with_name(name);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
41 return child and child:get_text() or nil;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
42 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
43 return xmlns ~= nil and self:get_child(name, xmlns) or self:child_with_name(name);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
44 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
45 self = xmlns ~= nil and self:get_child(name, xmlns) or self:child_with_name(name);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
46 until not self
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
47 return nil;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
48 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
49
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
50 local function new_pump(output, ...)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
51 -- luacheck: ignore 212/self
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
52 local q = new_queue(...);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
53 local flush = true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
54 function q:pause()
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
55 flush = false;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
56 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
57 function q:resume()
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
58 flush = true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
59 return q:flush();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
60 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
61 local push = q.push;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
62 function q:push(item)
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
63 local ok = push(self, item);
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
64 if not ok then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
65 q:flush();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
66 output(item, self);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
67 elseif flush then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
68 return q:flush();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
69 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
70 return true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
71 end
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
72 function q:flush(alternative_output)
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
73 local out = alternative_output or output;
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
74 local item = self:pop();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
75 while item do
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
76 out(item, self);
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
77 item = self:pop();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
78 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
79 return true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
80 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
81 return q;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
82 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
83
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
84 local function is_stamp_needed(stanza, session)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
85 local st_name = stanza and stanza.name or nil;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
86 if st_name == "presence" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
87 return true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
88 elseif st_name == "message" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
89 if stanza:get_child("delay", xmlns_delay) then return false; end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
90 if stanza.attr.type == "chat" or stanza.attr.type == "groupchat" then return true; end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
91 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
92 return false;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
93 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
94
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
95 local function add_stamp(stanza, session)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
96 stanza = stanza:tag("delay", { xmlns = xmlns_delay, from = session.host, stamp = datetime.datetime()});
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
97 return stanza;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
98 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
99
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
100 local function is_important(stanza, session)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
101 local st_name = stanza and stanza.name or nil;
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
102 if not st_name then return true; end -- nonzas are always important
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
103 if st_name == "presence" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
104 -- TODO check for MUC status codes?
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
105 return false;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
106 elseif st_name == "message" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
107 -- unpack carbon copies
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
108 local stanza_direction = "in";
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
109 local carbon;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
110 -- support carbon copied message stanzas having an arbitrary message-namespace or no message-namespace at all
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
111 if not carbon then carbon = find(stanza, "{urn:xmpp:carbons:2}/forwarded/message"); end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
112 if not carbon then carbon = find(stanza, "{urn:xmpp:carbons:1}/forwarded/message"); end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
113 stanza_direction = carbon and stanza:child_with_name("sent") and "out" or "in";
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
114 --session.log("debug", "mod_csi_battery_saver(%s): stanza_direction = %s, carbon = %s, stanza = %s", id, stanza_direction, carbon and "true" or "false", tostring(stanza));
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
115 if carbon then stanza = carbon; end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
116 -- carbon copied outgoing messages aren't important (but incoming carbon copies are!)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
117 if carbon and stanza_direction == "out" then return false; end
2735
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
118
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
119 local st_type = stanza.attr.type;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
120 if st_type == "headline" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
121 return false;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
122 end
2735
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
123
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
124 -- We can't check for nick in encrypted groupchat messages, so let's treat them as important
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
125 -- Some clients don't set a body or an empty body for encrypted messages
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
126
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
127 -- check omemo https://xmpp.org/extensions/inbox/omemo.html
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
128 if stanza:get_child("encrypted", "eu.siacs.conversations.axolotl") or stanza:get_child("encrypted", "urn:xmpp:omemo:0") then return true; end
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
129
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
130 -- check xep27 pgp https://xmpp.org/extensions/xep-0027.html
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
131 if stanza:get_child("x", "jabber:x:encrypted") then return true; end
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
132
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
133 -- check xep373 pgp (OX) https://xmpp.org/extensions/xep-0373.html
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
134 if stanza:get_child("openpgp", "urn:xmpp:openpgp:0") then return true; end
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
135
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
136 local body = stanza:get_child_text("body");
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
137 if st_type == "groupchat" then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
138 if stanza:get_child_text("subject") then return true; end
2746
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
139 if body == nil or body == "" then return false; end
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
140 -- body contains text, let's see if we want to process it further
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
141 if filter_muc then
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
142 if body:find(session.username, 1, true) then return true; end
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
143 local rooms = session.rooms_joined;
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
144 if not rooms then return false; end
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
145 local room_nick = rooms[jid.bare(stanza_direction == "in" and stanza.attr.from or stanza.attr.to)];
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
146 if room_nick and body:find(room_nick, 1, true) then return true; end
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
147 return false;
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
148 else
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
149 return true;
d3a2f4bdaf09 mod_csi_battery_saver: Add config option for better muc handling
tmolitor <thilo@eightysoft.de>
parents: 2745
diff changeset
150 end
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
151 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
152 return body ~= nil and body ~= "";
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
153 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
154 return true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
155 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
156
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
157 module:hook("csi-client-inactive", function (event)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
158 local session = event.origin;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
159 if session.pump then
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
160 session.log("debug", "mod_csi_battery_saver(%s): Client is inactive, buffering unimportant outgoing stanzas", id);
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
161 session.pump:pause();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
162 else
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
163 session.log("debug", "mod_csi_battery_saver(%s): Client is inactive the first time, initializing module for this session", id);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
164 local pump = new_pump(session.send, 100);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
165 pump:pause();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
166 session.pump = pump;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
167 session._pump_orig_send = session.send;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
168 function session.send(stanza)
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
169 session.log("debug", "mod_csi_battery_saver(%s): Got outgoing stanza: <%s>", id, tostring(stanza.name or stanza));
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
170 local important = is_important(stanza, session);
2742
2e30bb3a10d5 mod_csi_battery_saver: Fix a bug introduced by commit f43c77c69a8a
tmolitor <thilo@eightysoft.de>
parents: 2741
diff changeset
171 -- clone stanzas before adding delay stamp and putting them into the queue
2e30bb3a10d5 mod_csi_battery_saver: Fix a bug introduced by commit f43c77c69a8a
tmolitor <thilo@eightysoft.de>
parents: 2741
diff changeset
172 if st.is_stanza(stanza) then stanza = st.clone(stanza); end
2735
b5fae17e4403 mod_csi_battery_saver: correctly handle encrypted message stanzas
tmolitor <thilo@eightysoft.de>
parents: 2606
diff changeset
173 -- add delay stamp to unimportant (buffered) stanzas that can/need be stamped
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
174 if not important and is_stamp_needed(stanza, session) then stanza = add_stamp(stanza, session); end
2742
2e30bb3a10d5 mod_csi_battery_saver: Fix a bug introduced by commit f43c77c69a8a
tmolitor <thilo@eightysoft.de>
parents: 2741
diff changeset
175 -- add stanza to outgoing queue and flush the buffer if needed
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
176 pump:push(stanza);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
177 if important then
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
178 session.log("debug", "mod_csi_battery_saver(%s): Encountered important stanza, flushing buffer: <%s>", id, tostring(stanza.name or stanza));
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
179 pump:flush();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
180 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
181 return true;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
182 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
183 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
184 end);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
185
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
186 module:hook("csi-client-active", function (event)
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
187 local session = event.origin;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
188 if session.pump then
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
189 session.log("debug", "mod_csi_battery_saver(%s): Client is active, resuming direct delivery", id);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
190 session.pump:resume();
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
191 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
192 end);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
193
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
194 -- clean up this session on hibernation start
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
195 module:hook("smacks-hibernation-start", function (event)
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
196 local session = event.origin;
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
197 if session.pump then
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
198 session.log("debug", "mod_csi_battery_saver(%s): Hibernation started, flushing buffer and afterwards disabling for this session", id);
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
199 session.pump:flush();
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
200 session.send = session._pump_orig_send;
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
201 session.pump = nil;
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
202 session._pump_orig_send = nil;
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
203 end
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
204 end);
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
205
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
206 -- clean up this session on hibernation end as well
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
207 -- but don't change resumed.send(), it is already overwritten with session.send() by the smacks module
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
208 module:hook("smacks-hibernation-end", function (event)
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
209 local session = event.resumed;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
210 if session.pump then
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
211 session.log("debug", "mod_csi_battery_saver(%s): Hibernation ended without being started, flushing buffer and afterwards disabling for this session", id);
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
212 session.pump:flush(session.send); -- use the fresh session.send() introduced by the smacks resume
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
213 -- don't reset session.send() because this is not the send previously overwritten by this module, but a fresh one
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
214 -- session.send = session._pump_orig_send;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
215 session.pump = nil;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
216 session._pump_orig_send = nil;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
217 end
2741
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
218 end);
69248dcd7cff mod_csi_battery_saver: Fix interaction with smacks hibernation
tmolitor <thilo@eightysoft.de>
parents: 2737
diff changeset
219
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
220 function module.unload()
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
221 module:log("info", "%s: Unloading module, flushing all buffers", id);
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
222 local host_sessions = prosody.hosts[module.host].sessions;
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
223 for _, user in pairs(host_sessions) do
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
224 for _, session in pairs(user.sessions) do
2745
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
225 if session.pump then
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
226 session.log("debug", "mod_csi_battery_saver(%s): Flushing buffer and restoring to original session.send()", id);
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
227 session.pump:flush();
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
228 session.send = session._pump_orig_send;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
229 session.pump = nil;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
230 session._pump_orig_send = nil;
b62cec32680e mod_csi_battery_saver: Fix bug when smacks is resumed before hibernating
tmolitor <thilo@eightysoft.de>
parents: 2742
diff changeset
231 end
2606
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
232 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
233 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
234 end
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
235
538c54d2dab3 mod_csi_battery_saver: CSI module to save battery on mobile devices, based on mod_csi_pump
tmolitor <thilo@eightysoft.de>
parents:
diff changeset
236 module:log("info", "%s: Successfully loaded module", id);