diff --git a/modules/kazoo/const.c b/modules/kazoo/const.c index 4b99107d8a4..97a05419ea6 100644 --- a/modules/kazoo/const.c +++ b/modules/kazoo/const.c @@ -17,6 +17,7 @@ str str_body_col = str_init("body"); str str_expires_col = str_init("expires"); str str_received_time_col = str_init("received_time"); str str_presentity_uri_col = str_init("presentity_uri"); +str str_priority_col = str_init("priority"); str str_event_col = str_init("event"); str str_contact_col = str_init("contact"); diff --git a/modules/kazoo/const.h b/modules/kazoo/const.h index a80e75617dd..0e469bdbdb9 100644 --- a/modules/kazoo/const.h +++ b/modules/kazoo/const.h @@ -20,6 +20,7 @@ extern str str_body_col; extern str str_expires_col; extern str str_received_time_col; extern str str_presentity_uri_col; +extern str str_priority_col; extern str str_event_col; extern str str_contact_col; @@ -40,5 +41,6 @@ extern str str_presence_status_online; extern str str_null_string; +extern char kz_json_escape_char; #endif /* DBK_CONST_H_ */ diff --git a/modules/kazoo/kz_amqp.c b/modules/kazoo/kz_amqp.c index 9664cfd5e44..075ad84f871 100644 --- a/modules/kazoo/kz_amqp.c +++ b/modules/kazoo/kz_amqp.c @@ -1261,10 +1261,9 @@ int get_channel_index() { int kz_amqp_bind_targeted_channel(kz_amqp_conn_ptr kz_conn, int idx ) { kz_amqp_bind_ptr bind = channels[idx].targeted; - amqp_queue_declare_ok_t *r = NULL; int ret = -1; - r = amqp_queue_declare(kz_conn->conn, channels[idx].channel, bind->queue, 0, 0, 1, 1, kz_amqp_empty_table); + amqp_queue_declare(kz_conn->conn, channels[idx].channel, bind->queue, 0, 0, 1, 1, kz_amqp_empty_table); if (kz_amqp_error("Declaring queue", amqp_get_rpc_reply(kz_conn->conn))) { goto error; @@ -1297,7 +1296,6 @@ int kz_amqp_bind_targeted_channel(kz_amqp_conn_ptr kz_conn, int idx ) int kz_amqp_bind_targeted_channel_ex(kz_amqp_conn_ptr kz_conn, int loopcount, int idx ) { kz_amqp_bind_ptr bind = NULL; - amqp_queue_declare_ok_t *r = NULL; str rpl_exch = str_init("targeted"); str rpl_exch_type = str_init("direct"); int ret = -1; @@ -1325,7 +1323,7 @@ int kz_amqp_bind_targeted_channel_ex(kz_amqp_conn_ptr kz_conn, int loopcount, in goto error; } - r = amqp_queue_declare(kz_conn->conn, channels[idx].channel, bind->queue, 0, 0, 1, 1, kz_amqp_empty_table); + amqp_queue_declare(kz_conn->conn, channels[idx].channel, bind->queue, 0, 0, 1, 1, kz_amqp_empty_table); if (kz_amqp_error("Declaring queue", amqp_get_rpc_reply(kz_conn->conn))) { goto error; @@ -1738,12 +1736,12 @@ void kz_amqp_manager_loop(int child_no) int INTERNAL_READ_COUNT , INTERNAL_READ_MAX_LOOP; int CONSUMER_READ_COUNT , CONSUMER_READ_MAX_LOOP; int ACK_READ_COUNT , ACK_READ_MAX_LOOP; - char* payload; int channel_res; kz_amqp_conn_ptr kzconn; kz_amqp_cmd_ptr cmd; int loopcount = 0; int firstLoop = dbk_consume_messages_on_reconnect; + char* payload = NULL; while(1) { @@ -2114,10 +2112,10 @@ void kz_amqp_consumer_proc(int child_no) close(kz_pipe_fds[child_no*2+1]); int i, idx; int OK; - char* payload; int channel_res; kz_amqp_conn_ptr kzconn; kz_amqp_channel_ptr consumer_channels = NULL; + char* payload = NULL; kzconn = (kz_amqp_conn_ptr)pkg_malloc(sizeof(kz_amqp_conn)); if(kzconn == NULL) diff --git a/modules/kazoo/kz_amqp.h b/modules/kazoo/kz_amqp.h index 88ad8356d1f..bb222e67caa 100644 --- a/modules/kazoo/kz_amqp.h +++ b/modules/kazoo/kz_amqp.h @@ -11,6 +11,7 @@ #include #include "../../sr_module.h" +#include "../../str.h" #include "const.h" #include "defs.h" @@ -158,6 +159,11 @@ int kz_pv_get_event_payload(struct sip_msg *msg, pv_param_t *param, pv_value_t * int kz_pv_get_last_query_result(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); int kz_pv_get_connection_host(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); +/* callid generator */ +int kz_callid_init(void); +int kz_callid_child_init(int rank); +void kz_generate_callid(str* callid); + static inline int kz_amqp_error(char const *context, amqp_rpc_reply_t x) { amqp_connection_close_t *mconn; diff --git a/modules/kazoo/kz_json.c b/modules/kazoo/kz_json.c index c21a553c62a..5e705a02c1b 100644 --- a/modules/kazoo/kz_json.c +++ b/modules/kazoo/kz_json.c @@ -1,8 +1,4 @@ /** - * $Id$ - * - * Copyright (C) 2011 Flowroute LLC (flowroute.com) - * * This file is part of Kamailio, a free SIP server. * * This file is free software; you can redistribute it and/or modify @@ -33,6 +29,18 @@ #include "../../pvar.h" #include "../../usr_avp.h" +# define json_foreach_key(obj,key) \ + char *key;\ + struct lh_entry *entry ## key; \ + struct lh_entry *entry_next ## key = NULL; \ + for(entry ## key = json_object_get_object(obj)->head; \ + (entry ## key ? ( \ + key = (char*)entry ## key->k, \ + entry_next ## key = entry ## key->next, \ + entry ## key) : 0); \ + entry ## key = entry_next ## key) + + static str kz_pv_str_empty = {"", 0}; char** str_split(char* a_str, const char a_delim) @@ -290,12 +298,12 @@ int kz_json_get_keys(struct sip_msg* msg, char* json, char* field, char* dst) struct json_object *jtree = kz_json_get_field_object(&json_s, &field_s); if(jtree != NULL) { - json_object_object_foreach(jtree, k, v) { + json_foreach_key(jtree, k) { LM_DBG("ITERATING KEY %s\n", k); - int_str val; - val.s.s = k; - val.s.len = strlen(k); - if (add_avp(AVP_VAL_STR|keys_avp_type, keys_avp_name, val) < 0) { + int_str v1; + v1.s.s = k; + v1.s.len = strlen(k); + if (add_avp(AVP_VAL_STR|keys_avp_type, keys_avp_name, v1) < 0) { LM_ERR("failed to create AVP\n"); json_object_put(jtree); return -1; diff --git a/modules/kazoo/kz_pua.c b/modules/kazoo/kz_pua.c index d9757a7b478..e75cad322f9 100644 --- a/modules/kazoo/kz_pua.c +++ b/modules/kazoo/kz_pua.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "../../mem/mem.h" #include "../../timer_proc.h" #include "../../sr_module.h" @@ -9,15 +8,11 @@ #include "../presence/bind_presence.h" #include "../../pvar.h" -#include "../pua/pua.h" -#include "../pua/pua_bind.h" -#include "../pua/send_publish.h" - -#include "kz_pua.h" #include "defs.h" #include "const.h" #include "kz_json.h" +#include "kz_pua.h" extern int dbk_include_entity; extern int dbk_pua_mode; @@ -29,9 +24,9 @@ extern str kz_presentity_table; int kz_pua_update_presentity(str* event, str* realm, str* user, str* etag, str* sender, str* body, int expires, int reset) { - db_key_t query_cols[12]; - db_op_t query_ops[12]; - db_val_t query_vals[12]; + db_key_t query_cols[13]; + db_op_t query_ops[13]; + db_val_t query_vals[13]; int n_query_cols = 0; int ret = -1; int use_replace = 1; @@ -88,6 +83,12 @@ int kz_pua_update_presentity(str* event, str* realm, str* user, str* etag, str* query_vals[n_query_cols].val.int_val = expires; n_query_cols++; + query_cols[n_query_cols] = &str_priority_col; + query_vals[n_query_cols].type = DB1_INT; + query_vals[n_query_cols].nul = 0; + query_vals[n_query_cols].val.int_val = 0; + n_query_cols++; + if (kz_pa_dbf.use_table(kz_pa_db, &kz_presentity_table) < 0) { LM_ERR("unsuccessful use_table\n");