diff --git a/chan_capi_ami.c b/chan_capi_ami.c index 019e8e8..32dac02 100644 --- a/chan_capi_ami.c +++ b/chan_capi_ami.c @@ -28,13 +28,13 @@ #include "chan_capi_platform.h" #include "chan_capi20.h" #include "chan_capi.h" -#ifdef CC_AST_HAS_VERSION_1_6 #include "chan_capi_qsig.h" #include "chan_capi_utils.h" #include "chan_capi_chat.h" #include "chan_capi_management_common.h" #include "asterisk/manager.h" +#ifdef CC_AST_HAS_VERSION_1_6 #define CC_AMI_ACTION_NAME_CHATLIST "CapichatList" #define CC_AMI_ACTION_NAME_CHATMUTE "CapichatMute" @@ -343,3 +343,56 @@ void pbx_capi_ami_unregister(void) { } #endif + +void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * room) +{ +#ifdef CC_AST_HAS_VERSION_1_8 + ast_manager_event(c, +#else + manager_event( +#endif + EVENT_FLAG_CALL, "CapichatJoin", + "Channel: %s\r\n" + "Uniqueid: %s\r\n" + "Conference: %s\r\n" + "Conferencenum: %u\r\n" + "CallerIDnum: %s\r\n" + "CallerIDname: %s\r\n", + c->name, c->uniqueid, + pbx_capi_chat_get_room_name(room), + pbx_capi_chat_get_room_number(room), + pbx_capi_get_cid (c, ""), + pbx_capi_get_callername (c, "")); +} + +void pbx_capi_chat_leave_event(struct ast_channel* c, + const struct capichat_s *room, + long duration) +{ +#ifdef CC_AST_HAS_VERSION_1_8 + ast_manager_event(c, +#else + manager_event( +#endif + EVENT_FLAG_CALL, "CapichatLeave", + "Channel: %s\r\n" + "Uniqueid: %s\r\n" + "Conference: %s\r\n" + "Conferencenum: %u\r\n" + "CallerIDNum: %s\r\n" + "CallerIDName: %s\r\n" + "Duration: %ld\r\n", + c->name, c->uniqueid, + pbx_capi_chat_get_room_name(room), + pbx_capi_chat_get_room_number(room), + pbx_capi_get_cid (c, ""), + pbx_capi_get_callername (c, ""), + duration); +} + +void pbx_capi_chat_conference_end_event(const char* roomName) +{ + manager_event(EVENT_FLAG_CALL, "CapichatEnd", "Conference: %s\r\n", roomName); +} + + diff --git a/chan_capi_ami.h b/chan_capi_ami.h index 04ffb66..b58b845 100644 --- a/chan_capi_ami.h +++ b/chan_capi_ami.h @@ -3,6 +3,12 @@ void pbx_capi_ami_register(void); void pbx_capi_ami_unregister(void); +struct capichat_s; +void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * room); +void pbx_capi_chat_leave_event(struct ast_channel* c, + const struct capichat_s *room, + long duration); +void pbx_capi_chat_conference_end_event(const char* roomName); #endif diff --git a/chan_capi_chat.c b/chan_capi_chat.c index 9e08ed4..24e3201 100644 --- a/chan_capi_chat.c +++ b/chan_capi_chat.c @@ -24,7 +24,8 @@ #include "chan_capi_chat.h" #include "chan_capi_utils.h" #include "chan_capi_command.h" -#include "asterisk/manager.h" +#include "chan_capi_ami.h" +#include "chan_capi_devstate.h" #define CHAT_FLAG_MOH 0x0001 #define CHAT_FLAG_SAMEMSG 0x0002 @@ -71,11 +72,6 @@ AST_MUTEX_DEFINE_STATIC(chat_lock); * LOCALS */ static const char* room_member_type_2_name(room_member_type_t room_member_type); -static void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * room); -static void pbx_capi_chat_leave_event(struct ast_channel* c, - const struct capichat_s *room, - long duration); -static void pbx_capi_chat_conference_end_event(const struct capichat_s *room); /* * partial update the capi mixer for the given char room @@ -689,6 +685,9 @@ int pbx_capi_chat(struct ast_channel *c, char *param) } pbx_capi_chat_join_event(c, room); + if (room->active == 1) { + pbx_capi_chat_room_state_event(room->name, 1); + } conferenceConnectTime = time(NULL); /* main loop */ @@ -696,7 +695,8 @@ int pbx_capi_chat(struct ast_channel *c, char *param) pbx_capi_chat_leave_event(c, room, time(NULL)-conferenceConnectTime); if (room->active == 1) { - pbx_capi_chat_conference_end_event (room); + pbx_capi_chat_conference_end_event (room->name); + pbx_capi_chat_room_state_event(room->name, 0); } del_chat_member(room); @@ -1318,51 +1318,3 @@ void pbx_capi_unlock_chat_rooms(void) cc_mutex_unlock(&chat_lock); } -static void pbx_capi_chat_join_event(struct ast_channel* c, const struct capichat_s * room) -{ -#ifdef CC_AST_HAS_VERSION_1_8 - ast_manager_event(c, -#else - manager_event( -#endif - EVENT_FLAG_CALL, "CapichatJoin", - "Channel: %s\r\n" - "Uniqueid: %s\r\n" - "Conference: %s\r\n" - "Conferencenum: %u\r\n" - "CallerIDnum: %s\r\n" - "CallerIDname: %s\r\n", - c->name, c->uniqueid, room->name, - room->number, - pbx_capi_get_cid (c, ""), - pbx_capi_get_callername (c, "")); -} - -static void pbx_capi_chat_leave_event(struct ast_channel* c, - const struct capichat_s *room, - long duration) -{ -#ifdef CC_AST_HAS_VERSION_1_8 - ast_manager_event(c, -#else - manager_event( -#endif - EVENT_FLAG_CALL, "CapichatLeave", - "Channel: %s\r\n" - "Uniqueid: %s\r\n" - "Conference: %s\r\n" - "Conferencenum: %u\r\n" - "CallerIDNum: %s\r\n" - "CallerIDName: %s\r\n" - "Duration: %ld\r\n", - c->name, c->uniqueid, room->name, - room->number, - pbx_capi_get_cid (c, ""), - pbx_capi_get_callername (c, ""), - duration); -} - -static void pbx_capi_chat_conference_end_event(const struct capichat_s *room) -{ - manager_event(EVENT_FLAG_CALL, "CapichatEnd", "Conference: %s\r\n", room->name); -}