|
@@ -35,8 +35,8 @@
|
|
|
#include "../../hashes.h"
|
|
|
#include "../../dprint.h"
|
|
|
#include "../../mem/shm_mem.h"
|
|
|
+#include "../../xavp.h"
|
|
|
#include "../../str.h"
|
|
|
-#include "../alias_db/alias_db.h"
|
|
|
#include "../../data_lump_rpl.h"
|
|
|
#include "presentity.h"
|
|
|
#include "presence.h"
|
|
@@ -46,6 +46,9 @@
|
|
|
#include "utils_func.h"
|
|
|
|
|
|
|
|
|
+/* base priority value (20150101T000000) */
|
|
|
+#define PRES_PRIORITY_TBASE 1420070400
|
|
|
+
|
|
|
xmlNodePtr xmlNodeGetNodeByName(xmlNodePtr node, const char *name,
|
|
|
const char *ns);
|
|
|
static str pu_200_rpl = str_init("OK");
|
|
@@ -164,7 +167,31 @@ error:
|
|
|
pkg_free(hdr_append2.s);
|
|
|
|
|
|
return -1;
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * get priority value for presence document
|
|
|
+ */
|
|
|
+unsigned int pres_get_priority(void)
|
|
|
+{
|
|
|
+ sr_xavp_t *vavp = NULL;
|
|
|
+ str vname = str_init("priority");
|
|
|
+
|
|
|
+ if(pres_xavp_cfg.s==NULL || pres_xavp_cfg.len<=0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ vavp = xavp_get_child_with_ival(&pres_xavp_cfg, &vname);
|
|
|
+ if(vavp!=NULL) {
|
|
|
+ return (unsigned int)vavp->val.v.i;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (unsigned int)(time(NULL) - PRES_PRIORITY_TBASE);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * create new presentity record
|
|
|
+ */
|
|
|
presentity_t* new_presentity( str* domain,str* user,int expires,
|
|
|
pres_ev_t* event, str* etag, str* sender)
|
|
|
{
|
|
@@ -221,6 +248,7 @@ presentity_t* new_presentity( str* domain,str* user,int expires,
|
|
|
presentity->event= event;
|
|
|
presentity->expires = expires;
|
|
|
presentity->received_time= (int)time(NULL);
|
|
|
+ presentity->priority = pres_get_priority();
|
|
|
return presentity;
|
|
|
|
|
|
error:
|
|
@@ -268,9 +296,9 @@ int check_if_dialog(str body, int *is_dialog)
|
|
|
int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
|
int new_t, int* sent_reply, char* sphere)
|
|
|
{
|
|
|
- db_key_t query_cols[12], update_keys[8], result_cols[5];
|
|
|
- db_op_t query_ops[12];
|
|
|
- db_val_t query_vals[12], update_vals[8];
|
|
|
+ db_key_t query_cols[13], update_keys[9], result_cols[6];
|
|
|
+ db_op_t query_ops[13];
|
|
|
+ db_val_t query_vals[13], update_vals[9];
|
|
|
db1_res_t *result= NULL;
|
|
|
int n_query_cols = 0;
|
|
|
int n_update_cols = 0;
|
|
@@ -375,6 +403,12 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
|
|
|
query_vals[n_query_cols].nul = 0;
|
|
|
query_vals[n_query_cols].val.int_val = presentity->received_time;
|
|
|
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 = presentity->priority;
|
|
|
+ n_query_cols++;
|
|
|
|
|
|
if (presentity->expires != -1)
|
|
|
{
|
|
@@ -677,6 +711,12 @@ after_dialog_check:
|
|
|
update_vals[n_update_cols].val.int_val= presentity->received_time;
|
|
|
n_update_cols++;
|
|
|
|
|
|
+ update_keys[n_update_cols] = &str_priority_col;
|
|
|
+ update_vals[n_update_cols].type = DB1_INT;
|
|
|
+ update_vals[n_update_cols].nul = 0;
|
|
|
+ update_vals[n_update_cols].val.int_val= presentity->priority;
|
|
|
+ n_update_cols++;
|
|
|
+
|
|
|
if(body && body->s)
|
|
|
{
|
|
|
update_keys[n_update_cols] = &str_body_col;
|
|
@@ -1088,7 +1128,11 @@ char* get_sphere(str* pres_uri)
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- query_str = str_received_time_col;
|
|
|
+ if(pres_retrieve_order==1) {
|
|
|
+ query_str = str_priority_col;
|
|
|
+ } else {
|
|
|
+ query_str = str_received_time_col;
|
|
|
+ }
|
|
|
if (pa_dbf.query (pa_db, query_cols, 0, query_vals,
|
|
|
result_cols, n_query_cols, n_result_cols, &query_str , &result) < 0)
|
|
|
{
|