// ----------------------------------------------------------------------------- // CScardServer::NewL // Two-phased constructor. // ----------------------------------------------------------------------------- // CScardServer* CScardServer::NewL() { _WIMTRACE(_L("WIM|Scard|CScardServer::NewL|Begin")); CScardServer* self = new( ELeave ) CScardServer; CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); TPtrC tempName; tempName.Set( KScardServerName ); HBufC* pName = tempName.Alloc(); //Again these panics EPR __ASSERT_ALWAYS( pName, PanicServer( KScServerPanicSvrCreateServer ) ); self->iName = pName; // Ownership moves // Start the server TPtr name = self->iName->Des(); TInt r = self->Start( name ); __ASSERT_ALWAYS( r == KErrNone, PanicServer( KScServerPanicSvrCreateServer ) ); return self; }
EXPORT_C HBufC* CTIniData::ReadStrL(const TPtrC& aIniParam, const TDesC& aConfigFile) { CIniData * iniData = CIniData::NewL(aConfigFile); CleanupStack::PushL(iniData); TPtrC value; User::LeaveIfError(iniData->FindVar(KDefaultSectionName, aIniParam, value)); HBufC* ret = value.Alloc(); CleanupStack::PopAndDestroy(iniData); return ret; }
/** * Finds the java attribute specified by * aAttributeName from aJad and returns the value of that attribute * in HBufC. * @param[in] aJad contents of Jad file * @param[in] aAttributeName the name of a java attribute * @return the value of the attribute. Caller gets the ownership of the * returned HBufC. * If the attribute is not found, returns NULL */ HBufC *CSilentMIDletInstall::ParseAttribute(const HBufC *aJad, const TDesC& aAttributeName) { JELOG2(EJavaPreinstaller); TInt nInd(0); TBool fullNameFound(EFalse); TUint32 ch; // Start parsing from the beginning of the Jad file TPtrC parsePtr = aJad->Mid(nInd); do { // Find attribute name nInd = parsePtr.Find(aAttributeName); if (nInd < 0) { // Returns NULL if the attribute cannot be found return NULL; } // Check that the attribute name was preceded by line break or // it was at the beginning of the Jad file if (nInd == 0) { fullNameFound = ETrue; } else { ch = parsePtr[nInd-1]; if ((ch == CR) || (ch == LF)) { fullNameFound = ETrue; } else { // Name was just a part of longer string (not 'word match') fullNameFound = EFalse; // Skip to the last character of the found match. // We can skip because we are insterested only in 'word' matches // so the next cannot start inside the area we are skipping now. parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length() - 1)); continue; } } // Check whether Jad file ends after attribute name if (nInd + aAttributeName.Length() >= parsePtr.Length()) { // Jad file ends immediately after the found // attribute name instance. No attribute value return NULL; } // Check that there is a white space character or colon after // attribute name ch = parsePtr[nInd + aAttributeName.Length()]; if ((ch == COLON) || (ch == SP) || (ch == HT)) { fullNameFound = ETrue; } else { // Name was just a part of longer string (not 'word match') fullNameFound = EFalse; // Skip to the next character after the found match parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length())); continue; } } while (!fullNameFound); // Skip to the end of the attribute name and find ':' after the name. // The skipped characters must be white space chacraters, otherwise // the attribute name is illegal and Java Installer will not accept // the Jad file. parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length() - 1)); nInd = parsePtr.Locate(COLON); if (nInd < 0) { return NULL; } nInd++; // Parse attribute value (CR or LF ends) TInt nEndInd = parsePtr.Locate(CR); TInt nTmpInd = parsePtr.Locate(LF); if (KErrNotFound == nEndInd) { nEndInd = parsePtr.Length() - 1; } if (KErrNotFound == nTmpInd) { nTmpInd = parsePtr.Length() - 1; } if (nTmpInd < nEndInd) { nEndInd = nTmpInd; } if (nEndInd < nInd) { return NULL; } TPtrC attributeValue = parsePtr.Mid(nInd, (nEndInd - nInd)); // Remove possible white space from the beginning and end of the value HBufC *bufValue = attributeValue.Alloc(); if (NULL == bufValue) { return NULL; } TPtr value = bufValue->Des(); value.Trim(); return bufValue; } // parseAttribute
/** ExecuteActionL Obtains the parameters for the test action. Get the Message Id at given index. The Message Id is stored as output parameters of this Test Action @internalTechnology @pre None @post None @leave System wide errors */ void CMtfTestActionSendAsSetBodyText::ExecuteActionL() { if((TestCase().TestStepResult()) == EPass) { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsSetBodyText); // Get test action input parameters RSendAsMessage sendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(), ActionParameters().Parameter(0)); // Buffer type to be used for adding the body text // 0 => Set body text using Descriptor // 1 => Set body text using CRichText object (Default) TInt bufferType = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(1),1); TInt index = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(2)); // Get the body text configuration file name TPtrC fileName = TestCase().GetConfigurationFileL(CMtfConfigurationType::EMtfDataFile,index); // Create a Rich text object to store the Body text contents CPlainText::TTextOrganisation ttOrg = {CPlainText::EOrganiseByLine}; CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* bodyCRichText = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(bodyCRichText); HBufC* bodyTextFileName = fileName.Alloc(); CleanupStack::PushL(bodyTextFileName); // Read the body text contents into the Rich text object bodyCRichText->ImportTextFileL(0, bodyTextFileName->Des(), ttOrg); TInt err = KErrNone; // Set body text using descriptor if( bufferType == 0 ) { // Create a heap buffer and copy the file contents TInt len1 = bodyCRichText->DocumentLength(); HBufC* buf1 = HBufC::NewL(len1); CleanupStack::PushL(buf1); TPtr fileContents = buf1->Des(); bodyCRichText->Extract(fileContents,0,(len1)); // Set the body text to the message TRAP(err, sendAsMessage.SetBodyTextL(fileContents)); if(err == KErrNone) { TestCase().INFO_PRINTF1(_L("SetBodyTextL using Descriptor was successful")); } else { TestCase().ERR_PRINTF2(_L("SetBodyTextL using Descriptor failed with error: %d"), err); TestCase().SetTestStepResult(EFail); } // destroy the temporary storage of the text CleanupStack::PopAndDestroy(buf1); } else if (bufferType == 1) { // Set body text using CRichText TRAP(err, sendAsMessage.SetBodyTextL(*bodyCRichText)); if(err == KErrNone) { TestCase().INFO_PRINTF1(_L("SetBodyTextL using Rich Text was successful")); } else { TestCase().ERR_PRINTF2(_L("SetBodyTextL using Rich Text failed with error: %d"), err); TestCase().SetTestStepResult(EFail); } } else { err = KErrArgument; TestCase().ERR_PRINTF2(_L("Incorrent input parameter: Buffer type value should be either 0 or 1. The value provided is %d"),bufferType ); TestCase().SetTestStepResult(EFail); } StoreParameterL<TInt>(TestCase(),err,ActionParameters().Parameter(3)); CleanupStack::PopAndDestroy(4); //bodyTextFileName, bodyCRichText, charFormatLayer, paraFormatLayer TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsSetBodyText); } TestCase().ActionCompletedL(*this); }