app.h 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@digium.com>
  7. * See http://www.asterisk.org for more information about
  8. * the Asterisk project. Please do not directly contact
  9. * any of the maintainers of this project for assistance;
  10. * the project provides a web site, mailing lists and IRC
  11. * channels for your use.
  12. *
  13. * This program is free software, distributed under the terms of
  14. * the GNU General Public License Version 2. See the LICENSE file
  15. * at the top of the source tree.
  16. */
  17. /*! \file
  18. * \brief Application convenience functions, designed to give consistent
  19. * look and feel to Asterisk apps.
  20. */
  21. #ifndef _ASTERISK_APP_H
  22. #define _ASTERISK_APP_H
  23. #include "asterisk/stringfields.h"
  24. #include "asterisk/strings.h"
  25. #include "asterisk/threadstorage.h"
  26. #include "asterisk/file.h"
  27. #include "asterisk/linkedlists.h"
  28. #include "asterisk/utils.h"
  29. #include "asterisk/stasis.h"
  30. struct ast_flags64;
  31. #if defined(__cplusplus) || defined(c_plusplus)
  32. extern "C" {
  33. #endif
  34. AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf);
  35. /* IVR stuff */
  36. /*! \brief Callback function for IVR
  37. \return returns 0 on completion, -1 on hangup or digit if interrupted
  38. */
  39. typedef int (ast_ivr_callback)(struct ast_channel *chan, char *option, void *cbdata);
  40. typedef enum {
  41. AST_ACTION_UPONE, /*!< adata is unused */
  42. AST_ACTION_EXIT, /*!< adata is the return value for ast_ivr_menu_run if channel was not hungup */
  43. AST_ACTION_CALLBACK, /*!< adata is an ast_ivr_callback */
  44. AST_ACTION_PLAYBACK, /*!< adata is file to play */
  45. AST_ACTION_BACKGROUND, /*!< adata is file to play */
  46. AST_ACTION_PLAYLIST, /*!< adata is list of files, separated by ; to play */
  47. AST_ACTION_MENU, /*!< adata is a pointer to an ast_ivr_menu */
  48. AST_ACTION_REPEAT, /*!< adata is max # of repeats, cast to a pointer */
  49. AST_ACTION_RESTART, /*!< adata is like repeat, but resets repeats to 0 */
  50. AST_ACTION_TRANSFER, /*!< adata is a string with exten\verbatim[@context]\endverbatim */
  51. AST_ACTION_WAITOPTION, /*!< adata is a timeout, or 0 for defaults */
  52. AST_ACTION_NOOP, /*!< adata is unused */
  53. AST_ACTION_BACKLIST, /*!< adata is list of files separated by ; allows interruption */
  54. } ast_ivr_action;
  55. /*!
  56. Special "options" are:
  57. \arg "s" - "start here (one time greeting)"
  58. \arg "g" - "greeting/instructions"
  59. \arg "t" - "timeout"
  60. \arg "h" - "hangup"
  61. \arg "i" - "invalid selection"
  62. */
  63. struct ast_ivr_option {
  64. char *option;
  65. ast_ivr_action action;
  66. void *adata;
  67. };
  68. struct ast_ivr_menu {
  69. char *title; /*!< Title of menu */
  70. unsigned int flags; /*!< Flags */
  71. struct ast_ivr_option *options; /*!< All options */
  72. };
  73. /*!
  74. * \brief Structure used for ast_copy_recording_to_vm in order to cleanly supply
  75. * data needed for making the recording from the recorded file.
  76. */
  77. struct ast_vm_recording_data {
  78. AST_DECLARE_STRING_FIELDS(
  79. AST_STRING_FIELD(context);
  80. AST_STRING_FIELD(mailbox);
  81. AST_STRING_FIELD(folder);
  82. AST_STRING_FIELD(recording_file);
  83. AST_STRING_FIELD(recording_ext);
  84. AST_STRING_FIELD(call_context);
  85. AST_STRING_FIELD(call_macrocontext);
  86. AST_STRING_FIELD(call_extension);
  87. AST_STRING_FIELD(call_callerchan);
  88. AST_STRING_FIELD(call_callerid);
  89. );
  90. int call_priority;
  91. };
  92. #define AST_IVR_FLAG_AUTORESTART (1 << 0)
  93. #define AST_IVR_DECLARE_MENU(holder, title, flags, foo...) \
  94. static struct ast_ivr_option __options_##holder[] = foo;\
  95. static struct ast_ivr_menu holder = { title, flags, __options_##holder }
  96. enum ast_timelen {
  97. TIMELEN_HOURS,
  98. TIMELEN_MINUTES,
  99. TIMELEN_SECONDS,
  100. TIMELEN_MILLISECONDS,
  101. };
  102. /*! \brief Runs an IVR menu
  103. \return returns 0 on successful completion, -1 on hangup, or -2 on user error in menu */
  104. int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata);
  105. /*! \brief Plays a stream and gets DTMF data from a channel
  106. * \param c Which channel one is interacting with
  107. * \param prompt File to pass to ast_streamfile (the one that you wish to play).
  108. * It is also valid for this to be multiple files concatenated by "&".
  109. * For example, "file1&file2&file3".
  110. * \param s The location where the DTMF data will be stored
  111. * \param maxlen Max Length of the data
  112. * \param timeout Timeout length waiting for data(in milliseconds). Set to 0 for standard timeout(six seconds), or -1 for no time out.
  113. *
  114. * This function was designed for application programmers for situations where they need
  115. * to play a message and then get some DTMF data in response to the message. If a digit
  116. * is pressed during playback, it will immediately break out of the message and continue
  117. * execution of your code.
  118. */
  119. int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout);
  120. /*! \brief Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other full functions */
  121. int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd);
  122. /*!
  123. * \brief Run a macro on a channel, placing an optional second channel into autoservice.
  124. * \since 11.0
  125. *
  126. * \details
  127. * This is a shorthand method that makes it very easy to run a
  128. * macro on any given channel. It is perfectly reasonable to
  129. * supply a NULL autoservice_chan here in case there is no
  130. * channel to place into autoservice.
  131. *
  132. * \note Absolutely _NO_ channel locks should be held before calling this function.
  133. *
  134. * \param autoservice_chan A channel to place into autoservice while the macro is run
  135. * \param macro_chan Channel to execute macro on.
  136. * \param macro_args Macro application argument string.
  137. *
  138. * \retval 0 success
  139. * \retval -1 on error
  140. */
  141. int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args);
  142. /*!
  143. * \since 1.8
  144. * \brief Run a macro on a channel, placing an optional second channel into autoservice.
  145. *
  146. * \details
  147. * This is a shorthand method that makes it very easy to run a
  148. * macro on any given channel. It is perfectly reasonable to
  149. * supply a NULL autoservice_chan here in case there is no
  150. * channel to place into autoservice.
  151. *
  152. * \note Absolutely _NO_ channel locks should be held before calling this function.
  153. *
  154. * \param autoservice_chan A channel to place into autoservice while the macro is run
  155. * \param macro_chan Channel to execute macro on.
  156. * \param macro_name The name of the macro to run.
  157. * \param macro_args The arguments to pass to the macro.
  158. *
  159. * \retval 0 success
  160. * \retval -1 on error
  161. */
  162. int ast_app_run_macro(struct ast_channel *autoservice_chan,
  163. struct ast_channel *macro_chan, const char *macro_name, const char *macro_args);
  164. /*!
  165. * \brief Stack applications callback functions.
  166. */
  167. struct ast_app_stack_funcs {
  168. /*!
  169. * Module reference pointer so the module will stick around
  170. * while a callback is active.
  171. */
  172. void *module;
  173. /*!
  174. * \brief Callback for the routine to run a subroutine on a channel.
  175. *
  176. * \note Absolutely _NO_ channel locks should be held before calling this function.
  177. *
  178. * \param chan Channel to execute subroutine on.
  179. * \param args Gosub application argument string.
  180. * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
  181. *
  182. * \retval 0 success
  183. * \retval -1 on error
  184. */
  185. int (*run_sub)(struct ast_channel *chan, const char *args, int ignore_hangup);
  186. /*!
  187. * \brief Add missing context/exten to Gosub application argument string.
  188. *
  189. * \param chan Channel to obtain context/exten.
  190. * \param args Gosub application argument string.
  191. *
  192. * \details
  193. * Fills in the optional context and exten from the given channel.
  194. *
  195. * \retval New-args Gosub argument string on success. Must be freed.
  196. * \retval NULL on error.
  197. */
  198. const char *(*expand_sub_args)(struct ast_channel *chan, const char *args);
  199. /* Add new API calls to the end here. */
  200. };
  201. /*!
  202. * \since 11
  203. * \brief Set stack application function callbacks
  204. * \param funcs Stack applications callback functions.
  205. */
  206. void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs);
  207. /*!
  208. * \brief Add missing context/exten to subroutine argument string.
  209. *
  210. * \param chan Channel to obtain context/exten.
  211. * \param args Gosub application argument string.
  212. *
  213. * \details
  214. * Fills in the optional context and exten from the given channel.
  215. *
  216. * \retval New-args Gosub argument string on success. Must be freed.
  217. * \retval NULL on error.
  218. */
  219. const char *ast_app_expand_sub_args(struct ast_channel *chan, const char *args);
  220. /*!
  221. * \since 11
  222. * \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
  223. *
  224. * \details
  225. * This is a shorthand method that makes it very easy to run a
  226. * subroutine on any given channel. It is perfectly reasonable
  227. * to supply a NULL autoservice_chan here in case there is no
  228. * channel to place into autoservice.
  229. *
  230. * \note Absolutely _NO_ channel locks should be held before calling this function.
  231. *
  232. * \param autoservice_chan A channel to place into autoservice while the subroutine is run
  233. * \param sub_chan Channel to execute subroutine on.
  234. * \param sub_args Gosub application argument string.
  235. * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
  236. *
  237. * \retval 0 success
  238. * \retval -1 on error
  239. */
  240. int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup);
  241. /*!
  242. * \since 11
  243. * \brief Run a subroutine on a channel, placing an optional second channel into autoservice.
  244. *
  245. * \details
  246. * This is a shorthand method that makes it very easy to run a
  247. * subroutine on any given channel. It is perfectly reasonable
  248. * to supply a NULL autoservice_chan here in case there is no
  249. * channel to place into autoservice.
  250. *
  251. * \note Absolutely _NO_ channel locks should be held before calling this function.
  252. *
  253. * \param autoservice_chan A channel to place into autoservice while the subroutine is run
  254. * \param sub_chan Channel to execute subroutine on.
  255. * \param sub_location The location of the subroutine to run.
  256. * \param sub_args The arguments to pass to the subroutine.
  257. * \param ignore_hangup TRUE if a hangup does not stop execution of the routine.
  258. *
  259. * \retval 0 success
  260. * \retval -1 on error
  261. */
  262. int ast_app_run_sub(struct ast_channel *autoservice_chan,
  263. struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup);
  264. enum ast_vm_snapshot_sort_val {
  265. AST_VM_SNAPSHOT_SORT_BY_ID = 0,
  266. AST_VM_SNAPSHOT_SORT_BY_TIME,
  267. };
  268. struct ast_vm_msg_snapshot {
  269. AST_DECLARE_STRING_FIELDS(
  270. AST_STRING_FIELD(msg_id);
  271. AST_STRING_FIELD(callerid);
  272. AST_STRING_FIELD(callerchan);
  273. AST_STRING_FIELD(exten);
  274. AST_STRING_FIELD(origdate);
  275. AST_STRING_FIELD(origtime);
  276. AST_STRING_FIELD(duration);
  277. AST_STRING_FIELD(folder_name);
  278. AST_STRING_FIELD(flag);
  279. );
  280. unsigned int msg_number;
  281. AST_LIST_ENTRY(ast_vm_msg_snapshot) msg;
  282. };
  283. struct ast_vm_mailbox_snapshot {
  284. int total_msg_num;
  285. int folders;
  286. /* Things are not quite as they seem here. This points to an allocated array of lists. */
  287. AST_LIST_HEAD_NOLOCK(, ast_vm_msg_snapshot) *snapshots;
  288. };
  289. /*!
  290. * \brief Voicemail playback callback function definition
  291. *
  292. * \param chan Channel to play the file back on.
  293. * \param playfile Location of file on disk
  294. * \param duration of file in seconds. This will be zero if msg is very short or
  295. * has an unknown duration.
  296. */
  297. typedef void (ast_vm_msg_play_cb)(struct ast_channel *chan, const char *playfile, int duration);
  298. /*!
  299. * \brief Determines if the given folder has messages.
  300. *
  301. * \param mailboxes Comma or & delimited list of mailboxes (user@context).
  302. * If no context is found, uses 'default' for the context.
  303. * \param folder The folder to look in. Default is INBOX if not provided.
  304. *
  305. * \retval 1 if the folder has one or more messages.
  306. * \retval 0 otherwise.
  307. */
  308. typedef int (ast_has_voicemail_fn)(const char *mailboxes, const char *folder);
  309. /*!
  310. * \brief Gets the number of messages that exist for the mailbox list.
  311. *
  312. * \param mailboxes Comma or space delimited list of mailboxes (user@context).
  313. * If no context is found, uses 'default' for the context.
  314. * \param newmsgs Where to put the count of new messages. (Can be NULL)
  315. * \param oldmsgs Where to put the count of old messages. (Can be NULL)
  316. *
  317. * \details
  318. * Simultaneously determines the count of new + urgent and old
  319. * messages. The total messages would then be the sum of these.
  320. *
  321. * \retval 0 on success
  322. * \retval -1 on failure
  323. */
  324. typedef int (ast_inboxcount_fn)(const char *mailboxes, int *newmsgs, int *oldmsgs);
  325. /*!
  326. * \brief Gets the number of messages that exist for the mailbox list.
  327. *
  328. * \param mailboxes Comma or space delimited list of mailboxes (user@context).
  329. * If no context is found, uses 'default' for the context.
  330. * \param urgentmsgs Where to put the count of urgent messages. (Can be NULL)
  331. * \param newmsgs Where to put the count of new messages. (Can be NULL)
  332. * \param oldmsgs Where to put the count of old messages. (Can be NULL)
  333. *
  334. * \details
  335. * Simultaneously determines the count of new, old, and urgent
  336. * messages. The total messages would then be the sum of these
  337. * three.
  338. *
  339. * \retval 0 on success
  340. * \retval -1 on failure
  341. */
  342. typedef int (ast_inboxcount2_fn)(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs);
  343. /*!
  344. * \brief Gets the number of messages that exist in a mailbox folder.
  345. *
  346. * \param mailbox_id The mailbox name.
  347. * \param folder The folder to look in. Default is INBOX if not provided.
  348. *
  349. * \note If requesting INBOX then the returned count is INBOX + Urgent.
  350. *
  351. * \return The number of messages in the mailbox folder (zero or more).
  352. */
  353. typedef int (ast_messagecount_fn)(const char *mailbox_id, const char *folder);
  354. /*!
  355. * \brief Play a recorded user name for the mailbox to the specified channel.
  356. *
  357. * \param chan Where to play the recorded name file.
  358. * \param mailbox_id The mailbox name.
  359. *
  360. * \retval 0 Name played without interruption
  361. * \retval dtmf ASCII value of the DTMF which interrupted playback.
  362. * \retval -1 Unable to locate mailbox or hangup occurred.
  363. */
  364. typedef int (ast_sayname_fn)(struct ast_channel *chan, const char *mailbox_id);
  365. /*!
  366. * \brief Creates a voicemail based on a specified file to a mailbox.
  367. *
  368. * \param vm_rec_data A record containing filename and voicemail txt info.
  369. *
  370. * \retval 0 on success
  371. * \retval -1 on failure
  372. */
  373. typedef int (ast_copy_recording_to_vm_fn)(struct ast_vm_recording_data *vm_rec_data);
  374. /*!
  375. * \brief Convert the mailbox folder id to a folder name.
  376. *
  377. * \param id Mailbox folder id to convert.
  378. *
  379. * \deprecated Nothing calls it and nothing ever should.
  380. *
  381. * \return The folder name associated with the id.
  382. */
  383. typedef const char *(ast_vm_index_to_foldername_fn)(int id);
  384. /*!
  385. * \brief Create a snapshot of a mailbox which contains information about every msg.
  386. *
  387. * \param user The user part of user@context.
  388. * \param context The context part of user@context. Must be explicit.
  389. * \param folder When not NULL only msgs from the specified folder will be included.
  390. * \param descending list the msgs in descending order rather than ascending order.
  391. * \param sort_val What to sort in the snapshot.
  392. * \param combine_INBOX_and_OLD When this argument is set, The OLD folder will be represented
  393. * in the INBOX folder of the snapshot. This allows the snapshot to represent the
  394. * OLD and INBOX messages in sorted order merged together.
  395. *
  396. * \note Only used by voicemail unit tests.
  397. *
  398. * \retval snapshot on success
  399. * \retval NULL on failure
  400. */
  401. typedef struct ast_vm_mailbox_snapshot *(ast_vm_mailbox_snapshot_create_fn)(const char *user,
  402. const char *context, const char *folder, int descending,
  403. enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD);
  404. /*!
  405. * \brief destroy a snapshot
  406. *
  407. * \param mailbox_snapshot The snapshot to destroy.
  408. *
  409. * \note Only used by voicemail unit tests.
  410. *
  411. * \retval NULL
  412. */
  413. typedef struct ast_vm_mailbox_snapshot *(ast_vm_mailbox_snapshot_destroy_fn)(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
  414. /*!
  415. * \brief Move messages from one folder to another
  416. *
  417. * \param mailbox The mailbox to which the folders belong
  418. * \param context The voicemail context for the mailbox
  419. * \param num_msgs The number of messages to move
  420. * \param oldfolder The folder from where messages should be moved
  421. * \param old_msg_ids The message IDs of the messages to move
  422. * \param newfolder The folder to which messages should be moved
  423. * new folder. This array must be num_msgs sized.
  424. *
  425. * \note Only used by voicemail unit tests.
  426. *
  427. * \retval -1 Failure
  428. * \retval 0 Success
  429. */
  430. typedef int (ast_vm_msg_move_fn)(const char *mailbox, const char *context, size_t num_msgs,
  431. const char *oldfolder, const char *old_msg_ids[], const char *newfolder);
  432. /*!
  433. * \brief Remove/delete messages from a mailbox folder.
  434. *
  435. * \param mailbox The mailbox from which to delete messages
  436. * \param context The voicemail context for the mailbox
  437. * \param num_msgs The number of messages to delete
  438. * \param folder The folder from which to remove messages
  439. * \param msgs The message IDs of the messages to delete
  440. *
  441. * \note Only used by voicemail unit tests.
  442. *
  443. * \retval -1 Failure
  444. * \retval 0 Success
  445. */
  446. typedef int (ast_vm_msg_remove_fn)(const char *mailbox, const char *context, size_t num_msgs,
  447. const char *folder, const char *msgs[]);
  448. /*!
  449. * \brief forward a message from one mailbox to another.
  450. *
  451. * \brief from_mailbox The original mailbox the message is being forwarded from
  452. * \brief from_context The voicemail context of the from_mailbox
  453. * \brief from_folder The folder from which the message is being forwarded
  454. * \brief to_mailbox The mailbox to forward the message to
  455. * \brief to_context The voicemail context of the to_mailbox
  456. * \brief to_folder The folder to which the message is being forwarded
  457. * \brief num_msgs The number of messages being forwarded
  458. * \brief msg_ids The message IDs of the messages in from_mailbox to forward
  459. * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
  460. * Otherwise, the messages will remain in the from_mailbox.
  461. *
  462. * \note Only used by voicemail unit tests.
  463. *
  464. * \retval -1 Failure
  465. * \retval 0 Success
  466. */
  467. typedef int (ast_vm_msg_forward_fn)(const char *from_mailbox, const char *from_context,
  468. const char *from_folder, const char *to_mailbox, const char *to_context,
  469. const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old);
  470. /*!
  471. * \brief Play a voicemail msg back on a channel.
  472. *
  473. * \param chan
  474. * \param mailbox msg is in.
  475. * \param context of mailbox.
  476. * \param folder voicemail folder to look in.
  477. * \param msg_num message number in the voicemailbox to playback to the channel.
  478. * \param cb
  479. *
  480. * \note Only used by voicemail unit tests.
  481. *
  482. * \retval 0 success
  483. * \retval -1 failure
  484. */
  485. typedef int (ast_vm_msg_play_fn)(struct ast_channel *chan, const char *mailbox,
  486. const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb);
  487. #define VM_MODULE_VERSION 2
  488. /*! \brief Voicemail function table definition. */
  489. struct ast_vm_functions {
  490. /*!
  491. * \brief The version of this function table.
  492. *
  493. * \note If the ABI for this table changes, the module version
  494. * (\ref VM_MODULE_VERSION) should be incremented.
  495. */
  496. unsigned int module_version;
  497. /*! \brief The name of the module that provides the voicemail functionality */
  498. const char *module_name;
  499. /*! \brief The module for the voicemail provider */
  500. struct ast_module *module;
  501. ast_has_voicemail_fn *has_voicemail;
  502. ast_inboxcount_fn *inboxcount;
  503. ast_inboxcount2_fn *inboxcount2;
  504. ast_messagecount_fn *messagecount;
  505. ast_copy_recording_to_vm_fn *copy_recording_to_vm;
  506. ast_vm_index_to_foldername_fn *index_to_foldername;
  507. ast_vm_mailbox_snapshot_create_fn *mailbox_snapshot_create;
  508. ast_vm_mailbox_snapshot_destroy_fn *mailbox_snapshot_destroy;
  509. ast_vm_msg_move_fn *msg_move;
  510. ast_vm_msg_remove_fn *msg_remove;
  511. ast_vm_msg_forward_fn *msg_forward;
  512. ast_vm_msg_play_fn *msg_play;
  513. };
  514. /*!
  515. * \brief Determine if a voicemail provider is registered.
  516. * \since 12.0.0
  517. *
  518. * \retval 0 if no provider registered.
  519. * \retval 1 if a provider is registered.
  520. */
  521. int ast_vm_is_registered(void);
  522. /*!
  523. * \brief Set voicemail function callbacks
  524. *
  525. * \param vm_table Voicemail function table to install.
  526. * \param module Pointer to the module implementing the interface
  527. *
  528. * \retval 0 on success.
  529. * \retval -1 on error.
  530. * \retval AST_MODULE_LOAD_DECLINE if there's already another provider registered.
  531. */
  532. int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module);
  533. /*! \brief See \ref __ast_vm_register() */
  534. #define ast_vm_register(vm_table) __ast_vm_register(vm_table, ast_module_info ? ast_module_info->self : NULL)
  535. /*!
  536. * \brief Unregister the specified voicemail provider
  537. *
  538. * \param The module name of the provider to unregister
  539. *
  540. * \return Nothing
  541. */
  542. void ast_vm_unregister(const char *module_name);
  543. #ifdef TEST_FRAMEWORK
  544. /*!
  545. * \brief Swap out existing voicemail functions with a temporary set of functions for use with unit tests
  546. *
  547. * \param vm_table function table to use for testing
  548. *
  549. * \note ast_vm_test_swap_table_out should be called to restore the original set before testing concludes
  550. */
  551. void ast_vm_test_swap_table_in(const struct ast_vm_functions *vm_table);
  552. /*!
  553. * \brief Used after ast_vm_test_swap_table_in to restore the original set of voicemail functions
  554. */
  555. void ast_vm_test_swap_table_out(void);
  556. #endif
  557. #define VM_GREETER_MODULE_VERSION 1
  558. /*! \brief Voicemail greeter function table definition. */
  559. struct ast_vm_greeter_functions {
  560. /*!
  561. * \brief The version of this function table.
  562. *
  563. * \note If the ABI for this table changes, the module version
  564. * (\ref VM_GREETER_MODULE_VERSION) should be incremented.
  565. */
  566. unsigned int module_version;
  567. /*! \brief The name of the module that provides the voicemail greeter functionality */
  568. const char *module_name;
  569. /*! \brief The module for the voicemail greeter provider */
  570. struct ast_module *module;
  571. ast_sayname_fn *sayname;
  572. };
  573. /*!
  574. * \brief Determine if a voicemail greeter provider is registered.
  575. * \since 13.0.0
  576. *
  577. * \retval 0 if no provider registered.
  578. * \retval 1 if a provider is registered.
  579. */
  580. int ast_vm_greeter_is_registered(void);
  581. /*!
  582. * \brief Set voicemail greeter function callbacks
  583. * \since 13.0.0
  584. *
  585. * \param vm_table Voicemail greeter function table to install.
  586. * \param module Pointer to the module implementing the interface
  587. *
  588. * \retval 0 on success.
  589. * \retval -1 on error.
  590. * \retval AST_MODULE_LOAD_DECLINE if there's already another greeter registered.
  591. */
  592. int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module);
  593. /*! \brief See \ref __ast_vm_greeter_register() */
  594. #define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, ast_module_info ? ast_module_info->self : NULL)
  595. /*!
  596. * \brief Unregister the specified voicemail greeter provider
  597. * \since 13.0.0
  598. *
  599. * \param The module name of the provider to unregister
  600. *
  601. * \return Nothing
  602. */
  603. void ast_vm_greeter_unregister(const char *module_name);
  604. #ifdef TEST_FRAMEWORK
  605. typedef int (ast_vm_test_create_user_fn)(const char *context, const char *user);
  606. typedef int (ast_vm_test_destroy_user_fn)(const char *context, const char *user);
  607. void ast_install_vm_test_functions(ast_vm_test_create_user_fn *vm_test_create_user_func,
  608. ast_vm_test_destroy_user_fn *vm_test_destroy_user_func);
  609. void ast_uninstall_vm_test_functions(void);
  610. #endif
  611. /*!
  612. * \brief
  613. * param[in] vm_rec_data Contains data needed to make the recording.
  614. * retval 0 voicemail successfully created from recording.
  615. * retval -1 Failure
  616. */
  617. int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data);
  618. /*!
  619. * \brief Determine if a given mailbox has any voicemail
  620. * If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the
  621. * number of messages in the "Urgent" folder.
  622. * \retval 1 Mailbox has voicemail
  623. * \retval 0 No new voicemail in specified mailbox
  624. * \retval -1 Failure
  625. * \since 1.0
  626. */
  627. int ast_app_has_voicemail(const char *mailboxes, const char *folder);
  628. /*!
  629. * \brief Determine number of new/old messages in a mailbox
  630. * \since 1.0
  631. * \param[in] mailboxes Mailbox specification in the format
  632. * /code
  633. * mbox[\@context][&mbox2[\@context2]][...]
  634. * /code
  635. * \param[out] newmsgs Number of messages in the "INBOX" folder. Includes number of messages in the "Urgent" folder, if any.
  636. * \param[out] oldmsgs Number of messages in the "Old" folder.
  637. * \retval 0 Success
  638. * \retval -1 Failure
  639. */
  640. int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs);
  641. /*!
  642. * \brief Determine number of urgent/new/old messages in a mailbox
  643. * \param[in] mailboxes the mailbox context to use
  644. * \param[out] urgentmsgs the urgent message count
  645. * \param[out] newmsgs the new message count
  646. * \param[out] oldmsgs the old message count
  647. * \return Returns 0 for success, negative upon error
  648. * \since 1.6.1
  649. */
  650. int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs);
  651. /*!
  652. * \brief Play a recorded user name for the mailbox to the specified channel.
  653. *
  654. * \param chan Where to play the recorded name file.
  655. * \param mailbox_id The mailbox name.
  656. *
  657. * \retval 0 Name played without interruption
  658. * \retval dtmf ASCII value of the DTMF which interrupted playback.
  659. * \retval -1 Unable to locate mailbox or hangup occurred.
  660. */
  661. int ast_app_sayname(struct ast_channel *chan, const char *mailbox_id);
  662. /*!
  663. * \brief Get the number of messages in a given mailbox folder
  664. *
  665. * \param[in] mailbox_id Mailbox name
  666. * \param[in] folder The folder to look in. Default is INBOX if not provided.
  667. *
  668. * \note If requesting INBOX then the returned count is INBOX + Urgent.
  669. *
  670. * \return The number of messages in the mailbox folder (zero or more).
  671. */
  672. int ast_app_messagecount(const char *mailbox_id, const char *folder);
  673. /*!
  674. * \brief Return name of folder, given an id
  675. * \param[in] id Folder id
  676. * \return Name of folder
  677. */
  678. const char *ast_vm_index_to_foldername(int id);
  679. /*!
  680. * \brief Create a snapshot of a mailbox which contains information about every msg.
  681. *
  682. * \param mailbox, the mailbox to look for
  683. * \param context, the context to look for the mailbox in
  684. * \param folder, OPTIONAL. When not NULL only msgs from the specified folder will be included.
  685. * \param descending, list the msgs in descending order rather than ascending order.
  686. * \param combine_INBOX_and_OLD, When this argument is set, The OLD folder will be represented
  687. * in the INBOX folder of the snapshot. This allows the snapshot to represent the
  688. * OLD and INBOX messages in sorted order merged together.
  689. *
  690. * \retval snapshot on success
  691. * \retval NULL on failure
  692. */
  693. struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_create(const char *mailbox,
  694. const char *context,
  695. const char *folder,
  696. int descending,
  697. enum ast_vm_snapshot_sort_val sort_val,
  698. int combine_INBOX_and_OLD);
  699. /*!
  700. * \brief destroy a snapshot
  701. *
  702. * \param mailbox_snapshot The snapshot to destroy.
  703. * \retval NULL
  704. */
  705. struct ast_vm_mailbox_snapshot *ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot);
  706. /*!
  707. * \brief Move messages from one folder to another
  708. *
  709. * \param mailbox The mailbox to which the folders belong
  710. * \param context The voicemail context for the mailbox
  711. * \param num_msgs The number of messages to move
  712. * \param oldfolder The folder from where messages should be moved
  713. * \param old_msg_ids The message IDs of the messages to move
  714. * \param newfolder The folder to which messages should be moved
  715. * new folder. This array must be num_msgs sized.
  716. *
  717. * \retval -1 Failure
  718. * \retval 0 Success
  719. */
  720. int ast_vm_msg_move(const char *mailbox,
  721. const char *context,
  722. size_t num_msgs,
  723. const char *oldfolder,
  724. const char *old_msg_ids[],
  725. const char *newfolder);
  726. /*!
  727. * \brief Remove/delete messages from a mailbox folder.
  728. *
  729. * \param mailbox The mailbox from which to delete messages
  730. * \param context The voicemail context for the mailbox
  731. * \param num_msgs The number of messages to delete
  732. * \param folder The folder from which to remove messages
  733. * \param msgs The message IDs of the messages to delete
  734. *
  735. * \retval -1 Failure
  736. * \retval 0 Success
  737. */
  738. int ast_vm_msg_remove(const char *mailbox,
  739. const char *context,
  740. size_t num_msgs,
  741. const char *folder,
  742. const char *msgs[]);
  743. /*!
  744. * \brief forward a message from one mailbox to another.
  745. *
  746. * \brief from_mailbox The original mailbox the message is being forwarded from
  747. * \brief from_context The voicemail context of the from_mailbox
  748. * \brief from_folder The folder from which the message is being forwarded
  749. * \brief to_mailbox The mailbox to forward the message to
  750. * \brief to_context The voicemail context of the to_mailbox
  751. * \brief to_folder The folder to which the message is being forwarded
  752. * \brief num_msgs The number of messages being forwarded
  753. * \brief msg_ids The message IDs of the messages in from_mailbox to forward
  754. * \brief delete_old If non-zero, the forwarded messages are also deleted from from_mailbox.
  755. * Otherwise, the messages will remain in the from_mailbox.
  756. *
  757. * \retval -1 Failure
  758. * \retval 0 Success
  759. */
  760. int ast_vm_msg_forward(const char *from_mailbox,
  761. const char *from_context,
  762. const char *from_folder,
  763. const char *to_mailbox,
  764. const char *to_context,
  765. const char *to_folder,
  766. size_t num_msgs,
  767. const char *msg_ids[],
  768. int delete_old);
  769. /*!
  770. * \brief Play a voicemail msg back on a channel.
  771. *
  772. * \param chan
  773. * \param mailbox msg is in.
  774. * \param context of mailbox.
  775. * \param folder voicemail folder to look in.
  776. * \param msg_num message number in the voicemailbox to playback to the channel.
  777. * \param cb
  778. *
  779. * \retval 0 success
  780. * \retval -1 failure
  781. */
  782. int ast_vm_msg_play(struct ast_channel *chan,
  783. const char *mailbox,
  784. const char *context,
  785. const char *folder,
  786. const char *msg_num,
  787. ast_vm_msg_play_cb *cb);
  788. #ifdef TEST_FRAMEWORK
  789. int ast_vm_test_destroy_user(const char *context, const char *mailbox);
  790. int ast_vm_test_create_user(const char *context, const char *mailbox);
  791. #endif
  792. /*!
  793. * \brief Safely spawn an external program while closing file descriptors
  794. *
  795. * \note This replaces the \b execvp call in all Asterisk modules
  796. *
  797. * \param dualfork Non-zero to simulate running the program in the
  798. * background by forking twice. The option provides similar
  799. * functionality to the '&' in the OS shell command "cmd &". The
  800. * option allows Asterisk to run a reaper loop to watch the first fork
  801. * which immediately exits after spaning the second fork. The actual
  802. * program is run in the second fork.
  803. * \param file execvp(file, argv) file parameter
  804. * \param argv execvp(file, argv) argv parameter
  805. */
  806. int ast_safe_execvp(int dualfork, const char *file, char *const argv[]);
  807. /*!
  808. * \brief Safely spawn an OS shell command while closing file descriptors
  809. *
  810. * \note This replaces the \b system call in all Asterisk modules
  811. *
  812. * \param s - OS shell command string to execute.
  813. *
  814. * \warning Command injection can happen using this call if the passed
  815. * in string is created using untrusted data from an external source.
  816. * It is best not to use untrusted data. However, the caller could
  817. * filter out dangerous characters to avoid command injection.
  818. */
  819. int ast_safe_system(const char *s);
  820. /*!
  821. * \brief Replace the SIGCHLD handler
  822. *
  823. * Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie
  824. * processes from forking elsewhere in Asterisk. However, if you want to
  825. * wait*() on the process to retrieve information about it's exit status,
  826. * then this signal handler needs to be temporarily replaced.
  827. *
  828. * Code that executes this function *must* call ast_unreplace_sigchld()
  829. * after it is finished doing the wait*().
  830. */
  831. void ast_replace_sigchld(void);
  832. /*!
  833. * \brief Restore the SIGCHLD handler
  834. *
  835. * This function is called after a call to ast_replace_sigchld. It restores
  836. * the SIGCHLD handler that cleans up any zombie processes.
  837. */
  838. void ast_unreplace_sigchld(void);
  839. /*!
  840. * \brief Send a string of DTMF digits to a channel
  841. *
  842. * \param chan The channel that will receive the DTMF frames
  843. * \param peer (optional) Peer channel that will be autoserviced while the
  844. * primary channel is receiving DTMF
  845. * \param digits This is a string of characters representing the DTMF digits
  846. * to be sent to the channel. Valid characters are
  847. * "0123456789*#abcdABCD". Note: You can pass arguments 'f' or
  848. * 'F', if you want to Flash the channel (if supported by the
  849. * channel), or 'w' to add a 500 millisecond pause to the DTMF
  850. * sequence.
  851. * \param between This is the number of milliseconds to wait in between each
  852. * DTMF digit. If zero milliseconds is specified, then the
  853. * default value of 100 will be used.
  854. * \param duration This is the duration that each DTMF digit should have.
  855. *
  856. * \pre This must only be called by the channel's media handler thread.
  857. *
  858. * \retval 0 on success.
  859. * \retval -1 on failure or a channel hung up.
  860. */
  861. int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration);
  862. /*!
  863. * \brief Send a string of DTMF digits to a channel from an external thread.
  864. *
  865. * \param chan The channel that will receive the DTMF frames
  866. * \param digits This is a string of characters representing the DTMF digits
  867. * to be sent to the channel. Valid characters are
  868. * "0123456789*#abcdABCD". Note: You can pass arguments 'f' or
  869. * 'F', if you want to Flash the channel (if supported by the
  870. * channel), or 'w' to add a 500 millisecond pause to the DTMF
  871. * sequence.
  872. * \param between This is the number of milliseconds to wait in between each
  873. * DTMF digit. If zero milliseconds is specified, then the
  874. * default value of 100 will be used.
  875. * \param duration This is the duration that each DTMF digit should have.
  876. *
  877. * \pre This must only be called by threads that are not the channel's
  878. * media handler thread.
  879. *
  880. * \return Nothing
  881. */
  882. void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration);
  883. /*! \brief Stream a filename (or file descriptor) as a generator. */
  884. int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride);
  885. /*!
  886. * \brief Stream a file with fast forward, pause, reverse, restart.
  887. * \param chan Channel
  888. * \param file File to play.
  889. * \param fwd, rev, stop, pause, restart DTMF keys for media control
  890. * \param skipms Number of milliseconds to skip for fwd/rev.
  891. * \param offsetms Number of milliseconds to skip when starting the media.
  892. *
  893. * Before calling this function, set this to be the number
  894. * of ms to start from the beginning of the file. When the function
  895. * returns, it will be the number of ms from the beginning where the
  896. * playback stopped. Pass NULL if you don't care.
  897. *
  898. * \retval 0 on success
  899. * \retval Non-zero on failure
  900. */
  901. int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms);
  902. /*!
  903. * \brief Version of ast_control_streamfile() which allows the language of the
  904. * media file to be specified.
  905. *
  906. * \retval 0 on success
  907. * \retval Non-zero on failure
  908. */
  909. int ast_control_streamfile_lang(struct ast_channel *chan, const char *file,
  910. const char *fwd, const char *rev, const char *stop, const char *suspend,
  911. const char *restart, int skipms, const char *lang, long *offsetms);
  912. /*!
  913. * \brief Controls playback of a tone
  914. *
  915. * \retval 0 on success
  916. * \retval Non-zero on failure
  917. */
  918. int ast_control_tone(struct ast_channel *chan, const char *tone);
  919. /*!
  920. * \brief Stream a file with fast forward, pause, reverse, restart.
  921. * \param chan
  922. * \param file filename
  923. * \param fwd, rev, stop, pause, restart, skipms, offsetms
  924. * \param cb waitstream callback to invoke when fastforward or rewind occurrs.
  925. *
  926. * Before calling this function, set this to be the number
  927. * of ms to start from the beginning of the file. When the function
  928. * returns, it will be the number of ms from the beginning where the
  929. * playback stopped. Pass NULL if you don't care.
  930. */
  931. int ast_control_streamfile_w_cb(struct ast_channel *chan,
  932. const char *file,
  933. const char *fwd,
  934. const char *rev,
  935. const char *stop,
  936. const char *pause,
  937. const char *restart,
  938. int skipms,
  939. long *offsetms,
  940. ast_waitstream_fr_cb cb);
  941. /*! \brief Play a stream and wait for a digit, returning the digit that was pressed */
  942. int ast_play_and_wait(struct ast_channel *chan, const char *fn);
  943. /*!
  944. * Possible actions to take if a recording already exists
  945. * \since 12
  946. */
  947. enum ast_record_if_exists {
  948. /*! Return an Error State for IF_Exists */
  949. AST_RECORD_IF_EXISTS_ERROR = -1,
  950. /*! Fail the recording. */
  951. AST_RECORD_IF_EXISTS_FAIL,
  952. /*! Overwrite the existing recording. */
  953. AST_RECORD_IF_EXISTS_OVERWRITE,
  954. /*! Append to the existing recording. */
  955. AST_RECORD_IF_EXISTS_APPEND,
  956. };
  957. /*!
  958. * \brief Record a file based on input from a channel
  959. * This function will play "auth-thankyou" upon successful recording if
  960. * skip_confirmation_sound is false.
  961. *
  962. * \param chan the channel being recorded
  963. * \param playfile Filename of sound to play before recording begins. A beep is also played when playfile completes, before the recording begins.
  964. * \param recordfile Filename to save the recording
  965. * \param maxtime_sec Longest possible message length in seconds
  966. * \param fmt string containing all formats to be recorded delimited by '|'
  967. * \param duration pointer to integer for storing length of the recording
  968. * \param beep If true, play a beep before recording begins (and doesn't play \a playfile)
  969. * \param sound_duration pointer to integer for storing length of the recording minus all silence
  970. * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
  971. * \param maxsilence_ms Length of time in milliseconds which will trigger a timeout from silence, -1 for default
  972. * \param path Optional filesystem path to unlock
  973. * \param acceptdtmf Character of DTMF to end and accept the recording
  974. * \param canceldtmf Character of DTMF to end and cancel the recording
  975. * \param skip_confirmation_sound If true, don't play auth-thankyou at end. Nice for custom recording prompts in apps.
  976. * \param if_exists Action to take if recording already exists.
  977. *
  978. * \retval -1 failure or hangup
  979. * \retval 'S' Recording ended from silence timeout
  980. * \retval 't' Recording ended from the message exceeding the maximum duration
  981. * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
  982. */
  983. int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists);
  984. /*!
  985. * \brief Record a file based on input from a channel. Use default accept and cancel DTMF.
  986. * This function will play "auth-thankyou" upon successful recording.
  987. *
  988. * \param chan the channel being recorded
  989. * \param playfile Filename of sound to play before recording begins
  990. * \param recordfile Filename to save the recording
  991. * \param maxtime_sec Longest possible message length in seconds
  992. * \param fmt string containing all formats to be recorded delimited by '|'
  993. * \param duration pointer to integer for storing length of the recording
  994. * \param sound_duration pointer to integer for storing length of the recording minus all silence
  995. * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
  996. * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default
  997. * \param path Optional filesystem path to unlock
  998. *
  999. * \retval -1 failure or hangup
  1000. * \retval 'S' Recording ended from silence timeout
  1001. * \retval 't' Recording ended from the message exceeding the maximum duration
  1002. * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
  1003. */
  1004. int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path);
  1005. /*!
  1006. * \brief Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a little differently from normal recordings
  1007. * This function will not play a success message due to post-recording control in the application this was added for.
  1008. *
  1009. * \param chan the channel being recorded
  1010. * \param playfile Filename of sound to play before recording begins
  1011. * \param recordfile Filename to save the recording
  1012. * \param maxtime_sec Longest possible message length in seconds
  1013. * \param fmt string containing all formats to be recorded delimited by '|'
  1014. * \param duration pointer to integer for storing length of the recording
  1015. * \param sound_duration pointer to integer for storing length of the recording minus all silence
  1016. * \param beep whether to play a beep to prompt the recording
  1017. * \param silencethreshold tolerance of noise levels that can be considered silence for the purpose of silence timeout, -1 for default
  1018. * \param maxsilence_ms length of time in milliseconds which will trigger a timeout from silence, -1 for default.
  1019. *
  1020. * \retval -1 failure or hangup
  1021. * \retval 'S' Recording ended from silence timeout
  1022. * \retval 't' Recording either exceeded maximum duration or the call was ended via DTMF
  1023. */
  1024. int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms);
  1025. enum ast_getdata_result {
  1026. AST_GETDATA_FAILED = -1,
  1027. AST_GETDATA_COMPLETE = 0,
  1028. AST_GETDATA_TIMEOUT = 1,
  1029. AST_GETDATA_INTERRUPTED = 2,
  1030. /*! indicates a user terminated empty string rather than an empty string resulting
  1031. * from a timeout or other factors */
  1032. AST_GETDATA_EMPTY_END_TERMINATED = 3,
  1033. };
  1034. enum AST_LOCK_RESULT {
  1035. AST_LOCK_SUCCESS = 0,
  1036. AST_LOCK_TIMEOUT = -1,
  1037. AST_LOCK_PATH_NOT_FOUND = -2,
  1038. AST_LOCK_FAILURE = -3,
  1039. };
  1040. /*! \brief Type of locking to use in ast_lock_path / ast_unlock_path */
  1041. enum AST_LOCK_TYPE {
  1042. AST_LOCK_TYPE_LOCKFILE = 0,
  1043. AST_LOCK_TYPE_FLOCK = 1,
  1044. };
  1045. /*!
  1046. * \brief Set the type of locks used by ast_lock_path()
  1047. * \param type the locking type to use
  1048. */
  1049. void ast_set_lock_type(enum AST_LOCK_TYPE type);
  1050. /*!
  1051. * \brief Lock a filesystem path.
  1052. * \param path the path to be locked
  1053. * \return one of \ref AST_LOCK_RESULT values
  1054. */
  1055. enum AST_LOCK_RESULT ast_lock_path(const char *path);
  1056. /*! \brief Unlock a path */
  1057. int ast_unlock_path(const char *path);
  1058. /*! \brief Read a file into asterisk*/
  1059. char *ast_read_textfile(const char *file);
  1060. struct ast_group_info;
  1061. /*! \brief Split a group string into group and category, returning a default category if none is provided. */
  1062. int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max);
  1063. /*! \brief Set the group for a channel, splitting the provided data into group and category, if specified. */
  1064. int ast_app_group_set_channel(struct ast_channel *chan, const char *data);
  1065. /*! \brief Get the current channel count of the specified group and category. */
  1066. int ast_app_group_get_count(const char *group, const char *category);
  1067. /*! \brief Get the current channel count of all groups that match the specified pattern and category. */
  1068. int ast_app_group_match_get_count(const char *groupmatch, const char *category);
  1069. /*! \brief Discard all group counting for a channel */
  1070. int ast_app_group_discard(struct ast_channel *chan);
  1071. /*! \brief Update all group counting for a channel to a new one */
  1072. int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan);
  1073. /*! \brief Write Lock the group count list */
  1074. int ast_app_group_list_wrlock(void);
  1075. /*! \brief Read Lock the group count list */
  1076. int ast_app_group_list_rdlock(void);
  1077. /*! \brief Get the head of the group count list */
  1078. struct ast_group_info *ast_app_group_list_head(void);
  1079. /*! \brief Unlock the group count list */
  1080. int ast_app_group_list_unlock(void);
  1081. /*!
  1082. \brief Define an application argument
  1083. \param name The name of the argument
  1084. */
  1085. #define AST_APP_ARG(name) char *name
  1086. /*!
  1087. \brief Declare a structure to hold an application's arguments.
  1088. \param name The name of the structure
  1089. \param arglist The list of arguments, defined using AST_APP_ARG
  1090. This macro declares a structure intended to be used in a call
  1091. to ast_app_separate_args(). The structure includes all the
  1092. arguments specified, plus an argv array that overlays them and an
  1093. argc argument counter. The arguments must be declared using AST_APP_ARG,
  1094. and they will all be character pointers (strings).
  1095. \note The structure is <b>not</b> initialized, as the call to
  1096. ast_app_separate_args() will perform that function before parsing
  1097. the arguments.
  1098. */
  1099. #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(, arglist) name = { 0, }
  1100. /*!
  1101. \brief Define a structure type to hold an application's arguments.
  1102. \param type The name of the structure type
  1103. \param arglist The list of arguments, defined using AST_APP_ARG
  1104. This macro defines a structure type intended to be used in a call
  1105. to ast_app_separate_args(). The structure includes all the
  1106. arguments specified, plus an argv array that overlays them and an
  1107. argc argument counter. The arguments must be declared using AST_APP_ARG,
  1108. and they will all be character pointers (strings).
  1109. \note This defines a structure type, but does not declare an instance
  1110. of the structure. That must be done separately.
  1111. */
  1112. #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \
  1113. struct type { \
  1114. unsigned int argc; \
  1115. char *argv[0]; \
  1116. arglist \
  1117. }
  1118. /*!
  1119. \brief Performs the 'standard' argument separation process for an application.
  1120. \param args An argument structure defined using AST_DECLARE_APP_ARGS
  1121. \param parse A modifiable buffer containing the input to be parsed
  1122. This function will separate the input string using the standard argument
  1123. separator character ',' and fill in the provided structure, including
  1124. the argc argument counter field.
  1125. */
  1126. #define AST_STANDARD_APP_ARGS(args, parse) \
  1127. args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
  1128. #define AST_STANDARD_RAW_ARGS(args, parse) \
  1129. args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
  1130. /*!
  1131. \brief Performs the 'nonstandard' argument separation process for an application.
  1132. \param args An argument structure defined using AST_DECLARE_APP_ARGS
  1133. \param parse A modifiable buffer containing the input to be parsed
  1134. \param sep A nonstandard separator character
  1135. This function will separate the input string using the nonstandard argument
  1136. separator character and fill in the provided structure, including
  1137. the argc argument counter field.
  1138. */
  1139. #define AST_NONSTANDARD_APP_ARGS(args, parse, sep) \
  1140. args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
  1141. #define AST_NONSTANDARD_RAW_ARGS(args, parse, sep) \
  1142. args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
  1143. /*!
  1144. \brief Separate a string into arguments in an array
  1145. \param buf The string to be parsed (this must be a writable copy, as it will be modified)
  1146. \param delim The character to be used to delimit arguments
  1147. \param remove_chars Remove backslashes and quote characters, while parsing
  1148. \param array An array of 'char *' to be filled in with pointers to the found arguments
  1149. \param arraylen The number of elements in the array (i.e. the number of arguments you will accept)
  1150. Note: if there are more arguments in the string than the array will hold, the last element of
  1151. the array will contain the remaining arguments, not separated.
  1152. The array will be completely zeroed by this function before it populates any entries.
  1153. \return The number of arguments found, or zero if the function arguments are not valid.
  1154. */
  1155. unsigned int __ast_app_separate_args(char *buf, char delim, int remove_chars, char **array, int arraylen);
  1156. #define ast_app_separate_args(a,b,c,d) __ast_app_separate_args(a,b,1,c,d)
  1157. /*!
  1158. \brief A structure to hold the description of an application 'option'.
  1159. Application 'options' are single-character flags that can be supplied
  1160. to the application to affect its behavior; they can also optionally
  1161. accept arguments enclosed in parenthesis.
  1162. These structures are used by the ast_app_parse_options function, uses
  1163. this data to fill in a flags structure (to indicate which options were
  1164. supplied) and array of argument pointers (for those options that had
  1165. arguments supplied).
  1166. */
  1167. struct ast_app_option {
  1168. /*! \brief The flag bit that represents this option. */
  1169. uint64_t flag;
  1170. /*! \brief The index of the entry in the arguments array
  1171. that should be used for this option's argument. */
  1172. unsigned int arg_index;
  1173. };
  1174. #define BEGIN_OPTIONS {
  1175. #define END_OPTIONS }
  1176. /*!
  1177. \brief Declares an array of options for an application.
  1178. \param holder The name of the array to be created
  1179. \param options The actual options to be placed into the array
  1180. \sa ast_app_parse_options
  1181. This macro declares a 'static const' array of \c struct \c ast_option
  1182. elements to hold the list of available options for an application.
  1183. Each option must be declared using either the AST_APP_OPTION()
  1184. or AST_APP_OPTION_ARG() macros.
  1185. Example usage:
  1186. \code
  1187. enum my_app_option_flags {
  1188. OPT_JUMP = (1 << 0),
  1189. OPT_BLAH = (1 << 1),
  1190. OPT_BLORT = (1 << 2),
  1191. };
  1192. enum my_app_option_args {
  1193. OPT_ARG_BLAH = 0,
  1194. OPT_ARG_BLORT,
  1195. !! this entry tells how many possible arguments there are,
  1196. and must be the last entry in the list
  1197. OPT_ARG_ARRAY_SIZE,
  1198. };
  1199. AST_APP_OPTIONS(my_app_options, {
  1200. AST_APP_OPTION('j', OPT_JUMP),
  1201. AST_APP_OPTION_ARG('b', OPT_BLAH, OPT_ARG_BLAH),
  1202. AST_APP_OPTION_BLORT('B', OPT_BLORT, OPT_ARG_BLORT),
  1203. });
  1204. static int my_app_exec(struct ast_channel *chan, void *data)
  1205. {
  1206. char *options;
  1207. struct ast_flags opts = { 0, };
  1208. char *opt_args[OPT_ARG_ARRAY_SIZE];
  1209. ... do any argument parsing here ...
  1210. if (ast_app_parse_options(my_app_options, &opts, opt_args, options)) {
  1211. return -1;
  1212. }
  1213. }
  1214. \endcode
  1215. */
  1216. #define AST_APP_OPTIONS(holder, options...) \
  1217. static const struct ast_app_option holder[128] = options
  1218. /*!
  1219. \brief Declares an application option that does not accept an argument.
  1220. \param option The single character representing the option
  1221. \param flagno The flag index to be set if this option is present
  1222. \sa AST_APP_OPTIONS, ast_app_parse_options
  1223. */
  1224. #define AST_APP_OPTION(option, flagno) \
  1225. [option] = { .flag = flagno }
  1226. /*!
  1227. \brief Declares an application option that accepts an argument.
  1228. \param option The single character representing the option
  1229. \param flagno The flag index to be set if this option is present
  1230. \param argno The index into the argument array where the argument should
  1231. be placed
  1232. \sa AST_APP_OPTIONS, ast_app_parse_options
  1233. */
  1234. #define AST_APP_OPTION_ARG(option, flagno, argno) \
  1235. [option] = { .flag = flagno, .arg_index = argno + 1 }
  1236. /*!
  1237. \brief Parses a string containing application options and sets flags/arguments.
  1238. \param options The array of possible options declared with AST_APP_OPTIONS
  1239. \param flags The flag structure to have option flags set
  1240. \param args The array of argument pointers to hold arguments found
  1241. \param optstr The string containing the options to be parsed
  1242. \return zero for success, non-zero if an error occurs
  1243. \sa AST_APP_OPTIONS
  1244. */
  1245. int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr);
  1246. /*!
  1247. \brief Parses a string containing application options and sets flags/arguments.
  1248. \param options The array of possible options declared with AST_APP_OPTIONS
  1249. \param flags The 64-bit flag structure to have option flags set
  1250. \param args The array of argument pointers to hold arguments found
  1251. \param optstr The string containing the options to be parsed
  1252. \return zero for success, non-zero if an error occurs
  1253. \sa AST_APP_OPTIONS
  1254. */
  1255. int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr);
  1256. /*! \brief Given a list of options array, return an option string based on passed flags
  1257. \param options The array of possible options declared with AST_APP_OPTIONS
  1258. \param flags The flags of the options that you wish to populate the buffer with
  1259. \param buf The buffer to fill with the string of options
  1260. \param len The maximum length of buf
  1261. */
  1262. void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len);
  1263. /*! \brief Present a dialtone and collect a certain length extension.
  1264. \return Returns 1 on valid extension entered, -1 on hangup, or 0 on invalid extension.
  1265. \note Note that if 'collect' holds digits already, new digits will be appended, so be sure it's initialized properly */
  1266. int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout);
  1267. /*! \brief Allow to record message and have a review option */
  1268. int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path);
  1269. /*!
  1270. * \brief Decode an encoded control or extended ASCII character
  1271. * \param[in] stream String to decode
  1272. * \param[out] result Decoded character
  1273. * \param[out] consumed Number of characters used in stream to encode the character
  1274. * \retval -1 Stream is of zero length
  1275. * \retval 0 Success
  1276. */
  1277. int ast_get_encoded_char(const char *stream, char *result, size_t *consumed);
  1278. /*!
  1279. * \brief Decode a stream of encoded control or extended ASCII characters
  1280. * \param[in] stream Encoded string
  1281. * \param[out] result Decoded string
  1282. * \param[in] result_len Maximum size of the result buffer
  1283. * \return A pointer to the result string
  1284. */
  1285. char *ast_get_encoded_str(const char *stream, char *result, size_t result_len);
  1286. /*! \brief Decode a stream of encoded control or extended ASCII characters */
  1287. int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream);
  1288. /*!
  1289. * \brief Common routine for child processes, to close all fds prior to exec(2)
  1290. * \param[in] n starting file descriptor number for closing all higher file descriptors
  1291. * \since 1.6.1
  1292. */
  1293. void ast_close_fds_above_n(int n);
  1294. /*!
  1295. * \brief Common routine to safely fork without a chance of a signal handler firing badly in the child
  1296. * \param[in] stop_reaper flag to determine if sigchld handler is replaced or not
  1297. * \since 1.6.1
  1298. */
  1299. int ast_safe_fork(int stop_reaper);
  1300. /*!
  1301. * \brief Common routine to cleanup after fork'ed process is complete (if reaping was stopped)
  1302. * \since 1.6.1
  1303. */
  1304. void ast_safe_fork_cleanup(void);
  1305. /*!
  1306. * \brief Common routine to parse time lengths, with optional time unit specifier
  1307. * \param[in] timestr String to parse
  1308. * \param[in] defunit Default unit type
  1309. * \param[out] result Resulting value, specified in milliseconds
  1310. * \retval 0 Success
  1311. * \retval -1 Failure
  1312. * \since 1.8
  1313. */
  1314. int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit);
  1315. /*!
  1316. * \since 12
  1317. * \brief Publish a MWI state update via stasis
  1318. *
  1319. * \param[in] mailbox The mailbox identifier string.
  1320. * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
  1321. * \param[in] new_msgs The number of new messages in this mailbox
  1322. * \param[in] old_msgs The number of old messages in this mailbox
  1323. *
  1324. * \retval 0 Success
  1325. * \retval -1 Failure
  1326. */
  1327. #define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs) \
  1328. ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, NULL, NULL)
  1329. /*!
  1330. * \since 12
  1331. * \brief Publish a MWI state update associated with some channel
  1332. *
  1333. * \param[in] mailbox The mailbox identifier string.
  1334. * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
  1335. * \param[in] new_msgs The number of new messages in this mailbox
  1336. * \param[in] old_msgs The number of old messages in this mailbox
  1337. * \param[in] channel_id A unique identifier for a channel associated with this
  1338. * change in mailbox state
  1339. *
  1340. * \retval 0 Success
  1341. * \retval -1 Failure
  1342. */
  1343. #define ast_publish_mwi_state_channel(mailbox, context, new_msgs, old_msgs, channel_id) \
  1344. ast_publish_mwi_state_full(mailbox, context, new_msgs, old_msgs, channel_id, NULL)
  1345. /*!
  1346. * \since 12
  1347. * \brief Publish a MWI state update via stasis with all parameters
  1348. *
  1349. * \param[in] mailbox The mailbox identifier string.
  1350. * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
  1351. * \param[in] new_msgs The number of new messages in this mailbox
  1352. * \param[in] old_msgs The number of old messages in this mailbox
  1353. * \param[in] channel_id A unique identifier for a channel associated with this
  1354. * change in mailbox state
  1355. * \param[in] eid The EID of the server that originally published the message
  1356. *
  1357. * \retval 0 Success
  1358. * \retval -1 Failure
  1359. */
  1360. int ast_publish_mwi_state_full(
  1361. const char *mailbox,
  1362. const char *context,
  1363. int new_msgs,
  1364. int old_msgs,
  1365. const char *channel_id,
  1366. struct ast_eid *eid);
  1367. /*!
  1368. * \since 12.2.0
  1369. * \brief Delete MWI state cached by stasis
  1370. *
  1371. * \param[in] mailbox The mailbox identifier string.
  1372. * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
  1373. *
  1374. * \retval 0 Success
  1375. * \retval -1 Failure
  1376. */
  1377. #define ast_delete_mwi_state(mailbox, context) \
  1378. ast_delete_mwi_state_full(mailbox, context, NULL)
  1379. /*!
  1380. * \since 12.2.0
  1381. * \brief Delete MWI state cached by stasis with all parameters
  1382. *
  1383. * \param[in] mailbox The mailbox identifier string.
  1384. * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
  1385. * \param[in] eid The EID of the server that originally published the message
  1386. *
  1387. * \retval 0 Success
  1388. * \retval -1 Failure
  1389. */
  1390. int ast_delete_mwi_state_full(const char *mailbox, const char *context, struct ast_eid *eid);
  1391. /*! \addtogroup StasisTopicsAndMessages
  1392. * @{
  1393. */
  1394. /*!
  1395. * \brief The structure that contains MWI state
  1396. * \since 12
  1397. */
  1398. struct ast_mwi_state {
  1399. AST_DECLARE_STRING_FIELDS(
  1400. AST_STRING_FIELD(uniqueid); /*!< Unique identifier for this mailbox */
  1401. );
  1402. int new_msgs; /*!< The current number of new messages for this mailbox */
  1403. int old_msgs; /*!< The current number of old messages for this mailbox */
  1404. /*! If applicable, a snapshot of the channel that caused this MWI change */
  1405. struct ast_channel_snapshot *snapshot;
  1406. struct ast_eid eid; /*!< The EID of the server where this message originated */
  1407. };
  1408. /*!
  1409. * \brief Object that represents an MWI update with some additional application
  1410. * defined data
  1411. */
  1412. struct ast_mwi_blob {
  1413. struct ast_mwi_state *mwi_state; /*!< MWI state */
  1414. struct ast_json *blob; /*!< JSON blob of data */
  1415. };
  1416. /*!
  1417. * \since 12
  1418. * \brief Create a \ref ast_mwi_state object
  1419. *
  1420. * \param[in] mailbox The mailbox identifier string.
  1421. * \param[in] context The context this mailbox resides in (NULL or "" if only using mailbox)
  1422. *
  1423. * \retval \ref ast_mwi_state object on success
  1424. * \retval NULL on error
  1425. */
  1426. struct ast_mwi_state *ast_mwi_create(const char *mailbox, const char *context);
  1427. /*!
  1428. * \since 12
  1429. * \brief Creates a \ref ast_mwi_blob message.
  1430. *
  1431. * The \a blob JSON object requires a \c "type" field describing the blob. It
  1432. * should also be treated as immutable and not modified after it is put into the
  1433. * message.
  1434. *
  1435. * \param mwi_state MWI state associated with the update
  1436. * \param message_type The type of message to create
  1437. * \param blob JSON object representing the data.
  1438. * \return \ref ast_mwi_blob message.
  1439. * \return \c NULL on error
  1440. */
  1441. struct stasis_message *ast_mwi_blob_create(struct ast_mwi_state *mwi_state,
  1442. struct stasis_message_type *message_type,
  1443. struct ast_json *blob);
  1444. /*!
  1445. * \brief Get the \ref stasis topic for MWI messages
  1446. * \retval The topic structure for MWI messages
  1447. * \retval NULL if it has not been allocated
  1448. * \since 12
  1449. */
  1450. struct stasis_topic *ast_mwi_topic_all(void);
  1451. /*!
  1452. * \brief Get the \ref stasis topic for MWI messages on a unique ID
  1453. * \param uniqueid The unique id for which to get the topic
  1454. * \retval The topic structure for MWI messages for a given uniqueid
  1455. * \retval NULL if it failed to be found or allocated
  1456. * \since 12
  1457. */
  1458. struct stasis_topic *ast_mwi_topic(const char *uniqueid);
  1459. /*!
  1460. * \brief Get the \ref stasis caching topic for MWI messages
  1461. * \retval The caching topic structure for MWI messages
  1462. * \retval NULL if it has not been allocated
  1463. * \since 12
  1464. */
  1465. struct stasis_topic *ast_mwi_topic_cached(void);
  1466. /*!
  1467. * \brief Backend cache for ast_mwi_topic_cached().
  1468. * \retval Cache of \ref ast_mwi_state.
  1469. */
  1470. struct stasis_cache *ast_mwi_state_cache(void);
  1471. /*!
  1472. * \brief Get the \ref stasis message type for MWI messages
  1473. * \retval The message type structure for MWI messages
  1474. * \retval NULL on error
  1475. * \since 12
  1476. */
  1477. struct stasis_message_type *ast_mwi_state_type(void);
  1478. /*!
  1479. * \brief Get the \ref stasis message type for voicemail application specific messages
  1480. *
  1481. * This message type exists for those messages a voicemail application may wish to send
  1482. * that have no logical relationship with other voicemail applications. Voicemail apps
  1483. * that use this message type must pass a \ref ast_mwi_blob. Any extraneous information
  1484. * in the JSON blob must be packed as key/value pair tuples of strings.
  1485. *
  1486. * At least one key/value tuple must have a key value of "Event".
  1487. *
  1488. * \retval The \ref stasis_message_type for voicemail application specific messages
  1489. * \retval NULL on error
  1490. * \since 12
  1491. */
  1492. struct stasis_message_type *ast_mwi_vm_app_type(void);
  1493. /*!
  1494. * \brief Get the \ref stasis topic for queue messages
  1495. * \retval The topic structure for queue messages
  1496. * \retval NULL if it has not been allocated
  1497. * \since 12
  1498. */
  1499. struct stasis_topic *ast_queue_topic_all(void);
  1500. /*!
  1501. * \brief Get the \ref stasis topic for queue messages for a particular queue name
  1502. * \param queuename The name for which to get the topic
  1503. * \retval The topic structure for queue messages for a given name
  1504. * \retval NULL if it failed to be found or allocated
  1505. * \since 12
  1506. */
  1507. struct stasis_topic *ast_queue_topic(const char *queuename);
  1508. /*! @} */
  1509. /*!
  1510. * \brief Initialize the application core
  1511. * \retval 0 Success
  1512. * \retval -1 Failure
  1513. * \since 12
  1514. */
  1515. int app_init(void);
  1516. #define AST_MAX_MAILBOX_UNIQUEID (AST_MAX_EXTENSION + AST_MAX_CONTEXT + 2)
  1517. #if defined(__cplusplus) || defined(c_plusplus)
  1518. }
  1519. #endif
  1520. #endif /* _ASTERISK_APP_H */