app_userevent.c File Reference

UserEvent application -- send manager event. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/manager.h"
#include "asterisk/app.h"
#include "asterisk/json.h"
#include "asterisk/stasis_channels.h"

Include dependency graph for app_userevent.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int unload_module (void)
static int userevent_exec (struct ast_channel *chan, const char *data)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Custom User Event Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static char * app = "UserEvent"
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

UserEvent application -- send manager event.

Definition in file app_userevent.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 133 of file app_userevent.c.

static void __unreg_module ( void   )  [static]

Definition at line 133 of file app_userevent.c.

static int load_module ( void   )  [static]

Definition at line 128 of file app_userevent.c.

References ast_register_application_xml, and userevent_exec().

00129 {
00130    return ast_register_application_xml(app, userevent_exec);
00131 }

static int unload_module ( void   )  [static]

Definition at line 123 of file app_userevent.c.

References ast_unregister_application().

00124 {
00125    return ast_unregister_application(app);
00126 }

static int userevent_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 70 of file app_userevent.c.

References args, AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_DECLARE_APP_ARGS, ast_json_object_set(), ast_json_pack(), ast_json_string_create(), ast_json_unref(), ast_log, ast_multi_object_blob_single_channel_publish(), ast_multi_user_event_type(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strip(), ast_strlen_zero, LOG_WARNING, NULL, parse(), RAII_VAR, strsep(), and value.

Referenced by load_module().

00071 {
00072    char *parse;
00073    int x;
00074    AST_DECLARE_APP_ARGS(args,
00075       AST_APP_ARG(eventname);
00076       AST_APP_ARG(extra)[100];
00077    );
00078    RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
00079 
00080    if (ast_strlen_zero(data)) {
00081       ast_log(LOG_WARNING, "UserEvent requires an argument (eventname,optional event body)\n");
00082       return -1;
00083    }
00084 
00085    parse = ast_strdupa(data);
00086 
00087    AST_STANDARD_APP_ARGS(args, parse);
00088 
00089    blob = ast_json_pack("{s: s}",
00090               "eventname", args.eventname);
00091    if (!blob) {
00092       return -1;
00093    }
00094 
00095    for (x = 0; x < args.argc - 1; x++) {
00096       char *key, *value = args.extra[x];
00097       struct ast_json *json_value;
00098 
00099       key = strsep(&value, ":");
00100       if (!value) {
00101          /* no ':' in string? */
00102          continue;
00103       }
00104 
00105       value = ast_strip(value);
00106       json_value = ast_json_string_create(value);
00107       if (!json_value) {
00108          return -1;
00109       }
00110 
00111       /* ref stolen by ast_json_object_set */
00112       if (ast_json_object_set(blob, key, json_value)) {
00113          return -1;
00114       }
00115    }
00116 
00117    ast_channel_lock(chan);
00118    ast_multi_object_blob_single_channel_publish(chan, ast_multi_user_event_type(), blob);
00119    ast_channel_unlock(chan);
00120    return 0;
00121 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Custom User Event Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 133 of file app_userevent.c.

char* app = "UserEvent" [static]

Definition at line 68 of file app_userevent.c.

Definition at line 133 of file app_userevent.c.


Generated on Thu Apr 16 06:28:47 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6