Ejemplo n.º 1
0
CDesCArray* CCommonUtils::SplitText(const TDesC& aText,const char& aSplitChar)
{
	CDesCArray* tmpArray = new(ELeave) CDesCArrayFlat(5);
	CleanupStack::PushL(tmpArray);

	TInt len = aText.Length();
	TBuf<100> tmp;
	for ( TInt i = 0; i < len ; i ++)
	{
		if(aText[i] == aSplitChar)
		{
			tmp.TrimAll();
			tmpArray->AppendL(tmp);
			tmp.Zero();
		}
		else
			tmp.Append(aText[i]);		
	}
	if (tmp.Length() > 0 )
	{
		tmp.TrimAll();
		tmpArray->AppendL(tmp);
	}	

	CleanupStack::Pop(tmpArray);
	return tmpArray;
}
Ejemplo n.º 2
0
QString Camera::symbianCapture(int width, int height)
{
    CNewFileServiceClient* fileClient = NewFileServiceFactory::NewClientL();
    CleanupStack::PushL(fileClient);

    CDesCArray* fileNames = new (ELeave) CDesCArrayFlat(1);
    CleanupStack::PushL(fileNames);

    CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();

    TSize resolution = TSize(width, height);
    TPckgBuf<TSize> buffer( resolution );
    TAiwVariant resolutionVariant( buffer );
    TAiwGenericParam param( EGenericParamResolution, resolutionVariant );
    paramList->AppendL( param );

    const TUid KUidCamera = { 0x101F857A }; // Camera UID for S60 5th edition

    TBool result = fileClient->NewFileL( KUidCamera, *fileNames, paramList,
                               ENewFileServiceImage, EFalse );

    QString ret;

    if (result) {
        TPtrC fileName=fileNames->MdcaPoint(0);
        ret = QString((QChar*) fileName.Ptr(), fileName.Length());
    }
     qDebug() << ret;
    CleanupStack::PopAndDestroy(3);

    return ret;
}
Ejemplo n.º 3
0
EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList)
/** Gets a list of all heights in twips, available for the named typeface and the 
graphics device specified.

Also gets a list of heights in points, represented as character strings.

@param aDevice The graphics device.
@param aTypefaceName The name of the typeface.
@param aTwipsList On return, contains all available heights for the typeface, 
in twips.
@param aPointsList On return, the heights in points, represented as character 
strings.
@return KErrNotSupported if the named typeface is not supported by the graphics 
device, otherwise KErrNone. */
	{ // static
	aTwipsList.Reset();
	aPointsList.Reset();
	TInt err=GetAvailableHeightsInTwipsL(aDevice,aTypefaceName,aTwipsList);
	if (err==KErrNotSupported)
		return err;
	const TInt count=aTwipsList.Count();
	for (TInt ii=0;ii<count;ii++)
		{
		const TInt points=PointsFromTwips(aTwipsList[ii]);
		if (points<EMinFontHeight)
			continue;
		TBuf<8> num;
		num.Num(points);
		aPointsList.AppendL(num);
		}
	return KErrNone;
	}
Ejemplo n.º 4
0
void DoTestV8DatabaseL()
    {
    CopyOldCdbFileToCDriveL(KDatabaseV8);
    CContactDatabase* db=CContactDatabase::OpenL(KDatabaseCDrive); 
    TDriveUnit driveUnit = _L("c:");
    TBuf<190> driveName;
    CDesCArray* dataBaseList = db->ListDatabasesL(driveUnit);
    CleanupStack::PushL(dataBaseList);
    TInt theCount = dataBaseList->Count();
    TBool oldFileFormat = EFalse;
    for(TInt i = 0; i< theCount; i++)
        {
        driveName = (*dataBaseList)[i];
        test.Printf(_L("ListDatabaseTestL, ListDatabasesL: %s \n"),driveName.PtrZ());
        TPtrC filenamePtr(driveName);
        TInt found = filenamePtr.FindF(KOldFileFormatPrefix);
        if (found != 0 && found != KErrNotFound)
            {
            oldFileFormat = ETrue;  
            }
        }
    test(oldFileFormat);

    CleanupStack::PopAndDestroy(dataBaseList);
    delete db;
    }
Ejemplo n.º 5
0
EXPORT_C void FontUtils::GetAvailableFontsL(const CGraphicsDevice& aDevice, CDesCArray& aFontNameList,TInt aFonts)
/** Gets the list of typeface names available for the graphics device.

@param aDevice The graphics device.
@param aFontNameList On return, contains the list of typeface names.
@param aFonts Can be used to specify which sorts of typefaces are required. 
For possible values, see the flags defined in gulftflg.hrh 
beginning with EGulAllFonts. */
	{ // static
	aFontNameList.Reset();
	const TInt numTypefaces=aDevice.NumTypefaces();
	TTypefaceSupport typefaceInfo;
	for (TInt ii=0;ii<numTypefaces;ii++)
		{
		aDevice.TypefaceSupport(typefaceInfo,ii);
		if (typefaceInfo.iTypeface.IsProportional())
			{
			if (aFonts==EGulMonospaceFontsOnly)
				continue;
			}
		else if (aFonts==EGulNoMonospaceFonts || aFonts==EGulNoMonospaceOrSymbolFonts)
			continue;
		if (typefaceInfo.iTypeface.IsSymbol())
			{
			if (aFonts==EGulNoSymbolFonts || aFonts==EGulNoMonospaceOrSymbolFonts || aFonts==EGulMonospaceFontsOnly)
				continue;
			}
		else if (aFonts==EGulSymbolFontsOnly)
			continue;
		aFontNameList.AppendL(typefaceInfo.iTypeface.iName);
		}
	}
// ---------------------------------------------------------
// CPosLmLocalDatabaseManager::SynchronizeRegistryL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosLmLocalDatabaseManager::SynchronizeRegistryL()
    {
    RPointerArray<HPosLmDatabaseInfo> databaseInfoArray(KPosDbListGranularity);
    CleanupStack::PushL(TCleanupItem(CleanupRPointerArray, &databaseInfoArray));

    // list URIs
    CDesCArray* dbUriArray = ListDatabasesLC();

    // list registered databases
    Session().ListDatabasesL(databaseInfoArray, KFileProtocol);

    // unregister database which cannot be found on disk
    for (TInt i = databaseInfoArray.Count() - 1; i >= 0; i--)
        {
        TInt index;
        TPtrC registeredUri = databaseInfoArray[i]->DatabaseUri();
        if (dbUriArray->Find(registeredUri, index) != 0)
            {
            // unregister database
            User::LeaveIfError(Session().UnregisterDatabase(registeredUri,
                DatabaseDrive(registeredUri)));
            }
        }
    CleanupStack::PopAndDestroy(2, &databaseInfoArray);  // dbUriArray
    }
Ejemplo n.º 7
0
void TwtCamera::openCamera()
{
#ifdef Q_OS_SYMBIAN
    qDebug() << "TwtCamera::openCamera";
    CDesCArray* selectedFiles = new (ELeave) CDesCArrayFlat(1);
    CleanupStack::PushL(selectedFiles);

    CNewFileServiceClient* fileClient = NewFileServiceFactory::NewClientL();
    CleanupStack::PushL(fileClient);
    bool result = fileClient->NewFileL(KUidCamera, *selectedFiles, NULL,
                                       ENewFileServiceImage, EFalse);
    if(result)
    {
        TPtrC address = selectedFiles->MdcaPoint(0);
        QString filename = QString::fromUtf16(address.Ptr(), address.Length());
        qDebug() << "TwtCamera::openCamera name = " << filename;
        emit imgCaptured(filename);
    }
    else
    {
        qDebug() << "TwtCamera::openCamera file capture failed";
        emit imgCaptured("");
    }
    CleanupStack::PopAndDestroy( 2 ); // selectedFiles, fileClient
#else
    // for develop on simulator
    emit imgCaptured("");
#endif
}
void CSearchableListBoxContainer::AddFormattedListBoxItemL( const TDesC& aString )
{
   CTextListBoxModel* model = iListBox->Model();
   CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
   itemArray->AppendL( aString );
   iListBox->HandleItemAdditionL();
}
void CSpreadWFDialogs::ShowSpreadWayfinderOptionsDialogL()
{
   //Dialog that lets the user chose between contact bk search
   //and entering a number manually.
   CDesCArray* optionArray = new (ELeave) CDesCArrayFlat(2);
   HBufC* option = CCoeEnv::Static()->AllocReadResourceLC(R_WF_OPTION_CONTACTS);
   optionArray->AppendL(*option);
   CleanupStack::PopAndDestroy(option);
   option = CCoeEnv::Static()->AllocReadResourceLC(R_WF_OPTION_MANUALLY);
   optionArray->AppendL(*option);
   CleanupStack::PopAndDestroy(option);
   TInt preSelIndex = iOptionsIndex;

   typedef TCallBackEvent<CSpreadWFDialogs, TSpreadWFEvent> cb_t;
   typedef CCallBackListDialog<cb_t> cbd_t;
   cbd_t::RunDlgLD(cb_t(this,
                        ESpreadWFEventOptionsOk,
                        ESpreadWFEventOptionsCancel),
                   iOptionsIndex,
                   R_WF_SHARE_WAYFINDER,
                   optionArray,
                   R_WAYFINDER_CALLBACK_SINGLE_LIST_QUERY_OK_BACK,
                   EFalse, 
                   preSelIndex);
}
Ejemplo n.º 10
0
void CMdEQuery::NotifyNewResultsL( const CDesCArray& aNewResults )
    {
	TInt firstNewItemIndex = aNewResults.Count();

	TInt oldCount = 0;
	if( iDistinctResults )
		{
		oldCount = iDistinctResults->Count();
		}
	else
		{
	    iDistinctResults = new (ELeave) CDesCArrayFlat( 8 );
		}

    TRAPD( err, AppendResultsL( aNewResults ) );
    if( err != KErrNone )
        {
        // Cleanup: remove the ones that were added.
        while( iDistinctResults->Count() > oldCount )
            {
            iDistinctResults->Delete( iDistinctResults->Count() - 1 );
            }
        // Leave with the same error.
        User::Leave(err);
        }

    for( TInt i = iObservers.Count() - 1; i >=0; i-- )
		{
		MMdEQueryObserver* observer = iObservers[i];
		observer->HandleQueryNewResults( *this, firstNewItemIndex, 
                                         aNewResults.Count() );
		}
    }
Ejemplo n.º 11
0
TInt CFileSelectDialog::Show()
	{
	_LOG(_L("CFileSelectDialog::Show()"));
	TInt sel=0;
	CDesCArray* itemList = new (ELeave) CDesCArrayFlat(3);
	if (iCurrentPath.Compare(_L(""))!=0){if (iType==EFolder){iArray->InsertL(0,_L("Select folder"));}iArray->InsertL(0,_L("..."));}
	_LOGDATA(_L("Length of array: %d"),iArray->Count());
	
	for (TInt i=0;i<iArray->Count();i++)
		{
		TBuf<255> ItemTxt;
		ItemTxt.Copy(_L("0\t"));
		ItemTxt.Append(iArray->MdcaPoint(i));
		ItemTxt.Append(_L("\t\t"));
		itemList->AppendL(ItemTxt);
		_LOGDATA(_L("Item: %S"),&iArray->MdcaPoint(i));
		}
	_LOG(_L("Will create dialog"));
	SetItemTextArray(itemList);
    ListBox()->HandleItemAdditionL();
    Layout();
    ListBox()->SetCurrentItemIndex(0);
    ListBox()->DrawNow();
    DrawDeferred();
	}
// ---------------------------------------------------------------------------
// CLAPILandmarkStoreManager::LandmarkStoresL
// ---------------------------------------------------------------------------
//
CDesCArray* CLAPILandmarkStoreManager::LandmarkStoresL()
{
    JELOG2(EJavaLocation);
    // List landmark databases but remove the default store from the array
    CDesCArray* stores = iLmDbManager->ListDatabasesLC();
    HBufC* defaultDbName = iLmDbManager->DefaultDatabaseUriLC();

    // Remove the default database from the store names array. External stores
    // are also removed because this API does not support other than stores
    // which are located in the file system of the device
    TInt count = stores->Count();
    for (TInt i = 0; i < count; i++)
    {
        TPtrC storeUri = stores->MdcaPoint(i);
        if (defaultDbName->CompareF(storeUri) == 0 || storeUri.FindF(
                    KLAPIDefaultProtocol) == KErrNotFound)
        {
            stores->Delete(i);
            break;
        }
    }

    CleanupStack::PopAndDestroy(defaultDbName);
    CleanupStack::Pop(stores);
    return stores;
}
// ---------------------------------------------------------
// CPosLmLocalDatabaseManager::ListDatabasesL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosLmLocalDatabaseManager::ListDatabasesL(
    RPointerArray<HPosLmDatabaseInfo>& aDatabaseInfoArray)
    {
    // list URIs
    CDesCArray* dbUriArray = ListDatabasesLC();
    // list registered databases
    Session().ListDatabasesL(aDatabaseInfoArray, KFileProtocol);
    // delete from URI list those databases that are registered
    for (TInt i = aDatabaseInfoArray.Count() - 1; i >= 0; i--)
        {
        TInt index;
        if (dbUriArray->Find(aDatabaseInfoArray[i]->DatabaseUri(), index) == 0)
            {
            dbUriArray->Delete(index);
            }
        }

    // for each remaining URI in the list, fill in database info
    // and add to list
    TInt count = dbUriArray->Count();
    for (TInt i = 0; i < count; i++)
        {
        HPosLmDatabaseInfo* info = HPosLmDatabaseInfo::NewLC((*dbUriArray)[i]);
        aDatabaseInfoArray.AppendL(info);
        CleanupStack::Pop(info); // transfer of ownership to array
        }

    CleanupStack::PopAndDestroy(dbUriArray);
    // database drive, database media and default flag
    // will be filled in by database management provider.
    }
void CMainMenuGridContainer::DeleteItemL(TInt aIndex) 
{
   CArrayPtr<CGulIcon>* icons = 
      iGrid->ItemDrawer()->FormattedCellData()->IconArray();
   if (icons && aIndex >= 0 && aIndex < icons->Count()) {
      //Delete item if index is valid.
      _LIT(KItem, "%d\t\t0");
      TBuf<8> buf;
      MDesCArray* array = iGrid->Model()->ItemTextArray();
      CDesCArray* cArray = (CDesCArray*)array;

      //Remove icon and items.
      icons->Delete(aIndex);
      cArray->Delete(aIndex, (cArray->Count() - aIndex));
      iGrid->HandleItemRemovalL();

      //Re-add the items behind, needed since we changed the indexes.
      for (TInt i = aIndex; i < icons->Count(); i++) {
         buf.Format(KItem, i);
         cArray->AppendL(buf);
      }
      //Inform list box that data was added.
      iGrid->HandleItemAdditionL();

      SetGridGraphicStyleL();
   }
}
Ejemplo n.º 15
0
jobjectArray CopyToNewJavaStringArrayL(JNIEnv& aJni,
                                       const CDesCArray& aNativeArray)
{
    JELOG2(EJavaLocation);
    jclass stringClass = aJni.FindClass("java/lang/String");
    User::LeaveIfNull(stringClass);
    //
    jobjectArray result = aJni.NewObjectArray(aNativeArray.Count(),
                          stringClass, NULL);
    if (result != NULL)
    {
        TPtrC item;
        for (int i = 0; i < aNativeArray.Count(); ++i)
        {
            item.Set(aNativeArray[i]);
            jstring javaString =
                java::util::S60CommonUtils::NativeToJavaString(aJni, item);
            User::LeaveIfNull(javaString);
            //
            aJni.SetObjectArrayElement(result, i, javaString);
            aJni.DeleteLocalRef(javaString);
        }
    }
    return result;
}
// ---------------------------------------------------------
// CPosLmDatabaseManagerImpl::ListDatabasesLC
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
CDesCArray* CPosLmDatabaseManagerImpl::ListDatabasesLC(
    const TDesC& aProtocol)
    {
    CDesCArray* resultList = NULL;

    if (aProtocol == KNullDesC)
        {
        TInt pluginCount = iPlugins->NumberOfInstances();
        for (TInt i = 0; i < pluginCount; i++)
            {
            if (i == 0)
                {
                resultList = iPlugins->GetInstanceAt(i)->ListDatabasesLC();
                }
            else
                {
                CDesCArray* dbList =
                    iPlugins->GetInstanceAt(i)->ListDatabasesLC();
                TInt dbCount = dbList->Count();
                for (TInt j = 0; j < dbCount; j++)
                    {
                    resultList->AppendL((*dbList)[j]);
                    }
                CleanupStack::PopAndDestroy(dbList);
                }
            }
        }
    else
        {
        CPosLmDatabaseManagerPluginBase* plugin =
            iPlugins->GetInstanceL(aProtocol);
        resultList = plugin->ListDatabasesLC();
        }
    return resultList;
    }
// -----------------------------------------------------------------------------
// CTestSDKQueries::TestPhoneCreateEditorL
// -----------------------------------------------------------------------------
//
TInt CTestSDKQueries::TestPhoneCreateEditorL( CStifItemParser& /*aItem*/ )
    {
    CAknQueryValuePhone* valuePhone = CAknQueryValuePhone::NewLC();
    STIF_ASSERT_NOT_NULL( valuePhone );
    
    CAknQueryValuePhoneArray* array = CAknQueryValuePhoneArray::NewLC();
    STIF_ASSERT_NOT_NULL( array );
    
    CDesCArray* textArray = new (ELeave) CDesCArrayFlat( 1 );
    CleanupStack::PushL( textArray );
    _LIT( KValue, "123456" );
    textArray->AppendL( KValue );
    
    array->SetArray( *textArray );
    valuePhone->SetArrayL( array );
    
    valuePhone->SetCurrentValueIndex( 0 );
    
    TBool flag = valuePhone->CreateEditorL();
    STIF_ASSERT_TRUE( flag );
    
    CleanupStack::PopAndDestroy( textArray );
    CleanupStack::PopAndDestroy( array );
    CleanupStack::PopAndDestroy( valuePhone );
    
    return KErrNone;
    }
// ---------------------------------------------------------------------------
// TPresCondIdentityMany::AddIdentitiesInManyExceptL()
// ---------------------------------------------------------------------------
//
EXPORT_C TInt TPresCondIdentityMany::AddIdentitiesInManyExceptL(const TDesC& aRuleID,
        const CDesCArray& aIds, const TDesC& aDomain)
{
    OPENG_DP(D_OPENG_LIT( "TPresCondIdentityMany::AddIdentitiesInManyExceptL()" ) );
    OPENG_DP(D_OPENG_LIT( "     aRuleID:%S,aDomain:%S"),
             &aRuleID, &aDomain);

    TInt ret(KErrNotFound);

    RPointerArray<CXdmDocumentNode> nodes;
    CXdmDocumentNode* exceptNode(NULL);
    CXdmNodeAttribute* idattr(NULL);

    CXdmDocumentNode* manyNode = GetManyNodeL(aRuleID, EFalse, aDomain);
    TInt entitiesCount = aIds.MdcaCount();
    if(manyNode!=NULL)
    {
        for (TInt i = 0; i<entitiesCount; i++)
        {
            // if id doesnt exists in except
            if (!(IsIdentityExistsInManyExceptL(aRuleID, aIds.MdcaPoint(i), aDomain)))
            {
                exceptNode = manyNode->CreateChileNodeL(KXdmExcept);
                idattr = exceptNode->CreateAttributeL(KXdmId);
                idattr->SetAttributeValueL(aIds.MdcaPoint(i));
                ret = KErrNone;
            }
        }
        ret = KErrNone;
    }

    OPENG_DP(D_OPENG_LIT( "     return: %d"),ret);
    nodes.Close();
    return ret;
}
Ejemplo n.º 19
0
/**
 * Delete the selected item or items from the list box.
 */
void CSettingList::DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox )
	{
	CAknFilteredTextListBoxModel* model = 
		static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
	if ( model->NumberOfItems() == 0 )
		return;
	
	RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox );		
	if ( !orderedSelectedIndices )
		return;
		
	// Delete selected items from bottom up so indices don't change on us
	CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
	TInt currentItem = 0;
	
	for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) 
		{
		currentItem = ( *orderedSelectedIndices )[ idx ];
		itemArray->Delete ( currentItem );
		}
	
	// dispose the array resources
	CleanupStack::PopAndDestroy();
	
	// dispose the array pointer
	CleanupStack::PopAndDestroy( orderedSelectedIndices );
	
	// refresh listbox's cursor now that items are deleted
	AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
		aListBox, currentItem, ETrue );
	}
TBool CPackagerCntComparator::DoCompareCDesCArray(const CDesCArray& anArray1, const CDesCArray& anArray2) const
/** Compares two CDesCArray items. 

@param anArray1 The first CDesCArray to be compared.
@param anArray2 The second CDesCArray to be compared.
@return ETrue if the two items are equal, EFalse otherwise. */
	{// Need to check for NULL  arrays first.
	if((!&anArray1) && (!&anArray2))
		{
		return ETrue;
		}

	if((!&anArray1) || (!&anArray1))
		{
		return EFalse;
		}
	
	// Check if arrays are same length to begin with.
	TInt maxCount = anArray1.Count();
	if(!DoCompareTInt(maxCount, anArray2.Count()))
		{
		return EFalse;
		}

	for(TInt i=0; i<maxCount; ++i)
		{
		if(anArray1[i]!=anArray2[i])
			{
			return EFalse;
			}
		}

	return ETrue;	
	}	
Ejemplo n.º 21
0
// ----------------------------------------------------------------------------
// Copies elements from one array of descriptors to another
// ----------------------------------------------------------------------------
//
EXPORT_C void MPXUser::CopyArrayL(const MDesCArray& aSrc, CDesCArray& aDest)
    {
    aDest.Reset();
    for (TInt i=0; i < aSrc.MdcaCount(); ++i)
        {
        aDest.AppendL(aSrc.MdcaPoint(i));
        }
    }
Ejemplo n.º 22
0
/**
Copies the specified array contents.
@param aFrom The source array.
@param aTo The target array.
@leave One of the system wide error code, if a processing failure occurs.
*/
void CMTPMetaData::CopyL(const CDesCArray& aFrom, CDesCArray& aTo)
    {
    const TUint KCount(aFrom.Count());
    for (TUint i(0); (i < KCount); i++)
        {
        aTo.AppendL(aFrom[i]);
        }
    }
void CMainMenuGridContainer::AddItemL(TInt aBitmapId, TInt aMaskId, 
                                      TInt aIndex) 
{
   CArrayPtr<CGulIcon>* icons = 
      iGrid->ItemDrawer()->FormattedCellData()->IconArray();
   if (!icons) {
      icons = new ( ELeave ) CAknIconArray(9);
      iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
   }
   CleanupStack::PushL(icons);

   CFbsBitmap* bitmap;
   CFbsBitmap* mask;

#ifdef NAV2_CLIENT_SERIES60_V3
   AknIconUtils::CreateIconL(bitmap, mask, iView->GetMbmName(), 
                             aBitmapId, aMaskId);
   AknIconUtils::SetSize(bitmap, iIconRect.Size(),
                         EAspectRatioPreservedAndUnusedSpaceRemoved);
#else
   bitmap = iEikonEnv->CreateBitmapL(iView->GetMbmName(), aBitmapId);
   mask = iEikonEnv->CreateBitmapL(iView->GetMbmName(), aMaskId);
#endif

   CleanupStack::PushL(bitmap);
   CleanupStack::PushL(mask);

   if (aIndex >= 0 && aIndex < icons->Count()) {
      icons->InsertL(aIndex, CGulIcon::NewL(bitmap, mask));
   } else {
      icons->AppendL(CGulIcon::NewL(bitmap, mask));
   }
   CleanupStack::Pop(mask);
   CleanupStack::Pop(bitmap);
   CleanupStack::Pop(icons);

   _LIT(KItem, "%d\t\t0");
   TBuf<8> buf;
   MDesCArray* array = iGrid->Model()->ItemTextArray();
   CDesCArray* cArray = (CDesCArray*)array;
   if (aIndex >= 0 && aIndex < icons->Count()) {
      buf.Format(KItem, aIndex);
      cArray->InsertL(aIndex, buf);
      aIndex++;
      //We need to delete and re-index the array since we inserted
      //a new icon in the icon array.
      cArray->Delete(aIndex, icons->Count() - aIndex);
      for (TInt i = aIndex; i < icons->Count(); i++) {
         buf.Format(KItem, i);
         cArray->AppendL(buf);
      }
   } else {
      buf.Format(KItem, (icons->Count() - 1));
      cArray->AppendL(buf);
   }
   //Inform list box that data was added.
   iGrid->HandleItemAdditionL();
}
// ---------------------------------------------------------
// CSymTorrentSearchContainer::ConstructL
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CSymTorrentSearchContainer::ConstructL(const TRect& aRect, 
	CSymTorrentAppUi* aAppUi, CSTTorrentManager* aTorrentMgr)
{
	iAppUi=aAppUi;
	iTorrentMgr=aTorrentMgr;
    CreateWindowL();

    iListBox = new (ELeave) CAknDoubleGraphicStyleListBox();
    iListBox->SetMopParent(this);
	iListBox->ConstructL(this, EAknListBoxSelectionList);
	iListBox->SetContainerWindowL(*this);
	
	iListBox->View()->SetListEmptyTextL(_L("(empty)"));

	//create scrollbar
	iListBox->CreateScrollBarFrameL();
	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
		CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
	
	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(1);  // must be initialized with the number of icons used by the list!
	CleanupStack::PushL(icons);

	#ifdef EKA2
	{
		CGulIcon* chainLinkIcon = CGulIcon::NewL();
		CleanupStack::PushL(chainLinkIcon);
		
		CFbsBitmap* chainLinkBmp = NULL;
		CFbsBitmap* chainLinkMask = NULL;
		AknIconUtils::CreateIconLC(chainLinkBmp, chainLinkMask, KBitmapFile,
			EMbmSymtorrentChainlink, EMbmSymtorrentChainlink_mask);	
		chainLinkIcon->SetBitmap(chainLinkBmp);
		chainLinkIcon->SetMask(chainLinkMask);
		CleanupStack::Pop(2);
		icons->InsertL(0, chainLinkIcon);
		CleanupStack::Pop();				
	}
	#else
	{
		CEikonEnv* eikEnv = CEikonEnv::Static();
		
		icons->AppendL(eikEnv->CreateIconL(KBitmapFile, 
			EMbmSymtorrentChainlink, EMbmSymtorrentChainlink_mask));	
	}
	#endif
			
	CleanupStack::Pop(icons); // icons
	iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);

    SetRect(aRect);
    
    CDesCArray* itemArray = static_cast<CDesCArray*>
		(iListBox->Model()->ItemTextArray());
	itemArray->InsertL(0, _L("0\tFirst line\tSecond line"));			
    
   
    ActivateL();
}
Ejemplo n.º 25
0
void TestFindingL(CContactDatabase& aDb)
	{
	test.Next(_L("Test FindLC"));

	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrLocked);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrLocked);
	
	CContactItemFieldDef* fieldDef=new(ELeave) CContactItemFieldDef;
	CleanupStack::PushL(fieldDef);
	fieldDef->AppendL(KUidContactFieldFamilyName); 
	
	
	TRAPD(err,TestFindL(aDb, KGivenEditName, fieldDef, test) );
	test(err==KErrLocked);
	CleanupStack::PopAndDestroy(fieldDef);

	CContactItemFieldDef* fieldDef2=new(ELeave) CContactItemFieldDef;
	CleanupStack::PushL(fieldDef2);
	fieldDef2->AppendL(KUidContactFieldPhoneNumber); 
	TRAP(err, TestFindL(aDb, KTelephoneNum, fieldDef2, test) );
	test(err==KErrLocked);
	CleanupStack::PopAndDestroy(fieldDef2);

	test.Next(_L("Test FindInTextDefL"));

	TCallBack callBack(findWordSplitterL);
	CContactTextDef* textDef=CContactTextDef::NewLC();
	textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	CDesCArray* desArray = new(ELeave) CDesCArrayFlat(5);
	desArray->AppendL(_L("e"));
	
	CContactIdArray* arr = NULL;
	TRAP(err,arr = TestFindInTextDefL(aDb,*desArray,textDef, callBack, test) );
	
//	test(err==KErrLocked);
	desArray->Delete(0);
	delete desArray;
//FIX
	delete arr;	
	CleanupStack::PopAndDestroy(textDef); 

	test.Next(_L("Test FindInTextDefL2"));

	TCallBack callBack2(findWordSplitterL);
	CContactTextDef* textDef2=CContactTextDef::NewLC();
	textDef2->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	textDef2->AppendL(TContactTextDefItem(KUidContactFieldUrl));
	CDesCArray* desArray2 = new(ELeave) CDesCArrayFlat(5);
	desArray2->AppendL(_L("e"));
	
	TRAP(err,arr = TestFindInTextDefL(aDb,*desArray2,textDef2, callBack2, test) );
//	test(err==KErrLocked);
	desArray2->Delete(0);
	delete desArray2;
//FIX
	delete arr;	
	CleanupStack::PopAndDestroy(textDef2);
	}
Ejemplo n.º 26
0
/**
 *	Add a list box item to a list.
 */
void CSettingList::AddListBoxItemL( 
		CEikTextListBox* aListBox,
		const TDesC& aString )
	{
	CTextListBoxModel* model = aListBox->Model();
	CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
	itemArray->AppendL( aString );
	aListBox->HandleItemAdditionL();
	}
Ejemplo n.º 27
0
void CBCTestPtiEngine::TestPredictL()
    {
    //predictive
    iEngine->ActivateLanguageL(ELangEnglish, EPtiEnginePredictive);
    SimuInput(iEngine, _L("this"));

    TBuf<32> msg=_L("current word is: ");
    msg.Append(iEngine->CurrentWord());  //may be "this"
    msg.ZeroTerminate();
    AssertTrueL( ETrue, msg);

    // next
    msg=_L("next word is: ");
    msg.Append(iEngine->NextCandidate()); // Move on to next candidate.
    msg.ZeroTerminate();
    AssertTrueL( ETrue, msg);
    iEngine->CommitCurrentWord();

    // delete
    SimuInput(iEngine, _L("8447"));
    msg = _L("current word after del is: ");
    msg.Append(iEngine->DeleteKeyPress());
    msg.ZeroTerminate();
    AssertTrueL(ETrue, msg);

    // reject
    iEngine->ClearCurrentWord();
    AssertTrueL(ETrue, _L("reject current word"));

    // char2key
    AssertIntL(EPtiKey7, iEngine->CharacterToKey('s'), _L("char 's' map to key 7"));

    // candidate list
    iEngine->ClearCurrentWord();
    CDesCArray* cands = new (ELeave) CDesCArrayFlat(16);
    CleanupStack::PushL(cands);

    SimuInput(iEngine, _L("8447"));
    iEngine->GetCandidateListL(*cands);
    msg=_L("candidates: ");
    for (int i = 0; i < cands->Count(); ++i)
        {
        msg.Append(cands->MdcaPoint(i));
        msg.Append(_L(", "));
        }
    msg.ZeroTerminate();
    AssertIntL(cands->Count(), iEngine->NumberOfCandidates(), msg);
    CleanupStack::PopAndDestroy();  // cands

    // set current word
    iEngine->SetCurrentWord(_L("dog"));
    SimuInput(iEngine, _L("t"));
    msg=_L("dog+t change to: ");
    msg.Append(iEngine->CurrentWord());
    msg.ZeroTerminate();
    AssertTrueL(ETrue, msg);
    }
void TestFindInTextDefLC(CContactDatabase& aDb, TContactItemId aIccId, TContactItemId aNonIccId)
	{
	test.Next(_L("Test FindInTextDefLC"));
	// Successful find of icc entry
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrNone);
	syncChecker->SetValidateResponseL(MContactSynchroniser::ERead,KErrNone);

	TCallBack callBack(findWordSplitterL);
	CContactTextDef* textDef=CContactTextDef::NewLC();
	textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	CDesCArray* desArray = new(ELeave) CDesCArrayFlat(5);
	desArray->AppendL(_L("icc"));
	syncChecker->ResetMethodCallCountsL();
	CContactIdArray* array = aDb.FindInTextDefLC(*desArray,textDef,callBack);
	//test(syncChecker->ValidateMethodCallCountL() == 3);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aIccId);
	CleanupStack::PopAndDestroy(array);
	array=NULL;

	test.Next(_L("Test searching when ICC locked"));
	// Unsuccessful find of icc entry because icc locked
	syncChecker->SetValidateResponseL(MContactSynchroniser::ESearch,KErrLocked);
	syncChecker->ResetMethodCallCountsL();
	TRAPD(err,array = aDb.FindInTextDefLC(*desArray,textDef,callBack));
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(err==KErrLocked);
	test(array==NULL);
	desArray->Delete(0);
	delete desArray;

	// successful find of non-icc entry, even though icc locked
	CDesCArray* desArray2 = new(ELeave) CDesCArrayFlat(5);
	desArray2->AppendL(_L("non-icc"));
	syncChecker->ResetMethodCallCountsL();
	array = aDb.FindInTextDefLC(*desArray2,textDef,callBack);
	test(syncChecker->ValidateMethodCallCountL() == 0);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aNonIccId);

	// both the icc and non-icc entry should match the search criteria, but only the
	// non-icc entry should be returned since icc is locked
	SetNameField(aDb,aIccId,KNonIccName);
	syncChecker->ResetMethodCallCountsL();
	TRAP(err,array = aDb.FindInTextDefLC(*desArray2,textDef,callBack));
	test(syncChecker->ValidateMethodCallCountL() == 1);
	test(err==KErrLocked);
	test(array!=NULL);
	test(array->Count() == 1);
	test((*array)[0]==aNonIccId);
	desArray2->Delete(0);
	delete desArray2;
	SetNameField(aDb,aIccId,KIccName);
	CleanupStack::PopAndDestroy(2,textDef); // array, textDef
	}
Ejemplo n.º 29
0
void X509CertNameParser::CompareAndAddNameL( const TDesC& aProposal, 
                                             CDesCArray& aNameArray )
    {
    TInt pos = 0; // This is needed only for calling Find().
    // Append to array, if aProposal don't already exist in the array.
    if ( aNameArray.Find( aProposal, pos, ECmpNormal ) )
        {
        aNameArray.AppendL( aProposal );
        }
    }
Ejemplo n.º 30
0
CDesCArray* CLanguageList::GenerateLanguageNameArrayLC()
{
   CDesCArray* langArray = new (ELeave) CDesCArraySeg(8);
   CleanupStack::PushL(langArray);
   
   for(CLanguageList::iterator q = begin(); q != end(); ++q){
      langArray->AppendL(q->fullname);
   }
   return langArray;
}