Skip to content
Snippets Groups Projects
dial.c 31.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • int ast_dial_option_disable(struct ast_dial *dial, int num, enum ast_dial_option option)
    {
    	struct ast_dial_channel *channel = NULL;
    
    	/* Ensure we have required arguments */
    	if (!dial || AST_LIST_EMPTY(&dial->channels))
    		return -1;
    
    
    	if (!(channel = find_dial_channel(dial, num)))
    
    		return -1;
    
    	/* If the option is not enabled, return failure */
    	if (!channel->options[option])
    		return -1;
    
    	/* Execute callback of option to disable it if it exists */
    	if (option_types[option].disable)
    		option_types[option].disable(channel->options[option]);
    
    	/* Finally disable the option on the structure */
    	channel->options[option] = NULL;
    
    	return 0;
    }
    
    void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
    
    {
    	dial->state_callback = callback;
    }
    
    
    /*! \brief Set the maximum time (globally) allowed for trying to ring phones
     * \param dial The dial structure to apply the time limit to
     * \param timeout Maximum time allowed
     * \return nothing
     */
    void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
    {
    	dial->timeout = timeout;
    
    	if (dial->timeout > 0 && dial->actual_timeout > dial->timeout)
    		dial->actual_timeout = dial->timeout;
    
    	return;
    }
    
    /*! \brief Set the maximum time (per channel) allowed for trying to ring the phone
     * \param dial The dial structure the channel belongs to
     * \param num Channel number to set timeout on
     * \param timeout Maximum time allowed
     * \return nothing
     */
    void ast_dial_set_timeout(struct ast_dial *dial, int num, int timeout)
    {
    	struct ast_dial_channel *channel = NULL;
    
    	if (!(channel = find_dial_channel(dial, num)))
    		return;
    
    	channel->timeout = timeout;
    
    	if (channel->timeout > 0 && dial->actual_timeout > channel->timeout)
    		dial->actual_timeout = channel->timeout;
    
    	return;
    }