Browse Source

kazoo : missing options & corrections to publish. regenerated README

lazedo 11 years ago
parent
commit
cab397a9a8
3 changed files with 62 additions and 80 deletions
  1. 21 66
      modules/kazoo/README
  2. 9 4
      modules/kazoo/defs.h
  3. 32 10
      modules/kazoo/kz_pua.c

+ 21 - 66
modules/kazoo/README

@@ -58,9 +58,6 @@ Luis Azedo
 
                     4.4.1. db_url(str)
                     4.4.2. presentity_table(str)
-                    4.4.3. dialog_expires(str)
-                    4.4.4. presence_expires(str)
-                    4.4.5. mwi_expires(str)
 
         5. Functions
 
@@ -109,18 +106,15 @@ Luis Azedo
    1.16. Set amqp_query_timout parameter
    1.17. Set db_url parameter
    1.18. Set presentity_table parameter
-   1.19. Set dialog_expires parameter
-   1.20. Set presence_expires parameter
-   1.21. Set mwi_expires parameter
-   1.22. kazoo_publish usage
-   1.23. kazoo_query usage
-   1.24. kazoo_subscribe usage
-   1.25. kazoo_subscribe usage
-   1.26. kazoo_pua_publish usage
-   1.27. kazoo_encode usage
-   1.28. kazoo_json usage
-   1.29. kz.json usage
-   1.30. kz.encode usage
+   1.19. kazoo_publish usage
+   1.20. kazoo_query usage
+   1.21. kazoo_subscribe usage
+   1.22. kazoo_subscribe usage
+   1.23. kazoo_pua_publish usage
+   1.24. kazoo_encode usage
+   1.25. kazoo_json usage
+   1.26. kz.json usage
+   1.27. kz.encode usage
 
 Chapter 1. Admin Guide
 
@@ -167,9 +161,6 @@ Chapter 1. Admin Guide
 
               4.4.1. db_url(str)
               4.4.2. presentity_table(str)
-              4.4.3. dialog_expires(str)
-              4.4.4. presence_expires(str)
-              4.4.5. mwi_expires(str)
 
    5. Functions
 
@@ -340,9 +331,6 @@ event_route[kazoo:consumer-event]
 
         4.4.1. db_url(str)
         4.4.2. presentity_table(str)
-        4.4.3. dialog_expires(str)
-        4.4.4. presence_expires(str)
-        4.4.5. mwi_expires(str)
 
 4.1. amqp related
 
@@ -551,10 +539,10 @@ modparam("kazoo", "amqp_query_timout_micro", 200000)
 
 4.4.1. db_url(str)
 
-   The database url.
+   The database for the presentity table.
 
-   If set, the module is a fully operational presence server. Otherwise,
-   it is used as a 'library', for its exported functions.
+   If set, the kazoo_ppua_publish function will update the presentity
+   status in the database.
 
    Default value is “NULL”.
 
@@ -574,39 +562,6 @@ modparam("kazoo", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
 modparam("kazoo", "presentity_table", "my_presentity_table")
 ...
 
-4.4.3. dialog_expires(str)
-
-   The default Expires value for dialog event.
-
-   Default value is 30.
-
-   Example 1.19. Set dialog_expires parameter
-...
-modparam("kazoo", "dialog_expires", 3600)
-...
-
-4.4.4. presence_expires(str)
-
-   The default Expires value for presence event.
-
-   Default value is 3600.
-
-   Example 1.20. Set presence_expires parameter
-...
-modparam("kazoo", "presence_expires", 600)
-...
-
-4.4.5. mwi_expires(str)
-
-   The default Expires value for message-summary (mwi) event.
-
-   Default value is 3600.
-
-   Example 1.21. Set mwi_expires parameter
-...
-modparam("kazoo", "mwi_expires", 600)
-...
-
 5. Functions
 
    5.1. amqp related
@@ -638,7 +593,7 @@ modparam("kazoo", "mwi_expires", 600)
 
    This function can be used from ANY ROUTE.
 
-   Example 1.22. kazoo_publish usage
+   Example 1.19. kazoo_publish usage
 ...
 $var(amqp_payload_request) = "{'Event-Category' : 'directory', 'Event-Name' : '
 reg_success', 'Contact' : '" + $var(fs_contact) + "', 'Call-ID' : '" + $ci + "'
@@ -659,7 +614,7 @@ kazoo_publish("callmgr", $var(amqp_routing_key), $var(amqp_payload_request));
 
    This function can be used from ANY ROUTE.
 
-   Example 1.23. kazoo_query usage
+   Example 1.20. kazoo_query usage
 ...
 $var(amqp_payload_request) = "{'Event-Category' : 'call_event' , 'Event-Name' :
  'query_user_channels_req', 'Realm' : '" + $fd + "', 'Username' : '" + $fU + "'
@@ -683,7 +638,7 @@ $var(amqp_result)")) {
 
    This function must be called from event_route[kazoo:mod-init].
 
-   Example 1.24. kazoo_subscribe usage
+   Example 1.21. kazoo_subscribe usage
 ...
 event_route[kazoo:mod-init]
 {
@@ -715,7 +670,7 @@ event_route[kazoo:consumer-event]
 
    This function must be called from event_route[kazoo:mod-init].
 
-   Example 1.25. kazoo_subscribe usage
+   Example 1.22. kazoo_subscribe usage
 ...
 event_route[kazoo:mod-init]
 {
@@ -740,7 +695,7 @@ event_route[kazoo:consumer-event]
 
    This function can be used from ANY ROUTE.
 
-   Example 1.26. kazoo_pua_publish usage
+   Example 1.23. kazoo_pua_publish usage
 ...
 event_route[kazoo:consumer-event-presence-update]
 {
@@ -761,7 +716,7 @@ json,From})");
 
    This function can be used from ANY ROUTE.
 
-   Example 1.27. kazoo_encode usage
+   Example 1.24. kazoo_encode usage
 ...
 kazoo_encode("$ci", "$var(callid_encoded)");
 $var(amqp_routing_key) = "call.status_req.$var(callid_encoded)";
@@ -774,7 +729,7 @@ $var(amqp_routing_key) = "call.status_req.$var(callid_encoded)";
 
    This function can be used from ANY ROUTE.
 
-   Example 1.28. kazoo_json usage
+   Example 1.25. kazoo_json usage
 ...
 kazoo_json("$var(amqp_result)", "Channels[0].switch_url", "$du");
 if($du != $null) {
@@ -792,7 +747,7 @@ if($du != $null) {
 
    The prefix for kazoo transformations is kz.
      * json
-       Example 1.29. kz.json usage
+       Example 1.26. kz.json usage
 ...
 #kazoo_json("$var(amqp_result)", "Channels[0].switch_url", "$du");
 $du = $kzR{kz.json,Channels[0].switch_url};
@@ -802,7 +757,7 @@ if($du != $null) {
 }
 ...
      * encode
-       Example 1.30. kz.encode usage
+       Example 1.27. kz.encode usage
 ...
 #kazoo_encode("$ci", "$var(callid_encoded)");
 #$var(amqp_routing_key) = "call.status_req.$var(callid_encoded)";

+ 9 - 4
modules/kazoo/defs.h

@@ -9,12 +9,17 @@
 #define DBK_DEFS_H_
 
 #define BLF_MAX_DIALOGS 8
+#define BLF_JSON_PRES		"Presentity"
+#define BLF_JSON_PRES_USER	"Presentity-User"
+#define BLF_JSON_PRES_REALM	"Presentity-Realm"
 #define BLF_JSON_FROM      	"From"
 #define BLF_JSON_FROM_USER 	"From-User"
 #define BLF_JSON_FROM_REALM	"From-Realm"
+#define BLF_JSON_FROM_URI	"From-URI"
 #define BLF_JSON_TO        	"To"
 #define BLF_JSON_TO_USER 	"To-User"
 #define BLF_JSON_TO_REALM	"To-Realm"
+#define BLF_JSON_TO_URI		"To-URI"
 #define BLF_JSON_CALLID    	"Call-ID"
 #define BLF_JSON_TOTAG     	"To-Tag"
 #define BLF_JSON_FROMTAG   	"From-Tag"
@@ -74,11 +79,11 @@
 <dialog id=\"%.*s\" call-id=\"%.*s\" local-tag=\"%.*s\" remote-tag=\"%.*s\" direction=\"%.*s\">\
 <state>%.*s</state>\
 <local>\
-<identity>%.*s</identity>\
+<identity display=\"%.*s\">%.*s</identity>\
 <target uri=\"%.*s\"/>\
 </local>\
 <remote>\
-<identity>%.*s</identity>\
+<identity display=\"%.*s\">%.*s</identity>\
 <target uri=\"%.*s\"/>\
 </remote>\
 </dialog>\
@@ -89,10 +94,10 @@
 <dialog id=\"%.*s\" call-id=\"%.*s\" local-tag=\"%.*s\" remote-tag=\"%.*s\" direction=\"%.*s\">\
 <state>%.*s</state>\
 <local>\
-<identity>%.*s</identity>\
+<identity display=\"%.*s\">%.*s</identity>\
 </local>\
 <remote>\
-<identity>%.*s</identity>\
+<identity display=\"%.*s\">%.*s</identity>\
 </remote>\
 </dialog>\
 </dialog-info>"

+ 32 - 10
modules/kazoo/kz_pua.c

@@ -306,9 +306,10 @@ int kz_pua_publish_mwi_to_presentity(struct json_object *json_obj) {
 
 int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     int ret = 1;
-    str from = { 0, 0 }, to = { 0, 0 };
-    str from_user = { 0, 0 }, to_user = { 0, 0 };
-    str from_realm = { 0, 0 }, to_realm = { 0, 0 };
+    str from = { 0, 0 }, to = { 0, 0 }, pres = {0, 0};
+    str from_user = { 0, 0 }, to_user = { 0, 0 }, pres_user = { 0, 0 };
+    str from_realm = { 0, 0 }, to_realm = { 0, 0 }, pres_realm = { 0, 0 };
+    str from_uri = { 0, 0 }, to_uri = { 0, 0 };
     str callid = { 0, 0 }, fromtag = { 0, 0 }, totag = { 0, 0 };
     str state = { 0, 0 };
     str direction = { 0, 0 };
@@ -327,12 +328,17 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     }
 
 
+    json_extract_field(BLF_JSON_PRES, pres);
+    json_extract_field(BLF_JSON_PRES_USER, pres_user);
+    json_extract_field(BLF_JSON_PRES_REALM, pres_realm);
     json_extract_field(BLF_JSON_FROM, from);
     json_extract_field(BLF_JSON_FROM_USER, from_user);
     json_extract_field(BLF_JSON_FROM_REALM, from_realm);
+    json_extract_field(BLF_JSON_FROM_URI, from_uri);
     json_extract_field(BLF_JSON_TO, to);
     json_extract_field(BLF_JSON_TO_USER, to_user);
     json_extract_field(BLF_JSON_TO_REALM, to_realm);
+    json_extract_field(BLF_JSON_TO_URI, to_uri);
     json_extract_field(BLF_JSON_CALLID, callid);
     json_extract_field(BLF_JSON_FROMTAG, fromtag);
     json_extract_field(BLF_JSON_TOTAG, totag);
@@ -351,16 +357,28 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     	reset = json_object_get_int(ExpiresObj);
     }
 
-    if (!from_user.len || !to_user.len || !state.len) {
+    if (!from.len || !to.len || !state.len) {
     	LM_ERR("missing one of From / To / State\n");
 		goto error;
     }
 
+    if(!pres.len || !pres_user.len || !pres_realm.len) {
+    	pres = from;
+    	pres_user = from_user;
+    	pres_realm = from_realm;
+    }
+
+    if(!from_uri.len)
+    	from_uri = from;
+
+    if(!to_uri.len)
+    	to_uri = to;
+
     if(callid.len) {
 
     	if(dbk_include_entity) {
         sprintf(body, DIALOGINFO_BODY,
-        		from.len, from.s,
+        		pres.len, pres.s,
         		callid.len, callid.s,
         		callid.len, callid.s,
         		fromtag.len, fromtag.s,
@@ -369,13 +387,15 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
         		state.len, state.s,
         		from_user.len, from_user.s,
         		from.len, from.s,
+        		from_uri.len, from_uri.s,
         		to_user.len, to_user.s,
-        		to.len, to.s
+        		to.len, to.s,
+        		to_uri.len, to_uri.s
         		);
     	} else {
 
         sprintf(body, DIALOGINFO_BODY_2,
-        		from.len, from.s,
+        		pres.len, pres.s,
         		callid.len, callid.s,
         		callid.len, callid.s,
         		fromtag.len, fromtag.s,
@@ -383,12 +403,14 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
         		direction.len, direction.s,
         		state.len, state.s,
         		from_user.len, from_user.s,
-        		to_user.len, to_user.s
+        		from.len, from.s,
+        		to_user.len, to_user.s,
+        		to.len, to.s
         		);
     	}
 
     } else {
-    	sprintf(body, DIALOGINFO_EMPTY_BODY, from_user.len, from_user.s);
+    	sprintf(body, DIALOGINFO_EMPTY_BODY, pres.len, pres.s);
     }
 
     sprintf(sender_buf, "sip:%s",callid.s);
@@ -399,7 +421,7 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     dialoginfo_body.len = strlen(body);
 
     if(dbk_pua_mode == 1) {
-    	kz_pua_update_presentity(&event, &from_realm, &from_user, &callid, &sender, &dialoginfo_body, expires, reset);
+    	kz_pua_update_presentity(&event, &pres_realm, &pres_user, &callid, &sender, &dialoginfo_body, expires, reset);
     }
 
  error: