Index: include/asterisk/channel.h =================================================================== --- include/asterisk/channel.h (revision 424055) +++ include/asterisk/channel.h (working copy) @@ -631,6 +631,7 @@ struct ast_channel *(* const requester)(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause); int (* const devicestate)(const char *device_number); /*!< Devicestate call back */ + int (* const presencestate)(const char *presence_provider, char **subtype, char **message); /*!< Presencestate callback */ /*! * \brief Start sending a literal DTMF digit Index: main/channel.c =================================================================== --- main/channel.c (revision 424055) +++ main/channel.c (working copy) @@ -61,6 +61,7 @@ #include "asterisk/app.h" #include "asterisk/transcap.h" #include "asterisk/devicestate.h" +#include "asterisk/presencestate.h" #include "asterisk/threadstorage.h" #include "asterisk/slinfactory.h" #include "asterisk/audiohook.h" @@ -275,7 +276,7 @@ /*! \brief Show channel types - CLI command */ static char *handle_cli_core_show_channeltypes(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { -#define FORMAT "%-15.15s %-40.40s %-12.12s %-12.12s %-12.12s\n" +#define FORMAT "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n" struct chanlist *cl; int count_chan = 0; @@ -294,13 +295,14 @@ if (a->argc != 3) return CLI_SHOWUSAGE; - ast_cli(a->fd, FORMAT, "Type", "Description", "Devicestate", "Indications", "Transfer"); - ast_cli(a->fd, FORMAT, "-----------", "-----------", "-----------", "-----------", "-----------"); + ast_cli(a->fd, FORMAT, "Type", "Description", "Devicestate", "Presencestate", "Indications", "Transfer"); + ast_cli(a->fd, FORMAT, "-------------", "-------------", "-------------", "-------------", "-------------", "-------------"); AST_RWLIST_RDLOCK(&backends); AST_RWLIST_TRAVERSE(&backends, cl, list) { ast_cli(a->fd, FORMAT, cl->tech->type, cl->tech->description, (cl->tech->devicestate) ? "yes" : "no", + (cl->tech->presencestate) ? "yes" : "no", (cl->tech->indicate) ? "yes" : "no", (cl->tech->transfer) ? "yes" : "no"); count_chan++; @@ -375,6 +377,7 @@ ast_cli(a->fd, "-- Info about channel driver: %s --\n" " Device State: %s\n" + "Presence State: %s\n" " Indication: %s\n" " Transfer : %s\n" " Capabilities: %s\n" @@ -385,6 +388,7 @@ " Text Support: %s\n", cl->tech->type, (cl->tech->devicestate) ? "yes" : "no", + (cl->tech->presencestate) ? "yes" : "no", (cl->tech->indicate) ? "yes" : "no", (cl->tech->transfer) ? "yes" : "no", ast_format_cap_get_names(cl->tech->capabilities, &codec_buf), @@ -7388,6 +7392,7 @@ ast_data_add_str(data_type, "name", cl->tech->type); ast_data_add_str(data_type, "description", cl->tech->description); ast_data_add_bool(data_type, "devicestate", cl->tech->devicestate ? 1 : 0); + ast_data_add_bool(data_type, "presencestate", cl->tech->presencestate ? 1 : 0); ast_data_add_bool(data_type, "indications", cl->tech->indicate ? 1 : 0); ast_data_add_bool(data_type, "transfer", cl->tech->transfer ? 1 : 0); ast_data_add_bool(data_type, "send_digit_begin", cl->tech->send_digit_begin ? 1 : 0); Index: main/presencestate.c =================================================================== --- main/presencestate.c (revision 424055) +++ main/presencestate.c (working copy) @@ -147,6 +147,7 @@ static enum ast_presence_state ast_presence_state_helper(const char *presence_provider, char **subtype, char **message, int check_cache) { struct presence_state_provider *provider; + const struct ast_channel_tech *chan_tech; char *address; char *label = ast_strdupa(presence_provider); int res = AST_PRESENCE_INVALID; @@ -158,6 +159,17 @@ } } + if ((address = strchr(label, '/'))) { + *address = '\0'; + address++; + + if ((chan_tech = ast_get_channel_tech(label)) && chan_tech->presencestate) { + res = chan_tech->presencestate(address, subtype, message); + } + + return res; + } + if ((address = strchr(label, ':'))) { *address = '\0'; address++;