示例#1
0
TInt CIPv6Binder::DeleteContext(TDes8& aContextParameters)
/**
 * Deletes a context. As the NIF is responsible for one primary context,
 * this is equivalent to closing down the NIF.
 *
 * @param aContextParameters Parameters of the context to delete
 * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone
 */
	{
	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_DELETECONTEXT_1, "CIPv6Binder::DeleteContext");

	if (aContextParameters.Length() != sizeof(TContextParameters))
		{
		return KErrArgument;
		}

	TUint8* ptr = CONST_CAST(TUint8*, aContextParameters.Ptr());
	TContextParameters* params = REINTERPRET_CAST(TContextParameters*, ptr);

	if (params->iContextInfo.iContextId != 
		STATIC_CAST(TInt8, GetFlow().GetBcaController()->Nsapi()))
		{
		params->iReasonCode = KErrBadName;
		}
	else
		{
		params->iReasonCode = KErrNone; 
		GetFlow().Stop(KErrNone, MNifIfNotify::EDisconnect);
		}

	return KErrNone;
	}
示例#2
0
void GenericCashFlow::AddFlow(QDate Dte, double Amt, qint32 FlowTpe)
{
    Q_D(GenericCashFlow);
	if (Dte.isNull()) return;
	if (qAbs(Amt) < 0.01) Amt = 0.0;
	if (d->m_AdjustHolidays) {
        while (IsHoliday(Dte))
            Dte=Dte.addDays(1); 
    }
    auto index = d->m_CashFlows.begin();
    for (; index != d->m_CashFlows.end(); ++index) {
        if (d->SamePeriod(Dte, index.key(), d->m_AggregationLevel))
            break;
	}
    if (index != d->m_CashFlows.end()) {
		//if (Amt== 0.0) return;
		Amt += GetFlow(index.key(), FlowTpe);
		if (qAbs(Amt) < 0.01)
            Amt = 0.0;
		if (index.value()->contains(FlowTpe)) {
            if (Amt == 0.0 && !d->m_Stocks.contains(FlowTpe))
                index.value()->remove(FlowTpe);
			else
                index.value()->operator[](FlowTpe) = Amt;
		}
		else {
            if (qAbs(Amt) > 0.0 || d->m_Stocks.contains(FlowTpe)) 
                index.value()->insert(FlowTpe, Amt);
		}
	}
	else {
        d->m_CashFlows.insert(Dte, std::make_shared<QHash<qint32, double> >());
		//if (qAbs(Amt) > 0.0) {
			Amt += GetFlow(Dte, FlowTpe);
			if (qAbs(Amt) < 0.01) 
                Amt = 0.0;
            if (qAbs(Amt) > 0.0 || d->m_Stocks.contains(FlowTpe)) 
                d->m_CashFlows[Dte]->insert(FlowTpe, Amt);
		//}
	}
}
示例#3
0
void GenericCashFlow::AddFlow(const GenericCashFlow& a) {
    Q_D(GenericCashFlow);
	QSet<qint32> StocksToCalculate;
	QHash<qint32,QSet<QDate> >DatesOfStockChange;
    d->m_Stocks.unite(a.d_func()->m_Stocks);
	qint32 FakeFlow = 0;
    while (d->m_Stocks.contains(FakeFlow)) ++FakeFlow;

	//Aggregate Flows
    for (auto i = a.d_func()->m_CashFlows.constBegin(); i != a.d_func()->m_CashFlows.constEnd(); ++i) {
		if (i.value()->isEmpty()) AddFlow(i.key(), 0.0, FakeFlow);
		else {
			for (QHash<qint32, double>::const_iterator j = i.value()->constBegin(); j != i.value()->constEnd(); ++j) {
                if (d->m_Stocks.contains(j.key())) {
					//Save stocks types to calculate later
					AddFlow(i.key(), 0.0, FakeFlow);
					StocksToCalculate.insert(j.key());
					DatesOfStockChange[j.key()].insert(i.key());
				}
				else AddFlow(i.key(), j.value(), j.key());
			}
		}
	}
    for (auto i = d->m_CashFlows.constBegin(); i != d->m_CashFlows.constEnd(); ++i) {
		for (auto j = i.value()->constBegin(); j != i.value()->constEnd(); ++j) {
            if (d->m_Stocks.contains(j.key())) {
				//Add stocks types already in cash flows
				StocksToCalculate.insert(j.key());
				DatesOfStockChange[j.key()].insert(i.key());
			}
		}
	}
	//Aggregate Stocks
    for (auto SingleStock = StocksToCalculate.constBegin(); SingleStock != StocksToCalculate.constEnd(); ++SingleStock) {
		auto CurrDates = DatesOfStockChange.value(*SingleStock, QSet<QDate>()).toList();
		std::sort(CurrDates.begin(), CurrDates.end(), std::greater<QDate>());
		for (auto i = CurrDates.constBegin(); i != CurrDates.constEnd(); ++i) {
			SetFlow(*i, GetFlow(*i, *SingleStock) + a.GetFlow(*i, *SingleStock), *SingleStock);
		}
	}
	//Aggregate Labels
    for (auto i = a.d_func()->m_CashFlowLabels.constBegin(); i != a.d_func()->m_CashFlowLabels.constEnd(); ++i) {
        if (!d->m_CashFlowLabels.contains(i.key()))
            d->m_CashFlowLabels.insert(i.key(), i.value());
	}
}
示例#4
0
double GenericCashFlow::GetFlow(int index, qint32 FlowTpe) const {
	return GetFlow(GetDate(index), FlowTpe);
}
示例#5
0
TInt CIPv6Binder::Control(TUint aLevel, TUint aName, TDes8& /*aOption*/)
/**
 * The main function called by the TCP/IP protocol to control the interface.
 * Can perform a variety of general IP tasks (such as getting IP config)
 * and "3G" specific tasks (such as deleting the context).
 *
 * @param aLevel The level of the interface to control - always KSOLInterface
 * @param aName The command to perform
 * @param aOption Data to be input/output as a result of the command
 * @return Standard error codes
 */
	{
	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_CONTROL_1, "CIPv6Binder::Control [aLevel=%u, aName=%u]",aLevel, aName);

	if (aLevel == KSOLInterface)
		{
		switch (aName)
			{
		case KSoIfHardwareAddr:
			// unsupported because we don't have a h/w address
			break;

		// 3G-specific configuration commands are below this point.
		
#ifdef WCDMA_STUB
		case KRegisterEventHandler:
			// Raw IP NIF Events are not supported
		case KContextSetEvents:
			// Raw IP NIF Events are not supported
			break;

		case KContextCreate:
			// We don't support creating new secondary contexts.
			break;

		case KContextDelete:
			// Deletes the primary PDP context. This will shut down the Nif.
			return DeleteContext(aOption);

		case KContextActivate:
			// If the IPv6 interface is up, then the context will already have
			// been activated. So this command should fail with 
			// KErrAlreadyExists
			{
			TUint8* ptr = CONST_CAST(TUint8*, aOption.Ptr()); 
			TContextParameters* contextParams =
				REINTERPRET_CAST(TContextParameters*, ptr);

			if (contextParams->iContextInfo.iContextId != 
				STATIC_CAST(TInt8, GetFlow().GetBcaController()->Nsapi()))
				{
				contextParams->iReasonCode = KErrNotFound;
				}
			else
				{
				contextParams->iContextInfo.iStatus =
					GetFlow().GetContextStatus();
				contextParams->iReasonCode = KErrAlreadyExists;
				}
			return KErrNone;
			}

		case KNifSetDefaultQoS:
		case KContextQoSSet:
			// Setting the QoS is meaningless over GPRS, so we just return that
			// we don't support these operations.
			break;

		case KContextTFTModify:
			// As we only have one primary context, we don't support anything
			// to do with traffic flow templates, which are used by secondary
			// contexts.
			break;

		case KContextModifyActive:
			// This command is only valid aftermodifying TFT/QoS parameters. 
			// As we don't support any of these operations,
			// this command is never valid.
			break;
#endif

		default:
			break;
			}
		}
	return KErrNotSupported;
	}