示例#1
0
/*============================================================================

  Description: See documentation for standard C library fopen

  ==========================================================================*/
ChEXPORT SYMBIAN_FILE* symbian_fopen( const char* in_name, const char* in_mode)
{
    ChUINT4       i =     0;
    TFileName*    pName = ChNEW TFileName;
    CleanupStack::PushL(pName);
    TFileName*    pMode = ChNEW TFileName;
    CleanupStack::PushL(pMode);
    SYMBIAN_FILE* result = NULL;

    for (i = 0; i < strlen(in_name); i++)
    {
        pName->Append(in_name[i]);
    }
    pName->ZeroTerminate();

    for (i = 0; i < strlen(in_mode); i++)
    {
        pMode->Append(in_mode[i]);
    }
    pMode->ZeroTerminate();

    result = symbian_wfopen((wchar_t*)pName->Ptr(), (wchar_t*)pMode->Ptr());
    
    CleanupStack::PopAndDestroy(pMode);
    CleanupStack::PopAndDestroy(pName);
    
    return result;
}
void eapol_am_wlan_authentication_symbian_c::InitDatabaseL()
{
	EAP_TRACE_DEBUG(
		m_am_tools,
		TRACE_FLAGS_DEFAULT,
		(EAPL("eapol_am_wlan_authentication_symbian_c::InitDatabaseL()\n")));
	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::InitDatabaseL()");

	// Create the database (if necessary)
	TRAPD(error, TryInitDatabaseL());
	if (error != KErrNone)
	{
		// Because of error remove the database file.
		TFileName aPrivateDatabasePathName;

		EapPluginTools::GetPrivatePathL(
			m_session,
			aPrivateDatabasePathName);

		aPrivateDatabasePathName.Append(KEapolDatabaseName);

		EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
			aPrivateDatabasePathName.Ptr(),
			aPrivateDatabasePathName.Size()));

		error = m_session.Delete(aPrivateDatabasePathName);
		if(error != KErrNone)
		{
			User::Leave(KErrCorrupt);
		}		

		// Try open database again. This will leave if fails second time.
		TryInitDatabaseL();
	}
}
void CFileEngine::RequestCreateFolder(const TDesC& aParentPath)
{
	//ASSERT(NULL == iParentFolderName);
	delete iParentFolderName;
	iParentFolderName = NULL;
	iParentFolderName = aParentPath.AllocL();

	TFileName szTempParentPath = aParentPath;
	if ( szTempParentPath[ szTempParentPath.Length() - 1 ] != '\\' )
	{
		szTempParentPath.Append( _L("\\") );
	}
	//获取路径深度
	TInt dirDepth = 0;
	const TUint16* pSzTempParentPath = szTempParentPath.Ptr();
	for ( TInt i = 0; i < szTempParentPath.Length(); i ++ )
	{
		if ( pSzTempParentPath[ i ] == '\\' )
		{
			dirDepth ++;
		}
	}
	if ( dirDepth >= 7 )
	{
		iControlFactory.CreateTipDialog(iMainEngine.GetDesById(ETurkeyTextRes_CreateFolderNotSupported),*this,ECmdNull);
		delete iParentFolderName;
		iParentFolderName = NULL;
	}
	else
	{
		iControlFactory.CreateInputTextDialog(*this,iMainEngine.GetDesById(ETurkeyTextRes_InputFolderName),KNullDesC,ECmdCreateFolder);
		//iInputEvent = ECmdCreateFolder;
	}
}
示例#4
0
/**
Writes file names using IPC args along with data related to TWsClCmdRegisterEffect
Out going phase animation file name is sent in second slot of IPC to server
In coming phase animation file name is sent in third slot of IPC to server
Data related to TWsClCmdRegisterEffect and folder name are sent in the normal wserv buffer

@param aForRegister an object of TWsClCmdRegisterEffect filled with data related to RegisterTFXEffect
					If non Empty then this function is called for Register effect
@param aForOverride an object of TWsClCmdOverrideEffect filled with data related to OverrideTFXEffect
					If non Empty then this function is called for Overide effect					 
@param aResourceDir directory name of animation description file
@param aFilenameOutgoing File name of Outgoing phase of TFX
@param aFilenameIncoming File name of Incoming phase of TFX
@param aCalledFrom value from TFXEffect enum reprseting whether called from RWsSession or RWindowbase 	
*/
void RTFXEffect::WriteDataUsingIPC(TWsClCmdRegisterEffect* aForRegister, TWsClCmdOverrideEffect* aForOverride, 
		const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming, TFXEffect aCalledFrom)
	{
	TIpcArgs ipcArgsDesc;
	ipcArgsDesc.Set(1, &aFilenameOutgoing);
	ipcArgsDesc.Set(2, &aFilenameIncoming);
	// If called for RegisterTFXEffect
	if (aForRegister)
		{
		Write(aForRegister, sizeof(*aForRegister), aResourceDir.Ptr(), aResourceDir.Size(), 
				EWsClOpRegisterTFXEffectIPC, &ipcArgsDesc);
		}
	else	// Else called for OverrideTFXEffect
		{
		Write(aForOverride, sizeof(*aForOverride), aResourceDir.Ptr(), aResourceDir.Size(), 
				(aCalledFrom == ETFXSession ? EWsClOpOverrideEffectIPC : EWsWinOpOverrideEffectIPC), &ipcArgsDesc);
		}
	}
QString ControllerWrapper::getCurrentConfigName()
{
#ifdef Q_OS_SYMBIAN
    TFileName fn;
    d_ptr->GetCurrentConfigName(fn);
    return QString((QChar*)fn.Ptr(),fn.Length());
#elif defined(_SIMULATOR_STUB)
    return QString("");
#endif
}
TBool CFileExecuter::GetAssociatedApp( TFileName aFileExtension, TFileName& aAppPath )
{
	TBool aFoundType;

	CCoCoAppUi* nAppUi = (CCoCoAppUi*)(CEikonEnv::Static()->AppUi());
	CDictionaryStore* nlinkStore = nAppUi->Application()->OpenIniFileLC( CEikonEnv::Static()->FsSession() );

	aFileExtension.LowerCase();
	const TUint16* aFileExtensionPtr = aFileExtension.Ptr();

	TUint nDefaultUid = 0;
	TUint nMemberValue;
	for ( TInt i = 0; i < aFileExtension.Length(); i ++ )
	{
		nMemberValue = aFileExtensionPtr[i];
		if ( nMemberValue >= 97 && nMemberValue <= 122 )
		{
			nMemberValue -= 97;
		}
		else if ( nMemberValue >= 48 && nMemberValue <= 57 )
		{
			nMemberValue -= 48;
		}

		nDefaultUid = nDefaultUid* 10 + nMemberValue;
	}


	if ( nlinkStore->IsPresentL( TUid::Uid(nDefaultUid) ) ) 
	{
		RDictionaryReadStream inLinkStoreStream;
		inLinkStoreStream.OpenLC( *nlinkStore, TUid::Uid(nDefaultUid) );
		inLinkStoreStream >> aAppPath;
		CleanupStack::PopAndDestroy();

		aFoundType = true;
	}
示例#7
0
HXBOOL CHXDirectory::SetCurrentDir()
{
    HXBOOL bRetVal = FALSE;

    if (GetSession())
    {
	TFileName* psymbCurrentDir = new TFileName;

	if (psymbCurrentDir)
	{
	    bRetVal = (m_symbSession.SessionPath(*psymbCurrentDir) == KErrNone);

	    if (bRetVal)
	    {
		m_strPath = (const char *) OS_STRING2((OS_TEXT_PTR) psymbCurrentDir->Ptr(), 
						      psymbCurrentDir->Length());
	    }

	    delete psymbCurrentDir;
	}
    }

    return bRetVal;
}
QString QDesktopServices::storageLocation(StandardLocation type)
{
    TFileName path;

    switch (type) {
    case DesktopLocation:
        qWarning("No desktop concept in Symbian OS");
        // But lets still use some feasible default
        path.Append(writableDataRoot());
        break;
    case DocumentsLocation:
        path.Append(writableDataRoot());
        break;
    case FontsLocation:
        path.Append(KFontsDir);
        break;
    case ApplicationsLocation:
        path.Append(exeDrive().Name());
        path.Append(KSysBin);
        break;
    case MusicLocation:
        path.Append(writableDataRoot());
#ifdef Q_OS_SYMBIAN
        path.Append(PathInfo::SoundsPath());
#endif
        break;
    case MoviesLocation:
        path.Append(writableDataRoot());
#ifdef Q_OS_SYMBIAN
        path.Append(PathInfo::VideosPath());
#endif
        break;
    case PicturesLocation:
        path.Append(writableDataRoot());
#ifdef Q_OS_SYMBIAN
        path.Append(PathInfo::ImagesPath());
#endif
        break;
    case TempLocation:
        return QDir::tempPath();
        break;
    case HomeLocation:
        path.Append(writableDataRoot());
        //return QDir::homePath(); break;
        break;
    case DataLocation:
        qt_s60GetRFs().PrivatePath(path);
        path.Insert(0, writableExeDrive().Name());
        break;
    case CacheLocation:
        qt_s60GetRFs().PrivatePath(path);
        path.Insert(0, writableExeDrive().Name());
        path.Append(KCacheSubDir);
        break;
    default:
        // Lets use feasible default
        path.Append(writableDataRoot());
        break;
    }

    // Convert to cross-platform format and clean the path
    QString nativePath = QString::fromUtf16(path.Ptr(), path.Length());
    QString qtPath = QDir::fromNativeSeparators(nativePath);
    qtPath = QDir::cleanPath(qtPath);

    // Note: The storage location returned can be a directory that does not exist;
    // i.e., it may need to be created by the system or the user.
    return  qtPath;
}
示例#9
0
EXPORT_C TThreadId CSDL::CallMainL(const TMainFunc& aFunc, TRequestStatus* const aStatus, const CDesC8Array* const aArg, TInt aFlags, TInt aStackSize)
    {
    ASSERT(gEpocEnv != NULL);
    gEpocEnv->iMain = aFunc;
    const TBool args = aArg != NULL;
    
    if(gEpocEnv->iArgv != NULL)
    	User::Leave(KErrAlreadyExists);
    
    gEpocEnv->iArgc = args ? aArg->Count() + 1 : 0;
    gEpocEnv->iArgv = (char**) User::AllocL(sizeof(char*) * (gEpocEnv->iArgc + 2));  
      
    TInt k = 0;
    const TFileName processName = RProcess().FileName();
    const TInt len = processName.Length();
    gEpocEnv->iArgv[k] = (char*) User::AllocL(len + 1);
    Mem::Copy(gEpocEnv->iArgv[k], processName.Ptr(), len);
    gEpocEnv->iArgv[k][len] = 0;
      
    for(TInt i =  0; args && (i < aArg->Count()); i++)
        {
        k++;
        const TInt len = aArg->MdcaPoint(i).Length();
        gEpocEnv->iArgv[k] = (char*) User::AllocL(len + 1);
        Mem::Copy(gEpocEnv->iArgv[k], aArg->MdcaPoint(i).Ptr(), len);
        gEpocEnv->iArgv[k][len] = 0;
        }
        
    gEpocEnv->iArgv[k + 1] = NULL;
    
   
    if(aFlags & CSDL::ERequestResume)
        {
        gEpocEnv->iEpocEnvFlags |= EpocSdlEnvData::EResumeNeeded;   
    	}    
    
    gEpocEnv->iEventQueue->ConstructL();
    gEpocEnv->iAppSrv->ConstructL();
    
    gEpocEnv->iStackSize = aStackSize;
    
    if(EnvUtils::IsOwnThreaded())
		{  
    	RThread thread;
    	User::LeaveIfError(thread.Create(KSDLMain, DoMain, aStackSize, NULL, NULL));
    
   	 	if(aStatus != NULL)
    		{
    		thread.Logon(*aStatus);
    		}
 
    	gEpocEnv->iId = thread.Id();
    	thread.SetPriority(EPriorityLess);
    	if((aFlags & CSDL::ERequestResume) == 0)
        	{
        	thread.Resume();
       	 	}
    	thread.Close();
		}
	else
		{
		gEpocEnv->iCaller = CIdle::NewL(CActive::EPriorityIdle); //MUST!
		
		if((aFlags & CSDL::ERequestResume) == 0)
		    {
		    gEpocEnv->iCaller->Start(TCallBack(DoMain));
		    }
		
		gEpocEnv->iCallerStatus = aStatus;
		if(aStatus != NULL)
			*aStatus = KRequestPending;
		gEpocEnv->iId = RThread().Id();
		RThread().SetPriority(EPriorityLess);
		}
    return gEpocEnv->iId;
    }
示例#10
0
/**
Appends folder and file names to wserv client's buffer using AppendData() of MWsClientClass.
AppendData adds data directly to buffer. So before calling AppendData we must make sure that
current command is added to buffer. Please see description of MWsClientClass::AppendData()
for more details.

@param aResourceDir directory name of animation description file
@param aFilenameOutgoing File name of Outgoing phase of TFX
@param aFilenameIncoming File name of Incoming phase of TFX
*/
void RTFXEffect::AppendFileNameData(const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming)
	{
	AppendData(aResourceDir.Ptr(), aResourceDir.Size(), EFalse);
    AppendData(aFilenameOutgoing.Ptr(), aFilenameOutgoing.Size(), EFalse);
    AppendData(aFilenameIncoming.Ptr(), aFilenameIncoming.Size(), ETrue);
	}
EAP_FUNC_EXPORT eap_status_e eapol_am_wlan_authentication_symbian_c::read_configure(
	const eap_configuration_field_c * const field,
	eap_variable_data_c * const data)
{
	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
	EAP_ASSERT_ALWAYS(data != NULL);
	
	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("eapol_am_wlan_authentication_symbian_c::read_configure(): %s, this = 0x%08x => 0x%08x\n"),
		 (m_is_client == true) ? "client": "server",
		 this,
		 dynamic_cast<abs_eap_base_timer_c *>(this)));
	EAP_TRACE_RETURN_STRING_FLAGS(m_am_tools, TRACE_FLAGS_DEFAULT, "returns: eapol_am_wlan_authentication_symbian_c::read_configure()");

	// Trap must be set here because the OS independent portion of EAPOL
	// that calls this function does not know anything about Symbian.	
	eap_status_e status(eap_status_ok);

	// Check if the wanted parameter is default type

	eap_variable_data_c wanted_field(m_am_tools);
	eap_variable_data_c type_field(m_am_tools);
	
	status = wanted_field.set_buffer(
		field->get_field(),
		field->get_field_length(),
		false,
		false);
	if (status != eap_status_ok)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, status);
	}
	
	status = type_field.set_buffer(
		cf_str_EAP_default_type_hex_data.get_field()->get_field(),
		cf_str_EAP_default_type_hex_data.get_field()->get_field_length(),
		false,
		false);
	if (status != eap_status_ok)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, status);
	}

	// It was something else than EAP type. Read it from eapol DB.
	_LIT( KEapolTableName, "eapol" );

	TFileName aPrivateDatabasePathName;

	TRAPD(err, EapPluginTools::GetPrivatePathL(
		m_session,
		aPrivateDatabasePathName));
		
	if (err)
		{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
		}

	aPrivateDatabasePathName.Append(KEapolDatabaseName);

	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
		aPrivateDatabasePathName.Ptr(),
		aPrivateDatabasePathName.Size()));

	TRAPD( error, read_configureL(
		aPrivateDatabasePathName,
		KEapolTableName,
		field->get_field(),
		field->get_field_length(),
		data) );

	// Try to read it for eap fast DB	
	HBufC8* fieldBuf = HBufC8::New( field->get_field_length() );

	eap_automatic_variable_c<HBufC8> automatic_fieldBuf(
		m_am_tools,
		fieldBuf);

	if (fieldBuf == 0)
	{
		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
	}
	TPtr8 fieldPtr = fieldBuf->Des();
	fieldPtr.Copy( reinterpret_cast<const TUint8 *> ( field->get_field() ));

	if (error != KErrNone) 
	{
		status = m_am_tools->convert_am_error_to_eapol_error(error);

#if defined(USE_EAP_FILECONFIG)
		if (m_fileconfig != 0
			&& m_fileconfig->get_is_valid() == true)
		{
			// Here we could try the final configuration option.
			status = m_fileconfig->read_configure(
				field,
				data);
		}
#endif //#if defined(USE_EAP_FILECONFIG)
	}

	m_am_tools->trace_configuration(
		status,
		field,
		data);

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
	return EAP_STATUS_RETURN(m_am_tools, status);
}
void eapol_am_wlan_authentication_symbian_c::TryInitDatabaseL()
{
	EAP_TRACE_DEBUG(
		m_am_tools,
		TRACE_FLAGS_DEFAULT,
		(EAPL("eapol_am_wlan_authentication_symbian_c::TryOpenDatabaseL()\n")));	
	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::TryInitDatabaseL()");
		
	// 1. Open/create a database	
	RDbNamedDatabase db;

	// Create the secure shared database (if necessary) with the specified secure policy.
	// Database will be created in the data caging path for DBMS (C:\private\100012a5).

	TFileName aPrivateDatabasePathName;

	EapPluginTools::GetPrivatePathL(
		m_session,
		aPrivateDatabasePathName);

	aPrivateDatabasePathName.Append(KEapolDatabaseName);

	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
		aPrivateDatabasePathName.Ptr(),
		aPrivateDatabasePathName.Size()));

	TInt error = db.Create(m_session, aPrivateDatabasePathName);
	
	EAP_TRACE_DEBUG(
		m_am_tools,
		TRACE_FLAGS_DEFAULT,
		(EAPL("TryOpenDatabaseL() - Created Secure DB for eapol.dat. error=%d\n"), error ));	
		
	if(error == KErrNone)
	{	
		db.Close();
		
	} else if (error != KErrAlreadyExists) 
	{
		User::LeaveIfError(error);
	}
	
	User::LeaveIfError(db.Open(m_session, aPrivateDatabasePathName));	
		
	CleanupClosePushL(db);

	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
	TPtr sqlStatement = buf->Des();

	// 2. Create the table for pre-shared keys in database (ignore error if exists)

	//// NAME /////////////////////////////////////////////////// TYPE ////////////// Constant ///////
	//| ServiceType											  | UNSIGNED INTEGER | KServiceType    |//
	//| ServiceIndex										  | UNSIGNED INTEGER | KServiceIndex   |//
	//| SSID												  | VARBINARY(255)	 | KSSID		   |//	
	//| Password											  | VARBINARY(255)	 | KPassword	   |//	
	//| PSK												      | VARBINARY(255)   | KPSK			   |//	
	//////////////////////////////////////////////////////////////////////////////////////////////////	
	_LIT(KSQLCreateTable2, "CREATE TABLE %S (%S UNSIGNED INTEGER, \
											 %S UNSIGNED INTEGER, \
											 %S VARBINARY(255), \
											 %S VARBINARY(255), \
											 %S VARBINARY(255))");
	sqlStatement.Format(KSQLCreateTable2, &KEapolPSKTableName, 
		&KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK);
	error = db.Execute(sqlStatement);
	if (error != KErrNone && error != KErrAlreadyExists)
	{
		User::Leave(error);
	}
	
	CleanupStack::PopAndDestroy(buf);
	
	// If compacting is not done the database will start growing
	db.Compact();
	
	CleanupStack::PopAndDestroy(&db);
}
void eapol_am_wlan_authentication_symbian_c::SavePSKL(TPSKEntry& entry)
{
	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("eapol_am_wlan_authentication_symbian_c::SavePSKL(): this = 0x%08x\n"),
		this));
	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::SavePSKL()");

	// Connect to CommDBif so that we can delete PSK entries that have no IAP associated anymore.
	CWLanSettings* wlan_settings = new(ELeave) CWLanSettings;
	CleanupStack::PushL(wlan_settings);
	
	SWLANSettings wlanSettings;

	if (wlan_settings->Connect() != KErrNone)
	{
		// Could not connect to CommDB			
		User::Leave(KErrCouldNotConnect);
	}

	// Open database
	RDbNamedDatabase db;

	TFileName aPrivateDatabasePathName;

	EapPluginTools::GetPrivatePathL(
		m_session,
		aPrivateDatabasePathName);

	aPrivateDatabasePathName.Append(KEapolDatabaseName);

	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
		aPrivateDatabasePathName.Ptr(),
		aPrivateDatabasePathName.Size()));

	User::LeaveIfError(db.Open(m_session, aPrivateDatabasePathName));	
	
	CleanupClosePushL(db);

	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
	TPtr sqlStatement = sqlbuf->Des();

	RDbView view;

	_LIT(KSQL, "SELECT %S, %S, %S, %S, %S FROM %S");
	
	sqlStatement.Format(KSQL, &KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK,
		&KEapolPSKTableName);

	User::LeaveIfError(view.Prepare(db, TDbQuery(sqlStatement), TDbWindow::EUnlimited));	
	CleanupClosePushL(view);
	User::LeaveIfError(view.EvaluateAll());
	
	// Get column set so we get the correct column numbers
	CDbColSet* colSet = view.ColSetL();		
	CleanupStack::PushL(colSet);
	
	// Delete old row and also rows that have no associated IAP settings.
	if (view.FirstL())
	{
		do {
			view.GetL();

			if ((wlan_settings->GetWlanSettingsForService(view.ColUint32(colSet->ColNo(KServiceIndex)), wlanSettings) != KErrNone)
				|| (view.ColUint32(colSet->ColNo(KServiceType)) == static_cast<TUint>(entry.indexType)
					&& view.ColUint32(colSet->ColNo(KServiceIndex)) == static_cast<TUint>(entry.index)))
			{	
				// Not found or current IAP
				view.DeleteL();	
			}
			
		} while (view.NextL() != EFalse);
	}

	wlan_settings->Disconnect();
	
	view.InsertL();
	
	view.SetColL(colSet->ColNo(KServiceType), (TUint)entry.indexType);
	view.SetColL(colSet->ColNo(KServiceIndex), (TUint)entry.index);
	view.SetColL(colSet->ColNo(KSSID), entry.ssid);
	view.SetColL(colSet->ColNo(KPassword), entry.password);
	view.SetColL(colSet->ColNo(KPSK), entry.psk);	
	
	view.PutL();
	
	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.	

	CleanupStack::PopAndDestroy(&view);
	CleanupStack::PopAndDestroy(sqlbuf);
	CleanupStack::PopAndDestroy(&db);
	CleanupStack::PopAndDestroy(wlan_settings);

}
void eapol_am_wlan_authentication_symbian_c::RetrievePSKL(TPSKEntry& entry)
{
	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("eapol_am_wlan_authentication_symbian_c::RetrievePSKL(): this = 0x%08x\n"),
		this));
	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eapol_am_wlan_authentication_symbian_c::RetrievePSKL()");

	// Open database
	RDbNamedDatabase db;

	TFileName aPrivateDatabasePathName;

	EapPluginTools::GetPrivatePathL(
		m_session,
		aPrivateDatabasePathName);

	aPrivateDatabasePathName.Append(KEapolDatabaseName);

	EAP_TRACE_DATA_DEBUG_SYMBIAN(("aPrivateDatabasePathName",
		aPrivateDatabasePathName.Ptr(),
		aPrivateDatabasePathName.Size()));

	TInt error = db.Open(m_session, aPrivateDatabasePathName);

	EAP_TRACE_DEBUG(
		m_am_tools, 
		TRACE_FLAGS_DEFAULT, 
		(EAPL("eapol_am_wlan_authentication_symbian_c::RetrievePSKL(): db.Open(), error = %d\n"),
		 error));

	User::LeaveIfError(error);
	
	CleanupClosePushL(db);

	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
	TPtr sqlStatement = sqlbuf->Des();

	RDbView view;

	CleanupClosePushL(view);

	_LIT(KSQL, "SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d");

	sqlStatement.Format(KSQL, &KServiceType, &KServiceIndex, &KSSID, &KPassword, &KPSK,
		&KEapolPSKTableName, &KServiceType, entry.indexType, &KServiceIndex, entry.index);
		
	User::LeaveIfError(view.Prepare(db, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
	User::LeaveIfError(view.EvaluateAll());	

	TInt rows = view.CountL();
	
	if (rows == 0)
	{
		// No saved PSK
		User::Leave(KErrNotFound);
	}
	view.FirstL();
	view.GetL();

	entry.ssid.Copy(view.ColDes8(3));
	entry.password.Copy(view.ColDes8(4));
	entry.psk.Copy(view.ColDes8(5));

	CleanupStack::PopAndDestroy(&view);
	CleanupStack::PopAndDestroy(sqlbuf);
	CleanupStack::PopAndDestroy(&db);
}