satui/satapp/SATUISrc/CSatUiViewAppUi.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 18 594d59766373
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
     1 /*
       
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *    Implements the application UI and the methods derived from 
       
    16 *    MSatUiActionImplementer i.e. showing messages and asking input. 
       
    17 *
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include    <barsread.h>
       
    24 #include    <badesca.h> // for descriptor arrays
       
    25 #include    <e32std.h>
       
    26 #include    <eikenv.h>
       
    27 #include    <eikapp.h>
       
    28 #include    <StringLoader.h>
       
    29 #include    <aknview.h>
       
    30 #include    <aknnotedialog.h>
       
    31 #include    <aknstaticnotedialog.h>
       
    32 #include    <AknGlobalNote.h>
       
    33 #include    <AknQueryDialog.h>
       
    34 #include    <aknmessagequerydialog.h>
       
    35 #include    <AudioPreference.h>
       
    36 #include    <mdaaudiotoneplayer.h>
       
    37 #include    <activitymanager.h>
       
    38 #include    <AknIconArray.h>
       
    39 #include    <AknPopupform.h>                //DisplayText icon popupform
       
    40 #include    <eikcapc.h>                     //CEikCaptionedControl
       
    41 #include    <txtrich.h>                     //CRichText
       
    42 #include    <eikrted.h>                     //CEikRichTextEditor
       
    43 #include    <hlplch.h>
       
    44 #include    <aknsoundsystem.h>
       
    45 #include    <AknWaitDialog.h>
       
    46 #include    <akntitle.h>
       
    47 #include    <AknUtils.h>
       
    48 #include    <AknIconUtils.h>
       
    49 #include    <aknconsts.h>
       
    50 #include    <avkon.hrh>
       
    51 #include    <SatUi.rsg>
       
    52 #include    <msatuiadapter.h>
       
    53 #include    <aknkeylock.h>
       
    54 
       
    55 #include    "satui.hrh"
       
    56 #include    "CSatUiApplication.h"
       
    57 #include    "CSatUiViewAppUi.h"
       
    58 #include    "CSatUiView.h"
       
    59 #include    "CSatUiTextQueryDialog.h"
       
    60 #include    "CSatUiMessageQueryIcon.h" 
       
    61 #include    "CSatUiWaitDialog.h"
       
    62 #include    "tflogger.h"
       
    63 
       
    64 #include    <MProfile.h>
       
    65 #include    <MProfileEngine.h>
       
    66 #include    <MProfileTones.h>
       
    67 #include    <TProfileToneSettings.h>
       
    68 #include    <MProfileName.h>
       
    69 #include    <MProfileExtraTones.h>
       
    70 #include    <featmgr.h>                     // Used for FeatureManager
       
    71 #include    <BTSapDomainPSKeys.h>           // For BT SAP connection state keys.
       
    72 #include    <e32property.h>                 // Used for RProperty
       
    73 #include    <aknnotewrappers.h>
       
    74 
       
    75 #include    <aknlayout.cdl.h> 
       
    76 #include    <aknlayoutscalable_avkon.cdl.h>
       
    77 #include    <ctsydomainpskeys.h>
       
    78 #include    <mda/common/resource.h>
       
    79 
       
    80 #include    <ProfileEngineSDKCRKeys.h>
       
    81 #include    <centralrepository.h>
       
    82 
       
    83 
       
    84 // CONSTANTS
       
    85 const TInt KSatActiveProfileOffline = 5; // value from ProfileEngine
       
    86 const TInt K32TIntMaxValue = 0x7FFFFFFF;
       
    87 // From UI spec 60 sec delay user response.
       
    88 const TInt KNoResponseFromUserDelay = 60; 
       
    89 const TInt KMicroSecondsInSecond = 1000000;
       
    90 const TInt KClearScreenDelay = 3;
       
    91 const TInt KMicroSecondsInTenthOfSecond = 100000;
       
    92 const TInt K3Seconds = 3000000;
       
    93 
       
    94 // Maximum length for sound file. 
       
    95 const TInt KMaxSoundFileLength = 256;
       
    96 // Audio sample is repeated indefinitely.
       
    97 const TInt KSoundPlayerRepeatForever = KMdaRepeatForever;
       
    98 // Used when dividing some values. Used only for preventing the use of magic 
       
    99 // numbers
       
   100 const TInt KDivideByEight = 8;
       
   101 
       
   102 const TUint8 KGetInputStringMaxSize = 0xEF;
       
   103 
       
   104 _LIT( K3Spaces, "   " );                    // Used for empty title.
       
   105 const TInt KEmptyTitleLength( 3 );          // Length of empty title.                      
       
   106 _LIT( KSatEmptySpace, " " );                // Used for empty item.
       
   107 _LIT( KSatEmptyDes, "" );
       
   108 
       
   109 const TUint8 KKeyZero = 0x30;
       
   110 const TUint8 KKeyNine = 0x39;
       
   111 const TUint8 KHwAsterisk = 0x2a;    // In hw scan code value for asterisk
       
   112 
       
   113 // The max volume value from settings.
       
   114 // From TProfileToneSettings.h
       
   115 const TInt KMaxVolumeFromProfile( 10 );
       
   116 
       
   117 // ================= MEMBER FUNCTIONS =======================
       
   118 
       
   119 // C++ default constructor can NOT contain any code, that
       
   120 // might leave.
       
   121 //
       
   122 CSatUiViewAppUi::CSatUiViewAppUi():
       
   123     iHelp( EFalse ),
       
   124     iSetUpMenuFirst( ETrue ),
       
   125     iSelectItemFirst( ETrue ),
       
   126     iPreviousForeground( EFalse ),
       
   127     iViewLoopCounter( 0 ),
       
   128     iDuration( TTimeIntervalMicroSeconds( static_cast<TInt64>( 0 ) ) ),
       
   129     iReqWSBufferID( KErrNone )
       
   130     {
       
   131     }
       
   132 
       
   133 // Symbian OS default constructor can leave.
       
   134 void CSatUiViewAppUi::ConstructL()
       
   135     {
       
   136     TFLOGSTRING( "CSatUiViewAppUi::ConstructL() called" )
       
   137     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
   138     
       
   139     // Requests Window Server client buffer used by the application to
       
   140     // be of at least the given size.
       
   141     iReqWSBufferID = CAknEnv::Static()->RequestWsBuffer( KAknMaxWsBufferSize );
       
   142     TFLOGSTRING2( "iReqWSBufferID is %d", iReqWSBufferID )
       
   143 
       
   144     if ( BTSAPActivatedL() )
       
   145         {
       
   146         HBufC* sapText = 
       
   147             iCoeEnv->AllocReadResourceLC( R_QTN_OFFLINE_NOT_POSSIBLE_SAP );
       
   148         CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   149         iForegroundControl = note;
       
   150         note->ExecuteLD( *sapText );
       
   151         iForegroundControl = NULL;
       
   152         CleanupStack::PopAndDestroy( sapText );
       
   153         Exit();
       
   154         }
       
   155 
       
   156     if ( ProfileState() == KSatActiveProfileOffline )
       
   157         {
       
   158         ShowNotAvailableNoteL();
       
   159         Exit();        
       
   160         }
       
   161 
       
   162     
       
   163     if ( StatusPane()->PaneCapabilities( TUid::Uid(
       
   164         EEikStatusPaneUidTitle ) ).IsPresent() )
       
   165         {
       
   166         CAknTitlePane* titlePane = STATIC_CAST( CAknTitlePane*,
       
   167             StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   168         titlePane->SetTextL( KNullDesC );
       
   169         titlePane->DrawNow();
       
   170         }
       
   171         
       
   172     TFLOGSTRING( "CSatUiViewAppUi::ConstructL() exit" )
       
   173     }
       
   174 
       
   175 // Destructor.
       
   176 CSatUiViewAppUi::~CSatUiViewAppUi()
       
   177     {
       
   178     TFLOGSTRING( "CSatUiViewAppUi::~CSatUiViewAppUi() called" )
       
   179     this->StopShowWaitNote();
       
   180 
       
   181     delete iTitle;
       
   182     delete iAppName;
       
   183     delete iPlayer;
       
   184     delete iTimer;    
       
   185     
       
   186     TFLOGSTRING( "CSatUiViewAppUi::~CSatUiViewAppUi() exit" )
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // CSatUiViewAppUi::CreateEmptyMenuL
       
   191 // Creates empty menu. This is used in SIM originated commands.
       
   192 // (other items were commented in a header).
       
   193 // ---------------------------------------------------------
       
   194 //
       
   195 void CSatUiViewAppUi::CreateEmptyMenuL()
       
   196     {
       
   197     TFLOGSTRING( "CSatUiViewAppUi::CreateEmptyMenuL() called" )
       
   198 
       
   199     // Create the menu item array with no content.
       
   200     CDesCArrayFlat* menuItems = new( ELeave ) CDesCArrayFlat( 1 );
       
   201     CleanupStack::PushL( menuItems );
       
   202     menuItems->Reset();
       
   203     menuItems->AppendL( KSatEmptySpace );
       
   204 
       
   205     // Create the empty next action indicator array.
       
   206     CArrayFixFlat<TSatAction>* menuActions =
       
   207         new( ELeave ) CArrayFixFlat<TSatAction>( 1 );
       
   208     CleanupStack::PushL( menuActions );
       
   209     menuActions->Reset();
       
   210 
       
   211     // Create empty title pane.
       
   212     HBufC* satTitle = HBufC::NewLC( KEmptyTitleLength );
       
   213     satTitle->Des().Append( K3Spaces );
       
   214 
       
   215     iSetUpMenuFirst = EFalse;
       
   216     iSetUpMenuView = CSatUiView::NewL( ETrue, this, ETrue );
       
   217     iSetUpMenuView->SetItemsL( satTitle, 
       
   218         *menuItems, 
       
   219         menuActions, 
       
   220         EFalse );
       
   221         
       
   222     // Hide list box.
       
   223     iSetUpMenuView->MakeListBoxVisible( EFalse );
       
   224     
       
   225     // Transfer ownership to CAknViewAppUi.
       
   226     AddViewL( iSetUpMenuView );
       
   227 
       
   228     iSetUpMenuView->SetAdapter( iAdapter );
       
   229     iActiveView = KSetUpMenuViewId; 
       
   230     
       
   231     // satTitle, menuActions, menuItems  
       
   232     CleanupStack::PopAndDestroy( satTitle );
       
   233     CleanupStack::PopAndDestroy( menuActions );
       
   234     CleanupStack::PopAndDestroy( menuItems );
       
   235     TFLOGSTRING( "CSatUiViewAppUi::CreateEmptyMenuL() exit" )
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------
       
   239 // CSatUiViewAppUi::SetAdapter
       
   240 // Sets the pointer to MSatUiAdapter object.
       
   241 // (other items were commented in a header).
       
   242 // ---------------------------------------------------------
       
   243 //
       
   244 void CSatUiViewAppUi::SetAdapter(
       
   245     MSatUiAdapter* aAdapter )
       
   246     {
       
   247     iAdapter = aAdapter;
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------
       
   251 // CSatUiViewAppUi::ShowWaitNoteL
       
   252 // Displays the wait note.
       
   253 // (other items were commented in a header).
       
   254 // ---------------------------------------------------------
       
   255 //
       
   256 void CSatUiViewAppUi::ShowWaitNoteL()
       
   257     {
       
   258     TFLOGSTRING( "CSatUiViewAppUi::ShowWaitNoteL() called" )
       
   259     if ( !iWaitNote )
       
   260         {
       
   261         iWaitNote = new(ELeave)CAknWaitDialog(
       
   262             (REINTERPRET_CAST(CEikDialog**,&iWaitNote)));
       
   263         iForegroundControl = iWaitNote;
       
   264         iWaitNote->ExecuteLD( R_SATUI_WAIT_NOTE );
       
   265         // iForegroundControl won't be clear until the wait dialog
       
   266         // closed. It will avoid we lose the chance to set focus for
       
   267         // the wait dialog when the switch of foreground/background
       
   268         // happened.
       
   269         }
       
   270     TFLOGSTRING( "CSatUiViewAppUi::ShowWaitNoteL() exit" )
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------
       
   274 // CSatUiViewAppUi::ShowWaitNoteWithoutDelayL
       
   275 // Displays the wait note without delay
       
   276 // (other items were commented in a header).
       
   277 // ---------------------------------------------------------
       
   278 //
       
   279 void CSatUiViewAppUi::ShowWaitNoteWithoutDelayL()
       
   280     {
       
   281     TFLOGSTRING( "CSatUiViewAppUi::ShowWaitNoteWithoutDelayL() called" )
       
   282     if ( !iWaitNote )
       
   283         {
       
   284         iWaitNote = new(ELeave)CAknWaitDialog(
       
   285             (REINTERPRET_CAST(CEikDialog**,&iWaitNote)), ETrue );
       
   286         iForegroundControl = iWaitNote;
       
   287         iWaitNote->ExecuteLD( R_SATUI_WAIT_NOTE );
       
   288         // iForegroundControl won't be clear until the wait dialog
       
   289         // closed. It will avoid we lose the chance to set focus for
       
   290         // the wait dialog when the switch of foreground/background
       
   291         // happened.
       
   292         }
       
   293     TFLOGSTRING( "CSatUiViewAppUi::ShowWaitNoteWithoutDelayL() exit" )
       
   294     }
       
   295 
       
   296 // ---------------------------------------------------------
       
   297 // CSatUiViewAppUi::StopShowWaitNote
       
   298 // Removes the wait note from the screen.
       
   299 // (other items were commented in a header).
       
   300 // ---------------------------------------------------------
       
   301 //
       
   302 void CSatUiViewAppUi::StopShowWaitNote()
       
   303     {
       
   304     TFLOGSTRING( "CSatUiViewAppUi::StopShowWaitNote() called" )
       
   305 
       
   306     if ( iNoteDialog )
       
   307         {
       
   308         iForegroundControl = NULL;
       
   309 
       
   310         TFLOGSTRING( "CSatUiViewAppUi::StopShowWaitNote() Closing \
       
   311             NoteDialog" )
       
   312         delete iNoteDialog;
       
   313         iNoteDialog = NULL;
       
   314         }
       
   315 
       
   316     if ( iWaitNote )
       
   317         {
       
   318         iForegroundControl = NULL;
       
   319 
       
   320         TFLOGSTRING( "CSatUiViewAppUi::StopShowWaitNote() Closing WaitNote" )
       
   321         // Process finished. The function was either ExecuteLD or RunLD.
       
   322         // This function call stops the execution of these function and 
       
   323         // causes the deletion of object
       
   324         TInt err(0);
       
   325         TRAP( err, iWaitNote->ProcessFinishedL() )
       
   326         TFLOGSTRING2(" 2nd: iWaitNote: %x ", iWaitNote )
       
   327         TFLOGSTRING2( "TRAP: %d", err )
       
   328         // Delete the object just in case. Seems that above method does not 
       
   329         // delete the object in some cases. e.g in very fast execution
       
   330         delete iWaitNote;
       
   331         iWaitNote = NULL;
       
   332         }
       
   333     if ( iBipWaitNote )
       
   334         {
       
   335         iForegroundControl = NULL;
       
   336 
       
   337         TFLOGSTRING( "CSatUiViewAppUi::StopShowWaitNote() Closing BIP note" )
       
   338         delete iBipWaitNote;
       
   339         iBipWaitNote = NULL;
       
   340         }
       
   341         
       
   342     if ( iPermanentNote )
       
   343         {
       
   344         TFLOGSTRING( "CSatUiViewAppUi::StopShowWaitNote() \
       
   345                iPermanentNote cleared" )
       
   346         // If iPermanentNote exists until wait note is stopped,
       
   347         // then dialog has been already removed.
       
   348         iPermanentNote->ExitSleepingDialog();
       
   349         delete iPermanentNote;
       
   350         iPermanentNote = NULL;
       
   351         }
       
   352         
       
   353     TFLOGSTRING( "CSatUiViewAppUi::StopShowWaitNote() exit" )
       
   354     }
       
   355 
       
   356 // ---------------------------------------------------------
       
   357 // CSatUiViewAppUi::BTSAPActivatedL
       
   358 // Check that if BT SAP connection activated.
       
   359 // (other items were commented in a header).
       
   360 // ---------------------------------------------------------
       
   361 //
       
   362 TBool CSatUiViewAppUi::BTSAPActivatedL()
       
   363     {
       
   364 
       
   365     TFLOGSTRING( "CSatUiViewAppUi::BTSAPActivated() called" )
       
   366 
       
   367     TBool isActive( EFalse );
       
   368     FeatureManager::InitializeLibL();
       
   369     if ( FeatureManager::FeatureSupported( KFeatureIdBtSap ) )
       
   370         {
       
   371         TFLOGSTRING( "BTSAP is supported by ME" )
       
   372         TInt status( EBTSapNotConnected );
       
   373         TInt err = RProperty::Get( KPSUidBluetoothSapConnectionState, 
       
   374                                    KBTSapConnectionState, 
       
   375                                    status );
       
   376 
       
   377         if ( EBTSapNotConnected != status && !err )
       
   378             {
       
   379             TFLOGSTRING( "BTSAP is connected" )
       
   380             isActive = ETrue;
       
   381             }
       
   382         else
       
   383             {
       
   384             TFLOGSTRING3( "BTSAP status %d and error %d", status, err )
       
   385             }
       
   386         }
       
   387     else
       
   388         {
       
   389         TFLOGSTRING( "BTSAP is not supported by ME" )
       
   390         }
       
   391 
       
   392     FeatureManager::UnInitializeLib();
       
   393     TFLOGSTRING( "CSatUiViewAppUi::BTSAPActivated() exit" )
       
   394     return isActive;
       
   395 
       
   396     }
       
   397 
       
   398 // ---------------------------------------------------------
       
   399 // CSatUiViewAppUi::CoeEnv
       
   400 // Returns CoeEnv.
       
   401 // (other items were commented in a header).
       
   402 // ---------------------------------------------------------
       
   403 //
       
   404 CCoeEnv* CSatUiViewAppUi::CoeEnv()
       
   405     {
       
   406     return iCoeEnv;
       
   407     }
       
   408 
       
   409 // ---------------------------------------------------------
       
   410 // CSatUiViewAppUi::DisplayTextL
       
   411 // Displays the text in a note. 
       
   412 // (other items were commented in a header).
       
   413 // ---------------------------------------------------------
       
   414 //
       
   415 TSatUiResponse CSatUiViewAppUi::DisplayTextL(
       
   416     const TDesC& aText,
       
   417     const TDesC& aSimApplicationName,
       
   418     CFbsBitmap* aIconBitmapDisplayText,
       
   419     const TBool aSelfExplanatoryIcon,
       
   420     const TBool aSustainedText,
       
   421     const TTimeIntervalSeconds aDuration,
       
   422     const TBool aWaitUserToClear )
       
   423     {
       
   424     TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL called" )
       
   425     StopShowWaitNote();
       
   426 
       
   427     TSatUiResponse response( ESatSuccess );
       
   428     iHighPriorityEvent = EFalse;
       
   429     
       
   430     // Indication immediate response TLV for Display Text during MT call,
       
   431     // if it is immediate response, close dialog, otherwise leave it alone.
       
   432     iImmediateRsp = aSustainedText;
       
   433     TFLOGSTRING2( "CSatUiViewAppUi::DisplayTextL immediate rsp: %d", 
       
   434                    iImmediateRsp )    
       
   435     
       
   436     HBufC* header;
       
   437 
       
   438     if ( iHelp )
       
   439         {
       
   440         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL iHelp ETrue" )
       
   441         header = StringLoader::LoadLC(
       
   442             R_QTN_SAT_HELP_HEADER, iCoeEnv );
       
   443         iHelp = EFalse;
       
   444         }
       
   445     else
       
   446         {
       
   447         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL iHelp EFalse" )
       
   448         TFLOGSTRING2( "CSatUiViewAppUi::DisplayTextL length of \
       
   449             aSimApplicationName: %d", aSimApplicationName.Length() )
       
   450         if ( aSimApplicationName.Length() > 0 )
       
   451             {
       
   452             header = aSimApplicationName.AllocLC();
       
   453             }
       
   454         else
       
   455             {
       
   456             //Reads a resource string with memory allocation
       
   457             header = StringLoader::LoadLC( R_QTN_SAT_MESSAGE_HEADER, iCoeEnv );
       
   458             }
       
   459         }
       
   460 
       
   461     // Remove NULL characters from title
       
   462     RemoveNullCharacters( header );
       
   463 
       
   464     if ( aIconBitmapDisplayText )
       
   465         {
       
   466         //icon available use querydialog
       
   467         iDisplayTextIconDialog = CAknPopupForm::NewL();
       
   468         }
       
   469 
       
   470     CUserActivityManager* activityManager = 
       
   471         CUserActivityManager::NewL( EPriorityNormal );
       
   472 
       
   473     CleanupStack::PushL( activityManager );
       
   474     
       
   475     // Duration handling: 
       
   476     // If duration is given use that value for timeout.
       
   477     TTimeIntervalSeconds duration ( aDuration );
       
   478 
       
   479     // If user is expected to clear shown dialog and 
       
   480     // duration is NOT given use 60s timeout.
       
   481     if ( aWaitUserToClear && !aDuration.Int() )
       
   482         {
       
   483         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL wait user to clear" )
       
   484         duration = TTimeIntervalSeconds( KNoResponseFromUserDelay );
       
   485         }
       
   486     // If user is NOT expected to clear shown dialog and 
       
   487     // duration is NOT given use 3s timeout.
       
   488     else if ( !aDuration.Int() )
       
   489         {
       
   490         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL don't wait user \
       
   491             to clear" )
       
   492         duration = TTimeIntervalSeconds( KClearScreenDelay );
       
   493         }        
       
   494 
       
   495     // If not sustained or Clear after delay requested start timer
       
   496     if ( !aSustainedText || aDuration.Int() || !aWaitUserToClear )
       
   497         {
       
   498         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL No sustained text" )
       
   499         TFLOGSTRING2( "CSatUiViewAppUi::DisplayTextL duration: %d", 
       
   500             duration.Int() )
       
   501         
       
   502         // If duration is given start timer which doesn't 
       
   503         // care about user activity.        
       
   504         if ( aDuration.Int() )
       
   505             {
       
   506             CreateCallBackTimerL( duration.Int() * KMicroSecondsInSecond,
       
   507                 DelayCallback );
       
   508             }
       
   509         // Otherwise start timer which takes account user activity.
       
   510         else
       
   511             {
       
   512             User::ResetInactivityTime();
       
   513             activityManager->Start( duration, 
       
   514                 TCallBack( DispatchUserInactive, this ), 0 );            
       
   515             }
       
   516         }
       
   517 
       
   518     TInt userResponse;
       
   519 
       
   520     if ( aIconBitmapDisplayText )
       
   521         {
       
   522         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL have IconBitmap" )
       
   523         // Prepare dialog with icon
       
   524         iDisplayTextIconDialog->SetPopupFormType( EAknQuery );
       
   525         iDisplayTextIconDialog->PrepareLC( R_SATUI_MESSAGE_TEXT_ICON );
       
   526         iDisplayTextIconDialog->SetTitleL( *header );
       
   527 
       
   528         // Get richtext control
       
   529         CEikCaptionedControl* capControl = 
       
   530             iDisplayTextIconDialog->GetControlByControlType
       
   531             ( EEikCtRichTextEditor );
       
   532         CCoeControl* coeControl = NULL;
       
   533         if ( capControl )
       
   534             {
       
   535             coeControl = capControl->iControl;
       
   536             }
       
   537         if ( !coeControl )
       
   538             {
       
   539             User::Leave( KErrUnknown );
       
   540             }
       
   541         CEikRichTextEditor* rtxtEditor = 
       
   542             reinterpret_cast<CEikRichTextEditor*>( coeControl );
       
   543 
       
   544         if ( !aSelfExplanatoryIcon )
       
   545             {
       
   546             TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL not \
       
   547                 SelfExplanatoryIcon" )
       
   548             // Not selfexplanatory icon, add text
       
   549             // Get font
       
   550             const CFont* logicalFont = AknLayoutUtils::FontFromId( 
       
   551                 EAknLogicalFontSecondaryFont );
       
   552             
       
   553             // Extract font information
       
   554             TFontSpec fontspec = logicalFont->FontSpecInTwips();
       
   555             TCharFormat charFormat( fontspec.iTypeface.iName, 
       
   556                             fontspec.iHeight );
       
   557             
       
   558             // Make the font to be anti-aliased
       
   559             TFontStyle style;
       
   560             style.SetBitmapType( EAntiAliasedGlyphBitmap );
       
   561             charFormat.iFontSpec.iFontStyle = style;
       
   562                 
       
   563             // Set mask (which settings are set)
       
   564             TCharFormatMask charFormatMask;
       
   565             charFormatMask.SetAttrib( EAttColor );
       
   566             charFormatMask.SetAttrib( EAttFontTypeface );
       
   567             charFormatMask.SetAttrib( EAttFontHeight );
       
   568             
       
   569             // Apply settings
       
   570             rtxtEditor->RichText()->ApplyCharFormatL(
       
   571                 charFormat, charFormatMask, 0, 0 );
       
   572                     
       
   573             // One space between icon and text
       
   574             rtxtEditor->RichText()->InsertL( 0, KSatEmptySpace );
       
   575             rtxtEditor->RichText()->InsertL( 1, aText );
       
   576             }
       
   577 
       
   578         // Count icon size in twips 
       
   579         CWsScreenDevice* device = CCoeEnv::Static()->ScreenDevice();
       
   580         TInt width = device->HorizontalPixelsToTwips( 
       
   581             aIconBitmapDisplayText->SizeInPixels().iWidth );
       
   582         TInt height = device->VerticalPixelsToTwips( 
       
   583             aIconBitmapDisplayText->SizeInPixels().iHeight );
       
   584         TSize twipsSize( width, height );
       
   585 
       
   586         // Create picture
       
   587         CSatUiMessageQueryIcon* picture = new( ELeave ) 
       
   588             CSatUiMessageQueryIcon( twipsSize, *aIconBitmapDisplayText );
       
   589         TPictureHeader pictureHeader;    
       
   590         pictureHeader.iPicture = TSwizzle<CPicture>( picture );
       
   591         //Insert picture
       
   592         rtxtEditor->RichText()->InsertL( 0, pictureHeader );
       
   593         //Needed to show whole picture
       
   594         _LIT( KString, "\f\f\f");
       
   595         rtxtEditor->RichText()->InsertL( rtxtEditor->Text()->DocumentLength(),
       
   596             KString );
       
   597 
       
   598         // Set MSK same as LSK without any text causing the icon drawing
       
   599         iDisplayTextIconDialog->ButtonGroupContainer().SetCommandL(
       
   600             CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknSoftkeyOk,
       
   601             KSatEmptyDes );
       
   602         iForegroundControl = iDisplayTextIconDialog;
       
   603         userResponse = iDisplayTextIconDialog->RunLD();
       
   604         }
       
   605     else
       
   606         {
       
   607         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL don't have IconBitmap" )
       
   608         // Dialog without icon
       
   609         iDisplayTextDialog = new (ELeave) CAknMessageQueryDialog();
       
   610         iDisplayTextDialog->PrepareLC( R_SATUI_MESSAGE );
       
   611         iDisplayTextDialog->SetMessageTextL( aText );
       
   612         iDisplayTextDialog->QueryHeading()->SetTextL( *header );
       
   613 
       
   614         // Set MSK same as LSK without any text causing the icon drawing
       
   615         iDisplayTextDialog->ButtonGroupContainer().SetCommandL(
       
   616             CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknSoftkeyOk,
       
   617             KSatEmptyDes );
       
   618         iForegroundControl = iDisplayTextDialog;
       
   619         userResponse = iDisplayTextDialog->RunLD();
       
   620         }
       
   621     iForegroundControl = NULL;
       
   622 
       
   623     CleanupStack::PopAndDestroy( activityManager );
       
   624     CleanupStack::PopAndDestroy( header ); // header,activityManager
       
   625     // After duration call back timer is destroyed
       
   626     DestroyCallBackTimer();
       
   627     
       
   628     // If user is not expected to clear message used response is success
       
   629     // in timeout case.
       
   630     if ( userResponse 
       
   631         || ( iNoteClearedAfterDelay && !aWaitUserToClear ) )
       
   632         {
       
   633         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL successful response" )
       
   634         response = ESatSuccess;
       
   635         }
       
   636     else if ( iNoResponseFromUserAfterDelay || 
       
   637         ( aWaitUserToClear && iHighPriorityEvent ) )
       
   638         {
       
   639         TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL no user response" )
       
   640         // User did not close the text, closed by the timer or MT call
       
   641         response = ESatNoResponseFromUser;
       
   642         }
       
   643     else
       
   644         {
       
   645         if ( IsAppShutterRunning() )
       
   646             {
       
   647             TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL satsession \
       
   648                 terminated by user " )
       
   649             response = ESatSessionTerminatedByUser;
       
   650             iSessionTerminated = ETrue;
       
   651             }
       
   652         else
       
   653             {
       
   654             TFLOGSTRING( "CSatUiViewAppUi::DisplayTextL backward \
       
   655                 requested by user " )
       
   656             response = ESatBackwardModeRequestedByUser;
       
   657             }
       
   658         }
       
   659 
       
   660     if ( iDisplayTextDialog )
       
   661         {
       
   662         iDisplayTextDialog = NULL;
       
   663         }
       
   664     if ( iDisplayTextIconDialog )
       
   665         {
       
   666         iDisplayTextIconDialog = NULL;
       
   667         }
       
   668 
       
   669     iNoteClearedAfterDelay = EFalse;
       
   670     iNoResponseFromUserAfterDelay = EFalse;
       
   671 
       
   672     ShowWaitNoteL();
       
   673         
       
   674     TFLOGSTRING2( "CSatUiViewAppUi::DisplayTextL exit, return: %d", response )
       
   675     return response;
       
   676     }
       
   677 
       
   678 // ---------------------------------------------------------
       
   679 // CSatUiViewAppUi::ClearScreen
       
   680 // Displays yes/no confirmation query.
       
   681 // (other items were commented in a header).
       
   682 // ---------------------------------------------------------
       
   683 //
       
   684 void CSatUiViewAppUi::ClearScreen()
       
   685     {
       
   686     TFLOGSTRING( "CSatUiViewAppUi::ClearScreen() called" )
       
   687     
       
   688     iNoteClearedAfterDelay = ETrue;
       
   689     CloseDialogs();
       
   690     
       
   691     TFLOGSTRING( "CSatUiViewAppUi::ClearScreen() exit" )
       
   692     }
       
   693 // ---------------------------------------------------------
       
   694 // CSatUiViewAppUi::GetYesNoL
       
   695 // Displays yes/no confirmation query.
       
   696 // (other items were commented in a header).
       
   697 // ---------------------------------------------------------
       
   698 //
       
   699 TSatUiResponse CSatUiViewAppUi::GetYesNoL(
       
   700     const TDesC& aText,
       
   701     const TSatCharacterSet aCharacterSet,
       
   702     TChar& aInkey,
       
   703     const CFbsBitmap* aIconBitmap,
       
   704     const TBool aSelfExplanatory,
       
   705     TUint& aDuration,
       
   706     const TBool aImmediateDigitResponse )
       
   707     {
       
   708     TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL called" )
       
   709     TSatUiResponse response( ESatSuccess );
       
   710 
       
   711     StopShowWaitNote();
       
   712 
       
   713     CUserActivityManager* activityManager = 
       
   714         CUserActivityManager::NewL( EPriorityNormal );
       
   715     CleanupStack::PushL( activityManager );
       
   716 
       
   717     // Start time for duration
       
   718     TTime startTime;
       
   719     iImmediateDigitResponse = aImmediateDigitResponse;
       
   720     
       
   721     TFLOGSTRING2( "CSatUiViewAppUi::GetYesNoL duration in 1/10 sec: %d",
       
   722             aDuration )
       
   723 
       
   724     // If duration is given use that value for timeout.
       
   725     // Start timer which doesn't care about user activity.
       
   726     if ( aDuration )
       
   727         {
       
   728         TInt duration ( 0 );
       
   729          
       
   730         TTimeIntervalMicroSeconds max32Bit(
       
   731             static_cast<TInt64>( K32TIntMaxValue ) );        
       
   732         TTimeIntervalMicroSeconds durationInTenthOfSeconds( 
       
   733             static_cast<TInt64>( aDuration ) );
       
   734         TTimeIntervalMicroSeconds durationInus( 
       
   735             durationInTenthOfSeconds.Int64() * KMicroSecondsInTenthOfSecond );
       
   736         
       
   737         if ( durationInus > max32Bit )
       
   738             {
       
   739             TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL durationInus bigger \
       
   740                 than max32Bit" )
       
   741             // since timers can only handle 32-bit values,
       
   742             // let's break the aDuration to smaller bits.
       
   743             // we break it here to 8 bits to fit in 32-bit value
       
   744             duration = durationInus.Int64() / KDivideByEight;
       
   745             iTimerRepeatOn = ETrue;
       
   746             }
       
   747         else
       
   748             {
       
   749             TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL durationInus less \
       
   750                 than max32Bit" )
       
   751             duration = durationInus.Int64();
       
   752             }
       
   753             
       
   754         CreateCallBackTimerL( duration, DelayCallback );
       
   755         startTime.HomeTime();
       
   756         }
       
   757     // Otherwise start timer which takes account user activity.
       
   758     else
       
   759         {
       
   760         User::ResetInactivityTime();
       
   761         activityManager->Start( 
       
   762             TTimeIntervalSeconds( KNoResponseFromUserDelay ),
       
   763             TCallBack( DispatchUserInactive, this ), 0 );            
       
   764         }
       
   765 
       
   766     TInt resource( 0 );        
       
   767 
       
   768     if ( aIconBitmap )
       
   769         {
       
   770         TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL iGetYesNoIconDialog" )
       
   771 
       
   772         if ( ESatYesNo == aCharacterSet )
       
   773             {
       
   774             resource = R_SATUI_CONFIRM_YES_NO_QUERY_WITH_ICON;
       
   775             }
       
   776         else
       
   777             {
       
   778             resource = R_SATUI_IMMEDIATE_DIGIT_NOTE_WITH_ICON;
       
   779             }
       
   780         }
       
   781     else
       
   782         {
       
   783         TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL iGetYesNoDialog" )
       
   784 
       
   785         if ( ESatYesNo == aCharacterSet )
       
   786             {
       
   787             resource = R_SATUI_CONFIRM_YES_NO_QUERY;
       
   788             }
       
   789         else
       
   790             {
       
   791             resource = R_SATUI_IMMEDIATE_DIGIT_QUERY;
       
   792             }
       
   793         }
       
   794     
       
   795     TInt userResponse = RunQueryDialogL( resource , aText, aIconBitmap,
       
   796         aSelfExplanatory, EAknSoftkeyYes );
       
   797 
       
   798     iImmediateDigitResponse = EFalse;
       
   799     
       
   800     // set received immediate digit response
       
   801     aInkey = iKey;
       
   802     iKey = 0;
       
   803     
       
   804     if ( aDuration )
       
   805         {
       
   806         TTime endTime;
       
   807         endTime.HomeTime();
       
   808         TTimeIntervalMicroSeconds timeDifference( 0 );
       
   809         timeDifference = endTime.MicroSecondsFrom( startTime );
       
   810         aDuration = timeDifference.Int64() / KMicroSecondsInTenthOfSecond;
       
   811         
       
   812         // After duration call back timer is destroyed
       
   813         DestroyCallBackTimer();
       
   814         }
       
   815     
       
   816     CleanupStack::PopAndDestroy( activityManager );
       
   817 
       
   818     // Timeout
       
   819     if ( iNoResponseFromUserAfterDelay )
       
   820         {
       
   821         TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL no response from user" )
       
   822         response = ESatNoResponseFromUser;
       
   823         }
       
   824     // Cancel is pressed if immediate digit response without Yes/No
       
   825     else if ( !userResponse &&  ESatYesNo != aCharacterSet && !aInkey )
       
   826         {
       
   827         TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL backward request by user" )
       
   828         response = ESatBackwardModeRequestedByUser;
       
   829         }
       
   830     // Yes button is used
       
   831     else if ( userResponse && !aInkey)
       
   832         {
       
   833         TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL button used" )
       
   834         aInkey = 1;
       
   835         }
       
   836     // No button is used
       
   837     else if ( !aInkey )
       
   838         {
       
   839         TFLOGSTRING( "CSatUiViewAppUi::GetYesNoL no button used" )
       
   840         aInkey = 0;
       
   841         }
       
   842 
       
   843     iNoResponseFromUserAfterDelay = EFalse;
       
   844 
       
   845     ShowWaitNoteL();
       
   846     
       
   847     TFLOGSTRING2( "CSatUiViewAppUi::GetYesNoL exit, return: %d", response )
       
   848     return response;
       
   849     }
       
   850 
       
   851 // ---------------------------------------------------------
       
   852 // CSatUiViewAppUi::GetInputL
       
   853 // Displays data query.
       
   854 // (other items were commented in a header).
       
   855 // ---------------------------------------------------------
       
   856 //
       
   857 TSatUiResponse CSatUiViewAppUi::GetInputL(
       
   858     const TDesC& aText,
       
   859     const TSatCharacterSet aCharacterSet,
       
   860     TDes& aInput,
       
   861     const TInt aMinLength,
       
   862     const TInt aMaxLength,
       
   863     const TBool aHideInput,
       
   864     const TBool aGetInkey,
       
   865     const CFbsBitmap* aIconBitmapGetInput,
       
   866     const TBool aSelfExplanatory,
       
   867     TUint& aDuration ) 
       
   868     {
       
   869     TFLOGSTRING( "CSatUiViewAppUi::GetInputL called" )
       
   870     StopShowWaitNote();
       
   871 
       
   872     TSatUiResponse response( ESatSuccess );
       
   873 
       
   874     TPtrC textPtr( aText );
       
   875 
       
   876     TInt minLength( 0 );
       
   877     TInt maxLength( 1 );
       
   878     
       
   879     TFLOGSTRING2( "CSatUiViewAppUi::GetInputL aMinLength %d", aMinLength )
       
   880     TFLOGSTRING2( "CSatUiViewAppUi::GetInputL aMaxLength %d", aMaxLength )
       
   881     //lint -e{961} else block not needed, minLength initialized.
       
   882     if ( aMinLength <= KGetInputStringMaxSize && aMinLength > 0 )
       
   883         {
       
   884         minLength = aMinLength;
       
   885         }
       
   886     else if ( aMinLength > KGetInputStringMaxSize )
       
   887         {
       
   888         minLength = KGetInputStringMaxSize;
       
   889         }
       
   890 
       
   891     //lint -e{961} else block not needed, maxLength initialized.
       
   892     if ( aMaxLength < minLength )
       
   893         {
       
   894         maxLength = minLength;
       
   895         }
       
   896     else if ( aMaxLength <= KGetInputStringMaxSize && aMaxLength > 1 )
       
   897         {
       
   898         maxLength = aMaxLength;
       
   899         }
       
   900     else if ( aMaxLength > KGetInputStringMaxSize )
       
   901         {
       
   902         maxLength = KGetInputStringMaxSize;
       
   903         }
       
   904 
       
   905     HBufC* input = HBufC::NewLC( KGetInputStringMaxSize );
       
   906     TPtr inputPtr(input->Des());
       
   907 
       
   908     HBufC* textHolder = NULL;
       
   909     
       
   910     TFLOGSTRING2( "CSatUiViewAppUi::GetInputL aInput.Length %d",\
       
   911         aInput.Length() )
       
   912 
       
   913     if ( ( aInput.Length() >= minLength )
       
   914         && ( aInput.Length() <= maxLength ) )
       
   915         {
       
   916         inputPtr = aInput;
       
   917         }
       
   918 
       
   919     TInt userResponse;
       
   920 
       
   921     CUserActivityManager* activityManager = 
       
   922         CUserActivityManager::NewL( EPriorityNormal );
       
   923 
       
   924     CleanupStack::PushL( activityManager );
       
   925 
       
   926     // Start time for timer
       
   927     TTime startTime;
       
   928 
       
   929     // If duration is given use that value for timeout.
       
   930     // Start timer which doesn't care about user activity.
       
   931     if ( aDuration && aGetInkey )
       
   932         {
       
   933         TFLOGSTRING2( "CSatUiViewAppUi::GetInputL duration in 1/10 sec: %d",
       
   934             aDuration )        
       
   935         
       
   936         TInt duration ( 0 );
       
   937          
       
   938         TTimeIntervalMicroSeconds max32Bit(
       
   939             static_cast<TInt64>( K32TIntMaxValue ) );        
       
   940         TTimeIntervalMicroSeconds durationInTenthOfSeconds( 
       
   941             static_cast<TInt64>( aDuration ) );
       
   942         TTimeIntervalMicroSeconds durationInus( 
       
   943             durationInTenthOfSeconds.Int64() * KMicroSecondsInTenthOfSecond );
       
   944         
       
   945         if ( durationInus > max32Bit )
       
   946             {
       
   947             TFLOGSTRING( "CSatUiViewAppUi::GetInputL durationInus bigger \
       
   948                 than max32Bit" )
       
   949             // since timers can only handle 32-bit values,
       
   950             // let's break the aDuration to smaller bits.
       
   951             // we break it here to 8 bits to fit in 32-bit value
       
   952             duration = durationInus.Int64() / KDivideByEight;
       
   953             iTimerRepeatOn = ETrue;
       
   954             }
       
   955         else
       
   956             {
       
   957             TFLOGSTRING( "CSatUiViewAppUi::GetInputL durationInus less \
       
   958                 than max32Bit" )
       
   959             duration = durationInus.Int64();
       
   960             }
       
   961             
       
   962         CreateCallBackTimerL( duration, DelayCallback );
       
   963         startTime.HomeTime();
       
   964         }
       
   965     // Otherwise start timer which takes account user activity.
       
   966     else
       
   967         {
       
   968         User::ResetInactivityTime();
       
   969         activityManager->Start( 
       
   970             TTimeIntervalSeconds( KNoResponseFromUserDelay ),
       
   971             TCallBack( DispatchUserInactive, this ), 0 );            
       
   972         }
       
   973 
       
   974     CEikImage* image = new(ELeave) CEikImage;
       
   975     CleanupStack::PushL( image );
       
   976     
       
   977     if ( aIconBitmapGetInput )
       
   978         {        
       
   979         image->SetBitmap( aIconBitmapGetInput );
       
   980     
       
   981         // Create mask for icon bitmap
       
   982         CFbsBitmap* mask = new(ELeave) CFbsBitmap;
       
   983 
       
   984         TSize size = aIconBitmapGetInput->SizeInPixels();
       
   985         CleanupStack::PushL( mask );
       
   986         MakeGetInputBitmapMask( mask, size );
       
   987 
       
   988         image->SetMask( mask );
       
   989         CleanupStack::Pop( mask ); 
       
   990         }
       
   991 
       
   992     TInt resource( 0 );
       
   993     TInt textResource( 0 );
       
   994     // Query dialog
       
   995     iGetInputDialog = new (ELeave) CSatUiTextQueryDialog( inputPtr,
       
   996                 CAknQueryDialog::ENoTone, minLength, maxLength );
       
   997     iForegroundControl = iGetInputDialog;
       
   998 
       
   999     if ( aCharacterSet == ESatDigitOnly ) 
       
  1000         {
       
  1001         TFLOGSTRING( "CSatUiViewAppUi::GetInputL ESatDigitOnly" )
       
  1002         if ( aText.Length() == 0 )
       
  1003             {
       
  1004             if ( aGetInkey )
       
  1005                 {
       
  1006                 textResource = R_TEXT_SIMATK_ENTER_NBR;
       
  1007                 }
       
  1008             else
       
  1009                 {
       
  1010                 textResource = R_TEXT_SIMATK_ENTER_NBR_STRING;
       
  1011                 }
       
  1012             }
       
  1013         
       
  1014         // Hidden digit as input
       
  1015         if ( aHideInput )
       
  1016             {            
       
  1017             TFLOGSTRING( "CSatUiViewAppUi::GetInputL Hidden digit" )            
       
  1018             if ( aIconBitmapGetInput )
       
  1019                 {
       
  1020                 resource = R_SATUI_HIDDEN_NUMBER_QUERY_WITH_LABEL_AND_ICON;
       
  1021                 }
       
  1022             else
       
  1023                 {
       
  1024                 resource = R_SATUI_HIDDEN_NUMBER_QUERY_WITHOUT_LABEL;
       
  1025                 }
       
  1026             }
       
  1027         // Normal number query
       
  1028         else
       
  1029             {
       
  1030             TFLOGSTRING( "CSatUiViewAppUi::GetInputL normal digit" ) 
       
  1031             if ( aIconBitmapGetInput )
       
  1032                 {
       
  1033                 resource = R_SATUI_NUMBER_QUERY_WITH_LABEL_AND_ICON;
       
  1034                 }
       
  1035             else
       
  1036                 {
       
  1037                 resource = R_SATUI_NUMBER_QUERY_WITHOUT_LABEL;
       
  1038                 }
       
  1039             }
       
  1040         }
       
  1041 
       
  1042     else // ESatCharSmsDefaultAlphabet or ESatCharUcs2Alphabet
       
  1043         {
       
  1044         TFLOGSTRING( "CSatUiViewAppUi::GetInputL ESatCharSmsDefaultAlphabet \
       
  1045             or ESatCharUcs2Alphabet" )
       
  1046         if ( aText.Length() == 0 )
       
  1047             {
       
  1048             if ( aGetInkey )
       
  1049                 {
       
  1050                 textResource = R_TEXT_SIMATK_ENTER_CHAR;
       
  1051                 }
       
  1052             else
       
  1053                 {
       
  1054                 textResource = R_TEXT_SIMATK_ENTER_CHAR_STRING;
       
  1055                 }
       
  1056             }
       
  1057         
       
  1058         if ( !aGetInkey )
       
  1059             {
       
  1060             iGetInputDialog->SetPredictiveTextInputPermitted( ETrue );
       
  1061             }
       
  1062 
       
  1063         iGetInputDialog->SetMaxLength( maxLength );
       
  1064 
       
  1065         if ( aIconBitmapGetInput )
       
  1066             {
       
  1067             resource = R_SATUI_TEXT_QUERY_WITH_LABEL_AND_ICON;
       
  1068             }
       
  1069         else
       
  1070             {
       
  1071             resource = R_SATUI_TEXT_QUERY_WITHOUT_LABEL;
       
  1072             }
       
  1073         }
       
  1074 
       
  1075     // Read default text if sim doesn't provide text to dialog 
       
  1076     if ( aText.Length() == 0 )
       
  1077         {
       
  1078         // Reads a resource string with memory allocation
       
  1079         // and pushes the string onto the cleanup stack.
       
  1080         textHolder = StringLoader::LoadLC( textResource, iCoeEnv);
       
  1081         textPtr.Set( *textHolder );       
       
  1082         }
       
  1083 
       
  1084     // Icon is used and command is get input
       
  1085     if ( aIconBitmapGetInput )
       
  1086         {
       
  1087         TFLOGSTRING( "CSatUiViewAppUi::GetInputL icon is used" )
       
  1088         iGetInputDialog->PrepareLC( resource );
       
  1089         if ( !aSelfExplanatory )
       
  1090             {
       
  1091             // Icon is not self-explanatory, show also text
       
  1092             iGetInputDialog->SetPromptL( textPtr );            
       
  1093             }
       
  1094         // Add icon to query
       
  1095         iGetInputDialog->QueryHeading()->SetHeaderImageL( image );
       
  1096         // Set MSK same as LSK without any text causing the icon drawing
       
  1097         iGetInputDialog->ButtonGroupContainer().SetCommandL(
       
  1098             CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknSoftkeyOk,
       
  1099             KSatEmptyDes );
       
  1100         userResponse = iGetInputDialog->RunLD();
       
  1101         TFLOGSTRING2( "CSatUiViewAppUi::GetInputL userResponse is: %d",
       
  1102             userResponse )                
       
  1103         }
       
  1104     // No icon in use
       
  1105     else
       
  1106         {
       
  1107         TFLOGSTRING( "CSatUiViewAppUi::GetInputL icon isn't used" )
       
  1108         iGetInputDialog->PrepareLC( resource );
       
  1109         iGetInputDialog->SetPromptL( textPtr );  
       
  1110         // Set MSK same as LSK without any text causing the icon drawing
       
  1111         iGetInputDialog->ButtonGroupContainer().SetCommandL(
       
  1112             CEikButtonGroupContainer::EMiddleSoftkeyPosition, EAknSoftkeyOk,
       
  1113             KSatEmptyDes );
       
  1114         userResponse = iGetInputDialog->RunLD();
       
  1115         TFLOGSTRING2( "CSatUiViewAppUi::GetInputL userResponse is: %d",
       
  1116             userResponse )                
       
  1117         }
       
  1118     iForegroundControl = NULL;
       
  1119 
       
  1120     if ( textHolder )
       
  1121         {
       
  1122         CleanupStack::PopAndDestroy( textHolder ); 
       
  1123         }
       
  1124 
       
  1125     if ( aDuration && aGetInkey )
       
  1126         {
       
  1127         TTime endTime;
       
  1128         endTime.HomeTime();
       
  1129         TTimeIntervalMicroSeconds timeDifference( 0 );
       
  1130         timeDifference = endTime.MicroSecondsFrom( startTime );
       
  1131         aDuration = timeDifference.Int64() / KMicroSecondsInTenthOfSecond;
       
  1132         
       
  1133         // After duration call back timer is destroyed
       
  1134         DestroyCallBackTimer();
       
  1135         }
       
  1136 
       
  1137     CleanupStack::PopAndDestroy( image );
       
  1138     CleanupStack::PopAndDestroy( activityManager ); // image, activityManager
       
  1139     iGetInputDialog = NULL;
       
  1140 
       
  1141     if ( iNoResponseFromUserAfterDelay )
       
  1142         {
       
  1143         TFLOGSTRING( "CSatUiViewAppUi::GetInputL no response from user" )
       
  1144         response = ESatNoResponseFromUser;
       
  1145         }
       
  1146     else if ( userResponse )
       
  1147         {
       
  1148         TFLOGSTRING( "CSatUiViewAppUi::GetInputL successful response" )
       
  1149         if ( inputPtr.Length() )
       
  1150             {
       
  1151             aInput.Copy( inputPtr );
       
  1152             }
       
  1153         response = ESatSuccess;
       
  1154         }
       
  1155     else
       
  1156         {
       
  1157         if ( IsAppShutterRunning() )
       
  1158             {
       
  1159             TFLOGSTRING( "CSatUiViewAppUi::GetInputL satsession \
       
  1160                 terminated by user " )
       
  1161             response = ESatSessionTerminatedByUser;
       
  1162             iSessionTerminated = ETrue;
       
  1163             }
       
  1164         else
       
  1165             {
       
  1166             TFLOGSTRING( "CSatUiViewAppUi::GetInputL backward \
       
  1167                 requested by user " )
       
  1168             response = ESatBackwardModeRequestedByUser;
       
  1169             }
       
  1170         }
       
  1171 
       
  1172     iNoResponseFromUserAfterDelay = EFalse;
       
  1173     
       
  1174     CleanupStack::PopAndDestroy( input ); // input
       
  1175 
       
  1176     ShowWaitNoteL();
       
  1177 
       
  1178     TFLOGSTRING2( "CSatUiViewAppUi::GetInputL exit, return: %d", response )
       
  1179     return response;
       
  1180     }
       
  1181 
       
  1182 // ---------------------------------------------------------
       
  1183 // CSatUiViewAppUi::SetUpMenuL
       
  1184 // Sets the parameters for SetUpMenu view and calls the method
       
  1185 // from the CSatUiView class.
       
  1186 // (other items were commented in a header).
       
  1187 // ---------------------------------------------------------
       
  1188 //
       
  1189 TSatUiResponse CSatUiViewAppUi::SetUpMenuL(
       
  1190     const TDesC& aText,
       
  1191     const MDesCArray& aMenuItems,
       
  1192     const CArrayFixFlat<TSatAction>* aMenuItemNextActions,
       
  1193     const CFbsBitmap* aIconBitmap,
       
  1194     const CAknIconArray* aItemsIconArray,
       
  1195     const TBool aSelfExplanatoryItems,
       
  1196     const TBool aHelpIsAvailable )
       
  1197     {
       
  1198     TFLOGSTRING( "CSatUiViewAppUi::SetUpMenuL called" )
       
  1199     StopShowWaitNote();
       
  1200     TSatUiResponse response( ESatSuccess );
       
  1201 
       
  1202     delete iTitle;
       
  1203     iTitle = NULL;
       
  1204 
       
  1205     delete iAppName;
       
  1206     iAppName = NULL;
       
  1207 
       
  1208     TFLOGSTRING2( "CSatUiViewAppUi::SetUpMenuL length of aText %d", \
       
  1209         aText.Length() )
       
  1210     if ( aText.Length() > 0 )
       
  1211         {
       
  1212         iTitle = aText.AllocL();
       
  1213         iAppName = aText.AllocL();
       
  1214         } 
       
  1215     else
       
  1216         {
       
  1217         //Reads a resource string with memory allocation
       
  1218         iTitle = StringLoader::LoadL( R_QTN_SAT_TITLE, iCoeEnv );
       
  1219         }
       
  1220 
       
  1221     if ( iSetUpMenuFirst )
       
  1222         {
       
  1223         iSetUpMenuFirst = EFalse;
       
  1224         iSetUpMenuView = CSatUiView::NewL( ETrue, this, EFalse );
       
  1225 
       
  1226         // transfer ownership to CAknViewAppUi:
       
  1227         AddViewL( iSetUpMenuView );
       
  1228 
       
  1229         iSetUpMenuView->SetAdapter( iAdapter );
       
  1230         }
       
  1231 
       
  1232     // Make list box visible.
       
  1233     iSetUpMenuView->MakeListBoxVisible( ETrue );
       
  1234         
       
  1235     //set contextpane icon and item icons
       
  1236     iSetUpMenuView->SetIconL( aIconBitmap );
       
  1237     iSetUpMenuView->SetItemsIconL( aItemsIconArray, aSelfExplanatoryItems );    
       
  1238     iSetUpMenuView->SetTitle( iTitle );
       
  1239 
       
  1240     response = iSetUpMenuView->SetUpMenuL( iTitle, aMenuItems,
       
  1241         aMenuItemNextActions, aHelpIsAvailable );
       
  1242 
       
  1243     iActiveView = KSetUpMenuViewId;
       
  1244     
       
  1245     // Reset counter for detecting possible loop in HandleForegroundEventL.
       
  1246     iViewLoopCounter = 0;
       
  1247 
       
  1248     TFLOGSTRING2( "CSatUiViewAppUi::SetUpMenuL exit, return: %d", response )
       
  1249     return response;
       
  1250     }
       
  1251 
       
  1252 // ---------------------------------------------------------
       
  1253 // CSatUiViewAppUi::HandleForegroundEventL
       
  1254 // Called when satui is brought to foreground or put into
       
  1255 // background
       
  1256 // (other items were commented in a header).
       
  1257 // ---------------------------------------------------------
       
  1258 //
       
  1259 void CSatUiViewAppUi::HandleForegroundEventL( TBool aForeground )
       
  1260     {
       
  1261     TFLOGSTRING2( "CSatUiViewAppUi::HandleForegroundEventL called \
       
  1262         value %d", aForeground )
       
  1263     
       
  1264     iForeground = aForeground;
       
  1265     
       
  1266     // Check whether it is only need to display a dialog. 
       
  1267     if ( iForeground && ( iForegroundControl || iCcNote ) ) 
       
  1268         {
       
  1269         TFLOGSTRING( "CSatUiViewAppUi::HandleForegroundEventL \
       
  1270             need to display a dialog" )
       
  1271         if ( iForegroundControl && ForegroundAlive() )
       
  1272             {
       
  1273             iForegroundControl->SetFocus( ETrue, EDrawNow );
       
  1274             }
       
  1275         }
       
  1276     // Check is it allowed to activate local view.
       
  1277     // Removes possibility of view activation loop for example when
       
  1278     // launching Browser.
       
  1279     else if ( ViewActivationAllowed( aForeground, iActiveView ) )
       
  1280         {
       
  1281         TFLOGSTRING( "CSatUiViewAppUi::HandleForegroundEventL \
       
  1282             activate local view allowed" )
       
  1283         TVwsViewId viewId;
       
  1284         GetActiveViewId( viewId );
       
  1285         TFLOGSTRING2( "CSatUiViewAppUi::HandleForegroundEventL called \
       
  1286             appUid %x", viewId.iAppUid )
       
  1287         TFLOGSTRING2( "CSatUiViewAppUi::HandleForegroundEventL called \
       
  1288             viewUid %x", viewId.iViewUid )
       
  1289             
       
  1290         if( ( KUidSATUI != viewId.iAppUid ) || 
       
  1291             ( ( KUidSATUI == viewId.iAppUid ) 
       
  1292                 && ( viewId.iViewUid != iActiveView ) ) )
       
  1293             {       
       
  1294             TFLOGSTRING( "CSatUiViewAppUi::HandleForegroundEventL \
       
  1295                 activate local view executing" )
       
  1296             if ( KSetUpMenuViewId == iActiveView )
       
  1297                 {
       
  1298                 ActivateLocalViewL( KSetUpMenuViewId );
       
  1299                 }
       
  1300             else
       
  1301                 {
       
  1302                 ActivateLocalViewL( KSelectItemViewId );
       
  1303                 }
       
  1304             }
       
  1305             
       
  1306         }        
       
  1307     // Forwards event to the base class.
       
  1308     CAknViewAppUi::HandleForegroundEventL( aForeground );
       
  1309     TFLOGSTRING( "CSatUiViewAppUi::HandleForegroundEventL exit" )
       
  1310     }
       
  1311     
       
  1312 // ---------------------------------------------------------
       
  1313 // CSatUiViewAppUi::ViewActivationAllowed
       
  1314 // Sets the parameters for SelectItem view and calls the method
       
  1315 // from the CSatUiView class.
       
  1316 // (other items were commented in a header).
       
  1317 // ---------------------------------------------------------
       
  1318 //    
       
  1319 TBool CSatUiViewAppUi::ViewActivationAllowed( const TBool aForeground, 
       
  1320     const TUid  aActiveView )
       
  1321     {
       
  1322 
       
  1323     TFLOGSTRING( "CSatUiViewAppUi::ViewActivationAllowed called" )
       
  1324     TBool activationAllowed( EFalse );
       
  1325     // Value for detecting view activation loop. 
       
  1326     const TInt certainViewLoopCount( 6 );
       
  1327     
       
  1328     // Check for foreground event, background event, 
       
  1329     // foreground event, background event, ... sequence.
       
  1330     if ( aForeground ^ iPreviousForeground )
       
  1331         {
       
  1332         TFLOGSTRING( "CSatUiViewAppUi::ViewActivationAllowed \
       
  1333             check foreground event" )
       
  1334         iViewLoopCounter++;
       
  1335         }
       
  1336     else
       
  1337         {
       
  1338         TFLOGSTRING( "CSatUiViewAppUi::ViewActivationAllowed \
       
  1339             no foreground event" )
       
  1340         iViewLoopCounter = 0;
       
  1341         }
       
  1342     
       
  1343     // Store information is application in foreground or
       
  1344     // in background for next evaluation round.  
       
  1345     iPreviousForeground = aForeground;
       
  1346 
       
  1347     // Check that there is no loop.
       
  1348     if ( aForeground && aActiveView.iUid ) 
       
  1349         {
       
  1350         if ( iViewLoopCounter < certainViewLoopCount )
       
  1351             {
       
  1352             TFLOGSTRING( "CSatUiViewAppUi::ViewActivationAllowed \
       
  1353                 there are loops" )
       
  1354             activationAllowed = ETrue;    
       
  1355             }
       
  1356         else
       
  1357             {
       
  1358             TFLOGSTRING( "CSatUiViewAppUi::ViewActivationAllowed \
       
  1359                 no loop" )
       
  1360             // Counter is reset in case of foreground event
       
  1361             // because of background event does not draw anything.
       
  1362             iViewLoopCounter = 0;
       
  1363             }
       
  1364         
       
  1365         }
       
  1366 
       
  1367     if ( iDisplayTextDialog || iDisplayTextIconDialog )
       
  1368         {
       
  1369         activationAllowed = EFalse;
       
  1370         }
       
  1371         
       
  1372     TFLOGSTRING2( "CSatUiViewAppUi::ViewActivationAllowed exit, return: %d",\
       
  1373         activationAllowed )
       
  1374     return activationAllowed;
       
  1375     
       
  1376     }
       
  1377 
       
  1378 // ---------------------------------------------------------
       
  1379 // CSatUiViewAppUi::SelectItemL
       
  1380 // Sets the parameters for SelectItem view and calls the method
       
  1381 // from the CSatUiView class.
       
  1382 // (other items were commented in a header).
       
  1383 // ---------------------------------------------------------
       
  1384 //
       
  1385 TSatUiResponse CSatUiViewAppUi::SelectItemL(
       
  1386     const TDesC& aText,
       
  1387     const MDesCArray& aMenuItems,
       
  1388     const CArrayFixFlat<TSatAction>* aMenuItemNextActions,
       
  1389     const TInt aDefaultItem,
       
  1390     TUint8& aSelection,
       
  1391     const CFbsBitmap* aIconBitmap,
       
  1392     const CAknIconArray* aItemsIconArray,
       
  1393     const TBool aSelfExplanatoryItems,
       
  1394     const TBool aHelpIsAvailable )
       
  1395     {
       
  1396     TFLOGSTRING( "CSatUiViewAppUi::SelectItemL called" )
       
  1397     StopShowWaitNote();
       
  1398 
       
  1399     TSatUiResponse response( ESatSuccess );
       
  1400 
       
  1401     delete iTitle;
       
  1402     iTitle = NULL;
       
  1403 
       
  1404     TFLOGSTRING2( "CSatUiViewAppUi::SelectItemL length of aText %d",
       
  1405         aText.Length() )
       
  1406     if ( aText.Length() > 0 )
       
  1407         {
       
  1408         iTitle = aText.AllocL();
       
  1409         } 
       
  1410     else if ( iAppName )
       
  1411         {
       
  1412         TFLOGSTRING( "CSatUiViewAppUi::SelectItemL there is appname" )
       
  1413         iTitle = iAppName->AllocL();
       
  1414         }
       
  1415     else
       
  1416         {
       
  1417         TFLOGSTRING( "CSatUiViewAppUi::SelectItemL read appname" )
       
  1418         //Reads a resource string with memory allocation
       
  1419         iTitle = StringLoader::LoadL( R_QTN_SAT_TITLE, iCoeEnv );
       
  1420         } 
       
  1421 
       
  1422     if ( iSelectItemFirst )
       
  1423         {
       
  1424         iSelectItemFirst = EFalse;
       
  1425         iSelectItemView = CSatUiView::NewL( EFalse, this, EFalse );
       
  1426 
       
  1427         // transfer ownership to CAknViewAppUi:
       
  1428         AddViewL( iSelectItemView );
       
  1429         }
       
  1430                 
       
  1431     iSelectItemPending = ETrue;
       
  1432     iActiveView = KSelectItemViewId;
       
  1433 
       
  1434     //set contextpane icon and item icons
       
  1435     iSelectItemView->SetIconL( aIconBitmap );
       
  1436     iSelectItemView->SetItemsIconL( aItemsIconArray, aSelfExplanatoryItems );
       
  1437     response = iSelectItemView->SelectItemL( iTitle, aMenuItems,
       
  1438         aMenuItemNextActions, aDefaultItem, aSelection, aHelpIsAvailable );
       
  1439 
       
  1440     iSelectItemPending = EFalse;
       
  1441 
       
  1442     if ( iEndKeyPressed )
       
  1443         {
       
  1444         response = ESatSessionTerminatedByUser;
       
  1445         }
       
  1446 
       
  1447     if ( response != ESatSessionTerminatedByUser )
       
  1448         {
       
  1449         ShowWaitNoteL();
       
  1450         }
       
  1451 
       
  1452     TFLOGSTRING2( "CSatUiViewAppUi::SelectItemL exit, return: %d", response )
       
  1453     return response;
       
  1454     }
       
  1455 
       
  1456 // ---------------------------------------------------------
       
  1457 // CSatUiViewAppUi::MatoPrepareComplete
       
  1458 // Indicates success or failure.
       
  1459 // (other items were commented in a header).
       
  1460 // ---------------------------------------------------------
       
  1461 //
       
  1462 void CSatUiViewAppUi::MatoPrepareComplete(TInt aError)
       
  1463     {
       
  1464     TFLOGSTRING( "CSatUiViewAppUi::MatoPrepareComplete called" )
       
  1465     TFLOGSTRING2( "CSatUiViewAppUi::MatoPrepareComplete error %i", aError )
       
  1466     if ( KErrNone == aError )
       
  1467         {
       
  1468         iPlayToneError = ESatSuccess;
       
  1469 
       
  1470         TTimeIntervalMicroSeconds zero( static_cast<TInt64>( 0 ) );
       
  1471 
       
  1472         iPlayer->SetPriority( KAudioPriorityLowLevel,
       
  1473                STATIC_CAST( TMdaPriorityPreference, KAudioPrefConfirmation ) );
       
  1474 
       
  1475         iPlayer->SetRepeats( KMdaAudioToneRepeatForever, zero );
       
  1476 
       
  1477         iPlayer->Play();
       
  1478         }
       
  1479     else
       
  1480         {
       
  1481         iPlayToneError = ESatFailure;
       
  1482         }
       
  1483     TFLOGSTRING( "CSatUiViewAppUi::MatoPrepareComplete exit" )
       
  1484     }
       
  1485 
       
  1486 // ---------------------------------------------------------
       
  1487 // CSatUiViewAppUi::MatoPlayComplete
       
  1488 // Indicates success or failure.
       
  1489 // (other items were commented in a header).
       
  1490 // ---------------------------------------------------------
       
  1491 //
       
  1492 void CSatUiViewAppUi::MatoPlayComplete( TInt aError )
       
  1493     {
       
  1494     TFLOGSTRING( "CSatUiViewAppUi::MatoPlayComplete calling" )
       
  1495     if ( KErrNone == aError && iPlayer )
       
  1496         {
       
  1497         TFLOGSTRING( "CSatUiViewAppUi::MatoPlayComplete play" )
       
  1498         iPlayer->Play();
       
  1499         }
       
  1500     else if ( iWait && iWait->IsStarted() )
       
  1501         {
       
  1502         TFLOGSTRING( "CSatUiViewAppUi::MatoPlayComplete stop playing" )
       
  1503         // Stops playing if error.
       
  1504         iWait->AsyncStop();
       
  1505         }
       
  1506     TFLOGSTRING2( "CSatUiViewAppUi::MatoPlayComplete exit, error %i", aError )
       
  1507     }
       
  1508 
       
  1509 // ---------------------------------------------------------
       
  1510 // CSatUiViewAppUi::PlayStandardToneL
       
  1511 // Plays Standard Tone. If needed displays the text in a note
       
  1512 // while playing.
       
  1513 // (other items were commented in a header).
       
  1514 // ---------------------------------------------------------
       
  1515 //
       
  1516 TSatUiResponse CSatUiViewAppUi::PlayStandardToneL(
       
  1517     const TDesC& aText,
       
  1518     const TDesC8& aSequence,
       
  1519     TTimeIntervalMicroSeconds aDuration,
       
  1520     const CFbsBitmap* aIconBitmap,
       
  1521     const TBool aSelfExplanatory )
       
  1522     {
       
  1523     TFLOGSTRING( "CSatUiViewAppUi::PlayStandardToneL called" )
       
  1524     StopShowWaitNote();
       
  1525     // Delete timer just in case e.g. if DisplayText was on the screen
       
  1526     DestroyCallBackTimer();
       
  1527 
       
  1528     iPermanentNote = NULL;
       
  1529     iTimerRepeatOn = EFalse;
       
  1530     
       
  1531     TFLOGSTRING2( "CSatUiViewAppUi::PlayStandardToneL length of aText %i", \
       
  1532         aText.Length() )
       
  1533     if (aText.Length() != 0)
       
  1534         {
       
  1535         iPermanentNote = new (ELeave) CAknStaticNoteDialog();
       
  1536         iPermanentNote->PrepareLC( R_SATUI_PERMANENT_NOTE );
       
  1537         
       
  1538         if ( ( !aSelfExplanatory ) || ( !aIconBitmap ) )
       
  1539             {
       
  1540             // Set text
       
  1541             iPermanentNote->SetTextL( aText );
       
  1542             }
       
  1543         
       
  1544         if ( aIconBitmap )
       
  1545             {
       
  1546             //Set image 
       
  1547             TFLOGSTRING( "CSatUiViewAppUi::PlayStandardToneL SetImage" )
       
  1548             // Get scalable bitmap if available.
       
  1549             CEikImage* image = new ( ELeave ) CEikImage();
       
  1550             CleanupStack::PushL( image );
       
  1551             image->SetBitmap( aIconBitmap ); 
       
  1552             iPermanentNote->SetImageL( image );
       
  1553             CleanupStack::Pop( image );
       
  1554             }
       
  1555         
       
  1556         iForegroundControl = iPermanentNote;
       
  1557         iPermanentNote->RunLD();
       
  1558         iPermanentNote->DrawNow();
       
  1559         iCoeEnv->WsSession().Flush();
       
  1560         }
       
  1561 
       
  1562     iPlayer = CMdaAudioToneUtility::NewL(*this);
       
  1563 
       
  1564     TInt volume( iPlayer->MaxVolume() );
       
  1565     iPlayer->SetVolume( volume );
       
  1566     TFLOGSTRING2( "CSatUiViewAppUi::PlayStandardToneL SetVolume %d",
       
  1567         volume )    
       
  1568 
       
  1569     iPlayer->PrepareToPlayDesSequence( aSequence );
       
  1570 
       
  1571     TTimeIntervalMicroSeconds max32Bit(
       
  1572         static_cast<TInt64>( K32TIntMaxValue ) );
       
  1573     
       
  1574     if ( aDuration > max32Bit )
       
  1575         {
       
  1576         // since timers can only handle 32-bit values,
       
  1577         // let's break the aDuration to smaller bits.
       
  1578         // we break it here to 8 bits to fit in 32-bit value
       
  1579         aDuration = aDuration.Int64() / KDivideByEight;
       
  1580         iTimerRepeatOn = ETrue;
       
  1581         }
       
  1582 
       
  1583     CreateCallBackTimerL( I64INT( aDuration.Int64() ), DelayCallback );
       
  1584 
       
  1585     if ( !iWait->IsStarted() )
       
  1586         {
       
  1587         TFLOGSTRING( "CSatUiViewAppUi::PlayStandardToneL starting iWait" )
       
  1588         iWait->Start();
       
  1589         TFLOGSTRING( "CSatUiViewAppUi::PlayStandardToneL strarting done" )
       
  1590         }
       
  1591 
       
  1592     iPlayer->CancelPlay();
       
  1593 
       
  1594     DestroyCallBackTimer();
       
  1595 
       
  1596     delete iPlayer;
       
  1597     iPlayer = NULL;
       
  1598     
       
  1599     if ( iPermanentNote )
       
  1600         {
       
  1601         iPermanentNote->ExitSleepingDialog();
       
  1602         delete iPermanentNote;
       
  1603         iPermanentNote = NULL;
       
  1604         }
       
  1605     iForegroundControl = NULL;
       
  1606     
       
  1607     if ( !iEndKeyPressed )
       
  1608         {
       
  1609         ShowWaitNoteL();
       
  1610         }
       
  1611     
       
  1612     //get warning and game tones setting from active profile
       
  1613     GetProfileParamsL();
       
  1614     
       
  1615     if( ( EFalse == iWarningAndPlayTones ) && 
       
  1616                         ( ESatSuccess == iPlayToneError  ) )
       
  1617         {
       
  1618         iPlayToneError = ESatSuccessToneNotPlayed;
       
  1619         }
       
  1620         
       
  1621     TFLOGSTRING2( "CSatUiViewAppUi::PlayStandardToneL exit,return: %d", \
       
  1622         iPlayToneError )
       
  1623     return iPlayToneError;
       
  1624     }
       
  1625 
       
  1626 // ---------------------------------------------------------
       
  1627 // CSatUiViewAppUi::ConfirmSendL
       
  1628 // Displays a query to get confirmation for Send SMS,
       
  1629 // Send SS or Send USSD command.
       
  1630 // (other items were commented in a header).
       
  1631 // ---------------------------------------------------------
       
  1632 //
       
  1633 TSatUiResponse CSatUiViewAppUi::ConfirmSendL(
       
  1634     const TDesC& /* aText */,
       
  1635     TBool& aActionAccepted,
       
  1636     TInt aType)
       
  1637     {
       
  1638     TFLOGSTRING2( "CSatUiViewAppUi::ConfirmSendL called, aType: %d", \
       
  1639         aType )
       
  1640     HBufC* textHolder = NULL;
       
  1641 
       
  1642     switch ( aType )
       
  1643         {
       
  1644         case ESatUiConfirmSendSms:
       
  1645             textHolder = StringLoader::LoadLC( R_TEXT_SIMATK_SEND_SMS,
       
  1646                 iCoeEnv );
       
  1647             break;
       
  1648         case ESatUiConfirmSendSs:
       
  1649         case ESatUiConfirmSendUssd: //the same string for SS and USSD
       
  1650             textHolder = StringLoader::LoadLC( R_TEXT_SIMATK_SEND_SS,
       
  1651                 iCoeEnv );
       
  1652             break;
       
  1653         default:
       
  1654             return ESatFailure;
       
  1655         }
       
  1656         
       
  1657     TInt userResponse = RunQueryDialogL( R_SATUI_CONFIRM_SEND_CANCEL_QUERY,
       
  1658         *textHolder, NULL, EFalse, ESatUiSoftkeySend );
       
  1659     
       
  1660     TFLOGSTRING2( "CSatUiViewAppUi::ConfirmSendL userResponse: %d", \
       
  1661         userResponse )
       
  1662     if ( userResponse )
       
  1663         {
       
  1664         aActionAccepted = ETrue;
       
  1665         }
       
  1666     else
       
  1667         {
       
  1668         aActionAccepted = EFalse;
       
  1669         }
       
  1670 
       
  1671     if ( textHolder )
       
  1672         {
       
  1673         CleanupStack::PopAndDestroy( textHolder ); //textHolder
       
  1674         }
       
  1675 
       
  1676     TFLOGSTRING( "CSatUiViewAppUi::ConfirmSendL return ESatSuccess" )
       
  1677     return ESatSuccess;
       
  1678     }
       
  1679 
       
  1680 // ---------------------------------------------------------
       
  1681 // CSatUiViewAppUi::ShowSmsWaitNoteL
       
  1682 // Displays a wait note to indicate SMS sending.
       
  1683 // (other items were commented in a header).
       
  1684 // ---------------------------------------------------------
       
  1685 //
       
  1686 void CSatUiViewAppUi::ShowSmsWaitNoteL( const TDesC& aText, 
       
  1687     const CFbsBitmap* aIconBitmapSendSM,
       
  1688     const TBool aSelfExplanatoryIcon )
       
  1689     {
       
  1690 
       
  1691     TFLOGSTRING( "CSatUiViewAppUi::ShowSmsWaitNoteL called" )
       
  1692     
       
  1693     iWaitNoteInUse = ETrue;
       
  1694     
       
  1695     TFLOGSTRING2( "CSatUiViewAppUi::ShowSmsWaitNoteL iWaitNote: %d", \
       
  1696         iWaitNote )
       
  1697     if ( NULL == iWaitNote )
       
  1698         {
       
  1699         iWaitNote = new(ELeave) CAknWaitDialog(
       
  1700             ( REINTERPRET_CAST( CEikDialog**, &iWaitNote ) ), ETrue );
       
  1701         iWaitNote->PrepareLC( R_SATUI_SMS_WAIT_NOTE );
       
  1702 
       
  1703         if ( ( aText.Length() > 0 ) && ( !aSelfExplanatoryIcon ||
       
  1704             !aIconBitmapSendSM ) )
       
  1705             {
       
  1706             //Set text
       
  1707             TFLOGSTRING( "CSatUiViewAppUi::ShowSmsWaitNoteL SetText" )
       
  1708             iWaitNote->SetTextL( aText );
       
  1709             }
       
  1710             
       
  1711         if ( aIconBitmapSendSM )
       
  1712             {
       
  1713             //Set image
       
  1714             TFLOGSTRING( "CSatUiViewAppUi::ShowSmsWaitNoteL SetImage" )
       
  1715             CEikImage* image = new ( ELeave ) CEikImage();
       
  1716             CleanupStack::PushL( image );
       
  1717             image->SetBitmap( aIconBitmapSendSM );               
       
  1718             iWaitNote->SetImageL( image );
       
  1719             CleanupStack::Pop( image );
       
  1720             }
       
  1721             
       
  1722         iForegroundControl = iWaitNote;
       
  1723         iWaitNote->RunLD();
       
  1724         // iForegroundControl won't be clear until the wait dialog
       
  1725         // closed. It will avoid we lose the chance to set focus for
       
  1726         // the wait dialog when the switch of foreground/background
       
  1727         // happened.
       
  1728         }
       
  1729         
       
  1730     TFLOGSTRING( "CSatUiViewAppUi::ShowSmsWaitNoteL exit" )
       
  1731     }
       
  1732 
       
  1733 // ---------------------------------------------------------
       
  1734 // CSatUiViewAppUi::ShowSsWaitNoteL
       
  1735 // Displays a wait note to indicate SS sending.
       
  1736 // (other items were commented in a header).
       
  1737 // ---------------------------------------------------------
       
  1738 //
       
  1739 void CSatUiViewAppUi::ShowSsWaitNoteL( const TDesC& aText, 
       
  1740     const CFbsBitmap* aIconBitmap,
       
  1741     const TBool aSelfExplanatoryIcon )
       
  1742     {
       
  1743     TFLOGSTRING( "CSatUiViewAppUi::ShowSsWaitNoteL called" )
       
  1744     
       
  1745     iWaitNoteInUse = ETrue;
       
  1746     
       
  1747     TFLOGSTRING2( "CSatUiViewAppUi::ShowSsWaitNoteL iWaitNote: %d", \
       
  1748         iWaitNote )
       
  1749     if ( !iWaitNote )
       
  1750         {
       
  1751         iWaitNote = new ( ELeave ) CSatUiWaitDialog( 
       
  1752             ( REINTERPRET_CAST ( CEikDialog**,&iWaitNote ) ), 
       
  1753             *iAdapter, ETrue );
       
  1754         iForegroundControl = iWaitNote;
       
  1755         
       
  1756         TFLOGSTRING2( "CSatUiViewAppUi::ShowSsWaitNoteL length of aText: %d",\
       
  1757             aText.Length() )
       
  1758         // if there is an alpha id
       
  1759         if ( aText.Length() > 0 )
       
  1760             {
       
  1761             // if there is not an icon or it's not self explanatory
       
  1762             if ( ( !aSelfExplanatoryIcon ) || ( !aIconBitmap ) )
       
  1763                 {
       
  1764                 iWaitNote->SetTextL( aText );
       
  1765                 }
       
  1766             
       
  1767             if ( aIconBitmap )
       
  1768                 {
       
  1769                 //Set image
       
  1770                 TFLOGSTRING( "CSatUiViewAppUi::ShowSsWaitNoteL SetImage" )
       
  1771                 CEikImage* image = new ( ELeave ) CEikImage();
       
  1772                 CleanupStack::PushL( image );
       
  1773                 image->SetBitmap( aIconBitmap );
       
  1774                 iWaitNote->SetImageL( image );
       
  1775                 CleanupStack::Pop( image );
       
  1776                 }
       
  1777                 
       
  1778             iWaitNote->ExecuteLD( R_SATUI_SS_WAIT_NOTE );
       
  1779             }
       
  1780         else
       
  1781             {
       
  1782             iWaitNote->ExecuteLD( R_SATUI_REQUESTING_WAIT_NOTE );    
       
  1783             }
       
  1784         // iForegroundControl won't be clear until the wait dialog
       
  1785         // closed. It will avoid we lose the chance to set focus for
       
  1786         // the wait dialog when the switch of foreground/background
       
  1787         // happened.
       
  1788         }
       
  1789     TFLOGSTRING( "CSatUiViewAppUi::ShowSsWaitNoteL exit" )
       
  1790     }
       
  1791 
       
  1792 // ---------------------------------------------------------
       
  1793 // CSatUiViewAppUi::ShowDtmfWaitNoteL
       
  1794 // Shows a wait note while DTMF are being sent.
       
  1795 // (other items were commented in a header).
       
  1796 // ---------------------------------------------------------
       
  1797 //
       
  1798 TSatUiResponse CSatUiViewAppUi::ShowDtmfWaitNoteL( const TDesC& aText, 
       
  1799     const CFbsBitmap* aIconBitmap,
       
  1800     const TBool aSelfExplanatoryIcon )
       
  1801     {
       
  1802     TFLOGSTRING( "CSatUiViewAppUi::ShowDtmfWaitNoteL called" )
       
  1803     TSatUiResponse response(ESatFailure);
       
  1804 
       
  1805     iWaitNoteInUse = ETrue;
       
  1806     
       
  1807     TFLOGSTRING2( "CSatUiViewAppUi::ShowDtmfWaitNoteL iWaitNote: %d", \
       
  1808         iWaitNote )
       
  1809     if ( !iWaitNote )
       
  1810         {
       
  1811         iWaitNote = new ( ELeave ) CSatUiWaitDialog(
       
  1812             (REINTERPRET_CAST( CEikDialog**,&iWaitNote ) ), *iAdapter, ETrue );
       
  1813         
       
  1814         if ( ( aText.Length() > 0 ) &&
       
  1815             ( ( !aSelfExplanatoryIcon ) || ( !aIconBitmap ) ) )
       
  1816             {
       
  1817             iWaitNote->SetTextL( aText );
       
  1818             }
       
  1819             
       
  1820         if ( aIconBitmap )
       
  1821             {
       
  1822             //Set image
       
  1823             TFLOGSTRING( "CSatUiViewAppUi::ShowDtmfWaitNoteL SetImage" )
       
  1824             CEikImage* image = new ( ELeave ) CEikImage();
       
  1825             CleanupStack::PushL( image );
       
  1826             image->SetBitmap( aIconBitmap ); 
       
  1827             iWaitNote->SetImageL( image );
       
  1828             CleanupStack::Pop( image );
       
  1829             }
       
  1830         
       
  1831         iForegroundControl = iWaitNote;
       
  1832         iWaitNote->ExecuteLD( R_SATUI_DTMF_WAIT_NOTE );
       
  1833         // iForegroundControl won't be clear until the wait dialog
       
  1834         // closed. It will avoid we lose the chance to set focus for
       
  1835         // the wait dialog when the switch of foreground/background
       
  1836         // happened.
       
  1837         response = ESatSuccess;
       
  1838         }
       
  1839     TFLOGSTRING2( "CSatUiViewAppUi::ShowDtmfWaitNoteL exit, return: %d",\
       
  1840         response )
       
  1841     return response;
       
  1842     }
       
  1843 
       
  1844 // ---------------------------------------------------------
       
  1845 // CSatUiViewAppUi::ConfirmRefreshL
       
  1846 // Displays a query to get confirmation Refresh command.
       
  1847 // (other items were commented in a header).
       
  1848 // ---------------------------------------------------------
       
  1849 //
       
  1850 TSatUiResponse CSatUiViewAppUi::ConfirmRefreshL(TBool& aActionAccepted)
       
  1851     {
       
  1852     TFLOGSTRING( "CSatUiViewAppUi::ConfirmRefreshL called" )
       
  1853     StopShowWaitNote();
       
  1854 
       
  1855     TSatUiResponse response( ESatSuccess );
       
  1856 
       
  1857     HBufC* textHolder = NULL;
       
  1858 
       
  1859     textHolder = StringLoader::LoadLC( R_QTN_SAT_QUERY_ALLOW_RESET,
       
  1860             iCoeEnv );
       
  1861             
       
  1862     TInt userResponse = RunQueryDialogL( R_SATUI_CONFIRM_OK_CANCEL_QUERY,
       
  1863         *textHolder, NULL, EFalse, EAknSoftkeyOk );
       
  1864     
       
  1865     TFLOGSTRING2( "CSatUiViewAppUi::ConfirmRefreshL userResponse: %d", \
       
  1866         userResponse )
       
  1867     if ( userResponse )
       
  1868         {
       
  1869         aActionAccepted = ETrue;
       
  1870         }
       
  1871     else
       
  1872         {
       
  1873         aActionAccepted = EFalse;
       
  1874         }
       
  1875 
       
  1876     if ( textHolder )
       
  1877         {
       
  1878         CleanupStack::PopAndDestroy( textHolder ); //textHolder
       
  1879         }
       
  1880 
       
  1881     ShowWaitNoteL();
       
  1882 
       
  1883     TFLOGSTRING2( "CSatUiViewAppUi::ConfirmRefreshL exit, return: %d",\
       
  1884         response )
       
  1885     return response;
       
  1886     }
       
  1887 
       
  1888 // ---------------------------------------------------------
       
  1889 // CSatUiViewAppUi::CallControlL
       
  1890 // Displays info about call control to user
       
  1891 // (other items were commented in a header).
       
  1892 // ---------------------------------------------------------
       
  1893 //
       
  1894 TSatUiResponse CSatUiViewAppUi::CallControlL(
       
  1895     const TDesC& aText,
       
  1896     const TSatAlphaIdStatus aAlphaIdStatus )
       
  1897     {
       
  1898     TFLOGSTRING( "CSatUiViewAppUi::CallControlL called" )
       
  1899     
       
  1900     if ( !iCcNote ) 
       
  1901         {
       
  1902         iCcNote = CAknGlobalNote::NewL();
       
  1903         }
       
  1904     iCcNote->SetTone( CAknNoteDialog::ENoTone );
       
  1905     
       
  1906     if ( ESatAlphaIdNotNull == aAlphaIdStatus )
       
  1907         {
       
  1908         TFLOGSTRING( "CSatUiViewAppUi::CallControlL AlphaIdNotNull" )
       
  1909         
       
  1910         // The note will be disabled by the phone UI when the call is 
       
  1911         // in connecting status. But call controll case is an exception, So we
       
  1912         // use RAknKeyLock to enable soft notifications.
       
  1913         RAknKeyLock keyLock;
       
  1914         TInt errorCode = keyLock.Connect();
       
  1915         TFLOGSTRING2( "CSatUiViewAppUi::CallControlL connect error %d", \
       
  1916             errorCode )
       
  1917         if ( KErrNone == errorCode )
       
  1918             {
       
  1919             keyLock.EnableSoftNotifications( ETrue );
       
  1920             }
       
  1921         keyLock.Close();
       
  1922         
       
  1923         iCcNote->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY );
       
  1924         iCcNoteId = iCcNote->ShowNoteL( 
       
  1925                                        EAknGlobalInformationNote, aText );
       
  1926         CreateCallBackTimerL( K3Seconds, CloseCallControlNoteL );
       
  1927         if ( iWait && !iWait->IsStarted() )
       
  1928             {
       
  1929             TFLOGSTRING( "CSatUiViewAppUi::CallControlL iWait starting" )
       
  1930             iWait->Start();
       
  1931             }
       
  1932         DestroyCallBackTimer();
       
  1933         }
       
  1934     else
       
  1935         {
       
  1936         TFLOGSTRING( "CSatUiViewAppUi::CallControlL AlphaId Null" )
       
  1937         iCcNote->ShowNoteL( EAknGlobalInformationNote, aText );
       
  1938         }
       
  1939 
       
  1940     if ( iCcNote )
       
  1941         {
       
  1942         delete iCcNote;
       
  1943         iCcNote = NULL;
       
  1944         }
       
  1945     TFLOGSTRING( "CSatUiViewAppUi::CallControlL exit" )
       
  1946     
       
  1947     return ESatSuccess;
       
  1948     }
       
  1949 
       
  1950 // ---------------------------------------------------------
       
  1951 // CSatUiViewAppUi::MoSmControlL
       
  1952 // Displays info about Mo SM control to user
       
  1953 // (other items were commented in a header).
       
  1954 // ---------------------------------------------------------
       
  1955 //
       
  1956 TSatUiResponse CSatUiViewAppUi::MoSmControlL(
       
  1957     const TDesC& aText,
       
  1958     const TSatAlphaIdStatus aAlphaIdStatus )
       
  1959     {
       
  1960     TFLOGSTRING( "CSatUiViewAppUi::MoSmControlL called" )
       
  1961     if ( ESatAlphaIdNotNull == aAlphaIdStatus )
       
  1962         {
       
  1963         TFLOGSTRING( "CSatUiViewAppUi::MoSmControlL AlphaIdNotNull" )
       
  1964         CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog(
       
  1965             REINTERPRET_CAST( CEikDialog**,&dialog ),
       
  1966             CAknNoteDialog::ENoTone,
       
  1967             CAknNoteDialog::ELongTimeout );
       
  1968 
       
  1969         dialog->PrepareLC( R_SATUI_MOSM_CONTROL_NOTE );
       
  1970 
       
  1971         dialog->SetTextL( aText );
       
  1972 
       
  1973         iForegroundControl = dialog;
       
  1974         dialog->RunLD();
       
  1975         }
       
  1976     else
       
  1977         {
       
  1978         TFLOGSTRING( "CSatUiViewAppUi::MoSmControlL AlphaId Null" )
       
  1979         CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog(
       
  1980             REINTERPRET_CAST( CEikDialog**,&dialog ),
       
  1981             CAknNoteDialog::ENoTone,
       
  1982             CAknNoteDialog::ELongTimeout );
       
  1983 
       
  1984         dialog->PrepareLC( R_SATUI_INFORMATION_NOTE );
       
  1985 
       
  1986         dialog->SetTextL( aText );
       
  1987 
       
  1988         iForegroundControl = dialog;
       
  1989         dialog->RunLD();
       
  1990         }
       
  1991     iForegroundControl = NULL;
       
  1992     TFLOGSTRING( "CSatUiViewAppUi::MoSmControlL exit" )
       
  1993     return ESatSuccess;
       
  1994     }
       
  1995 
       
  1996 // ---------------------------------------------------------
       
  1997 // CSatUiViewAppUi::ConfirmLaunchBrowserL
       
  1998 // Displays a query to get confirmation for Launch Browser
       
  1999 // (other items were commented in a header).
       
  2000 // ---------------------------------------------------------
       
  2001 //
       
  2002 void CSatUiViewAppUi::ConfirmLaunchBrowserL(
       
  2003     const TDesC& aText,
       
  2004     TBool& aActionAccepted,
       
  2005     const CFbsBitmap* aIconBitmap,
       
  2006     const TBool aSelfExplanatory )
       
  2007     {
       
  2008     TFLOGSTRING( "CSatUiViewAppUi::ConfirmLaunchBrowserL called" )
       
  2009     
       
  2010     TInt resource( 0 );
       
  2011     
       
  2012     if ( aIconBitmap )
       
  2013         {
       
  2014         TFLOGSTRING( "CSatUiViewAppUi::ConfirmLaunchBrowserL icon" )
       
  2015         resource = R_SATUI_CONFIRM_OK_CANCEL_QUERY_WITH_ICON;
       
  2016         }
       
  2017     else
       
  2018         {
       
  2019         TFLOGSTRING( "CSatUiViewAppUi::ConfirmLaunchBrowserL no icon" )
       
  2020         resource = R_SATUI_CONFIRM_OK_CANCEL_QUERY;
       
  2021         }
       
  2022         
       
  2023     TInt userResponse = RunQueryDialogL( resource, aText, aIconBitmap,
       
  2024         aSelfExplanatory, EAknSoftkeyOk ); 
       
  2025     
       
  2026     TFLOGSTRING2( "CSatUiViewAppUi::ConfirmLaunchBrowserL userResponse %d",\
       
  2027         userResponse )
       
  2028     if ( userResponse )
       
  2029         {
       
  2030         aActionAccepted = ETrue;
       
  2031         }
       
  2032     else
       
  2033         {
       
  2034         aActionAccepted = EFalse;
       
  2035         }
       
  2036         
       
  2037     TFLOGSTRING( "CSatUiViewAppUi::ConfirmLaunchBrowserL exit" )
       
  2038     }
       
  2039 
       
  2040 // ---------------------------------------------------------
       
  2041 // CSatUiViewAppUi::HandleCommandL
       
  2042 // Called by CSatUiView::HandleCommandL.
       
  2043 // (other items were commented in a header).
       
  2044 // ---------------------------------------------------------
       
  2045 //
       
  2046 void CSatUiViewAppUi::HandleCommandL(
       
  2047     TInt aCommand )
       
  2048     {
       
  2049     TFLOGSTRING2( "CSatUiViewAppUi::HandleCommandL called, aCommand: %d",\
       
  2050         aCommand )
       
  2051     switch ( aCommand )
       
  2052         {
       
  2053         case EEikCmdExit:
       
  2054             {
       
  2055             HandleExitCommandL();
       
  2056             break;
       
  2057             }
       
  2058         case EAknCmdHelp:
       
  2059             {
       
  2060             //Show Series 60 Help
       
  2061             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
       
  2062                                                 AppHelpContextL() );
       
  2063             break;
       
  2064             }
       
  2065         default: 
       
  2066             break;
       
  2067         }
       
  2068     TFLOGSTRING( "CSatUiViewAppUi::HandleCommandL exit" )
       
  2069     }
       
  2070 
       
  2071 // ---------------------------------------------------------
       
  2072 // CSatUiViewAppUi::HandleExitCommandL
       
  2073 // Handling of the exit softkey.
       
  2074 // (other items were commented in a header).
       
  2075 // ---------------------------------------------------------
       
  2076 //
       
  2077 void CSatUiViewAppUi::HandleExitCommandL()
       
  2078     {
       
  2079     TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL called" )
       
  2080   
       
  2081     if ( iBipWaitNote )
       
  2082         {
       
  2083         TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL iBipWaitNote" )
       
  2084         SetCommandPending( EFalse );
       
  2085         }
       
  2086 
       
  2087     if ( iWait )
       
  2088         {
       
  2089         TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL iWait " )
       
  2090         if ( iWait->IsStarted() )
       
  2091             {
       
  2092             TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL \
       
  2093                 iWait->AsyncStop()" )
       
  2094             iWait->AsyncStop();
       
  2095             }
       
  2096         }
       
  2097 
       
  2098     CloseDialogs();
       
  2099 
       
  2100     if ( iEndKeyPressed )
       
  2101         {
       
  2102         TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL endkeypressed" )
       
  2103         // Inform SAT Server that end key has been pressed
       
  2104         iAdapter->SessionTerminated( EEndKeyUsed );        
       
  2105         }
       
  2106 
       
  2107     if ( !iCommandPending )
       
  2108         {
       
  2109         TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL !iCommandPending" )
       
  2110 
       
  2111         if ( iPlayer && EMdaAudioToneUtilityPlaying == iPlayer->State() )
       
  2112             {
       
  2113             TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL cancel playtone")
       
  2114             iPlayer->CancelPlay();
       
  2115             }
       
  2116             
       
  2117         if ( iAudioPlayer )
       
  2118             {
       
  2119             TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL cancel \
       
  2120                 userselected tone" )
       
  2121             iAudioPlayer->Stop();
       
  2122             delete iAudioPlayer;
       
  2123             iAudioPlayer = NULL;
       
  2124             TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL\
       
  2125                 iAudioPlayer deleted" )
       
  2126             }
       
  2127         TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL exiting AppUI ")
       
  2128         Exit();
       
  2129         }
       
  2130     if ( iWaitNoteInUse )
       
  2131         {
       
  2132         iCommandPending = EFalse;
       
  2133         }
       
  2134     if ( iSelectItemPending && !iEndKeyPressed )
       
  2135         {
       
  2136         TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL SelectItem pending" )
       
  2137         iSessionTerminated = ETrue;
       
  2138         iSelectItemView->HandleCommandL( ESatUiCmdExit );
       
  2139         }
       
  2140 
       
  2141     TFLOGSTRING( "CSatUiViewAppUi::HandleExitCommandL exit" )
       
  2142     }
       
  2143 
       
  2144 // ---------------------------------------------------------
       
  2145 // CSatUiViewAppUi::HandleWsEventL
       
  2146 // Handling of the window server events.
       
  2147 // (other items were commented in a header).
       
  2148 // ---------------------------------------------------------
       
  2149 //
       
  2150 void CSatUiViewAppUi::HandleWsEventL( 
       
  2151         const TWsEvent& aEvent,
       
  2152         CCoeControl* aDestination )
       
  2153     {
       
  2154     switch ( aEvent.Type() )
       
  2155         {
       
  2156         // This is End key closing event. If this window server event is 
       
  2157         // received, by default application will be closed unless it is 
       
  2158         // the system application.
       
  2159         case KAknUidValueEndKeyCloseEvent:
       
  2160             {            
       
  2161             // Performs the same behaviour as when Exit softkey is pressed.
       
  2162             TFLOGSTRING( "CSatUiViewAppUi::HandleWsEventL End key pressed" )
       
  2163             iEndKeyPressed = ETrue;
       
  2164             HandleExitCommandL();
       
  2165             break;
       
  2166             }
       
  2167         case EEventPointer:
       
  2168             {
       
  2169             TFLOGSTRING( "CSatUiViewAppUi::HandleWsEventL EEventPointer" )
       
  2170             const TPointerEvent& pointer = *( aEvent.Pointer() );
       
  2171             const TPointerEvent::TType pointerType = pointer.iType;
       
  2172             
       
  2173             if ( ( TPointerEvent::EButton1Down == pointerType ) ||
       
  2174                  ( TPointerEvent::EButton2Down == pointerType ) ||
       
  2175                  ( TPointerEvent::EButton3Down == pointerType ) )
       
  2176                 {
       
  2177                 TFLOGSTRING( "CSatUiViewAppUi::HandleWsEventL EEventPointer\
       
  2178                     handle the event" )
       
  2179                 // Check if we need to end play tone    
       
  2180                 StopPlayToneL();
       
  2181                 }
       
  2182             break;
       
  2183             }
       
  2184         case EEventKeyDown:
       
  2185             {
       
  2186             // Handles other user key presses
       
  2187             TFLOGSTRING( "CSatUiViewAppUi::HandleWsEventL EEventKeyDown" )
       
  2188             // Check if we need to end play tone
       
  2189             StopPlayToneL();
       
  2190             if ( iImmediateDigitResponse )
       
  2191                 {
       
  2192                 HandleImmediateDigitResponse( aEvent.Key()->iScanCode );
       
  2193                 }
       
  2194             break;
       
  2195             }
       
  2196 
       
  2197         default:
       
  2198             break;
       
  2199         }
       
  2200     // Forwards event to the base class.
       
  2201     CAknViewAppUi::HandleWsEventL( aEvent, aDestination );
       
  2202     PriorityVerifyAndClose( aEvent );
       
  2203     }
       
  2204 
       
  2205 // ---------------------------------------------------------
       
  2206 // CSatUiViewAppUi::HelpStatus
       
  2207 // Help support status
       
  2208 // (other items were commented in a header).
       
  2209 // ---------------------------------------------------------
       
  2210 //
       
  2211 void CSatUiViewAppUi::HelpStatus( TBool aStatus )
       
  2212     {
       
  2213     TFLOGSTRING( "CSatUiViewAppUi::HelpStatus calling" )
       
  2214     iHelp = aStatus;
       
  2215     TFLOGSTRING( "CSatUiViewAppUi::HelpStatus exiting" )
       
  2216     }
       
  2217 
       
  2218 // ---------------------------------------------------------
       
  2219 // CSatUiViewAppUi::DelayCallback
       
  2220 // Delay Callback function. Completes after predefined 
       
  2221 // time has passed
       
  2222 // (other items were commented in a header).
       
  2223 // ---------------------------------------------------------
       
  2224 //
       
  2225 TInt CSatUiViewAppUi::DelayCallback( TAny* aPtr )
       
  2226     {
       
  2227     TFLOGSTRING( "CSatUiViewAppUi::DelayCallback calling" )
       
  2228     if ( ((CSatUiViewAppUi* )aPtr)->iTimerRepeatOn )
       
  2229         {
       
  2230         if ( ((CSatUiViewAppUi* )aPtr)->iTimerRepeatCount++ == KDivideByEight )
       
  2231             {
       
  2232             TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 1" )
       
  2233             if ( ((CSatUiViewAppUi* )aPtr)->iWait->IsStarted() )
       
  2234                 {
       
  2235                 TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 2" )
       
  2236                 ((CSatUiViewAppUi* )aPtr)->iWait->AsyncStop();
       
  2237                 }
       
  2238             if ( ( ( CSatUiViewAppUi* ) aPtr )->iGetInputDialog ||
       
  2239                 ( ( CSatUiViewAppUi* ) aPtr )->iQueryDialog )
       
  2240                 {
       
  2241                 TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 3" )
       
  2242                 ( ( CSatUiViewAppUi* ) aPtr )->
       
  2243                     iNoResponseFromUserAfterDelay = ETrue;
       
  2244                 ( ( CSatUiViewAppUi* ) aPtr )->CloseDialogs();
       
  2245                 }
       
  2246             }
       
  2247         else
       
  2248             {
       
  2249             TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 4" )
       
  2250             return ( ETrue );
       
  2251             }
       
  2252         }
       
  2253     else
       
  2254         {
       
  2255         TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 5" )
       
  2256         if ( ((CSatUiViewAppUi* )aPtr)->iWait->IsStarted() )
       
  2257             {
       
  2258             TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 6" )
       
  2259             ((CSatUiViewAppUi* )aPtr)->iWait->AsyncStop();
       
  2260             }
       
  2261         }
       
  2262 
       
  2263     // Close DisplayText dialog if clearing after delay is requested
       
  2264     if ( ((CSatUiViewAppUi* )aPtr)->iDisplayTextDialog ||
       
  2265         ((CSatUiViewAppUi* )aPtr)->iDisplayTextIconDialog )
       
  2266         {
       
  2267         TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 7" )
       
  2268         ( ( CSatUiViewAppUi* ) aPtr )->iNoResponseFromUserAfterDelay = ETrue;
       
  2269         ( ( CSatUiViewAppUi* ) aPtr )->ClearScreen();
       
  2270         }    
       
  2271     else if ( ( ( CSatUiViewAppUi* ) aPtr )->iGetInputDialog ||
       
  2272         ( ( CSatUiViewAppUi* ) aPtr )->iQueryDialog )
       
  2273         {
       
  2274         TFLOGSTRING( "CSatUiViewAppUi::DelayCallback  -- 8" )
       
  2275         ( ( CSatUiViewAppUi* ) aPtr )->iNoResponseFromUserAfterDelay = ETrue;
       
  2276         ( ( CSatUiViewAppUi* ) aPtr )->CloseDialogs();
       
  2277         }
       
  2278 
       
  2279     TFLOGSTRING( "CSatUiViewAppUi::DelayCallback exiting" )
       
  2280     return ( EFalse );
       
  2281     }
       
  2282 
       
  2283 // ---------------------------------------------------------
       
  2284 // CSatUiViewAppUi::CreateCallBackTimerLC
       
  2285 // Creates a callback timer
       
  2286 // (other items were commented in a header).
       
  2287 // ---------------------------------------------------------
       
  2288 //
       
  2289 void CSatUiViewAppUi::CreateCallBackTimerL( const TInt aDelay, 
       
  2290     TInt (*aFunction)(TAny* aPtr) )
       
  2291     {
       
  2292     TFLOGSTRING( "CSatUiViewAppUi::CreateCallBackTimerLC called" )
       
  2293     iTimerRepeatCount = 0;
       
  2294     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
  2295 
       
  2296     if ( iTimerRepeatOn )
       
  2297         {
       
  2298         TFLOGSTRING( "CSatUiViewAppUi::CreateCallBackTimerLC repeating" )
       
  2299         iTimer->Start( aDelay, aDelay,
       
  2300             TCallBack( aFunction, this  ) );
       
  2301         }
       
  2302     else
       
  2303         {
       
  2304         TFLOGSTRING( "CSatUiViewAppUi::CreateCallBackTimerLC \
       
  2305             no repeating" )
       
  2306         iTimer->Start( aDelay, KMicroSecondsInSecond,
       
  2307             TCallBack( aFunction, this  ) );
       
  2308         }
       
  2309     
       
  2310     TFLOGSTRING( "CSatUiViewAppUi::CreateCallBackTimerLC exit" )
       
  2311     }
       
  2312 
       
  2313 // ---------------------------------------------------------
       
  2314 // CSatUiViewAppUi::DestroyCallBackTimer
       
  2315 // Destroys the callback timer
       
  2316 // (other items were commented in a header).
       
  2317 // ---------------------------------------------------------
       
  2318 //
       
  2319 void CSatUiViewAppUi::DestroyCallBackTimer( )
       
  2320     {
       
  2321     TFLOGSTRING( "CSatUiViewAppUi::DestroyCallBackTimer() called" )
       
  2322     delete iTimer;
       
  2323     iTimer = NULL;
       
  2324     iTimerRepeatOn = EFalse;
       
  2325     TFLOGSTRING( "CSatUiViewAppUi::DestroyCallBackTimer() exit" )
       
  2326     }
       
  2327 
       
  2328 // ---------------------------------------------------------
       
  2329 // CSatUiViewAppUi::ProcessCommandParametersL
       
  2330 // Takes care of external launching.
       
  2331 // (other items were commented in a header).
       
  2332 // ---------------------------------------------------------
       
  2333 //
       
  2334 TBool CSatUiViewAppUi::ProcessCommandParametersL(
       
  2335     TApaCommand aCommand,
       
  2336     TFileName& aDocumentName,
       
  2337     const TDesC8& aTail )
       
  2338     {
       
  2339     TFLOGSTRING2( "CSatUiViewAppUi::ProcessCommandParametersL called,\
       
  2340         aCommand: %d", aCommand )    
       
  2341     // TApaCommand is 0 for SIM originated opening and 2 for user originated
       
  2342     // opening. Empty view is only needed for SIM originated opening. 
       
  2343     if ( EApaCommandOpen == aCommand )
       
  2344         {
       
  2345         // Creates empty view for commands without view.
       
  2346         CreateEmptyMenuL();
       
  2347         }
       
  2348     
       
  2349     TFLOGSTRING( "CSatUiViewAppUi::ProcessCommandParametersL exit" )
       
  2350     return CAknViewAppUi::ProcessCommandParametersL( aCommand, aDocumentName, 
       
  2351                                                      aTail );
       
  2352     }
       
  2353 
       
  2354 // ---------------------------------------------------------
       
  2355 // CSatUiViewAppUi::DispatchUserInactive
       
  2356 // Called when user has been inactive for a pre-defined time period
       
  2357 // (other items were commented in a header).
       
  2358 // ---------------------------------------------------------
       
  2359 //
       
  2360 TInt CSatUiViewAppUi::DispatchUserInactive( TAny* aPtr )
       
  2361     {
       
  2362     TFLOGSTRING( "CSatUiViewAppUi::DispatchUserInactive calling" )
       
  2363     ((CSatUiViewAppUi* )aPtr)->iNoResponseFromUserAfterDelay = ETrue;
       
  2364 
       
  2365     //lint -e{961} else block not needed.
       
  2366     if ( ( ( CSatUiViewAppUi* ) aPtr )->iDisplayTextDialog ||
       
  2367         ( ( CSatUiViewAppUi* ) aPtr )->iDisplayTextIconDialog )
       
  2368         {
       
  2369         TFLOGSTRING( "CSatUiViewAppUi::DispatchUserInactive clear screen" )
       
  2370         ( ( CSatUiViewAppUi* ) aPtr )->ClearScreen();
       
  2371         }
       
  2372     else if ( ( ( CSatUiViewAppUi* ) aPtr )->iQueryDialog ||
       
  2373         ( (CSatUiViewAppUi* ) aPtr )->iGetInputDialog )
       
  2374         {
       
  2375         TFLOGSTRING( "CSatUiViewAppUi::DispatchUserInactive close dialog" )
       
  2376         ( ( CSatUiViewAppUi* ) aPtr )->CloseDialogs();
       
  2377         }
       
  2378 
       
  2379     TFLOGSTRING( "CSatUiViewAppUi::DispatchUserInactive exiting" )
       
  2380     return (EFalse);
       
  2381     }
       
  2382 
       
  2383 // ---------------------------------------------------------
       
  2384 // CSatUiViewAppUi::MakeGetInputBitmapMask
       
  2385 // Make a mask for get input icon
       
  2386 // (other items were commented in a header).
       
  2387 // ---------------------------------------------------------
       
  2388 //
       
  2389 void CSatUiViewAppUi::MakeGetInputBitmapMask( CFbsBitmap* aMask,
       
  2390         TSize aSize ) const
       
  2391     {
       
  2392     TFLOGSTRING( "CSatUiViewAppUi::MakeGetInputBitmapMask calling" )
       
  2393     TInt width = aSize.iWidth;
       
  2394     TInt height = aSize.iHeight;
       
  2395     aMask->Create( TSize( width, height ), EColor16M );
       
  2396 
       
  2397     TBitmapUtil bitmap1Util( aMask );
       
  2398     // Begin manipulation with bitmap1Util, setting initial pixel to 0,0 
       
  2399     bitmap1Util.Begin( TPoint( 0,0 ) ); 
       
  2400 
       
  2401     // Make mask which covers whole icon
       
  2402     for ( TInt y = 0; y < height; y++ )
       
  2403         {
       
  2404         for ( TInt x = 0; x < width; x++ )
       
  2405             {
       
  2406             bitmap1Util.SetPos( TPoint( x, y ) );
       
  2407             bitmap1Util.SetPixel( 0x0000ff );
       
  2408             }
       
  2409         }
       
  2410     bitmap1Util.End();
       
  2411     TFLOGSTRING( "CSatUiViewAppUi::MakeGetInputBitmapMask exiting" )
       
  2412     }
       
  2413 
       
  2414 // ---------------------------------------------------------
       
  2415 // CSatUiViewAppUi::DispatchTimer
       
  2416 // Dispatch iWait to action implementer.
       
  2417 // (other items were commented in a header).
       
  2418 // ---------------------------------------------------------
       
  2419 // 
       
  2420 void CSatUiViewAppUi::DispatchTimer( CActiveSchedulerWait& aWait )
       
  2421     {
       
  2422     TFLOGSTRING( "CSatUiViewAppUi::DispatchTimer calling" )
       
  2423     iWait = &aWait;
       
  2424     TFLOGSTRING( "CSatUiViewAppUi::DispatchTimer exiting" )
       
  2425     }
       
  2426 
       
  2427 // ---------------------------------------------------------
       
  2428 // CSatUiViewAppUi::GetEndKey
       
  2429 // Get a flag which is indicating if end key is pressed.
       
  2430 // (other items were commented in a header).
       
  2431 // ---------------------------------------------------------
       
  2432 //
       
  2433 TBool CSatUiViewAppUi::GetEndKey()
       
  2434     {
       
  2435     TFLOGSTRING( "CSatUiViewAppUi::GetEndKey calling-exiting" )
       
  2436     return iEndKeyPressed;
       
  2437     }
       
  2438 
       
  2439 // ---------------------------------------------------------
       
  2440 // CSatUiViewAppUi::SetEndKey
       
  2441 // Set a flag which is indicating if end key is pressed.
       
  2442 // (other items were commented in a header).
       
  2443 // ---------------------------------------------------------
       
  2444 //
       
  2445 void CSatUiViewAppUi::SetEndKey( TBool aValue )
       
  2446     {
       
  2447     TFLOGSTRING2( "CSatUiViewAppUi::SetEndKey calling, aValue:%d", aValue )
       
  2448     iEndKeyPressed = aValue;
       
  2449     TFLOGSTRING( "CSatUiViewAppUi::SetEndKey exiting" )    
       
  2450     }
       
  2451 
       
  2452 // ---------------------------------------------------------
       
  2453 // CSatUiViewAppUi::SetCommandPending
       
  2454 // Set a flag which is indicating proactive command is pending.
       
  2455 // (other items were commented in a header).
       
  2456 // ---------------------------------------------------------
       
  2457 //
       
  2458 void CSatUiViewAppUi::SetCommandPending( TBool aValue )
       
  2459     {
       
  2460     TFLOGSTRING2( "CSatUiViewAppUi::SetCommandPending calling, aValue:%d", \
       
  2461         aValue )
       
  2462     iCommandPending = aValue;
       
  2463     if ( aValue )
       
  2464         {
       
  2465         // Cancels a request to save RAM when higher than normal buffer size is
       
  2466         // no longer required.
       
  2467         CAknEnv::Static()->CancelWsBufferRequest( iReqWSBufferID );
       
  2468         }
       
  2469     TFLOGSTRING( "CSatUiViewAppUi::SetCommandPending exiting" )  
       
  2470     }
       
  2471 
       
  2472 // ---------------------------------------------------------
       
  2473 // CSatUiViewAppUi::CloseDialogs
       
  2474 // Close all existing dialogs.
       
  2475 // (other items were commented in a header).
       
  2476 // ---------------------------------------------------------
       
  2477 //
       
  2478 void CSatUiViewAppUi::CloseDialogs()
       
  2479     {
       
  2480     TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() called" )
       
  2481     if ( iWaitNote || iBipWaitNote || iNoteDialog ) 
       
  2482         {
       
  2483         TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() StopShowWaitNote" )
       
  2484         StopShowWaitNote();
       
  2485         }
       
  2486     if ( iDisplayTextDialog )
       
  2487         {
       
  2488         TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() iDisplayTextDialog" )
       
  2489         delete iDisplayTextDialog;
       
  2490         iDisplayTextDialog = NULL;
       
  2491         iImmediateRsp = EFalse;
       
  2492         }
       
  2493     if ( iDisplayTextIconDialog )
       
  2494         {
       
  2495         TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() iDisplayTextIconDialog" )
       
  2496         delete iDisplayTextIconDialog;
       
  2497         iDisplayTextIconDialog = NULL;
       
  2498         iImmediateRsp = EFalse;
       
  2499         }
       
  2500     if ( iGetInputDialog )
       
  2501         {
       
  2502         TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() iGetInputDialog" )
       
  2503         TRAP_IGNORE( iGetInputDialog->DismissQueryL() )
       
  2504         iGetInputDialog = NULL;
       
  2505         }
       
  2506     if ( iQueryDialog )
       
  2507         {
       
  2508         TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() iQueryDialog" )
       
  2509         delete iQueryDialog;
       
  2510         iQueryDialog = NULL;
       
  2511         }
       
  2512     if ( iPermanentNote )
       
  2513         {
       
  2514         TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() iPermanentNote" )
       
  2515         // CAknNoteDialog has already performed deletion when user action.
       
  2516         iPermanentNote = NULL;
       
  2517         }
       
  2518     TFLOGSTRING( "CSatUiViewAppUi::CloseDialogs() exit" )
       
  2519     }
       
  2520 
       
  2521 // ---------------------------------------------------------
       
  2522 // CSatUiViewAppUi::MapcInitComplete
       
  2523 // Plays the tone.
       
  2524 // (other items were commented in a header).
       
  2525 // ---------------------------------------------------------
       
  2526 //
       
  2527 void CSatUiViewAppUi::MapcInitComplete( TInt aError, 
       
  2528     const TTimeIntervalMicroSeconds& /*aDuration*/ )
       
  2529     {
       
  2530     TFLOGSTRING( "CSatUiViewAppUi::MapcInitComplete called" )
       
  2531     // Audio player is initialised, so if there is no error, we can start 
       
  2532     // playing the tone.
       
  2533     if( KErrNone == aError )
       
  2534         {
       
  2535         const TInt volume( Max( 0, Min( iVolume, 
       
  2536                            iAudioPlayer->MaxVolume() ) ) );
       
  2537         TFLOGSTRING2( "CSatUiViewAppUi::\
       
  2538             MapcInitComplete SetVolume %i", volume )
       
  2539         // Set volume according Settings. 
       
  2540         iAudioPlayer->SetVolume( volume );
       
  2541         iAudioPlayer->Play();
       
  2542         TFLOGSTRING( "CSatUiViewAppUi::MapcInitComplete Play" )
       
  2543         }
       
  2544     else
       
  2545         {
       
  2546         // Otherwise, we delete the initialised audio player.
       
  2547         if ( iAudioPlayer )
       
  2548             {
       
  2549             TFLOGSTRING( "CSatUiViewAppUi::MapcInitComplete iAudioPlayer \
       
  2550                           true" )
       
  2551             delete iAudioPlayer;
       
  2552             iAudioPlayer = NULL;
       
  2553             }
       
  2554 
       
  2555         // Remove also the note for play tone
       
  2556         if ( iPermanentNote )
       
  2557             {
       
  2558             TFLOGSTRING( "CSatUiViewAppUi::MapcInitComplete iPermanentNote \
       
  2559                           true" )
       
  2560             iPermanentNote->ExitSleepingDialog();
       
  2561             delete iPermanentNote;
       
  2562             iPermanentNote = NULL;
       
  2563             }
       
  2564 
       
  2565         // If there was a duration for play tone, stop waiting
       
  2566         if ( iWait->IsStarted() )
       
  2567             {
       
  2568             TFLOGSTRING( "CSatUiViewAppUi::MapcInitComplete stop iWait" )
       
  2569             iWait->AsyncStop();
       
  2570             }
       
  2571 
       
  2572         TFLOGSTRING2( "CSatUiViewAppUi::MapcInitComplete Error %i", aError )
       
  2573         }
       
  2574 
       
  2575     TFLOGSTRING( "CSatUiViewAppUi::MapcInitComplete exit" )
       
  2576     }
       
  2577 
       
  2578 // ---------------------------------------------------------
       
  2579 // CSatUiViewAppUi::MapcPlayComplete
       
  2580 // Deletes audio player after playing is completed.
       
  2581 // (other items were commented in a header).
       
  2582 // ---------------------------------------------------------
       
  2583 //
       
  2584 void CSatUiViewAppUi::MapcPlayComplete( TInt aError )
       
  2585     {
       
  2586     TFLOGSTRING( "CSatUiViewAppUi::MapcPlayComplete called" )
       
  2587     
       
  2588     // When playing is completed, deleting the audio player.
       
  2589     if ( iAudioPlayer )
       
  2590         {
       
  2591         TFLOGSTRING( "CSatUiViewAppUi::MapcPlayComplete delete iAudioPlayer" )
       
  2592         delete iAudioPlayer;
       
  2593         iAudioPlayer = NULL;
       
  2594         }
       
  2595     // Remove note after play has completed.
       
  2596     if ( iPermanentNote )
       
  2597         {
       
  2598         TFLOGSTRING( "CSatUiViewAppUi::MapcPlayComplete ExitSleepingDialog" )
       
  2599         iPermanentNote->ExitSleepingDialog();
       
  2600         delete iPermanentNote;
       
  2601         iPermanentNote = NULL;
       
  2602         }
       
  2603     // Show wait note only for samples that have duration, otherwise there is
       
  2604     // chance that wait note is not stopped.
       
  2605     if ( TTimeIntervalMicroSeconds( static_cast<TInt64>( 0 ) ) != iDuration )
       
  2606         {
       
  2607         // It does not affect for tone playing if wait note
       
  2608         // is not able to show.
       
  2609         TFLOGSTRING( "CSatUiViewAppUi::MapcPlayComplete ShowWaitNoteL" )
       
  2610         TRAP_IGNORE( ShowWaitNoteL() )
       
  2611         }
       
  2612 
       
  2613     TFLOGSTRING2( "CSatUiViewAppUi::MapcPlayComplete exit, error:%i", aError )
       
  2614     }
       
  2615 
       
  2616 // ---------------------------------------------------------
       
  2617 // CSatUiViewAppUi::PlayUserSelectedToneL
       
  2618 // Plays user selected tone from active Profile. 
       
  2619 // If needed displays the text in a note while playing.
       
  2620 // (other items were commented in a header).
       
  2621 // ---------------------------------------------------------
       
  2622 //
       
  2623 TSatUiResponse CSatUiViewAppUi::PlayUserSelectedToneL(
       
  2624     const TDesC& aText,
       
  2625     TTimeIntervalMicroSeconds aDuration,
       
  2626     TSatTone aTone,
       
  2627     const CFbsBitmap* aIconBitmap,
       
  2628     const TBool aSelfExplanatory )
       
  2629     {
       
  2630     TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL called" )
       
  2631     StopShowWaitNote();
       
  2632     // Delete timer just in case e.g. if DisplayText was on the screen
       
  2633     DestroyCallBackTimer();
       
  2634 
       
  2635     iPermanentNote = NULL;
       
  2636     iDuration = aDuration;
       
  2637     
       
  2638     TFLOGSTRING2( "CSatUiViewAppUi::PlayUserSelectedToneL length of aText \
       
  2639         %d", aText.Length() )
       
  2640     if ( 0 != aText.Length() )
       
  2641         {
       
  2642         iPermanentNote = new (ELeave) CAknStaticNoteDialog();
       
  2643         iPermanentNote->PrepareLC( R_SATUI_PERMANENT_NOTE );
       
  2644         
       
  2645         if ( ( !aSelfExplanatory ) || ( !aIconBitmap ) )
       
  2646             {
       
  2647             // Set text
       
  2648             iPermanentNote->SetTextL( aText );
       
  2649             }
       
  2650         
       
  2651         if ( aIconBitmap )
       
  2652             {
       
  2653             //Set image 
       
  2654             TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL SetImage" )
       
  2655             CEikImage* image = new ( ELeave ) CEikImage();
       
  2656             CleanupStack::PushL( image );
       
  2657             image->SetBitmap( aIconBitmap ); 
       
  2658             iPermanentNote->SetImageL( image );
       
  2659             CleanupStack::Pop( image );
       
  2660             }
       
  2661         
       
  2662         iPermanentNote->SetTimeout( CAknNoteDialog::ENoTimeout );
       
  2663         iForegroundControl = iPermanentNote;
       
  2664         iPermanentNote->RunLD();
       
  2665         }
       
  2666 
       
  2667     // If several messages/calls arrive during a small amount of time and if the
       
  2668     // message received or incoming call tone is already being played we do not 
       
  2669     // restart it.
       
  2670     if ( iAudioPlayer )
       
  2671         {
       
  2672         TFLOGSTRING( "CSatUiViewAppUi::\
       
  2673             PlayUserSelectedToneL Error - already played" )
       
  2674         return ESatFailure;
       
  2675         }
       
  2676 
       
  2677     // This defines name for the current message alert or incoming call tone. 
       
  2678     TBuf<KMaxSoundFileLength> soundFileName;
       
  2679     GetProfileParamsL( aTone, &soundFileName );
       
  2680     // This defines the behaviour to be adopted by an
       
  2681     // audio client if a higher priority client takes over the device.
       
  2682     TInt mdaPriority( KAudioPrefIncomingCall );
       
  2683     // This is used to resolve conflicts when more than one client tries to 
       
  2684     // access the same sound output device simultaneously.
       
  2685     TInt audioPriority( KAudioPriorityPhoneCall );
       
  2686     
       
  2687     TFLOGSTRING2( "CSatUiViewAppUi::PlayUserSelectedToneL\
       
  2688         Volume is %i ", iVolume )
       
  2689 
       
  2690     // Creates the audio player.
       
  2691     iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL( 
       
  2692         soundFileName,                                                
       
  2693         *this,                                              
       
  2694         audioPriority,                                                  
       
  2695         ( TMdaPriorityPreference ) mdaPriority );
       
  2696 
       
  2697     if ( TTimeIntervalMicroSeconds( static_cast<TInt64>( 0 ) ) != aDuration )
       
  2698         {
       
  2699         TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL duration not 0" )
       
  2700         TTimeIntervalMicroSeconds max32Bit( 
       
  2701             static_cast<TInt64>( K32TIntMaxValue ) );
       
  2702         if ( aDuration > max32Bit )
       
  2703             {
       
  2704             // Timers can only handle 32-bit values 
       
  2705             // and 64-bit value is received.
       
  2706             // Let's break the aDuration to smaller bits.
       
  2707             // Divided here by 8 to fit in 32-bit maxvalue.
       
  2708             // Loops 8 times in DelayCallback to play tone
       
  2709             // right duration. 
       
  2710             aDuration = aDuration.Int64() / KDivideByEight;
       
  2711             iTimerRepeatOn = ETrue;
       
  2712             }
       
  2713         iAudioPlayer->SetRepeats( KSoundPlayerRepeatForever, 
       
  2714                                   TTimeIntervalMicroSeconds( 
       
  2715                                   static_cast<TInt64>( 0 ) ) );
       
  2716         CreateCallBackTimerL( I64INT( aDuration.Int64() ), DelayCallback );
       
  2717         
       
  2718         if ( !iWait->IsStarted() )
       
  2719             {
       
  2720             TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL\
       
  2721                 starting iWait" )
       
  2722             iWait->Start();
       
  2723             TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL\
       
  2724                 strarting done" )
       
  2725             }
       
  2726         
       
  2727         // Sample is played in forever loop for the duration.
       
  2728         // After duration call back timers are destroyed       
       
  2729         DestroyCallBackTimer();
       
  2730         // If player exists, stop playing and delete player. MapcPlayComplete
       
  2731         // is not called because CallBackTimer stops the playing.
       
  2732         if ( iAudioPlayer )
       
  2733             {
       
  2734             iAudioPlayer->Stop();
       
  2735             delete iAudioPlayer;
       
  2736             iAudioPlayer = NULL;
       
  2737             TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL\
       
  2738                 iAudioPlayer deleted" )
       
  2739             }
       
  2740         // Remove note after play has completed.
       
  2741         if ( iPermanentNote )
       
  2742             {
       
  2743             iPermanentNote->ExitSleepingDialog();
       
  2744             delete iPermanentNote;
       
  2745             iPermanentNote = NULL;
       
  2746             }
       
  2747         iForegroundControl = NULL;
       
  2748         
       
  2749         if ( !iEndKeyPressed )
       
  2750             {
       
  2751             ShowWaitNoteL();
       
  2752             }
       
  2753             
       
  2754         }
       
  2755     else
       
  2756         {
       
  2757         // If duration is zero then tone is played only once.
       
  2758         // Playing duration is same as duration of the sample.
       
  2759         iAudioPlayer->SetRepeats(
       
  2760             0, TTimeIntervalMicroSeconds( static_cast<TInt64>( 0 ) ) );
       
  2761         TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL SetRepeats 0" )
       
  2762         }
       
  2763 
       
  2764     TFLOGSTRING( "CSatUiViewAppUi::PlayUserSelectedToneL exit" )
       
  2765     if( EFalse == iWarningAndPlayTones )
       
  2766         {
       
  2767         return ESatSuccessToneNotPlayed;
       
  2768         }
       
  2769         
       
  2770     return ESatSuccess;
       
  2771     }
       
  2772 
       
  2773 
       
  2774 // ---------------------------------------------------------
       
  2775 // CSatUiViewAppUi::ConfirmOpenChannelL
       
  2776 // Displays a query to get confirmation for Open Channel command.
       
  2777 // (other items were commented in a header).
       
  2778 // ---------------------------------------------------------
       
  2779 //
       
  2780 TSatUiResponse CSatUiViewAppUi::ConfirmOpenChannelL(
       
  2781     const TDesC& aText,
       
  2782     TBool& aActionAccepted,
       
  2783     const CFbsBitmap* aIconBitmapOpenChannel,
       
  2784     const TBool aSelfExplanatory )
       
  2785     {
       
  2786     TFLOGSTRING( "CSatUiViewAppUi::ConfirmOpenChannelL called" )
       
  2787     
       
  2788     TSatUiResponse response( ESatSuccess );
       
  2789     TInt resource( 0 );
       
  2790     TPtrC textPtr( aText );
       
  2791     HBufC* textHolder = NULL;
       
  2792     
       
  2793     if ( aIconBitmapOpenChannel )
       
  2794         {
       
  2795         TFLOGSTRING( "CSatUiViewAppUi::ConfirmOpenChannelL have icon" )
       
  2796         resource = R_SATUI_CONFIRM_OK_CANCEL_QUERY_WITH_ICON;
       
  2797         }
       
  2798     else
       
  2799         {
       
  2800         TFLOGSTRING( "CSatUiViewAppUi::ConfirmOpenChannelL no icon" )
       
  2801         resource = R_SATUI_CONFIRM_OK_CANCEL_QUERY;
       
  2802         
       
  2803         TFLOGSTRING2( "CSatUiViewAppUi::ConfirmOpenChannelL length of \
       
  2804             aText %d", aText.Length() )
       
  2805         if ( 0 == aText.Length() )
       
  2806             {
       
  2807             textHolder = StringLoader::LoadLC( R_QTN_SAT_CONF_OPEN_CHANNEL_BIP,
       
  2808                 iCoeEnv );    
       
  2809             textPtr.Set( *textHolder ); 
       
  2810             }
       
  2811         }
       
  2812     
       
  2813     TInt userResponse = RunQueryDialogL( resource, textPtr,
       
  2814         aIconBitmapOpenChannel, aSelfExplanatory, EAknSoftkeyOk );
       
  2815         
       
  2816     if ( textHolder )
       
  2817         {
       
  2818         CleanupStack::PopAndDestroy( textHolder ); 
       
  2819         }
       
  2820 
       
  2821     if ( userResponse )
       
  2822         {
       
  2823         TFLOGSTRING( "CSatUiViewAppUi::ConfirmOpenChannelL action accepted" )
       
  2824         aActionAccepted = ETrue;
       
  2825         }
       
  2826     else
       
  2827         {
       
  2828         TFLOGSTRING( "CSatUiViewAppUi::ConfirmOpenChannelL action not \
       
  2829             accepted" )
       
  2830         aActionAccepted = EFalse;
       
  2831         }
       
  2832 
       
  2833     
       
  2834 
       
  2835     ShowWaitNoteL();
       
  2836 
       
  2837     TFLOGSTRING2( "CSatUiViewAppUi::ConfirmOpenChannelL exit,return: %d",\
       
  2838         response )
       
  2839     return response;
       
  2840     }
       
  2841 
       
  2842 // ---------------------------------------------------------
       
  2843 // CSatUiViewAppUi::ShowBIPNoteL
       
  2844 // Displays the BIP note.
       
  2845 // (other items were commented in a header).
       
  2846 // ---------------------------------------------------------
       
  2847 //
       
  2848 void CSatUiViewAppUi::ShowBIPNoteL( TInt aCommand, const TDesC& aText,
       
  2849     const CFbsBitmap* aIconBitmap,
       
  2850     const TBool aSelfExplanatory )
       
  2851     {
       
  2852     TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL() called" )
       
  2853     TFLOGSTRING2( "CSatUiViewAppUi::ShowBIPNoteL() aCommand: %d", aCommand )
       
  2854     
       
  2855     iWaitNoteInUse = ETrue;
       
  2856     TBool showNote( EFalse );
       
  2857     TInt resourceId( 0 );
       
  2858     switch ( aCommand )
       
  2859         {
       
  2860         case ESendDataIdentier: // fall through
       
  2861         case EReceiveDataIdentifier:
       
  2862             {
       
  2863             resourceId = R_SATUI_BIP_WAIT_NOTE;
       
  2864             showNote = ETrue;
       
  2865             break;
       
  2866             }
       
  2867         case ECloseChannelIdentifier:
       
  2868             {
       
  2869             HBufC* textHolder = StringLoader::LoadLC(
       
  2870                         R_QTN_SAT_CONF_CLOSE_CHANNEL_BIP, iCoeEnv );
       
  2871                         
       
  2872             if ( !iNoteDialog )
       
  2873                 {
       
  2874                 TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL no NoteDialog" )
       
  2875                 iNoteDialog = new (ELeave) CAknNoteDialog(
       
  2876                     REINTERPRET_CAST( CEikDialog**, &iNoteDialog ),
       
  2877                     CAknNoteDialog::ENoTone,
       
  2878                     CAknNoteDialog::EShortTimeout );
       
  2879                               
       
  2880                 if ( aIconBitmap )
       
  2881                     {
       
  2882                     iNoteDialog->PrepareLC( R_SATUI_CLOSE_CHANNEL_ICON_NOTE );
       
  2883                     //Set image
       
  2884                     TFLOGSTRING(
       
  2885                         "CSatUiViewAppUi::ShowBIPNoteL SetImage" )
       
  2886                     CEikImage* image = new ( ELeave ) CEikImage();
       
  2887                     CleanupStack::PushL( image );
       
  2888                     image->SetBitmap( aIconBitmap );
       
  2889                     iNoteDialog->SetImageL( image );
       
  2890                     CleanupStack::Pop( image );
       
  2891                     }
       
  2892                 else
       
  2893                     {
       
  2894                     TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL no Icon" )
       
  2895                     iNoteDialog->PrepareLC( R_SATUI_CLOSE_CHANNEL_NOTE );
       
  2896                     }
       
  2897                 
       
  2898                 // inform the user using received alpha id
       
  2899                 if ( ( aText.Length() > 0 ) &&
       
  2900                     ( !aSelfExplanatory || !aIconBitmap ) )
       
  2901                     {
       
  2902                     TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL using \
       
  2903                         received alpha id" )
       
  2904                     iNoteDialog->SetTextL( aText );
       
  2905                     }
       
  2906                 // inform the user using localized text
       
  2907                 else if ( aText.Length() == 0 )
       
  2908                     {
       
  2909                     TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL using \
       
  2910                         localized text" )
       
  2911                     iNoteDialog->SetTextL( *textHolder );
       
  2912                     }
       
  2913                     
       
  2914                 iForegroundControl = iNoteDialog;
       
  2915                 iNoteDialog->RunLD();    
       
  2916                 // iForegroundControl won't be clear until the note dialog
       
  2917                 // closed. It will avoid we lose the chance to set focus for
       
  2918                 // the wait dialog when the switch of foreground/background
       
  2919                 // happened.
       
  2920                 }
       
  2921                 
       
  2922             CleanupStack::PopAndDestroy( textHolder ); // textHolder
       
  2923             
       
  2924             showNote = EFalse;
       
  2925             break;
       
  2926             }
       
  2927         default:
       
  2928             {
       
  2929             showNote = EFalse;
       
  2930             break;
       
  2931             }
       
  2932         }
       
  2933     if ( showNote )
       
  2934         {
       
  2935         
       
  2936         // First, stop normal wait note.
       
  2937         if ( iWaitNote )
       
  2938             {
       
  2939             TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL() Closing WaitNote" )
       
  2940             TRAP_IGNORE( iWaitNote->ProcessFinishedL() )
       
  2941             iWaitNote = NULL;
       
  2942             }
       
  2943         
       
  2944         if ( !iBipWaitNote )
       
  2945             {
       
  2946             TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL() no  BipWaitNote" )
       
  2947             iBipWaitNote = new ( ELeave ) CSatUiWaitDialog(
       
  2948                 (REINTERPRET_CAST(CEikDialog**,&iBipWaitNote)),
       
  2949                 *iAdapter, ETrue );
       
  2950 
       
  2951             if ( ( aText.Length() > 0 ) && ( !aSelfExplanatory ||
       
  2952                 !aIconBitmap ) )
       
  2953                 {
       
  2954                 iBipWaitNote->SetTextL( aText );
       
  2955                 }
       
  2956                 
       
  2957             if ( aIconBitmap )
       
  2958                 {
       
  2959                 //Set image
       
  2960                 TFLOGSTRING(
       
  2961                     "CSatUiViewAppUi::ShowBIPNoteL SetImage" )    
       
  2962                 CEikImage* image = new ( ELeave ) CEikImage();
       
  2963                 CleanupStack::PushL( image );
       
  2964                 image->SetBitmap( aIconBitmap );      
       
  2965                 iBipWaitNote->SetImageL( image );
       
  2966                 CleanupStack::Pop( image );
       
  2967                 }
       
  2968             
       
  2969             iForegroundControl = iBipWaitNote;
       
  2970             iBipWaitNote->ExecuteLD( resourceId );
       
  2971             // iForegroundControl won't be clear until the BipWait dialog
       
  2972             // closed. It will avoid we lose the chance to set focus for
       
  2973             // the wait dialog when the switch of foreground/background
       
  2974             // happened.
       
  2975             }
       
  2976         else
       
  2977             {
       
  2978             TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL() have BipWaitNote" )
       
  2979             // BIP note already exists, update text if not with self
       
  2980             // explanatory icon
       
  2981             if ( ( aText.Length() > 0 ) &&
       
  2982                 ( !aSelfExplanatory || !aIconBitmap ) )
       
  2983                 {
       
  2984                 iBipWaitNote->SetTextL( aText );
       
  2985                 }
       
  2986             else if ( aSelfExplanatory && aIconBitmap )
       
  2987                 {
       
  2988                 const TDesC emptyText( KNullDesC );
       
  2989                 iBipWaitNote->SetTextL( emptyText );
       
  2990                 }
       
  2991             // BIP note already exists, update image
       
  2992             if ( aIconBitmap )
       
  2993                 {
       
  2994                 //Set image
       
  2995                 TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL SetImage" )   
       
  2996                 CEikImage* image = new ( ELeave ) CEikImage();
       
  2997                 CleanupStack::PushL( image ); 
       
  2998                 image->SetBitmap( aIconBitmap );            
       
  2999                 iBipWaitNote->SetImageL( image );
       
  3000                 CleanupStack::Pop( image );
       
  3001                 }
       
  3002             }
       
  3003         }
       
  3004     TFLOGSTRING( "CSatUiViewAppUi::ShowBIPNoteL() exit" )
       
  3005     }
       
  3006 
       
  3007 // ---------------------------------------------------------
       
  3008 // CSatUiViewAppUi::RemoveNullCharacters
       
  3009 // Null characters are removed from text
       
  3010 // (other items were commented in a header).
       
  3011 // ---------------------------------------------------------
       
  3012 //
       
  3013 void CSatUiViewAppUi::RemoveNullCharacters( HBufC* aText )
       
  3014     {
       
  3015     TFLOGSTRING( "CSatUiViewAppUi::RemoveNullCharacters calling" )
       
  3016     TPtr titleptr = aText->Des();
       
  3017     TInt nullLocation( 0 );
       
  3018     while ( ( nullLocation = titleptr.Locate( NULL ) ) >= 0 )
       
  3019         {
       
  3020         titleptr.Delete( nullLocation, 1 );
       
  3021         }
       
  3022     TFLOGSTRING( "CSatUiViewAppUi::RemoveNullCharacters exiting" )
       
  3023     }
       
  3024 
       
  3025 // ---------------------------------------------------------
       
  3026 // CSatUiViewAppUi::ConfirmSetUpCallL
       
  3027 // (other items were commented in a header).
       
  3028 // ---------------------------------------------------------
       
  3029 //
       
  3030 void CSatUiViewAppUi::ConfirmSetUpCallL( 
       
  3031     const TDesC& aText,
       
  3032     const TDesC& aSimAppName,
       
  3033     TBool& aActionAccepted,
       
  3034     const CFbsBitmap* aIconBitmap,
       
  3035     const TBool aSelfExplanatory )
       
  3036     {
       
  3037     TFLOGSTRING( "CSatUiViewAppUi::ConfirmSetUpCallL calling" )
       
  3038     
       
  3039     aActionAccepted = EFalse;
       
  3040     TPtrC text( aText );
       
  3041     HBufC* textHolder = NULL;
       
  3042     HBufC* titleHolder = NULL;    
       
  3043     TInt resource( 0 );
       
  3044     
       
  3045     if ( aIconBitmap )
       
  3046         {
       
  3047         TFLOGSTRING( "CSatUiViewAppUi::ConfirmSetUpCallL have icon" )
       
  3048         resource = R_SATUI_CONFIRM_CALL_CANCEL_QUERY_WITH_ICON;
       
  3049 
       
  3050         }
       
  3051     else
       
  3052         {
       
  3053         TFLOGSTRING( "CSatUiViewAppUi::ConfirmSetUpCallL no icon" )
       
  3054         resource = R_SATUI_CONFIRM_CALL_CANCEL_QUERY;
       
  3055         
       
  3056         TFLOGSTRING2( "CSatUiViewAppUi::ConfirmSetUpCallL length of aText, \
       
  3057             %d", aText.Length() )
       
  3058         if ( aText.Length() == 0 )
       
  3059             {
       
  3060             
       
  3061             if ( aSimAppName.Length() > 0 )
       
  3062                 {
       
  3063                 titleHolder = aSimAppName.AllocLC();
       
  3064                 }
       
  3065             else
       
  3066                 {
       
  3067                 titleHolder = StringLoader::LoadLC( R_QTN_SAT_QUERY_TITLE, 
       
  3068                     iCoeEnv );
       
  3069                 }
       
  3070 
       
  3071             textHolder = StringLoader::LoadLC( R_TEXT_CALL_SETUP_BY_SIMATK, 
       
  3072                 *titleHolder, iCoeEnv );
       
  3073 
       
  3074             RemoveNullCharacters( textHolder );
       
  3075 
       
  3076             text.Set(*textHolder);
       
  3077             }
       
  3078         }
       
  3079 
       
  3080     TInt userResponse = RunQueryDialogL( resource, text, aIconBitmap,
       
  3081         aSelfExplanatory, ESatUiSoftkeyCall );
       
  3082 
       
  3083     if ( textHolder )
       
  3084         {
       
  3085         CleanupStack::PopAndDestroy( textHolder ); //textHolder
       
  3086         }
       
  3087 
       
  3088     if ( titleHolder )
       
  3089         {
       
  3090         CleanupStack::PopAndDestroy( titleHolder ); //titleHolder
       
  3091         }
       
  3092     
       
  3093     if ( userResponse )
       
  3094         {
       
  3095         aActionAccepted = ETrue;
       
  3096         }
       
  3097 
       
  3098     TFLOGSTRING( "CSatUiViewAppUi::ConfirmSetUpCallL exiting" )
       
  3099     }
       
  3100 
       
  3101 // ---------------------------------------------------------
       
  3102 // CSatUiViewAppUi::ShowNotAvailableNoteL
       
  3103 // Show note indicating SAT is not available
       
  3104 // (other items were commented in a header).
       
  3105 // ---------------------------------------------------------
       
  3106 //
       
  3107 void CSatUiViewAppUi::ShowNotAvailableNoteL()
       
  3108     {
       
  3109     TFLOGSTRING( "CSatUiViewAppUi::ShowNotAvailableNoteL() called" )
       
  3110     CAknNoteDialog* noteDialog = new (ELeave) CAknNoteDialog(
       
  3111         REINTERPRET_CAST(CEikDialog**,&noteDialog),
       
  3112         CAknNoteDialog::ENoTone,
       
  3113         CAknNoteDialog::ELongTimeout );
       
  3114 
       
  3115     HBufC* textHolder = StringLoader::LoadLC( R_QTN_SAT_SERVICES_NOT_AVAILABLE,
       
  3116             iCoeEnv );
       
  3117 
       
  3118     noteDialog->PrepareLC( R_SATUI_INFORMATION_NOTE );
       
  3119     noteDialog->SetTextL( *textHolder );
       
  3120     iForegroundControl = noteDialog;
       
  3121     noteDialog->RunLD();
       
  3122     iForegroundControl = NULL;
       
  3123     
       
  3124     CleanupStack::PopAndDestroy( textHolder );
       
  3125     
       
  3126     TFLOGSTRING( "CSatUiViewAppUi::ShowNotAvailableNoteL() exit" )    
       
  3127     }
       
  3128     
       
  3129 // ---------------------------------------------------------
       
  3130 // CSatUiViewAppUi::RunQueryIconDialogL
       
  3131 // Make and run note dialog with an icon
       
  3132 // (other items were commented in a header).
       
  3133 // ---------------------------------------------------------
       
  3134 //
       
  3135 TInt CSatUiViewAppUi::RunQueryDialogL(
       
  3136     TInt aResourceId, const TDesC& aText, const CFbsBitmap* aIconBitmap,
       
  3137     const TBool aSelfExplanatory, TInt aMskCommand )
       
  3138     {
       
  3139     TFLOGSTRING( "CSatUiViewAppUi::RunQueryDialogL called" )
       
  3140     CEikImage* image = new(ELeave) CEikImage;
       
  3141     CleanupStack::PushL( image );     
       
  3142     iQueryDialog = CAknQueryDialog::NewL();
       
  3143     iQueryDialog->PrepareLC( aResourceId );
       
  3144     TInt userResponse( 0 );
       
  3145 
       
  3146     if ( aIconBitmap )
       
  3147         {
       
  3148         TFLOGSTRING( "CSatUiViewAppUi::RunQueryDialogL set icon" ) 
       
  3149         image->SetBitmap( aIconBitmap );
       
  3150     
       
  3151         // Create mask for icon bitmap
       
  3152         CFbsBitmap* mask = new(ELeave) CFbsBitmap;
       
  3153         TSize size = aIconBitmap->SizeInPixels();
       
  3154         MakeGetInputBitmapMask( mask, size );
       
  3155         image->SetMask( mask );
       
  3156         // Add icon to query
       
  3157         iQueryDialog->QueryHeading()->SetHeaderImageL( image );
       
  3158         }
       
  3159 
       
  3160     if ( !aSelfExplanatory || !aIconBitmap )
       
  3161         {
       
  3162         TFLOGSTRING( "CSatUiViewAppUi::RunQueryDialogL set text" )
       
  3163         TPtrC textPtr( aText );
       
  3164         // Icon is not self-explanatory, show also text
       
  3165         iQueryDialog->SetPromptL( textPtr );            
       
  3166         }
       
  3167                    
       
  3168     // Set MSK same as LSK without any text causing the icon drawing
       
  3169     iQueryDialog->ButtonGroupContainer().SetCommandL(
       
  3170         CEikButtonGroupContainer::EMiddleSoftkeyPosition, aMskCommand,
       
  3171         KSatEmptyDes );
       
  3172     iForegroundControl = iQueryDialog;
       
  3173     userResponse = iQueryDialog->RunLD();
       
  3174     iForegroundControl = NULL;
       
  3175     CleanupStack::PopAndDestroy( image ); // image
       
  3176 
       
  3177     iQueryDialog = NULL;
       
  3178     
       
  3179     TFLOGSTRING2( "CSatUiViewAppUi::RunQueryDialogL exit,return: %d", \
       
  3180         userResponse )
       
  3181     return userResponse;
       
  3182     }
       
  3183 
       
  3184 // ---------------------------------------------------------
       
  3185 // CSatUiViewAppUi::CloseSatUI
       
  3186 // Start SatUi closing process
       
  3187 // (other items were commented in a header).
       
  3188 // ---------------------------------------------------------
       
  3189 //
       
  3190 void CSatUiViewAppUi::CloseSatUI()
       
  3191     {
       
  3192     TFLOGSTRING( "CSatUiViewAppUi::CloseSatUI called" )
       
  3193     
       
  3194     TRAP_IGNORE( HandleExitCommandL() );
       
  3195     
       
  3196     if ( !IsAppShutterRunning() )
       
  3197         {
       
  3198         TFLOGSTRING( "CSatUiViewAppUi::CloseSatUI RunAppShutter" )
       
  3199         RunAppShutter();
       
  3200         }    
       
  3201     
       
  3202     TFLOGSTRING( "CSatUiViewAppUi::CloseSatUI exit" )
       
  3203     }
       
  3204     
       
  3205 // ---------------------------------------------------------
       
  3206 // CSatUiViewAppUi::GetProfileParamsL
       
  3207 // Get and store settings from current profile 
       
  3208 // (other items were commented in a header).
       
  3209 // ---------------------------------------------------------
       
  3210 //
       
  3211 void CSatUiViewAppUi::GetProfileParamsL( TSatTone aTone /*= ESatToneNotSet*/,
       
  3212                                          TDes* aToneName /*= NULL*/ )
       
  3213     {
       
  3214     TFLOGSTRING( "CSatUiViewAppUi::GetProfileParamsL calling" )
       
  3215     
       
  3216     MProfile* profile = NULL;
       
  3217     MProfileEngine* engine = NULL;
       
  3218     
       
  3219     engine = CreateProfileEngineL();
       
  3220     CleanupReleasePushL( *engine );
       
  3221         
       
  3222     profile = engine->ActiveProfileLC();
       
  3223                
       
  3224     const MProfileTones& tones = profile->ProfileTones();
       
  3225     
       
  3226     // Takes a current warning and gametones setting.
       
  3227     const TProfileToneSettings& ts = tones.ToneSettings();
       
  3228     iWarningAndPlayTones = ts.iWarningAndGameTones;
       
  3229     iVolume = ts.iRingingVolume;
       
  3230     TFLOGSTRING2( "CSatUiViewAppUi::GetProfileParamsL \
       
  3231         iVolume before mapping %d", iVolume )
       
  3232     
       
  3233     // Max volume from profile is KMaxVolumeFromProfile, Max volume from 
       
  3234     // CMdaAudioToneUtility is different, maybe 10,000. So, 
       
  3235     // rate = maxVolumeFromPlayer / KMaxVolumeFromProfile
       
  3236     // User may never hear the TONE, because volume is too small.
       
  3237     // iVolume times the rate make it can be heard.
       
  3238     
       
  3239     CMdaAudioToneUtility* toneUtl = CMdaAudioToneUtility::NewL( *this );
       
  3240     TInt maxVolumeFromPlayer( toneUtl->MaxVolume() );
       
  3241     iVolume *= maxVolumeFromPlayer / KMaxVolumeFromProfile;
       
  3242     delete toneUtl;
       
  3243     toneUtl = NULL;
       
  3244     TFLOGSTRING2( "CSatUiViewAppUi::GetProfileParamsL \
       
  3245         iVolume after mapping %d", iVolume )
       
  3246     
       
  3247     if ( ( ESatUserSelectedToneIncomingSms == aTone ) && ( aToneName ) )
       
  3248         {
       
  3249         TFLOGSTRING( "CSatUiViewAppUi::GetProfileParamsL message tone" )
       
  3250         aToneName->Copy( tones.MessageAlertTone() );
       
  3251         }
       
  3252     else if( aToneName )
       
  3253         {
       
  3254         TFLOGSTRING( "CSatUiViewAppUi::GetProfileParamsL ring tone" )
       
  3255         aToneName->Copy( tones.RingingTone1() );
       
  3256         }
       
  3257         
       
  3258     CleanupStack::PopAndDestroy( 2 ); // engine, profile
       
  3259     
       
  3260     TFLOGSTRING( "CSatUiViewAppUi::GetProfileParamsL exits" )    
       
  3261     }
       
  3262     
       
  3263 // ---------------------------------------------------------
       
  3264 // CSatUiViewAppUi::HandleImmediateDigitResponse
       
  3265 // Check received key event.
       
  3266 // (other items were commented in a header).
       
  3267 // ---------------------------------------------------------
       
  3268 //
       
  3269 void CSatUiViewAppUi::HandleImmediateDigitResponse( TInt aScanCode )
       
  3270     {
       
  3271     TFLOGSTRING2( "CSatUiViewAppUi::HandleImmediateDigitResponse() code: %d",
       
  3272         aScanCode )
       
  3273     TBool closeDialog( ETrue );
       
  3274 
       
  3275     // If number button is pressed
       
  3276     if ( ( KKeyZero <= aScanCode ) && ( KKeyNine >= aScanCode ) )
       
  3277         {
       
  3278         TFLOGSTRING( "CSatUiViewAppUi::HandleImmediateDigitResponse press \
       
  3279             digit 0-9" )
       
  3280         iKey = aScanCode;
       
  3281         }
       
  3282     else if ( EStdKeyNkpAsterisk == aScanCode || KHwAsterisk == aScanCode )
       
  3283         {
       
  3284         TFLOGSTRING( "CSatUiViewAppUi::HandleImmediateDigitResponse press \
       
  3285             *" )
       
  3286         iKey = 0x2A;
       
  3287         }
       
  3288     else if ( EStdKeyHash == aScanCode )
       
  3289         {
       
  3290         TFLOGSTRING( "CSatUiViewAppUi::HandleImmediateDigitResponse press \
       
  3291             #" )
       
  3292         iKey = 0x23;
       
  3293         }
       
  3294     else 
       
  3295         {
       
  3296         TFLOGSTRING( "CSatUiViewAppUi::HandleImmediateDigitResponse press \
       
  3297             others" )
       
  3298         closeDialog = EFalse;
       
  3299         iKey = 0x00;
       
  3300         }
       
  3301         
       
  3302     if( closeDialog )
       
  3303         {
       
  3304         CloseDialogs();
       
  3305         }
       
  3306     
       
  3307     TFLOGSTRING( "CSatUiViewAppUi::HandleImmediateDigitResponse exits" )
       
  3308     }
       
  3309       
       
  3310 // ---------------------------------------------------------
       
  3311 // CSatUiViewAppUi::PriorityVerifyAndClose
       
  3312 // Handle closing display text in high priority events
       
  3313 // (other items were commented in a header).
       
  3314 // ---------------------------------------------------------
       
  3315 //
       
  3316 void CSatUiViewAppUi::PriorityVerifyAndClose( const TWsEvent& aEvent )
       
  3317     {
       
  3318     TFLOGSTRING( "CSatUiViewAppUi::PriorityVerifyAndClose calling" )
       
  3319     
       
  3320     if ( ( iDisplayTextDialog || iDisplayTextIconDialog ) &&
       
  3321         ( EEventFocusLost == aEvent.Type() ) )
       
  3322         {
       
  3323         // Open the WS server session.
       
  3324         RWsSession wsSession;
       
  3325         if ( KErrNone == wsSession.Connect() )
       
  3326             {
       
  3327             TInt wgFocus( wsSession.GetFocusWindowGroup() );
       
  3328             TInt wgPriority(
       
  3329                 wsSession.GetWindowGroupOrdinalPriority( wgFocus ) );
       
  3330             TFLOGSTRING2(
       
  3331                 "CSatUiViewAppUi::PriorityVerifyAndClose priority=%d",
       
  3332                 wgPriority )
       
  3333             
       
  3334             // For some reason window group priority for call dialogs was 0
       
  3335             // so those cases must be checked in addition
       
  3336             TInt callActiveState = EPSCTsyCallStateNone;
       
  3337                 
       
  3338             // Get current call status from P&S
       
  3339             const TInt errCode( RProperty::Get(
       
  3340                 KPSUidCtsyCallInformation,
       
  3341                 KCTsyCallState,
       
  3342                 callActiveState ) );
       
  3343             
       
  3344             // Receiving MT or creating MO call
       
  3345             const TBool callIncoming(
       
  3346                 ( EPSCTsyCallStateAlerting == callActiveState ) ||
       
  3347                 ( EPSCTsyCallStateRinging == callActiveState ) ||
       
  3348                 ( EPSCTsyCallStateDialling == callActiveState ) ); 
       
  3349             TFLOGSTRING2(
       
  3350                 "CSatUiViewAppUi::PriorityVerifyAndClose callActiveState=%d",
       
  3351                 callActiveState )
       
  3352             TFLOGSTRING2(
       
  3353                 "CSatUiViewAppUi::PriorityVerifyAndClose iImmediateRsp=%d",
       
  3354                 iImmediateRsp )  
       
  3355                 
       
  3356             // If the new focus window group has high priority
       
  3357             // close dialog
       
  3358             if ( ( wgPriority > 0 && iForeground ) || 
       
  3359                  ( iImmediateRsp && callIncoming ) )
       
  3360                 {
       
  3361                 iHighPriorityEvent = ETrue;
       
  3362                 CloseDialogs();
       
  3363                 }
       
  3364                 
       
  3365             wsSession.Close();
       
  3366             }
       
  3367         }
       
  3368         
       
  3369     TFLOGSTRING( "CSatUiViewAppUi::PriorityVerifyAndClose exiting" )
       
  3370     }
       
  3371 
       
  3372 // ---------------------------------------------------------
       
  3373 // CSatUiViewAppUi::CloseCallControlNote
       
  3374 // Call back method, close the note in call control. 
       
  3375 // (other items were commented in a header).
       
  3376 // ---------------------------------------------------------
       
  3377 //
       
  3378 TInt CSatUiViewAppUi::CloseCallControlNoteL( TAny* aPtr )
       
  3379     {
       
  3380     TFLOGSTRING( "CSatUiViewAppUi::CloseCallControlNote calling" )
       
  3381 
       
  3382     if ( !aPtr ) 
       
  3383         {
       
  3384         return KErrArgument;
       
  3385         }
       
  3386 
       
  3387     CSatUiViewAppUi* pAppUi = 
       
  3388         reinterpret_cast<CSatUiViewAppUi*>( aPtr );
       
  3389     
       
  3390     TRAPD( err, pAppUi->iCcNote->CancelNoteL( pAppUi->iCcNoteId ) );
       
  3391     if( KErrNone != err )
       
  3392         {
       
  3393         return err;
       
  3394         }
       
  3395 
       
  3396     if ( pAppUi->iWait->IsStarted() ) 
       
  3397         {
       
  3398         pAppUi->iWait->AsyncStop();
       
  3399         }
       
  3400     delete pAppUi->iCcNote;
       
  3401     pAppUi->iCcNote = NULL;
       
  3402         
       
  3403     TFLOGSTRING( "CSatUiViewAppUi::CloseCallControlNote exiting" )
       
  3404     
       
  3405     return 0;
       
  3406     }
       
  3407 
       
  3408 // ---------------------------------------------------------
       
  3409 // CSatUiViewAppUi::ShowSsErrorNoteL
       
  3410 // Show a Ss Error note. 
       
  3411 // (other items were commented in a header).
       
  3412 // ---------------------------------------------------------
       
  3413 //
       
  3414 void CSatUiViewAppUi::ShowSsErrorNoteL()
       
  3415     {
       
  3416     TFLOGSTRING( "CSatUiViewAppUi::ShowSsErrorNoteL calling" )
       
  3417     CAknNoteDialog* errorNote = new ( ELeave ) CAknNoteDialog( 
       
  3418                                 REINTERPRET_CAST( CEikDialog**,&errorNote ),
       
  3419                                 CAknNoteDialog::ENoTone, 
       
  3420                                 CAknNoteDialog::ELongTimeout );
       
  3421     CleanupStack::PushL( errorNote );
       
  3422         
       
  3423     HBufC* textHolder = StringLoader::LoadLC(R_TEXT_NOT_DONE, iCoeEnv );
       
  3424     errorNote->SetTextL( *textHolder );
       
  3425     CleanupStack::PopAndDestroy( textHolder ); 
       
  3426     CleanupStack::Pop( errorNote );
       
  3427     errorNote->ExecuteLD( R_SATUI_INFORMATION_NOTE );
       
  3428         
       
  3429     TFLOGSTRING( "CSatUiViewAppUi::ShowSsErrorNoteL exiting" )
       
  3430     }
       
  3431 
       
  3432 // -----------------------------------------------------------------------------
       
  3433 // CSatUiViewAppUi::ProfileState
       
  3434 // Return current profile state
       
  3435 // -----------------------------------------------------------------------------
       
  3436 //
       
  3437 TInt CSatUiViewAppUi::ProfileState()
       
  3438     {
       
  3439     TFLOGSTRING( "CSatUiViewAppUi::ProfileState called" )
       
  3440 
       
  3441     TInt profileId( 0 );
       
  3442     CRepository* cr ( NULL );
       
  3443 
       
  3444     TRAPD( err, cr = CRepository::NewL( KCRUidProfileEngine ) );
       
  3445     if ( ( KErrNone == err ) && cr )
       
  3446         {
       
  3447         TFLOGSTRING( "CSatUiViewAppUi::ProfileState no err" )
       
  3448         // Get the ID of the currently active profile:
       
  3449         cr->Get( KProEngActiveProfile, profileId );
       
  3450         delete cr;
       
  3451         }
       
  3452 
       
  3453     else
       
  3454         {
       
  3455         TFLOGSTRING2( "CR failed: %i", err )
       
  3456         }
       
  3457 
       
  3458     TFLOGSTRING2( "CSatUiViewAppUi::ProfileState exit value: %d",
       
  3459         profileId )
       
  3460 
       
  3461     return profileId;
       
  3462     }
       
  3463 // -----------------------------------------------------------------------------
       
  3464 // CSatUiViewAppUi::StopPlayToneL
       
  3465 // Stops playing play tone. Used when user terminates play tone 
       
  3466 // -----------------------------------------------------------------------------
       
  3467 //
       
  3468 void CSatUiViewAppUi::StopPlayToneL()
       
  3469     {
       
  3470     TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL called" )
       
  3471     if ( iPlayer && iWait->IsStarted() )
       
  3472         {
       
  3473         TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL\
       
  3474             iPlayer exists" )
       
  3475         iPlayToneError = ESatSessionTerminatedByUser;
       
  3476         iWait->AsyncStop();
       
  3477         }
       
  3478     if ( iAudioPlayer )
       
  3479         {
       
  3480         TFLOGSTRING( "StopPlayToneL iAudioPlayer exists" )
       
  3481         if ( iWait->IsStarted() )
       
  3482             {
       
  3483             TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL\
       
  3484                 iWait started" )
       
  3485             // Remove note when play has been interrupted.
       
  3486             if ( iPermanentNote )
       
  3487                 {
       
  3488                 iPermanentNote->ExitSleepingDialog();
       
  3489                 delete iPermanentNote;
       
  3490                 iPermanentNote = NULL;
       
  3491                 }
       
  3492             iPlayToneError = ESatSessionTerminatedByUser;
       
  3493             iWait->AsyncStop();
       
  3494             }
       
  3495         else
       
  3496             {
       
  3497             TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL\
       
  3498                 iWait not started" )
       
  3499             iAudioPlayer->Stop();
       
  3500             // When playing is stopped, deleting the audio player.
       
  3501             // MapcPlayComplete is not called because user stops
       
  3502             // the playing.
       
  3503             if ( iAudioPlayer )
       
  3504                 {
       
  3505                 delete iAudioPlayer;
       
  3506                 iAudioPlayer = NULL;
       
  3507                 TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL\
       
  3508                     iAudioPlayer deleted" )
       
  3509 
       
  3510                 // Remove note after play has completed.
       
  3511                 if ( iPermanentNote )
       
  3512                     {
       
  3513                     TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL\
       
  3514                                  iPermanentNote true" )
       
  3515                     iPermanentNote->ExitSleepingDialog();
       
  3516                     delete iPermanentNote;
       
  3517                     iPermanentNote = NULL;
       
  3518                     }
       
  3519 
       
  3520                 // Show wait note only for samples that have 
       
  3521                 // duration, otherwise there is chance that wait 
       
  3522                 // note is not stopped.
       
  3523                 if ( TTimeIntervalMicroSeconds(
       
  3524                     static_cast<TInt64>( 0 ) ) != iDuration )
       
  3525                     {
       
  3526                     ShowWaitNoteL();
       
  3527                     }
       
  3528                 }
       
  3529             }
       
  3530         }
       
  3531     TFLOGSTRING( "CSatUiViewAppUi::StopPlayToneL exiting" )
       
  3532     }
       
  3533     
       
  3534 // -----------------------------------------------------------------------------
       
  3535 // CSatUiViewAppUi::ForegroundAlive
       
  3536 // Check if foreground control is alive when HandleForegroundEventL is called.
       
  3537 // -----------------------------------------------------------------------------
       
  3538 //
       
  3539 TBool CSatUiViewAppUi::ForegroundAlive() const
       
  3540     {
       
  3541     TFLOGSTRING( "CSatUiViewAppUi::ForegroundAlive called" )
       
  3542     
       
  3543     // Only if value of iForegroundControl equals to one of the following 8
       
  3544     // pointers, the alive value will be set to true. This will check if 
       
  3545     // the foreground control is alive.
       
  3546     TBool alive = 
       
  3547         iForegroundControl == static_cast<CCoeControl*>( iWaitNote ) 
       
  3548         || iForegroundControl == static_cast<CCoeControl*>( 
       
  3549            iDisplayTextIconDialog )
       
  3550         || iForegroundControl == static_cast<CCoeControl*>( 
       
  3551            iDisplayTextDialog )
       
  3552         || iForegroundControl == static_cast<CCoeControl*>( iGetInputDialog )
       
  3553         || iForegroundControl == static_cast<CCoeControl*>( iPermanentNote )
       
  3554         || iForegroundControl == static_cast<CCoeControl*>( iNoteDialog )
       
  3555         || iForegroundControl == static_cast<CCoeControl*>( iBipWaitNote )
       
  3556         || iForegroundControl == static_cast<CCoeControl*>( iQueryDialog );
       
  3557     
       
  3558     TFLOGSTRING2( "CSatUiViewAppUi::ForegroundAlive exiting alive=%d", alive )
       
  3559     
       
  3560     return alive;
       
  3561     }
       
  3562 
       
  3563 // End of File