/** This function opens a RMobileSmartCardEap sub-session from RMobilePhone that will refer to the application referenced by aAID. It will be assumed that the application exists and contains a DF_EAP for the aEapType specified. The client must call RMobileSmartCardEap::InitialiseEapMethod() to ensure correct functionality of this sub-session. @param aPhone The RMobilePhone sub-session relative to which this sub-session will open. @param aAId The UICC Application ID, which should be of one that has EAP support. @param aEapType The EAP method type that this sub-session will use under the aAID application. @return KErrNone if successful, otherwise a system-wide error code. @see RMobileSmartCardEap::InitialiseEapMethod() @capability None @publishedPartner @released */ EXPORT_C TInt RMobileSmartCardEap::Open(RMobilePhone& aPhone, const RMobilePhone::TAID& aAID, const TEapType& aEapType) { RSessionBase* session = &aPhone.SessionHandle(); __ASSERT_ALWAYS(session != NULL, PanicClient(EEtelPanicNullHandle)); TInt subSessionHandle = aPhone.SubSessionHandle(); __ASSERT_ALWAYS(subSessionHandle != NULL, PanicClient(EEtelPanicNullHandle)); TRAPD(ret, ConstructL()); if (ret != KErrNone) { Destruct(); return ret; } // Appending the application ID and Eap Type to the name of the // subsession; plus two one-byte delimeters indicating lengths. // See var appIdbuf for why KAIDSize is multiplied by 2. TBufC<SCEAP_SSN_LENGTH + RMobilePhone::KAIDSize*2 + KEapTypeSize + 2> nameBuf(KETelSmartCardEapSession); // 2 for delimeters TPtr name(nameBuf.Des()); // the length of the AID as a Sept ASCII character TChar lengthAIDChar = SeptChar(aAID.Length()); // the value of the AID // converted to a 16-bit string representation. Multiply by 2, // since each AID byte is represented as two sem-octects. TBufC<2*RMobilePhone::KAIDSize> appIdbuf; TPtr appIdPtr(appIdbuf.Des()); ConvertBinToText(aAID, appIdPtr); // the length of the EapType TInt lengthEapType = aEapType.Length(); TChar charEapType = SeptChar(lengthEapType); // the value of the EapType (converted to 16-bit) TBufC<KEapTypeSize> eapTypeBuf; TPtr eapTypePtr(eapTypeBuf.Des()); eapTypePtr.Copy(aEapType); // appending... name.Append(lengthAIDChar); name.Append(appIdPtr); name.Append(charEapType); name.Append(eapTypePtr); TIpcArgs args(&name, TIpcArgs::ENothing, subSessionHandle); SetSessionHandle(*session); ret = CreateSubSession(*session, EEtelOpenFromSubSession, args); if (ret != KErrNone) { Destruct(); } return ret; }
void example_tbufc_modify_with_tptr(TBufC<16> &aBufC) { _LIT(casename, "example_tbufc_modify_with_tptr"); TBufC<128> buf(casename); prompt_case(buf); aBufC = KTxtHelloWorld; dump_tbufc_contentaddress_len_size(aBufC); TPtr ptr = aBufC.Des(); dump_tptr_content_contentaddress_len_size(ptr); // Now change the TBufC data through // the TPtr. This is OK provided the length // of the changed data does not exceed 16. // // The following change deletes the last // character (the "!") and appends // the characters " & Hi". // // Note that the length of both the TBufC // and the TPtr reflect the changed data. dump_tbufc_contentaddress_len_size(aBufC); _LIT(KTxtAndHi, " & Hi"); ptr.Delete((ptr.Length() - 1), 1); ptr.Append(KTxtAndHi); dump_tptr_content_contentaddress_len_size(ptr); }
void CSliderForDialog :: Draw( const TRect& /*aRect*/ ) const { // ��������� �������� TRect rect = Rect(); TInt runner_w = iMaxLbWidth + 2 * iDelimiter + 2 * iBvThickness; TInt runner_h = font->HeightInPixels() + 2 * iDelimiter + 2 * iBvThickness; TInt x_offs = rect.iTl.iX + iBvThickness + runner_w / 2; TPoint line_A( x_offs + 2, rect.iTl.iY + rect.Height() / 2 ), line_B( rect.iBr.iX - runner_w / 2 - 2, line_A.iY ); TInt runner_c = line_A.iX + iValue * ( line_B.iX - line_A.iX ) / iMaxVal; TRect iRunner_rect=TRect( runner_c - runner_w / 2, line_A.iY - runner_h / 2, runner_c + runner_w / 2, line_A.iY + runner_h / 2 ); TBufC<50> tmpLabel; TPtr tmpPtr = tmpLabel.Des(); tmpPtr.Append( iLabel ); tmpPtr.AppendNum( iValue ); TRgb penColor, brushColor; if( IsFocused() ) { penColor = KRgbBlack; brushColor = KRgbRed; } else { penColor = KRgbWhite; brushColor = KRgbGray; } CWindowGc& gc = SystemGc(); //Window().SetTransparencyAlphaChannel(); //TRgb c(0,0,0,0); //Window().SetBackgroundColor(c); //gc.Clear(); gc.SetPenSize( TSize( iBvThickness, iBvThickness ) ); gc.SetPenStyle( CGraphicsContext :: ENullPen ); gc.SetPenColor( penColor ); gc.SetBrushStyle( CGraphicsContext :: ESolidBrush ); gc.SetPenStyle( CGraphicsContext :: ESolidPen ); gc.DrawLine( line_A, line_B ); gc.SetBrushColor( brushColor ); gc.DrawRoundRect( iRunner_rect, TSize( 4, 4 ) ); gc.UseFont( font ); gc.DrawText( tmpLabel, TPoint( iRunner_rect.iTl.iX + iDelimiter + iBvThickness, iRunner_rect.iBr.iY - iDelimiter - iBvThickness ) ); }
int main() { __UHEAP_MARK; { int retval[10]; TBufC8<30> buf; TPtrC8 myTptr8 = buf.Des(); wchar_t* myWchar = L"no_worth_purpose"; char* temp = new char[15]; retval[0] = WcharpToTptrc8(myWchar,temp,myTptr8); wstring myWstring; retval[1] = Tptrc8ToWstring(myTptr8,myWstring); TBufC<30> tbuf; TPtrC16 myTptr16 = tbuf.Des(); retval[2] = WstringToTptrc16(myWstring,myTptr16); char* myChar = new char[40]; int size = 40; retval[3] = Tptrc16ToCharp(myTptr16,myChar,size); TBufC8<30> buf8; TPtr8 myTptr = buf8.Des(); retval[4] = CharpToTptr8(myChar,myTptr); wchar_t* Wstr_fin = new wchar_t[36]; int size_char=36; retval[5] = Tptr8ToWcharp(myTptr,Wstr_fin,size_char); for(int i=1; i<=5; i++) { if (retval[i]!= 0) printf("Conversion failed for retval\n",retval[i]); } if(!wcscmp(myWchar,Wstr_fin)) { printf("\n\nintegration_test_scenario23 case passed"); } else { printf("\n\nintegration_test_scenario23 case failed"); assert_failed = true; } delete[] temp; delete[] myChar; delete[] Wstr_fin; } __UHEAP_MARKEND; testResultXml("integration_test_scenario23"); return 0; }
void CSpaceInvadersAppView::DrawQuitCommand(CWindowGc& aGc) const { TRgb pencolor = TRgb(255,255,255); aGc.SetPenColor(pencolor); _LIT(KQuitText, "Quit"); TBufC<4> quitText; TPtr quitPtr = quitText.Des(); quitPtr.Append(KQuitText); const CFont* menuFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL); aGc.UseFont(menuFont); TInt textLength = menuFont->TextWidthInPixels(quitPtr); TInt textHeight = menuFont->HeightInPixels(); TPoint textpoint(Rect().Width() - ( textLength + 10 ), Rect().Height() - textHeight); aGc.DrawText(quitPtr, textpoint); }
void CSpaceInvadersAppView::DrawPoints(CWindowGc& aGc) const { TRgb pencolor = TRgb(255,255,255); aGc.SetPenColor(pencolor); _LIT(KPointsText, "Points: "); TBufC<15> pointsText; TPtr pointsPtr = pointsText.Des(); pointsPtr.Append(KPointsText); pointsPtr.AppendNum(iHolder->ActivePoints()); const CFont* menuFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL); aGc.UseFont(menuFont); TInt textLength = menuFont->TextWidthInPixels(pointsPtr); TInt textHeight = menuFont->HeightInPixels(); TPoint textpoint(Rect().Width() / 2 - textLength / 2, textHeight); aGc.DrawText(pointsPtr, textpoint); }
TBool CTestUtils::CheckLogStatus(const TBool aEventViewRet, const TRequestStatus& aStatus) { TBool ret = ETrue; TBufC<256> txtBuf; TPtr txt = txtBuf.Des(); if (!aEventViewRet) { txt.Zero(); txt.Append(_L("No more events in the LogView!")); AppendEol(txt, EFalse); Printf(txt); ret = EFalse; } else if (aStatus.Int() != KErrNone) { Printf(_L("\nError: CLogViewEvent async request completed with error %d.\n"), aStatus.Int()); ret = EFalse; } return ret; }
int main() { __UHEAP_MARK; TBufC<20> buf _L("praveen"); TPtrC16 src = buf.Des(); wchar_t * des= new wchar_t [20]; int size=50; int retval =ESuccess; retval= Tptrc16ToWcharp(src,des,size); if(retval ==ESuccess) { printf(" Test_tptrc16towcharp_positive PASSED\n"); } else { assert_failed = true; printf(" Test_tptrc16towcharp_positive FAILURE\n"); } delete[] des; des = NULL; __UHEAP_MARKEND; testResultXml("test_tptrc16towcharp_positive"); }
int main() { __UHEAP_MARK; TBufC<20> buf _L(""); TPtrC16 src = buf.Des(); char * des= new char [20]; int size=50; int retval =ESuccess; retval= Tptrc16ToCharp(src,des,size); if(retval ==ESuccess) { printf("Test_tptrc16tocharp_nodata PASSED\n"); } else { assert_failed = true; printf("Test_tptrc16tocharp_nodata FAILURE\n"); } delete[] des; des = NULL; __UHEAP_MARKEND; testResultXml("test_tptrc16tocharp_nodata"); }
int main() { __UHEAP_MARK; TBufC<5> buf _L("hello"); TPtr16 src = buf.Des(); char * des= new char [5]; int size=15; int retval =ESuccess; retval= Tptr16ToCharp(src,des,size); if(retval ==ESuccess) { printf(" Test_tptr16tocharp_minsize PASSED\n"); } else { assert_failed = true; printf(" Test_tptr16tocharp_minsize FAILURE\n"); } delete[] des; des = NULL; __UHEAP_MARKEND; testResultXml("test_tptr16tocharp_minsize"); }
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; }
/** * After the player has received the update after the last iteration of the game. * We want to display the current game status, if there is only one player remaining then * the game has finished. */ void CScabbyQueenPlayer::ReceiveNextRole() { if (iPlayerUpdate == iGameOverBuffer) { iConsole.Printf(_L("\nDealer Says: GAME OVER")); } else { // Break down the update descriptor and display the result TBufC<20> buffer; buffer.Des().Copy(iPlayerUpdate); iConsole.Printf(_L("\n\nUpdate from the dealer...%S\n"), &buffer); TInt position; TPtrC8 ptr(iPlayerUpdate); TLex8 lex; TInt player; TBool stillIn = EFalse; iConsole.Printf(_L("\n Number of players: %d\n"), iPlayerUpdate.Length()-1); TInt stillInCount = 0; for (TInt i=0; i<iPlayerUpdate.Length();i++) { TChar inspect = ptr[i]; if (inspect != 'F') { TBuf8<2> buff; buff.Append(inspect); lex.Assign(buff); lex.Val(player); if (stillIn) { TBufC16<2> buff; buff.Des().Append(inspect); iConsole.Printf(_L("\n Player %S still in play"), &buff); stillInCount++; } else { position = i+1; if (i == 0) { iConsole.Printf(_L("\n The winner is player %d"), player); } else { iConsole.Printf(_L("\n In position %d is player %d"), position, player); } } } else { stillIn = ETrue; } } if (stillInCount == 1) { // If there is only one player left the game is over. iGameOver = ETrue; iConsole.Printf(_L("\nThe loser is player %d, give them a smack"), player); iConsole.Printf(_L("\n\nDealer Says: GAME OVER")); } iGameStatus = EReadyForToken; iSendMode = ESendReadyForToken; BaseSendTo(iGameStatus, KDealerIpAddr); } }