Example #1
0
// Compare the right hand side of the atom with the match string.
TBool CImapAtom::CompareTail(const TDesC8& aVal)
	{
	if (aVal.Length() > iAtom.Length())
		return EFalse;
	TPtrC8 ptr = iAtom.Right(aVal.Length());
	return(ptr.CompareF(aVal)==0);
	}
//---------------------------------------------------------------
// CNativeMmsUtility::getBodyTextFromAttManL
// @see header
//---------------------------------------------------------------
void CNativeMmsUtility::getBodyTextFromAttManL(QString& returnbuf)
{
#ifdef _DEBUG_TRACES_
    qDebug() << " Enter CNativeMmsUtility::getBodyTextFromAttManL";
#endif

    TUint count = iattachmanager->AttachmentCount();
    for (int i = 0; i < count; i++)
    {
        CMsvAttachment *attachment = iattachmanager->GetAttachmentInfoL(i);
        TPtrC8 mimetype = attachment->MimeType();

        if (!isAttachment(attachment) && mimetype.CompareF(KMsgMimeTextPlain)
                == 0)
        {
            QString filepath =
                    XQConversions::s60DescToQString(attachment->FilePath());
            readFileIntoBuffer(filepath, returnbuf);
            break;
        }
    }

#ifdef _DEBUG_TRACES_
    qDebug() << " Exit CNativeMmsUtility::getBodyTextFromAttManL";
#endif

    return;
}
// ---------------------------------------------------------------------------
// CPIMParserProperty::MatchContactField
// ---------------------------------------------------------------------------
//
TPIMField CPIMParserProperty::MatchToDoField() const
{
    JELOG2(EPim);
    TPIMField field = KErrNotFound;
    TPtrC8 name = Name();

    if (name.CompareF(KVersitTokenDUE) == 0)
    {
        field = EPIMToDoDue;
    }
    else if (name.CompareF(KVersitTokenCOMPLETED) == 0)
    {
        field = EPIMToDoCompletionDate;
    }
    else if (name.CompareF(KVersitTokenLASTMODIFIED) == 0)
    {
        field = EPIMToDoRevision;
    }
    else if (name.CompareF(KVersitTokenSUMMARY) == 0)
    {
        field = EPIMToDoSummary;
    }
    else if (name.CompareF(KVersitTokenDESCRIPTION) == 0)
    {
        field = EPIMToDoNote;
    }
    else if (name.CompareF(KVersitTokenPRIORITY) == 0)
    {
        field = EPIMToDoPriority;
    }
    else if (name.CompareF(KVersitTokenDALARM) == 0)
    {
        field = EPIMToDoExtAlarm;
    }
    else if (name.CompareF(KVersitTokenSTATUS) == 0)
    {
        field = EPIMToDoCompleted;
    }
    else if (name.CompareF(KVersitTokenUID) == 0)
    {
        field = EPIMToDoUid;
    }
    return field;
}
Example #4
0
/**
	Parses the descriptor aUri into uri components.
	
	@since			6.0
	@param			aUri A reference to a descriptor pointer to be parsed.
	@return			KErrNone if the descriptor has been parsed into uri components.
	KUriUtilsParserErrInvalidUri if the descriptor is an invalid uri.
	KErrNoMemory if out of memory
	@post			The object references the input descriptor.
 */
EXPORT_C TInt TUriParser8::Parse(const TDesC8& aUri)
	{
	// Reset the Uri information and then set the Uri
	if( iUriDes.Length() )
		{
		Reset();
		}
	iUriDes.Set(aUri);

	// Check uri is valid
	if( iUriDes.Length() && iUriDes[0]==KSchemeDelimiter )
		{
		return KUriUtilsErrInvalidUri;
		}
	
	TPtrC8 schemeComponent;
	RetrieveScheme(iUriDes,schemeComponent);
	CGenericUriParser* UriHandler = NULL;
	TInt err=KErrNone;
	if(schemeComponent.CompareF(KSIP()) == 0 || schemeComponent.CompareF(KSIPS()) == 0 )
		{
	    TRAP(err,UriHandler = CSIPUriParser::NewL());
		}
	else
		{
	    TRAP(err,UriHandler = CGenericUriParser::NewL());
 		}
	if(UriHandler)
		{
		UriHandler->DoParseUri(iUriDes, iComponent);
		delete UriHandler;
		}
       
		return err;      

	}
//---------------------------------------------------------------
// CNativeMmsUtility::getAttachmentListFromAttManL
// @see header
//---------------------------------------------------------------
void CNativeMmsUtility::getAttachmentListFromAttManL(
                                                     ConvergedMessageAttachmentList& attachmentlist)
{
#ifdef _DEBUG_TRACES_
    qDebug() << " Enter CNativeMmsUtility::getAttachmentListFromAttManL";
#endif

    TUint count = iattachmanager->AttachmentCount();
    for (int i = 0; i < count; i++)
    {
        CMsvAttachment *attachment = iattachmanager->GetAttachmentInfoL(i);
        TPtrC8 mimetype = attachment->MimeType();
        QString filepath =
                XQConversions::s60DescToQString(attachment->FilePath());
        // converting directory separators from native to
        // universal (QT) format
        filepath.replace(KBackwardSlash, KForwardSlash);
        quint16 attachmenttype;
        if (isAttachment(attachment))
            attachmenttype = ConvergedMessageAttachment::EAttachment;
        else
            attachmenttype = ConvergedMessageAttachment::EUnknown;

        //smil files aren't of either type
        if (mimetype.CompareF(KMsgMimeSmil) == 0)
        {
            ConvergedMessageAttachment
                    * targetatt =
                            new ConvergedMessageAttachment(filepath,
                                                           ConvergedMessageAttachment::ESmil);
            attachmentlist << targetatt;
        }
        else
        {
            ConvergedMessageAttachment* targetatt =
                    new ConvergedMessageAttachment(filepath, attachmenttype);
            attachmentlist << targetatt;
        }
    }

#ifdef _DEBUG_TRACES_
    qDebug() << " Exit CNativeMmsUtility::getAttachmentListFromAttManL";
#endif

}
// ---------------------------------------------------------------------------
// CPIMParserProperty::MatchContactField
// ---------------------------------------------------------------------------
//
TPIMField CPIMParserProperty::MatchEventField() const
{
    JELOG2(EPim);
    TPIMField field = KErrNotFound;
    TPtrC8 name = Name();
    if (name.CompareF(KVersitTokenDTSTART) == 0)
    {
        field = EPIMEventStart;
    }
    else if (name.CompareF(KVersitTokenDTEND) == 0)
    {
        field = EPIMEventEnd;
    }
    else if (name.CompareF(KVersitTokenLASTMODIFIED) == 0)
    {
        field = EPIMEventRevision;
    }
    else if (name.CompareF(KVersitTokenSUMMARY) == 0)
    {
        field = EPIMEventSummary;
    }
    else if (name.CompareF(KVersitTokenDESCRIPTION) == 0)
    {
        field = EPIMEventNote;
    }
    else if (name.CompareF(KVersitTokenLOCATION) == 0)
    {
        field = EPIMEventLocation;
    }
    else if (name.CompareF(KVersitTokenDALARM) == 0)
    {
        field = EPIMEventAlarm;
    }
    else if (name.CompareF(KVersitTokenUID) == 0)
    {
        field = EPIMEventUid;
    }
    return field;
}
/**
Checks whether this is a STATUS response.
If it is, then it starts buiding an atom tree.  
If the tree is completed then the data is parsed straight away.  Otherwise, more data is requested.
If the atom tree is completed by this line, then tree is parsed to decode the response.
@return ENotRecognised if this is not a STATUS response
		EResponseIncomplete if this is a STATUS resposne, but more data is required.
		ECompleteUntagged if this is a STATUS response that has been fully parsed.
*/
CImapCommand::TParseBlockResult CImapStatus::ParseUntaggedResponseL()
	{
	TParseBlockResult result = ENotRecognised;
	
	TPtrC8 response = GetNextPart();
	if(response.CompareF(KImapTxtStatus) == 0)
		{
		TPtrC8 remainingData = Remainder();
   		TBool wantMoreData = iAtomParser->ProcessLineL(remainingData);
   		if (wantMoreData)
   			{
   			result = EResponseIncomplete;
   			}
   		else
   			{
   			ParseStatusResponseL();
   			result = ECompleteUntagged;
   			}
		}
	
	return result;
	}
// ---------------------------------------------------------------------------
// CPIMParserProperty::MatchContactField
// ---------------------------------------------------------------------------
//
TPIMField CPIMParserProperty::MatchContactField() const
{
    JELOG2(EPim);
    TPIMField field = KErrNotFound;
    TPtrC8 name = Name();
    if (name.CompareF(KVersitTokenADR) == 0)
    {
        field = EPIMContactAddr;
    }
    else if (name.CompareF(KVersitTokenN) == 0)
    {
        field = EPIMContactName;
    }
    else if (name.CompareF(KVersitTokenORG) == 0)
    {
        field = EPIMContactOrg;
    }
    else if (name.CompareF(KVersitTokenChildren) == 0)
    {
        field = EPIMContactExtChildren;
    }
    else if (name.CompareF(KVersitTokenBDAY) == 0)
    {
        field = EPIMContactBirthday;
    }
    else if (name.CompareF(KVersitTokenREV) == 0)
    {
        field = EPIMContactRevision;
    }
    else if (name.CompareF(KVersitTokenAnniversary) == 0)
    {
        field = EPIMContactExtAnniversary;
    }
    else if (name.CompareF(KVersitTokenEMAIL) == 0)
    {
        field = EPIMContactEmail;
    }
    else if (name.CompareF(KVersitTokenNOTE) == 0)
    {
        field = EPIMContactNote;
    }
    else if (name.CompareF(KVersitTokenTEL) == 0 || name.CompareF(
                 KPIMVersitTokenASSTTEL) == 0)
    {
        field = EPIMContactTel;
    }
    else if (name.CompareF(KVersitTokenTITLE) == 0)
    {
        field = EPIMContactTitle;
    }
    else if (name.CompareF(KVersitTokenURL) == 0)
    {
        field = EPIMContactUrl;
    }
    else if (name.CompareF(KPIMVersitTokenNICKNAME) == 0)
    {
        field = EPIMContactNickname;
    }
    else if (name.CompareF(KPIMVersitTokenDTMF) == 0)
    {
        field = EPIMContactExtDtmf;
    }
    else if (name.CompareF(KPIMVersitTokenWVID) == 0)
    {
        field = EPIMContactExtWvUserId;
    }
    else if (name.CompareF(KVersitTokenAssistant) == 0)
    {
        field = EPIMContactExtAssistantName;
    }
    else if (name.CompareF(KVersitTokenChildren) == 0)
    {
        field = EPIMContactExtChildren;
    }
    else if (name.CompareF(KVersitTokenSpouse) == 0)
    {
        field = EPIMContactExtSpouse;
    }
    else if (name.CompareF(KPIMVersitTokenSIP) == 0)
    {
        // Check that if this is VOIP field
        if (ContainsParameter(KPIMVersitTokenVoip))
        {
            field = EPIMContactExtVoip;
        }
        // Check that if this is POC field
        else if (ContainsParameter(KPIMVersitTokenPoc))
        {
            field = EPIMContactExtPTT;
        }
        // Check that if this is SWIS field
        else if (ContainsParameter(KPIMVersitTokenSwis))
        {
            field = EPIMContactExtSWIS;
        }
        else
        {
            field = EPIMContactExtSip;
        }
    }
    else if (name.CompareF(KVersitTokenUID) == 0)
    {
        field = EPIMContactUid;
    }
    return field;
}
EXPORT_C void CTestConfig::ReadScriptL(const TDesC& aScript)
	{
	iSections.ResetAndDestroy();

	CTestConfigSection* section = NULL;
	CTestConfigItem* currentItem = NULL;
	TInt currentItemStart = 0;
	CTestConfigSection* sectionDefaults = NULL;

	HBufC8* scriptContents = ReadFileL(aScript);
	CleanupStack::PushL(scriptContents);

	TLex8 input(*scriptContents);

	while (!input.Eos())
		{
		input.SkipSpaceAndMark();
		input.SkipCharacters();

		if ( input.TokenLength() == 0)    // if valid potential token
			{
			//end of the script file found
			break;
			}

		const TPtrC8 token(input.MarkedToken());

		if (token.CompareF(_L8("endscript")) == 0)
			{
			//end of the script file found
			break;
			}
		else if (IsNewSection(*scriptContents, input))
			{
			ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem);

			TInt mid = 1;
			TInt len = token.Length() - 2;

			const TPtrC8 sectionName(token.Mid(mid, len));

			if (sectionDefaults != NULL)
				section = CTestConfigSection::NewLC(sectionName, *sectionDefaults);
			else
				section = CTestConfigSection::NewLC(sectionName);

			if (sectionDefaults == NULL && IsDefaultSection(section->SectionName()))
				sectionDefaults = section;

			User::LeaveIfError(iSections.Append(section));
			CleanupStack::Pop(section);
			}
		else if (section != NULL)
			{
			TInt valueOffset;
			TPtrC8 newItem;

			if (IsNewComment(*scriptContents, input))
				{
				ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem);
				__ASSERT_DEBUG(currentItem == NULL, User::Invariant());
				SkipToNextLine(input);
				}
			else if (IsNewItem(*scriptContents, input, newItem, valueOffset))
				{
				ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem);
				currentItemStart = input.MarkedOffset() + valueOffset;
				currentItem = &section->AddItemL(newItem, KNullDesC8);
				}
			}
		}

	ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem);
	CleanupStack::PopAndDestroy(scriptContents);
	}
//---------------------------------------------------------------
// CNativeMmsUtility::getRemainingAttachmentsFromAttManL
// @see header
//---------------------------------------------------------------
void CNativeMmsUtility::getRemainingAttachmentsFromAttManL(
                                                           ConvergedMessageAttachmentList& attachmentlist)
{
#ifdef _DEBUG_TRACES_
    qDebug() << " Enter CNativeMmsUtility::getRemainingAttachmentsFromAttManL";
#endif

    TUint count = iattachmanager->AttachmentCount();
    for (int i = 0; i < count; i++)
    {
        CMsvAttachment *attachment = iattachmanager->GetAttachmentInfoL(i);
        TPtrC8 mimetype = attachment->MimeType();
        QString filepath =
                XQConversions::s60DescToQString(attachment->FilePath());
        // converting directory separators from native to
        // universal (QT) format
        filepath.replace(KBackwardSlash, KForwardSlash);

        //create convergedmessage attachment to match with inline objects
        ConvergedMessageAttachment
                compareatt(filepath, ConvergedMessageAttachment::EInline);

        //before adding to the list check if already present in the list
        TBool found = EFalse;
        TUint listcount = attachmentlist.count();
        for (int j = 0; j < listcount && !found; j++)
        {
            if (compareatt == *attachmentlist.at(j))
            {
                found = ETrue;
            }
        }

        //no match found in the list
        if (!found)
        {
            //smil files aren't of either type
            if (mimetype.CompareF(KMsgMimeSmil) == 0)
            {
                ConvergedMessageAttachment
                        * targetatt =
                                new ConvergedMessageAttachment(filepath,
                                                               ConvergedMessageAttachment::ESmil);
                attachmentlist << targetatt;
            }
            else
            {
                ConvergedMessageAttachment
                        * targetatt =
                                new ConvergedMessageAttachment(filepath,
                                                               ConvergedMessageAttachment::EAttachment);
                attachmentlist << targetatt;
            }
        }
    }

#ifdef _DEBUG_TRACES_
    qDebug() << " Exit CNativeMmsUtility::getRemainingAttachmentsFromAttManL";
#endif

    return;
}
/**
Parse the flags data and update to iFlags.
@param aFlagsData contains list of flags to be parsed.
@return The remaining portion of the aFlagsData parameter that was not parsed.
*/
TPtrC8 TMessageFlagInfo::ParseFlagsL(const TDesC8& aFlagsData)
	{
	// formal definition of the FLAGS data item of a FETCH FLAGS is
	//
	// msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")"
	//
	// flag-fetch = flag / "\Recent"
	// flag = "\Answered" / "\Flagged" / "\Deleted" / "\Seen" / "\Draft" / flag-keyword / flag-extension
	// flag-extension = "\" atom
	// flag-keyword = atom
	//
	//

	TPtrC8 parseData(aFlagsData);
	
	TInt start = aFlagsData.Locate('(');
	TInt end = aFlagsData.Locate(')');

	// Reset the flags, prior to setting them.
	iFlags = 0;

	// Now set them.
	if ((start >= 0) && (end > start))
		{
		RDesParts flags;
		CleanupClosePushL(flags);
		
		// lose the brackets
		parseData.Set(aFlagsData.Mid(start+1, end-start-1));
		
		CImapCommand::GetDelimitedPartsL(' ', parseData, flags);
		TInt flagsCount = flags.Count();
		for (TInt i = 0; i < flagsCount; ++i)
			{
			TPtrC8 flag = flags[i];

			if(flag.CompareF(KImapTxtFlagDeleted) == 0)
				{
				SetFlag(TMessageFlagInfo::EDeleted, ETrue);
				}
			else if (flag.CompareF(KImapTxtFlagSeen) == 0)
				{
				SetFlag(TMessageFlagInfo::ESeen, ETrue);
				}
			else if(flag.CompareF(KImapTxtFlagFlagged) == 0)
				{
				SetFlag(TMessageFlagInfo::EFlagged, ETrue);			
				}
			else if(flag.CompareF(KImapTxtFlagAnswered) == 0)
				{
				SetFlag(TMessageFlagInfo::EAnswered, ETrue);
				}
			else if(flag.CompareF(KImapTxtFlagDraft) == 0)
				{
				SetFlag(TMessageFlagInfo::EDraft, ETrue);
				}
			else if(flag.CompareF(KImapTxtFlagRecent) == 0)
				{
				SetFlag(TMessageFlagInfo::ERecent, ETrue);	
				}
			}

		// return the remainder.
		// if there is a space after the closing bracket, 
		// then remainder should start after the space.
		if (aFlagsData.Length() > end + 1)
			{
			if (aFlagsData[end+1] == ' ')
				{
				++end;
				}
			}		
		
		if (aFlagsData.Length() > end)
			{
			parseData.Set(aFlagsData.Mid(end + 1));
			}
		else
			{
			parseData.Set(aFlagsData.Right(0));
			}
			
		CleanupStack::PopAndDestroy(&flags);
		}

	return parseData;
	}