[sr-dev] git:lazedo/kazoo: kazoo : remove expires parameters for presence. they should be in the

Luis Azedo luis at 2600hz.com
Sat Sep 13 06:09:13 CEST 2014


Module: sip-router
Branch: lazedo/kazoo
Commit: fb66389261c03d57d6c182cf490c5730d97c7e22
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fb66389261c03d57d6c182cf490c5730d97c7e22

Author: Luis Azedo <luis at 2600hz.com>
Committer: Luis Azedo <luis at 2600hz.com>
Date:   Sat Sep 13 05:07:26 2014 +0100

kazoo : remove expires parameters for presence. they should be in the
payload. handle expires = 0

---

 modules/kazoo/doc/kazoo_admin.xml |   59 +-----------------------------------
 modules/kazoo/kazoo.c             |   13 ++++----
 modules/kazoo/kz_pua.c            |   17 ++++++----
 3 files changed, 19 insertions(+), 70 deletions(-)

diff --git a/modules/kazoo/doc/kazoo_admin.xml b/modules/kazoo/doc/kazoo_admin.xml
index 4134d8b..5f2dac8 100644
--- a/modules/kazoo/doc/kazoo_admin.xml
+++ b/modules/kazoo/doc/kazoo_admin.xml
@@ -495,11 +495,9 @@ modparam("kazoo", "amqp_query_timout_micro", 200000)
     <section>
         <title><varname>db_url</varname>(str)</title>
         <para>
-        The database url.
+        The database for the presentity table.
         </para>
-        <para>If set, the module is a fully operational
-        presence server. Otherwise, it is used as a 'library', for 
-        its exported functions.
+        <para>If set, the kazoo_ppua_publish function will update the presentity status in the database.
         </para>
         <para>
         <emphasis>Default value is <quote>NULL</quote>.</emphasis>
@@ -532,59 +530,6 @@ modparam("kazoo", "presentity_table", "my_presentity_table")
         </example>
     </section>
 
-    <section>
-        <title><varname>dialog_expires</varname>(str)</title>
-        <para>
-        The default Expires value for dialog event.
-        </para>
-        <para>
-        <emphasis>Default value is 30.</emphasis>
-        </para>
-        <example>
-        <title>Set <varname>dialog_expires</varname> parameter</title>
-        <programlisting format="linespecific">
-...
-modparam("kazoo", "dialog_expires", 3600)
-...
-</programlisting>
-        </example>
-    </section>
-
-    <section>
-        <title><varname>presence_expires</varname>(str)</title>
-        <para>
-        The default Expires value for presence event.
-        </para>
-        <para>
-        <emphasis>Default value is 3600.</emphasis>
-        </para>
-        <example>
-        <title>Set <varname>presence_expires</varname> parameter</title>
-        <programlisting format="linespecific">
-...
-modparam("kazoo", "presence_expires", 600)
-...
-</programlisting>
-        </example>
-    </section>
-
-    <section>
-        <title><varname>mwi_expires</varname>(str)</title>
-        <para>
-        The default Expires value for message-summary (mwi) event.
-        </para>
-        <para>
-        <emphasis>Default value is 3600.</emphasis>
-        </para>
-        <example>
-        <title>Set <varname>mwi_expires</varname> parameter</title>
-        <programlisting format="linespecific">
-...
-modparam("kazoo", "mwi_expires", 600)
-...
-</programlisting>
-        </example>
-    </section>
     
     </section>
     
diff --git a/modules/kazoo/kazoo.c b/modules/kazoo/kazoo.c
index 0514ab8..af98c33 100644
--- a/modules/kazoo/kazoo.c
+++ b/modules/kazoo/kazoo.c
@@ -57,9 +57,9 @@ int dbk_reconn_retries = 8;
 
 int dbk_presentity_phtable_size = 4096;
 
-int dbk_dialog_expires = 30;
-int dbk_presence_expires = 3600;
-int dbk_mwi_expires = 3600;
+//int dbk_dialog_expires = 30;
+//int dbk_presence_expires = 3600;
+//int dbk_mwi_expires = 3600;
 int dbk_create_empty_dialog = 1;
 
 int dbk_channels = 50;
@@ -140,9 +140,9 @@ static cmd_export_t cmds[] = {
 
 static param_export_t params[] = {
     {"node_hostname", STR_PARAM, &dbk_node_hostname.s},
-    {"dialog_expires", INT_PARAM, &dbk_dialog_expires},
-    {"presence_expires", INT_PARAM, &dbk_presence_expires},
-    {"mwi_expires", INT_PARAM, &dbk_mwi_expires},
+  //  {"dialog_expires", INT_PARAM, &dbk_dialog_expires},
+  //  {"presence_expires", INT_PARAM, &dbk_presence_expires},
+  //  {"mwi_expires", INT_PARAM, &dbk_mwi_expires},
     {"amqp_connection", STR_PARAM|USE_FUNC_PARAM,(void*)kz_amqp_add_connection},
     {"amqp_max_channels", INT_PARAM, &dbk_channels},
     {"amqp_consumer_ack_timeout_micro", INT_PARAM, &kz_ack_tv.tv_usec},
@@ -248,6 +248,7 @@ static int mod_init(void) {
     }
 
     register_procs(total_workers);
+    cfg_register_child(total_workers);
 
     return 0;
 }
diff --git a/modules/kazoo/kz_pua.c b/modules/kazoo/kz_pua.c
index 256e1fe..1efe96b 100644
--- a/modules/kazoo/kz_pua.c
+++ b/modules/kazoo/kz_pua.c
@@ -18,9 +18,6 @@
 #include "const.h"
 
 
-extern int dbk_dialog_expires;
-extern int dbk_presence_expires;
-extern int dbk_mwi_expires;
 extern int dbk_include_entity;
 extern int dbk_pua_mode;
 
@@ -87,7 +84,7 @@ int kz_pua_update_presentity(str* event, str* realm, str* user, str* etag, str*
 	query_cols[n_query_cols] = &str_expires_col;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val = expires+(int)time(NULL);
+	query_vals[n_query_cols].val.int_val = expires;
 	n_query_cols++;
 
 	if (kz_pa_dbf.use_table(kz_pa_db, &kz_presentity_table) < 0)
@@ -173,7 +170,7 @@ int kz_pua_publish_presence_to_presentity(struct json_object *json_obj) {
     str activity = str_init("");
     str note = str_init("Idle");
     str status = str_presence_status_online;
-    int expires = dbk_presence_expires;
+    int expires = 0;
 
     char *body = (char *)pkg_malloc(PRESENCE_BODY_BUFFER_SIZE);
     if(body == NULL) {
@@ -197,6 +194,8 @@ int kz_pua_publish_presence_to_presentity(struct json_object *json_obj) {
     struct json_object* ExpiresObj = json_object_object_get(json_obj, BLF_JSON_EXPIRES);
     if(ExpiresObj != NULL) {
     	expires = json_object_get_int(ExpiresObj);
+    	if(expires > 0)
+    		expires += (int)time(NULL);
     }
 
     if (!from_user.len || !to_user.len || !state.len) {
@@ -250,7 +249,7 @@ int kz_pua_publish_mwi_to_presentity(struct json_object *json_obj) {
         mwi_new = { 0, 0 }, mwi_saved = { 0, 0 },
         mwi_urgent = { 0, 0 }, mwi_urgent_saved = { 0, 0 },
         mwi_account = { 0, 0 }, mwi_body = { 0, 0 };
-    int expires = dbk_mwi_expires;
+    int expires = 0;
 
     char *body = (char *)pkg_malloc(MWI_BODY_BUFFER_SIZE);
     if(body == NULL) {
@@ -280,6 +279,8 @@ int kz_pua_publish_mwi_to_presentity(struct json_object *json_obj) {
     struct json_object* ExpiresObj = json_object_object_get(json_obj, BLF_JSON_EXPIRES);
     if(ExpiresObj != NULL) {
     	expires = json_object_get_int(ExpiresObj);
+    	if(expires > 0)
+    		expires += (int)time(NULL);
     }
 
     sprintf(body, MWI_BODY, mwi_waiting.len, mwi_waiting.s,
@@ -314,7 +315,7 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     char sender_buf[1024];
     str sender = {0, 0};
     str dialoginfo_body = {0 , 0};
-    int expires = dbk_dialog_expires;
+    int expires = 0;
     str event = str_init("dialog");
     int reset = 0;
 
@@ -341,6 +342,8 @@ int kz_pua_publish_dialoginfo_to_presentity(struct json_object *json_obj) {
     struct json_object* ExpiresObj = json_object_object_get(json_obj, BLF_JSON_EXPIRES);
     if(ExpiresObj != NULL) {
     	expires = json_object_get_int(ExpiresObj);
+    	if(expires > 0)
+    		expires += (int)time(NULL);
     }
 
     ExpiresObj = json_object_object_get(json_obj, "Flush-Level");




More information about the sr-dev mailing list