[prev in list] [next in list] [prev in thread] [next in thread]
List: asterisk-dev
Subject: Re: [asterisk-dev] [Code Review] 3482: func_presencestate: Make base64 encoded-ness consistent for c
From: "Joshua Colp" <reviewboard () asterisk ! org>
Date: 2014-04-29 11:59:19
Message-ID: 20140429115919.14465.38372 () sonic ! digium ! api
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3482/#review11777
-----------------------------------------------------------
Ship it!
Ship It!
- Joshua Colp
On April 25, 2014, 9:34 p.m., Mark Michelson wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/3482/
> -----------------------------------------------------------
>
> (Updated April 25, 2014, 9:34 p.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Bugs: ASTERISK-23671
> https://issues.asterisk.org/jira/browse/ASTERISK-23671
>
>
> Repository: Asterisk
>
>
> Description
> -------
>
> The 'e' option for the PRESENCE_STATE() function is not very well defined. \
> Specifically, when using the function in write mode, it is unclear whether \
> consumers of presence state events should expect to receive base64-encoded values \
> or not. Further, the behavior is not consistent within the module. When the initial \
> presence state is written, base64-encoded values are written to stasis and \
> consumers receive these encoded values. However, if the ast_presence_state() \
> function is called to retrieve the current presence values, decoded values are \
> returned.
> With this patch, if the subtype and message given in the PRESENCE_STATE() function \
> are base64-encoded, these values are decoded before being sent to stasis. This way, \
> consumers of presence state will always be guaranteed to get decoded values.
> So with this patch, you can do the following:
>
> exten => blah,1,Set(PRESENCE_STATE(CustomPresence:blah)=away,bHVuY2g=,Q2xlbSdzIENsYW1z,e) \
> ; Sends consumers state=away, subtype="lunch", message="Clem's Clams". Stores \
> base64 in astdb exten => \
> blah,n,Set(subtype=${PRESENCE_STATE(CustomPresence:blah,subtype)}) ; Sets subtype \
> to "lunch" exten => \
> blah,n,Set(message=${PRESENCE_STATE(CustomPresence:blah,message)}) ; Sets message \
> to "Clem's Clams"
> If you actually want to be sending Base64-encoded data to consumers, then omit the \
> e option.
> exten => blah,1,Set(PRESENCE_STATE(CustomPresence:blah)=away,bHVuY2g=,Q2xlbSdzIENsYW1z) \
> ; Sends consumers state=away, subtype="bHVuY2g=", message=Q2xlbSdzIENsYW1z. Stores \
> base64 in astdb exten => \
> blah,n,Set(subtype=${PRESENCE_STATE(CustomPresence:blah,subtype)}) ; Sets subtype \
> to "bHVuY2g=" exten => \
> blah,n,Set(message=${PRESENCE_STATE(CustomPresence:blah,message)}) ; Sets message \
> to "Q2xlbSdzIENsYW1z" exten => \
> blah,n,Set(subtype=${BASE64_DECODE(${PRESENCE_STATE(CustomPresence:blah,subtype)})}) \
> ; Sets subtype to "lunch" exten => \
> blah,n,Set(message=${BASE64_DECODe(${PRESENCE_STATE(CustomPresence:blah,message)})}) \
> ; Sets message to "Clem's Clams"
> To me, this behavior seems at the very least more consistent than what was being \
> done before. I'm certainly willing to hear objections, though.
>
> Diffs
> -----
>
> /trunk/funcs/func_presencestate.c 412583
>
> Diff: https://reviewboard.asterisk.org/r/3482/diff/
>
>
> Testing
> -------
>
> I have added a unit test that ensures this behaves as expected. In doing so, I \
> realized it was nearly identical to the previous test_presence_state_change test, \
> so I refactored the code to be reusable and to plug some memory leaks and stasis \
> subscription leaks.
>
> Thanks,
>
> Mark Michelson
>
>
[Attachment #5 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/3482/">https://reviewboard.asterisk.org/r/3482/</a>
</td>
</tr>
</table>
<br />
<p>Ship it!</p>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Ship It!</pre> <br />
<p>- Joshua Colp</p>
<br />
<p>On April 25th, 2014, 9:34 p.m. UTC, Mark Michelson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Asterisk Developers.</div>
<div>By Mark Michelson.</div>
<p style="color: grey;"><i>Updated April 25, 2014, 9:34 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23671">ASTERISK-23671</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The 'e' option for the PRESENCE_STATE() function is not very \
well defined. Specifically, when using the function in write mode, it is unclear \
whether consumers of presence state events should expect to receive base64-encoded \
values or not. Further, the behavior is not consistent within the module. When the \
initial presence state is written, base64-encoded values are written to stasis and \
consumers receive these encoded values. However, if the ast_presence_state() function \
is called to retrieve the current presence values, decoded values are returned.
With this patch, if the subtype and message given in the PRESENCE_STATE() function \
are base64-encoded, these values are decoded before being sent to stasis. This way, \
consumers of presence state will always be guaranteed to get decoded values.
So with this patch, you can do the following:
exten => blah,1,Set(PRESENCE_STATE(CustomPresence:blah)=away,bHVuY2g=,Q2xlbSdzIENsYW1z,e) \
; Sends consumers state=away, subtype="lunch", message="Clem's \
Clams". Stores base64 in astdb exten => \
blah,n,Set(subtype=${PRESENCE_STATE(CustomPresence:blah,subtype)}) ; Sets subtype to \
"lunch" exten => \
blah,n,Set(message=${PRESENCE_STATE(CustomPresence:blah,message)}) ; Sets message to \
"Clem's Clams"
If you actually want to be sending Base64-encoded data to consumers, then omit the e \
option.
exten => blah,1,Set(PRESENCE_STATE(CustomPresence:blah)=away,bHVuY2g=,Q2xlbSdzIENsYW1z) \
; Sends consumers state=away, subtype="bHVuY2g=", message=Q2xlbSdzIENsYW1z. \
Stores base64 in astdb exten => \
blah,n,Set(subtype=${PRESENCE_STATE(CustomPresence:blah,subtype)}) ; Sets subtype to \
"bHVuY2g=" exten => \
blah,n,Set(message=${PRESENCE_STATE(CustomPresence:blah,message)}) ; Sets message to \
"Q2xlbSdzIENsYW1z" exten => \
blah,n,Set(subtype=${BASE64_DECODE(${PRESENCE_STATE(CustomPresence:blah,subtype)})}) \
; Sets subtype to "lunch" exten => \
blah,n,Set(message=${BASE64_DECODe(${PRESENCE_STATE(CustomPresence:blah,message)})}) \
; Sets message to "Clem's Clams"
To me, this behavior seems at the very least more consistent than what was being done \
before. I'm certainly willing to hear objections, though.</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">I have added a unit test that ensures this behaves as expected. In doing \
so, I realized it was nearly identical to the previous test_presence_state_change \
test, so I refactored the code to be reusable and to plug some memory leaks and \
stasis subscription leaks.</pre> </td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/trunk/funcs/func_presencestate.c <span style="color: grey">(412583)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/3482/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic