Roster updates

Thu, 23 Oct 2008 20:02:30 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Thu, 23 Oct 2008 20:02:30 +0500
changeset 132
9a4aa57af367
parent 131
4bbbc7883ee6
child 133
b92493ea6fd7

Roster updates
- Added support for item.ask attribute in rostermanager and mod_roster
- Updated roster docs
- Removed old code from rostermanager

core/rostermanager.lua file | annotate | diff | comparison | revisions
doc/roster_format.txt file | annotate | diff | comparison | revisions
plugins/mod_roster.lua file | annotate | diff | comparison | revisions
--- a/core/rostermanager.lua	Thu Oct 23 19:53:02 2008 +0500
+++ b/core/rostermanager.lua	Thu Oct 23 20:02:30 2008 +0500
@@ -18,17 +18,6 @@
 
 module "rostermanager"
 
---[[function getroster(username, host)
-	return { 
-			["mattj@localhost"] = true,
-			["tobias@getjabber.ath.cx"] = true,
-			["waqas@getjabber.ath.cx"] = true,
-			["thorns@getjabber.ath.cx"] = true, 
-			["idw@getjabber.ath.cx"] = true, 
-		}
-	--return datamanager.load(username, host, "roster") or {};
-end]]
-
 function add_to_roster(session, jid, item)
 	if session.roster then
 		local old_item = session.roster[jid];
@@ -65,7 +54,7 @@
 		local stanza = st.iq({type="set"});
 		stanza:tag("query", {xmlns = "jabber:iq:roster"});
 		if item then
-			stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name});
+			stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name, ask = item.ask});
 			for group in pairs(item.groups) do
 				stanza:tag("group"):text(group):up();
 			end
@@ -94,6 +83,7 @@
 		return roster;
 	end
 	-- Attempt to load roster for non-loaded user
+	-- TODO also support loading for offline user
 end
 
 function save_roster(username, host)
--- a/doc/roster_format.txt	Thu Oct 23 19:53:02 2008 +0500
+++ b/doc/roster_format.txt	Thu Oct 23 20:02:30 2008 +0500
@@ -9,7 +9,7 @@
   string subscription = "none" | "to" | "from" | "both"
   string name = Opaque string set by client. (optional)
   set groups = a set of opaque strings set by the client
-  boolean ask = nil | true - a value of true indicates subscription is pending
+  boolean ask = nil | "subscribe" - a value of true indicates subscription is pending
 }
 
 The roster is available as
--- a/plugins/mod_roster.lua	Thu Oct 23 19:53:02 2008 +0500
+++ b/plugins/mod_roster.lua	Thu Oct 23 20:02:30 2008 +0500
@@ -19,6 +19,7 @@
 						roster:tag("item", {
 							jid = jid,
 							subscription = session.roster[jid].subscription,
+							ask = session.roster[jid].ask,
 							name = session.roster[jid].name,
 						});
 						for group in pairs(session.roster[jid].groups) do
@@ -54,6 +55,7 @@
 									if r_item.name == "" then r_item.name = nil; end
 									if session.roster[item.attr.jid] then
 										r_item.subscription = session.roster[item.attr.jid].subscription;
+										r_item.ask = session.roster[item.attr.jid].ask;
 									else
 										r_item.subscription = "none";
 									end

mercurial