Пример #1
0
TInt CSCPParamDB :: ListEntriesL(RArray <TInt32>& aNumCols, RPointerArray <HBufC>& aDesCols, const TInt32 aApp) {
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() >>>"));
    
    RDbView lDBView;
    CleanupClosePushL(lDBView);
    
    HBufC* lSelectQry(NULL);
    
    if(aApp == -1) {
        lSelectQry = HBufC :: NewLC(KSelectAll().Length() + 50);
        lSelectQry->Des().Format(KSelectAll);
    }
    else {
        lSelectQry = HBufC :: NewLC(KSelectWhereAppId().Length() + 30);
        lSelectQry->Des().Format(KSelectWhereAppId, aApp);
    }
    
    __LEAVE_IF_ERROR(lDBView.Prepare(iParameterDB, TDbQuery(*lSelectQry)));
    __LEAVE_IF_ERROR(lDBView.EvaluateAll());

    TInt lRet(KErrNone);
    TBool lStatus(EFalse);
    
    TRAP(lRet, lStatus = lDBView.FirstL());
    
    if(lRet == KErrNone && lStatus) {
        do {
            lDBView.GetL();

            aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColParamId)));
            aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColAppId)));
            aNumCols.AppendL(lDBView.ColInt(iColSet->ColNo(KColValueInt)));           

            TPtrC lValueDes = lDBView.ColDes16(iColSet->ColNo(KColValueDes));
            HBufC* lBuff = HBufC :: NewL(lValueDes.Length());
            lBuff->Des().Append(lValueDes);
            aDesCols.AppendL(lBuff);
        }
        while(lDBView.NextL());
    }
    
    _SCPDB_LOG(_L("[CSCPParamDB]-> ListEntries() <<<"));
    CleanupStack :: PopAndDestroy(2);
    return KErrNone;
}
void eap_am_type_securid_symbian_c::type_configure_readL(
	eap_config_string field,
	const u32_t field_length,
	eap_variable_data_c * const data)
{
	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT,
		(EAPL("eap_am_type_securid_symbian_c::type_configure_readL(): 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()));

	EAP_UNREFERENCED_PARAMETER(field_length);

	// Create a buffer for the ascii strings - initialised with the argument
	HBufC16* unicodeBuf = HBufC16::NewLC(KMaxDBFieldNameLength);
	TPtr16 unicodeString = unicodeBuf->Des();

	TPtrC8 fieldPtr(reinterpret_cast<const TUint8 *> (field), field_length);

	unicodeString.Copy(fieldPtr);
			
	// Now do the database query
	
	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
	TPtr sqlStatement = buf->Des();

	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
	if (m_eap_type == eap_type_securid)
	{
		sqlStatement.Format(
			KSQLQueryRow,
			&unicodeString,
			&KSecurIDTableName, 
			&KServiceType,
			m_index_type,
			&KServiceIndex,
			m_index,
			&KTunnelingTypeVendorId,
			m_tunneling_type.get_vendor_id(),
			&KTunnelingType, 
			m_tunneling_type.get_vendor_type());
	}
	else
	{
		sqlStatement.Format(
			KSQLQueryRow,
			&unicodeString,
			&KGtcTableName, 
			&KServiceType,
			m_index_type,
			&KServiceIndex,
			m_index,
			&KTunnelingTypeVendorId,
			m_tunneling_type.get_vendor_id(),
			&KTunnelingType, 
			m_tunneling_type.get_vendor_type());
	}

	RDbView view;
	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
	CleanupClosePushL(view);
	
	User::LeaveIfError(view.EvaluateAll());	
	
	if (view.FirstL())
	{
		eap_status_e status = eap_status_ok;
		view.GetL();		

		switch (view.ColType(KDefaultColumnInView_One))
		{
		case EDbColText:
			{
				if (view.ColLength(KDefaultColumnInView_One) > 0)
				{
					TPtrC16 value = view.ColDes16(KDefaultColumnInView_One);

					eap_variable_data_c string_unicode(m_am_tools);

					status = string_unicode.set_copy_of_buffer(value.Ptr(), value.Size());
					if (status != eap_status_ok)
					{
						User::Leave(
							m_am_tools->convert_eapol_error_to_am_error(
								EAP_STATUS_RETURN(m_am_tools, status)));
					}

					status = m_am_tools->convert_unicode_to_utf8(
						*data,
						string_unicode);
					if (status != eap_status_ok)
					{
						User::Leave(
							m_am_tools->convert_eapol_error_to_am_error(
								EAP_STATUS_RETURN(m_am_tools, status)));
					}
				} 
				else 
				{
					data->reset();
					status = data->set_copy_of_buffer("", 0);
					if (status != eap_status_ok)
					{
						User::Leave(
							m_am_tools->convert_eapol_error_to_am_error(
								EAP_STATUS_RETURN(m_am_tools, status)));
					}
				}
			}
			break;

		case EDbColUint32:
			{
				TUint value = view.ColUint32(KDefaultColumnInView_One);
				status = data->set_copy_of_buffer(reinterpret_cast<unsigned char *> (&value), sizeof(value));
				if (status != eap_status_ok)
				{
					User::Leave(
						m_am_tools->convert_eapol_error_to_am_error(
							EAP_STATUS_RETURN(m_am_tools, status)));
				}
			}
			break;

		default:
			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Unexpected column type.\n")));
			User::Leave(KErrGeneral);
			break;
		}
	} 
	else 
	{
		// Could not find parameter
		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Could not find configuration parameter.\n")));
		User::Leave(KErrArgument);
	}		
	
	CleanupStack::PopAndDestroy(3); // Close view, 2 x buf

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
}