Comparison

core/rostermanager.lua @ 3087:9b31e36528e0

rostermanager: When loading the roster, also return a datamanager error if available.
author Waqas Hussain <waqas20@gmail.com>
date Sat, 22 May 2010 05:50:47 +0500
parent 2925:692b3c6c5bd2
child 3090:f14d2962f32c
comparison
equal deleted inserted replaced
3086:931acb1188b1 3087:9b31e36528e0
91 if roster then return roster; end 91 if roster then return roster; end
92 log("debug", "load_roster: loading for new user: "..username.."@"..host); 92 log("debug", "load_roster: loading for new user: "..username.."@"..host);
93 else -- Attempt to load roster for non-loaded user 93 else -- Attempt to load roster for non-loaded user
94 log("debug", "load_roster: loading for offline user: "..username.."@"..host); 94 log("debug", "load_roster: loading for offline user: "..username.."@"..host);
95 end 95 end
96 roster = datamanager.load(username, host, "roster") or {}; 96 local data, err = datamanager.load(username, host, "roster");
97 roster = data or {};
97 if user then user.roster = roster; end 98 if user then user.roster = roster; end
98 if not roster[false] then roster[false] = { }; end 99 if not roster[false] then roster[false] = { }; end
99 if roster[jid] then 100 if roster[jid] then
100 roster[jid] = nil; 101 roster[jid] = nil;
101 log("warn", "roster for "..jid.." has a self-contact"); 102 log("warn", "roster for "..jid.." has a self-contact");
102 end 103 end
103 hosts[host].events.fire_event("roster-load", username, host, roster); 104 hosts[host].events.fire_event("roster-load", username, host, roster);
104 return roster; 105 return roster, err;
105 end 106 end
106 107
107 function save_roster(username, host, roster) 108 function save_roster(username, host, roster)
108 log("debug", "save_roster: saving roster for "..username.."@"..host); 109 log("debug", "save_roster: saving roster for "..username.."@"..host);
109 if not roster then 110 if not roster then