void CAMPreInstallApp::ListPreInstalledAppL(const TDesC& installDocPath) { RDEBUG("Clist_PreInstallAppUi: ListPreInstalledApp: <<<<"); CDir* dir= NULL; TInt err = iFs.GetDir(installDocPath, KEntryAttNormal, ESortByName, dir); // _LIT(KInstallpath,"C:\\private\\10202dce\\"); //TInt err = iFs.GetDir(KInstallpath, KEntryAttNormal, ESortByName, dir); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: err in getting dir list : %d",err); if (err==KErrNone) { CleanupStack::PushL(dir); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: no of dir's : %d",dir->Count()); for (TInt i(0); i < dir->Count(); i++) { RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: <<<< dir entry %d", i); TEntry entry; entry = (*dir)[i]; HBufC* pathAndName = HBufC::NewLC(installDocPath.Length() + entry.iName.Length() ); TPtr ptrPathAndName = pathAndName->Des(); ptrPathAndName.Append(installDocPath); ptrPathAndName.Append(entry.iName); HBufC* mimeType = HBufC::NewLC(KMaxDataTypeLength); //Recognize if (!RecognizeL(*pathAndName, mimeType)) { CleanupStack::PopAndDestroy(mimeType); CleanupStack::PopAndDestroy(pathAndName); continue; } #ifdef RD_MULTIPLE_DRIVE if (TParsePtrC(installDocPath).Path().CompareF(KPreInstallPath) == 0) #else if (installDocPath.CompareF(iPreInstallPath) == 0) #endif { RDEBUG("Clist_PreInstallAppUi: ListPreInstalledApp: <<<< Entered installDocPath.CompareF(iPreInstallPath)"); Swi::RSisRegistrySession regSession; CleanupClosePushL(regSession); User::LeaveIfError(regSession.Connect() ); RArray<TUid> uids; CleanupClosePushL(uids); regSession.InstalledUidsL(uids); RFile temp; User::LeaveIfError(temp.Open(iFs, *pathAndName, EFileShareReadersOnly | EFileRead) ); CleanupClosePushL(temp); TUid appUid; TInt uidLen = sizeof(TInt32); TInt seekLen = sizeof(TInt32) + sizeof(TInt32); User::LeaveIfError(temp.Seek(ESeekStart, seekLen)); TPckg<TInt32> uid1(appUid.iUid); User::LeaveIfError(temp.Read(uid1, uidLen)); if (uid1.Length() != uidLen) { User::Leave(KErrUnderflow); } //checking whether this is installed or not TBool installed = regSession.IsInstalledL(appUid); Swi::RSisRegistryEntry registryEntry; TInt regEntryError = registryEntry.Open(regSession, appUid); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: RegEntryError : %d",regEntryError); //User::LeaveIfError(regEntryError); if (regEntryError == KErrNone) { CleanupClosePushL(registryEntry); TBool isPreInstalled = registryEntry.PreInstalledL(); // TBool isPreInstalled = ETrue; RDEBUG_4("Clist_PreInstallAppUi: ListPreInstalledApp: UID is : '0x%X', installed:, preinstalled %d %d",appUid,installed,isPreInstalled); for (TInt i(0); isPreInstalled && i < uids.Count(); i++) { if (appUid == uids[i]) { RDEBUG("Clist_PreInstallAppUi: appUid == uids[i]"); Swi::CSisRegistryPackage* sisRegistry = NULL; TRAPD( err, sisRegistry = regSession.SidToPackageL( uids[i] ) ) ; //User::LeaveIfError(err); if(err == KErrNone) { RDEBUG("Clist_PreInstallAppUi: err == KErrNone"); TPreInstalledAppParams *params = new (ELeave) TPreInstalledAppParams; params->iPreInstalledAppame.Copy(sisRegistry->Name()); params->iPreInstalledAppVendorName.Copy( sisRegistry->Vendor()); params->iPreInstalledAppUid = sisRegistry->Uid(); params->iMimeType.Copy(*mimeType); //Get version TVersion version = registryEntry.VersionL(); TBuf8<KVersionLength> pkgDes; pkgDes.AppendNum(version.iMajor); pkgDes.Append(KLiteralPeriod); pkgDes.AppendNum(version.iMinor); params->iVersion.Copy(pkgDes); iPreInstalledAppParams.AppendL(params); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App UID is : '0x%X'",appUid); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App Name is: %S",&(sisRegistry->Name())); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App Vendor is: %S",&(sisRegistry->Vendor())); RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App UID is : '0x%X'",sisRegistry->Uid()); delete sisRegistry; } continue; } } CleanupStack::PopAndDestroy(®istryEntry); } CleanupStack::PopAndDestroy(&temp); CleanupStack::PopAndDestroy(&uids); CleanupStack::PopAndDestroy(®Session); CleanupStack::PopAndDestroy(mimeType); CleanupStack::PopAndDestroy(pathAndName); } } CleanupStack::PopAndDestroy(dir); } }
EXPORT_C void CSettingsListBoxItemDrawer::DrawItemText( TInt aItemIndex, const TRect& aItemTextRect, TBool aItemIsCurrent, TBool /*aViewIsEmphasized*/, TBool /*aItemIsSelected*/) const { _AKNTRACE_FUNC_ENTER; _AKNTRACE("DrawItemText: aItemIndex=%d, aItemTextRect=(%d,%d,%d,%d), aItemIsCurrent=%d", aItemIndex, aItemTextRect.iTl.iX, aItemTextRect.iTl.iY, aItemTextRect.iBr.iX, aItemTextRect.iBr.iY, aItemIsCurrent); #ifdef RD_UI_TRANSITION_EFFECTS_LIST MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc ); if ( transApi ) { transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); } #endif //RD_UI_TRANSITION_EFFECTS_LIST iGc->SetBrushColor( AKN_LAF_COLOR( 0 ) ); #ifdef RD_UI_TRANSITION_EFFECTS_LIST if ( transApi ) { transApi->StopDrawing(); } #endif //RD_UI_TRANSITION_EFFECTS_LIST DrawBackgroundAndSeparatorLines( aItemTextRect ); if ( aItemIsCurrent ) { FormattedCellData()->SetCurrentItemIndex( aItemIndex ); } FormattedCellData()->SetCurrentlyDrawnItemIndex( aItemIndex ); FormattedCellData()->DrawSettingHighlight( *iGc, aItemTextRect, aItemIsCurrent ); TBool drawBackground = ETrue; TPtrC temp = iModel->ItemText( aItemIndex ); TPtrC columnText; TextUtils::ColumnText( columnText, 3, &temp ); if ( columnText == KNullDesC ) { drawBackground = EFalse; } #ifdef RD_UI_TRANSITION_EFFECTS_LIST if ( transApi ) { transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); iGc->SetClippingRect( iViewRect ); } #endif // RD_UI_TRANSITION_EFFECTS_LIST // draw setting item's background if ( drawBackground ) { TAknLayoutRect outerRect; TAknWindowComponentLayout valuePane; #ifdef RD_LIST_STRETCH if ( Layout_Meta_Data::IsLandscapeOrientation() && Layout_Meta_Data::IsListStretchingEnabled() && FormattedCellData()->StretchingEnabled() ) { valuePane = AknLayoutScalable_Avkon::set_value_pane_cp_vc( 0 ); } else #endif // RD_LIST_STRETCH { valuePane = AknLayoutScalable_Avkon::set_value_pane_cp( 0 ); } outerRect.LayoutRect( aItemTextRect, TAknWindowComponentLayout::Compose( valuePane, AknLayoutScalable_Avkon::bg_set_opt_pane( 0 ) ).LayoutLine() ); TBool frameDrawn = EFalse; MAknsControlContext *cc = AknsDrawUtils::ControlContext( FormattedCellData()->Control() ); if ( !cc ) { cc = FormattedCellData()->SkinBackgroundContext(); } if ( cc ) { TAknLayoutRect innerRect; innerRect.LayoutRect( aItemTextRect, TAknWindowComponentLayout::Compose( valuePane, AknLayoutScalable_Avkon::bg_set_opt_pane_g1() ).LayoutLine() ); frameDrawn = AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *iGc, outerRect.Rect(), innerRect.Rect(), KAknsIIDQsnFrSetOptFoc, KAknsIIDQsnFrSetOptFocCenter ); } if ( !frameDrawn ) { iGc->SetBrushColor( AKN_LAF_COLOR( 243 ) ); iGc->Clear( outerRect.Rect() ); } } SetupGc( aItemIndex ); CFormattedCellListBoxData::TColors colors; TBufC<KMaxTotalDataLength> target; // Try to allocate buffer dynamically. If out of memory, use the fixed size stack buffer. // This size should be sufficient. TInt size = temp.Length() * 2; HBufC* buffer = NULL; if ( size > KMaxTotalDataLength ) { buffer = HBufC::New( size ); } TPtr des = ( buffer ? buffer->Des() : target.Des() ); TDesC* targetptr = &temp; if ( columnText == KNullDesC ) { #ifdef RD_LIST_STRETCH // If list stretching is used and the device is in landscape orientation // there is only one text cell available. Therefore, word wrapping // cannot be done. Instead the first text cell must be omitted and the // possible text moved to the second cell. If both text cells contain // data they are combined and the data is moved to the second cell (i.e. // the first cell is never drawn in landscape if list stretching is // turned on). if ( Layout_Meta_Data::IsLandscapeOrientation() && Layout_Meta_Data::IsListStretchingEnabled() && FormattedCellData()->StretchingEnabled() ) { TBool swapCells = ETrue; TPtrC itemText; // check if cell swapping should be done at all for ( TInt i = 2; i <= 4; ++i ) { if ( TextUtils::ColumnText( itemText, i, targetptr ) == KErrNotFound ) { break; } if ( itemText != KNullDesC ) { swapCells = EFalse; break; } } TextUtils::ColumnText( itemText, 1, targetptr ); if ( swapCells && itemText.Length() > 0 ) { TPtrC secondaryText; TextUtils::ColumnText( secondaryText, 5, targetptr ); // remove text from the first text cell AknLAFUtils::ReplaceColumn( des, targetptr, (TDesC16*)&KNullDesC, KColumnListSeparator, 1 ); // ReplaceColumn does not update descriptor's length :( des.Set( buffer ? buffer->Des() : target.Des() ); TInt secondaryPos = 0; TPtrC temp; temp.Set( des ); // add separators if needed for ( TInt i = 0; i < 5; ++i ) { TInt position = temp.Locate( KColumnListSeparator ); if ( position != KErrNotFound ) { if ( position < temp.Length() ) { ++position; } secondaryPos += position; } else { des.Append( KColumnListSeparator ); secondaryPos = des.Length(); } temp.Set( des.Mid( secondaryPos ) ); } des.Insert( secondaryPos, itemText ); if ( secondaryText != KNullDesC ) { _LIT( KEmptySpace, " " ); des.Insert( secondaryPos + itemText.Length(), KEmptySpace ); } targetptr = &des; } } else { WordWrapListItem( des, *targetptr, 1, 5, aItemIndex ); // Set again because ReplaceColumn in WordWrapListItem does not update the length to 'des' ! des.Set( buffer ? buffer->Des() : target.Des() ); targetptr = &des; } #else WordWrapListItem( des, temp, 1, 5, aItemIndex ); // Set again because ReplaceColumn in WordWrapListItem does not update the length to 'des' ! des.Set( buffer ? buffer->Des() : target.Des() ); targetptr = &des; #endif // RD_LIST_STRETCH } #ifdef RD_UI_TRANSITION_EFFECTS_LIST if ( transApi ) { iGc->CancelClippingRect(); transApi->StopDrawing(); } #endif // RD_UI_TRANSITION_EFFECTS_LIST if (FormattedCellData()->IsMarqueeOn() && FormattedCellData()->CurrentMarqueeItemIndex() != aItemIndex && aItemIsCurrent) { FormattedCellData()->ResetMarquee(); FormattedCellData()->SetCurrentMarqueeItemIndex(aItemIndex); } SettingsData()->Draw( Properties( aItemIndex ), *iGc, targetptr, aItemTextRect, aItemIsCurrent, colors ); delete buffer; _AKNTRACE_FUNC_EXIT; }
void CPixelMetricsMapperAppUi::ShowSingleValueL(TInt& aPixelMetric, TInt& aValue, TBool& aLast ) { HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); switch (aPixelMetric) { case QStyle::PM_DockWidgetTitleMargin: bufferPtr.Append(_L("DockTitleMargin: ")); break; case QStyle::PM_DockWidgetTitleBarButtonMargin: bufferPtr.Append(_L("DockTitleBtnMargin: ")); break; case QStyle::PM_ButtonMargin: bufferPtr.Append(_L("ButtonMargin: ")); break; case QStyle::PM_ButtonDefaultIndicator: bufferPtr.Append(_L("ButtonDefaultIndicator: ")); break; case QStyle::PM_MdiSubWindowFrameWidth: bufferPtr.Append(_L("MdiSubWndFrameW: ")); break; case QStyle::PM_ComboBoxFrameWidth: bufferPtr.Append(_L("ComboBoxFrameWidth: ")); break; case QStyle::PM_SpinBoxFrameWidth: bufferPtr.Append(_L("SpinBoxFrameWidth: ")); break; case QStyle::PM_DefaultFrameWidth: bufferPtr.Append(_L("DefaultFrameWidth: ")); break; case QStyle::PM_RadioButtonLabelSpacing: bufferPtr.Append(_L("RadioButtonLabelSpc: ")); break; case QStyle::PM_CheckBoxLabelSpacing: bufferPtr.Append(_L("CheckBoxLabelSpacing: ")); break; case QStyle::PM_ToolTipLabelFrameWidth: bufferPtr.Append(_L("ToolTipLabelFrameW: ")); break; case QStyle::PM_ListViewIconSize: bufferPtr.Append(_L("ListViewIconSize: ")); break; case QStyle::PM_LargeIconSize: bufferPtr.Append(_L("LargeIconSize: ")); break; case QStyle::PM_IconViewIconSize: bufferPtr.Append(_L("IconViewIconSize: ")); break; case QStyle::PM_TabBarIconSize: bufferPtr.Append(_L("TabBarIconSize: ")); break; case QStyle::PM_MessageBoxIconSize: bufferPtr.Append(_L("MessageBoxIconSize: ")); break; case QStyle::PM_ButtonIconSize: bufferPtr.Append(_L("ButtonIconSize: ")); break; case QStyle::PM_TextCursorWidth: bufferPtr.Append(_L("TextCursorWidth: ")); break; case QStyle::PM_SliderLength: bufferPtr.Append(_L("SliderLength: ")); break; case QStyle::PM_SliderThickness: bufferPtr.Append(_L("SliderThickness: ")); break; case QStyle::PM_SliderTickmarkOffset: bufferPtr.Append(_L("SliderTickmarkOffset: ")); break; case QStyle::PM_SliderControlThickness: bufferPtr.Append(_L("SliderCntrlThickness: ")); break; case QStyle::PM_SliderSpaceAvailable: bufferPtr.Append(_L("SliderSpaceAvailable: ")); break; case QStyle::PM_MenuBarItemSpacing: bufferPtr.Append(_L("MenuBarItemSpacing: ")); break; case QStyle::PM_MenuBarHMargin: bufferPtr.Append(_L("MenuBarHMargin: ")); break; case QStyle::PM_MenuBarVMargin: bufferPtr.Append(_L("MenuBarVMargin: ")); break; case QStyle::PM_ToolBarItemSpacing: bufferPtr.Append(_L("ToolBarItemSpacing: ")); break; case QStyle::PM_ToolBarFrameWidth: bufferPtr.Append(_L("ToolBarFrameWidth: ")); break; case QStyle::PM_ToolBarItemMargin: bufferPtr.Append(_L("ToolBarItemMargin: ")); break; case QStyle::PM_LayoutLeftMargin: bufferPtr.Append(_L("LayoutLeftMargin: ")); break; case QStyle::PM_LayoutRightMargin: bufferPtr.Append(_L("LayoutRightMargin: ")); break; case QStyle::PM_LayoutTopMargin: bufferPtr.Append(_L("LayoutTopMargin: ")); break; case QStyle::PM_LayoutBottomMargin: bufferPtr.Append(_L("LayoutBottomMargin: ")); break; case QStyle::PM_LayoutHorizontalSpacing: bufferPtr.Append(_L("LayoutHSpacing: ")); break; case QStyle::PM_LayoutVerticalSpacing: bufferPtr.Append(_L("LayoutVSpacing: ")); break; case QStyle::PM_MaximumDragDistance: bufferPtr.Append(_L("MaxDragDistance: ")); break; case QStyle::PM_ScrollBarExtent: bufferPtr.Append(_L("ScrollBarExtent: ")); break; case QStyle::PM_ScrollBarSliderMin: bufferPtr.Append(_L("ScrollBarSliderMin: ")); break; case QStyle::PM_MenuBarPanelWidth: bufferPtr.Append(_L("MenuBarPanelWidth: ")); break; case QStyle::PM_ProgressBarChunkWidth: bufferPtr.Append(_L("ProgBarChunkWidth: ")); break; case QStyle::PM_TabBarTabOverlap: bufferPtr.Append(_L("TabBarTabOverlap: ")); break; case QStyle::PM_TabBarTabHSpace: bufferPtr.Append(_L("TabBarTabHSpace: ")); break; case QStyle::PM_TabBarTabVSpace: bufferPtr.Append(_L("TabBarTabVSpace: ")); break; case QStyle::PM_TabBarBaseHeight: bufferPtr.Append(_L("TabBarBaseHeight: ")); break; case QStyle::PM_TabBarBaseOverlap: bufferPtr.Append(_L("TabBarBaseOverlap: ")); break; case QStyle::PM_TabBarScrollButtonWidth: bufferPtr.Append(_L("TabBarScrollBtnWidth: ")); break; case QStyle::PM_TabBarTabShiftHorizontal: bufferPtr.Append(_L("TabBarTabShiftH: ")); break; case QStyle::PM_TabBarTabShiftVertical: bufferPtr.Append(_L("TabBarTabShiftV: ")); break; case QStyle::PM_MenuPanelWidth: bufferPtr.Append(_L("MenuPanelWidth: ")); break; case QStyle::PM_MenuHMargin: bufferPtr.Append(_L("MenuHMargin: ")); break; case QStyle::PM_MenuVMargin: bufferPtr.Append(_L("MenuVMargin: ")); break; case QStyle::PM_MenuDesktopFrameWidth: bufferPtr.Append(_L("MenuFrameWidth: ")); break; case QStyle::PM_SmallIconSize: bufferPtr.Append(_L("SmallIconSize: ")); break; case QStyle::PM_FocusFrameHMargin: bufferPtr.Append(_L("FocusFrameHMargin: ")); break; case QStyle::PM_FocusFrameVMargin: bufferPtr.Append(_L("FocusFrameVMargin: ")); break; case QStyle::PM_ToolBarIconSize: bufferPtr.Append(_L("ToolBarIconSize: ")); break; case QStyle::PM_TitleBarHeight: // use titlepane height bufferPtr.Append(_L("TitleBarHeight: ")); break; case QStyle::PM_IndicatorWidth: bufferPtr.Append(_L("IndicatorWidth: ")); break; case QStyle::PM_IndicatorHeight: bufferPtr.Append(_L("IndicatorHeight: ")); break; case QStyle::PM_ExclusiveIndicatorHeight: bufferPtr.Append(_L("ExclusiveIndHeight: ")); break; case QStyle::PM_ExclusiveIndicatorWidth: bufferPtr.Append(_L("ExclusiveIndWidth: ")); break; case QStyle::PM_HeaderMargin: // not in S60 bufferPtr.Append(_L("HeaderMargin: ")); break; case QStyle::PM_MenuScrollerHeight: // not in S60 bufferPtr.Append(_L("MenuScrollerHeight: ")); break; case QStyle::PM_MenuTearoffHeight: // not in S60 bufferPtr.Append(_L("MenuTearoffHeight: ")); break; case QStyle::PM_DockWidgetFrameWidth: // not in S60 bufferPtr.Append(_L("DockFrameWidth: ")); break; case QStyle::PM_DockWidgetSeparatorExtent: // not in S60 bufferPtr.Append(_L("DockSepExtent: ")); break; case QStyle::PM_MdiSubWindowMinimizedWidth: //no such thing in S60 bufferPtr.Append(_L("MdiSubWndMinWidth: ")); break; case QStyle::PM_HeaderGripMargin: // not in S60 bufferPtr.Append(_L("HeaderGripMargin: ")); break; case QStyle::PM_SplitterWidth: // not in S60 bufferPtr.Append(_L("SplitterWidth: ")); break; case QStyle::PM_ToolBarExtensionExtent: // not in S60 bufferPtr.Append(_L("ToolBarExtExtent: ")); break; case QStyle::PM_ToolBarSeparatorExtent: // not in S60 bufferPtr.Append(_L("ToolBarSepExtent: ")); break; case QStyle::PM_ToolBarHandleExtent: // not in s60 bufferPtr.Append(_L("ToolBarHandleExtent: ")); break; case QStyle::PM_MenuButtonIndicator: // none??? bufferPtr.Append(_L("MenuButtonIndicator: ")); break; case QStyle::PM_ButtonShiftHorizontal: //none in 3.x bufferPtr.Append(_L("ButtonShiftHorizontal: ")); break; case QStyle::PM_ButtonShiftVertical: // none in 3.x bufferPtr.Append(_L("ButtonShiftVertical: ")); break; case QStyle::PM_TabBar_ScrollButtonOverlap: // not used in S60 - tab arrows are on left and right side of tab group - not together bufferPtr.Append(_L("TabScrollBtnOverlap: ")); break; case QStyle::PM_SizeGripSize: // use default bufferPtr.Append(_L("SizeGripSize: ")); break; case QStyle::PM_DockWidgetHandleExtent: bufferPtr.Append(_L("DockWdgtHandleExt: ")); break; case QStyle::PM_CheckListButtonSize: bufferPtr.Append(_L("CheckListButtonSize: ")); break; case QStyle::PM_CheckListControllerSize: bufferPtr.Append(_L("CheckListCntlerSize: ")); break; case QStyle::PM_DialogButtonsSeparator: bufferPtr.Append(_L("DialogBtnSeparator: ")); break; case QStyle::PM_DialogButtonsButtonWidth: bufferPtr.Append(_L("DialogBtnWidth: ")); break; case QStyle::PM_DialogButtonsButtonHeight: bufferPtr.Append(_L("DialogBtnHeight: ")); break; case QStyle::PM_HeaderMarkSize: bufferPtr.Append(_L("HeaderMarkSize: ")); break; case QStyle::PM_SpinBoxSliderHeight: bufferPtr.Append(_L("SpinBoxSliderHeight: ")); break; case QStyle::PM_DefaultTopLevelMargin: bufferPtr.Append(_L("DefaultTopLvlMrg: ")); break; case QStyle::PM_DefaultChildMargin: bufferPtr.Append(_L("DefaultChildMrg: ")); break; case QStyle::PM_DefaultLayoutSpacing: bufferPtr.Append(_L("DefaultlayoutSpc: ")); break; case QStyle::PM_TabCloseIndicatorWidth: bufferPtr.Append(_L("TabCloseIndWidth: ")); break; case QStyle::PM_TabCloseIndicatorHeight: bufferPtr.Append(_L("TabCloseIndHeight: ")); break; case QStyle::PM_ScrollView_ScrollBarSpacing: bufferPtr.Append(_L("ScrollViewBarSpc: ")); break; case QStyle::PM_SubMenuOverlap: bufferPtr.Append(_L("SubMenuOverlap: ")); break; case QStyle::PM_Custom_FrameCornerHeight: bufferPtr.Append(_L("C_FrCornerHeight: ")); break; case QStyle::PM_Custom_FrameCornerWidth: bufferPtr.Append(_L("C_FrCornerWidth: ")); break; case QStyle::PM_Custom_ThinLineWidth: bufferPtr.Append(_L("C_ThinLineWidth: ")); break; case QStyle::PM_Custom_BoldLineWidth: bufferPtr.Append(_L("C_BoldLineWidth: ")); break; case QStyle::PM_Custom_MessageBoxHeight: bufferPtr.Append(_L("C_MsgBoxHeight: ")); break; default: bufferPtr.Append(_L("Default: ")); break; } if (iFileOutputOn) { bufferPtr.Append('\t'); } bufferPtr.AppendNum(aValue); bufferPtr.Append(_L(" ")); ShowL( *buffer, aLast, iFileOutputOn ); CleanupStack::PopAndDestroy( buffer ); }
// ---------------------------------------------------- // CSymellaAppUi::HandleCommandL(TInt aCommand) // ?implementation_description // ---------------------------------------------------- // void CSymellaAppUi::HandleCommandL(TInt aCommand) { switch ( aCommand ) { case ESymellaCmdConnect: { CTR->ConnectL(); } break; case ESymellaCmdSelectGenre: { TInt index = 0; CAknListQueryDialog* queryDialog = new(ELeave) CAknListQueryDialog(&index); if(queryDialog->ExecuteLD(R_SYMELLA_GENRE_SELECTION_LIST)) { CTR->SetGenre(index); } } break; case ESymellaCmdResetHostCache: { // ask to quit CAknQueryDialog* query = CAknQueryDialog::NewL(); CleanupStack::PushL(query); _LIT(KPrompt, "Are you sure you want to reset the hostcache?"); query->SetPromptL(KPrompt); CleanupStack::Pop(); // query if (query->ExecuteLD(R_GENERAL_QUERY)) { CTR->HostCache().Reset(); } } break; case ESymellaCmdDisconnect: { CTR->DisconnectL(); } break; case ESymellaCmdConnectInfo: { HBufC* info = CTR->CreateConnectInfoL(); CleanupStack::PushL(info); /*CAknNoteDialog* note = new (ELeave) CAknNoteDialog; CleanupStack::PushL(note); note->SetTextL(*info); CleanupStack::Pop(); note->PrepareLC(R_CONNECTION_INFO_NOTE); note->RunLD();*/ CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); dlg->PrepareLC( R_MESSAGE_QUERY ); dlg->SetMessageTextL(info->Des()); dlg->QueryHeading()->SetTextL(_L("Connect info")); dlg->RunLD(); CleanupStack::PopAndDestroy(); //info } break; case ESymellaCmdAbout: { TBuf<30> time; TBuf<50> date; date.Copy(_L8(__DATE__)); time.Copy(_L8(__TIME__)); _LIT(KBuild, "Built on "); HBufC* info = HBufC::NewLC(TPtrC(KAbout).Length() + 64 /*+ TPtrC(KEngineVersion).Length() */+ TPtrC(KBuild).Length() + date.Length() + 4); TPtr des = info->Des(); des.Append(_L("Version ")); des.Append(SYMELLA_VERSION_LIT); des.Append(KAbout); //des.Append(KEngineVersion); des.Append(KBuild); des.Append(date); CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); CleanupStack::PushL(dlg); dlg->PrepareLC( R_MESSAGE_QUERY ); dlg->SetMessageTextL(des); dlg->QueryHeading()->SetTextL(_L("Symella S60")); CleanupStack::Pop(); //dlg dlg->RunLD(); CleanupStack::PopAndDestroy(); //info } break; case ESymellaCmdAddNode: { // Create dialog to allow user to view/edit connection details TBuf<100> hostName; //hostName.Copy(_L("")); hostName.Copy(_L("192.168.0.100")); TInt port = 6346; CAknMultiLineDataQueryDialog* dialog = CAknMultiLineDataQueryDialog::NewL(hostName, port); // Display and execute dialog, and act according to return value if (dialog->ExecuteLD(R_ADD_NODE_DIALOG)) { TInetAddr addr; if (addr.Input(hostName) == KErrNone) { addr.SetPort(port); CTR->HostCache().AddUltrapeerL(addr); } } } break; case EAknCmdExit: case EEikCmdExit: { PREFERENCES->SaveWebCachesL(); LOG->WriteLineL(_L("Saving hostcache...")); CTR->HostCache().SaveHostCacheL(); LOG->WriteLineL(_L("Symella terminating")); Exit(); } break; case EAknSoftkeyBack: case EAknSoftkeyExit: { // ask to quit CAknQueryDialog* query = CAknQueryDialog::NewL(); CleanupStack::PushL(query); _LIT(KPrompt, "Quit Symella?"); query->SetPromptL(KPrompt); CleanupStack::Pop(); // query if (query->ExecuteLD(R_GENERAL_QUERY)) { // ((CSymellaSearchView*)View(TUid::Uid(1)))->CloseFindBoxL(); PREFERENCES->SaveWebCachesL(); LOG->WriteLineL(_L("Saving hostcache...")); CTR->HostCache().SaveHostCacheL(); LOG->WriteLineL(_L("Symella terminating")); Exit(); } } break; case ESymellaCmdSearch: { TBuf<256> query; query.Copy(CTR->SearchString()); CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(query, CAknQueryDialog::ENoTone); dlg->SetPredictiveTextInputPermitted(ETrue); if (! dlg->ExecuteLD(R_SEARCH_QUERY)) break; HBufC8* query8 = HBufC8::NewLC(query.Length()); TPtr8 query8Ptr(query8->Des()); query8Ptr.Copy(query); CTR->SearchL(*query8); CleanupStack::PopAndDestroy(); // query8 iTabGroup->SetActiveTabByIndex(1); ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(1))); LOG->WriteL(_L("Searching for: ")); LOG->WriteLineL(query); } break; case ESymellaCmdSettings: { ActivateLocalViewL(KSettingsViewId); } break; default: break; } }
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryL(TDesC& aText, TBIOMessageType aMessageType) { // Ensure that we have a valid service ID to work with: TMsvId iBioServiceId; iBioServiceId = SetBIOServiceIdL(); HBufC* localBuffer = aText.AllocL(); CleanupStack::PushL(localBuffer); TPtr messDes = localBuffer->Des(); if (aMessageType != EBiovCardMessage && aMessageType != EBiovCalenderMessage) { // convert \r\n to \n since this is what is expected from SMS when not vCard data for (TInt i = 0; i < messDes.Length(); i++) { if (messDes[i] == (TText) '\r' && i < messDes.Length() - 1 && messDes[i + 1] == (TText) '\n') messDes.Delete(i, 1); } } // Create and fill a CRichText object for the jobbie: CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(richText); TInt pos = richText->DocumentLength(); richText->InsertL(pos, messDes); TMsvEntry newBioEntry; newBioEntry.SetNew(ETrue); newBioEntry.SetComplete(EFalse); newBioEntry.SetUnread(ETrue); newBioEntry.SetVisible(ETrue); newBioEntry.SetReadOnly(EFalse); newBioEntry.SetFailed(EFalse); newBioEntry.SetOperation(EFalse); newBioEntry.SetMultipleRecipients(EFalse); newBioEntry.SetAttachment(EFalse); newBioEntry.iMtm = KUidBIOMessageTypeMtm; newBioEntry.iType = KUidMsvMessageEntry; newBioEntry.iServiceId = iBioServiceId; TTime now; now.UniversalTime(); newBioEntry.iDate = now; TTime unixEpoch(KUnixEpoch); TTimeIntervalSeconds seconds; TTime timeStamp = newBioEntry.iDate; timeStamp.SecondsFrom(unixEpoch, seconds); retTimeStamp.setTime_t(seconds.Int()); newBioEntry.iDescription.Set(richText->Read(0, richText->DocumentLength())); TBufC<KTelephoneNumberMaxLength> telNumber; QString recepient(TEST_MSG_FROM1); tempNumber = XQConversions::qStringToS60Desc(recepient); telNumber = tempNumber->Des(); newBioEntry.iDetails.Set(telNumber); SetForMtmTypeL(newBioEntry, aMessageType); newBioEntry.iSize = richText->DocumentLength();// msgSize; CreateBioEntryClientSideL(newBioEntry, *richText); CleanupStack::PopAndDestroy(4); // richText, charFormatLayer, paraFormatLayer, localBuffer return newBioEntry.Id(); }
// --------------------------------------------------------- // CPosTp149::PrintParsedDataFromEncoderL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp149::PrintParsedDataFromEncoderL( const TDesC& aFile, const TDesC8& aBuffer, TInt aExpectedStatusCode, const TDesC8& aMimeType) { iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); if (aFile != KNullDesC) { TFileName file( aFile ); iLog->Log(_L("FILE (%S)"), &file ); TraceL(_L("----->Using FILE<-------")); TraceL(file); iLandmarkParser->SetInputFileL(file); } else { iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); TraceL(_L("----->Using BUFFER<-------")); iLandmarkParser->SetInputBuffer(aBuffer); } iOperation = iLandmarkParser->ParseContentL(); TRequestStatus status = KPosLmOperationNotComplete; TReal32 progress; TInt number = 0; RArray<TPosLmItemId> array; CleanupClosePushL(array); while (status == KPosLmOperationNotComplete) { iLog->Log(_L("--- Parsing ---------------------------")); TraceL(_L("------------------------------")); iOperation->NextStep(status, progress); // Wait for NextStep to complete User::WaitForRequest(status); if (status != KPosLmOperationNotComplete && status != KErrNone) { HBufC* buffer = HBufC::NewLC( 128); TPtr buf = buffer->Des(); buf.Format(_L("\tStatus %d"), status.Int()); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } else { iLog->Log(_L("Parsing element")); if ( iLandmarkParser->NumOfParsedLandmarks() ) { // Get last parsed landmark CPosLandmark* lm = iLandmarkParser->LandmarkLC(); TPtrC lmName; TPtrC catName; lm->GetLandmarkName(lmName); lm->GetCategoriesL(array); //iLog->Log(lmName); for (TInt i=0;i<array.Count();i++) { CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC( array[i] ); category->GetCategoryName( catName ); HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); TPtr buf = buffer->Des(); if ( category->GlobalCategory()) { buf.Append(_L("\tGlobal category: ")); } else { buf.Append(_L("\tLocal category: ")); } buf.Append(catName); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; CleanupStack::PopAndDestroy(category); } PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); number++; CleanupStack::PopAndDestroy(lm); } } } iLog->Log(_L("--- Parsing end ---------------------------")); TraceL(_L("------------------------------")); CleanupStack::PopAndDestroy(&array); if (status.Int() != aExpectedStatusCode) { HBufC* buffer = HBufC::NewLC( 128 ); TPtr buf = buffer->Des(); buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); iLog->Log( buf ); iErrorsFound++; CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); HBufC* buffer = HBufC::NewLC( 256 ); TPtr buf = buffer->Des(); buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; if (nr != (TUint32)number) { iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); iErrorsFound++; } TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); iLog->Log(_L("--- CollectionData ---")); TraceL(_L("--- CollectionData ---")); if (lmId != EPosLmCollDataNone) { TPtrC first = iLandmarkParser->CollectionData(lmId); HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); TPtr buf = buffer->Des(); buf.Zero(); buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); buf.Append(first); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } else { iLog->Log(_L("\tNo collection data found 1")); } while (lmId != EPosLmCollDataNone) { lmId = iLandmarkParser->NextCollectionDataId(lmId); if (lmId != EPosLmCollDataNone) { TPtrC first = iLandmarkParser->CollectionData(lmId); HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); TPtr buf = buffer->Des(); buf.Zero(); buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); buf.Append(first); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } else { iLog->Log(_L("\tNo collection data found 2")); } } iLog->Log(_L("--- CollectionData ---")); TraceL(_L("--- CollectionData ---")); delete iOperation; iOperation = NULL; delete iLandmarkParser; iLandmarkParser = NULL; iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); }
// --------------------------------------------------------- // CPosTp149::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp149::StartL() { BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); // Delete the trace file DeleteFileL(KFileTrace); HBufC8* emptyBuffer=NULL; iLog->Log(_L("Test with Tp149KMZFile.kmz")); PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); // Now compare tha trace file against the correct one RFile correctFile; RFile file; iLog->Log(_L(">>>>>>>Comparing files<<<<<")); TFileName filename; CreateCorrectXmlFileL( KCorrectFile, filename ); User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); CleanupClosePushL(correctFile); User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); CleanupClosePushL(file); HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); TPtr correctLine = correctLinebuffer->Des(); HBufC* linebuffer = HBufC::NewLC( KBufSize ); TPtr line = linebuffer->Des(); TInt err = KErrNone; TBool done = EFalse; TInt lineNr = 0; while (ReadLn(correctFile, correctLine) != KErrEof && !done) { lineNr++; err = ReadLn(file, line); if ( err == KErrEof ) { done = ETrue; } correctLine.Trim(); line.Trim(); if (correctLine.Compare(line) != KErrNone) { HBufC* buf = HBufC::NewLC( 128 ); TPtr buffer = buf->Des(); buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); iLog->Log( buffer ); iLog->Log( correctLine ); iLog->Log( line ); iErrorsFound++; CleanupStack::PopAndDestroy( buf ); } } CleanupStack::PopAndDestroy(linebuffer); CleanupStack::PopAndDestroy(correctLinebuffer); CleanupStack::PopAndDestroy(&file); CleanupStack::PopAndDestroy(&correctFile); // EOF for trace file was reach before EOF in the correct file if (done) { iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); iErrorsFound++; } DoCancelTestL(); if (iErrorsFound != KErrNone) { iLog->Log(_L("Errors found in TP149")); User::Leave(-1); } }
/** Set up the CCntSqlStatement objects held by the class. */ void CPplGroupsTable::ConstructL() { // Statement types TCntSqlStatementType insertType(EInsert, KSqlContactGroupTableName); TCntSqlStatementType selectType(ESelect, KSqlContactGroupTableName); TCntSqlStatementType updateType(EUpdate, KSqlContactGroupTableName); TCntSqlStatementType deleteType(EDelete, KSqlContactGroupTableName); TCntSqlStatementType countContactsType(ESelect, KSqlContactTableName); // Where clauses // sizes of the clauses const TInt KWhereGroupClauseBufSize(KGroupContactGroupId().Size() + KWhereStringEqualsStringFormatText().Size() + KGroupContactGroupIdParam().Size() ); const TInt KWhereMemberClauseBufSize(KGroupContactGroupMemberId().Size() + KWhereStringEqualsStringFormatText().Size() + KGroupContactGroupMemberIdParam().Size() ); const TInt KWhereOrClauseBufSize(KWhereGroupClauseBufSize + KSqlOr().Size() + KWhereMemberClauseBufSize); // for WHERE contact_group_id = [contact id value] HBufC* whereGroupIdClause = HBufC::NewLC(KWhereGroupClauseBufSize); whereGroupIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupId, &KGroupContactGroupIdParam ); // for WHERE contact_group_member_id = [contact id value] HBufC* whereMemberIdClause = HBufC::NewLC(KWhereMemberClauseBufSize); whereMemberIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupMemberId, &KGroupContactGroupMemberIdParam ); // for WHERE contact_group_id = [contact id value] // OR contact_group_member_id = [contact id value] HBufC* whereGroupOrMemberIdClause = HBufC::NewLC(KWhereOrClauseBufSize); TPtr whereGroupOrMemberIdClausePtr = whereGroupOrMemberIdClause->Des(); whereGroupOrMemberIdClausePtr.AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupId, &KGroupContactGroupIdParam); whereGroupOrMemberIdClausePtr.Append(KSqlOr); whereGroupOrMemberIdClausePtr.AppendFormat(KWhereStringEqualsStringFormatText, &KGroupContactGroupMemberId, &KGroupContactGroupMemberIdParam); // for WHERE contact_id = [contact_id] HBufC* whereContactIdClause = HBufC::NewLC(KWhereGroupClauseBufSize); whereContactIdClause->Des().AppendFormat(KWhereStringEqualsStringFormatText, &KContactId, &KContactIdParam ); // INSERT // insert group-member relationships // For a statement in the following format: // INSERT INTO groups // (group_id, contact_group_id, contact_group_member_id) // VALUES (NULL, [contact group id value], [contact group member id value]); // iInsertStmnt = TSqlProvider::GetSqlStatementL(insertType); iInsertStmnt->SetParamL(KGroupContactGroupId(), KGroupContactGroupIdParam()); iInsertStmnt->SetParamL(KGroupContactGroupMemberId(), KGroupContactGroupMemberIdParam()); // SELECT // select group id // For a statement in the following format: // SELECT contact_group_id FROM groups // WHERE contact_group_member_id = [contact id value]; // iSelectGroupsStmnt = TSqlProvider::GetSqlStatementL(selectType); iSelectGroupsStmnt->SetParamL(KGroupContactGroupId(), KNullDesC() ); iSelectGroupsStmnt->SetConditionL(*whereMemberIdClause); // select member id // For a statement in the following format: // SELECT contact_group_member_id FROM groups // WHERE contact_group_id = [contact id value]; // iSelectMembersStmnt = TSqlProvider::GetSqlStatementL(selectType); iSelectMembersStmnt->SetParamL(KGroupContactGroupMemberId(), KNullDesC() ); iSelectMembersStmnt->SetConditionL(*whereGroupIdClause); // DELETE // delete all where group or member equals id // For a statement in the following format: // DELETE FROM groups WHERE contact_group_id = [contact id value] // OR contact_group_member_id = [contact id value]; // iDeleteStmnt = TSqlProvider::GetSqlStatementL(deleteType); iDeleteStmnt->SetConditionL(*whereGroupOrMemberIdClause); // SELECT // SELECt count(*) FROM contact WHERE contact_id = [contact_id] iCountContactsStmnt = TSqlProvider::GetSqlStatementL(countContactsType); iCountContactsStmnt->SetParamL(KSqlCount, KSpace); iCountContactsStmnt->SetConditionL(*whereContactIdClause); CleanupStack::PopAndDestroy(4, whereGroupIdClause); // and whereContactIdClause, whereMemberIdClause, whereGroupOrMemberIdClause }
void CStartupProperties::ConstructFromResourceL(TResourceReader& aSource) { const TStartupCommandType commandType = static_cast<TStartupCommandType>(aSource.ReadUint16()); iStartupType = ((commandType==EStartupApp)||(commandType==EStartupApp2)) ? EStartApp : EStartProcess; iFileName = aSource.ReadHBufCL(); if(iFileName) { TPtr writeableFilename = iFileName->Des(); writeableFilename.TrimAll(); } iArgs = aSource.ReadHBufCL(); if(iArgs) { TPtr writeableArgs = iArgs->Des(); writeableArgs.TrimAll(); } iStartMethod = static_cast<TStartMethod>(aSource.ReadUint16()); switch(commandType) { case EStartupApp: delete iArgs; // deleted for backwards compatibility iArgs = NULL; iViewless = static_cast<TUint16>(aSource.ReadUint16()); iStartInBackground = static_cast<TUint16>(aSource.ReadUint16()); iTimeout = aSource.ReadInt32(); iRecoveryMethod.iActionOnCommandFailure = static_cast<TActionOnCommandFailure> (aSource.ReadUint16()); iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16()); break; case EStartupApp2: iViewless = static_cast<TUint16>(aSource.ReadUint16()); iStartInBackground = static_cast<TUint16>(aSource.ReadUint16()); iTimeout = aSource.ReadInt32(); iRecoveryMethod.iRecoveryMethod = static_cast<TRecoveryMethod> (aSource.ReadUint16()); iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16()); iMonitored = static_cast<TUint16>(aSource.ReadUint16()); iRestartMode = aSource.ReadInt16(); break; case EStartupProcess: iTimeout = aSource.ReadInt32(); iRecoveryMethod.iActionOnCommandFailure = static_cast<TActionOnCommandFailure>(aSource.ReadUint16()); iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16()); break; case EStartupProcess2: iTimeout = aSource.ReadInt32(); iRecoveryMethod.iRecoveryMethod = static_cast<TRecoveryMethod>(aSource.ReadUint16()); iNoOfRetries = static_cast<TUint16> (aSource.ReadUint16()); iMonitored = static_cast<TUint16>(aSource.ReadUint16()); iRestartMode = aSource.ReadInt16(); break; default: PanicNow(KPanicStartupProperties, EInvalidCommandType); break; } DoSanityCheck(commandType); }
void CMontgomeryPerformance::PerformAction(TRequestStatus& aStatus) { TRequestStatus* status = &aStatus; iResult = ETrue; CMontgomeryStructure* montConst; TUint iterations = 0; TTime start, end; TTimeIntervalSeconds diff(0); const TTimeIntervalSeconds iterationTime(iIterations); start.UniversalTime(); while (diff < iterationTime) { montConst = CMontgomeryStructure::NewL(iModulus); delete montConst; iterations++; end.UniversalTime(); end.SecondsFrom(start, diff); } end.UniversalTime(); TTimeIntervalMicroSeconds time = end.MicroSecondsFrom(start); TReal rate = I64REAL(time.Int64()) / (iterations); TReal rtime = I64REAL(time.Int64()); HBufC* realbuf = HBufC::NewLC(128); TPtr buf = realbuf->Des(); buf.Format(KPerfConstFormat, rate, iterations, rtime); iOut.writeString(buf); iConsole.Printf(_L(".")); CMontgomeryStructure* mont = CMontgomeryStructure::NewLC(iModulus); //Multiply diff = 0; iterations = 0; start.UniversalTime(); while (diff < iterationTime) { mont->MultiplyL(iA, iB); iterations++; end.UniversalTime(); end.SecondsFrom(start, diff); } end.UniversalTime(); time = end.MicroSecondsFrom(start); rate = I64REAL(time.Int64()) / iterations; rtime = I64REAL(time.Int64()); buf.Zero(); buf.Format(KPerfMultiplyFormat, rate, iterations, rtime); iOut.writeString(buf); iConsole.Printf(_L(".")); //Square diff = 0; iterations = 0; start.UniversalTime(); while (diff < iterationTime) { mont->SquareL(iA); iterations++; end.UniversalTime(); end.SecondsFrom(start, diff); } end.UniversalTime(); time = end.MicroSecondsFrom(start); rate = I64REAL(time.Int64()) / iterations; rtime = I64REAL(time.Int64()); buf.Zero(); buf.Format(KPerfSquareFormat, rate, iterations, rtime); iOut.writeString(buf); iConsole.Printf(_L(".")); //Exponentiate diff = 0; iterations = 0; start.UniversalTime(); while (diff < iterationTime) { mont->ExponentiateL(iA, iB); iterations++; end.UniversalTime(); end.SecondsFrom(start, diff); } end.UniversalTime(); time = end.MicroSecondsFrom(start); rate = I64REAL(time.Int64()) / iterations; rtime = I64REAL(time.Int64()); buf.Zero(); buf.Format(KPerfExpFormat, rate, iterations, rtime); iOut.writeString(buf); iConsole.Printf(_L(".")); //Reduce RInteger top = iA.TimesL(iB); CleanupStack::PushL(top); diff = 0; iterations = 0; start.UniversalTime(); while (diff < iterationTime) { mont->ReduceL(top); iterations++; end.UniversalTime(); end.SecondsFrom(start, diff); } end.UniversalTime(); CleanupStack::PopAndDestroy(&top); time = end.MicroSecondsFrom(start); rate = I64REAL(time.Int64()) / iterations; rtime = I64REAL(time.Int64()); buf.Zero(); buf.Format(KPerfReduceFormat, rate, iterations, rtime); iOut.writeString(buf); iConsole.Printf(_L(".")); CleanupStack::PopAndDestroy(mont); CleanupStack::PopAndDestroy(realbuf); User::RequestComplete(status, KErrNone); iActionState = CTestAction::EPostrequisite; }
/** @SYMTestCaseID UIF-ETUL-0009 @SYMREQ 7736 @SYMTestCaseDesc Test to Parse for URI's, Email Addresses, Phone Numbers and URL's in a file and to verify them @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Constructs CTulAddressStringTokenizer object with CTulAddressStringTokenizer::EFindItemSearchMailAddressBin \n which parses the given string and creates an item array consisting of all the Email addresses\n API Calls:\n CTulAddressStringTokenizer::NewL(const TDesC& aText, TInt aSearchCases);\n CTulAddressStringTokenizer::Item(SFoundItem& aItem); \n CTulAddressStringTokenizer::NextItem(SFoundItem& aItem); \n @SYMTestExpectedResults The test checks whether 1. Phone numbers, Email addresses, URL's and URI's parsed by CTulAddressStringTokenizer are the correct ones. */ void CT_AddressStringTokenizerStep::ParseURIFileL() { INFO_PRINTF1(_L("Test begins")); __UHEAP_MARK; //load test case text to string RFs rfs; User::LeaveIfError(rfs.Connect()); CleanupClosePushL(rfs); _LIT(KParesTextFile, "z:\\system\\data\\addressstringtokenizertestappdata.txt"); _LIT(KParesTextFileRef, "z:\\system\\data\\addressstringtokenizertestappdataref.txt"); RFile file; HBufC* fullBuf = HBufC::NewMaxLC(KFullBufSize); TPtr fullBufPtr = fullBuf->Des(); fullBufPtr = KNullDesC; TFileText reader; TBuf<KReadBufSize> fileBuffer; if ((file.Open(rfs, KParesTextFile, EFileStreamText|EFileRead|EFileShareAny)) == KErrNone) { CleanupClosePushL(file); // use TFileText for reading file. There is probably better ways to do this tho. reader.Set(file); if (reader.Seek(ESeekStart)) { INFO_PRINTF1(_L("File corrupted")); User::Leave(KErrGeneral); // not cleaning up properly } while (!reader.Read(fileBuffer)) { fullBufPtr.Append(fileBuffer); fullBufPtr.Append('\n'); } CleanupStack::Pop(&file); file.Close(); } else { INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdata.txt not found")); User::Leave(KErrNotFound); } if (file.Open(rfs, KParesTextFileRef, EFileStreamText|EFileRead|EFileShareAny) == KErrNone) { CleanupClosePushL(file); // use TFileText for reading file. There is probably better way to do this tho. reader.Set(file); if (reader.Seek(ESeekStart)) { INFO_PRINTF1(_L("File corrupted")); User::Leave(KErrGeneral); // not cleaning up properly } } else { INFO_PRINTF1(_L("z:\\system\\data\\addressstringtokenizertestappdataref.txt not found")); User::Leave(KErrNotFound); } INFO_PRINTF1(_L("Start searching...")); // Create an instance of Address String Tokenizer and search for URL's. CTulAddressStringTokenizer* addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchURLBin); TestAddressStringTokenizers(addressString, reader, fullBufPtr); delete addressString; // find phone numbers from same text addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin); TestAddressStringTokenizers(addressString, reader, fullBufPtr); // test do new search with same instance TInt count = addressString->DoNewSearchL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchMailAddressBin); TEST(count > 0); TestAddressStringTokenizers(addressString, reader, fullBufPtr); delete addressString; // find schemed URIs from same text addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, CTulAddressStringTokenizer::EFindItemSearchScheme); TestAddressStringTokenizers(addressString, reader, fullBufPtr); delete addressString; // find everything from same text addressString = CTulAddressStringTokenizer::NewL(fullBufPtr, (CTulAddressStringTokenizer::TTokenizerSearchCase)(CTulAddressStringTokenizer::EFindItemSearchPhoneNumberBin | CTulAddressStringTokenizer::EFindItemSearchURLBin | CTulAddressStringTokenizer::EFindItemSearchMailAddressBin | CTulAddressStringTokenizer::EFindItemSearchScheme)); TestAddressStringTokenizers(addressString, reader, fullBufPtr); delete addressString; CleanupStack::PopAndDestroy(3, &rfs); __UHEAP_MARKEND; }
void CLowDiskSpaceTest::FillDiskL() { _LIT(KFillDiskTitle, "Fill the disk"); test.Next(_L("Fill the disk")); TVolumeInfo tv; User::LeaveIfError( iFileSession.Volume(tv) ); TInt frees = 0; iManyFiles = tv.iFree / KMaxTInt; if ( iManyFiles > 0) { TPtrC tname( KFileName ); TInt i = 0; for( ; i < iManyFiles; ++i ) { HBufC *fval=HBufC::NewLC( tname.Length()+4 );//assume #files < 10000 TPtr fptr = fval->Des() ; fptr.Append( tname ); fptr.AppendNum( i ); User::LeaveIfError( iFile->Replace( iFileSession, fptr, EFileWrite ) ); User::LeaveIfError( iFile->SetSize( KMaxTInt ) ); iFile->Close(); CleanupStack::PopAndDestroy( fval ); } User::LeaveIfError( iFileSession.Volume(tv) ); frees = tv.iFree - KMinusFull ; if( frees <= 0 ) { frees = tv.iFree; } User::LeaveIfError( iFile->Replace( iFileSession, KFileName, EFileWrite ) ); #ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__ TInt err = KErrDiskFull; while(err == KErrDiskFull) { err = iFile->SetSize(frees); frees -= 100; if(frees <= 0) { break; } } #else User::LeaveIfError( iFile->SetSize( frees ) ); #endif iFile->Close(); } else { frees = tv.iFree - KMinusFull ; if( frees <= 0 ) { frees = tv.iFree; } User::LeaveIfError( iFile->Replace( iFileSession, KFileName, EFileWrite ) ); #ifdef __SYMBIAN_CNTMODEL_USE_SQLITE__ TInt err = KErrDiskFull; while(err == KErrDiskFull) { err = iFile->SetSize(frees); frees -= 100; if(frees <= 0) { break; } } #else User::LeaveIfError( iFile->SetSize( frees ) ); #endif iFile->Close(); } }
//---------------------------------------------- // execute menu item command //---------------------------------------------- Bool TLMenu::TMenuController::ExecuteMenuItem(TRefRef MenuItemRef) { TPtr<TMenuItem> pMenuItem = GetMenuItem(MenuItemRef); if ( !pMenuItem ) { TLDebug_Break("No such menu item"); return FALSE; } // get command of menu item TRefRef MenuCommand = pMenuItem->GetMenuCommand(); TRefRef AudioRef = pMenuItem->GetAudioRef();; // open-menu command if ( MenuCommand == "Open" ) { // Already has a queued command? if(m_QueuedCommand.GetRef().IsValid()) return FALSE; // Queue up the command. m_QueuedCommand.SetRef(MenuCommand); m_QueuedCommand.SetTypeRef(pMenuItem->GetNextMenu()); } else if ( MenuCommand == "Close" ) { // Already has a queued command? if(m_QueuedCommand.GetRef().IsValid()) return FALSE; // Queue up the command. m_QueuedCommand.SetRef(MenuCommand); } else { // do non standard command if ( !ExecuteCommand( MenuCommand, pMenuItem->GetData() ) ) return FALSE; } // Valid audio to play? // Create menu audio for command execution // gr: this should go in menu renderer code, not menu logic code if(AudioRef.IsValid()) { TLMessaging::TMessage Message(TLCore::InitialiseRef); Message.ExportData("Asset", AudioRef); Message.ExportData("Play", TRUE); Message.ExportData("RateOfDecay", 0.0f); // Make 2D Message.ExportData("MinRange", 100000.0f); Message.ExportData("MaxRange", 100000.0f); TLAudio::g_pAudiograph->StartAudio(MenuCommand, AudioRef); } // publish that command has been executed OnMenuItemExecuted( MenuCommand, pMenuItem->GetData() ); return TRUE; }
TVerdict CHashIncrementalHashWithCopyStep::doTestStepL() { if (TestStepResult()==EPass) { //Assume faliure, unless all is successful SetTestStepResult(EFail); INFO_PRINTF1(_L("*** Hash - Incremental Hash with Copy ***")); INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells()); TVariantPtrC algorithmUid; TVariantPtrC operationModeUid; TPtrC sourcePath; TPtrC expectedHash; //Extract the Test Case ID parameter from the specified INI file if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) || !GetStringFromConfig(ConfigSection(),KConfigOperationMode,operationModeUid) || !GetStringFromConfig(ConfigSection(),KConfigSourcePath,sourcePath) || !GetStringFromConfig(ConfigSection(),KConfigExHashHmacValue,expectedHash)) { ERR_PRINTF1(_L("** Error: Failed to Load Configuration Parameters **")); SetTestStepResult(EFail); } else { //Create a pointer for the Hash Implementation Object CHash* hashImpl = NULL; //Retrieve a Hash Factory Object TRAPD(err,CHashFactory::CreateHashL(hashImpl, algorithmUid, operationModeUid, NULL, NULL)); if(hashImpl && (err == KErrNone)) { //Push the Hash Implementation Object onto the Cleanup Stack CleanupStack::PushL(hashImpl); RFs fsSession; //Create a connection to the file server err = fsSession.Connect(); if(err != KErrNone) { ERR_PRINTF2(_L("*** Error: File Server Connection - %d ***"), err); SetTestStepResult(EFail); } else { RFile sourceFile; CleanupClosePushL(sourceFile); //Open the specified source file err = sourceFile.Open(fsSession,sourcePath, EFileRead); if(err != KErrNone) { ERR_PRINTF2(_L("*** Error: Opening Source File - %d ***"), err); SetTestStepResult(EFail); } else { TInt sourceLength = 0; TInt readPosition = 0; TInt readIncrement = 0; TBool hashComplete = EFalse; TBool hashCopied = EFalse; TPtrC8 hashStr; CHash* hashCopyImpl = NULL; User::LeaveIfError(sourceFile.Size(sourceLength)); //Divide the total size of the source file up into individual equal sized blocks to read //over several increments readIncrement = sourceLength/KDataReadBlocks; do { //Create a heap based descriptor to store the data HBufC8* sourceData = HBufC8::NewL(readIncrement); CleanupStack::PushL(sourceData); TPtr8 sourcePtr = sourceData->Des(); //Read in a block of data from the source file from the current position err = sourceFile.Read(readPosition,sourcePtr,readIncrement); //Update the read position by adding the number of bytes read readPosition += readIncrement; if(readPosition == readIncrement) { //Read in the first block from the data file into the Hash implementation object hashImpl->Hash(*sourceData); INFO_PRINTF2(_L("Intial Hash - Bytes Read: %d"), readPosition); } else if(readPosition >= sourceLength) { //Reading in the final block, constructs the complete hash value and returns it within a TPtrC8 hashStr.Set(hashCopyImpl->Final(*sourceData)); //Sets the Complete Flag to ETrue in order to drop out of the loop hashComplete = ETrue; TInt totalRead = (readPosition - readIncrement) + (*sourceData).Length(); INFO_PRINTF2(_L("Final Hash - Bytes Read: %d"),totalRead); } //If the read position is half the source length and the implementation //object hasn't already been copied else if((readPosition >= sourceLength/2) && (hashCopied == EFalse)) { //Update the hash message before copying hashImpl->Update(*sourceData); INFO_PRINTF1(_L("Copying Hash Object...")); //Create a Copy of the existing Hash Object and all internal state of the message digest hashCopyImpl = hashImpl->CopyL(); hashCopied = ETrue; INFO_PRINTF2(_L("*** HASH COPY - Bytes Read: %d ***"), readPosition); } else { //Update the message data within the Hash object with the new block if(hashCopied == EFalse) { hashImpl->Update(*sourceData); INFO_PRINTF2(_L("Hash Update - Bytes Read: %d"), readPosition); } else { hashCopyImpl->Update(*sourceData); INFO_PRINTF2(_L("Hash Update (Copy) - Bytes Read: %d"), readPosition); } } CleanupStack::PopAndDestroy(sourceData); }while(hashComplete == EFalse); //Create a NULL TCharacteristics pointer const TCharacteristics* charsPtr(NULL); //Retrieve the characteristics for the hash implementation object TRAP_LOG(err, hashImpl->GetCharacteristicsL(charsPtr)); //Static cast the characteristics to type THashCharacteristics const THashCharacteristics* hashCharsPtr = static_cast<const THashCharacteristics*>(charsPtr); //The hash output size is returned in Bits, divide by 8 to get the Byte size TInt hashSize = hashCharsPtr->iOutputSize/8; //Retrieve the final 8bit hash value and convert to 16bit HBufC* hashData = HBufC::NewLC(hashSize); TPtr hashPtr = hashData->Des(); //Copy the hashed content into the heap based descriptor hashPtr.Copy(hashStr); //Take the 16bit descriptor and convert the string to hexadecimal TVariantPtrC convertHash; convertHash.Set(hashPtr); HBufC* hashResult = convertHash.HexStringLC(); INFO_PRINTF2(_L("*** Hashed Data: %S ***"),&*hashResult); INFO_PRINTF2(_L("*** Expected Hash: %S ***"),&expectedHash); //If the returned hash value matches the expected hash, Pass the test if(*hashResult == expectedHash) { INFO_PRINTF1(_L("*** Hash - Incremental Hash with Copy : PASS ***")); SetTestStepResult(EPass); } else { ERR_PRINTF2(_L("*** FAIL: Hashed and Expected Value Mismatch ***"), err); SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(hashResult); CleanupStack::PopAndDestroy(hashData); delete hashCopyImpl; } //Cleanup the Source RFile CleanupStack::PopAndDestroy(); } fsSession.Close(); CleanupStack::PopAndDestroy(hashImpl); } else { ERR_PRINTF2(_L("*** FAIL: Failed to Create Hash Object - %d ***"), err); SetTestStepResult(EFail); } } } INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells()); return TestStepResult(); }
// ----------------------------------------------------------------------------- // For Devanagari AS // Checks if @c aItemText matches @c aSearchText. // @param aItemText list box item text. // @param aSearchText search text. // @param aNextChars reference to the next characters for the adaptive search grid // @return @c ETrue if list box item text matches EFalse otherwise. // ----------------------------------------------------------------------------- // inline TBool IsIndicAdaptiveFindMatch( const TDesC& aItemString, const TDesC& aSearchText, HBufC*& aNextChars, TInt /*aInputLang*/ ) { HBufC16* searchText(NULL); TRAPD( error, searchText = HBufC16::NewL( KMatchingBufferLength ) ); if ( error == KErrNone ) { TInt itemStringLength = aItemString.Length(); TInt searchTextLength = aSearchText.Length(); if ( searchTextLength < KMatchingBufferLength ) { searchText->Des().Append( aSearchText ); } else { searchText->Des().Append( aSearchText.Left(KMatchingBufferLength-1) ); } TInt indicSyllableCount = -1; if( aSearchText.Length()>0 ) { //This will replace all placeholder '-' symbols with '*' indicSyllableCount = IndicSyllableCount( searchText, searchTextLength ); } //Append '*' to the end if not already present. if ( (*searchText)[searchText->Length() - 1] != KLitStar) { searchText->Des().Append( KLitStar ); } TInt result = KErrNotFound; //check if the search string is found in the item string for( TInt index = 0; index < itemStringLength; index++ ) { if ( index==0 || IsFindWordSeparator( aItemString[index-1] ) ) { TUint flag = ( TCollationMethod::EFoldCase | TCollationMethod::EIgnoreNone | TCollationMethod::EIgnoreCombining);//TCollationMethod::EIgnoreNone | TCollationMethod collationMethod = *Mem::GetDefaultMatchingTable(); collationMethod.iFlags |= flag; result = aItemString.Mid(index).MatchC( (*searchText), &collationMethod ); if( result != KErrNotFound ) { if( index <= (itemStringLength-searchTextLength) ) { //search for the last character in the string //We use a TBuf instead of TChar since a special ligature is //represented by 3 characters. Last char would be the '*' wildchar. TBuf<4> lastChar; TInt modifiedStrLength = searchText->Length(); if( (*searchText)[modifiedStrLength-1] == KLitStar ) { //is this a special ligature? if ( modifiedStrLength > 3 && IsSpecialIndicLigature( (*searchText).Mid(modifiedStrLength-4) ) ) { lastChar = (*searchText).Mid(modifiedStrLength-4); } else { lastChar = (*searchText).Mid(modifiedStrLength-2); } } else { //No wildchar here lastChar = (*searchText).Mid(modifiedStrLength-1); } lastChar.UpperCase(); //For latin characters as adaptive grid is always in upper case TInt charPos = result; //aItemString.Mid(index).MatchC( searchText->Des(), &collationMethod ); //if found position is not within the substring to be searched, return EFalse. if( charPos == KErrNotFound) { delete searchText; return EFalse; } TInt tempPos = charPos; TInt startCount = -1 , endCount = -1; //TInt tempIndex(0); //Get the position of the next syllable to be checked IndicSyllableBoundary(startCount, endCount, indicSyllableCount, aItemString.Mid(index)); tempPos = aItemString.Mid(index+startCount).MatchC( lastChar, &collationMethod ); if ( //if found position is not within the next syllable to be searched, //return EFalse. ( tempPos != 0 ) //Also check if character to be searched is a single unicode while //the match is at the start of a special ligature || ( !IsSpecialIndicLigature( lastChar ) && IsSpecialIndicLigature( aItemString.Mid(index+startCount) ) ) ) { delete searchText; return EFalse; } //else, continue - find the next characters to be displayed on the grid tempPos = index + endCount + 1; do { if(charPos!=KErrNotFound && (tempPos) < itemStringLength ) { TRAP_IGNORE( UpdateNextCharsL( aNextChars, aItemString.Mid(tempPos) ) ); } //Is the found next character a consonent/independent-vowel/non-Indic character? if ( IsValidNextChars( *aNextChars ) ) { //found a valid character for displaying on the grid - return from here delete searchText; return ETrue; } else //we found an invalid valid character - keep searching { TPtr ptr = aNextChars->Des(); ptr.Delete(aNextChars->Length()-1,1); //Is this a fallback rendered character? if ( IsFallbackRenderedCharacter(aItemString, tempPos) ) { //Keep the entry but don't show any more characters from this word delete searchText; return ETrue; } } } //keep looping till we find a valid nextChar or we reach the end of the string while(tempPos < itemStringLength ); } } // if( result != KErrNotFound ) } // if (index==0 ..) } // for loop if( result != KErrNotFound ) { delete searchText; return ETrue; } else { delete searchText; return EFalse; } } // if (error == KErrNone) delete searchText; return EFalse; }
int main(int argc, char **argv) { TPtr x; x = test(10); printf("x->get(): %d\n", x->get()); }
Bool TApplication::TApplicationState_Bootup::CreateIntroScreen() { m_SkipBootup = FALSE; TPtr<TLRender::TScreen>& pScreen = TLRender::g_pScreenManager->GetDefaultScreen(); if(!pScreen) { TLDebug_Break("Error: Failed to get screen"); return FALSE; } // create background graphic TLAsset::TMesh* pBgAsset = TLAsset::GetAsset<TLAsset::TMesh>("logo"); if ( pBgAsset ) { TLMessaging::TMessage InitMessage(TLCore::InitialiseRef); InitMessage.ExportData("MeshRef", pBgAsset->GetAssetRef() ); InitMessage.ExportData(TRef_Static(T,r,a,n,s), float3( 0.f, 0.f, -50.f ) ); InitMessage.ExportData("LineWidth", 3.f ); m_LogoRenderNode = TLRender::g_pRendergraph->CreateNode("logo", TRef(), TRef(), &InitMessage ); } else { //TLDebug_Break("Error: Failed to load logo asset"); m_SkipBootup = TRUE; // gr: this will just go into a "no mode" mode. //return FALSE; } // create a render target if we created a render node if ( m_LogoRenderNode.IsValid() ) { TPtr<TLRender::TRenderTarget> pRenderTarget = pScreen->CreateRenderTarget( TRef("Intro") ); if(!pRenderTarget) { TLDebug_Break("Error: Failed to create logo render target"); return FALSE; } m_RenderTarget = pRenderTarget->GetRef(); pRenderTarget->SetClearColour( TColour( 1.f, 1.f, 1.f, 1.f ) ); TPtr<TLRender::TCamera> pCamera = new TLRender::TOrthoCamera; pRenderTarget->SetCamera( pCamera ); pCamera->SetPosition( float3( 0, 0, -10.f ) ); pRenderTarget->SetRootRenderNode( m_LogoRenderNode ); } // Create timeline TPtr<TLAsset::TTimeline> pIntroTimeline = TLAsset::GetAssetPtr<TLAsset::TTimeline>("t_logo"); if ( pIntroTimeline ) { // Create the timeline instance m_pTimelineInstance = new TLAnimation::TTimelineInstance( pIntroTimeline ); // Bind the timeline instance to the render node and init if(m_pTimelineInstance) { TLMessaging::TMessage Message(TLCore::InitialiseRef); Message.ExportData("Time", 0.0f); m_pTimelineInstance->Initialise(Message); } } // All done return TRUE; }
//--------------------------------------------------------------------------- void SetupCoreSubsystem() { if( theCoreSystemCounter.IncRef() ) { mxInitializeBase(); DEVOUT("Initializing Core...\n"); mxName::StaticInitialize(); gCore.currTimeStamp = STimeStamp::GetCurrent(); #if MX_DEVELOPER { ANSICHAR timeStampStr[ MAX_STRING_CHARS ]; gCore.currTimeStamp.ToChars( timeStampStr, NUMBER_OF(timeStampStr) ); DEVOUT("Timestamp: %s\n", timeStampStr ); } { DevBuildOptionsList buildOptions; if( MX_DEBUG ) { buildOptions.Add("MX_DEBUG"); } if( MX_MULTITHREADED ) { buildOptions.Add("MX_MULTITHREADED"); } if( MX_CHECKED ) { buildOptions.Add("MX_CHECKED"); } if( MX_DEVELOPER ) { buildOptions.Add("MX_DEVELOPER"); } if( MX_ENABLE_PROFILING ) { buildOptions.Add("MX_ENABLE_PROFILING"); } if( MX_ENABLE_REFLECTION ) { buildOptions.Add("MX_ENABLE_REFLECTION"); } if( MX_EDITOR ) { buildOptions.Add("MX_EDITOR"); } if( MX_DEMO_BUILD ) { buildOptions.Add("MX_DEMO_BUILD"); } ANSICHAR buildOptionsStr[ MAX_STRING_CHARS ]; buildOptions.ToChars( buildOptionsStr, NUMBER_OF(buildOptionsStr) ); DEVOUT("Core library build settings:\n\t%s\n", buildOptionsStr); } #endif // MX_DEVELOPER Kernel::Initialize(); #if MX_EDITOR AssertX( gCore.editor.IsValid(), "Editor system must be initialized" ); #endif // MX_EDITOR // Initialize Object system. //STATIC_IN_PLACE_CTOR_X( gCore.objectSystem, mxObjectSystem ); #if MX_EDITOR gCore.tweaks.ConstructInPlace(); #endif // MX_EDITOR // Initialize Input/Output system. gCore.ioSystem.ConstructInPlace(); // Open config file. { TPtr<ConfigFile> pConfigFile; pConfigFile.ConstructInPlace(); gCore.config = pConfigFile; pConfigFile->Load( DEFAULT_ENGINE_CONFIG_FILE_NAME ); } // Initialize resource system. gCore.resources.ConstructInPlace(); EntitySystem_Setup(); } }
// --------------------------------------------------------- // CPosTp149::PrintLandmarkFieldsWithDescriptionL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp149::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) { iLog->Log(_L("Parsing Description ... \n")); TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); TLocality loc; TInt err; TPtrC landmarkName; TPtrC landmarkDescription; err = aLandmark.GetLandmarkName(landmarkName); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); TPtr buf = buffer->Des(); buf.Append(_L("\tLandmark Name: ")); buf.Append(landmarkName); iLog->Log(buf); if( aTraceFlag ) { TraceL( buf ); } CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } err = aLandmark.GetPosition(loc); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( 1024 ); TPtr buf = buffer->Des(); TRealFormat format( 12, KRealFormatFixed ); format.iPoint = TChar('.'); format.iTriLen = KDoNotUseTriads; format.iPlaces = 6; TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; sLon.Num( loc.Longitude(), format ); sLat.Num( loc.Latitude(), format ); sAlt.Num( loc.Altitude(), format ); sVacc.Num( loc.VerticalAccuracy(), format ); sHacc.Num( loc.HorizontalAccuracy(), format ); buf.Format( _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), &sLon, &sLat, &sVacc, &sHacc, &sAlt); TReal32 sourceR; err = aLandmark.GetCoverageRadius(sourceR); if (err == KErrNone ) { sRad.Num( sourceR, format ); buf.AppendFormat(_L("srcRadius %S"), &sRad); } iLog->Log(buf); if (aTraceFlag) TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } //Get landmark description err = aLandmark.GetLandmarkDescription(landmarkDescription); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); TPtr buf = buffer->Des(); buf.Format(_L("\tLandmark Description: ")); buf.Append(landmarkDescription); iLog->Log(buf); if ( aTraceFlag ) { TraceL( buf ); } CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } while (sourceFieldId != EPositionFieldNone) { TPtrC sourceValue; aLandmark.GetPositionField(sourceFieldId, sourceValue); HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); TPtr buf = buffer->Des(); buf.Format(_L("\tIdField Id: %d Value:"), sourceFieldId); buf.Append(sourceValue); iLog->Log(buf); if ( aTraceFlag ) { TraceL( buf ); } sourceFieldId = aLandmark.NextPositionFieldId(sourceFieldId); CleanupStack::PopAndDestroy( buffer ); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // TInt CCPRefDTMFProvider::SendDtmfToneString( const TDesC& aString ) { TInt value; if( iProvider.ConfigurationHandler().IsActionConfigured(_L8("MCCPDTMFProvider::SendDtmfToneString"),value ) ) { return value; } RDebug::Print(_L("[TESTPLUGIN] CCPRefDTMFProvider::SendDtmfToneString") ); TLex16 lex( aString ); TBool exit = EFalse; //if pause found, exit function /* Make a copy of the aString to be called iStringNotSent */ TRAPD(err, InitializeStringL(aString)); _LIT(KWaitChar, "w"); //this is the reference to the possible wait character 'w' TBufC<1> waitTone(KWaitChar); //for comparing purposes //TPtrC aCharPtr = lex.NextToken(); //get rest of the tokens if ( err == KErrNone ) { /* loop all the tones and send those until pause or end of the string */ for( TInt i = 0; i < aString.Length() && exit==EFalse; i++ ) { TChar charTone = lex.Get(); //get the token for sending purposes TPtrC toneCharPtr((TText*)&charTone); /* check if tone is waitcharacter 'w' */ if ( waitTone.CompareF(toneCharPtr) != 0 ) //send the tone other than wait tone { RDebug::Print(_L("[TESTPLUGIN] CCPRefDTMFProvider::SendDtmfToneString:Tone sent") ); iObserver->HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfSequenceStart, KErrNone, charTone ); iObserver->HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfSequenceStop, KErrNone, charTone ); } else /* Wait tone found, exit loop*/ { /* Update or the member iString (rip the sent tones) */ TPtr pointer = iStringNotSent->Des(); //Create a pointer to modify pointer.Delete(0, i+1); //Delete the tones from index to the point tones sent plus pause char exit = ETrue; RDebug::Print(_L("[TESTPLUGIN] CCPRefDTMFProvider::SendDtmfToneString:Pause") ); iObserver->HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfStopInDtmfString, KErrNone, NULL ); } } } else //Out of Mem { RDebug::Print(_L("[TESTPLUGIN] CCPRefDTMFProvider::SendDtmfToneString:Out of Mem") ); ClearDtmfString();// Destroys successfully allocated member data } /* check if sending is complete */ if (EFalse == exit) { RDebug::Print(_L("[TESTPLUGIN] CCPRefDTMFProvider::SendDtmfToneString:DONE") ); iObserver->HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfStringSendingCompleted, KErrNone, NULL ); ClearDtmfString(); } return KErrNone; }
TBool CProfileListDialog::OkToExitL(TInt aButtonId) { TBool okToExit = EFalse; CEikTextListBox *lbox = ((CEikTextListBox*)Control(EProfileListDlgProfileList)); // Buffers for current and new file names and a name HBufC *fileNameBuf = HBufC::NewLC(KMaxFileName); TPtr fileName = fileNameBuf->Des(); HBufC *nameBuf = HBufC::NewLC(KMaxFileName); TPtr name = nameBuf->Des(); switch ( aButtonId ) { case ECmdProfileListConnect: { // Connect to the selected profile TInt sel = lbox->CurrentItemIndex(); if ( sel == KDefaultProfileIndex ) { iProfileFile = iDefaultProfileFile; } else { iProfileFile = iProfileDirectory; iProfileFile.Append((*iProfileArray)[sel]); } okToExit = ETrue; break; } case ECmdProfileListEdit: { // Edit the selected profile TInt sel = lbox->CurrentItemIndex(); if ( sel == KDefaultProfileIndex ) { name = KDefaultProfileName; fileName = iDefaultProfileFile; } else { name = (*iProfileArray)[sel]; fileName = iProfileDirectory; fileName.Append(name); } // Edit settings iPutty->ReadConfigFileL(fileName); Config *cfg = iPutty->GetConfig(); CSettingsDialog *dlg = new (ELeave) CSettingsDialog(name, (sel == KDefaultProfileIndex), cfg, iPutty); switch ( dlg->ExecuteLD(R_SETTINGS_DIALOG) ) { case EEikBidOk: // Handle rename first if ( (sel != KDefaultProfileIndex) && (name.Compare((*iProfileArray)[sel]) != 0) ) { MakeNameLegal(name); // Delete current file so that we can rename to a file // that maps to the same name (e.g. changes in case) User::LeaveIfError( CEikonEnv::Static()->FsSession().Delete(fileName)); MakeNameUniqueL(name); fileName = iProfileDirectory; fileName.Append(name); // Update profile list and listbox iProfileArray->Delete(sel); iProfileArray->InsertL(sel, name); lbox->DrawNow(); } // Just write, the name can be an old one or a renamed one iPutty->WriteConfigFileL(fileName); break; case ECmdSettingsDelete: if ( sel != KDefaultProfileIndex ) { // Remove the profile from the list and update // listbox iProfileArray->Delete(sel); lbox->HandleItemRemovalL(); if ( sel >= iProfileArray->Count() ) { sel = iProfileArray->Count() - 1; } lbox->SetCurrentItemIndexAndDraw(sel); // Delete profile file User::LeaveIfError( CEikonEnv::Static()->FsSession().Delete(fileName)); } break; default: break; } okToExit = EFalse; break; } case ECmdProfileListNew: { // New profile -- start with defaults, but with a new name iPutty->ReadConfigFileL(iDefaultProfileFile); Config *cfg = iPutty->GetConfig(); name = KNewProfileName; MakeNameUniqueL(name); CSettingsDialog *dlg = new (ELeave) CSettingsDialog(name, EFalse, cfg, iPutty); if ( dlg->ExecuteLD(R_SETTINGS_DIALOG) == EEikBidOk ) { // Finalize name MakeNameLegal(name); MakeNameUniqueL(name); fileName = iProfileDirectory; fileName.Append(name); // Update the listbox iProfileArray->AppendL(name); lbox->HandleItemAdditionL(); lbox->SetCurrentItemIndexAndDraw(iProfileArray->Count() - 1); // Write out new settings iPutty->WriteConfigFileL(fileName); } okToExit = EFalse; break; } case ECmdProfileListClose: okToExit = ETrue; break; default: User::Invariant(); } CleanupStack::PopAndDestroy(2); //fileNameBuf, nameBuf return okToExit; }
// // StoreL() - Store bookmarks as an attachment file // in the .eBM format. If the system runs out of memory while // the bookmarks are being written to the file, the file will be // deleted. For example, if 2 bookmarks have already been written // to the file, and the writing of the third bookmark fails, the // file will be deleted. Otherwise, a failure of file writing would // need to be handled differently from memory allocation failure. // void CWWWHotlistParser::StoreL(CMsvEntry& aEntry) { TInt numberOfItems = iHotlistItemList->Count(); if (numberOfItems>0) // Only create a file if there is something to save! { // Generate fileName from msgId and bookmark file extension. // The file name consists of the msgId in hex format // followed by .eBM. Sizeof operator returns the size of msgId // in bytes and each byte requires 2 hex digits to represent it, // hence sizeof is multipled by 2. Didn't want to make // fileNameLength constant because the size of TMsvId may change // in the future. TMsvId entryId = aEntry.Entry().Id(); TInt fileNameLength = 2*sizeof(entryId) + KEBookmarkExtension().Length(); HBufC *fileName = HBufC::NewLC(fileNameLength); TPtr fileNameDes = fileName->Des(); // The file name uses the hex representation of the entry Id. // If this changes to some other representation then // fileNameLength will need to be calculated differently. fileNameDes.Num(entryId,EHex); fileNameDes.Append(KEBookmarkExtension); // Get the attachment manager and create an empty attachment file CMsvStore* store = aEntry.EditStoreL(); CleanupStack::PushL(store); MMsvAttachmentManagerSync& managerSync = store->AttachmentManagerExtensionsL(); CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); CleanupStack::PushL(attachment); attachment->SetAttachmentNameL(*fileName); RFile file; managerSync.CreateAttachmentL(*fileName, file, attachment); CleanupStack::Pop(attachment); // ownership passed CleanupClosePushL(file); #ifdef SYMBIAN_BOOKMARK_DATABASE // Open the bookmark database ready to add the bookmarks RBkDatabase bookmarkDb; bookmarkDb.OpenL(); CleanupClosePushL(bookmarkDb); #endif // SYMBIAN_BOOKMARK_DATABASE // Stream each bookmark into the file. // The eBookmark file must contain only 8bit ascii. // Add a linefeed to the end of each line. for(TInt count=0; count < numberOfItems; count++) { CWWWHotlistItem &item = *iHotlistItemList->At(count); // Allocate enough space to hold the full bookmark entry. TInt length = item.Name().Length() + item.Url().Length() + KEBookmarkConstantChars; HBufC8 *writeBuf = HBufC8::NewLC(length); TPtr8 des = writeBuf->Des(); des.Append(KEBookmarkItemBegin); des.Append(KEBookmarkItemURL); des.Append(item.Url()); des.Append(KCRLinefeed); des.Append(KEBookmarkItemName); des.Append(item.Name()); des.Append(KCRLinefeed); des.Append(KEBookmarkType); des.Append(KEBookmarkItemEnd); User::LeaveIfError(file.Write(des)); CleanupStack::PopAndDestroy(); #ifdef SYMBIAN_BOOKMARK_DATABASE // Add the bookmark to the bookmark database RBkBookmark bookmark = bookmarkDb.CreateBookmarkL(); CleanupClosePushL(bookmark); bookmark.SetTitleL(item.Name()); // Convert Uri to 8-bit HBufC8* bookmarkUri = HBufC8::NewLC(item.Url().Length()); bookmarkUri->Des().Copy(item.Url()); bookmark.SetUriL(*bookmarkUri); CleanupStack::PopAndDestroy(2, &bookmark); // bookmarkUri, bookmark #endif // SYMBIAN_BOOKMARK_DATABASE } #ifdef SYMBIAN_BOOKMARK_DATABASE // Commit all the added bookmarks and close bookmark db bookmarkDb.CommitL(); CleanupStack::PopAndDestroy(&bookmarkDb); #endif // SYMBIAN_BOOKMARK_DATABASE // File writing has completed, set the size in the attachment TInt fileSize = 0; User::LeaveIfError(file.Size(fileSize)); attachment->SetSize(fileSize); // commit the changes store->CommitL(); CleanupStack::PopAndDestroy(3, fileName); // file, store, fileName } }
/** Protected constructor. Extracts the initialisation data provided by the calling functions: ConstructSourceL() and ConstructSinkL(). Creates a file server session and sets up file name. If there is a file name and it cannot be found this function leaves. If there is no file name the function leaves. Does not attempt to open the file or check whether the file exists. If aInitData contains a TMMFFileHandleParams instead of TMMFFileParams, the source/sink is constructed from the file handle provided by the caller @param aInitData Initialisation data packaged in a TMMFFileParams or in a TMMFFileHandleParams (File Handle) */ void CMMFFile::ConstructL(const TDesC8& aInitData,TMMFileMode aFileMode) { User::LeaveIfError(iFsSession.Connect()); #ifdef __IPC_V2_PRESENT__ // on IPCv2 we auto attach User::LeaveIfError(iFsSession.ShareAuto()); #else // on IPCv1 we use explicit - more efficient User::LeaveIfError(iFsSession.Share(RSessionBase::EExplicitAttach)); #endif User::LeaveIfError(iFsSession.ShareProtected()); HBufC* filename = NULL; iCAFParameters = new (ELeave) CCAFParameters; TBool drmContent = EFalse; RDesReadStream stream(aInitData); CleanupClosePushL(stream); TUid initUid = TUid::Uid(stream.ReadInt32L()); if (initUid == KMMFileHandleSourceUid) { TPckgBuf<RFile*> fileptr; stream.ReadL(fileptr); iHandle.Duplicate(*fileptr()); TInt length = stream.ReadInt32L(); if (length>0) { iCAFParameters->iUniqueId = HBufC::NewL(length); TPtr16 ptr = iCAFParameters->iUniqueId->Des(); stream.ReadL(ptr, length); } iFileHandle = ETrue; filename = HBufC::NewMaxLC(KMaxFileName); TPtr ptr = filename->Des(); User::LeaveIfError(iHandle.FullName(ptr)); drmContent = ETrue; iCAFParameters->iEnableUI = stream.ReadInt32L(); } else if (initUid == KMMFileSourceUid) { TInt length = stream.ReadInt32L(); filename = HBufC::NewMaxLC(length); TPtr ptr = filename->Des(); stream.ReadL(ptr, length); length = stream.ReadInt32L(); if (length>0) { iCAFParameters->iUniqueId = HBufC::NewMaxL(length); ptr.Set(iCAFParameters->iUniqueId->Des()); stream.ReadL(ptr, length); } drmContent = ETrue; iCAFParameters->iEnableUI = stream.ReadInt32L(); } else { // XXX If the UID is unknown we should reject, but currently // code also used for older calls that just supply filename. // User::Leave(KErrNotSupported); } if ((filename == NULL) && aInitData.Length() == sizeof(TMMFFileHandleParams)) { TMMFFileHandleParams params; TPckgC<TMMFFileHandleParams> config(params); config.Set(aInitData); params = config(); if (params.iUid == KFileHandleUid) { User::LeaveIfError(iHandle.Duplicate(*params.iFile)); TInt pos = 0; // make sure the duplicate handle is at the start of the file - the usage of the file handle really requires this User::LeaveIfError(iHandle.Seek(ESeekStart, pos)); iFileHandle = ETrue; ASSERT(filename == NULL); filename = HBufC::NewMaxLC(KMaxFileName); TPtr ptr = filename->Des(); User::LeaveIfError(iHandle.FullName(ptr)); } } if (filename == NULL) // do old case as last resort { TMMFFileParams params; TPckgC<TMMFFileParams> config(params); config.Set(aInitData); params = config(); filename = params.iPath.AllocLC(); } ASSERT(filename != NULL); TParse parser ; User::LeaveIfError(parser.Set(*filename, NULL, NULL)); CleanupStack::PopAndDestroy(2, &stream); //filename, stream if ( !( parser.NamePresent() ) && !( parser.ExtPresent() ) ) { User::Leave( KErrBadName ) ; } iFullFileName.Copy( parser.FullName() ) ; iFileName = parser.Name().AllocL() ; iFileExt = parser.Ext().AllocL() ; iFilePath = parser.Path().AllocL() ; iFileDrive = parser.Drive().AllocL() ; // in order to simulate old behaviour we are not passing error out // but will try to create Content again during PrimeL() if (drmContent && aFileMode==ESourceMode) { TInt contentError; if (iFileHandle) { TRAP(contentError, iFile = CContentFile::NewL(iHandle, UniqueId(), iCAFParameters->iEnableUI); ); }
void CWsTop::InitStaticsL() { iShuttingDown=EFalse; // By default shell should be started. TBool startShell = ETrue; iCurrentFocusScreen = 0; // The windows server has been invoked. // This may have been from the system starter (via a // start up rss file) // This block looks for a "-NoShell" argument in the invocation. // The existence of the argument means that shell does not need to be // invoked from here because the new system starter // is in charge, and it will do it if required. _LIT(KNoShell,"-NOSHELL"); TInt argLen = User::CommandLineLength(); if(argLen) { HBufC* arg = HBufC::NewLC(argLen); TPtr argPtr = arg->Des(); User::CommandLine(argPtr); argPtr.UpperCase(); if(KErrNotFound != argPtr.Find(KNoShell)) { // Don't start the shell. It will be started if required by // the system starter. startShell = EFalse; } CleanupStack::PopAndDestroy(arg); } TheActiveScheduler=new(ELeave) CWsActiveScheduler; CActiveScheduler::Install(TheActiveScheduler); // WsIniFile is already created (before E32Main's Loop) _LIT(KWSERVIniFileVarLogEnable,"LOGENABLE"); TInt loggingLevel; if (WsIniFile->FindVar(KWSERVIniFileVarLogEnable,loggingLevel)) { EnableLogging(EDoNotReloadWsIni); if (wsDebugLog) { wsDebugLog->SetLoggingLevel(loggingLevel); } } _LIT(KWSERVIniFileVarFadeEnable,"FADEDISABLE"); iFadeEnabled = !WsIniFile->FindVar(KWSERVIniFileVarFadeEnable); _LIT(KWSERVIniFileVarFinishEveryFlush,"FINISHEVERYFLUSH"); iFinishEveryFlush = WsIniFile->FindVar(KWSERVIniFileVarFinishEveryFlush); _LIT(KWSERVIniFileVarSwitchOffEvent,"IGNORESWITCHOFFEVENT"); iIgnoreSwitchOffEvent = WsIniFile->FindVar(KWSERVIniFileVarSwitchOffEvent); iPluginManager = CWsPluginManager::NewL(); // need to be constructed before iServer! iServer=CWindowServer::NewL(); CClick::InitStaticsL(); RProcess wservProc; if (!wservProc.DefaultDataPaged()) { iServer->SetPinClientDescriptors(ETrue); } User::LeaveIfError(FbsStartup()); User::LeaveIfError(RFbsSession::Connect()); User::LeaveIfError(iTimer.CreateLocal()); TWindowServerEvent::InitStaticsL(); CWsClient::InitStaticsL(); //------------------------------------------- User::LeaveIfError( HAL::Get( HAL::EDisplayNumberOfScreens, iNumberOfScreens ) ) ; // Check that the INI file matches the HAL WS_ASSERT_ALWAYS(WsIniFile->NumberOfScreens()<=iNumberOfScreens, EWsPanicScreenInformationError); iScreens = new (ELeave) CArrayPtrFlat<CScreen>( iNumberOfScreens ) ; // // now construct screens for as long as there is information TInt ii ; for ( ii = 0 ; ii < iNumberOfScreens ; ++ii ) { InitScreenL( ii ) ; } //--------------------------------------------- iCurrentFocusScreen = (*iScreens)[0] ; iServer->StartL(); CWsFontCache::CreateInstanceL(); CWsGc::InitStaticsL(); CPlaybackGc::InitStaticsL(); CWsSpriteBase::InitStaticsL(); CEventQueue::InitStaticsL(); // CWsAnimDll::InitStaticsL(); // TInt bootMode=0; _LIT(KWSERVIniFileVarReboot,"REBOOT"); WsIniFile->FindVar(KWSERVIniFileVarReboot,bootMode); if (bootMode>=0 && bootMode<=2) iShellBootMode=bootMode; // CWsBackedUpWindow::StaticInitL(); CWsRedrawMsgWindow::StaticInitL(); // TWsPointer::InitStaticsL(); iShellStarter=new (ELeave) CShellStarter; iShellStarter->ConstructL(); _LIT(KPreProcess,"REMOVEFADINGONFOCUSGAIN"); CWsWindowGroup::SetFocusGainPreprocessing(WsIniFile->FindVar(KPreProcess)); _LIT(KAbsFade,"ABSOLUTEFADING"); CWsClientWindow::SetAbsoluteFading(WsIniFile->FindVar(KAbsFade)); //Set the focus policy _LIT(KFocusPolicy,"MULTIFOCUSPOLICY"); if(WsIniFile->FindVar(KFocusPolicy)) { iMultiFocusPolicy = ETrue; } RProcess::Rendezvous(KErrNone); // Start the shell from here unless the 'NoShell' option has been // received indicating that the system starter will start the shell directly. if(startShell) { StartShell(); } UserSvr::WsRegisterSwitchOnScreenHandling(ETrue); iRenderOrientationTracker = CWsRenderOrienationTracker::NewL(); }
void CTestCImPlainTextStore::TestStoreRestore16BitChunkAsyncL() { CreateNewPlaintextMessageL(); CMsvEntry* entry = testUtils->iMsvSession->GetEntryL(newMessageId); CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*entry); iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForWriteL(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf1->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); TInt bodyTextSize = iFilebuf1->Length(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf2->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); bodyTextSize += iFilebuf2->Length(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf3->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); bodyTextSize += iFilebuf3->Length(); iCImPlainBodyTextStore->CommitL(iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); delete iCImPlainBodyTextStore; iCImPlainBodyTextStore = NULL; //Restore the data in chunks. HBufC16* filebuf11 = HBufC16::NewL(100+KTestStringLength); TInt origSize = bodyTextSize; TInt sizeOfRestoredText = 0; TPtr bufPtr = filebuf11->Des(); TInt pos = 0; iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForReadL(CImEmailMessage::EThisMessageOnly,100); iCImPlainBodyTextStore->NextChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); RArray<TPtr> chunkArray; chunkArray.Append(bufPtr); sizeOfRestoredText += bufPtr.Length(); while(bufPtr.Length() > 0 && bufPtr.Length() == 100) { iCImPlainBodyTextStore->NextChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); // put retrived buffer in a array. chunkArray.Append(bufPtr); sizeOfRestoredText += bufPtr.Length(); } ASSERT_EQUALS(bodyTextSize, sizeOfRestoredText); for(TInt j=chunkArray.Count() - 1;j >0; --j ) { bufPtr.SetLength(0); iCImPlainBodyTextStore->PreviousChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); // Compare chunk retrieved with chunk retrieved by NextChunkL TInt comp = bufPtr.Compare(chunkArray[j-1]); ASSERT_EQUALS(comp, 0); } CleanupStack::PopAndDestroy(imEmailMessage); }
TInt COpenMAXALTestModule::al_metadataextractionitf_GetKey( CStifItemParser& aItem ) { iLog->Log( _L("al_metadataextractionitf_GetKey >>") ); TInt status(KErrNotFound); XAresult res; XAMetadataInfo *key = NULL; if(m_MetadataExtractionItf) { TPtrC keyToFind; if(aItem.GetNextString(keyToFind) == KErrNone) { HBufC *pB = HBufC16::NewL(keyToFind.Size()); TPtr tP = pB->Des(); tP.Copy(keyToFind); iLog->Log( _L("Expected Key: %S"), pB); delete pB; XAuint32 numItems = 0; res = (*m_MetadataExtractionItf)->GetItemCount(m_MetadataExtractionItf, &numItems); for(int i = 0; (i < numItems) && (MapErr(res) == KErrNone) && (status == KErrNotFound); i++) { XAuint32 keySize = 0; res = (*m_MetadataExtractionItf)->GetKeySize( m_MetadataExtractionItf, i, &keySize); if(MapErr(res) == KErrNone) { key = (XAMetadataInfo *)calloc(keySize,1); if(key) { res = (*m_MetadataExtractionItf)->GetKey( m_MetadataExtractionItf, i , keySize, key); status = MapErr(res); if(status==KErrNone) { HBufC* temp = NULL; if(key->encoding == XA_CHARACTERENCODING_ASCII) { TPtrC8 des((TUint8*)(key->data), key->size-1 ); temp = HBufC16::NewL(key->size-1); TPtr tempPtr = temp->Des(); tempPtr.Copy(des); iLog->Log( _L("Key[%d]: %S"), i, temp); } else if(key->encoding == XA_CHARACTERENCODING_UTF16LE) { TPtrC des((const TUint16*)key->data, key->size/2 - 1); temp = HBufC16::NewL(key->size/2 - 1); TPtr tempPtr = temp->Des(); tempPtr.Copy(des); iLog->Log( _L("Key[%d]: %S"), i, temp); } if(temp && !keyToFind.Compare(temp->Des())) { status = KErrNone; } else { status = KErrNotFound; } if(temp) { delete temp; } }//end if(status==KErrNone) free(key); }//end if(key) }//end if(MapErr(res) == KErrNone) }//end for }//end if(aItem.GetNextString(index) == KErrNone) }//end if(m_MetadataExtractionItf) iLog->Log( _L("al_metadataextractionitf_GetKey (%d)<<"), status ); return status; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) { switch ( aCommand ) { case EAknSoftkeyExit: case EEikCmdExit: Exit(); break; case ECmdSwitchOutput: { HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; bufferPtr.Append(_L("Output switched to ")); iFileOutputOn = !iFileOutputOn; if (iFileOutputOn) bufferPtr.Append(_L("file.")); else bufferPtr.Append(_L("screen.")); ShowL( *buffer, last ); CleanupStack::PopAndDestroy( buffer ); } break; case ECmdStatus: { ClearL(); // layout HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; // Orientation bufferPtr.Append(_L("Orientation: ")); bufferPtr.AppendNum((TInt)iAvkonAppUi->Orientation()); ShowL( *buffer, last ); bufferPtr.Zero(); // Output bufferPtr.Append(_L("Output: ")); if (iFileOutputOn) bufferPtr.Append(_L("File")); else bufferPtr.Append(_L("Screen")); ShowL( *buffer, last ); bufferPtr.Zero(); CAknLayoutConfig::TScreenMode localAppScreenMode = CAknSgcClient::ScreenMode(); TInt hashValue = localAppScreenMode.ScreenStyleHash(); TPixelsTwipsAndRotation pixels = CAknSgcClient::PixelsAndRotation(); TSize pixelSize = pixels.iPixelSize; bufferPtr.Append(_L("LayoutName: ")); if ( (pixelSize.iWidth == 320 || pixelSize.iWidth == 240 )&& (pixelSize.iHeight == 320 || pixelSize.iHeight == 240 )) { if (hashValue==0x996F7AA7) bufferPtr.Append(_L("QVGA2")); else bufferPtr.Append(_L("QVGA1")); } else if ((pixelSize.iWidth == 640 || pixelSize.iWidth == 360 )&& (pixelSize.iHeight == 360 || pixelSize.iHeight == 640 )) { bufferPtr.Append(_L("nHD")); } else if ((pixelSize.iWidth == 640 || pixelSize.iWidth == 480 )&& (pixelSize.iHeight == 480 || pixelSize.iHeight == 640 )) { bufferPtr.Append(_L("VGA")); } else if ((pixelSize.iWidth == 352 || pixelSize.iWidth == 800 )&& (pixelSize.iHeight == 800 || pixelSize.iHeight == 352 )) { bufferPtr.Append(_L("E90")); } else if ((pixelSize.iWidth == 320 || pixelSize.iWidth == 480 || pixelSize.iWidth == 240 || pixelSize.iWidth == 640 )&& (pixelSize.iHeight == 320 || pixelSize.iHeight == 480 || pixelSize.iHeight == 240 || pixelSize.iHeight == 640)) { bufferPtr.Append(_L("HVGA")); } else if ((pixelSize.iWidth == 480 || pixelSize.iWidth == 854 || pixelSize.iWidth == 848 || pixelSize.iWidth == 800 )&& (pixelSize.iHeight == 800 || pixelSize.iHeight == 480 || pixelSize.iHeight == 848 || pixelSize.iHeight == 854)) { bufferPtr.Append(_L("WVGA")); } else { bufferPtr.Append(_L("Unknown")); } ShowL( *buffer, last ); bufferPtr.Zero(); CleanupStack::PopAndDestroy( buffer ); } break; case ECmdSwitchOrientation: { ClearL(); HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; #ifndef __SERIES60_31__ if (!iAvkonAppUi->OrientationCanBeChanged()) { bufferPtr.Append(_L("Orientation cannot be changed.")); ShowL( *buffer, last ); bufferPtr.Zero(); CleanupStack::PopAndDestroy( buffer ); break; } #endif //__SERIES60_31__ if ( iAvkonAppUi->Orientation() == CAknAppUiBase::EAppUiOrientationPortrait) { iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape); } else if (iAvkonAppUi->Orientation() == CAknAppUiBase::EAppUiOrientationLandscape) { iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationPortrait); } else { // unspecified iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape); } bufferPtr.Append(_L("Orientation changed.")); ShowL( *buffer, last ); bufferPtr.Zero(); CleanupStack::PopAndDestroy( buffer ); break; } case ECmdStartCalculations: { ClearL(); // Get known values TInt index = 0; TBool last = EFalse; if (iFileOutputOn) { TRect screenRect; AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, screenRect ); // Add screen dimensions TInt height = screenRect.Height(); TInt width = screenRect.Width(); TBuf16<32> tgt; // HEIGHT tgt.Append(_L("height: \t")); tgt.AppendNum(height, EDecimal); // put max height into text file ShowL( tgt, last ); tgt.Zero(); // WIDTH tgt.Append(_L("width: \t")); tgt.AppendNum(width, EDecimal); // put max width into text file ShowL( tgt, last ); tgt.Zero(); // VERSION TPixelMetricsVersion version = PixelMetrics::Version(); tgt.Append(_L("major_version: \t")); tgt.AppendNum(version.majorVersion, EDecimal); // put major version into text file ShowL( tgt, last ); tgt.Zero(); tgt.Append(_L("minor_version: \t")); tgt.AppendNum(version.minorVersion, EDecimal); // put minor version into text file ShowL( tgt, last ); tgt.Zero(); } TInt myValue = KErrNotFound; for (;;) { if (index==QStyle::PM_Custom_MessageBoxHeight) { last = ETrue; } myValue = PixelMetrics::PixelMetricValue(static_cast<QStyle::PixelMetric>(index)); ShowSingleValueL( index, myValue, last ); if (last) break; // if last before custom values, "jump" to custom base if (index==QStyle::PM_SubMenuOverlap) index = QStyle::PM_CustomBase; index++; } } break; case ECmdCreateHeaderFile: CreateHeaderFileL(); break; default: break; } }
TInt COpenMAXALTestModule::al_metadataextractionitf_GetValue( CStifItemParser& aItem ) { iLog->Log( _L("al_metadataextractionitf_GetValue >>") ); TInt status(KErrNotFound); XAresult res; XAMetadataInfo *key = NULL; if(m_MetadataExtractionItf) { TInt index; //Find Key Index TPtrC keyToFind; if(aItem.GetNextString(keyToFind) == KErrNone) { HBufC *pB = HBufC16::NewL(keyToFind.Size()); TPtr tP = pB->Des(); tP.Copy(keyToFind); iLog->Log( _L("Expected Key: %S"), pB); delete pB; XAuint32 numItems = 0; res = (*m_MetadataExtractionItf)->GetItemCount(m_MetadataExtractionItf, &numItems); for(index = 0; (index < numItems) && (MapErr(res) == KErrNone) && (status == KErrNotFound); index++) { XAuint32 keySize = 0; res = (*m_MetadataExtractionItf)->GetKeySize( m_MetadataExtractionItf, index, &keySize); if(MapErr(res) == KErrNone) { key = (XAMetadataInfo *)calloc(keySize,1); if(key) { res = (*m_MetadataExtractionItf)->GetKey( m_MetadataExtractionItf, index , keySize, key); status = MapErr(res); if(status==KErrNone) { HBufC* temp = NULL; TDesC16* pdesc = NULL; if(key->encoding == XA_CHARACTERENCODING_ASCII) { TPtrC8 des((TUint8*)(key->data), key->size - 1 ); temp = HBufC16::NewL(key->size - 1); TPtr tempPtr = temp->Des(); tempPtr.Copy(des); iLog->Log( _L("Key[%d]: %S"), index, temp); pdesc = &tempPtr; } else if(key->encoding == XA_CHARACTERENCODING_UTF16LE) { TPtrC des((const TUint16*)key->data, key->size/2 - 1); temp = HBufC16::NewL(key->size/2 - 1); TPtr tempPtr = temp->Des(); tempPtr.Copy(des); iLog->Log( _L("Key[%d]: %S"), index, temp); pdesc = &tempPtr; } if(!keyToFind.Compare(*pdesc)) { status = KErrNone; } else { status = KErrNotFound; } if(temp) { delete temp; } }//end if(status==KErrNone) free(key); }//end if(key) }//end if(MapErr(res) == KErrNone) }//end for }//end if(aItem.GetNextString(index) == KErrNone) if((status == KErrNone) && (--index >= 0)) { XAMetadataInfo *value = NULL; XAuint32 valueSize; res = (*m_MetadataExtractionItf)->GetValueSize( m_MetadataExtractionItf, index, &valueSize); if(MapErr(res) == KErrNone) { value = (XAMetadataInfo *)calloc(valueSize,1); if(value) { res = (*m_MetadataExtractionItf)->GetValue( m_MetadataExtractionItf, index, valueSize, value); status = MapErr(res); HBufC* temp = NULL; if(status == KErrNone) { if(value->encoding == XA_CHARACTERENCODING_ASCII) { TPtrC8 des((TUint8*)(value->data), value->size - 1 ); temp = HBufC16::NewL(value->size - 1); TPtr tempPtr = temp->Des(); tempPtr.Copy(des); iLog->Log( _L("Value[%d]: %S"), index, temp); } else if(value->encoding == XA_CHARACTERENCODING_UTF16LE) { TPtrC des((const TUint16*)value->data, value->size/2 - 1); temp = HBufC16::NewL(value->size/2 - 1); TPtr tempPtr = temp->Des(); tempPtr.Copy(des); iLog->Log( _L("Value[%d]: %S"), index, temp); } else { iLog->Log( _L("Value[%d]: <Binary Value>"), index); } if(value->encoding != XA_CHARACTERENCODING_BINARY) { TPtrC expectedValue; if(aItem.GetNextString(expectedValue) == KErrNone) { HBufC *pB = HBufC16::NewL(expectedValue.Size()); TPtr tP = pB->Des(); tP.Copy(expectedValue); iLog->Log( _L("Expected Value: %S"), pB); iLog->Log(_L("Size: Expected(%d), Actual(%d)"),expectedValue.Size(), temp->Des().Size()); delete pB; if(temp && !expectedValue.Compare(temp->Des())) { status = KErrNone; } else { status = KErrNotFound; } } } if(temp) { delete temp; } }//end if(status == KErrNone) delete value; }//end if(value) }//end if(MapErr(res) == KErrNone) }//end if(status == KErrNone) }//end if(m_MetadataExtractionItf) iLog->Log( _L("al_metadataextractionitf_GetValue (%d)<<"), status ); return status; }
TBool CheckAttribute (CConsoleBase* iConsole, ConfigPtrsPtr cpPtr,TInt aKeyIndex, TPtrC aDes) { TBool retValue = ETrue; TBuf<50> attrib = aDes; TInt typePos; TInt dirPos; TInt typeLen; TInt dirLen; TUint epType = 0; TUint epDir = 0; TUint ifNumber = 0; _LIT (KQuote,"\""); switch (aKeyIndex) { // level 0 index LDD case ExiLdd : if (attrib.Find(KAttributeName) == 0) { attrib.Delete(0,((TDesC&)KAttributeName).Length()); if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0]) { TUSB_VERBOSE_PRINT1 ("LDD with attribute name %s",attrib.PtrZ()); if(gVerbose) { OstTraceExt1 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP17, "LDD with attribute name %s",attrib); } cpPtr->iThisLDDPtr = new LDDConfig (attrib.MidTPtr(1,attrib.Length()-2)); *cpPtr->iNextLDDPtrPtr = cpPtr->iThisLDDPtr; cpPtr->iNextLDDPtrPtr = &(cpPtr->iThisLDDPtr->iPtrNext); cpPtr->iNextIFPtrPtr = &(cpPtr->iThisLDDPtr->iIFPtr); } else retValue = EFalse; } else { retValue = EFalse; } break; // level 1 index INTERFACE case ExiInterface : if (attrib.Find(KAttributeNumber) == 0) { attrib.Delete(0,((TDesC&)KAttributeNumber).Length()); if (attrib[0] == ((TDesC&)KQuote)[0] && attrib[attrib.Length()-1] == ((TDesC&)KQuote)[0]) { if (TDesToTUint(attrib.MidTPtr(1,attrib.Length()-2), &ifNumber)) { if (cpPtr->iThisLDDPtr == NULL) { TUSB_PRINT ("No LDD container for interface"); OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP18, "No LDD container for interface"); retValue = EFalse; } } else { TUSB_PRINT2 ("Number conversion error %s %d",attrib.PtrZ(),ifNumber); OstTraceExt2 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP19, "Number conversion error %S %u",attrib,ifNumber); retValue = EFalse; } } else { TUSB_PRINT1 ("Attribute number not in \"\" %s",attrib.PtrZ()); OstTraceExt1 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP20, "Attribute number not in \"\" %s",attrib); retValue = EFalse; } } if (retValue) { TUSB_VERBOSE_PRINT1 ("Interface number %d",ifNumber); if(gVerbose) { OstTrace1 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP21, "Interface number %d",ifNumber); } cpPtr->iThisIFPtr = new IFConfig ((TUint8)ifNumber); * cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr; cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext; cpPtr->iThisLDDPtr->iNumChannels++; } break; // level 1 index Setting case ExiSetting : if (aDes.Length() != 0) { retValue = EFalse; } else { if (cpPtr->iThisLDDPtr == NULL) { TUSB_PRINT ("No LDD container for interface"); OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP22, "No LDD container for interface"); retValue = EFalse; } else { TUSB_VERBOSE_PRINT ("Alternate Interface Setting"); if(gVerbose) { OstTrace0 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP23, "Alternate Interface Setting"); } cpPtr->iThisIFPtr = new IFConfig (0); * cpPtr->iNextIFPtrPtr = cpPtr->iThisIFPtr; cpPtr->iNextIFPtrPtr = &cpPtr->iThisIFPtr->iPtrNext; cpPtr->iThisIFPtr->iAlternateSetting = ETrue; } } break; // level 2 index ENDPOINT case ExiEndpoint : typePos = attrib.Find(KAttributeType); dirPos = attrib.Find(KAttributeDirection); if (typePos == KErrNotFound || dirPos == KErrNotFound) { retValue = EFalse; } else { if (typePos < dirPos) { typePos += ((TDesC&)KAttributeType).Length(); typeLen = dirPos - typePos; dirPos += ((TDesC&)KAttributeDirection).Length(); dirLen = attrib.Length() - dirPos; } else { dirPos += ((TDesC&)KAttributeDirection).Length(); dirLen = typePos - dirPos; typePos += ((TDesC&)KAttributeType).Length(); typeLen = attrib.Length() - typePos; } TPtr attribPtr = attrib.MidTPtr(typePos,typeLen); attribPtr.UpperCase(); attribPtr.TrimAll(); if (attribPtr == KEpBulk) { epType = KUsbEpTypeBulk; } else { if (attribPtr == KEpInterrupt) { epType = KUsbEpTypeInterrupt; } else { if (attribPtr == KEpIsochronous) { epType = KUsbEpTypeIsochronous; } else { retValue = EFalse; } } } attribPtr = attrib.MidTPtr(dirPos,dirLen); attribPtr.UpperCase(); attribPtr.TrimAll(); if (attribPtr == KEpIn) { epDir = KUsbEpDirIn; } else { if (attribPtr == KEpOut) { epDir = KUsbEpDirOut; } else { retValue = EFalse; } } if (retValue) { if (cpPtr->iThisIFPtr == NULL) { TUSB_PRINT ("No Interface container for Endpoint"); OstTrace0 (TRACE_NORMAL, CONFIGPTRS_CONFIGPTRS_DUP24, "No Interface container for Endpoint"); retValue = EFalse; } else { TUint epIndex = cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed; TUSB_VERBOSE_PRINT2 ("Endpoint with type %d %d",epType,epDir); if(gVerbose) { OstTraceExt2 (TRACE_VERBOSE, CONFIGPTRS_CONFIGPTRS_DUP25, "Endpoint with type %u %u",(TUint32)epType,(TUint32)epDir); } cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iType = epType; cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iDir = epDir; #ifdef USB_SC cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iBufferSize = 65536; cpPtr->iThisIFPtr->iInfoPtr->iEndpointData[epIndex].iReadSize = 4096; #endif cpPtr->iThisIFPtr->iEpDMA[epIndex] = EFalse; cpPtr->iThisIFPtr->iEpDoubleBuff[epIndex] = EFalse; cpPtr->iThisIFPtr->iInfoPtr->iTotalEndpointsUsed++; } } } break; default : if (aDes.Length() != 0) { retValue = EFalse; } } return retValue; }
Bool TLCollada::TGeometry::Import(TXmlTag& Tag,TPtrArray<TLCollada::TMaterial>& Materials) { // import names m_pGeometryName = Tag.GetProperty("name"); // optional // require ID const TString* pGeometryID = Tag.GetProperty("id"); if ( !pGeometryID ) { TLDebug_Break("<geometry> missing ID"); return FALSE; } // copy ID and prefix with # to make it easier to match m_GeometryID = "#"; m_GeometryID.Append( *pGeometryID ); // get the "mesh" child TXmlTag* pMeshTag = Tag.GetChild("mesh"); if ( !pMeshTag ) { TLDebug_Break("<mesh> tag expected"); return FALSE; } // import the geometry data first TLDebug_Print("Collada: Importing geometry source data..."); TPtrArray<TXmlTag> DataTags; pMeshTag->GetChildren("source", DataTags ); pMeshTag->GetChildren("vertices", DataTags ); for ( u32 i=0; i<DataTags.GetSize(); i++ ) { TXmlTag* pDataTag = DataTags[i]; TPtr<TGeometryData> pGeometryData = new TGeometryData(); if ( !pGeometryData->Import( *pDataTag ) ) { TLDebug_Break("failed to import geometry data"); return FALSE; } // add to list m_GeometryData.Add( pGeometryData ); } // create a mesh to import the geometry into m_pMesh = new TLAsset::TMesh( TRef(*m_pGeometryName) ); // import triangles into the mesh TLDebug_Print("Collada: Importing geometry triangles..."); TPtrArray<TXmlTag> TriangleTags; pMeshTag->GetChildren("triangles", TriangleTags ); for ( u32 t=0; t<TriangleTags.GetSize(); t++ ) { TXmlTag* pTriangleTag = TriangleTags[t]; // get material const TString* pMaterialID = pTriangleTag->GetProperty("Material"); TPtr<TLCollada::TMaterial>* ppMaterial = pMaterialID ? Materials.Find( *pMaterialID ) : NULL; TLCollada::TMaterial* pMaterial = ppMaterial ? (*ppMaterial).GetObjectPointer() : NULL; // get all the different mappings of triangle data -> vertex data u32 TriangleDataStep = 1; // step is the biggest offset from the inputs, + 1 // gr: store relavant inputs - dont need all of them (maybe for future expansion) TPtr<TLCollada::TriangleInput> pPositionInput; //TPtr<TLCollada::TriangleInput> pNormalInput; TPtr<TLCollada::TriangleInput> pTexCoordInput; TLDebug_Print("Collada: Importing geometry triangle inputs..."); TPtrArray<TXmlTag> InputTags; pTriangleTag->GetChildren("input",InputTags); for ( u32 i=0; i<InputTags.GetSize(); i++ ) { TPtr<TLCollada::TriangleInput> pInput = new TLCollada::TriangleInput(); if ( !pInput->Import( *InputTags[i], m_GeometryData ) ) { TLDebug_Break("failed to import <triangles> input tag"); return FALSE; } // gr: make sure we take ALL offsets into account to get the correct stride of the triangle data if ( pInput->m_Offset+1 > TriangleDataStep ) TriangleDataStep = pInput->m_Offset+1; // store input if ( pInput->m_Semantic == "Vertex" ) pPositionInput = pInput; //else if ( pInput->m_Semantic == "Normal" ) // pNormalInput = pInput; else if ( pInput->m_Semantic == "TexCoord" ) pTexCoordInput = pInput; // else unwanted input } // pull out triangle data TXmlTag* pDataTag = pTriangleTag->GetChild("p"); if ( !pDataTag ) { TLDebug_Break("<triangles> tag is missing data tag <p>"); return FALSE; } // get vertex's colour TColour* pVertexColour = pMaterial ? &pMaterial->m_Colour : NULL; TLDebug_Print("Collada: Importing geometry triangle's triangles..."); u32 DataIndex = 0; // which bit of data are we on (ie. index in the array) u32 TriangleComponentIndex = 0; // which of the 3 parts of the triangle are we on // keep reading through all the data and get each index of data s32 InputIndex = -1; u32 CharIndex = 0; TLCollada::VertexMap CurrentTriangleVertexMap; TLAsset::TMesh::Triangle CurrentTriangle; while ( TLString::ReadNextInteger( pDataTag->GetDataString(), CharIndex, InputIndex ) ) { u32 Offset = DataIndex % TriangleDataStep; DataIndex++; // set the vertex index for each kind of input at this offset if ( pPositionInput && pPositionInput->m_Offset == Offset ) CurrentTriangleVertexMap.m_Position = InputIndex; if ( pTexCoordInput && pTexCoordInput->m_Offset == Offset ) CurrentTriangleVertexMap.m_TexCoord = InputIndex; // more components to read of the current vertex map if ( Offset != TriangleDataStep-1 ) continue; // all parts of the vertex map have been read, get vertex // see if the vertex map configuration already exists (which means vertex has already been created) TLCollada::VertexMap* pExistingVertexMap = m_VertexMap.Find( CurrentTriangleVertexMap ); // doesnt already exist, create vertex and entry if ( !pExistingVertexMap ) { // get vertex's data const float3* pPosition = pPositionInput ? pPositionInput->m_pData->GetData<float3>( CurrentTriangleVertexMap.m_Position ) : NULL; const float2* pTexCoord = pTexCoordInput ? pTexCoordInput->m_pData->GetData<float2>( CurrentTriangleVertexMap.m_TexCoord ) : NULL; if ( !pPosition ) { TLDebug_Break("Missing vertex position"); return FALSE; } // create vertex CurrentTriangleVertexMap.m_VertexIndex = m_pMesh->AddVertex( *pPosition, pVertexColour, pTexCoord ); // add to list s32 MapIndex = m_VertexMap.Add( CurrentTriangleVertexMap ); pExistingVertexMap = &m_VertexMap[MapIndex]; } // add to triangle's data if ( pExistingVertexMap->m_VertexIndex == -1 ) { TLDebug_Break("Missing vertex index from mapping"); return FALSE; } // update triangle CurrentTriangle[TriangleComponentIndex] = pExistingVertexMap->m_VertexIndex; // more of the triangle to fetch? if ( TriangleComponentIndex < 2 ) { TriangleComponentIndex++; continue; } // triangle complete! add to mesh m_pMesh->GetTriangles().Add( CurrentTriangle ); m_pMesh->OnPrimitivesChanged(); // reset temporary triangle for debugging CurrentTriangle.Set( 0xffff, 0xffff, 0xffff ); TriangleComponentIndex = 0; } // clean map for next set of triangles m_VertexMap.Empty(); } return TRUE; }