Software /
code /
prosody
Comparison
core/rostermanager.lua @ 103:ebdb7875443e
Fixed: Typos caused by lack of sleep.
Learned: Lua variable assignments are not expressions.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Tue, 14 Oct 2008 07:20:29 +0500 |
parent | 101:c690fa382743 |
child | 107:8d8debda3df2 |
comparison
equal
deleted
inserted
replaced
102:a5b914370db5 | 103:ebdb7875443e |
---|---|
5 end | 5 end |
6 | 6 |
7 local setmetatable = setmetatable; | 7 local setmetatable = setmetatable; |
8 local format = string.format; | 8 local format = string.format; |
9 local loadfile, setfenv, pcall = loadfile, setfenv, pcall; | 9 local loadfile, setfenv, pcall = loadfile, setfenv, pcall; |
10 | |
11 local hosts = hosts; | |
10 | 12 |
11 require "util.datamanager" | 13 require "util.datamanager" |
12 | 14 |
13 local datamanager = datamanager; | 15 local datamanager = datamanager; |
14 | 16 |
33 function remove_from_roster(roster, jid) | 35 function remove_from_roster(roster, jid) |
34 roster[jid] = nil; | 36 roster[jid] = nil; |
35 -- TODO implement | 37 -- TODO implement |
36 end | 38 end |
37 | 39 |
38 function load_roster(host, username) | 40 function load_roster(username, host) |
39 if hosts[host] and hosts[host].sessions[username] then | 41 if hosts[host] and hosts[host].sessions[username] then |
40 local roster = hosts[host].sessions[username].roster; | 42 local roster = hosts[host].sessions[username].roster; |
41 if not roster then | 43 if not roster then |
42 return hosts[host].sessions[username].roster = datamanger.load(username, host, "roster") or {}; | 44 roster = datamanager.load(username, host, "roster") or {}; |
45 hosts[host].sessions[username].roster = roster; | |
43 end | 46 end |
44 return roster; | 47 return roster; |
45 end | 48 end |
46 error("Attempt to load roster for non-loaded user"); --return nil; | 49 error("Attempt to load roster for non-loaded user"); --return nil; |
47 end | 50 end |
48 | 51 |
49 function save_roster(host, username) | 52 function save_roster(username, host) |
50 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then | 53 if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then |
51 return datamanager.save(username, host, "roster", hosts[host].sessions[username].roster); | 54 return datamanager.save(username, host, "roster", hosts[host].sessions[username].roster); |
52 end | 55 end |
53 return nil; | 56 return nil; |
54 end | 57 end |