diff options
author | Terry Wilson <twilson@digium.com> | 2012-01-09 22:15:50 +0000 |
---|---|---|
committer | Terry Wilson <twilson@digium.com> | 2012-01-09 22:15:50 +0000 |
commit | 04da92c3799e546fa4d84bdaeebd499fb64aea7a (patch) | |
tree | 9617b8b2d6d06f96ba27c0baefc5b93eb9e3bc5b /apps/app_followme.c | |
parent | 64d1b247c407de2af029392a6c32a99bf11c7ded (diff) |
Replace direct access to channel name with accessor functions
There are many benefits to making the ast_channel an opaque handle, from
increasing maintainability to presenting ways to kill masquerades. This patch
kicks things off by taking things a field at a time, renaming the field to
'__do_not_use_${fieldname}' and then writing setters/getters and converting the
existing code to using them. When all fields are done, we can move ast_channel
to a C file from channel.h and lop off the '__do_not_use_'.
This patch sets up main/channel_interal_api.c to be the only file that actually
accesses the ast_channel's fields directly. The intent would be for any API
functions in channel.c to use the accessor functions. No more monkeying around
with channel internals. We should use our own APIs.
The interesting changes in this patch are the addition of
channel_internal_api.c, the moving of the AST_DATA stuff from channel.c to
channel_internal_api.c (note: the AST_DATA stuff will have to be reworked to
use accessor functions when ast_channel is really opaque), and some re-working
of the way channel iterators/callbacks are handled so as to avoid creating fake
ast_channels on the stack to pass in matching data by directly accessing fields
(since "name" is a stringfield and the fake channel doesn't init the
stringfields, you can't use the ast_channel_name_set() function). I went with
ast_channel_name(chan) for a getter, and ast_channel_name_set(chan, name) for a
setter.
The majority of the grunt-work for this change was done by writing a semantic
patch using Coccinelle ( http://coccinelle.lip6.fr/ ).
Review: https://reviewboard.asterisk.org/r/1655/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@350223 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_followme.c')
-rw-r--r-- | apps/app_followme.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/apps/app_followme.c b/apps/app_followme.c index 6d46a1fd5..d3e8f4778 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -681,7 +681,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us if (f->frametype == AST_FRAME_CONTROL) { switch (f->subclass.integer) { case AST_CONTROL_HANGUP: - ast_verb(3, "%s received a hangup frame.\n", winner->name); + ast_verb(3, "%s received a hangup frame.\n", ast_channel_name(winner)); if (f->data.uint32) { winner->hangupcause = f->data.uint32; } @@ -692,7 +692,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us } break; case AST_CONTROL_ANSWER: - ast_verb(3, "%s answered %s\n", winner->name, caller->name); + ast_verb(3, "%s answered %s\n", ast_channel_name(winner), ast_channel_name(caller)); /* If call has been answered, then the eventual hangup is likely to be normal hangup */ winner->hangupcause = AST_CAUSE_NORMAL_CLEARING; caller->hangupcause = AST_CAUSE_NORMAL_CLEARING; @@ -720,38 +720,38 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us } break; case AST_CONTROL_BUSY: - ast_verb(3, "%s is busy\n", winner->name); + ast_verb(3, "%s is busy\n", ast_channel_name(winner)); break; case AST_CONTROL_CONGESTION: - ast_verb(3, "%s is circuit-busy\n", winner->name); + ast_verb(3, "%s is circuit-busy\n", ast_channel_name(winner)); break; case AST_CONTROL_RINGING: - ast_verb(3, "%s is ringing\n", winner->name); + ast_verb(3, "%s is ringing\n", ast_channel_name(winner)); break; case AST_CONTROL_PROGRESS: - ast_verb(3, "%s is making progress passing it to %s\n", winner->name, caller->name); + ast_verb(3, "%s is making progress passing it to %s\n", ast_channel_name(winner), ast_channel_name(caller)); break; case AST_CONTROL_VIDUPDATE: - ast_verb(3, "%s requested a video update, passing it to %s\n", winner->name, caller->name); + ast_verb(3, "%s requested a video update, passing it to %s\n", ast_channel_name(winner), ast_channel_name(caller)); break; case AST_CONTROL_SRCUPDATE: - ast_verb(3, "%s requested a source update, passing it to %s\n", winner->name, caller->name); + ast_verb(3, "%s requested a source update, passing it to %s\n", ast_channel_name(winner), ast_channel_name(caller)); break; case AST_CONTROL_PROCEEDING: - ast_verb(3, "%s is proceeding passing it to %s\n", winner->name,caller->name); + ast_verb(3, "%s is proceeding passing it to %s\n", ast_channel_name(winner),ast_channel_name(caller)); break; case AST_CONTROL_HOLD: - ast_verb(3, "Call on %s placed on hold\n", winner->name); + ast_verb(3, "Call on %s placed on hold\n", ast_channel_name(winner)); break; case AST_CONTROL_UNHOLD: - ast_verb(3, "Call on %s left from hold\n", winner->name); + ast_verb(3, "Call on %s left from hold\n", ast_channel_name(winner)); break; case AST_CONTROL_OFFHOOK: case AST_CONTROL_FLASH: /* Ignore going off hook and flash */ break; case -1: - ast_verb(3, "%s stopped sounds\n", winner->name); + ast_verb(3, "%s stopped sounds\n", ast_channel_name(winner)); break; default: ast_debug(1, "Dunno what to do with control type %d\n", f->subclass.integer); @@ -1206,7 +1206,7 @@ static int app_exec(struct ast_channel *chan, const char *data) /* Make sure channels are compatible */ res = ast_channel_make_compatible(caller, outbound); if (res < 0) { - ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", caller->name, outbound->name); + ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", ast_channel_name(caller), ast_channel_name(outbound)); ast_hangup(outbound); goto outrun; } |