def _register_ami_callbacks(self): callback_handler = ami_callback_handler.AMICallbackHandler.get_instance() agent_status_parser = context.get('agent_status_parser') self._queue_member_updater.register_ami_events(callback_handler) callback_handler.register_callback('QueueMemberPaused', agent_status_parser.parse_ami_paused) callback_handler.register_callback('AgentConnect', agent_status_parser.parse_ami_acd_call_start) callback_handler.register_callback('AgentComplete', agent_status_parser.parse_ami_acd_call_end) callback_handler.register_userevent_callback('AgentLogin', agent_status_parser.parse_ami_login) callback_handler.register_userevent_callback('AgentLogoff', agent_status_parser.parse_ami_logout) current_call_parser = context.get('current_call_parser') current_call_parser.register_ami_events() callback_handler.register_callback('NewCallerId', channel_updater.parse_new_caller_id) callback_handler.register_callback('UserEvent', channel_updater.parse_userevent) callback_handler.register_callback('Hold', channel_updater.parse_hold) call_receiver = context.get('call_receiver') callback_handler.register_callback('Newstate', call_receiver.handle_newstate) callback_handler.register_callback('Hangup', call_receiver.handle_hangup) callback_handler.register_callback('Dial', call_receiver.handle_dial) callback_handler.register_callback('Bridge', call_receiver.handle_bridge) callback_handler.register_callback('NewChannel', call_receiver.handle_new_channel) callback_handler.register_callback('Masquerade', call_receiver.handle_masquerade)
def _register_ami_callbacks(self): callback_handler = ami_callback_handler.AMICallbackHandler.get_instance() agent_status_parser = context.get('agent_status_parser') self._bridge_updater.register_ami_events(callback_handler) self._queue_member_updater.register_ami_events(callback_handler) callback_handler.register_callback('QueueMemberPause', agent_status_parser.parse_ami_paused) callback_handler.register_callback('AgentConnect', agent_status_parser.parse_ami_acd_call_start) callback_handler.register_callback('AgentComplete', agent_status_parser.parse_ami_acd_call_end) callback_handler.register_userevent_callback('AgentLogin', agent_status_parser.parse_ami_login) callback_handler.register_userevent_callback('AgentLogoff', agent_status_parser.parse_ami_logout) current_call_parser = context.get('current_call_parser') current_call_parser.register_ami_events() callback_handler.register_callback('NewCallerId', channel_updater.parse_new_caller_id) callback_handler.register_callback('UserEvent', channel_updater.parse_userevent) call_receiver = context.get('call_receiver') callback_handler.register_callback('Newstate', call_receiver.handle_newstate) callback_handler.register_callback('Hangup', call_receiver.handle_hangup) callback_handler.register_callback('DialBegin', call_receiver.handle_dial_begin) callback_handler.register_callback('NewChannel', call_receiver.handle_new_channel) call_pickup_tracker = context.get('call_pickup_tracker') callback_handler.register_callback('Hangup', call_pickup_tracker.handle_hangup)
def handle_agent_unlinked(self, event): channel_name = event['Channel'] member_name = event['MemberName'] uniqueid = event['Uniqueid'] self._set_channel_extra_vars_agent(event, channel_name, member_name) context.get('call_form_dispatch_filter').handle_agent_complete( uniqueid, channel_name)
def parse_join(event): number = event[CONF_ROOM_NUMBER] if meetme_dao.is_a_meetme(number): context.get('meetme_service_manager').join(event[CHANNEL], number, int(event[USERNUM]), event[CIDNAME], event[CIDNUMBER])
def handle_agent_called(self, event): channel_name = event['DestinationChannel'] member_name = event['AgentName'] uniqueid = event['Uniqueid'] self._set_channel_extra_vars_agent(event, channel_name, member_name) context.get('call_form_dispatch_filter').handle_agent_called( uniqueid, channel_name)
def parse_meetmelist(event): number = event['Conference'] if meetme_dao.is_a_meetme(number): context.get('meetme_service_manager').refresh(event[CHANNEL], number, int(event['UserNumber']), event['CallerIDName'], event['CallerIDNum'], event['Muted'] == YES)
def handle_agent_unlinked(self, event): member_name = event['MemberName'] uniqueid = event['Uniqueid'] self._set_channel_extra_vars_agent(event, member_name) context.get('call_form_dispatch_filter').handle_agent_complete( uniqueid) context.get('call_form_variable_aggregator').on_agent_complete( uniqueid)
def parse_meetmemute(event): number = event['Meetme'] if meetme_dao.is_a_meetme(number): muting = event['Status'] == 'on' if muting: context.get('meetme_service_manager').mute(number, int(event['Usernum'])) else: context.get('meetme_service_manager').unmute(number, int(event['Usernum']))
def _init_agent_availability(self): for agent_status in self._agent_client.get_agent_statuses(): if agent_status.logged: agent_status_cti = AgentStatus.available else: agent_status_cti = AgentStatus.logged_out dao.agent.set_agent_availability(agent_status.id, agent_status_cti) context.get('agent_status_adapter').subscribe_all_logged_agents()
def parse_join(event): number = event[CONF_ROOM_NUMBER] if meetme_dao.is_a_meetme(number): context.get('meetme_service_manager').join( event[CHANNEL], number, int(event[USERNUM]), event[CIDNAME], event[CIDNUMBER])
def parse_meetmemute(event): with session_scope(): number = event['Meetme'] is_a_meetme = meetme_dao.is_a_meetme(number) if is_a_meetme: muting = event['Status'] == 'on' if muting: context.get('meetme_service_manager').mute(number, int(event[USER])) else: context.get('meetme_service_manager').unmute(number, int(event[USER]))
def parse_meetmemute(event): number = event['Meetme'] if meetme_dao.is_a_meetme(number): muting = event['Status'] == 'on' if muting: context.get('meetme_service_manager').mute(number, int(event['Usernum'])) else: context.get('meetme_service_manager').unmute( number, int(event['Usernum']))
def parse_meetmelist(event): number = event['Conference'] if meetme_dao.is_a_meetme(number): context.get('meetme_service_manager').refresh( event[CHANNEL], number, int(event['UserNumber']), event['CallerIDName'], event['CallerIDNum'], event['Muted'] == YES)
def _object_request_cmd(self, sre_obj): object_name = sre_obj.group(1) state = sre_obj.group(2) id = sre_obj.group(3) if sre_obj.group(3) else None if object_name not in _OBJECTS: logger.warning('WEBI did an unknow object %s', object_name) else: msg_data = {'object_name': object_name, 'state': state, 'id': id} self._ctiserver.update_config_list.append(msg_data) if object_name == 'meetme': context.get('meetme_service_manager').initialize()
def parse_join(event): with session_scope(): number = event[CONF_ROOM_NUMBER] is_a_meetme = meetme_dao.is_a_meetme(number) if is_a_meetme: context.get('meetme_service_manager').join( event[CHANNEL], number, int(event[USER]), event[CIDNAME], event[CIDNUMBER])
def __init__(self, connection, on_complete_cb): self._connection = connection self._session_id = self._new_session_id() self._auth_backend = config['auth']['backend'] self._auth_config = config['auth'] self._async_runner = context.get('async_runner') self._task_queue = context.get('task_queue') self._task_scheduler = context.get('task_scheduler') self._auth_token = None self._authenticated = False self._on_complete_cb = on_complete_cb self._login_task = None self._login_timeout = int(config['client']['login_timeout'])
def _object_request_cmd(self, sre_obj): object_name = sre_obj.group(1) state = sre_obj.group(2) id = sre_obj.group(3) if sre_obj.group(3) else None if object_name not in _OBJECTS: logger.warning('WEBI did an unknow object %s', object_name) else: msg_data = { 'object_name': object_name, 'state': state, 'id': id } self._ctiserver.update_config_list.append(msg_data) if object_name == 'meetme': context.get('meetme_service_manager').initialize()
def _get_set_fn(self, uniqueid): aggregator = context.get('call_form_variable_aggregator') def _set(var_name, var_value): aggregator.set(uniqueid, CallFormVariable('xivo', var_name, var_value)) return _set
def __init__(self, connection, thiscommand): self._connection = connection self._ctiserver = self._connection._ctiserver self._commanddict = thiscommand self._queue_statistics_manager = cti_context.get( 'queue_statistics_manager') self._queue_statistics_encoder = QueueStatisticsEncoder()
def _get_answer_cb(self, user_id): device_manager = context.get('device_manager') try: device_id = user_dao.get_device_id(user_id) return device_manager.get_answer_fn(device_id) except LookupError: return self.answer_cb
def main(): cti_config.init_cli_config(sys.argv[1:]) cti_config.init_config_file() cti_config.init_auth_config() xivo_dao.init_db_from_config(config) cti_config.update_db_config() user = config.get('user') if user: change_user(user) setup_logging(config['logfile'], config['foreground'], config['debug']) silence_loggers( ['amqp', 'urllib3', 'Flask-Cors', 'kombu', 'stevedore.extension'], logging.WARNING) xivo_uuid = get_xivo_uuid(logger) register_class.setup(xivo_uuid) ctid = context.get('cti_server') ctid.setup() with ServiceCatalogRegistration('xivo-ctid', xivo_uuid, config['consul'], config['service_discovery'], config['bus'], partial(self_check, config)): ctid.run()
def parse_queue_entry(event): try: manager = context.get('queue_entry_manager') manager.insert(event[QUEUE], int(event[POSITION]), event[NAME], event[NUMBER], event[UNIQUE_ID], int(event[WAIT])) except (KeyError, ValueError): logger.warning('Failed to parse QueueEntry event %s', event)
def parse_join(event): try: manager = context.get('queue_entry_manager') manager.join(event[QUEUE], int(event[POSITION]), int(event[COUNT]), event[NAME], event[NUMBER], event[UNIQUE_ID]) except (KeyError, ValueError): logger.warning('Failed to parse Join event %s', event)
def parse_leave(event): try: manager = context.get('queue_entry_manager') manager.leave(event[QUEUE], int(event[POSITION]), int(event[COUNT]), event[UNIQUE_ID]) except (KeyError, ValueError): logger.warning('Failed to parse Leave event %s', event)
def sheetsend(self, where, uid): sheets = config.get('sheets') if not sheets: return self.sheetevents = sheets.get('events') self.sheetdisplays = sheets.get('displays') self.sheetoptions = sheets.get('options') self.sheetconditions = sheets.get('conditions') if where not in self.sheetevents: return _set = self._get_set_fn(uid) for se in self.sheetevents[where]: display_id = se.get('display') condition_id = se.get('condition') option_id = se.get('option') if not self.sheetdisplays.get(display_id): continue _set('time', time.strftime('%H:%M:%S', time.localtime())) _set('date', time.strftime('%Y-%m-%d', time.localtime())) _set('where', where) _set('uniqueid', uid) _set('ipbxid', self.ipbxid) channel = context.get('call_form_variable_aggregator').get( uid)['xivo']['channel'] sheet = cti_sheets.Sheet(where, self.ipbxid, uid) sheet.setoptions(self.sheetoptions.get(option_id)) sheet.setdisplays(self.sheetdisplays.get(display_id)) sheet.setconditions(self.sheetconditions.get(condition_id)) # 1. whom / userinfos : according to outdest or destlist to update in Channel structure # + according to conditions # final 'whom' description should be clearly written in order to send across 'any path' tomatch = sheet.checkdest() tosendlist = self._ctiserver.get_connected(tomatch) # 2. make an extra call to a db if requested ? could be done elsewhere (before) also ... # 3. build sheet items (according to values) sheet.setfields() # 4. sheet construct (according to serialization) sheet.serialize() # 5. sheet manager ? # 6. json message / zip or not / b64 / ... # print sheet.internaldata # 7. send the payload self._ctiserver.sendsheettolist( tosendlist, { 'class': 'sheet', 'channel': channel, 'serial': sheet.serial, 'compressed': sheet.compressed, 'payload': sheet.payload })
def register_callbacks(): ami_handler = ami_callback_handler.AMICallbackHandler.get_instance() ami_handler.register_callback('MeetmeJoin', parse_join) ami_handler.register_callback('MeetmeLeave', parse_leave) ami_handler.register_callback('MeetmeMute', parse_meetmemute) ami_handler.register_callback('MeetmeList', parse_meetmelist) manager = context.get('meetme_service_manager') InviteConfroom.register_callback_params(manager.invite, ['user_id', 'invitee'])
def variable_values(self): variables = context.get('call_form_variable_aggregator').get(self.internaldata['uid']) result = {} for variable_type, variables in variables.iteritems(): for variable_name, value in variables.iteritems(): full_variable_name = '%s-%s' % (variable_type, variable_name) result[full_variable_name] = value return result
def variable_values(self): variables = context.get('call_form_variable_aggregator').get( self.internaldata['uid']) result = {} for variable_type, variables in variables.iteritems(): for variable_name, value in variables.iteritems(): full_variable_name = '%s-%s' % (variable_type, variable_name) result[full_variable_name] = value return result
def parse_queue_summary(queuesummary_event): queue_name = queuesummary_event['Queue'] queue_id = dao.queue.get_id_as_str_from_name(queue_name) if queue_id is None: return counters = QueueCounters(available=queuesummary_event['Available'], EWT=queuesummary_event['HoldTime'], Talking=queuesummary_event['Talking']) queue_statistics_producer = context.get('queue_statistics_producer') queue_statistics_producer.on_queue_summary(queue_id, counters)
def sheetsend(self, where, uid): sheets = config.get('sheets') if not sheets: return self.sheetevents = sheets.get('events') self.sheetdisplays = sheets.get('displays') self.sheetoptions = sheets.get('options') self.sheetconditions = sheets.get('conditions') if where not in self.sheetevents: return _set = self._get_set_fn(uid) for se in self.sheetevents[where]: display_id = se.get('display') condition_id = se.get('condition') option_id = se.get('option') if not self.sheetdisplays.get(display_id): continue _set('time', time.strftime('%H:%M:%S', time.localtime())) _set('date', time.strftime('%Y-%m-%d', time.localtime())) _set('where', where) _set('uniqueid', uid) _set('ipbxid', self.ipbxid) channel = context.get('call_form_variable_aggregator').get(uid)['xivo']['channel'] sheet = cti_sheets.Sheet(where, self.ipbxid, uid) sheet.setoptions(self.sheetoptions.get(option_id)) sheet.setdisplays(self.sheetdisplays.get(display_id)) sheet.setconditions(self.sheetconditions.get(condition_id)) # 1. whom / userinfos : according to outdest or destlist to update in Channel structure # + according to conditions # final 'whom' description should be clearly written in order to send across 'any path' tomatch = sheet.checkdest() tosendlist = self._ctiserver.get_connected(tomatch) # 2. make an extra call to a db if requested ? could be done elsewhere (before) also ... # 3. build sheet items (according to values) sheet.setfields() # 4. sheet construct (according to serialization) sheet.serialize() # 5. sheet manager ? # 6. json message / zip or not / b64 / ... # print sheet.internaldata # 7. send the payload self._ctiserver.sendsheettolist(tosendlist, {'class': 'sheet', 'channel': channel, 'serial': sheet.serial, 'compressed': sheet.compressed, 'payload': sheet.payload})
def main(): cti_config.init_cli_config(sys.argv[1:]) cti_config.init_config_file() cti_config.update_db_config() register_class.setup() ctid = context.get('cti_server') ctid.setup() ctid.run()
def __init__(self, cti_server, queue_member_cti_adapter): self._ctiserver = cti_server self.queue_member_cti_adapter = queue_member_cti_adapter self.ipbxid = 'xivo' self.xod_config = {} self.xod_status = {} self.channels = {} self.faxes = {} self.ctistack = [] self._sent_sheets = defaultdict(list) self.funckey_manager = context.get('funckey_manager')
def handle_ami_function(self, evfunction, event): """ Handles the AMI events related to a given function (i.e. containing the Event field). It roughly only dispatches them to the relevant commandset's methods. """ ami_18 = context.get('ami_18') functions = [] if 'Event' in event: functions.extend(ami_callback_handler.AMICallbackHandler.get_instance().get_callbacks(event)) if evfunction in ami_def.evfunction_to_method_name: methodname = ami_def.evfunction_to_method_name.get(evfunction) if hasattr(ami_18, methodname): functions.append(getattr(ami_18, methodname)) self._run_functions_with_event(functions, event)
def disconnected(self, cause): logger.info('disconnected %s', cause) self.login_task.cancel() if self.transferconnection and self.transferconnection.get('direction') == 'c2s': logger.info('%s got the file ...', self.transferconnection.get('faxobj').fileid) else: try: user_service_manager = context.get('user_service_manager') user_id = self.user_id() if (cause == self.DisconnectCause.by_client or cause == self.DisconnectCause.by_server_stop or cause == self.DisconnectCause.by_server_reload or cause == self.DisconnectCause.broken_pipe): user_service_manager.disconnect_no_action(user_id) else: raise TypeError('invalid DisconnectCause %s' % cause) except NotLoggedException: logger.warning('Called disconnected with no user_id')
def instanciate_dao(innerdata_obj, queue_member_manager): global agent agent = AgentDAO(innerdata_obj, queue_member_manager) global channel channel = ChannelDAO(innerdata_obj, context.get('call_form_variable_aggregator')) global queue queue = QueueDAO(innerdata_obj) global meetme meetme = MeetmeDAO(innerdata_obj) global phone phone = PhoneDAO(innerdata_obj) global user user = UserDAO(innerdata_obj) global voicemail voicemail = VoicemailDAO(innerdata_obj) global innerdata innerdata = InnerdataDAO(innerdata_obj)
def _on_login_capas(self, profile_id, state, cti_connection): if cti_connection != self._connection: return logger.debug('_on_login_capas: %r %s', profile_id, state) LoginCapas.deregister_callback(self._on_login_capas) if profile_id != self._cti_profile_id: logger.info( 'LOGINFAIL - login_capas - wrong cti_profile_id: %r %r', profile_id, self._cti_profile_id) return self._fatal('login_capas', 'wrong cti_profile_id') profile_config = config['profiles'].get(profile_id) if not profile_config: logger.info('LOGINFAIL - login_capas - unknown cti_profile_id') return self._fatal('login_capas', 'unknown cti_profile_id') get_capa = lambda key: config[key].get(profile_config[key], {}) capas = { 'services': get_capa('services'), 'preferences': get_capa('preferences'), 'userstatus': get_capa('userstatus'), 'phonestatus': get_capa('phonestatus') } msg = { 'class': 'login_capas', 'userid': self._user_id, 'ipbxid': self._ipbxid, 'capas': capas, 'capaxlets': profile_config['xlets'], 'appliname': profile_config['name'] } user_service_manager = context.get('user_service_manager') user_service_manager.connect(self._user_id, self._user_uuid, self._auth_token, state) if self._login_task: self._login_task.cancel() self._send_msg(msg) login_info = {'user_uuid': self._user_uuid, 'user_id': self._user_id} logger.info('LOGIN_SUCCESSFUL for %s', login_info)
def _on_exit(self): time_uptime = int(time.time() - time.mktime(self.time_start)) logger.info('STOPPING %s (pid %d) / uptime %d s (since %s)', self.servername, os.getpid(), time_uptime, time.asctime(self.time_start)) logger.debug('Stopping the bus listener') if self._bus_listener_thread: context.get('bus_listener').should_stop = True self._bus_listener_thread.join() logger.debug('Closing all sockets') self._socket_close_all() logger.debug('Stopping all remaining threads') for thread in threading.enumerate(): if thread.getName() not in ('MainThread', 'HTTPServerThread', 'ServiceDiscoveryThread'): thread._Thread__stop() daemonize.unlock_pidfile(config['pidfile'])
def setup(self): cti_config.update_db_config() self._set_logger() self._daemonize() QueueLogger.init() self._set_signal_handlers() self.interface_ami = context.get('interface_ami') self._user_service_manager = context.get('user_service_manager') self._funckey_manager = context.get('funckey_manager') self._agent_service_manager = context.get('agent_service_manager') self._call_form_result_handler = context.get('call_form_result_handler') self._presence_service_executor = context.get('presence_service_executor') self._statistics_notifier = context.get('statistics_notifier') self._queue_statistics_producer = context.get('queue_statistics_producer') self._queue_member_notifier = context.get('queue_member_notifier') self._queue_member_updater = context.get('queue_member_updater') self._queue_member_manager = context.get('queue_member_manager') self._queue_member_cti_adapter = context.get('queue_member_cti_adapter') self._queue_member_cti_subscriber = context.get('queue_member_cti_subscriber') self._queue_member_indexer = context.get('queue_member_indexer') self._user_service_manager.presence_service_executor = self._presence_service_executor self._queue_entry_manager = context.get('queue_entry_manager') self._queue_statistics_manager = context.get('queue_statistics_manager') self._queue_entry_notifier = context.get('queue_entry_notifier') self._task_queue = context.get('task_queue') self._task_scheduler = context.get('task_scheduler') self._agent_availability_updater = context.get('agent_availability_updater') self._agent_service_cti_parser = context.get('agent_service_cti_parser') self._statistics_producer_initializer = context.get('statistics_producer_initializer') self._agent_status_manager = context.get('agent_status_manager') self._agent_client = context.get('agent_client') self._agent_client.connect() context.get('user_service_notifier').send_cti_event = self.send_cti_event context.get('user_service_notifier').ipbx_id = self.myipbxid queue_entry_manager.register_events() queue_statistics_manager.register_events() queue_statistics_producer.register_events() meetme_service_manager_module.register_callbacks() meetme_service_manager = context.get('meetme_service_manager') meetme_service_manager.initialize() self._register_cti_callbacks() self._register_ami_callbacks() self._register_message_hooks()
def parse_queue_status_complete(event): manager = context.get('queue_entry_manager') manager.publish()
def handle_agent_unlinked(self, event): channel_name = event['Channel'] member_name = event['MemberName'] uniqueid = event['Uniqueid'] self._set_channel_extra_vars_agent(event, channel_name, member_name) context.get('call_form_dispatch_filter').handle_agent_complete(uniqueid, channel_name)
def handle_agent_called(self, event): channel_name = event['DestinationChannel'] member_name = event['AgentName'] uniqueid = event['Uniqueid'] self._set_channel_extra_vars_agent(event, channel_name, member_name) context.get('call_form_dispatch_filter').handle_agent_called(uniqueid, channel_name)
def parse_queue_params(event): try: manager = context.get('queue_entry_manager') manager.clear_data(event[QUEUE]) except KeyError: logger.warning('Failed to parse QueueParams event %s', event)
def __init__(self, name, params): threading.Thread.__init__(self) self.setName(name) self.params = params self._task_queue = context.get('task_queue')
def parse_queue_member_status(event): try: manager = context.get('queue_statistics_manager') manager.get_queue_summary(event['Queue']) except (KeyError, ValueError): logger.warning('Failed to parse QueueSummary event %s', event)
def parse_leave(event): number = event[CONF_ROOM_NUMBER] if meetme_dao.is_a_meetme(number): context.get('meetme_service_manager').leave(number, int(event[USERNUM]))
def parse_hold(event): updater = context.get('channel_updater') updater.set_hold(event['Channel'], event['Status'] == 'On')
def main_loop(self): self.askedtoquit = False self.time_start = time.localtime() logger.info('STARTING %s (pid %d))', self.servername, os.getpid()) self._task_queue.clear() self._task_scheduler.clear() logger.info('Connecting to bus') bus_producer = context.get('bus_producer') if not bus_producer.connected: bus_producer.connect() bus_producer.declare_exchange(name=config['bus']['exchange_name'], exchange_type=config['bus']['exchange_type'], durable=config['bus']['exchange_durable']) logger.info('Retrieving data') self.safe = context.get('innerdata') self.safe.user_service_manager = self._user_service_manager self.safe.queue_member_cti_adapter = self._queue_member_cti_adapter dao.instanciate_dao(self.safe, self._queue_member_manager) self.safe.init_xod_config() self.safe.init_xod_status() self.safe.register_cti_handlers() self.safe.register_ami_handlers() self.safe.update_directories() self._queue_member_updater.on_initialization() self._queue_member_cti_subscriber.send_cti_event = self.send_cti_event self._queue_member_cti_subscriber.subscribe_to_queue_member(self._queue_member_notifier) self._queue_member_indexer.subscribe_to_queue_member(self._queue_member_notifier) self._queue_statistics_manager.subscribe_to_queue_member(self._queue_member_notifier) self._queue_statistics_producer.subscribe_to_queue_member(self._queue_member_notifier) self._init_statistics_producers() self._init_agent_availability() self._queue_member_indexer.initialize(self._queue_member_manager) logger.info('Local AMI socket connection') self.interface_ami.init_connection() self.ami_sock = self.interface_ami.connect() if not self.ami_sock: self._on_ami_down() logger.info('Listening sockets') xivoconf_general = config['main'] socktimeout = float(xivoconf_general.get('sockettimeout', '2')) socket.setdefaulttimeout(socktimeout) self.fdlist_established = {} self.fdlist_listen_cti = {} incoming_tcp = xivoconf_general.get('incoming_tcp', {}) for kind, bind_and_port in incoming_tcp.iteritems(): allow_kind = True if len(bind_and_port) > 2: allow_kind = bind_and_port[2] if not allow_kind: logger.warning('%s kind listening socket has been explicitly disabled', kind) continue bind, port = bind_and_port[:2] self._init_tcp_socket(kind, bind, port) logger.info('CTI Fully Booted in %.6f seconds', (time.time() - self.start_time)) while not self.askedtoquit: self.select_step()
def _handle_extension_success(self, event, actionid, properties, mode): ami_18 = context.get('ami_18') msg = event.get('Message') if msg and msg == 'Extension Status': ami_18.amiresponse_extensionstatus(event)
def _register_cti_callbacks(self): people_adapter = context.get('people_cti_adapter') PeopleSearch.register_callback_params(people_adapter.search, ('user_id', 'pattern')) PeopleHeaders.register_callback_params(people_adapter.get_headers, ['user_id']) CallFormResult.register_callback_params( self._call_form_result_handler.parse, ['user_id', 'variables'], ) Dial.register_callback_params(self._user_service_manager.call_destination, ['cti_connection', 'user_id', 'destination']) EnableDND.register_callback_params(self._user_service_manager.enable_dnd, ['user_id']) DisableDND.register_callback_params(self._user_service_manager.disable_dnd, ['user_id']) EnableRecording.register_callback_params(self._user_service_manager.enable_recording, ['target']) DisableRecording.register_callback_params(self._user_service_manager.disable_recording, ['target']) EnableFilter.register_callback_params(self._user_service_manager.enable_filter, ['user_id']) DisableFilter.register_callback_params(self._user_service_manager.disable_filter, ['user_id']) EnableUnconditionalForward.register_callback_params(self._user_service_manager.enable_unconditional_fwd, ['user_id', 'destination']) DisableUnconditionalForward.register_callback_params(self._user_service_manager.disable_unconditional_fwd, ['user_id', 'destination']) EnableNoAnswerForward.register_callback_params(self._user_service_manager.enable_rna_fwd, ['user_id', 'destination']) DisableNoAnswerForward.register_callback_params(self._user_service_manager.disable_rna_fwd, ['user_id', 'destination']) EnableBusyForward.register_callback_params(self._user_service_manager.enable_busy_fwd, ['user_id', 'destination']) DisableBusyForward.register_callback_params(self._user_service_manager.disable_busy_fwd, ['user_id', 'destination']) SubscribeToQueuesStats.register_callback_params(self._statistics_notifier.subscribe, ['cti_connection']) SubscribeToQueuesStats.register_callback_params(self._queue_statistics_producer.send_all_stats, ['cti_connection']) SubscribeToQueuesStats.register_callback_params(self._queue_statistics_manager.get_all_queue_summary) SubscribeToQueuesStats.register_callback_params(self._queue_entry_manager.publish_all_realtime_stats, ['cti_connection']) SubscribeQueueEntryUpdate.register_callback_params( self._queue_entry_notifier.subscribe, ['cti_connection', 'queue_id']) AgentLogin.register_callback_params( self._agent_service_manager.on_cti_agent_login, ['user_id', 'agent_id', 'agent_phone_number'] ) AgentLogout.register_callback_params( self._agent_service_manager.on_cti_agent_logout, ['user_id', 'agent_id'] ) Listen.register_callback_params( self._agent_service_manager.on_cti_listen, ['user_id', 'destination'] ) Logout.register_callback_params(self._user_service_manager.disconnect, ['user_id']) QueueAdd.register_callback_params( self._agent_service_cti_parser.queue_add, ['member', 'queue'] ) QueueRemove.register_callback_params( self._agent_service_cti_parser.queue_remove, ['member', 'queue'] ) QueuePause.register_callback_params( self._agent_service_cti_parser.queue_pause, ['member', 'queue'] ) QueueUnPause.register_callback_params( self._agent_service_cti_parser.queue_unpause, ['member', 'queue'] ) SubscribeMeetmeUpdate.register_callback_params( context.get('meetme_service_notifier').subscribe, ['cti_connection'] ) SubscribeCurrentCalls.register_callback_params( context.get('current_call_notifier').subscribe, ['cti_connection'] ) Hangup.register_callback_params( context.get('current_call_manager').hangup, ['user_id'] ) AttendedTransfer.register_callback_params( context.get('current_call_manager').attended_transfer, ['user_id', 'number'] ) DirectTransfer.register_callback_params( context.get('current_call_manager').direct_transfer, ['user_id', 'number'] ) CancelTransfer.register_callback_params( context.get('current_call_manager').cancel_transfer, ['user_id'] ) CompleteTransfer.register_callback_params( context.get('current_call_manager').complete_transfer, ['user_id'] ) HoldSwitchboard.register_callback_params( context.get('current_call_manager').switchboard_hold, ['user_id', 'queue_name'] ) ResumeSwitchboard.register_callback_params( context.get('current_call_manager').switchboard_retrieve_waiting_call, ['user_id', 'unique_id', 'cti_connection'], ) Answer.register_callback_params( context.get('current_call_manager').switchboard_retrieve_waiting_call, ['user_id', 'unique_id', 'cti_connection'], ) History.register_callback_params( call_history_cti_interface.get_history, ['user_id', 'mode', 'size'] )