[asterisk-commits] dvossel: branch group/aoc r251628 - in /team/group/aoc: include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 10 12:01:40 CST 2010
Author: dvossel
Date: Wed Mar 10 12:01:36 2010
New Revision: 251628
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251628
Log:
beginnings of the AOCMessage manager action
Modified:
team/group/aoc/include/asterisk/aoc.h
team/group/aoc/main/aoc.c
team/group/aoc/main/manager.c
Modified: team/group/aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/include/asterisk/aoc.h?view=diff&rev=251628&r1=251627&r2=251628
==============================================================================
--- team/group/aoc/include/asterisk/aoc.h (original)
+++ team/group/aoc/include/asterisk/aoc.h Wed Mar 10 12:01:36 2010
@@ -28,7 +28,7 @@
/* AOC enums */
enum ast_aoc_currency_multiplier {
- AOC_MULT_ONETHOUSANDTH,
+ AOC_MULT_ONETHOUSANDTH = 1,
AOC_MULT_ONEHUNDREDTH,
AOC_MULT_ONETENTH,
AOC_MULT_ONE,
@@ -43,6 +43,7 @@
AOC_BILLING_REVERSE_CHARGE,
AOC_BILLING_CREDIT_CARD,
AOC_BILLING_CALL_FWD_UNCONDITIONAL,
+ AOC_BILLING_CALL_FWD_BUSY,
AOC_BILLING_CALL_FWD_NO_REPLY,
AOC_BILLING_CALL_DEFLECTION,
AOC_BILLING_CALL_TRANSFER,
@@ -56,7 +57,7 @@
};
enum ast_aoc_charge_type {
- AOC_CHARGE_NA,
+ AOC_CHARGE_NA = 0,
AOC_CHARGE_FREE,
AOC_CHARGE_CURRENCY,
AOC_CHARGE_UNIT, /* make sure unit is always the last enum here */
Modified: team/group/aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/main/aoc.c?view=diff&rev=251628&r1=251627&r2=251628
==============================================================================
--- team/group/aoc/main/aoc.c (original)
+++ team/group/aoc/main/aoc.c Wed Mar 10 12:01:36 2010
@@ -31,7 +31,6 @@
#include "asterisk/strings.h"
#include "asterisk/_private.h"
-
/* Encoded Payload Flags */
#define AOC_ENCODED_TYPE_REQUEST ((0 << 0) | (0 << 1))
#define AOC_ENCODED_TYPE_D (1 << 0)
@@ -460,7 +459,12 @@
}
decoded->currency_amount = amount;
- decoded->multiplier = multiplier;
+
+ if (multiplier <= AOC_MULT_THOUSAND && multiplier >= AOC_MULT_ONETHOUSANDTH) {
+ decoded->multiplier = multiplier;
+ } else {
+ decoded->multiplier = AOC_MULT_ONE;
+ }
return 0;
Modified: team/group/aoc/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/main/manager.c?view=diff&rev=251628&r1=251627&r2=251628
==============================================================================
--- team/group/aoc/main/manager.c (original)
+++ team/group/aoc/main/manager.c Wed Mar 10 12:01:36 2010
@@ -74,6 +74,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/features.h"
#include "asterisk/security_events.h"
+#include "asterisk/aoc.h"
/*** DOCUMENTATION
<manager name="Ping" language="en_US">
@@ -3372,6 +3373,145 @@
return NULL;
}
+
+static int action_aocmessage(struct mansession *s, const struct message *m)
+{
+ const char *channel = astman_get_header(m, "Channel");
+ const char *msgtype = astman_get_header(m, "MsgType");
+ const char *chargetype = astman_get_header(m, "ChargeType");
+// const char *currencyname = astman_get_header(m, "CurrencyName");
+ const char *currencyamount = astman_get_header(m, "CurrencyAmount");
+ const char *mult = astman_get_header(m, "CurrencyMultiplier");
+ const char *totaltype = astman_get_header(m, "TotalType");
+ const char *aocebillingid = astman_get_header(m, "AOCEBillingId");
+ const char *aocdbillingid = astman_get_header(m, "AOCDBillingId");
+// const char *association_id= astman_get_header(m, "ChargingAssociationId");
+// const char *association_num = astman_get_header(m, "ChargingAssociationNumber");
+// const char *actionid = astman_get_header(m, "ActionId");
+
+ enum ast_aoc_type _msgtype;
+ enum ast_aoc_charge_type _chargetype;
+ enum ast_aoc_currency_multiplier _mult = AOC_MULT_ONE;
+ enum ast_aoc_total_type _totaltype = AOC_TOTAL;
+ enum ast_aoc_billing_id _billingid = AOC_BILLING_NA;
+ unsigned int _currencyamount = 0;
+// int _association_id;
+ struct ast_channel *chan;
+
+ if (ast_strlen_zero(channel)) {
+ astman_send_error(s, m, "Channel not specified");
+ return 0;
+ }
+
+ if (!(chan = ast_channel_get_by_name(channel))) {
+ astman_send_error(s, m, "No such channel");
+ return 0;
+ }
+
+ if (ast_strlen_zero(msgtype) || (strcasecmp(msgtype, "d") && strcasecmp(msgtype, "e"))) {
+ astman_send_error(s, m, "Invalid MsgType");
+ return 0;
+ }
+
+ if (ast_strlen_zero(chargetype)) {
+ astman_send_error(s, m, "ChargeType not specified");
+ return 0;
+ }
+
+ _msgtype = strcasecmp(msgtype, "d") ? AOC_E : AOC_D;
+
+ if (!strcasecmp(chargetype, "NA")) {
+ _chargetype = AOC_CHARGE_NA;
+ } else if (!strcasecmp(chargetype, "Free")) {
+ _chargetype = AOC_CHARGE_FREE;
+ } else if (!strcasecmp(chargetype, "Currency")) {
+ _chargetype = AOC_CHARGE_CURRENCY;
+ } else if (!strcasecmp(chargetype, "Unit")) {
+ _chargetype = AOC_CHARGE_UNIT;
+ } else {
+ astman_send_error(s, m, "Invalid ChargeType");
+ return 0;
+ }
+
+ if (_chargetype == AOC_CHARGE_CURRENCY) {
+
+ if (!ast_strlen_zero(currencyamount) && (sscanf(currencyamount, "%30u", &_currencyamount) != 1)) {
+ astman_send_error(s, m, "Invalid CurrencyAmount");
+ }
+
+ if (ast_strlen_zero(mult)) {
+ /* if mult is zero len, ignore this is optional */
+ } else if (!strcasecmp(mult, "onethousandth")) {
+ _mult = AOC_MULT_ONETHOUSANDTH;
+ } else if (!strcasecmp(mult, "onehundredth")) {
+ _mult = AOC_MULT_ONEHUNDREDTH;
+ } else if (!strcasecmp(mult, "onetenth")) {
+ _mult = AOC_MULT_ONETENTH;
+ } else if (!strcasecmp(mult, "one")) {
+ _mult = AOC_MULT_ONE;
+ } else if (!strcasecmp(mult, "ten")) {
+ _mult = AOC_MULT_TEN;
+ } else if (!strcasecmp(mult, "hundred")) {
+ _mult = AOC_MULT_HUNDRED;
+ } else if (!strcasecmp(mult, "thousand")) {
+ _mult = AOC_MULT_THOUSAND;
+ } else {
+ astman_send_error(s, m, "Invalid ChargeMultiplier");
+ return 0;
+ }
+
+ } else if (_chargetype == AOC_CHARGE_UNIT) {
+ /*TODO handle the unit stuffs */
+ }
+
+
+ if (_msgtype == AOC_D) {
+ if (!ast_strlen_zero(totaltype) && !strcasecmp(totaltype, "subtotal")) {
+ _totaltype = AOC_SUBTOTAL;
+ }
+
+ if (!ast_strlen_zero(aocdbillingid)) {
+ /* ignore this is optional */
+ } else if (!strcasecmp(aocdbillingid, "Normal")) {
+ _billingid = AOC_BILLING_NORMAL;
+ } else if (!strcasecmp(aocdbillingid, "ReverseCharge")) {
+ _billingid = AOC_BILLING_REVERSE_CHARGE;
+ } else if (!strcasecmp(aocdbillingid, "CreditCard")) {
+ _billingid = AOC_BILLING_CREDIT_CARD;
+ } else {
+ astman_send_error(s, m, "Invalid AOCDBillingId");
+ return 0;
+ }
+ } else {
+ if (!ast_strlen_zero(aocebillingid)) {
+ /* ignore this is optional */
+ } else if (!strcasecmp(aocebillingid, "Normal")) {
+ _billingid = AOC_BILLING_NORMAL;
+ } else if (!strcasecmp(aocebillingid, "ReverseCharge")) {
+ _billingid = AOC_BILLING_REVERSE_CHARGE;
+ } else if (!strcasecmp(aocebillingid, "CreditCard")) {
+ _billingid = AOC_BILLING_CREDIT_CARD;
+ } else if (!strcasecmp(aocebillingid, "CallFwdUnconditional")) {
+ _billingid = AOC_BILLING_CALL_FWD_UNCONDITIONAL;
+ } else if (!strcasecmp(aocebillingid, "CallFwdBusy")) {
+ _billingid = AOC_BILLING_CALL_FWD_BUSY;
+ } else if (!strcasecmp(aocebillingid, "CallFwdNoReply")) {
+ _billingid = AOC_BILLING_CALL_FWD_NO_REPLY;
+ } else if (!strcasecmp(aocebillingid, "CallDeflection")) {
+ _billingid = AOC_BILLING_CALL_DEFLECTION;
+ } else if (!strcasecmp(aocebillingid, "CallTransfer")) {
+ _billingid = AOC_BILLING_CALL_TRANSFER;
+ } else {
+ astman_send_error(s, m, "Invalid AOCEBillingId");
+ return 0;
+ }
+ }
+
+//charging association crap
+
+ return 0;
+}
+
static int action_originate(struct mansession *s, const struct message *m)
{
const char *name = astman_get_header(m, "Channel");
@@ -5584,6 +5724,7 @@
ast_manager_register_xml("CoreShowChannels", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coreshowchannels);
ast_manager_register_xml("ModuleLoad", EVENT_FLAG_SYSTEM, manager_moduleload);
ast_manager_register_xml("ModuleCheck", EVENT_FLAG_SYSTEM, manager_modulecheck);
+ ast_manager_register_xml("AOCMessage", EVENT_FLAG_CALL, action_aocmessage);
ast_cli_register_multiple(cli_manager, ARRAY_LEN(cli_manager));
ast_extension_state_add(NULL, NULL, manager_state_cb, NULL);
More information about the asterisk-commits
mailing list