void CBCTestPtiEngine::TestNavigationL() { iEngine->ClearCurrentWord(); SimuInput(iEngine, _L("46873")); CDesCArray* cands = new (ELeave) CDesCArrayFlat(16); CleanupStack::PushL(cands); iEngine->GetCandidateListL(*cands); AssertIntL(0, iEngine->FirstCandidate().Compare(cands->MdcaPoint(0)), _L("First candidate verified")); for (int i = 1; i < cands->Count(); ++i) { AssertIntL(0, iEngine->NextCandidate().Compare(cands->MdcaPoint(i)), _L("next candidate verified")); } for (int i = cands->Count() - 2; i >= 0; --i) { AssertIntL(0, iEngine->PreviousCandidate().Compare(cands->MdcaPoint(i)), _L("Previous candidate verified")); } CleanupStack::PopAndDestroy(); // cands }
// --------------------------------------------------------------------------- // 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; }
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 }
// --------------------------------------------------------------------------- // 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; }
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; }
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); }
/** Return a list of Contacts databases found on drive aDriveUnit. @param aListBuffer Client supplied flat buffer to be filled with a serialized CDesCArray of Contacts databases found on drive aDriveUnit. @param aDriveUnit Drive to list Contacts databases for. If defaulted then a list of Contacts databases on all drives will be returned. */ void CCntDbManagerController::ListDatabasesL(CBufFlat*& aListBuffer, TDriveUnit* aDriveUnit) const { const TInt KInitialBufferSize = 200; aListBuffer = CBufFlat::NewL(KInitialBufferSize); CleanupStack::PushL(aListBuffer); // Create a write stream for this buffer. RBufWriteStream bufStream; CleanupClosePushL(bufStream); bufStream.Open(*aListBuffer); // Use Persistence Layer to get list of Contacts databases. Note that the // ListL() method always returns a list even if empty so no NULL check for // list is required. MLplContactsFile& pl = iPersistenceLayer->ContactsFileL(); CDesCArray* list =NULL; if(aDriveUnit == NULL) { list = pl.ListL(); // Retrieve Contacts databases on all drives. } else { list = pl.ListL(aDriveUnit); // Retrieve Contacts databases on named drive. } // Externalize the CDesCArray. CleanupStack::PushL(list); TInt count = list->Count(); bufStream.WriteUint32L(count); for (TInt i=0; i<count; i++) { TInt length=(list->MdcaPoint(i)).Length(); bufStream.WriteUint8L(length); bufStream.WriteL(list->MdcaPoint(i),length); } bufStream.CommitL(); CleanupStack::PopAndDestroy(2, &bufStream); // list CleanupStack::Pop(aListBuffer); }
void CPhotoListView::StoreFolder() { int answer; TInt Index; if(iFolderStatus>=0) { TInt compareflag; TBuf<160> folderName; folderName.FillZ(); folderName.Zero(); folderName.SetLength(0); CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(folderName, CAknQueryDialog::ENoTone ); answer=( dlg->ExecuteLD( R_FOLDER_NAME_QUERY ) ); // new folder name if(answer) { iFolderStatus=0; compareflag=iPhotosAppUi->CheckAndSaveFolderToDB(folderName); if(compareflag!=1) { comment.Copy(folderName); iNewFolder = 1; ReadandSendData(); } else { CDesCArray* folderexist = iPhotosAppUi->FolderExist(); //CEikonEnv::Static ()->AlertWin (folderexist->MdcaPoint(0)) ; TBuf<100> msg; msg.Copy(folderexist->MdcaPoint(0)); CAknMessageQueryDialog* verdlg = CAknMessageQueryDialog::NewL(msg); verdlg->PrepareLC(R_ABOUT_QUERY); verdlg->RunLD(); folderexist->Reset(); } } else { Index=0; iFolderStatus=0; iPublic_Photo=EFalse; } } }
void CBCTestPtiEngine::TestChineseInputL() { TeardownL(); if((iEngine = CreateEngineL(ELangPrcChinese, EPtiEngineStroke))!=NULL) { AssertNotNullL(iEngine, _L("Chinese Pinyin activated")); SimuInput(iEngine, _L("wei")); int page=0; iEngine->SetCandidatePageLength(20); AssertTrueL(ETrue, _L("page length set to 20")); for(TPtrC str=iEngine->CandidatePage(); iEngine->MoreCandidatePages(); iEngine->NextCandidatePage()) { TFileName res; res.Format(_L("page[%d]: "), page++); for(int j=0; j<str.Length(); ++j) { res.Append(_L("<")); res.AppendNumUC(str[j], EHex); res.Append(_L(">")); } res.ZeroTerminate(); AssertTrueL(ETrue, res); if(page>10) { break; } }//end of for //predict iEngine->PreviousCandidatePage(); TPtrC aChar=iEngine->CandidatePage(); iEngine->SetPredictiveChineseChar(aChar); AssertTrueL(ETrue, _L("next chinese char predicted")); //test next candidate list iEngine->CommitCurrentWord(); CDesCArray* cands = new (ELeave) CDesCArrayFlat(16); CleanupStack::PushL(cands); TRAPD(err, iEngine->GetNextWordCandidateListL(*cands)); if(err == KErrNotSupported) { AssertTrueL(ETrue, _L("predict next candidate not supported")); } else{ TFileName msg=_L("candidates: "); for (int i = 0; i < cands->Count(); ++i) { msg.Append(cands->MdcaPoint(i)); msg.Append(_L(", ")); } msg.ZeroTerminate(); AssertTrueL(ETrue, msg); } CleanupStack::PopAndDestroy(); // cands //test conversion TInt convCap=iEngine->AvailableCharConversions(); if((convCap & EPtiSimplifiedToComplex)!=0) { AssertTrueL(ETrue, _L("can convert from simplified chinese to traditional")); } else { AssertIntL(0, convCap, _L("conv capability:")); } char inbuf[]={0x76, 0x84}; char outbuf[]={0,0}; iEngine->CharConversion(EPtiSimplifiedToComplex, inbuf, 2, outbuf); AssertTrueL(ETrue, _L("tried char conversion")); //Chinese Varient RArray<TInt> modes; iEngine->GetModeNameIndexL(EPtiChineseVariantPrc, modes); AssertTrueL(ETrue, _L("Chinese varient index table got")); modes.Close(); //phrase list iEngine->ClearCurrentWord(); SimuInput(iEngine, _L("wei")); cands = new (ELeave) CDesCArrayFlat(16); CleanupStack::PushL(cands); iEngine->GetChinesePhraseCandidatesL(*cands); AssertTrueL(ETrue, _L("Chinese phrase candidate list got")); CleanupStack::PopAndDestroy(); //cands TestSpellL(); TestDictL();// test Pinyin dict. } else { AssertTrueL(ETrue, _L("unable to activate Chinese Pinyin")); if ( iEngine == NULL ) { SetupL(); } iEngine->ActivateLanguageL(ELangEnglish, EPtiEnginePredictive); } }
LOCAL_C TBool CompareLogsL() { TBool errorOccured = EFalse; CDesCArray* correctFile = new (ELeave) CDesCArrayFlat(1); CPtrCArray* resultFile = new (ELeave) CPtrCArray(1); TParse parsedFileName; TParse parsedResultFileName; TFileName name; name.Append(KOkFileNameEntryStructure); testUtils->ResolveFile(KComponent, name, parsedFileName); correctFile->AppendL(parsedFileName.FullName()); name.Zero(); name.Copy(KFileNameEntryStructure); testUtils->ResolveLogFile(name, parsedResultFileName); resultFile->AppendL(parsedResultFileName.FullName()); RFileReadStream file1; RFileReadStream file2; HBufC8* line1Buffer = HBufC8::NewLC(1024); TPtr8 line1 = line1Buffer->Des(); TBuf8<1> aChar1; HBufC8* line2Buffer = HBufC8::NewLC(1024); TPtr8 line2 = line2Buffer->Des(); TBuf8<1> aChar2; for(TInt i=0; i<correctFile->MdcaCount(); i++) { TFileName file1Name = correctFile->MdcaPoint(i); TFileName file2Name = resultFile->MdcaPoint(i); TInt error1=KErrNone; TInt error2=KErrNone; test.Printf(_L("\n%s"), file2Name.PtrZ()); error1=file1.Open(testUtils->FileSession(), file1Name, EFileShareAny); if(error1!=KErrNone) { errorOccured = ETrue; } else { error2=file2.Open(testUtils->FileSession(), file2Name, EFileShareAny); if(error2!=KErrNone) { errorOccured = ETrue; } } if((error1==KErrNone)&&(error2==KErrNone)) { // read the file into the conversion object TBool finished = EFalse; do { line1.FillZ(); line1.SetLength(0); // compile the lines one char at a time do { TRAPD( error, file1.ReadL(aChar1, 1) ); if (error!=KErrEof) line1.Append(aChar1); else { finished = ETrue; break; } // stop at the end of line or no more data } while((aChar1[0]!=0x0A)&&(line1.Length()<1024)); line2.FillZ(); line2.SetLength(0); do { TRAPD( error, file2.ReadL(aChar2, 1) ); if (error!=KErrEof) line2.Append(aChar2); else { finished = ETrue; break; } // stop at the end of line or no more data } while((aChar2[0]!=0x0A)&&(line2.Length()<1024)); // get rid of white space line1.TrimRight(); line2.TrimRight(); if(line1.Compare(line2) != 0) { // error so no point in continuing to compare!! errorOccured = ETrue; file1.Close(); file2.Close(); delete correctFile; delete resultFile; CleanupStack::PopAndDestroy(2); //line 1 , line 2 return ETrue; } } while(!finished); } file1.Close(); file2.Close(); } delete correctFile; delete resultFile; CleanupStack::PopAndDestroy(2); //line 1 , line 2 return errorOccured; }
// ----------------------------------------------------------------------------- // CPosLmMultiDbSearch::SetDatabasesToSearchL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void CPosLmMultiDbSearch::SetDatabasesToSearchL( const CDesCArray& aDatabaseList) { __ASSERT_ALWAYS(!iMultiSearchOperation, User::Leave(KErrInUse)); __ASSERT_ALWAYS(aDatabaseList.Count() != 0, User::Leave(KErrArgument)); CloseDbsNotToSearch(aDatabaseList); // Create search items for new uri, re-sort for existing uri for (TInt j = 0; j < aDatabaseList.Count(); j++) { TPtrC dbListUri = aDatabaseList.MdcaPoint(j); // Does uri exist in search items? TBool foundUri = EFalse; TInt i; for (i = j; i < iSearchItems.Count() && !foundUri; i++) { HBufC* searchItemUri = iSearchItems[i]->iDbUriPtr; if (dbListUri == *searchItemUri) { foundUri = ETrue; break; } } if (foundUri) { if (i != j) { // Re-sort item CPosLmMultiDbSearchItem* item = iSearchItems[i]; iSearchItems.Remove(i); CleanupStack::PushL(item); iSearchItems.InsertL(item, j); CleanupStack::Pop(item); } } else { HBufC* uriPtr = dbListUri.AllocLC(); CPosLmMultiDbSearchItem* item = new (ELeave) CPosLmMultiDbSearchItem(uriPtr); CleanupStack::Pop(uriPtr); CleanupStack::PushL(item); iSearchItems.InsertL(item, j); CleanupStack::Pop(item); } } // Remove any remaining double uri:s for (TInt i = aDatabaseList.Count(); i < iSearchItems.Count(); ) { CPosLmMultiDbSearchItem* item = iSearchItems[i]; iSearchItems.Remove(i); delete item; } // Reset all search errors as their db indexes might be invalid now. iSearchErrors.Reset(); iNoOfSearchErrors = 0; }
void CContactsSubScreenView::ConstructL(CCoeControl* aWindowOwningContainer) { // Application title iAppTitle = CCknAppTitle::NewL(CCknAppTitle::EWindow); iAppTitle->SetContainerWindowL(*this); TBuf<50> titlename; TBuf<50> formatBuf; titlename.Copy(_L("")); formatBuf.Copy(_L("")); formatBuf.Append(*(iEikonEnv->AllocReadResourceL(R_STATUSTEXT_CONTACTS_UPLOADED))); titlename.Format(formatBuf, 0); iAppTitle->SetTextL(titlename, CCknAppTitle::EMainTitle); // Search results listbox iListbox = new(ELeave)CEikColumnListBox; // Column listbox with one column iListbox->ConstructL(aWindowOwningContainer, CEikListBox::ENoExtendedSelection); iListbox->CreateScrollBarFrameL(ETrue); iListbox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); iListbox->SetObserver(this); // See HandleControlEventL iListbox->SetContainerWindowL(*aWindowOwningContainer); SetContainerWindowL(*aWindowOwningContainer); // Set the listbox's first column to fill the listbox's whole width CColumnListBoxData* colData = iListbox->ItemDrawer()->ColumnData(); if(colData) { colData->SetColumnWidthPixelL(0, 200); } iListbox->SetItemHeightL(30); if(iAppUi.iStoragePath == 1) { CDesCArray* smsnames = iAppUi.GetSmsNameList(); CDesCArray* smsmobiles = iAppUi.GetSmsMobileList(); if(smsnames->Count() == 0) { iContactsArray = new (ELeave) CDesCArrayFlat(1); iMobileArray = new (ELeave) CDesCArrayFlat(1); } else { iContactsArray = new (ELeave) CDesCArrayFlat(smsnames->Count()); iMobileArray = new (ELeave) CDesCArrayFlat(smsnames->Count()); } for(int i = 0 ; i < smsnames->Count() ; i++) { iContactsArray->AppendL(smsnames->MdcaPoint(i)); iMobileArray->AppendL(smsmobiles->MdcaPoint(i)); } SetData(); } else { iContactsArray = new (ELeave) CDesCArrayFlat(12); iMobileArray = new (ELeave) CDesCArrayFlat(12); } }
void CPhotoListView::GetFolder() { TInt PopValue; //TBuf<150> msg; TInt count=0; CDesCArray* items = iPhotosAppUi->GetFolderList(); CDesCArray* foldernames = iPhotosAppUi->ReturnText(); if (items == NULL) { Count = 0; items = new (ELeave) CDesCArrayFlat(1); items->AppendL(foldernames->MdcaPoint(0)); } else { Count = items->MdcaCount(); items->AppendL(foldernames->MdcaPoint(0)); } foldernames->Reset(); CEikTextListBox* list = new( ELeave ) CAknSinglePopupMenuStyleListBox; CleanupStack::PushL( list ); CAknPopupList* popupList = CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_SELECT_CANCEL, AknPopupLayouts::EMenuWindow); CleanupStack::PushL( popupList ); popupList->SetMaximumHeight(2); list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect ); list->CreateScrollBarFrameL( ETrue ); list->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); CTextListBoxModel* model = list->Model(); model->SetItemTextArray( items ); model->SetOwnershipType( ELbmOwnsItemArray ); count = GetPhotoCount(); // TInt price; // TLex lex(iPhotosAppUi->iCharge); // lex.Val(price); // count = count * price; // TBuf<30> temp; // temp.AppendNum(count); // msg.Copy(_L("Charge ")); // msg.Append(temp); // msg.Append(_L(" pesos")); //msg.Copy(_L("Select Album:")); //msg.Copy(*(iEikonEnv->AllocReadResourceL(R_IMAGES_SELECT_ALBUM))); /*count = count / 3; temp.Copy(_L("")); temp.AppendNum(count); path = iPhotosAppUi->ImageFolderPath(); if(path == 0 || path == 1) msg.Append(_L(" Photos)")); else if(path == 2 || path == 3) msg.Append(_L(" Videos)"));*/ popupList->SetTitleL(*(iEikonEnv->AllocReadResourceL(R_IMAGES_SELECT_ALBUM))); PopValue = popupList->ExecuteLD(); if(PopValue==0) { iFolderStatus=-1; } else if(PopValue==1) { PopValue=list->CurrentItemIndex(); iFolderStatus=PopValue; TPtrC ptr1(items->MdcaPoint(PopValue)); comment.Copy(ptr1); } items->Reset(); CleanupStack::Pop(); // popupList CleanupStack::PopAndDestroy(); // list }