[asterisk-commits] rmudgett: branch dvossel/generic_aoc r258763 - in /team/dvossel/generic_aoc: ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 22 18:45:10 CDT 2010
Author: rmudgett
Date: Thu Apr 22 18:44:59 2010
New Revision: 258763
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=258763
Log:
AOC-D was missing some SubTotal/Total charge handling.
Modified:
team/dvossel/generic_aoc/channels/sig_pri.c
team/dvossel/generic_aoc/main/aoc.c
team/dvossel/generic_aoc/tests/test_aoc.c
Modified: team/dvossel/generic_aoc/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/channels/sig_pri.c?view=diff&rev=258763&r1=258762&r2=258763
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Thu Apr 22 18:44:59 2010
@@ -2164,8 +2164,11 @@
}
for (idx = 0; idx < aoc_s->num_items; ++idx) {
- int charged_item = sig_pri_aoc_charged_item_to_ast(aoc_s->item[idx].chargeable);
- if (aoc_s->item[idx].chargeable == PRI_AOC_CHARGED_ITEM_NOT_AVAILABLE) {
+ enum ast_aoc_s_charged_item charged_item;
+
+ charged_item = sig_pri_aoc_charged_item_to_ast(aoc_s->item[idx].chargeable);
+ if (charged_item == AST_AOC_CHARGED_ITEM_NA) {
+ /* Delete the unknown charged item from the list. */
continue;
}
switch (aoc_s->item[idx].rate_type) {
@@ -2311,7 +2314,6 @@
*/
static void sig_pri_aoc_d_from_pri(const struct pri_subcmd_aoc_d *aoc_d, struct ast_channel *owner, int passthrough)
{
-
struct ast_aoc_decoded *decoded = NULL;
struct ast_aoc_encoded *encoded = NULL;
size_t encoded_size = 0;
@@ -2340,6 +2342,19 @@
return;
}
+ switch (aoc_d->billing_accumulation) {
+ default:
+ ast_debug(1, "AOC-D billing accumulation has unknown value: %d\n",
+ aoc_d->billing_accumulation);
+ /* Fall through */
+ case 0:/* subTotal */
+ ast_aoc_set_total_type(decoded, AST_AOC_SUBTOTAL);
+ break;
+ case 1:/* total */
+ ast_aoc_set_total_type(decoded, AST_AOC_TOTAL);
+ break;
+ }
+
switch (aoc_d->billing_id) {
case PRI_AOC_D_BILLING_ID_NORMAL:
ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NORMAL);
@@ -2353,6 +2368,7 @@
case PRI_AOC_D_BILLING_ID_NOT_AVAILABLE:
default:
ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+ break;
}
switch (aoc_d->charge) {
@@ -2374,6 +2390,7 @@
aoc_d->recorded.unit.item[i].type);
}
}
+ break;
}
if (passthrough && (encoded = ast_aoc_encode(decoded, &encoded_size, owner))) {
@@ -2533,7 +2550,6 @@
break;
}
- aoc_s.num_items++;
aoc_s.item[idx].chargeable = sig_pri_aoc_charged_item_to_pri(entry->charged_item);
switch (entry->rate_type) {
@@ -2555,7 +2571,6 @@
entry->rate.duration.currency_name,
sizeof(aoc_s.item[idx].rate.duration.currency));
}
-
break;
case AST_AOC_RATE_TYPE_FLAT:
aoc_s.item[idx].rate_type = PRI_AOC_RATE_TYPE_FLAT;
@@ -2592,12 +2607,13 @@
case AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING:
aoc_s.item[idx].rate_type = PRI_AOC_RATE_TYPE_FREE_FROM_BEGINNING;
break;
+ default:
case AST_AOC_RATE_TYPE_NA:
- default:
aoc_s.item[idx].rate_type = PRI_AOC_RATE_TYPE_NOT_AVAILABLE;
break;
}
}
+ aoc_s.num_items = idx;
/* if this rate should be sent as a response to an AOC-S request we will
* have an aoc_s_request_invoke_id associated with this pvt */
@@ -2626,6 +2642,7 @@
static void sig_pri_aoc_d_from_ast(struct sig_pri_chan *pvt, struct ast_aoc_decoded *decoded)
{
struct pri_subcmd_aoc_d aoc_d = { 0, };
+
aoc_d.billing_accumulation = (ast_aoc_get_total_type(decoded) == AST_AOC_TOTAL) ? 1 : 0;
switch (ast_aoc_get_billing_id(decoded)) {
Modified: team/dvossel/generic_aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/main/aoc.c?view=diff&rev=258763&r1=258762&r2=258763
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Thu Apr 22 18:44:59 2010
@@ -1010,6 +1010,31 @@
/*!
* \internal
+ * \brief Convert ast_aoc_total_type to string.
+ * \since 1.8
+ *
+ * \param value Value to convert to string.
+ *
+ * \return String equivalent.
+ */
+static const char *aoc_type_of_totaling_str(enum ast_aoc_total_type value)
+{
+ const char *str;
+
+ switch (value) {
+ default:
+ case AST_AOC_SUBTOTAL:
+ str = "SubTotal";
+ break;
+ case AST_AOC_TOTAL:
+ str = "Total";
+ break;
+ }
+ return str;
+}
+
+/*!
+ * \internal
* \brief Convert ast_aoc_rate_type to string.
* \since 1.8
*
@@ -1366,15 +1391,19 @@
charge_str = aoc_charge_type_str(decoded->charge_type);
ast_str_append(msg, 0, "Type: %s\r\n", charge_str);
+
switch (decoded->charge_type) {
case AST_AOC_CHARGE_CURRENCY:
case AST_AOC_CHARGE_UNIT:
ast_str_append(msg, 0, "BillingID: %s\r\n",
aoc_billingid_str(decoded->billing_id));
+ ast_str_append(msg, 0, "TypeOfCharging: %s\r\n",
+ aoc_type_of_totaling_str(decoded->total_type));
break;
default:
break;
}
+
switch (decoded->charge_type) {
case AST_AOC_CHARGE_CURRENCY:
ast_str_append(msg, 0, "%s: %s\r\n", charge_str,
Modified: team/dvossel/generic_aoc/tests/test_aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/tests/test_aoc.c?view=diff&rev=258763&r1=258762&r2=258763
==============================================================================
--- team/dvossel/generic_aoc/tests/test_aoc.c (original)
+++ team/dvossel/generic_aoc/tests/test_aoc.c Thu Apr 22 18:44:59 2010
@@ -86,8 +86,12 @@
goto cleanup_aoc_event_test;
}
if (strncmp(ast_str_buffer(msg),
- "AOC-D\r\nType: Currency\r\nBillingID: CreditCard\r\n"
- "Currency: usd\r\nCurrency/Amount/Cost: 100\r\n"
+ "AOC-D\r\n"
+ "Type: Currency\r\n"
+ "BillingID: CreditCard\r\n"
+ "TypeOfCharging: SubTotal\r\n"
+ "Currency: usd\r\n"
+ "Currency/Amount/Cost: 100\r\n"
"Currency/Amount/Multiplier: 1\r\n",
strlen(ast_str_buffer(msg)))) {
More information about the asterisk-commits
mailing list