// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::ConvertExceptionDatesL
// Inserts exceptiondates to a parser.
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::ConvertExceptionDatesL(const CArrayFix<
        TPIMDate>& aDates, CParserVCalEntity& aParser)
{
    JELOG2(EPim);
    TInt exDateCount = aDates.Count();
    if (exDateCount > 0)
    {
        CArrayPtrFlat<TVersitDateTime>* versitExDates =
            new(ELeave) CArrayPtrFlat<TVersitDateTime> (exDateCount);
        CleanupStack::PushL(versitExDates);
        CleanupResetAndDestroyPushL(*versitExDates);
        for (TInt i = 0; i < exDateCount; i++)
        {
            TVersitDateTime
            * versitDateTime =
                new(ELeave) TVersitDateTime(aDates.At(i).DateTime(), TVersitDateTime::EIsUTC);
            CleanupDeletePushL(versitDateTime);
            versitExDates->AppendL(versitDateTime);
            CleanupStack::Pop(versitDateTime); // versitDateTime
        }
        CParserPropertyValue* propertyValue =
            new(ELeave) CParserPropertyValueMultiDateTime(versitExDates);
        CleanupStack::Pop(2); // versitExDates is now owned by propertyValue
        AddPropertyToParserL(propertyValue, KVersitTokenEXDATE(), aParser);
        // Needed cleanup stack items are popped out in the AddPropretyToParserL
    }
}
EXPORT_C TBool AknPhoneNumberTextUtils::WrapPhoneNumberToArrayL( 
    const TDesC& aPhoneNumberToWrap,
    TInt aLineWidthInPixels,
    TInt aMaxLines,
    const CFont& aFont,
    CArrayFix<TPtrC>& aWrappedArray )
    {
    TBool retVal( EFalse ); // Not truncated
 
    HBufC* reversedText = aPhoneNumberToWrap.AllocLC();
    TPtr revPtr = reversedText->Des();

    ReverseDescriptor( revPtr );

    CArrayFix<TInt>* lineWidthArray = new (ELeave) CArrayFixFlat<TInt>(KLineArrayGranularity);
    CleanupStack::PushL( lineWidthArray );

    lineWidthArray->AppendL( aLineWidthInPixels, aMaxLines );

    // Perform the wrap on the reversed text
    AknTextUtils::WrapToArrayL( revPtr, *lineWidthArray, aFont, aWrappedArray );

    // Now rearrange the TPtrCs to point to the original array
    TInt totalLen = reversedText->Length();
    TInt count = aWrappedArray.Count();
    TInt usedLen = 0; // Accumulates the length actually used
    for ( TInt index = 0; index < count; index++)
        {
        TPtrC& currentPtr = aWrappedArray.At(index);
        // The TPtrCs have to be moved. The reversing is taken into effect, but not purely reversed
        // because their otherwise they would have negative lengths.  That is, {a,b} does not go to
        // { final - a, final - b }, but rather to {final - b, final - a}; they are flipped, to get
        // their start points before the end points
        //
        // Now, representing the start position by pos, and the end by pos+len-1 we have the TPtrC at
        // {pos, pos+len-1} inclusive, in reversed array. 
        // The TPtrC must be modified to point to {total_len-1 - (pos+len-1), total_len-1 - pos} 
        // in the unreversed array:
        TInt len = currentPtr.Length();
        usedLen += len;
        TInt pos = currentPtr.Ptr() - reversedText->Ptr(); // pointer arithmetic
        TInt newPos = totalLen - pos - len;
        // If the TPtr is zero length then it must get special treatment, as the normal
        // calculations give an end point before the start point! i.e. {pos, pos-1}
        // We handle this by NOT flipping in this case.
        // { pos, pos-1 } -> {totalLen-1-pos, totalLen-1 - (pos-1)}
        // Note that a zero length wrapped line is completely possible amoung a bunch of other 
        // lines with characters on them, as the line lengths may be of wildly different lengths.
        if ( len == 0 ) 
            newPos--;
        currentPtr.Set( aPhoneNumberToWrap.Mid(newPos, len) );
        }

    // If the accumulated length is less than that in the entire input descriptor, then text does not fit
    if ( usedLen < totalLen )
        retVal = ETrue;

    CleanupStack::PopAndDestroy(2); // lineWidthArray first, and then reversedText
    return retVal;
    }
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ExportItemL
// (other items were commented in a header)
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ExportItemL(const MPIMToDoItem& aItem,
                                     CCalEntry& aEntry, TBool aResetEntry)
{
    JELOG2(EPim);
    if (aResetEntry)
    {
        // Reset native entry for exporting new data
        aEntry.SetSummaryL(KNullDesC());
        aEntry.SetDescriptionL(KNullDesC());
        aEntry.SetPriorityL(0);
        aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
    }

    // Export item data to the native ToDo calendar entry
    const MPIMItemData& itemData = aItem.ItemData();
    CArrayFix<TPIMField>* fields = itemData.FieldsLC();

    // Add default values to the calendar entry
    AddDefaultValuesToEntryL(itemData, aEntry);

    // Convert each field to the native ToDo calendar entry
    TInt count = fields->Count();
    for (TInt i = 0; i < count; i++)
    {
        TPIMToDoField field = static_cast<TPIMToDoField>(fields->At(i));
        ConvertToAgnL(field, aEntry, itemData);
    }
    CleanupStack::PopAndDestroy(fields);
}
/**
 * Set text and font into labels.
 *
 * SetBufferReserveLengthL causes a reallocation but this should never
 * be called unless somebody decides to change the font after the label
 * has been created and with this new font you can fit more characters 
 * in the same width

 */
void CAknTextControl::SetWrappedTextIntoLabelsL(const CArrayFix<TPtrC>& aWrappedArray, TInt aNumLines, const CFont* aFont)
	{
	__ASSERT_DEBUG(aNumLines == iNumberOfLines, Panic(EAknPanicSelfCheckFailure));

	for (TInt i=0; i < iNumberOfLines; i++)
		{
		
		if (Line(i)->BufferReserveLength() < aWrappedArray.At(i).Length())
			Line(i)->SetBufferReserveLengthL(aWrappedArray.At(i).Length());

		if (*(Line(i)->Text()) != aWrappedArray.At(i) )
			{
			Line(i)->SetTextL(aWrappedArray.At(i));
			Line(i)->SetFont(aFont);
			iLines[i]->iModified = ETrue;
			}
		}
	}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertFieldsToAgnL
// Reads PIM Item fields and converts them into Agenda entry's fields.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertFieldsToAgnL(const MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    CArrayFix<TPIMField>* fields = aItem.ItemData().FieldsLC();
    TInt amount = fields->Count();

    for (int i = 0; i < amount; i++)
    {
        TPIMEventField field = static_cast<TPIMEventField>(fields->At(i));
        switch (field)
        {
        case EPIMEventSummary: // Fallthrough
        case EPIMEventLocation: // Fallthrough
        case EPIMEventNote:
        {
            ConvertStringFieldToAgnL(aItem, aEntry, field);
            break;
        }
        case EPIMEventAlarm:
        {
            ConvertAlarmToAgnL(aItem, aEntry);
            break;
        }
        case EPIMEventStart: // Fallthrough
        case EPIMEventEnd:
        {
            ConvertDateFieldToAgnL(aItem, aEntry, field);
            break;
        }
        case EPIMEventClass:
        {
            ConvertClassToAgnL(aItem, aEntry);
            break;
        }
        case EPIMEventRevision: // fallthrough
        case EPIMEventUid:
        {
            // nothing
            break;
        }
        default:
        {
            User::Leave(KErrArgument);
        }
        }
    }
    CleanupStack::PopAndDestroy(fields);
}
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::GetRepeatRuleFieldsL
// Gets the fields from a repeat rule
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::GetRepeatRuleFieldsL(
    const MPIMRepeatRuleData* aRepeat, // Fields are read from this
    TInt* aInterval, // interval is stored here
    TInt* aFrequency, // frequency is stored here
    TVersitDateTime** aVersitEndDate) // end date is stored here
{
    JELOG2(EPim);
    TBool endExists = EFalse;
    CArrayFix<TPIMField>* repeatFields = aRepeat->GetFieldsL();
    CleanupStack::PushL(repeatFields);
    TInt fieldCount = repeatFields->Count();
    for (TInt i = 0; i < fieldCount; i++)
    {
        switch (repeatFields->At(i))
        {
        case EPIMRepeatRuleFrequency:
        {
            *aFrequency = aRepeat->GetIntL(EPIMRepeatRuleFrequency);
            break;
        }
        case EPIMRepeatRuleInterval:
        {
            *aInterval = aRepeat->GetIntL(EPIMRepeatRuleInterval);
            break;
        }
        case EPIMRepeatRuleEnd:
        {
            endExists = ETrue;
            break;
        }
        default:
        {
            // We ignore other fields
        }
        }
    }
    CleanupStack::PopAndDestroy(repeatFields);
    if (endExists)
    {
        TPIMDate endDate = aRepeat->GetDateL(EPIMRepeatRuleEnd);
        *aVersitEndDate
        = new(ELeave) TVersitDateTime(endDate.DateTime(), TVersitDateTime::EIsUTC);
    }
}
Example #7
0
void QtFallbackWebPopup::showS60BrowserDialog()
{
    static MBrCtlDialogsProvider* dialogs = CBrowserDialogsProvider::NewL(0);
    if (!dialogs)
        return;

    int size = itemCount();
    CArrayFix<TBrCtlSelectOptionData>* options = new CArrayFixFlat<TBrCtlSelectOptionData>(qMax(1, size));
    RPointerArray<HBufC> items(qMax(1, size));
    CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &items));

    for (int i = 0; i < size; i++) {
        if (itemType(i) == Separator) {
            TBrCtlSelectOptionData data(_L("----------"), false, false, false);
            options->AppendL(data);
        } else {
            HBufC16* itemStr = HBufC16::NewL(itemText(i).length());
            itemStr->Des().Copy((const TUint16*)itemText(i).utf16(), itemText(i).length());
            CleanupStack::PushL(itemStr);
            TBrCtlSelectOptionData data(*itemStr, i == currentIndex(), false, itemIsEnabled(i));
            options->AppendL(data);
            items.AppendL(itemStr);
            CleanupStack::Pop();
        }
    }

    dialogs->DialogSelectOptionL(KNullDesC(), (TBrCtlSelectOptionType)(ESelectTypeSingle | ESelectTypeWithFindPane), *options);

    CleanupStack::PopAndDestroy(&items);

    int newIndex;
    for (newIndex = 0; newIndex < options->Count() && !options->At(newIndex).IsSelected(); newIndex++) {}
    if (newIndex == options->Count())
        newIndex = currentIndex();
    
    m_popupVisible = false;
    popupDidHide();

    if (currentIndex() != newIndex && newIndex >= 0)
        valueChanged(newIndex);

    delete options;
}
Example #8
0
TInt TDmAdUtil::FindLargestLocallyCreated(const CArrayFix<TSmlDmMappingInfo>& aPreviousUriSegmentList)
    {
    TRACE("TDmAdUtil::FindLargestLocallyCreated");
    TInt largest = 0;
    for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
        {
        const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);        
        if (mappingInfo.iURISeg.Find(KDmAdLocallyCreatedRtNodeUriSegPrefix) == 0)
            {            
            TPtrC8 numberPart(mappingInfo.iURISeg.Mid(KDmAdLocallyCreatedRtNodeUriSegPrefix().Length()));
            TInt number = TDmAdUtil::DesToInt(numberPart);
            if (number > largest)
                {
                largest = number;
                }
            }
        }
    return largest;
    }
Example #9
0
DMAD_EXPORT_C void TDmAdUtil::BuildRtNodeChildUriListL(MDmAdCallBack*                          aDmAdCallBack,
                                                  MDmAdStoreApi*                          aStoreApi,
                                                  const TDesC8&                           aUri,
                                                  const TDesC8&                           aParentLuid,
                                                  const CArrayFix<TSmlDmMappingInfo>&     aPreviousUriSegmentList,
                                                  CBufBase&                               aCurrentList)
    {
#ifdef DMAD_DUMP_PREVIOUS_URI_SEGMENT_LIST
        DEBUG_LOG(_L("BuildRtNodeChildUriListL:"));
        {
        for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
            {
            const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
                        
            DEBUG_LOG1(_L("entry %d:"), i);            
            DEBUG_LOG1(_L8("Uri: %S"), &(mappingInfo.iURISeg));
            DEBUG_LOG_HEX(mappingInfo.iURISegLUID);
            
            }
        }
#endif

    RPointerArray<HBufC8> luidList;
    CleanupStack::PushL(TCleanupItem(PointerArrayCleanup, &luidList));
    
    aStoreApi->LuidListL(aUri, aParentLuid, luidList);


    // Finds largest number used in cli<x> named nodes.
    TInt largest = FindLargestLocallyCreated(aPreviousUriSegmentList);
    DEBUG_LOG1(_L("largest is cli%d"), largest);
    
    TInt countLuidList = luidList.Count();
    for (TInt j=0; j < countLuidList; j++)
        {
        const HBufC8* luidElem = luidList[j];

        HBufC8* uriSeg = 0;
        
        //Tries to find the luid from the aPreviousUriSegmentList
        for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
            {
            const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
                        
            if (mappingInfo.iURISegLUID.Compare(*luidElem) == 0)
                {            
                uriSeg = mappingInfo.iURISeg.AllocLC();
                break;
                }
            }
        
        if (uriSeg == 0)
            {
            //Uri was not found from the aPreviousUriSegmentList
            uriSeg = BuildLocallyCreatedRtNodeUriSegLC(largest);
            
            DEBUG_LOG2(_L8("uriSeg %S, largest %d"), uriSeg, largest);
            
            HBufC8* wholeUri = TDmAdUtil::BuildUriLC(aUri, *uriSeg);            
            aDmAdCallBack->SetMappingL(*wholeUri, *luidElem);
            CleanupStack::PopAndDestroy(); //wholeUri
            }

        //If this is not the first element, inserts slash at the beginning
        //of the result list.
        if (j > 0)
            {            
            aCurrentList.InsertL(aCurrentList.Size(), KDmAdSeparator);
            }
        aCurrentList.InsertL(aCurrentList.Size(), *uriSeg);
        
        CleanupStack::PopAndDestroy(); // uriSeg
        }
    
    CleanupStack::PopAndDestroy(); //luidList
    }
Example #10
0
// -----------------------------------------------------------------------------
// CWPRoot::CreateLinksL
// -----------------------------------------------------------------------------
//
void CWPRoot::CreateLinksL()
    {
    FLOG( _L( "[Provisioning] CWPRoot::ParameterL2:" ) );
    
    iNeeders.Reset();
    delete iNeededIDs;
    iNeededIDs = NULL;
    iNeededIDs = new(ELeave) CDesCArrayFlat( KIDArrayGranularity );
    delete iProviderIDs;
    iProviderIDs = NULL;
    iProviderIDs = new(ELeave) CDesCArrayFlat( KIDArrayGranularity );

    AcceptL( *this );

    // We now have arrays of links and targets of links. Put them together.
    for( TInt i( 0 ); i < iNeeders.Count(); i++ )
        {
        CWPCharacteristic* needer = iNeeders[i];
        TPtrC neededID( iNeededIDs->MdcaPoint( i ) );

        TBool foundProvider( EFalse );
        for( TInt j( 0 ); j < iProviders.Count() && !foundProvider; j++ )
            {
            CWPCharacteristic* needed = iProviders[j];
            TPtrC providerID( iProviderIDs->MdcaPoint( j ) );

            if( providerID == neededID )
                {
            	if ( needer->Type() == KWPPxPhysical && needed->Type() != KWPNapDef)
            		{
            		// incorrect link found. do nothing.
            		}
            	else
            		{
#ifndef __SYNCML_DM_OTA
					FLOG ( _L( "[Provisioning] CWPRoot::CreateLinksL*********** __SYNCML_DM_OTA ***********" ) );
            		if (KWPApplication == needer->Type())
            			{
            			_LIT( KNSmlDMProvisioningDMAppIdVal, "w7" );
            			FLOG (_L( "[Provisioning] CWPRoot::CreateLinksL:Needer is Application" ) );
            			
            			CArrayFix<TPtrC>* name = new(ELeave) CArrayFixFlat<TPtrC>(1);
				        CleanupStack::PushL(name);
				        				        
				        needer->ParameterL(EWPParameterAppID, name);
				        
				        if ((name->Count() > 0)
				        	&&
				        	0 == name->At(0).Compare(KNSmlDMProvisioningDMAppIdVal) )
				            {
				            CleanupStack::PopAndDestroy(); // name
            				continue;
				            }
				            
				        
				        CleanupStack::PopAndDestroy(); // name
            			}
            		FLOG ( _L( "[Provisioning] CWPRoot::CreateLinksL:*********** __SYNCML_DM_OTA ***********" ) );
#endif
            		
                    needer->InsertLinkL( *needed );
                    foundProvider = ETrue;
            		}
                }
            }
        }
    
    // Free the temporary memory
    iNeeders.Reset();
    iProviders.Reset();
    delete iNeededIDs;
    iNeededIDs = NULL;
    delete iProviderIDs;
    iProviderIDs = NULL;
    }