Module: kamailio
Branch: master
Commit: 2584ba37b2d8c0aa42f83820dd6384c3ed9c3042
URL:
https://github.com/kamailio/kamailio/commit/2584ba37b2d8c0aa42f83820dd6384c…
Author: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Committer: Emmanuel Schmidbauer <emmanuel(a)getweave.com>
Date: 2016-05-09T16:53:51-04:00
Merge pull request #607 from kamailio/NSQ/feature-MWI-Voice-Message
nsq: allow sending MWI-Voice-Message json for message details
---
Modified: modules/nsq/defs.h
Modified: modules/nsq/nsq_pua.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2584ba37b2d8c0aa42f83820dd6384c…
Patch:
https://github.com/kamailio/kamailio/commit/2584ba37b2d8c0aa42f83820dd6384c…
---
diff --git a/modules/nsq/defs.h b/modules/nsq/defs.h
index 7e75756..8c5060c 100644
--- a/modules/nsq/defs.h
+++ b/modules/nsq/defs.h
@@ -38,6 +38,7 @@
#define BLF_JSON_CONTACT "Contact"
#define BLF_JSON_EVENT_PKG "Event-Package"
#define MWI_JSON_WAITING "Messages-Waiting"
+#define MWI_JSON_VOICE_MESSAGE "MWI-Voice-Message"
#define MWI_JSON_NEW "Messages-New"
#define MWI_JSON_SAVED "Messages-Saved"
#define MWI_JSON_URGENT "Messages-Urgent"
@@ -50,6 +51,7 @@
#define MWI_BODY_BUFFER_SIZE 2048
#define PRESENCE_BODY_BUFFER_SIZE 4096
+#define MWI_BODY_VOICE_MESSAGE "Messages-Waiting: %.*s\r\nMessage-Account:
%.*s\r\nVoice-Message: %.*s\r\n"
#define MWI_BODY "Messages-Waiting: %.*s\r\nMessage-Account:
%.*s\r\nVoice-Message: %.*s/%.*s (%.*s/%.*s)\r\n"
#define PRESENCE_BODY "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"
xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\"
xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\"
xmlns:c=\"urn:ietf:params:xml:ns:pidf:cipid\" entity=\"%s\"> \
diff --git a/modules/nsq/nsq_pua.c b/modules/nsq/nsq_pua.c
index 1fa8826..082f4af 100644
--- a/modules/nsq/nsq_pua.c
+++ b/modules/nsq/nsq_pua.c
@@ -277,7 +277,7 @@ int nsq_pua_publish_mwi_to_presentity(struct json_object *json_obj) {
str from_realm = { 0, 0 }, to_realm = { 0, 0 };
str callid = { 0, 0 }, fromtag = { 0, 0 }, totag = { 0, 0 };
str mwi_user = { 0, 0 }, mwi_waiting = { 0, 0 },
- mwi_new = { 0, 0 }, mwi_saved = { 0, 0 },
+ mwi_voice_message = { 0, 0 }, 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 = 0;
@@ -301,6 +301,7 @@ int nsq_pua_publish_mwi_to_presentity(struct json_object *json_obj) {
json_extract_field(MWI_JSON_TO, mwi_user);
json_extract_field(MWI_JSON_WAITING, mwi_waiting);
+ json_extract_field(MWI_JSON_VOICE_MESSAGE, mwi_voice_message);
json_extract_field(MWI_JSON_NEW, mwi_new);
json_extract_field(MWI_JSON_SAVED, mwi_saved);
json_extract_field(MWI_JSON_URGENT, mwi_urgent);
@@ -314,10 +315,15 @@ int nsq_pua_publish_mwi_to_presentity(struct json_object *json_obj)
{
expires += (int)time(NULL);
}
- sprintf(body, MWI_BODY, mwi_waiting.len, mwi_waiting.s,
- mwi_account.len, mwi_account.s, mwi_new.len, mwi_new.s,
- mwi_saved.len, mwi_saved.s, mwi_urgent.len, mwi_urgent.s,
- mwi_urgent_saved.len, mwi_urgent_saved.s);
+ if (mwi_voice_message.len > 0) {
+ sprintf(body, MWI_BODY_VOICE_MESSAGE, mwi_waiting.len, mwi_waiting.s,
+ mwi_account.len, mwi_account.s, mwi_voice_message.len, mwi_voice_message.s);
+ } else {
+ sprintf(body, MWI_BODY, mwi_waiting.len, mwi_waiting.s,
+ mwi_account.len, mwi_account.s, mwi_new.len, mwi_new.s,
+ mwi_saved.len, mwi_saved.s, mwi_urgent.len, mwi_urgent.s,
+ mwi_urgent_saved.len, mwi_urgent_saved.s);
+ }
mwi_body.s = body;
mwi_body.len = strlen(body);