12 |
12 |
13 local datamanager = datamanager; |
13 local datamanager = datamanager; |
14 |
14 |
15 module "rostermanager" |
15 module "rostermanager" |
16 |
16 |
17 function getroster(username, host) |
17 --[[function getroster(username, host) |
18 return { |
18 return { |
19 ["mattj@localhost"] = true, |
19 ["mattj@localhost"] = true, |
20 ["tobias@getjabber.ath.cx"] = true, |
20 ["tobias@getjabber.ath.cx"] = true, |
21 ["waqas@getjabber.ath.cx"] = true, |
21 ["waqas@getjabber.ath.cx"] = true, |
22 ["thorns@getjabber.ath.cx"] = true, |
22 ["thorns@getjabber.ath.cx"] = true, |
23 ["idw@getjabber.ath.cx"] = true, |
23 ["idw@getjabber.ath.cx"] = true, |
24 } |
24 } |
25 -- return datamanager.load(username, host, "roster") or {}; |
25 --return datamanager.load(username, host, "roster") or {}; |
|
26 end]] |
|
27 |
|
28 function add_to_roster(roster, jid, item) |
|
29 roster[jid] = item; |
|
30 -- TODO implement |
|
31 end |
|
32 |
|
33 function remove_from_roster(roster, jid) |
|
34 roster[jid] = nil; |
|
35 -- TODO implement |
|
36 end |
|
37 |
|
38 function load_roster(host, username) |
|
39 if hosts[host] and hosts[host].sessions[username] then |
|
40 local roster = hosts[host].sessions[username].roster; |
|
41 if not roster then |
|
42 return hosts[host].sessions[username].roster = datamanger.load(username, host, "roster") or {}; |
|
43 end |
|
44 return roster; |
|
45 end |
|
46 error("Attempt to load roster for non-loaded user"); --return nil; |
|
47 end |
|
48 |
|
49 function save_roster(host, username) |
|
50 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); |
|
52 end |
|
53 return nil; |
26 end |
54 end |
27 |
55 |
28 return _M; |
56 return _M; |