/** Function checks the sent parmaters and pancis client if any of its length is greater than KMaxFileName. Calculates the padded lengths of sent parameters and stores them in member variables @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::CheckFileNameAndSetSizes(const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming) { __ASSERT_ALWAYS(aResourceDir.Length() <= KMaxFileName, Panic(EW32PanicStringTooLong)); __ASSERT_ALWAYS(aFilenameOutgoing.Length() <= KMaxFileName, Panic(EW32PanicStringTooLong)); __ASSERT_ALWAYS(aFilenameIncoming.Length() <= KMaxFileName, Panic(EW32PanicStringTooLong)); iDirPathSizePaded = PaddedValue(aResourceDir.Size()); iFileName1SizePaded = PaddedValue(aFilenameOutgoing.Size()); iFileName2SizePaded = PaddedValue(aFilenameIncoming.Size()); iCombSizePaded = iDirPathSizePaded + iFileName1SizePaded + iFileName2SizePaded; }
char* fetch_remote_data(char* url) { char* szData = NULL; CHttpFileManager* iHttpFileManager = CHttpFileManager::NewL(); if (!gHttpClient) gHttpClient = CHttpClient::NewL(); if ( iHttpFileManager && gHttpClient ) { if ( iHttpFileManager->GetFilesCount( ETrue) == 0 ) //currently only one file will be used { if ( iHttpFileManager->CreateRequestFile( (const TUint8*)url, strlen(url), NULL, 0 ) ) gHttpClient->InvokeHttpMethodL(CHttpConstants::EGet); } TFileName respFile; iHttpFileManager->GetOldestFile( respFile, EFalse ); if ( respFile.Size() > 0 ) { TFileName respFilePath; respFilePath.Append(CHttpConstants::KHttpOUT); respFilePath.Append(respFile); szData = iHttpFileManager->ReadResponseFile( respFilePath ); iHttpFileManager->DeleteFile(respFilePath); } } delete iHttpFileManager; return szData; }
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(); } }
/** Checks the length of sent variables and does as explained in RTFXEffect::RegisterTFXEffect() API description @param aAction The particular transition to set the animation for. @param aPurpose This override only effects the window/layers owned by the application that have the specified purpose. @param aResourceDir The name of the directory that contains the animation description files. @param aFilenameOutgoing The file containing the description of the animation for the outgoing phase of the transition. Specify KNullDesC for no outgoing phase effect. @param aFilenameIncoming The file containing the description of the animation for the incoming phase of the transition. Specify KNullDesC for no incoming phase effect. @param aFlags Flag for the effect. Please see TTfxFlags for values this flag parameter can use. */ void RTFXEffect::OverrideTFXEffect(TFXEffect aCalledFrom, TInt aAction, TInt aPurpose, const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming, TBitFlags aFlags) { CheckFileNameAndSetSizes(aResourceDir, aFilenameOutgoing, aFilenameIncoming); if (CheckCombinedSizeWithCurrentBuffer(sizeof(TWsClCmdOverrideEffect))) { TWsClCmdOverrideEffect params(aAction, aPurpose, aResourceDir.Size(), aFilenameOutgoing.Size(), aFilenameIncoming.Size(), aFlags); Write(¶ms, sizeof(params), iCombSizePaded, (aCalledFrom == ETFXSession ? EWsClOpOverrideEffectBuf : EWsWinOpOverrideEffectBuf)); if (iCombSizePaded > 0) AppendFileNameData(aResourceDir, aFilenameOutgoing, aFilenameIncoming); } else { TWsClCmdOverrideEffect params(aAction, aPurpose, aResourceDir.Size(), 0, 0, aFlags); WriteDataUsingIPC(NULL, ¶ms, aResourceDir, aFilenameOutgoing, aFilenameIncoming, aCalledFrom); } }
/** 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); } }
/** Checks the length of sent variables and does as explained below Main logic involved in both RegisterTFXEffect() and OverrideTFXEffect() is as follows First check the sum of all strings If it is less then max wserv buffer Send unpadded sizes in TWsClCmdRegisterEffect/TWsClCmdOverrideEffect but when we append the data we make sure that we pad it Then at server side get the buffer for total length(inlcuding pading)and unpad it and send it to renderstage's RegisterEffect/OverrideEffect function If it is greater then max wserv buffer Send one string in the wserv buffer as done before ie. pading and unpading Other two strings are sent using IPC args in 2 and 3 slot of IPC and do explicit flush And at server side get one string from buffer and other 2 from IPC @param aAction Particular transition to register the animation for. @param aPurpose The purpose of the window. @param aResourceDir The name of the directory that contains the animation description files. @param aFilenameOutgoing The file containing the description of the animation for the outgoing phase of the transition. Specify KNullDesC for no outgoing phase effect. @param aFilenameIncoming The file containing the description of the animation for the incoming phase of the transition. Specify KNullDesC for no incoming phase effect. @param aAppUid The Application UID this effect applies to. Set to zero to specify that all apps will use default effect. @param aFlags Flag for the effect. Please see TTfxFlags for values this flag parameter can use. */ void RTFXEffect::RegisterTFXEffect(TInt aAction, TInt aPurpose, const TFileName& aResourceDir, const TFileName& aFilenameOutgoing, const TFileName& aFilenameIncoming, TUint aAppUid, TBitFlags aFlags) { CheckFileNameAndSetSizes(aResourceDir, aFilenameOutgoing, aFilenameIncoming); if (CheckCombinedSizeWithCurrentBuffer(sizeof(TWsClCmdRegisterEffect))) { TWsClCmdRegisterEffect params(aAction, aPurpose, aResourceDir.Size(), aFilenameOutgoing.Size(), aFilenameIncoming.Size(), aAppUid, aFlags); // Here we just pass the length of combined strings so that it checks and does flush if needed. // Then AppendData actually adds the data to buffer at the end Write(¶ms, sizeof(params), iCombSizePaded, EWsClOpRegisterTFXEffectBuf); if (iCombSizePaded > 0) AppendFileNameData(aResourceDir, aFilenameOutgoing, aFilenameIncoming); } else { TWsClCmdRegisterEffect params(aAction, aPurpose, aResourceDir.Size(), 0, 0, aAppUid, aFlags); WriteDataUsingIPC(¶ms, NULL, aResourceDir, aFilenameOutgoing, aFilenameIncoming, ETFXSession); } }
int push_remote_data(char* url, char* data, size_t data_size) { int retval = 0; char* szData = NULL; CHttpFileManager* iHttpFileManager = CHttpFileManager::NewL(); if (!gHttpClient) gHttpClient = CHttpClient::NewL(); if ( iHttpFileManager && gHttpClient ) { if ( iHttpFileManager->GetFilesCount( ETrue) == 0 ) //currently only one file will be used { if ( iHttpFileManager->CreateRequestFile( (const TUint8*)url, strlen(url), (const TUint8*)data, data_size ) ) gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost); } TFileName respFile; iHttpFileManager->GetOldestFile( respFile, EFalse ); if ( respFile.Size() > 0 ) { TFileName respFilePath; respFilePath.Append(CHttpConstants::KHttpOUT); respFilePath.Append(respFile); szData = iHttpFileManager->ReadResponseFile( respFilePath ); iHttpFileManager->DeleteFile(respFilePath); } } delete iHttpFileManager; if ( szData ) delete szData; else retval = 1; return retval; }
/* * Creates (asynchronously) Preview Image from Jpeg ImageBuffer and also * writes Jpeg (synchronously) to a file. */ void S60ImageCaptureSession::saveImageL(TDesC8 *aData, TFileName &aPath) { // Checked if aData is NULL already in the MceoCapturedDataReady() if (aPath.Size() > 0) { #ifndef ECAM_PREVIEW_API if (m_previewDecodingOngoing) { m_previewInWaitLoop = true; CActiveScheduler::Start(); // Wait for the completion of the previous Preview generation } // Delete old instances if needed if (m_imageDecoder) { delete m_imageDecoder; m_imageDecoder = 0; } if (m_previewBitmap) { delete m_previewBitmap; m_previewBitmap = 0; } #endif // ECAM_PREVIEW_API if (m_fileSystemAccess) { m_fileSystemAccess->Close(); delete m_fileSystemAccess; m_fileSystemAccess = 0; } RFs *fileSystemAccess = new (ELeave) RFs; User::LeaveIfError(fileSystemAccess->Connect()); CleanupClosePushL(*fileSystemAccess); #ifndef ECAM_PREVIEW_API // Generate Thumbnail to be used as Preview S60ImageCaptureDecoder *imageDecoder = S60ImageCaptureDecoder::DataNewL(this, fileSystemAccess, aData); CleanupStack::PushL(imageDecoder); TSize scaledSize = getScaledPreviewSize(m_imageSettings->imageResolution()); TFrameInfo *info = imageDecoder->frameInfo(); if (!info) { setError(KErrGeneral, tr("Preview image creation failed.")); return; } CFbsBitmap *previewBitmap = new (ELeave) CFbsBitmap; CleanupStack::PushL(previewBitmap); TInt bitmapCreationErr = previewBitmap->Create(scaledSize, info->iFrameDisplayMode); if (bitmapCreationErr) { setError(bitmapCreationErr, tr("Preview creation failed.")); return; } // Jpeg conversion completes in RunL m_previewDecodingOngoing = true; imageDecoder->decode(previewBitmap); #endif // ECAM_PREVIEW_API RFile file; TInt fileWriteErr = KErrNone; fileWriteErr = file.Replace(*fileSystemAccess, aPath, EFileWrite); if (fileWriteErr) { #ifndef ECAM_PREVIEW_API imageDecoder->cancelDecoding(); #endif // ECAM_PREVIEW_API User::Leave(fileWriteErr); } CleanupClosePushL(file); fileWriteErr = file.Write(*aData); if (fileWriteErr) { #ifndef ECAM_PREVIEW_API imageDecoder->cancelDecoding(); #endif // ECAM_PREVIEW_API User::Leave(fileWriteErr); } file.Close(); CleanupStack::PopAndDestroy(&file); #ifdef ECAM_PREVIEW_API CleanupStack::PopAndDestroy(fileSystemAccess); #else // !ECAM_PREVIEW_API // Delete when Image is decoded CleanupStack::Pop(previewBitmap); CleanupStack::Pop(imageDecoder); CleanupStack::Pop(fileSystemAccess); // Set member variables (Cannot leave any more) m_previewBitmap = previewBitmap; m_imageDecoder = imageDecoder; m_fileSystemAccess = fileSystemAccess; #endif // ECAM_PREVIEW_API QString qtFileName(m_stillCaptureFileName); qtFileName.replace(QChar('\\'), QChar('/')); emit imageSaved(m_currentImageId, qtFileName); // For custom preview generation, image buffer gets released in RunL() #ifdef ECAM_PREVIEW_API releaseImageBuffer(); #endif // ECAM_PREVIEW_API // Inform that we can continue taking more pictures emit readyForCaptureChanged(true); } else { setError(KErrPathNotFound, tr("Invalid path given."), true); } }
/** @SYMTestCaseID PDS-SQL-UT-4142 @SYMTestCaseDesc RFileBuf64 OOM test. The test calls RFileBuf64:Create(), RFileBuf64:Open() and RFileBuf64:Temp() in an OOM simulation loop and verifies that no memory is leaked. @SYMTestActions RFileBuf64 OOM test. @SYMTestExpectedResults Test must not fail @SYMTestPriority High @SYMREQ REQ12106 REQ12109 */ void OomTest(TOomTestType aOomTestType) { (void)TheFs.Delete(KTestFile); if(aOomTestType == EOomOpenTest) { RFile64 file; TInt err2 = file.Create(TheFs, KTestFile, EFileWrite | EFileRead); file.Close(); TEST2(err2, KErrNone); } TFileName tmpFileName; TInt err = KErrNoMemory; TInt failingAllocationNo = 0; RFileBuf64 fbuf(1024); TheTest.Printf(_L("Iteration:\r\n")); while(err == KErrNoMemory) { TheTest.Printf(_L(" %d"), ++failingAllocationNo); MarkHandles(); MarkAllocatedCells(); __UHEAP_MARK; __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); switch(aOomTestType) { case EOomCreateTest: err = fbuf.Create(TheFs, KTestFile, EFileWrite | EFileRead); break; case EOomOpenTest: err = fbuf.Open(TheFs, KTestFile, EFileWrite | EFileRead); break; case EOomTempTest: { err = fbuf.Temp(TheFs, KTestDir, tmpFileName, EFileWrite | EFileRead); } break; default: TEST(0); break; } fbuf.Close(); __UHEAP_RESET; __UHEAP_MARKEND; CheckAllocatedCells(); CheckHandles(); TEntry entry; if(err != KErrNoMemory) { TEST2(err, KErrNone); } else if(aOomTestType == EOomCreateTest) { TInt err2 = TheFs.Entry(KTestFile, entry); TEST2(err2, KErrNotFound); } else if(aOomTestType == EOomTempTest) { if(tmpFileName.Size() > 0) { TInt err2 = TheFs.Entry(tmpFileName, entry); TEST2(err2, KErrNotFound); } } } TEST2(err, KErrNone); TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); if(aOomTestType == EOomTempTest) { (void)TheFs.Delete(tmpFileName); } (void)TheFs.Delete(KTestFile); }
/** 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); }