[sr-dev] git:master:750a3707: presence: use spve fixup for pres_auth_status()

Daniel-Constantin Mierla miconda at gmail.com
Sat Apr 29 11:29:18 CEST 2017


Module: kamailio
Branch: master
Commit: 750a37076517c227af8fa1666229652e026b9b69
URL: https://github.com/kamailio/kamailio/commit/750a37076517c227af8fa1666229652e026b9b69

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-04-29T11:07:46+02:00

presence: use spve fixup for pres_auth_status()

- flexibility to provide static string values or variable parameters

---

Modified: src/modules/presence/presence.c

---

Diff:  https://github.com/kamailio/kamailio/commit/750a37076517c227af8fa1666229652e026b9b69.diff
Patch: https://github.com/kamailio/kamailio/commit/750a37076517c227af8fa1666229652e026b9b69.patch

---

diff --git a/src/modules/presence/presence.c b/src/modules/presence/presence.c
index 3b131ba..116c37f 100644
--- a/src/modules/presence/presence.c
+++ b/src/modules/presence/presence.c
@@ -185,7 +185,7 @@ static cmd_export_t cmds[]=
 	{"handle_subscribe",      (cmd_function)w_handle_subscribe,      1,
 		fixup_subscribe, 0, REQUEST_ROUTE},
 	{"pres_auth_status",      (cmd_function)w_pres_auth_status,      2,
-		fixup_pvar_pvar, fixup_free_pvar_pvar, REQUEST_ROUTE},
+		fixup_spve_spve, fixup_free_spve_spve, REQUEST_ROUTE},
 	{"pres_refresh_watchers", (cmd_function)w_pres_refresh_watchers, 3,
 		fixup_refresh_watchers, 0, ANY_ROUTE},
 	{"pres_refresh_watchers", (cmd_function)w_pres_refresh_watchers5,5,
@@ -1406,52 +1406,33 @@ static int update_pw_dialogs(subs_t* subs, unsigned int hash_code, subs_t** subs
 	return 0;
 }
 
-static int w_pres_auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2)
+static int w_pres_auth_status(struct sip_msg *_msg, char *_sp1, char *_sp2)
 {
-	pv_spec_t *sp;
-	pv_value_t pv_val;
 	str watcher_uri, presentity_uri;
 
-	sp = (pv_spec_t *)_sp1;
+	if(fixup_get_svalue(_msg, (gparam_t *)_sp1, &watcher_uri) != 0) {
+		LM_ERR("invalid watcher uri parameter");
+		return -1;
+	}
 
-	if (sp && (pv_get_spec_value(_msg, sp, &pv_val) == 0)) {
-		if (pv_val.flags & PV_VAL_STR) {
-			watcher_uri = pv_val.rs;
-			if (watcher_uri.len == 0 || watcher_uri.s == NULL) {
-				LM_ERR("missing watcher uri\n");
-				return -1;
-			}
-		} else {
-			LM_ERR("watcher pseudo variable value is not string\n");
-			return -1;
-		}
-	} else {
-		LM_ERR("cannot get watcher pseudo variable value\n");
+	if(fixup_get_svalue(_msg, (gparam_t *)_sp2, &presentity_uri) != 0) {
+		LM_ERR("invalid presentity uri parameter");
 		return -1;
 	}
 
-	sp = (pv_spec_t *)_sp2;
+	if(watcher_uri.len == 0 || watcher_uri.s == NULL) {
+		LM_ERR("missing watcher uri\n");
+		return -1;
+	}
 
-	if (sp && (pv_get_spec_value(_msg, sp, &pv_val) == 0)) {
-		if (pv_val.flags & PV_VAL_STR) {
-			presentity_uri = pv_val.rs;
-			if (presentity_uri.len == 0 || presentity_uri.s == NULL) {
-				LM_DBG("missing presentity uri\n");
-				return -1;
-			}
-		} else {
-			LM_ERR("presentity pseudo variable value is not string\n");
-			return -1;
-		}
-	} else {
-		LM_ERR("cannot get presentity pseudo variable value\n");
+	if(presentity_uri.len == 0 || presentity_uri.s == NULL) {
+		LM_DBG("missing presentity uri\n");
 		return -1;
 	}
 
 	return pres_auth_status(_msg, watcher_uri, presentity_uri);
 }
 
-
 int pres_auth_status(struct sip_msg* msg, str watcher_uri, str presentity_uri)
 {
 	str event;




More information about the sr-dev mailing list