aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-03-26 00:15:11 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-03-26 00:15:11 +0000
commit821fb99f76c2b0bcaeaac4ba2507706e327521e0 (patch)
treef4390ba612566a961f42a0de06234bc7b084a7d7 /channels
parent18e59eea4122770c018c770213abc1c053ffdd0a (diff)
Make SIP message notify send detail MWI info
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@688 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 2582a1b10..3ec1a29e6 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2027,19 +2027,22 @@ static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, ch
return send_request(p, &req);
}
-static int transmit_notify(struct sip_pvt *p, int hasmsgs)
+static int transmit_notify(struct sip_pvt *p, int newmsgs, int oldmsgs)
{
struct sip_request req;
char tmp[256];
+ char tmp2[256];
char clen[20];
initreqprep(&req, p, "NOTIFY", NULL);
add_header(&req, "Event", "message-summary");
add_header(&req, "Content-Type", "text/plain");
- snprintf(tmp, sizeof(tmp), "Message-Waiting: %s\n", hasmsgs ? "yes" : "no");
- snprintf(clen, sizeof(clen), "%d", strlen(tmp));
+ snprintf(tmp, sizeof(tmp), "Message-Waiting: %s\n", (newmsgs + oldmsgs) ? "yes" : "no");
+ snprintf(tmp2, sizeof(tmp2), "Voicemail: %d/%d\n", newmsgs, oldmsgs);
+ snprintf(clen, sizeof(clen), "%d", strlen(tmp) + strlen(tmp2));
add_header(&req, "Content-Length", clen);
add_line(&req, tmp);
+ add_line(&req, tmp2);
if (!p->initreq.headers) {
/* Use this as the basis */
@@ -3694,15 +3697,15 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
{
/* Called with peerl lock, but releases it */
struct sip_pvt *p;
- int hasmsgs;
char name[256] = "";
+ int newmsgs, oldmsgs;
/* Check for messages */
- hasmsgs = ast_app_has_voicemail(peer->mailbox);
+ ast_app_messagecount(peer->mailbox, &newmsgs, &oldmsgs);
time(&peer->lastmsgcheck);
/* Return now if it's the same thing we told them last time */
- if (hasmsgs == peer->lastmsgssent) {
+ if (((newmsgs << 8) | (oldmsgs)) == peer->lastmsgssent) {
ast_pthread_mutex_unlock(&peerl.lock);
return 0;
}
@@ -3714,7 +3717,7 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
return -1;
}
strncpy(name, peer->name, sizeof(name) - 1);
- peer->lastmsgssent = hasmsgs;
+ peer->lastmsgssent = ((newmsgs << 8) | (oldmsgs));
ast_pthread_mutex_unlock(&peerl.lock);
if (create_addr(p, peer->name)) {
/* Maybe they're not registered, etc. */
@@ -3726,7 +3729,7 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=%08x", inet_ntoa(p->ourip), ourport, p->branch);
build_callid(p->callid, sizeof(p->callid), p->ourip);
/* Send MWI */
- transmit_notify(p, hasmsgs);
+ transmit_notify(p, newmsgs, oldmsgs);
/* Destroy channel */
sip_destroy(p);
return 0;