Пример #1
0
static int unload_module(void)
{
	if (event_sub) {
		event_sub = ast_event_unsubscribe(event_sub);
	}
	return 0;
}
static int load_config(int reload)
{
	const char *cat = NULL;
	struct ast_config *cfg;
	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
	struct ast_variable *v;
	int newenablecel = CEL_AMI_ENABLED_DEFAULT;
	int new_cel_show_user_def = CEL_SHOW_USERDEF_DEFAULT;

	cfg = ast_config_load(CONF_FILE, config_flags);
	if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
		return 0;
	}

	if (cfg == CONFIG_STATUS_FILEINVALID) {
		ast_log(LOG_WARNING, "Configuration file '%s' is invalid. CEL manager Module not activated.\n",
			CONF_FILE);
		enablecel = 0;
		return -1;
	} else if (!cfg) {
		ast_log(LOG_WARNING, "Failed to load configuration file. CEL manager Module not activated.\n");
		enablecel = 0;
		return -1;
	}

	while ((cat = ast_category_browse(cfg, cat))) {
		if (strcasecmp(cat, "manager")) {
			continue;
		}

		for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
			if (!strcasecmp(v->name, "enabled")) {
				newenablecel = ast_true(v->value) ? 1 : 0;
			} else if (!strcasecmp(v->name, "show_user_defined")) {
				new_cel_show_user_def = ast_true(v->value) ? 1 : 0;
			} else {
				ast_log(LOG_NOTICE, "Unknown option '%s' specified "
						"for cel_manager.\n", v->name);
			}
		}
	}

	ast_config_destroy(cfg);

	cel_show_user_def = new_cel_show_user_def;
	if (enablecel && !newenablecel) {
		if (event_sub) {
			event_sub = ast_event_unsubscribe(event_sub);
		}
	} else if (!enablecel && newenablecel) {
		event_sub = ast_event_subscribe(AST_EVENT_CEL, manager_log, "Manager Event Logging", NULL, AST_EVENT_IE_END);
		if (!event_sub) {
			ast_log(LOG_ERROR, "Unable to register Asterisk Call Manager CEL handling\n");
		}
	}
	enablecel = newenablecel;

	return 0;
}
Пример #3
0
static int unload_module(void)
{
    if (security_event_sub) {
        security_event_sub = ast_event_unsubscribe(security_event_sub);
    }

    ast_verb(3, "Security Logging Disabled\n");

    return 0;
}
Пример #4
0
static int unload_module(void)
{
	if (event_sub) {
		event_sub = ast_event_unsubscribe(event_sub);
	}
	if (rh) {
		rc_destroy(rh);
		rh = NULL;
	}
	return AST_MODULE_LOAD_SUCCESS;
}