Exemplo n.º 1
0
void CSyGeneratorBase::FinishElementDeclarationIfNeeded()
{
	if (!iNeedClosingBrace)
		return;
	else
		; // we need to close the current declaration
		
	// first we ensure the buffer has sufficient space		
	TPtr buffer = ExpandBufferL(2);

	// now get the last element
	const TInt		   lastIndex = iContextStack.Count() -1;
	const TXMLElement& lastElement = iContextStack[ lastIndex ];
	
	// if the last element on the context stack is empty then this was
	// an empty element so close the element marker
	// and pop it from the stack
	if (lastElement.iName.Length() == 0)
	{
		buffer.Append(KElementEmpty);
		iContextStack.Remove(lastIndex);
	}
	else
	{
		// the last element was a regular element so just close
		// the declaration - we will remove it from the stack when
		// the corresponding EndElement is encountered
		buffer.Append(KElementClose);
	}
		
	iOutput.WriteL(buffer, EFalse);
	
	iNeedClosingBrace = EFalse;
}
Exemplo n.º 2
0
// -----------------------------------------------------------------------------
// CLandmarksEditDialog::ConfigureCategoryFieldL
// 
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CLandmarksEditDialog::ConfigureCategoryFieldL()
    {
    TInt nrOfCategories = iCategoryIds.Count();
    const TInt KExtraChars = 2; // CRLF
    
    HBufC* lmCategoriesBuf = HBufC::NewLC(
        (KPosLmMaxTextFieldLength + KExtraChars) * nrOfCategories);
    
    TPtr lmCategories = lmCategoriesBuf->Des();
    for (TInt i = 0; i < nrOfCategories; i++)
        {
        if (i > 0)
            {
            lmCategories.Append(CEditableText::ELineBreak);
            }

        CPosLandmarkCategory* category = iEngine.CategoryLC(iCategoryIds[i]);
        TPtrC categoryName;
        category->GetCategoryName(categoryName);
        lmCategories.Append(categoryName);
        CleanupStack::PopAndDestroy(category);
        }

    ConfigureTextFieldL(ELandmarkCategoryField, *lmCategoriesBuf);

    CleanupStack::PopAndDestroy(lmCategoriesBuf);
    }
// ------------------------------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::CombineURILC()
// Combines address and port to URI 
// ------------------------------------------------------------------------------------------------
TInt CNSmlDsProvisioningAdapter::CombineURILC( const TDesC& aAddr, const TDesC& aPort, HBufC*& aRealURI )
	{
	TInt offset = 0;
	TInt i = 0;
	if( aAddr.Find( KNSmlDsProvisioningHTTP ) == 0 )
		{
		offset = KNSmlDsProvisioningHTTP().Length();
		}
	else if( aAddr.Find( KNSmlDsProvisioningHTTPS ) == 0 )
		{
		offset = KNSmlDsProvisioningHTTPS().Length();
		}
		
	// after skipping double slashes seek next single slash
	for( i = offset; i < aAddr.Length(); i++ )
		{
		if( aAddr[i] == KNSmlDMUriSeparator )
			{
			break;
			}
		}
	
	aRealURI = HBufC::NewLC( aAddr.Length() + aPort.Length() + 1 );
	TPtr uriPtr = aRealURI->Des();

	uriPtr.Copy( aAddr.Ptr(), i );
	uriPtr.Append( KNSmlDMColon );
	uriPtr.Append( aPort );
	uriPtr.Append( aAddr.Right( aAddr.Length() - i ) );
		
	return KErrNone;
	}
Exemplo n.º 4
0
// Display retrieved metadata
void CMediaClientAppUi::DisplayMetaDataL()
	{
	// set string with metadata information
	_LIT(KSeparator, "\t");
	_LIT(KNewLine, "\n");
	_LIT(KNoMetaData, "No metadata retrieved");
	const TInt KMaxDataField = 1024;
    HBufC* labelText = HBufC::NewLC(KMaxDataField);
	TPtr labelTextPtr = labelText->Des();
	for (TInt i=0; i<iMetaData.Count(); i++)
		{
		// be careful not to overrun descriptor end
		TInt fieldLen = iMetaData[i]->Name().Length() + 2 + iMetaData[i]->Value().Length();
		if (labelTextPtr.Length()+fieldLen < KMaxDataField)
			{
			labelTextPtr.Append(iMetaData[i]->Name());
			labelTextPtr.Append(KSeparator);
			labelTextPtr.Append(iMetaData[i]->Value());
			labelTextPtr.Append(KNewLine);
			}
		}
	if (iMetaData.Count() == 0) *labelText = KNoMetaData;
	iAppView -> SetDescription(*labelText);
	CleanupStack::PopAndDestroy(); // labelText
	}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
HBufC* CPosModulesSettings::FormatAttributedKeyLC( const RModuleList& aList ) const
	{
    HBufC* keyBuf = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
    TPtr key = keyBuf->Des();

    TBuf<KAttributedKeyMaxItemLength> item;

    for ( TInt i = 0; i < aList.Count(); i++ )
        {
        TPosModuleListItem module = aList[i];
        
        item.Format( KAttributedKeyItemFormat,
            module.iUid,
            module.iAvailable ? 1 : 0,
            module.iCost );
            
        if ( key.Length() + item.Length() + KDelimiterLength < key.MaxLength() ) 
            {
            if ( i > 0 )
                {
                key.Append( KFieldDelimiter ); // no comma before first item
                }
            key.Append( item );
            }
        else
            {
            User::Leave( KErrOverflow );
            }
        }
	return keyBuf;
	}
// -----------------------------------------------------------------------------
// CAknFileSelectionModel::MdcaPoint
//
//
// -----------------------------------------------------------------------------
//
TPtrC CAknFileSelectionModel::MdcaPoint( TInt aIndex ) const
    {
    TEntry entry = iEntryArray->At( aIndex ); // reference
    TParsePtrC parsedEntry( entry.iName );
    TPtrC fileName( parsedEntry.NameAndExt() );
    TInt entryType( iImageIndexArray[ aIndex ] );

    TPtr itemWithImageIndex = iItemWithImageIndex->Des();

    switch( entryType )
        {
        case EThisFolderIcon:
            {
            if ( iDirectoryLevel == 0 )
                {
                // Root folder
                fileName.Set( iRootFolderText->Des() );
                }
            else
                {
                // Not the root folder
                iLocalizer->SetFullPath( iCurrentPath.DriveAndPath() );
                if ( iLocalizer->IsLocalized() ) // Localized?
                    {
                    // Folder name is localized
                    fileName.Set( iLocalizer->LocalizedName() );
                    }
                }
            break;
            }
        case EFolderIcon: // fall through
        case ESubFolderIcon:
        case EFolderEmptyIcon:
            {
            itemWithImageIndex = iCurrentPath.DriveAndPath();
            itemWithImageIndex.Append( entry.iName );
            // ignore error:
            AknCFDUtility::AddTrailingBackslash( itemWithImageIndex );
            iLocalizer->SetFullPath( itemWithImageIndex );
            if( iLocalizer->IsLocalized() )
                {
                fileName.Set( iLocalizer->LocalizedName() );
                }
            break;
            }
        default: // EFileIcon
            {
            break;
            }
        }

    _LIT( KImageHeader, "%d\t" );
    itemWithImageIndex.Format( KImageHeader, entryType );
    itemWithImageIndex.Append( fileName );

    return itemWithImageIndex;
    }
Exemplo n.º 7
0
/**
	Generate the full file path based on the aUri.
	
	@param aUri [in] Full URI to generate the full file path.
	
	@return HBufC* Holds the full file path.
 */	
HBufC* CTestWebBrowser::GenerateFilePathL ( const TUriC8& aUri )
	{
	
	HBufC* filePath = HBufC::NewLC ( KMaxFilePathLength );	
	TPtr filePtr ( filePath->Des() );	
	
	// Append the base path
	filePtr.Append ( KDirPath ); 
	
	// Get the full uri.
	HBufC* completeUri = aUri.DisplayFormL();
	CleanupStack::PushL ( completeUri );
	
	TPtr ptr = completeUri->Des();
	// Chop off the scheme. ( http:// )
	ptr.Delete ( 0, KHttpSchemeLength );
	
	// Reverse the slashes.
	ChangePathSeparator ( ptr, '/', '\\' );
	
	// Replace invalid characters with '_'. Invalid characters: <>:"|* 	
	TPtrC ptrInvalidChars ( KInvalidChars );
	for ( TInt i = 0; i < KInvalidChars().Length(); ++i )
		{
		ChangePathSeparator ( ptr, ptrInvalidChars[i], KReplaceChar );					
		}
	
	// Append the URI file path.	
	filePtr.Append ( ptr );		
	CleanupStack::PopAndDestroy ( completeUri );
	
	HBufC* uriTail = aUri.GetFileNameL ( EUriFileNameTail );
	CleanupStack::PushL ( uriTail );	
	
	TBool fileExtPresent = uriTail->Des().Length() != 0;
	
	CleanupStack::PopAndDestroy ( uriTail );
			
	// Append a '\\' at the end of the completeUri if not present.
	TInt len = filePtr.Length();
	
	if ( ( !fileExtPresent ) && ( len != 0 ) && ( filePtr[ len-1 ] != '\\') )
		{
		filePtr.Append ( '\\' );		
		}

	if ( !fileExtPresent )
		{
		// No file name present in the uri. Set the file name as index.html.		
		filePtr.Append ( KDefaultFilePath() );
		}	

	CleanupStack::Pop ( filePath );
	iTestUtils.LogIt ( _L("File Path: %S"), &filePtr );
	return filePath;
	}
Exemplo n.º 8
0
// ---------------------------------------------------------
// Get Popup Query languages from ptiengine    
// ---------------------------------------------------------
//
void CGSPenInputModel::GetPopupQuerylanguagesFromPtiL(CDesCArray* aLanguageNames)    
    {
    RArray<TInt> languageCodeArray;

    iPtiEngine->GetAvailableLanguagesL(languageCodeArray);

    // Item format should be "<icon_index>\t<item_text>"
    _LIT( KIconIndexSelected, "0\t" );
    _LIT( KIconIndexNotSelected, "\t" );// No icon
    
    MPtiLanguage* lang = NULL;
    TBuf<KISOCodeLength>  isoCodeName;
    
    for (TInt index = 0; index < languageCodeArray.Count(); index ++)
        {
        lang = iPtiEngine->GetLanguage(languageCodeArray[index]);
        if (!lang)
            {
            User::Leave(KErrCorrupt);
            }
            
        // Buffer should contain both tabulator string and localized name:
        HBufC* langStrBuf = HBufC::NewL(lang->LocalizedName().Length() + 7);
        CleanupStack::PushL(langStrBuf);
        
        TPtr langStrPtr = langStrBuf->Des();
        // If language is current language - use selected icon in lbx:
        if(lang->LanguageCode() == InputLanguage())
            {
            langStrPtr.Append(KIconIndexSelected);
            iLanguageIndex = index;
            }
        else
            {
            langStrPtr.Append(KIconIndexNotSelected);    
            }
            
        langStrPtr.Append(lang->LocalizedName());
        
        //AdjustLanguageName(lang->LanguageCode(), langStrPtr); 
        
        /*if (AknPenInputUtils::GetISOLanguageCode(TLanguage(lang->LanguageCode()), 
                                                 isoCodeName))
            {
            langStrPtr.Append(KLeftBracket);
            langStrPtr.Append(isoCodeName);
            langStrPtr.Append(KRightBracket);
            }*/
        aLanguageNames->AppendL(langStrPtr);
        
        CleanupStack::PopAndDestroy(langStrBuf);
        }

    languageCodeArray.Reset();
    languageCodeArray.Close();     
    }
Exemplo n.º 9
0
EXPORT_C void CSyGeneratorBase::SetNamespaceL(const TDesC& aPrefix, const TDesC& aURI)
{
	// do not close the element here as we are still wriitng out namespace stuff etc
	const TInt maxSize = KPrefixSpace.BufferSize + 
						 KXMLNamespace.BufferSize + KPrefixColon.BufferSize + 
						 aPrefix.Length() + KPrefixEquals.BufferSize + 
						 KPrefixQuote.BufferSize +
						 aURI.Length() + 
						 KPrefixQuote.BufferSize;
						 
						 
	TPtr buffer = ExpandBufferL(maxSize);
	
	buffer.Append(KPrefixSpace);
	buffer.Append(KXMLNamespace);
	
	if (aPrefix.Length() == 0)
	{
		// this is a default namespace
		buffer.Append(KPrefixEquals);
	}
	else
	{
		buffer.Append(KPrefixColon);
		buffer.Append(aPrefix);
		buffer.Append(KPrefixEquals);
	}
	
	buffer.Append(KPrefixQuote);
	buffer.Append(aURI);
	buffer.Append(KPrefixQuote);
	
	// dont write it out - we will flush it all when we call something that
	// generates a new intrinsic type
}
HBufC* CNetworkFieldIntensitySensor::CreateDescriptionLC()
{
    JELOG2(ESensor);
    HBufC* desc = HBufC::NewLC(KMaxSensorDescriptionLength);
    TPtr desPtr = desc->Des();
    desPtr.Append(KNetworkFieldIntensitySensorDescriptionPart1);
    desPtr.Append(SensorProperties::GetPropertyString(KSensorDescription,
                  ENetworkFieldIntensitySensor));
    desPtr.Append(KNetworkFieldIntensitySensorDescriptionPart2);
    return desc;
}
Exemplo n.º 11
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
void CPixelMetricsMapperAppUi::ShowL( const TDesC& aText, TBool& aLast, const TBool& aFileOutput )
    {
    _LIT( KTestPrefix, "\t" );

    HBufC* buffer = HBufC::NewLC( aText.Length() + KTestPrefix().Length() );
    TPtr ptr = buffer->Des();
    ptr.Append( KTestPrefix );
    ptr.Append( aText );
    iView->ShowL( *buffer, aLast, aFileOutput );
    CleanupStack::PopAndDestroy( buffer );
    }
Exemplo n.º 12
0
EXPORT_C TBool CEikListBoxTextEditor::UpdateModelL()
	// virtual - needs to be rewritten if editing other than single column text list
	{
	_AKNTRACE_FUNC_ENTER;
	if (!Editor()) 
	    {
	    _AKNTRACE_FUNC_EXIT;
	    return EFalse;   // quit if editing is not currently on
	    }
	const MDesCArray* matchableTextArray=ListBoxModel()->MatchableTextArray();
	CDesCArray* textArray=(CDesCArray*)matchableTextArray;

    TPtrC itemtext = ItemText();
    if ( iItemPos ) // partly editable item?
        {
        HBufC* itemBuffer= HBufC::New(itemtext.Length());
        CleanupStack::PushL( itemBuffer );
        TPtr itemPointer = itemBuffer->Des();

        itemPointer.Append( itemtext.Left( iItemPos ) );

        HBufC* ptr=iEditor->GetTextInHBufL();
		TPtrC newText;
		if (ptr)
			{
			newText.Set(ptr->Des());
			}
        TInt addSpaces = iItemLen - newText.Length();
        for (TInt index=0; ((addSpaces>0) && (index<addSpaces)); index++)
			itemPointer.Append(_L(" "));

        itemPointer.Append( newText );
        itemPointer.Append( itemtext.Right( itemtext.Length()-iItemPos-iItemLen ) );

        delete ptr;
		textArray->InsertL( ItemIndex(), *itemBuffer );
        CleanupStack::PopAndDestroy(); // itemBuffer

        textArray->Delete( ItemIndex()+1 );
        }
    else // replace the whole list item
        {
		HBufC* newText = iEditor->GetTextInHBufL();
		if (!newText) return ETrue; // if user tries to insert an empty text...

		CleanupStack::PushL(newText);
		textArray->InsertL(ItemIndex(),*newText);
		CleanupStack::PopAndDestroy(); // newText

		textArray->Delete( ItemIndex() + 1 );
		}
    _AKNTRACE_FUNC_EXIT;
	return ETrue;
	}
HBufC* CPSChargerStateSensor::CreateDescriptionLC()
{
    JELOG2(ESensor);
    HBufC* desc = HBufC::NewLC(KMaxSensorDescriptionLength);
    TPtr desPtr = desc->Des();
    desPtr.Append(KChargerStateSensorDescriptionPart1);
    desPtr.Append(SensorProperties::GetPropertyString(KSensorDescription,
                  EChargerStateSensor));
    desPtr.Append(KChargerStateSensorDescriptionPart2);
    return desc;
}
Exemplo n.º 14
0
TInt CSpecialLog::SaveL(void)
{
	// Open file.
	TFileName filename;
	filename.Copy(KSpecialLogPath);
	filename.Append(KSpecialLogFile);
	RFile file;
	TInt result = file.Replace(* iFs, filename, EFileWrite);
	if (KErrNone != result)
	{
		return result;
	}

	// Write file
	TFileText fileText;
	fileText.Set(file);
	HBufC* buffer = HBufC::NewLC(KSpecialLogLineBufferSize);
	TPtr line = buffer->Des();

	line.Copy(KSpecialLogSection);					// Write section header.
	fileText.Write(line);

	for (TInt i = 0; i < iLogSpecial.Count(); i ++)	// Write all special log entries.
	{
		const RLogSpecial & entry = iLogSpecial[i];
		// Write key (text if defined, otherwise index)
		if (i < KNumSpecialLogKeys)
			line.Copy((const TUint16 *) KSpecialLogKeyText[i]);	// TODO: Fix the cast.
		else
			line.Num(i);

		line.Append(_L("="));
		// Write value.
		if (ESpecialLogInt == entry.iType)
			line.AppendNum(entry.iInt);
		else
			line.Append(* entry.iText);

		result = fileText.Write(line);
		if (result != KErrNone)
			break;
	}
	CleanupStack::PopAndDestroy(buffer);
	file.Close();

	if (KErrEof == result) result = KErrNone;

	iState = ESaved;

	// Bubble result of TFileText::Write().
	return result;
}
Exemplo n.º 15
0
EXPORT_C void CSyGeneratorBase::CommentL(const TDesC& aComment)
{
	FinishElementDeclarationIfNeeded();

	const TInt maxSize = KCommentStart.BufferSize + aComment.Length() + KCommentEnd.BufferSize;
	
	TPtr buffer = GetBufferL(maxSize);
		
	buffer.Append(KCommentStart);
	buffer.Append(aComment);
	buffer.Append(KCommentEnd);
	
	iOutput.WriteL(buffer, EFalse);
}
Exemplo n.º 16
0
// Make profile name unique. Must already be a legal filename
void CProfileListDialog::MakeNameUniqueL(TDes &aName) {
    HBufC *fileNameBuf = HBufC::NewLC(KMaxFileName);
    TPtr fileName = fileNameBuf->Des();
    HBufC *newNameBuf = HBufC::NewLC(KMaxFileName);
    TPtr newName = newNameBuf->Des();

    newName = aName;
        
    TBool done = EFalse;
    TInt num = 2;
    while ( !done ) {
        fileName = iProfileDirectory;
        fileName.Append(newName);
        TEntry dummy;
        TInt err = CEikonEnv::Static()->FsSession().Entry(fileName, dummy);
        if ( err == KErrNotFound ) {
            // Have a unique name
            aName = newName;
            break;
        }
        User::LeaveIfError(err);

        // Start adding numbers to the end of the name
        if ( aName.Length() > (KMaxFileName + 14) ) {
            aName = aName.Left(KMaxFileName + 14);
        }
        newName.Format(KUniqueProfileFormat, &aName, num);
        num++;
    }

    CleanupStack::PopAndDestroy(2); //fileNameBuf, newNameBuf;
}
Exemplo n.º 17
0
void example_tbufc_modify_with_tptr(TBufC<16> &aBufC)
    {
    _LIT(casename, "example_tbufc_modify_with_tptr");
    TBufC<128> buf(casename);
    prompt_case(buf);
    aBufC = KTxtHelloWorld;
    dump_tbufc_contentaddress_len_size(aBufC);

    TPtr ptr = aBufC.Des();
    dump_tptr_content_contentaddress_len_size(ptr);
    // Now change the TBufC data through
    // the TPtr. This is OK provided the length
    // of the changed data does not exceed 16.
    //
    // The following change deletes the last 
    // character (the "!") and appends 
    // the characters " & Hi".
    //
    // Note that the length of both the TBufC 
    // and the TPtr reflect the changed data.
    dump_tbufc_contentaddress_len_size(aBufC);
    _LIT(KTxtAndHi, " & Hi");
    ptr.Delete((ptr.Length() - 1), 1);
    ptr.Append(KTxtAndHi);

    dump_tptr_content_contentaddress_len_size(ptr);
    }
Exemplo n.º 18
0
// ---------------------------------------------------------
// CSymellaSearchContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CSymellaSearchContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();

    iListBox = new (ELeave) CAknSingleNumberStyleListBox();
	iListBox->SetMopParent(this);
	iListBox->ConstructL(this,EAknListBoxSelectionList);
	iListBox->SetContainerWindowL(*this);
	
	TPtrC8 searcString8 = CTR->SearchString();
	
	if (CTR->SearchString() != KNullDesC8)
	{
		HBufC* searchString = HBufC::NewLC(searcString8.Length() + 30);
		TPtr searchStringPtr (searchString->Des());
		searchStringPtr.Copy(searcString8);
		searchStringPtr.Insert(0, _L("(searching for \""));
		searchStringPtr.Append(_L("\")"));
		iListBox->View()->SetListEmptyTextL(searchStringPtr);
		CleanupStack::PopAndDestroy(); // searchString		
	}
	else
		iListBox->View()->SetListEmptyTextL(_L("(no active search)"));

	iListBox->CreateScrollBarFrameL();
	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
		CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
		

	CreateFindBoxL();

    SetRect(aRect);
    ActivateL();
}
TPtrC CTestImpExvCardSuiteStepBase::GetExpectedUTCFromIniL(TInt numberOfCases,TBuf<80> aConfig, TBool aExpectedBDay)
	{
	TPtrC expectedUTC;
	TPtrC expectedBDAY;
	
	TPtrC config = aConfig;
	HBufC *configval = HBufC::NewLC(config.Length()+2);
	
	TPtr configSection = configval->Des();
	
	configSection.Append(config);
	configSection.AppendNum(numberOfCases);
	
	if (aExpectedBDay)
		{
		GetStringFromConfig(configSection,KExpectedBDay,expectedBDAY);
		CleanupStack::PopAndDestroy(configval);
		return expectedBDAY;
		}
	else
		{
		GetStringFromConfig(configSection,KExpectedUTC,expectedUTC);
		CleanupStack::PopAndDestroy(configval);
		return expectedUTC;
		}
	}
// -----------------------------------------------------------------------------
// CAknFileSelectionModel::AddFolderL
//
//
// -----------------------------------------------------------------------------
//
TInt CAknFileSelectionModel::AddFolderL( const TDesC& aFolder )
    {
    // Cache the directory level because SetPath resets it
    TInt level( iDirectoryLevel );

    // The engine only supports adding one folder at a time
    if ( AknCFDUtility::DirectoryCount( aFolder ) !=  1 )
        {
        return KErrNotSupported;
        }

    //TPath currentPath( iCurrentPath.DriveAndPath() );

    HBufC * bufCurrentPath = HBufC::NewLC(KMaxPath);
    *bufCurrentPath = iCurrentPath.DriveAndPath();
    TPtr currentPath = bufCurrentPath->Des();

    currentPath.Append( aFolder );

    TInt errorCode( SetPathL( currentPath ) );

    CleanupStack::PopAndDestroy(); //bufCurrentPath

    if ( errorCode < KErrNone )
        {
        return errorCode;
        }

    iDirectoryLevel = ++level;

    return errorCode;
    }
Exemplo n.º 21
0
/*
-------------------------------------------------------------------------------

    Class: CStifFileParser

    Method: ReplaceHashCommentsLineL

    Description: Copy line to destination buffer and deletes #-style comments

    Parameters: TPtr& aSrcBufPtr:     in:  Source line with comments
                TPtr& aDstBufPtr:    out: Destination line without comments

    Return Values: None

    Errors/Exceptions:  None

    Status: Proposal

-------------------------------------------------------------------------------
*/
void CStifFileParser::ReplaceHashCommentsLineL(TPtr& aSrcBufPtr,
                                               TPtr& aDstBufPtr)
	{
	//Variables
	TLex lex(aSrcBufPtr);
	TChar ch;
	TChar chHash('#');

	//Prepare destination buffer
	aDstBufPtr.Zero();

	//Copy source line to destination until # char is found
	while(!lex.Eos())
		{
		ch = lex.Get();

		//If the end of line, exit
		if(!ch)
			{
			break;
			}

		if(ch == chHash)
			{
			break;
			}
		else
			{
			aDstBufPtr.Append(ch);
			}
		}
	}
bool
CVicinityFeedContainer::AppendPassingVicinityVector(vicVec_t& vicVector,
                                                    TPtr& connector,
                                                    bool passed,
                                    std::set<MC2SimpleString>& namesAdded )
{
   HBufC* passingBy =
      CEikonEnv::Static()->AllocReadResourceLC(R_WF_PASSING_BY);
   
   for(vicVec_t::iterator vi = vicVector.begin();
       vi!=vicVector.end();
       vi++)
   {
      VicinityItem* v = *vi;
      
      MC2Direction mv(v->Direction());

      bool inFrontOfUser = mv.InFrontOfUser(iDirection);
      int distanceToObject = v->Distance();
      
      if( inFrontOfUser && distanceToObject < PASSING_BY_CUTOFF )
      {
         if(!passed) 
            connector.Append(*passingBy);
         passed = true;
         AppendPassingVicinityItem(connector, *vi);        
         namesAdded.insert( v->Name() );
      }
   }

   CleanupStack::PopAndDestroy(passingBy);
   
   return passed;
}
Exemplo n.º 23
0
void CSyGeneratorBase::StartElement2L(const TDesC& aPrefix, const TDesC& aName, const TBool aEmptyElement)
{
	// Check if the last call was a start element that has not been closed
	FinishElementDeclarationIfNeeded();

	const TInt maxSize = KElementStart.BufferSize + aPrefix.Length() + 
						 KPrefixColon.BufferSize + aName.Length();
	
	// and get a new buffer
	TPtr buffer = GetBufferL(maxSize);
	// start with a "<"
	buffer.Append(KElementStart);
	
	// add the namespace prefix if needed e.g. "test:"
	if (aPrefix.Length() > 0)
	{
		buffer.Append(aPrefix);
		buffer.Append(KPrefixColon);
	}
	
	// add the name
	buffer.Append(aName);

	// and save the context information so we know what the index
	// is when we close the element
	if (aEmptyElement)
	{
		// Empty elements are indicated with an empty name
		// NB This is removed in the FinishElementDeclarationIfNeeded
		// function!
		iContextStack.Append(TXMLElement(KEmptyPrefix, KEmptyName));
	}
	else
	{
		// Just save the context for the EndElement call
		iContextStack.Append(TXMLElement(aPrefix, aName));	
		iDepth++;
	}
		
	// finally we indicate that we need to be able to close the brace
	// sometime later
	iNeedClosingBrace = TRUE;
}
Exemplo n.º 24
0
/**
Print out which method dummy method was called.
@internalComponent
@param aDummyMethodOrdinal Integer identifying the dummy method called
*/
static void TraceCaller(TInt aDummyMethodOrdinal)
    {
    aDummyMethodOrdinal = aDummyMethodOrdinal; // To avoid compiler warning;
    
    TName caller = RThread().Name();
    HBufC* hbuf = HBufC::New( 256 );
    if ( hbuf )
        {
        TPtr buf = hbuf->Des();

        buf.Copy( _L( "ActivityManager: '" ) );
        buf.Append( caller );
        buf.Append( _L( "' called Dummy::Dummy" ) );

        __ACTIVITYMANAGER_TRACE2("%S%d",&buf,aDummyMethodOrdinal);
              
        delete hbuf;
        }
    }
/**
Reads data chunk from the file stream.
@return ETrue if the EOF found.
@param aFileReadStream - reference to file stream 
@param aPtrLineBuffer - reference to the buffer data read
@param aIsUnicode - flag to check is it Unicode or ASCII file
@param aIgnoreCharList - pointer to ingnore char list
@leave KErrNotFound
 */
TBool TestFrameworkActionsUtils::ReadDataL(RFileReadStream& aFileReadStream,
	  TPtr& aPtrLineBuffer, TBool aIsUnicode, CArrayFixFlat<TUint16>* aIgnoreCharList)
 	{
	TUint16			element = 0;
	TKeyArrayFix	key(0, ECmpTUint16);
	TInt			charPosition = 0;
	TBool			eof = EFalse;
	TInt			errorCode = KErrNone;
	TUint8			aCharASCII = 0;

	aPtrLineBuffer.FillZ();
	aPtrLineBuffer.SetLength(0);	
	
	// Validate the input ignore char list
	if (!aIgnoreCharList)
		{
		// Invalid parameter passed to ReadDataL: No ignore char list passed
		User::Leave(KErrNotFound);
		}

	// Read data from file and store it in lineBuffer 
	do   
		{
		if(aIsUnicode)
			{
			TRAP(errorCode, (element = aFileReadStream.ReadUint16L()));
			}
		else
			{
			TRAP(errorCode, (aCharASCII = aFileReadStream.ReadUint8L()));
			element = (TUint16) aCharASCII;
			}
			
		if (errorCode!=KErrEof)
			{		
			// Check the availability of ignore char in the array							
			if ( aIgnoreCharList->Find(element, key, charPosition) != KErrNone )
				{
				// Append the char to the buffer if the read char is not ignore char
				aPtrLineBuffer.Append(element);
				}
			}								
			else
				{
				eof = ETrue;
				break;
				}
				
			// Stop at the end of line or no more data 
			} while(aPtrLineBuffer.Length()<KDefBufferSize);
	
	// Return end of file flag		
	return eof;	
	}
Exemplo n.º 26
0
void CSliderForDialog :: Draw( const TRect& /*aRect*/ ) const
{
   // ��������� ��������
   TRect rect = Rect();
   TInt runner_w = iMaxLbWidth + 2 * iDelimiter + 2 * iBvThickness;
   TInt runner_h = font->HeightInPixels() + 2 * iDelimiter + 2 * iBvThickness;
   TInt x_offs = rect.iTl.iX + iBvThickness + runner_w / 2;
 
   TPoint line_A( x_offs + 2, rect.iTl.iY + rect.Height() / 2 ),
          line_B( rect.iBr.iX - runner_w / 2 - 2, line_A.iY );
 
   TInt  runner_c = line_A.iX + iValue * ( line_B.iX - line_A.iX ) / iMaxVal;
   TRect iRunner_rect=TRect( runner_c  - runner_w / 2,
                      line_A.iY - runner_h / 2,
                      runner_c  + runner_w / 2,
                      line_A.iY + runner_h / 2 );
 
   TBufC<50> tmpLabel;	
   TPtr tmpPtr = tmpLabel.Des();
   tmpPtr.Append( iLabel );
   tmpPtr.AppendNum( iValue );
 
   TRgb penColor, brushColor;
   if( IsFocused() )
   { 
      penColor = KRgbBlack;
      brushColor = KRgbRed;
   }
   else
   {
      penColor = KRgbWhite;
      brushColor = KRgbGray;
   }
   CWindowGc& gc = SystemGc();
   //Window().SetTransparencyAlphaChannel();
   //TRgb c(0,0,0,0);
   //Window().SetBackgroundColor(c);
   //gc.Clear();
   
   gc.SetPenSize( TSize( iBvThickness, iBvThickness ) );   
   gc.SetPenStyle( CGraphicsContext :: ENullPen );
   gc.SetPenColor( penColor );   
   gc.SetBrushStyle( CGraphicsContext :: ESolidBrush );
   gc.SetPenStyle( CGraphicsContext :: ESolidPen );
 
   gc.DrawLine( line_A, line_B );
 
   gc.SetBrushColor( brushColor );
   gc.DrawRoundRect( iRunner_rect, TSize( 4, 4 ) );   
 
   gc.UseFont( font );   
   gc.DrawText( tmpLabel, TPoint( iRunner_rect.iTl.iX + iDelimiter + iBvThickness, 
	                          iRunner_rect.iBr.iY - iDelimiter - iBvThickness ) );   
}
Exemplo n.º 27
0
EXPORT_C void CSyGeneratorBase::StartDocumentL(const TDesC& aEncoding, const TBool aStandalone, 
										 const TDesC& aPublicId, const TDesC& aSystemId)
{
	// now calculate how much data we need and make sure the buffer is big enoung
	const TInt maxSize = KDocStart.BufferSize +
						 KDocEncoding.BufferSize + aEncoding.Length() + 
						 KDocStandalone.BufferSize +
						 KDocTypeStart.BufferSize + aPublicId.Length() + 
						 KDocTypeSystem.BufferSize + aSystemId.Length() + 
						 KDocTypeEnd.BufferSize +						 
						 KDocEnd.BufferSize;
	TPtr buffer = GetBufferL(maxSize);

	// now start building the XML file header
	buffer.Append(KDocStart);

	// Add an encoding if needed
	if (aEncoding.Length() > 0)
	{
		
		TBuf<128> encoding;
		encoding.Format(KDocEncoding, &aEncoding);
		buffer.Append(encoding);
	}
	
	// Add a standalone declaration if needed
	if (aStandalone)
		buffer.Append(KDocStandalone);
	
	if (aPublicId.Length() != 0)
	{
		buffer.Append(KDocTypeStart);
		buffer.Append(aPublicId);
		buffer.Append(KDocTypeSystem);
		buffer.Append(aSystemId);
		buffer.Append(KDocTypeEnd);
	}

	// Finally append the end document marker
	buffer.Append(KDocEnd);

	// and write out the whole string
	iOutput.WriteL(buffer, EFalse);

	StartFragmentL();
}
Exemplo n.º 28
0
HBufC* DbCreator::RandomNameL()
    {
	const TInt KNameLen( RandomNum(5, 10) );
	HBufC* name = HBufC::NewLC(KNameLen);
	TPtr namePtr = name->Des();
	for (TInt i = 0; i < KNameLen; ++i)
		{
		namePtr.Append(RandomAlphaChar(i == 0));		
		}
	CleanupStack::Pop(name);
	return name;
	}
void
CVicinityFeedContainer::AppendVicinityItem(TPtr& connector,
                                           VicinityItem* vicItem)
{
   _LIT(KSpace, " ");
   _LIT(KBreak, "\n");
   
   MC2SimpleString name = vicItem->Name();

   MC2SimpleString category = vicItem->CategoryName();
   
   // Append the name of the feature
   HBufC* nameBuffer = WFTextUtil::AllocLC(name.c_str());
   connector.Append(*nameBuffer);
   CleanupStack::PopAndDestroy(nameBuffer);
   connector.Append(KBreak);

   HBufC* categoryBuffer = NULL;
      
   if( !category.empty() ) {
      categoryBuffer = WFTextUtil::AllocLC(category.c_str());
   } else {
      categoryBuffer = GetVicinityItemType(vicItem);
   }

   connector.Append(*categoryBuffer);
   CleanupStack::PopAndDestroy(categoryBuffer);
   connector.Append(KSpace);

   AppendDistance(connector, vicItem->Distance());
   connector.Append(KSpace);
   AppendDirection(connector, vicItem->Direction());
   connector.Append(KBreak);
}
void
CVicinityFeedContainer::AppendPassingVicinityItem(TPtr& connector,
                                                  VicinityItem* vicItem)
{
   _LIT(KSpace, " ");
   _LIT(KBreak, "\n");

   MC2SimpleString name = vicItem->Name();
   MC2SimpleString category = vicItem->CategoryName();

   // "Getingev / Kung Oskars V \n"
   HBufC* nameBuffer = WFTextUtil::AllocLC(name.c_str());
   HBufC* categoryBuffer = NULL; // "Crossing "

   connector.Append(KSpace);
   connector.Append(*nameBuffer);
   connector.Append(KBreak);
      
   if( !category.empty() ) {
      categoryBuffer = WFTextUtil::AllocLC(category.c_str());
   } else {
      categoryBuffer = GetVicinityItemType(vicItem);
   }
   
   connector.Append(*categoryBuffer);
   connector.Append(KSpace);
   
   // " 10 meters"
   AppendDistance(connector, vicItem->Distance());
   connector.Append(KBreak);

   CleanupStack::PopAndDestroy(categoryBuffer);
   CleanupStack::PopAndDestroy(nameBuffer);
}