[sr-dev] git:master: modules/app_lua: Updated to handle optional parameters to handle_subscribe() and rls_handle_subscribe()

Peter Dunkley peter.dunkley at crocodile-rcs.com
Thu Apr 19 19:12:36 CEST 2012


Module: sip-router
Branch: master
Commit: 4fc8134ccc57957c96530600ddcf613769e0d2bd
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4fc8134ccc57957c96530600ddcf613769e0d2bd

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Thu Apr 19 18:05:59 2012 +0100

modules/app_lua: Updated to handle optional parameters to handle_subscribe() and rls_handle_subscribe()

---

 modules/app_lua/app_lua_exp.c |   38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/modules/app_lua/app_lua_exp.c b/modules/app_lua/app_lua_exp.c
index beb4ccd..ce69a1d 100644
--- a/modules/app_lua/app_lua_exp.c
+++ b/modules/app_lua/app_lua_exp.c
@@ -1724,13 +1724,28 @@ static int lua_sr_pres_handle_subscribe(lua_State *L)
 		return app_lua_return_error(L);
 	}
 
-	if(lua_gettop(L)!=0)
+	if(lua_gettop(L)==0)
+		ret = _lua_presenceb.handle_subscribe0(env_L->msg);
+	else if (lua_gettop(L)==1)
+	{
+		str wuri;
+		struct sip_uri parsed_wuri;
+
+		wuri.s = (char *) lua_tostring(L, -1);
+		wuri.len = strlen(wuri.s);
+		if (parse_uri(wuri.s, wuri.len, &parsed_wuri))
+		{
+			LM_ERR("failed to parse watcher URI\n");
+			return app_lua_return_error(L);
+		}
+		ret = _lua_presenceb.handle_subscribe(env_L->msg, parsed_wuri.user, parsed_wuri.host);
+	}
+	else
 	{
 		LM_ERR("incorrect number of arguments\n");
 		return app_lua_return_error(L);
 	}
 
-	ret = _lua_presenceb.handle_subscribe(env_L->msg, NULL, NULL);
 	return app_lua_return_int(L, ret);
 }
 
@@ -2015,13 +2030,28 @@ static int lua_sr_rls_handle_subscribe(lua_State *L)
 		return app_lua_return_error(L);
 	}
 
-	if(lua_gettop(L)!=0)
+	if(lua_gettop(L)==0)
+		ret = _lua_rlsb.rls_handle_subscribe0(env_L->msg);
+	else if (lua_gettop(L)==1)
+	{
+		str wuri;
+		struct sip_uri parsed_wuri;
+
+		wuri.s = (char *) lua_tostring(L, -1);
+		wuri.len = strlen(wuri.s);
+		if (parse_uri(wuri.s, wuri.len, &parsed_wuri))
+		{
+			LM_ERR("failed to parse watcher URI\n");
+			return app_lua_return_error(L);
+		}
+		ret = _lua_rlsb.rls_handle_subscribe(env_L->msg, parsed_wuri.user, parsed_wuri.host);
+	}
+	else
 	{
 		LM_ERR("incorrect number of arguments\n");
 		return app_lua_return_error(L);
 	}
 
-	ret = _lua_rlsb.rls_handle_subscribe(env_L->msg, NULL, NULL);
 	return app_lua_return_int(L, ret);
 }
 




More information about the sr-dev mailing list