[asterisk-dev] [Code Review] Group Variables

Sean Bright sean.bright at gmail.com
Sat Jan 23 17:21:40 CST 2010


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/464/#review1404
-----------------------------------------------------------


I started to do a more exhaustive review but have to run.  These are what I have so far.  Will do more once you've updated the diff.


/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3164>

    Don't introduce unnecessary white space changes in the diff in the future.  It makes it more difficult to review.



/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3170>

    Yes, everywhere we have a manager event we use this variable name, but it is not in line with our coding standards.  Use 'action_id' or 'id_text' or something else you think is appropriate.



/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3168>

    ast_free()



/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3169>

    ast_malloc()



/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3167>

    Use either ast_build_string or an ast_str here instead of manually building.



/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3171>

    ast_free()



/trunk/funcs/func_groupcount.c
<https://reviewboard.asterisk.org/r/464/#comment3172>

    Why was this change necessary?  AST_MODULE_INFO_STANDARD should be fine here.



/trunk/include/asterisk/app.h
<https://reviewboard.asterisk.org/r/464/#comment3173>

    group and category should be 'const char *'



/trunk/include/asterisk/app.h
<https://reviewboard.asterisk.org/r/464/#comment3174>

    Same here, group and category should be 'const char *'



/trunk/main/app.c
<https://reviewboard.asterisk.org/r/464/#comment3175>

    While it is not my personaly preference, the coding guidelines suggest shortening conditionals when possible.  So here we would use:
    
        if (strcasecmp(gmi->group, group) || strcasecmp(gmi->category, category)) {
    
    This happens a few other places in the new code.



/trunk/main/app.c
<https://reviewboard.asterisk.org/r/464/#comment3165>

    group and category should be 'const char *' here.



/trunk/main/app.c
<https://reviewboard.asterisk.org/r/464/#comment3166>

    Use ast_calloc().  There are probably other places where the raw versions of the memory allocation functions are being used so I won't explicitly list them all, but you get the idea.


- Sean


On 2010-01-14 15:47:31, kobaz wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/464/
> -----------------------------------------------------------
> 
> (Updated 2010-01-14 15:47:31)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> This patch allows for setting variables on a group of channels.
> First a channel is assigned a group via dialplan GROUP() or GroupSet via the ami (new command)
> Then, variables can be set on that group with the GROUP_VAR() dialplan function, or GroupVarSet in the manager
> 
> This patch also adds manager events for channel group changes, and variable updates
> 
> When a group is no longer used (all channels referencing the group are hung up, or all channels referencing the group have their group changed/unset), variables are destroyed
> 
> new manager commands:
> GroupSet - adds functionality to the manager to be able to set a GROUP() on a channel.
> GroupsShowChannels - show each channel and it's associated groups (a channel will be repeated for each group at category it's a member of)
> GroupsShowVariables - show variables in each group at category, one event per group, all variables are contained in each group at category event
> GroupVarSet - set a group variable (the group has to exist)
> GroupVarGet - get a group variable
> 
> new manager events:
> GroupCreate
> GroupChannelAdd
> GroupChannelRemove
> GroupDestroy
> GroupVarSet
> 
> Example AMI:
> Action: GroupVarSet
> Group: 1000
> Category: ConferenceBridge
> Variable: LastUpdateCheck
> Value: 1263502512
> 
> Example CLI:
> demo1*CLI> group show variables
> Group    Variables    Category
> 1000            ConferenceBridge
>     LastUpdateCheck=1263502512
> 1000            ConferenceModerator
> 2 active groups
> 
> 
> Adds support for:
>   Group variables
>      dialplan access: GROUP_VAR()
>      cli access: group show variables
>      manager access: GroupVarSet GroupVarGet
>   Group information: 
>      manager access: GroupSet GroupsShow GroupsShowChannels GroupsShowVariables
>   
> 
> 
> Diffs
> -----
> 
>   /trunk/include/asterisk/channel.h 240226 
>   /trunk/main/app.c 240226 
>   /trunk/main/cli.c 240226 
>   /trunk/include/asterisk/app.h 240226 
>   /trunk/funcs/func_groupcount.c 240226 
> 
> Diff: https://reviewboard.asterisk.org/r/464/diff
> 
> 
> Testing
> -------
> 
> dialplan:
>     Set(GROUP()=foo);
>     Set(GROUP()=foobar at foocat);
> 
>     Set(GROUP_VAR(foo,myvar)=123);
>     Set(GROUP_VAR(foo,myvar2)=456);
>     NoOp(${GROUP_VAR(foo,myvar)});
>     NoOp(${GROUP_VAR(foo,myvar2)});
> 
>     Set(GROUP_VAR(foobar at foocat,myvar)=123);
>     NoOp(${GROUP_VAR(foobar at foocat,myvar)});
> 
>     Set(GROUP_VAR(something,myvar)=123);
>     NoOp(${GROUP_VAR(something,myvar)});
> 
>     Wait(10000);
>     Hangup();
> 
> 
> CLI:
> -------------------
> > group show channels
> -------------------
> channel                    Group                 Category
> IAX2/branch-15569          foo                   (default)
> IAX2/branch-15569          foobar                foocat
> 2 active channels
> 
> -------------------
> > group show variables
> -------------------
> Group    Variables    Category
> foo                   (Default)
>      myvar2=456
>      myvar=123
> foobar                foocat
>      myvar=123
> 2 active groups
> 
> 
> AMI:
> -------------------
> Action: GroupsShow
> -------------------
> Response: Success
> Eventlist: start
> Message: Groups will follow
> 
> Event: GroupsShow
> Group: foo
> Category:
> 
> Event: GroupsShow
> Group: foobar
> Category: foocat
> 
> Event: GroupsShowComplete
> EventList: Complete
> ListItems: 2
> 
> 
> -------------------
> Action: GroupsShowChannels
> -------------------
> Response: Success
> Eventlist: start
> Message: Group channels will follow
> 
> Event: GroupsShowChannels
> Group: foo
> Category:
> Channel: IAX2/branch-14981
> 
> Event: GroupsShowChannels
> Group: foobar
> Category: foocat
> Channel: IAX2/branch-14981
> 
> Event: GroupsShowChannelsComplete
> EventList: Complete
> ListItems: 2
> 
> 
> -------------------
> Action: GroupsShowVariables
> -------------------
> Response: Success
> Eventlist: start
> Message: Group variables will follow
> 
> Event: GroupsShowVariables
> Group: foo
> Category:
> VariablesStart: Variables will follow
> myvar2: 456
> myvar: 123
> 
> 
> Event: GroupsShowVariables
> Group: foobar
> Category: foocat
> VariablesStart: Variables will follow
> myvar: 123
> 
> Event: GroupsShowVariablesComplete
> EventList: Complete
> ListItems: 2
> 
> 
> -------------------
> Action: GroupVarGet
> Group: foo
> Variable: myvar
> -------------------
> Response: Success
> Message: Result will follow
> 
> Event: GroupVarGetResponse
> Group: foo
> Category:
> Variable: myvar
> Value: 123
> 
> 
> -------------------
> Action: GroupVarSet
> Group: foobar
> Category: foocat
> Variable: something
> Value: 1238091283123
> -------------------
> 
> Response: Success
> Message: Variable Set
> 
> 
> -------------------
> Action: GroupVarSet
> Group: doesntexist
> Category: foocat
> Variable: something
> Value: 1238091283123
> -------------------
> 
> Response: Error
> Message: Variable set failed (group doesn't exist)
> 
> 
> Thanks,
> 
> kobaz
> 
>




More information about the asterisk-dev mailing list