diff --git a/chan_capi_chat.c b/chan_capi_chat.c index a70a728..d48fcbb 100644 --- a/chan_capi_chat.c +++ b/chan_capi_chat.c @@ -1018,9 +1018,11 @@ int pbxcli_capi_chatinfo(int fd, int argc, char *argv[]) room->number, room->name, room->i->vname, "?", "?"); } else { + ast_channel_lock(c); ast_cli(fd, "%3d %-12s%-30s\"%s\" <%s>\n", room->number, room->name, c->name, - (c->cid.cid_name) ? c->cid.cid_name:"", c->cid.cid_num); + pbx_capi_get_callername (c), pbx_capi_get_cid (c)); + ast_channel_unlock(c); } room = room->next; } diff --git a/chan_capi_utils.c b/chan_capi_utils.c index d06856d..d8bb07b 100644 --- a/chan_capi_utils.c +++ b/chan_capi_utils.c @@ -1541,3 +1541,37 @@ int capi_write_frame(struct capi_pvt *i, struct ast_frame *f) return ret; } +/* + ast_channel_lock(chan) to be held while + while accessing returned pointer + */ +const char* pbx_capi_get_cid (struct ast_channel* c) +{ + const char* cid; + +#ifdef CC_AST_HAS_VERSION_1_8 + cid = S_COR(c->caller.id.number.valid, c->caller.id.number.str, ""); +#else + cid = c->cid.cid_num; +#endif + + return (cid); +} + +/* + ast_channel_lock(chan) to be held while + while accessing returned pointer + */ +const char* pbx_capi_get_callername (struct ast_channel* c) +{ + const char* name; + +#ifdef CC_AST_HAS_VERSION_1_8 + name = S_COR(c->caller.id.name.valid, c->caller.id.name.str, ""); +#else + name = (c->cid.cid_name) ? c->cid.cid_name : ""; +#endif + + return (name); +} + diff --git a/chan_capi_utils.h b/chan_capi_utils.h index 8dbc7d5..e811fce 100644 --- a/chan_capi_utils.h +++ b/chan_capi_utils.h @@ -59,6 +59,8 @@ extern int capi_create_reader_writer_pipe(struct capi_pvt *i); extern struct ast_frame *capi_read_pipeframe(struct capi_pvt *i); extern int capi_write_frame(struct capi_pvt *i, struct ast_frame *f); extern int capi_verify_resource_plci(const struct capi_pvt *i); +extern const char* pbx_capi_get_cid (struct ast_channel* c); +extern const char* pbx_capi_get_callername (struct ast_channel* c); #define capi_number(data, strip) \ capi_number_func(data, strip, alloca(AST_MAX_EXTENSION))