Skip to content

Commit

Permalink
kazoo : missing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lazedo committed Jun 11, 2015
1 parent 7a871ed commit b3e0fe1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
1 change: 1 addition & 0 deletions modules/kazoo/const.c
Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions modules/kazoo/const.h
Expand Up @@ -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;
Expand All @@ -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_ */
10 changes: 4 additions & 6 deletions modules/kazoo/kz_amqp.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions modules/kazoo/kz_amqp.h
Expand Up @@ -11,6 +11,7 @@
#include <amqp.h>

#include "../../sr_module.h"
#include "../../str.h"

#include "const.h"
#include "defs.h"
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 17 additions & 9 deletions 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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 10 additions & 9 deletions modules/kazoo/kz_pua.c
@@ -1,23 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <json-c/json.h>
#include "../../mem/mem.h"
#include "../../timer_proc.h"
#include "../../sr_module.h"
#include "../../lib/kmi/mi.h"
#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;
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit b3e0fe1

Please sign in to comment.