< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

Re: [reSIProcate] MessageWaitingContexts: a bit wrong encoding


There is an easier way to make a MWI message.

Uri uri = Data::from("sip:jason@xxxxxxxxxxx");
MessageWaitingContents mwi;
mwi.header(mw_account) = uri;
mwi.header(mw_voice).newCount() = 4;
mwi.header(mw_voice).oldCount()  = 20;
mwi.header(mw_voice).urgentNewCount() = 1;
mwi.header(mw_voice).urgentOldCount() = 3;

SipMessage msg;
msg.setContents(&mwi);


On 11/9/05, Scott Godin <slgodin@xxxxxxxxxxxx> wrote:
>
>
>
> Thanks Sasha – I've committed your fixes to SVN.
>
>
>
> Scott
>
>
>
>
>  ________________________________
>
>
> From: resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx
> [mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx] On
> Behalf Of Sasha Youkhananov
>  Sent: Wednesday, November 09, 2005 8:09 AM
>  To: resiprocate-devel@xxxxxxxxxxxxxxxxxxx
>  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@xxxxxxxxxxx\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@xxxxxxxxxxxxxxxxxxxxxxxx: 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@xxxxxxxxxxx\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.
>
>
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxxxxxx
> https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel
>
>