Ver código fonte

modules/pua_rpc: return result as struct

Juha Heinanen 8 anos atrás
pai
commit
07310c634d
1 arquivos alterados com 11 adições e 3 exclusões
  1. 11 3
      src/modules/pua_rpc/pua_rpc.c

+ 11 - 3
src/modules/pua_rpc/pua_rpc.c

@@ -63,6 +63,7 @@ static int publish_callback(ua_pres_t* hentity, struct sip_msg* reply)
 {
 {
 	rpc_delayed_ctx_t* dctx;
 	rpc_delayed_ctx_t* dctx;
 	void* c;
 	void* c;
+	void* st;
 	rpc_t* rpc;
 	rpc_t* rpc;
 	struct hdr_field* hdr= NULL;
 	struct hdr_field* hdr= NULL;
 	int statuscode;
 	int statuscode;
@@ -95,7 +96,13 @@ static int publish_callback(ua_pres_t* hentity, struct sip_msg* reply)
 		statuscode = reply->first_line.u.reply.statuscode;
 		statuscode = reply->first_line.u.reply.statuscode;
 		reason = reply->first_line.u.reply.reason;
 		reason = reply->first_line.u.reply.reason;
 	}
 	}
-	rpc->add(c, "dS", statuscode, &reason);
+	if (rpc->add(c, "{", &st) < 0) {
+	    LM_ERR("rpc->add failed on '{'\n");
+	    rpc->delayed_ctx_close(dctx);
+	    return -1;
+	}
+	rpc->struct_add(st, "d", "statusCode", statuscode);
+	rpc->struct_add(st, "S", "reasonPhrase", &reason);
 
 
 	if (statuscode == 200) {
 	if (statuscode == 200) {
 		expires = ((exp_body_t*)reply->expires->parsed)->val;
 		expires = ((exp_body_t*)reply->expires->parsed)->val;
@@ -116,7 +123,8 @@ static int publish_callback(ua_pres_t* hentity, struct sip_msg* reply)
 		}
 		}
 		etag = hdr->body;
 		etag = hdr->body;
 		LM_DBG("SIP-Etag = %.*s\n", etag.len, etag.s);
 		LM_DBG("SIP-Etag = %.*s\n", etag.len, etag.s);
-		rpc->add(c, "Sd", &etag, expires);
+		rpc->struct_add(st, "S", "SIP-Etag", &etag);
+		rpc->struct_add(st, "d", "Expires", expires);
 	}	
 	}	
 
 
 	rpc->delayed_ctx_close(dctx);
 	rpc->delayed_ctx_close(dctx);
@@ -279,7 +287,7 @@ static void publish(rpc_t* rpc, void* c)
 
 
 
 
 rpc_export_t pua_rpc[] = {
 rpc_export_t pua_rpc[] = {
-	{"pua.publish",  publish, publish_doc, 0},
+	{"pua.publish", publish, publish_doc, 0},
 	{0, 0, 0, 0}
 	{0, 0, 0, 0}
 };
 };