Add device state for chat conference rooms

This commit is contained in:
MelwareDE 2010-11-05 13:13:12 +00:00
parent d55a1dae94
commit e4de99914f
4 changed files with 115 additions and 1 deletions

View File

@ -131,7 +131,8 @@ SHAREDOS=chan_capi.so
OBJECTS=chan_capi.o chan_capi_utils.o chan_capi_rtp.o chan_capi_command.o xlaw.o dlist.o \
chan_capi_qsig_core.o chan_capi_qsig_ecma.o chan_capi_qsig_asn197ade.o \
chan_capi_qsig_asn197no.o chan_capi_supplementary.o chan_capi_chat.o \
chan_capi_mwi.o chan_capi_cli.o chan_capi_ami.o chan_capi_management_common.o
chan_capi_mwi.o chan_capi_cli.o chan_capi_ami.o chan_capi_management_common.o \
chan_capi_devstate.o
ifeq (${USE_OWN_LIBCAPI},yes)
OBJECTS += libcapi20/convert.o libcapi20/capi20.o libcapi20/capifunc.o

View File

@ -57,6 +57,7 @@ struct _diva_streaming_vector* vind;
#include "chan_capi_mwi.h"
#include "chan_capi_cli.h"
#include "chan_capi_ami.h"
#include "chan_capi_devstate.h"
/* #define CC_VERSION "x.y.z" */
#define CC_VERSION "$Revision$"
@ -8533,6 +8534,7 @@ int unload_module(void)
ast_unregister_application(commandapp);
pbx_capi_unregister_device_state_providers();
pbx_capi_ami_unregister();
pbx_capi_cli_unregister();
@ -8649,6 +8651,7 @@ int load_module(void)
pbx_capi_cli_register();
pbx_capi_ami_register();
pbx_capi_register_device_state_providers();
ast_register_application(commandapp, pbx_capicommand_exec, commandsynopsis, commandtdesc);

101
chan_capi_devstate.c Normal file
View File

@ -0,0 +1,101 @@
/*
*
Copyright (c) Dialogic (R) 2009 - 2010
*
This source file is supplied for the use with
Eicon Networks range of DIVA Server Adapters.
*
Dialogic (R) File Revision : 1.9
*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
*
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY OF ANY KIND WHATSOEVER INCLUDING ANY
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_qsig.h"
#include "chan_capi_utils.h"
#include "chan_capi_chat.h"
#include "chan_capi_devstate.h"
/*
LOCALS
*/
static
#ifdef CC_AST_HAS_VERSION_1_6
enum ast_device_state
#else
int
#endif
pbx_capi_chat_room_state(const char *data);
static int capiChatProviderRegistered;
void pbx_capi_register_device_state_providers(void)
{
capiChatProviderRegistered = (ast_devstate_prov_add("Capichat", pbx_capi_chat_room_state) == 0);
}
void pbx_capi_unregister_device_state_providers(void)
{
if (capiChatProviderRegistered != 0) {
ast_devstate_prov_del("Capichat");
}
}
/*!
* \brief Read conference room state
*/
static
#ifdef CC_AST_HAS_VERSION_1_6
enum ast_device_state
#else
int
#endif
pbx_capi_chat_room_state(const char *data)
{
const struct capichat_s *room;
enum ast_device_state ret = AST_DEVICE_NOT_INUSE;
if (data == 0)
return AST_DEVICE_INVALID;
pbx_capi_lock_chat_rooms();
for (room = pbx_capi_chat_get_room_c(NULL);
room != 0;
room = pbx_capi_chat_get_room_c(room)) {
if (strcmp(data, pbx_capi_chat_get_room_name(room)) == 0) {
ret = AST_DEVICE_INUSE;
break;
}
}
pbx_capi_unlock_chat_rooms();
return ret;
}
/*!
* \brief Conference room state change
*/
void pbx_capi_chat_room_state_event(const char* roomName, int inUse) {
if (capiChatProviderRegistered != 0) {
#ifdef CC_AST_HAS_VERSION_1_6
ast_devstate_changed((inUse != 0) ? AST_DEVICE_INUSE : AST_DEVICE_NOT_INUSE, "capichat:%s", roomName);
#else
ast_device_state_changed("capichat:%s", roomName);
#endif
}
}

9
chan_capi_devstate.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef __CC_DEVICE_STATE_PROVIDER_INTERFACE_H__
#define __CC_DEVICE_STATE_PROVIDER_INTERFACE_H__
void pbx_capi_register_device_state_providers(void);
void pbx_capi_unregister_device_state_providers(void);
void pbx_capi_chat_room_state_event(const char* roomName, int inUse);
#endif