// -----------------------------------------------------------------------------
// CTestPosLandmarkDatabase::PrepareAndTakePartialLmks
// 
// 
// -----------------------------------------------------------------------------
//
TInt CTestPosLandmarkDatabase::PrepareAndTakePartialLmksL( CStifItemParser& /*aItem*/ )
	{
	// Open and initialize DB
	CPosLandmarkDatabase* lmkDatabase = CPosLandmarkDatabase::OpenL( KDBUri );
	CleanupStack::PushL( lmkDatabase );
	// Initialize database
	ExecuteAndDeleteLD( lmkDatabase->InitializeL() );
	// Partial read params
	CPosLmPartialReadParameters* readParams = CPosLmPartialReadParameters::NewLC();
	// Set attributes, only name
	readParams->SetRequestedAttributes( CPosLandmark::ELandmarkName );
	// Set partial read params
	lmkDatabase->SetPartialReadParametersL( *readParams );
	// Get ids of all the landmarks using an iterator
	RArray<TPosLmItemId> idArray;
	TPosLmItemId id;
	CPosLmItemIterator* iterator = lmkDatabase->LandmarkIteratorL();
	CleanupStack::PushL( iterator );
	if( iterator->NumOfItemsL() == 0 )
		{
		iLog->Log(_L("No landmark exists in database, PrepareAndTakePartialLmks fails"));
		User::Leave( KErrGeneral );
		}
	// Iterate through all the landmarks and save ids into array
	while( ( id = iterator->NextL()) != KPosLmNullItemId )
		{
		idArray.Append( id );
		}
	// Prepare partial landmark
	CPosLmOperation* operation = lmkDatabase->PreparePartialLandmarksL( idArray );
	CleanupStack::PushL( operation );
	operation->ExecuteL();
	iLog->Log(_L("operation done"));
	// Take partial landmark
	CArrayPtr<CPosLandmark>* lmkPtrArray = lmkDatabase->TakePreparedPartialLandmarksL( operation );
	iLog->Log(_L("Takeprepared done"));
	//CleanupStack::PushL(lmkPtrArray);
	iLog->Log(_L("PrepareAndTakePartialLmks succeeds"));
//	CleanupStack::Pop(lmkPtrArray);
	lmkPtrArray->ResetAndDestroy();
	iLog->Log(_L("after reset done"));
	CleanupStack::PopAndDestroy( 4, lmkDatabase );
	ReleaseLandmarkResources();	
	return KErrNone; 	
	}
void CDirectPrintPrinterSettingView::SetBearerListL(CAknEnumeratedTextPopupSettingItem* item)
	{
	TInt err = GetBearerMgr()->GetProtocolNames(iBearerList);
	if (!err)
		{
		CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
		textArray->ResetAndDestroy();

		TInt count = iBearerList.Count();
		for (TInt i=0; i<count; i++)
			{
			CAknEnumeratedText* enumText = new (ELeave) CAknEnumeratedText(i, iBearerList[i].iName.AllocLC());
			CleanupStack::Pop();
			CleanupStack::PushL(enumText);
			textArray->AppendL(enumText);
			CleanupStack::Pop();
			}
		}
	}
예제 #3
0
/** Import the fields from vCard format into contact item in 3 scenarios.
 *  1) Field present in both vCard and the Contact Item
 *	2) Field present in vCard but absent in  the Contact Item
 *	3) Field present in vCard but does not contain any value
 *	@param aExistingFile - existing file for existing contact item
 *	@param aNewFile - New file for vCard format
 *  @param aStorageType - Storage type of each field
 *	@param aContFieldUid - Uid of Contact field
 *	@param avCardMapUid - Uid of vCard 
 *	@return - void
*/
void CTestImportContactMergeModeStep::ImportFieldsInMergeModeL(TBuf<50> aExistingFile, TBuf<50> aNewFile, TInt aStorageType,TUid aContFieldUid, TUid avCardMapUid)
{
	
	TPtrC compareVal, value;
   _LIT(KTestDbName, "c:importcontact.cdb");
   	TInt year, month, day;
   	RFs fsSession;
	RFileReadStream readStream, newReadStream;
	TBool success=EFalse;
	_LIT(KImportNewFileWithUid,			"C:\\ImportNewFileWithUid.vcf");
	
	//replace existing database
	dBase = CContactDatabase::ReplaceL(KTestDbName);

	//connect to file system
	User::LeaveIfError(fsSession.Connect());
	CleanupClosePushL(fsSession);

	//Opens a existing file in read mode
	User::LeaveIfError(readStream.Open(fsSession,aExistingFile, EFileRead));
    CleanupClosePushL(readStream);
	INFO_PRINTF1(_L("Importing Contact in Merge Mode....."));
	
	// importing contact item from vCard format
	CArrayPtr<CContactItem>* item = dBase->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), readStream, success, CContactDatabase::EImportSingleContact|CContactDatabase::ETTFormat);
	if(!success)
		{
		INFO_PRINTF1(_L("Contact Imported Failed"));
		SetTestStepResult(EFail);
		return;
		}
	INFO_PRINTF1(_L("Contact Imported in Merge Mode"));

	// Get the Contact Id
    TContactItemId contactId = (*item)[0]->Id();
    
    // Reads a contact item
    CContactItem* importedContact = dBase->ReadContactLC(contactId);

	AddUidRevPropertyL(*importedContact, fsSession, aNewFile, KImportNewFileWithUid);
	
	item->ResetAndDestroy();
	delete item;
	//Opens a file contains Uid of existing CI and field value from 
	// newly created contact item in read mode
   	User::LeaveIfError(newReadStream.Open(fsSession,KImportNewFileWithUid, EFileRead));
    CleanupClosePushL(newReadStream);
    
    // import the contact from vCard format.
    item = NULL;
	item = dBase->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), newReadStream, success, CContactDatabase::EImportSingleContact|CContactDatabase::ETTFormat);
	if(!success)
		{
		INFO_PRINTF1(_L("Contact Imported Failed"));
		SetTestStepResult(EFail);
		return;
		}
	INFO_PRINTF1(_L("Contact Imported in Merge Mode"));
	
	// Extract the merge mode value from ImportExportTestCases.ini.
	TInt flagValue;
	GetIntFromConfig(ConfigSection(), KIniFlagvalue, flagValue);

	//
	// Specifically for Mode 3 tests. Checks if the contact item has
	// been deleted. Passes the test if the contact item has been deleted.
	// Fails otherwise.
	//
	if( flagValue == 3 )
		{
		// Checks if any contact item has been returned.
		if( (*item).Count() == 0 )
			{
			SetTestStepResult(EPass);
			INFO_PRINTF1(_L("Contact Item Deleted"));
			}
		else
			{
			// Assuming that in mode 3, the item always has just 1 field
			// hence on merge, the item should always be deleted, and 
			// if it is not deleted the test will fail.
			SetTestStepResult(EFail);
			INFO_PRINTF1(_L("Contact Item Not Deleted"));
			}
		// Cleanup.
		item->ResetAndDestroy();
		delete item;	
		CleanupStack::PopAndDestroy(4,&fsSession);
		delete dBase;
		return;
		}

    // verify the field is being added	
	CContactItemFieldSet& ContactFieldSet = (*item)[0]->CardFields();
	//get the string value
	GetStringFromConfig(ConfigSection(), KExpectedData, compareVal);
	TInt pos = ContactFieldSet.Find(aContFieldUid, avCardMapUid);
	if(pos != KErrNotFound)
		{
		if(aStorageType==KStorageTypeDateTime)
			{
			//Get the int value
			TBool res;
			res = GetIntFromConfig(ConfigSection(), KIniYear, year);
			if(!res)
				{
				ERR_PRINTF1(_L("Unable to read year val from ini file"));
				SetTestStepResult(EFail);
				}
			res = GetIntFromConfig(ConfigSection(), KIniMonth, month);
			if(!res)
				{
				ERR_PRINTF1(_L("Unable to read month val from ini file"));
				SetTestStepResult(EFail);
				}
			res = GetIntFromConfig(ConfigSection(), KIniDay, day);
			if(!res)
				{
				ERR_PRINTF1(_L("Unable to read day val from ini file"));
				SetTestStepResult(EFail);
				}
			TDateTime result=ContactFieldSet[pos].DateTimeStorage()->Time().DateTime();
			//compare the results
			if((result.Year() == year) && (result.Month() == (TMonth)month) && (result.Day() == day))
				{
				SetTestStepResult(EPass);
				}
			else
				{
				SetTestStepResult(EFail);
				}
			}
		else
			{
			value.Set(ContactFieldSet[pos].TextStorage()->Text());
			//compare the results
			if(compareVal.Compare(value)==0 )
				{
				SetTestStepResult(EPass);
				}
			else
				{
				SetTestStepResult(EFail);
				}
			}
		}
	else
		{
		TInt deleted;
		// get the flag value from ini file
		GetIntFromConfig(ConfigSection(), KIniFlagvalue, deleted);
		if(deleted == 3)
			{
			SetTestStepResult(EPass);
			INFO_PRINTF1(_L("Field deleted"));
			}
		else
			{
			INFO_PRINTF1(_L("Field not found"));
			}	
		
		}
	// Cleanup	
	item->ResetAndDestroy();
	delete item;	
    CleanupStack::PopAndDestroy(4,&fsSession);
    delete dBase;
}
// ----------------------------------------------------
// CNormalSettingContainer::LoadListL()
// Loads the setting item list dynamically.
// ----------------------------------------------------
//
void CNormalSettingContainer::LoadListL()
    {
    TBool isNumberedStyle = iItemList->IsNumberedStyle();
    CArrayPtr<CGulIcon>* icons = iItemList->ListBox()->ItemDrawer()->FormattedCellData()->IconArray();
    CArrayPtr<CAknEnumeratedText>* texts;
    CAknEnumeratedText* enumText;
    HBufC* text;

    /* Text setting item */
//    CAknTextSettingItem* item = new (ELeave) CAknTextSettingItem(1, iText);
//    CleanupStack::PushL(item);
//    item->SetEmptyItemTextL( KEmptyText );
//    // The same resource id can be used for multiple text setting pages.
//    item->ConstructL(isNumberedStyle, 1, KName, icons, R_TEXT_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item);
//    CleanupStack::Pop(item);
//
//
//    /* Integer setting item */
//    CAknIntegerEdwinSettingItem* item2 = new (ELeave) CAknIntegerEdwinSettingItem(2, iNumber);
//    CleanupStack::PushL(item2);
//    // The same resource id can be used for multiple integer setting pages.
//    item2->ConstructL(isNumberedStyle, 2, KName2, icons, R_INTEGER_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item2);
//    CleanupStack::Pop(item2);
//
//
//    /* Password setting item */
//    CAknPasswordSettingItem* item3 = new (ELeave) CAknPasswordSettingItem(  3,
//                                                                            CAknPasswordSettingItem::EAlpha,
//                                                                            iPassword);
//    CleanupStack::PushL(item3);
//    item3->SetEmptyItemTextL( KEmptyText );
//    // The same resource id can be used for multiple password setting pages.
//    item3->ConstructL(isNumberedStyle, 3, KName3, icons, R_PASSWORD_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item3);
//    CleanupStack::Pop(item3);
//
//
//    /* Volume setting item */
//    CAknVolumeSettingItem* item4 = new (ELeave) CAknVolumeSettingItem(4, iVolume);
//    CleanupStack::PushL(item4);
//    // The same resource id can be used for multiple volume setting pages.
//    item4->ConstructL(isNumberedStyle, 4, KName4, icons, R_VOLUME_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item4);
//    CleanupStack::Pop(item4);
//
//
//   /* Slider setting item. Read comments in CDynamicSettingListSlider, why
//    * a derived class is used instead of CAknSliderSettingItem
//    */
//    CDynamicSettingListSlider* item5 = new (ELeave) CDynamicSettingListSlider(5, iSlider);
//    CleanupStack::PushL(item5);
//    // The same resource id can be used for multiple slider setting pages.
//    item5->ConstructL(isNumberedStyle, 5, KName5, icons, R_SLIDER_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item5);
//    CleanupStack::Pop(item5);
//
//
//    /* Date setting item */
//    CAknTimeOrDateSettingItem* item6 = new (ELeave) CAknTimeOrDateSettingItem(  6,
//                                                                                CAknTimeOrDateSettingItem::EDate,
//                                                                                iDate);
//    CleanupStack::PushL(item6);
//    // The same resource id can be used for multiple date setting pages.
//    item6->ConstructL(isNumberedStyle, 6, KName6, icons, R_DATE_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item6);
//    CleanupStack::Pop(item6);
//
//
//    /* Time offset setting item */
//    CAknTimeOffsetSettingItem* item7 = new (ELeave) CAknTimeOffsetSettingItem(7, iTime);
//    CleanupStack::PushL(item7);
//    // The same resource id can be used for multiple time offset setting pages.
//    item7->ConstructL(isNumberedStyle, 7, KName7, icons, R_TIMEOFFSET_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item7);
//    CleanupStack::Pop(item7);
//
//
//    /* Ip field setting item */
//    CAknIpFieldSettingItem* item8 = new (ELeave) CAknIpFieldSettingItem(8, iIp);
//    CleanupStack::PushL(item8);
//    // The same resource id can be used for multiple ip field setting pages.
//    item8->ConstructL(isNumberedStyle, 8, KName8, icons, R_IPFIELD_SETTING_PAGE, -1);
//    iItemList->SettingItemArray()->AppendL(item8);
//    CleanupStack::Pop(item8);
//
//
//    /* Enumerated text setting item */  更换频率
    CAknEnumeratedTextPopupSettingItem* item9 = new (ELeave) CAknEnumeratedTextPopupSettingItem(EItemFreqency, iEnumText);
    CleanupStack::PushL(item9);
    // The same resource id can be used for multiple enumerated text setting pages.
    text = StringLoader::LoadLC(R_SETTING_FREQUENCY_TITLE);
    item9->ConstructL(isNumberedStyle, EItemFreqency, text->Des(), icons, R_ENUMERATEDTEXT_SETTING_PAGE, -1, 0, R_POPUP_SETTING_TEXTS);
    CleanupStack::PopAndDestroy();
    
    // Load texts dynamically.
    texts = item9->EnumeratedTextArray();
    texts->ResetAndDestroy();    
    // 1 hour
    text = StringLoader::LoadLC(R_TEXT_FREQUENCY_ONE_HOUR);
    enumText = new (ELeave) CAknEnumeratedText(EFrequencyOneHour, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);
    // 8 hours
    text = StringLoader::LoadLC(R_TEXT_FREQUENCY_EIGHT_HOURS);
    enumText = new (ELeave) CAknEnumeratedText(EFrequencyEightHours, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);
    // 1 day
    text = StringLoader::LoadLC(R_TEXT_FREQUENCY_ONE_DAY);
    enumText = new (ELeave) CAknEnumeratedText(EFrequencyOneDay, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);
    // 3 days
    text = StringLoader::LoadLC(R_TEXT_FREQUENCY_THREE_DAYS);
    enumText = new (ELeave) CAknEnumeratedText(EFrequencyThreeDays, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);
    // 1 week
    text = StringLoader::LoadLC(R_TEXT_FREQUENCY_ONE_WEEK);
    enumText = new (ELeave) CAknEnumeratedText(EFrequencyOneWeek, text);
    CleanupStack::Pop(text);
    CleanupStack::PushL(enumText);
    texts->AppendL(enumText);
    CleanupStack::Pop(enumText);

    iItemList->SettingItemArray()->AppendL(item9);
    CleanupStack::Pop(item9);


//  /* Binary popup setting item */	开机启动
//    CAknBinaryPopupSettingItem* item10 = new (ELeave) CAknBinaryPopupSettingItem(EItemAutoStart, iBinary);
//    CleanupStack::PushL(item10);
//    // The same resource id can be used for multiple binary setting pages.
//    text = StringLoader::LoadLC(R_SETTING_AUTOSTART_TITLE);
//    item10->ConstructL(isNumberedStyle, EItemAutoStart, text->Des(), icons, R_BINARY_SETTING_PAGE, -1, 0, R_BINARY_TEXTS);
//    CleanupStack::PopAndDestroy();
//    
//    // Load texts dynamically.
//    texts = item10->EnumeratedTextArray();
//    texts->ResetAndDestroy();
//    // Text 1
//    text = StringLoader::LoadLC(R_TEXT_NO);
//    enumText = new (ELeave) CAknEnumeratedText(0, text);
//    CleanupStack::Pop(text);
//    CleanupStack::PushL(enumText);
//    texts->AppendL(enumText);
//    CleanupStack::Pop(enumText);
//    // Text 2
//    text = StringLoader::LoadLC(R_TEXT_YES);
//    enumText = new (ELeave) CAknEnumeratedText(1, text);
//    CleanupStack::Pop(text);
//    CleanupStack::PushL(enumText);
//    texts->AppendL(enumText);
//    CleanupStack::Pop(enumText);
//
//    // Sets the correct text visible
//    item10->LoadL();
//
//    iItemList->SettingItemArray()->AppendL(item10);
//    CleanupStack::Pop(item10);

    // Required when there is only one setting item.
    iItemList->SettingItemArray()->RecalculateVisibleIndicesL();

    iItemList->HandleChangeInItemArrayOrVisibilityL();
    }
예제 #5
0
/**
	Static convenience cleanup method copied from CSmlContactsDba  
*/
void CDeleteMany::CleanupPtrArray(TAny* aCArrayPtr)
	{ 
	CArrayPtr<CContactItem>* array = reinterpret_cast<CArrayPtr<CContactItem>*>(aCArrayPtr);
	array->ResetAndDestroy();
	delete array;
	}