[reSIProcate] MessageWaitingContexts: a bit wrong encoding

Scott Godin slgodin at icescape.com
Wed Nov 9 09:56:03 CST 2005


Thanks Sasha - I've committed your fixes to SVN.

 

Scott

 

________________________________

From: resiprocate-devel-bounces at list.sipfoundry.org
[mailto:resiprocate-devel-bounces at list.sipfoundry.org] On Behalf Of
Sasha Youkhananov
Sent: Wednesday, November 09, 2005 8:09 AM
To: resiprocate-devel at list.sipfoundry.org
Subject: [reSIProcate] MessageWaitingContexts: a bit wrong encoding

 

Hello resiprocate developers.

 

In order to implement MWI feature in my application I made simple
notifier that works as my voice mail server and sends towards me NOTIFY
messages with bodies using MessageWaitingContexts class.

 

For example, in ServerSubscriptionHandler::onNewSubscription () I call:

Data Txt ("Messages-Waiting: yes\r\n"

          "Message-Account: sip:a at vmail.b.com\r\n"

          "Voice-Message: 2/1 (1/0)\r\n");

HeaderFieldValue Hfv (Txt.begin (), Txt.size ());

MessageWaitingContexts Mwc (& Hfv, Mime ("application",
"message-summary");

 

Unfortunately, encoder of MessageWaitingContexts class produces a bit
wrong output and after the message is encoded I get exactly following:

 

Messages-Waiting: yes\r\n

sip:a at vmail.b.comvoice-message: 2/1(1/0\r\n

 

That is the encoder doesn't place "Message-Account:" at the start of the
second line, doesn't add "\r\n" at its end, forgets to place space
character before '(' in case there are urgent messages and doesn't add
')' after urgent counters.

 

I slightly changed encoder and now it works as expected. I get correct
(to my mind) output:

Messages-Waiting: yes\r\n

Message-Account: sip:a at vmail.b.com\r\n

voice-message: 2/1 (1/0)\r\n

 

Here are the changes (signed with "added by S.Y.") I did in function
MessageWaitingContents::encodeParsed:

 

...

if (exists(mw_account))

{

s << "Message-Account" << Symbols::COLON[0] << Symbols::SPACE[0]; //*
added by S.Y. the entire line

      header(mw_account).encode(s);

      s << Symbols::CRLF; //* added by S.Y. the entire line

}

 

for(int i = 0; i < (int)MW_MAX; i++)

{

if (mHeaders[i] != 0)

      {

            s << MessageHeaders[i] << Symbols::COLON[0] <<
Symbols::SPACE[0]

              << mHeaders[i]->mNew << Symbols::SLASH[0] 

              << mHeaders[i]->mOld;

            if (mHeaders[i]->mHasUrgent)

            {

                  s << Symbols::SPACE[0] << Symbols::LPAREN[0]    //*
added by S.Y. SPACE[0]

                  << mHeaders[i]->mUrgentNew << Symbols::SLASH[0] 

                  << mHeaders[i]->mUrgentOld << Symbols::RPAREN[0]; //*
added by S.Y. RPAREN[0]

            }

 

            s << Symbols::CRLF;

      }

}

...

 

 

Best regards, 

Sasha.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20051109/308449dc/attachment.htm>


More information about the resiprocate-devel mailing list