// --------------------------------
// CNSmlRoamTable::GetItemIAPL( TInt aProfileId, TInt aPriority )
// Return IAP for profile id and priority
// --------------------------------
//
EXPORT_C TUint32 CNSmlRoamTable::GetItemIAPL( TInt aProfileId, TInt aPriority )
	{
	RDbView view;
	CleanupClosePushL(view);

	TUint32 uint(0);
	TBuf<KNSmlMaxSQLLength> sqlBuf;
	sqlBuf.Format( KSQLSelectUint, aProfileId, aPriority );

	view.Prepare(iDatabase, TDbQuery( sqlBuf ));
	view.EvaluateAll();

	if ( view.IsEmptyL() )
		{		
		User::Leave( KErrNotFound );
		}
	
	view.FirstL();
	view.GetL();

	uint = view.ColUint( iColSet->ColNo( KColIapId ));
	
	CleanupStack::PopAndDestroy(); //view

	return uint;
	}
示例#2
0
// ---------------------------------------------------------------------------
// CFotaDB::RowToStateL
// Extracts db row contents to package state object and aPkgUrl
// Returns url in aPkgURL parameter
// ---------------------------------------------------------------------------
TPackageState CFotaDB::RowToStateL(HBufC8*& aPkgUrl, const RDbView& aView)
    {
    TPackageState s;
    TInt pkgid = aView.ColInt(iColSet->ColNo(KColPkgId));
    TInt state = aView.ColInt(iColSet->ColNo(KColState));
    TInt result = aView.ColInt(iColSet->ColNo(KColResult));
    TSmlProfileId profileid(aView.ColInt(iColSet->ColNo(KColProfileId)));
    TPtrC pkgname = aView.ColDes(iColSet->ColNo(KColPkgName));
    TPtrC version = aView.ColDes(iColSet->ColNo(KColVersion));
    TInt smltrycount = aView.ColInt(iColSet->ColNo(KColSmlTryCount));
    TInt sessiontype = aView.ColInt(iColSet->ColNo(KColSessionType));
    TInt iapid = aView.ColInt(iColSet->ColNo(KColIapId));
    TUint pkgsize = aView.ColUint(iColSet->ColNo(KColPkgSize));
    TBool updateltr = aView.ColUint8(iColSet->ColNo(KColUpdateLtr));

    s.iPkgId = pkgid;
    s.iPkgName.Copy(pkgname);
    s.iPkgVersion.Copy(version);
    s.iProfileId = profileid;
    s.iResult = result;
    s.iState = RFotaEngineSession::TState(state);
    s.iSmlTryCount = smltrycount;
    s.iSessionType = sessiontype;
    s.iIapId = iapid;
    s.iPkgSize = pkgsize;
    s.iUpdateLtr = updateltr;

    RDbColReadStream rstream;
    TInt len = aView.ColLength(iColSet->ColNo(KColPkgUrl));
    rstream.OpenLC(aView, iColSet->ColNo(KColPkgUrl));
    HBufC* pkgurl = HBufC::NewLC(len);
    TPtr ptr = pkgurl->Des();
    rstream.ReadL(ptr, len);

    HBufC8* tmp = HBufC8::NewL(pkgurl->Des().Length());
    tmp->Des().Copy(pkgurl->Des());
    aPkgUrl = tmp;

    CleanupStack::PopAndDestroy(pkgurl);
    CleanupStack::PopAndDestroy(&rstream);
    return s;
    }
TInt eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL()
	{

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): m_index_type=%d, m_index=%d, m_tunneling_type=0xfe%06x%08x\n"),
		m_index_type,
		m_index,
		m_tunneling_type.get_vendor_id(),
		m_tunneling_type.get_vendor_type()));

	TInt status = KErrNone;
	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
	TPtr sqlStatement = buf->Des();
	
	// Query all the relevant parameters
	_LIT(KSQLQuery, "SELECT %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
	
	sqlStatement.Format(
		KSQLQuery,
		&cf_str_EAP_GTC_passcode_prompt_literal,
		&cf_str_EAP_GTC_identity_literal,
		&cf_str_EAP_GTC_passcode_literal,
		&KGtcTableName,
		&KServiceType,
		m_index_type, 
		&KServiceIndex,
		m_index,
		&KTunnelingTypeVendorId,
		m_tunneling_type.get_vendor_id(),
		&KTunnelingType, 
		m_tunneling_type.get_vendor_type());
	

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): Reads database\n")));

	RDbView view;
	// Evaluate view
	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
	CleanupClosePushL(view);
	
	User::LeaveIfError(view.EvaluateAll());
	
	// Get the first (and only) row
	view.FirstL();
	view.GetL();
	
	// Get column set so we get the correct column numbers
	CDbColSet* colSet = view.ColSetL();
	CleanupStack::PushL(colSet);

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): Reads database\n")));

	TPtrC username = view.ColDes(colSet->ColNo( cf_str_EAP_GTC_identity_literal ) );

	EAP_TRACE_DATA_DEBUG(
		m_am_tools,
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): username"),
		username.Ptr(),
		username.Size()));

	TPtrC password = view.ColDes(colSet->ColNo( cf_str_EAP_GTC_passcode_literal ) );

	EAP_TRACE_DATA_DEBUG(
		m_am_tools,
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): password"),
		password.Ptr(),
		password.Size()));

	TUint prompt = view.ColUint(colSet->ColNo(cf_str_EAP_GTC_passcode_prompt_literal));

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): prompt=%d\n"),
		prompt));


	if ((EEapDbFalse != prompt)
		 || (username.Size() == 0) 
		 || (password.Size() == 0))
		{

		if (username.Size() == 0)
			{
			m_dialog_data_ptr->iUsername.Zero();
			}
		else
			{
			m_dialog_data_ptr->iUsername.Copy(username);
			}

		status = KErrCancel;
		}
	else
		{
		status = KErrNone;	
		m_dialog_data_ptr->iUsername.Copy(username);
		m_dialog_data_ptr->iPassword.Copy(password);
		}
		
	CleanupStack::PopAndDestroy(colSet); // Delete colSet.
	CleanupStack::PopAndDestroy(&view); // Close view.
	CleanupStack::PopAndDestroy(buf); // Delete buf.
		
	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): status=%d\n"),
		status));

	return status;
	}