-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mod_asterisk_queues: Add Asterisk queue agent module.
This adds several modules related to allowing Asterisk queue agents to interact with queues using a BBS module: * mod_asterisk_ami: Asterisk Manager Interface (AMI) integration using CAMI library callbacks. Other modules can then receive AMI events, such as mod_asterisk_queues. * mod_asterisk_queues: Generic queue management system. Specific queue functionality needs to be implemented in custom user modules that define queue handlers. This module handles all the general queue management functionality so that handlers only need to define queue-specific business logic. * mod_ncurses: Provides graphical ncurses interface that works abstractly within the BBS. Since ncurses is generally not safe to use in multithreaded programs, this interface forks and run ncurses on a node in a separate process and returns the chosen value to the calling BBS function. This also abstracts the complexity of ncurses away to make simple menus easy to create. This commit does include specific queue handlers. As part of this change: * Variables can now be defined per user in variables.conf and can be used by modules to restrict or customize functionality (such as by mod_asterisk_queues)
- Loading branch information
1 parent
9addb13
commit 18e401f
Showing
25 changed files
with
2,065 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
; mod_asterisk_ami.conf | ||
|
||
;[ami] ; Connection information for Asterisk Manager Interface | ||
;hostname=127.0.0.1 | ||
;username=amiuser | ||
;password=amipass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
; mod_asterisk_queues.conf | ||
|
||
[general] | ||
title = OPERATOR SERVICE POSITION SYSTEM | ||
callmenutitle = OPERATOR SERVICE POSITION SYSTEM (CHOOSE CALL) | ||
queueidvar = queueuniq ; Name of Asterisk channel variable on queue calls that will contain a unique, numeric ID for the call | ||
|
||
; Agents must have the variable ASTERISK_AGENT_ID defined. Only these users may use the module. | ||
; You can define these variables statically in variables.conf. | ||
|
||
;[sales] | ||
;title = SALES ; Queue name that will display to the agent. | ||
;handler = sales ; The name of a queue call handler that will handle this call. | ||
; Currently, these handlers are implemented in custom C handlers that must be written for each module. | ||
; These are generally proprietary business logic - so you will likely have to implement your own. | ||
|
||
;[engineering] | ||
;title = ENGINEERING | ||
;handler = engineering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* LBBS -- The Lightweight Bulletin Board System | ||
* | ||
* Copyright (C) 2023, Naveen Albert | ||
* | ||
* Naveen Albert <[email protected]> | ||
* | ||
* This program is free software, distributed under the terms of | ||
* the GNU General Public License Version 2. See the LICENSE file | ||
* at the top of the source tree. | ||
*/ | ||
|
||
/*! \file | ||
* | ||
* \brief Asterisk Manager Interface | ||
* | ||
* \author Naveen Albert <[email protected]> | ||
*/ | ||
|
||
int __bbs_ami_callback_register(int (*callback)(struct ami_event *event, const char *eventname), void *mod); | ||
|
||
/*! | ||
* \brief Register an AMI callback | ||
* \param callback Callback function to execute on AMI events | ||
* \retval 0 on success, -1 on failure | ||
*/ | ||
#define bbs_ami_callback_register(callback) __bbs_ami_callback_register(callback, BBS_MODULE_SELF) | ||
|
||
/*! | ||
* \brief Unregister an AMI callback previously registered using bbs_ami_callback_register | ||
* \param callback | ||
* \retval 0 on success, -1 on failure | ||
*/ | ||
int bbs_ami_callback_unregister(int (*callback)(struct ami_event *event, const char *eventname)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* LBBS -- The Lightweight Bulletin Board System | ||
* | ||
* Copyright (C) 2023, Naveen Albert | ||
* | ||
* Naveen Albert <[email protected]> | ||
* | ||
* This program is free software, distributed under the terms of | ||
* the GNU General Public License Version 2. See the LICENSE file | ||
* at the top of the source tree. | ||
*/ | ||
|
||
/*! \file | ||
* | ||
* \brief Asterisk Queue Position System | ||
* | ||
* \author Naveen Albert <[email protected]> | ||
*/ | ||
|
||
struct queue_call_handle { | ||
/* Agent info */ | ||
struct bbs_node *node; /*!< Node of agent handling call */ | ||
int agentid; /*!< ID of agent handling call */ | ||
/* Call info */ | ||
int id; /*!< Queue call ID */ | ||
const char *channel; /*!< Channel name */ | ||
int ani2; /*!< ANI II */ | ||
unsigned long ani; /*!< ANI */ | ||
unsigned long dnis; /*!< DNIS */ | ||
const char *cnam; /*!< CNAM */ | ||
}; | ||
|
||
int __bbs_queue_call_handler_register(const char *name, int (*handler)(struct queue_call_handle *qch), void *mod); | ||
|
||
/*! | ||
* \brief Register a queue call handler | ||
* \param name Name of handler to register | ||
* \retval 0 on success, -1 on failure | ||
*/ | ||
#define bbs_queue_call_handler_register(name, handler) __bbs_queue_call_handler_register(name, handler, BBS_MODULE_SELF) | ||
|
||
/*! | ||
* \brief Unregister a queue call handler | ||
* \param name Name of registered handler | ||
* \retval 0 on success, -1 on failure | ||
*/ | ||
int bbs_queue_call_handler_unregister(const char *name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* LBBS -- The Lightweight Bulletin Board System | ||
* | ||
* Copyright (C) 2023, Naveen Albert | ||
* | ||
* Naveen Albert <[email protected]> | ||
* | ||
* This program is free software, distributed under the terms of | ||
* the GNU General Public License Version 2. See the LICENSE file | ||
* at the top of the source tree. | ||
*/ | ||
|
||
/*! \file | ||
* | ||
* \brief Graphical text menus | ||
* | ||
* \author Naveen Albert <[email protected]> | ||
*/ | ||
|
||
#define MAX_NCURSES_MENU_OPTIONS 64 | ||
|
||
struct bbs_ncurses_menu { | ||
const char *title; | ||
const char *subtitle; | ||
const char *keybindings; | ||
char keybind[MAX_NCURSES_MENU_OPTIONS]; | ||
char *options[MAX_NCURSES_MENU_OPTIONS]; | ||
char *optvals[MAX_NCURSES_MENU_OPTIONS]; | ||
int num_options; | ||
}; | ||
|
||
/*! | ||
* \brief Initialize a menu. You must call this before using it in any way. | ||
*/ | ||
void bbs_ncurses_menu_init(struct bbs_ncurses_menu *menu); | ||
|
||
/*! \brief Destroy a menu when done with it */ | ||
void bbs_ncurses_menu_destroy(struct bbs_ncurses_menu *menu); | ||
|
||
/*! | ||
* \brief Set the title of a menu | ||
* \param menu | ||
* \param title Menu title. Must remain valid throughout the lifetime of menu. | ||
*/ | ||
void bbs_ncurses_menu_set_title(struct bbs_ncurses_menu *menu, const char *title); | ||
|
||
/*! | ||
* \brief Set the subtitle of a menu | ||
* \param menu | ||
* \param subtitle Menu subtitle. Must remain valid throughout the lifetime of menu. | ||
*/ | ||
void bbs_ncurses_menu_set_subtitle(struct bbs_ncurses_menu *menu, const char *subtitle); | ||
|
||
/*! | ||
* \brief Disable custom key bindings. A default 'q' option will still be added to quit. | ||
* \param menu | ||
*/ | ||
void bbs_ncurses_menu_disable_keybindings(struct bbs_ncurses_menu *menu); | ||
|
||
/*! | ||
* \brief Add an option to a menu | ||
* \param menu | ||
* \param key Key binding. Specify 0 for no key binding. | ||
* \param opt Will be duplicated. | ||
* \param value Will be duplicated. | ||
* \retval -1 on failure, 0 on success | ||
*/ | ||
int bbs_ncurses_menu_addopt(struct bbs_ncurses_menu *menu, char key, const char *opt, const char *value) __nonnull ((1, 3)); | ||
|
||
/*! | ||
* \brief Get the option value of a menu item at a particular index | ||
* \param menu | ||
* \param index | ||
* \return NULL on failure or invalid index | ||
* \return Option value | ||
*/ | ||
const char *bbs_ncurses_menu_getopt_name(struct bbs_ncurses_menu *menu, int index); | ||
|
||
/*! | ||
* \brief Get the keybinding of a menu item at a particular index | ||
* \param menu | ||
* \param index | ||
* \return 0 on failure or invalid index | ||
* \return Key binding | ||
*/ | ||
char bbs_ncurses_menu_getopt_key(struct bbs_ncurses_menu *menu, int index); | ||
|
||
/*! | ||
* \brief Get an option using a menu (pass to bbs_ncurses_menu_getopt_name for the text value) | ||
* \param node | ||
* \param menu | ||
* \retval -1 on failure, option index otherwise | ||
*/ | ||
int bbs_ncurses_menu_getopt(struct bbs_node *node, struct bbs_ncurses_menu *menu); | ||
|
||
/*! | ||
* \brief Run a menu and return the keybinding for the chosen option. | ||
* This is a convenience wrapper that calls bbs_ncurses_menu_getopt | ||
* and then calls bbs_ncurses_menu_getopt_key on the result, if there is one. | ||
* \param node | ||
* \param menu | ||
* \return Same as bbs_ncurses_menu_getopt_key | ||
*/ | ||
char bbs_ncurses_menu_getopt_selection(struct bbs_node *node, struct bbs_ncurses_menu *menu); |
Oops, something went wrong.