phoneclientserver/phoneclient/Src/UssdWrapper/CPhCltUssdNoteController.cpp
branchRCL_3
changeset 19 7d48bed6ce0c
parent 0 ff3b6d0fd310
child 20 987c9837762f
equal deleted inserted replaced
18:594d59766373 19:7d48bed6ce0c
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <AknGlobalNote.h> //CAknGlobalNote
    20 #include <hbdevicemessageboxsymbian.h>
    21 #include <aknnotewrappers.h>
    21 #include <hbdeviceprogressdialogsymbian.h>
    22 #include <ConeResLoader.h>
    22 #include <hbtextresolversymbian.h>
    23 #include <StringLoader.h>
    23 
    24 
    24 #include "phcltclientserver.h" 
    25 #include "PhCltClientServer.h"
    25 #include "cphcltussdnotecontroller.h" 
    26 #include "CPhCltUssdNoteController.h"
    26 #include "tflogger.h"
    27 
    27 
    28 
    28 _LIT(KUssdLocFilename, "ussd_");
       
    29 _LIT(KCommonLocFilename, "common_");
       
    30 _LIT(KPath, "z:\\resource\\qt\\translations");
       
    31 _LIT(KUssdRequesting, "txt_common_info_requesting"); // Requesting
       
    32 _LIT(KUssdDone, "txt_ussd_dpopinfo_done"); // Done
       
    33 _LIT(KUssdNotDone, "txt_ussd_dpopinfo_not_done"); // NotDone
       
    34 _LIT(KUssdNotAllowed, "txt_ussd_dpopinfo_not_allowed"); //NotAllowed
       
    35 _LIT(KUssdUnconfirmed, "txt_ussd_dpopinfo_request_not_confirmed"); // Unconfirmed
       
    36 _LIT(KUssdNoService, "txt_ussd_dpopinfo_no_service"); // NoService
       
    37 _LIT(KUssdOffline, "txt_ussd_dpopinfo_unable_to_use_network_phone_is"); // Offline
       
    38 _LIT(KUssdHide, "txt_common_button_hide"); // Hide
       
    39 
       
    40 const int KPhCltUssdProgressBarMaxLength = 10;
    29 // ============================ MEMBER FUNCTIONS ===============================
    41 // ============================ MEMBER FUNCTIONS ===============================
    30 
    42 
    31 // -----------------------------------------------------------------------------
    43 // -----------------------------------------------------------------------------
    32 // CPhCltUssdNoteController::NewL
    44 // CPhCltUssdNoteController::NewL
    33 // Two-phased constructor.
    45 // Two-phased constructor.
    34 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    35 //
    47 //
    36 CPhCltUssdNoteController* CPhCltUssdNoteController::NewL(
    48 CPhCltUssdNoteController* CPhCltUssdNoteController::NewL(
    37         MPhCltUssdNoteControllerCallBack& aCallBack,
    49         MPhCltUssdNoteControllerCallBack& aCallBack )
    38         TInt aPriority )
    50     {
    39     {
    51     TFLOGSTRING("CPhCltUssdNoteController: NewL call")
    40     CPhCltUssdNoteController* self = new( ELeave ) 
    52     CPhCltUssdNoteController* self = new( ELeave ) 
    41         CPhCltUssdNoteController( aCallBack, aPriority );
    53         CPhCltUssdNoteController( aCallBack );
    42     
    54 
    43     CleanupStack::PushL( self );
    55     CleanupStack::PushL( self );
    44     self->ConstructL();
    56     self->ConstructL();
    45     CleanupStack::Pop( self );
    57     CleanupStack::Pop( self );
       
    58     TFLOGSTRING("CPhCltUssdNoteController: NewL exit")
    46     return self;
    59     return self;
    47     }
    60     }
    48 
       
    49 
    61 
    50 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    51 // CPhCltUssdNoteController::ConstructL
    63 // CPhCltUssdNoteController::ConstructL
    52 // Symbian 2nd phase constructor can leave.
    64 // Symbian 2nd phase constructor can leave.
    53 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    54 //
    66 //
    55 void CPhCltUssdNoteController::ConstructL()
    67 void CPhCltUssdNoteController::ConstructL()
    56     {
    68     {
    57     LoadResourceFileL();
    69     TFLOGSTRING( "CPhCltUssdNoteController: ConstructL call_exit" ) 
    58     }
    70     }
    59 
       
    60 
    71 
    61 // -----------------------------------------------------------------------------
    72 // -----------------------------------------------------------------------------
    62 // CPhCltUssdNoteController::CPhCltUssdNoteController
    73 // CPhCltUssdNoteController::CPhCltUssdNoteController
    63 // C++ constructor can NOT contain any code, that
    74 // C++ constructor can NOT contain any code, that
    64 // might leave.
    75 // might leave.
    65 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    66 CPhCltUssdNoteController::CPhCltUssdNoteController(
    77 CPhCltUssdNoteController::CPhCltUssdNoteController(
    67     MPhCltUssdNoteControllerCallBack& aCallBack,
    78     MPhCltUssdNoteControllerCallBack& aCallBack )
    68     TInt aPriority )
    79     : iGlobalWaitNote( NULL ),
    69     : CActive( aPriority ), 
    80       iCallBack( aCallBack )
    70     iCallBack( aCallBack ),
    81     {
    71     iWaitNoteId( KErrNotFound )
    82     TFLOGSTRING("CPhCltUssdNoteController: CPhCltUssdNoteController call")
    72     {
    83     TFLOGSTRING("CPhCltUssdNoteController: CPhCltUssdNoteController exit")
    73     CActiveScheduler::Add( this );
    84     }
    74     }
    85 
    75     
       
    76     
       
    77 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    78 // CPhCltUssdNoteController:~CPhCltUssdNoteController
    87 // CPhCltUssdNoteController:~CPhCltUssdNoteController
    79 // C++ default constructor can NOT contain any code, that
    88 // C++ default constructor can NOT contain any code, that
    80 // might leave.
    89 // might leave.
    81 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    82 //
    91 //
    83 CPhCltUssdNoteController::~CPhCltUssdNoteController()
    92 CPhCltUssdNoteController::~CPhCltUssdNoteController()
    84     {
    93     {
    85     Cancel();
    94     TFLOGSTRING("CPhCltUssdNoteController: ~CPhCltUssdNoteController call")
    86 
       
    87     DestroyGlobalWaitNote();
    95     DestroyGlobalWaitNote();
    88     
    96     TFLOGSTRING("CPhCltUssdNoteController: ~CPhCltUssdNoteController exit")
    89     delete iMessageBuffer;
    97     }
    90     iMessageBuffer = NULL;
    98 
    91     
    99 // -----------------------------------------------------------------------------
    92     if ( iResourceLoader )
   100 // CPhCltUssdNoteController::ShowGlobalInformationNoteL
       
   101 // -----------------------------------------------------------------------------
       
   102 void CPhCltUssdNoteController::ShowGlobalInformationNoteL( 
       
   103         const TPhCltUssdInformationType aInfoType )
       
   104     {
       
   105     TFLOGSTRING2("CPhCltUssdNoteController: ShowGlobalInformationNoteL\
       
   106             aInfoType = %d call", aInfoType)
       
   107     const TBool textResolver = HbTextResolverSymbian::Init( 
       
   108         KUssdLocFilename, KPath );
       
   109     TFLOGSTRING2("CPhCltUssdNoteController: ShowGlobalInformationNoteL\
       
   110         ussd textResolver = %d", textResolver ) 
       
   111     HBufC* temp(NULL);
       
   112     switch ( aInfoType )
    93         {
   113         {
    94         iResourceLoader->Close();
   114         case EPhCltUssdUnconfirme:
    95         delete iResourceLoader;
   115             {
    96         iResourceLoader = NULL;
   116             temp = HbTextResolverSymbian::LoadLC( KUssdUnconfirmed );
       
   117             break;
       
   118             }
       
   119         case EPhCltUssdNotallowed:
       
   120             {
       
   121             temp = HbTextResolverSymbian::LoadLC( KUssdNotAllowed );
       
   122             break;
       
   123             }
       
   124         case EPhCltUssdNoservice:
       
   125             {
       
   126             temp = HbTextResolverSymbian::LoadLC( KUssdNoService );
       
   127             break;
       
   128             }
       
   129         case EPhCltUssdOffline:
       
   130             {
       
   131             temp = HbTextResolverSymbian::LoadLC( KUssdOffline );
       
   132             break;
       
   133             }
       
   134         case EPhCltUssdDone:
       
   135             {
       
   136             temp = HbTextResolverSymbian::LoadLC( KUssdDone );
       
   137             break;
       
   138             }
       
   139         case EPhCltUssdNotDone:
       
   140             {
       
   141             temp = HbTextResolverSymbian::LoadLC( KUssdNotDone );
       
   142             break;
       
   143             }
       
   144         default:
       
   145             {
       
   146             User::Leave( KErrArgument );
       
   147             break;
       
   148             }
    97         }
   149         }
    98     }
   150     CHbDeviceMessageBoxSymbian* dlg = CHbDeviceMessageBoxSymbian::NewL(
    99 
   151             CHbDeviceMessageBoxSymbian::EInformation);
   100 
   152     CleanupStack::PushL( dlg );
   101 // -----------------------------------------------------------------------------
   153     dlg->SetTextL( temp->Des() );
   102 // CPhCltUssdNoteController::RunL
   154     dlg->SetButton( CHbDeviceMessageBoxSymbian::EAcceptButton, ETrue );
   103 //
   155     dlg->ExecL();
   104 // Called when dialog is dismissed by pressing a softkey.
   156     CleanupStack::PopAndDestroy( dlg );
   105 // -----------------------------------------------------------------------------
   157     CleanupStack::PopAndDestroy( temp );
   106 void CPhCltUssdNoteController::RunL()
   158     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalInformationNoteL exit")
   107     {
   159     }
   108     iCallBack.GlobalWaitNoteDismissedL( iStatus.Int() );
   160 
   109     }
   161 // -----------------------------------------------------------------------------
   110 
   162 // CPhCltUssdNoteController::ShowGlobalWaitNoteL
   111 
   163 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   164 void CPhCltUssdNoteController::ShowGlobalWaitNoteL( )
   113 // CPhCltUssdNoteController::DoCancel
   165     {
   114 // -----------------------------------------------------------------------------
   166     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL call")
   115 void CPhCltUssdNoteController::DoCancel()
       
   116     {
       
   117     DestroyGlobalWaitNote();
   167     DestroyGlobalWaitNote();
   118     }
   168     TBool textResolver = HbTextResolverSymbian::Init( 
   119 
   169         KCommonLocFilename, KPath );
   120 
   170     TFLOGSTRING2("CPhCltUssdNoteController: ConstructL\
   121 // -----------------------------------------------------------------------------
   171         init common textResolver = %d", textResolver ) 
   122 // CPhCltUssdNoteController::ShowInformationNoteL
   172     //CHbDeviceProgressDialogSymbian
   123 // -----------------------------------------------------------------------------
   173     iGlobalWaitNote = CHbDeviceProgressDialogSymbian::NewL(
   124 void CPhCltUssdNoteController::ShowInformationNoteL( TInt aResourceId )
   174             CHbDeviceProgressDialogSymbian::EProgressDialog );
   125     {
   175     CleanupStack::PushL( iGlobalWaitNote );
   126     ShowNoteL( EPhCltUssdInformationNote, aResourceId );
   176     HBufC* context = HbTextResolverSymbian::LoadLC( KUssdRequesting );
   127     }
   177     iGlobalWaitNote->SetTextL( context->Des() );
   128 
   178     HBufC* bottonText = HbTextResolverSymbian::LoadLC( KUssdHide );
   129 
   179     iGlobalWaitNote->SetButtonTextL( bottonText->Des() );
   130 // -----------------------------------------------------------------------------
   180     iGlobalWaitNote->SetObserver( this );
   131 // CPhCltUssdNoteController::ShowGlobalInformationNoteL
   181     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL before setactive")
   132 // -----------------------------------------------------------------------------
   182     iGlobalWaitNote->SetRange(0,KPhCltUssdProgressBarMaxLength);
   133 void CPhCltUssdNoteController::ShowGlobalInformationNoteL( TInt aResourceId )
   183     iGlobalWaitNote->SetProgressValue( KPhCltUssdProgressBarMaxLength );
   134     {
   184     iGlobalWaitNote->SetAutoClose( EFalse );
   135     ShowNoteL( EPhCltUssdGlobalInformationNote, aResourceId );
   185     iGlobalWaitNote->ShowL();
   136     }
   186     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL after ShowL")
   137 
   187     CleanupStack::PopAndDestroy( bottonText );
   138 
   188     CleanupStack::PopAndDestroy( context );
   139 // -----------------------------------------------------------------------------
   189     CleanupStack::Pop( iGlobalWaitNote );
   140 // CPhCltUssdNoteController::ShowGlobalConfirmationNoteL
   190     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL after setactive")
   141 // -----------------------------------------------------------------------------
   191     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL exit")
   142 void CPhCltUssdNoteController::ShowGlobalConfirmationNoteL( TInt aResourceId )
   192     }
   143     {
       
   144     ShowNoteL( EPhCltUssdGlobalConfirmationNote, aResourceId );
       
   145     }
       
   146 
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CPhCltUssdNoteController::ShowGlobalWaitNoteL
       
   150 // -----------------------------------------------------------------------------
       
   151 void CPhCltUssdNoteController::ShowGlobalWaitNoteL( 
       
   152     TInt aResourceId, 
       
   153     TInt aSoftkeyResourceId )
       
   154     {
       
   155     delete iMessageBuffer;
       
   156     iMessageBuffer = NULL;
       
   157     iMessageBuffer = StringLoader::LoadL( aResourceId );
       
   158 
       
   159     DestroyGlobalWaitNote();
       
   160     
       
   161     iGlobalWaitNote = CAknGlobalNote::NewL();    
       
   162    
       
   163     if ( aSoftkeyResourceId )
       
   164         {
       
   165         iGlobalWaitNote->SetSoftkeys( aSoftkeyResourceId );
       
   166         }
       
   167     
       
   168     SetActive();
       
   169     
       
   170     iWaitNoteId = iGlobalWaitNote->ShowNoteL( iStatus,
       
   171                                 EAknGlobalWaitNote, 
       
   172                                 *iMessageBuffer );
       
   173     }
       
   174 
       
   175 
   193 
   176 // -----------------------------------------------------------------------------
   194 // -----------------------------------------------------------------------------
   177 // CPhCltUssdNoteController::DestroyGlobalWaitNote
   195 // CPhCltUssdNoteController::DestroyGlobalWaitNote
   178 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   179 void CPhCltUssdNoteController::DestroyGlobalWaitNote()
   197 void CPhCltUssdNoteController::DestroyGlobalWaitNote()
   180     {
   198     {
       
   199     TFLOGSTRING("CPhCltUssdNoteController: DestroyGlobalWaitNote call")
   181     if ( iGlobalWaitNote )
   200     if ( iGlobalWaitNote )
   182         {
   201         {
   183         if ( iWaitNoteId != KErrNotFound ) 
   202         iGlobalWaitNote->Close();
   184             {
       
   185             TRAP_IGNORE( iGlobalWaitNote->CancelNoteL( iWaitNoteId ) );
       
   186             iWaitNoteId = KErrNotFound;
       
   187             }
       
   188         delete iGlobalWaitNote;
   203         delete iGlobalWaitNote;
   189         iGlobalWaitNote = NULL;
   204         iGlobalWaitNote = NULL;
   190         }
   205         }
   191     }
   206     TFLOGSTRING("CPhCltUssdNoteController: DestroyGlobalWaitNote exit")
   192 
   207     }
   193 
   208 
   194 // -----------------------------------------------------------------------------
   209 // -----------------------------------------------------------------------------
   195 // CPhCltUssdNoteController::ShowNoteL
   210 // CPhCltUssdNoteController::ProgressDialogCancelled
   196 //
   211 //
   197 // Launches a corresponding dialog with the given string.
   212 // 
   198 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   199 //
   214 //
   200 void CPhCltUssdNoteController::ShowNoteL( TPhCltUssdNoteType aType, TInt aResourceId )
   215 void CPhCltUssdNoteController::ProgressDialogCancelled(
   201     {
   216         const CHbDeviceProgressDialogSymbian* /*aProgressDialog*/)
   202     switch ( aType )
   217     {
   203         {
   218     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogCancelled call")
   204         case EPhCltUssdInformationNote:
   219     iCallBack.GlobalWaitNoteHidden();
   205             {       
   220     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogCancelled exit")
   206             delete iMessageBuffer;
   221     }
   207             iMessageBuffer = NULL;
   222 
   208             iMessageBuffer = StringLoader::LoadL( aResourceId );
   223 // -----------------------------------------------------------------------------
   209             
   224 // CPhCltUssdNoteController::ProgressDialogClosed
   210             if ( iMessageBuffer->Length() == 0 )
   225 //
   211                 {
   226 // 
   212                 break;
   227 // -----------------------------------------------------------------------------
   213                 }
   228 //
   214             CAknInformationNote* dlg = new ( ELeave ) 
   229 void CPhCltUssdNoteController::ProgressDialogClosed(
   215                 CAknInformationNote( ETrue );
   230         const CHbDeviceProgressDialogSymbian* /*aProgressDialog*/)
   216 
   231     {
   217             dlg->ExecuteLD( *iMessageBuffer );
   232     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogClosed call")
   218             break;
   233     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogClosed exit")
   219             }
       
   220         case EPhCltUssdGlobalInformationNote:
       
   221         case EPhCltUssdGlobalConfirmationNote:
       
   222             {
       
   223             CAknGlobalNote* dlg = CAknGlobalNote::NewLC();
       
   224             
       
   225             delete iMessageBuffer;
       
   226             iMessageBuffer = NULL;
       
   227             iMessageBuffer = StringLoader::LoadL( aResourceId );
       
   228             
       
   229             if ( aType == EPhCltUssdGlobalInformationNote )
       
   230                 {
       
   231                 dlg->ShowNoteL( EAknGlobalInformationNote , *iMessageBuffer );
       
   232                 }
       
   233             else if ( aType == EPhCltUssdGlobalConfirmationNote )
       
   234                 {
       
   235                 dlg->ShowNoteL( EAknGlobalConfirmationNote , *iMessageBuffer );
       
   236                 }
       
   237             CleanupStack::PopAndDestroy(); // dlg
       
   238             break;
       
   239             }
       
   240 
       
   241         default:
       
   242             break;
       
   243         }
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CPhCltUssdNoteController::LoadResourceFileL
       
   248 //
       
   249 // Loads resource file via RConeResourceLoader.
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 void CPhCltUssdNoteController::LoadResourceFileL()
       
   253     {
       
   254     // load resource file for notes
       
   255     iResourceLoader = new( ELeave ) RConeResourceLoader( *CCoeEnv::Static() );
       
   256     TFileName fileName ( KPhCltServerZDrive );
       
   257     fileName.Append( KDC_RESOURCE_FILES_DIR );
       
   258     fileName.Append( KPhCltResourceFileNameAndPath );
       
   259     fileName.ZeroTerminate();
       
   260     iResourceLoader->OpenL( fileName );
       
   261     }
   234     }
   262 
   235 
   263 // End of file
   236 // End of file
   264 
   237