phoneclientserver/phoneclient/Src/UssdWrapper/CPhCltUssdNoteController.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2009-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:  Ussd note controller
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <hbdevicemessageboxsymbian.h>
       
    21 #include <hbdeviceprogressdialogsymbian.h>
       
    22 #include <hbtextresolversymbian.h>
       
    23 
       
    24 #include "phcltclientserver.h" 
       
    25 #include "cphcltussdnotecontroller.h" 
       
    26 #include "tflogger.h"
       
    27 
       
    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_unconfirmed"); // Unconfirmed
       
    36 _LIT(KUssdNoService, "txt_ussd_dpopinfo_no_service"); // NoService
       
    37 _LIT(KUssdOffline, "txt_ussd_dpopinfo_offline_not_possible"); // Offline
       
    38 _LIT(KUssdHide, "txt_common_button_hide"); // Hide
       
    39 
       
    40 const int KPhCltUssdProgressBarMaxLength = 10;
       
    41 // ============================ MEMBER FUNCTIONS ===============================
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CPhCltUssdNoteController::NewL
       
    45 // Two-phased constructor.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CPhCltUssdNoteController* CPhCltUssdNoteController::NewL(
       
    49         MPhCltUssdNoteControllerCallBack& aCallBack )
       
    50     {
       
    51     TFLOGSTRING("CPhCltUssdNoteController: NewL call")
       
    52     CPhCltUssdNoteController* self = new( ELeave ) 
       
    53         CPhCltUssdNoteController( aCallBack );
       
    54 
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL();
       
    57     CleanupStack::Pop( self );
       
    58     TFLOGSTRING("CPhCltUssdNoteController: NewL exit")
       
    59     return self;
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CPhCltUssdNoteController::ConstructL
       
    64 // Symbian 2nd phase constructor can leave.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CPhCltUssdNoteController::ConstructL()
       
    68     {
       
    69     TFLOGSTRING( "CPhCltUssdNoteController: ConstructL call_exit" ) 
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CPhCltUssdNoteController::CPhCltUssdNoteController
       
    74 // C++ constructor can NOT contain any code, that
       
    75 // might leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 CPhCltUssdNoteController::CPhCltUssdNoteController(
       
    78     MPhCltUssdNoteControllerCallBack& aCallBack )
       
    79     : iGlobalWaitNote( NULL ),
       
    80       iCallBack( aCallBack ),
       
    81       iIsResolverSuccess( EFalse ),
       
    82       iGlobalResource( NULL )
       
    83     {
       
    84     TFLOGSTRING("CPhCltUssdNoteController: CPhCltUssdNoteController call")
       
    85     TFLOGSTRING("CPhCltUssdNoteController: CPhCltUssdNoteController exit")
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CPhCltUssdNoteController:~CPhCltUssdNoteController
       
    90 // C++ default constructor can NOT contain any code, that
       
    91 // might leave.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CPhCltUssdNoteController::~CPhCltUssdNoteController()
       
    95     {
       
    96     TFLOGSTRING("CPhCltUssdNoteController: ~CPhCltUssdNoteController call")
       
    97     DestroyGlobalWaitNote();
       
    98     TFLOGSTRING("CPhCltUssdNoteController: ~CPhCltUssdNoteController exit")
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CPhCltUssdNoteController::ShowGlobalInformationNoteL
       
   103 // -----------------------------------------------------------------------------
       
   104 void CPhCltUssdNoteController::ShowGlobalInformationNoteL( 
       
   105         const TPhCltUssdInformationType aInfoType )
       
   106     {
       
   107     TFLOGSTRING2("CPhCltUssdNoteController: ShowGlobalInformationNoteL\
       
   108             aInfoType = %d call", aInfoType)
       
   109     iIsResolverSuccess = HbTextResolverSymbian::Init( KUssdLocFilename, KPath );
       
   110     TFLOGSTRING2("CPhCltUssdNoteController: ShowGlobalInformationNoteL\
       
   111         ussd iIsResolverSuccess = %d", iIsResolverSuccess ) 
       
   112     HBufC* temp(NULL);
       
   113     switch ( aInfoType )
       
   114         {
       
   115         case EPhCltUssdUnconfirme:
       
   116             {
       
   117             temp = LoadDefaultStringL(KUssdUnconfirmed);
       
   118             break;
       
   119             }
       
   120         case EPhCltUssdNotallowed:
       
   121             {
       
   122             temp = LoadDefaultStringL(KUssdNotAllowed);
       
   123             break;
       
   124             }
       
   125         case EPhCltUssdNoservice:
       
   126             {
       
   127             temp = LoadDefaultStringL(KUssdNoService);
       
   128             break;
       
   129             }
       
   130         case EPhCltUssdOffline:
       
   131             {
       
   132             temp = LoadDefaultStringL(KUssdOffline);
       
   133             break;
       
   134             }
       
   135         case EPhCltUssdDone:
       
   136             {
       
   137             temp = LoadDefaultStringL(KUssdDone);
       
   138             break;
       
   139             }
       
   140         case EPhCltUssdNotDone:
       
   141             {
       
   142             temp = LoadDefaultStringL(KUssdNotDone);
       
   143             break;
       
   144             }
       
   145         default:
       
   146             {
       
   147             User::Leave( KErrArgument );
       
   148             }
       
   149             break;
       
   150         }
       
   151     CHbDeviceMessageBoxSymbian* dlg = CHbDeviceMessageBoxSymbian::NewL(
       
   152             CHbDeviceMessageBoxSymbian::EInformation);
       
   153     CleanupStack::PushL( dlg );
       
   154     dlg->SetTextL( temp->Des() );
       
   155     dlg->SetButton( CHbDeviceMessageBoxSymbian::EAcceptButton,
       
   156              ETrue );
       
   157     dlg->ExecL();
       
   158     CleanupStack::PopAndDestroy( dlg );
       
   159     delete temp;
       
   160     temp = NULL;
       
   161     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalInformationNoteL exit")
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CPhCltUssdNoteController::ShowGlobalWaitNoteL
       
   166 // -----------------------------------------------------------------------------
       
   167 void CPhCltUssdNoteController::ShowGlobalWaitNoteL( )
       
   168     {
       
   169     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL call")
       
   170     DestroyGlobalWaitNote();
       
   171     iIsResolverSuccess = HbTextResolverSymbian::Init( KCommonLocFilename, KPath );
       
   172     TFLOGSTRING2("CPhCltUssdNoteController: ConstructL\
       
   173         init common iIsResolverSuccess = %d", iIsResolverSuccess ) 
       
   174     //CHbDeviceProgressDialogSymbian
       
   175     iGlobalWaitNote = CHbDeviceProgressDialogSymbian::NewL(
       
   176             CHbDeviceProgressDialogSymbian::EProgressDialog );
       
   177     CleanupStack::PushL( iGlobalWaitNote );
       
   178     iGlobalResource = LoadDefaultStringL( KUssdRequesting );
       
   179     iGlobalWaitNote->SetTextL( iGlobalResource->Des() );
       
   180     iGlobalWaitNote->SetObserver( this );
       
   181     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL before setactive")
       
   182     iGlobalWaitNote->SetRange(0,KPhCltUssdProgressBarMaxLength);
       
   183     iGlobalWaitNote->SetProgressValue( KPhCltUssdProgressBarMaxLength );
       
   184     iGlobalWaitNote->SetAutoClose( EFalse );
       
   185     iGlobalWaitNote->SetButtonTextL( LoadDefaultStringL( KUssdHide )->Des() );
       
   186     iGlobalWaitNote->ShowL();
       
   187     CleanupStack::Pop( iGlobalWaitNote );
       
   188     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL after setactive")
       
   189     TFLOGSTRING("CPhCltUssdNoteController: ShowGlobalWaitNoteL exit")
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // CPhCltUssdNoteController::DestroyGlobalWaitNote
       
   194 // -----------------------------------------------------------------------------
       
   195 void CPhCltUssdNoteController::DestroyGlobalWaitNote()
       
   196     {
       
   197     TFLOGSTRING("CPhCltUssdNoteController: DestroyGlobalWaitNote call")
       
   198     if ( iGlobalWaitNote )
       
   199         {
       
   200         iGlobalWaitNote->Close();
       
   201         delete iGlobalWaitNote;
       
   202         iGlobalWaitNote = NULL;
       
   203         delete iGlobalResource;
       
   204         iGlobalResource = NULL;
       
   205         }
       
   206     TFLOGSTRING("CPhCltUssdNoteController: DestroyGlobalWaitNote exit")
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CPhCltUssdNoteController::ProgressDialogCancelled
       
   211 //
       
   212 // 
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CPhCltUssdNoteController::ProgressDialogCancelled(
       
   216         const CHbDeviceProgressDialogSymbian* /*aProgressDialog*/)
       
   217     {
       
   218     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogCancelled call")
       
   219     iCallBack.GlobalWaitNoteHidden();
       
   220     delete iGlobalResource;
       
   221     iGlobalResource = NULL;
       
   222     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogCancelled exit")
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CPhCltUssdNoteController::ProgressDialogClosed
       
   227 //
       
   228 // 
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 void CPhCltUssdNoteController::ProgressDialogClosed(
       
   232         const CHbDeviceProgressDialogSymbian* /*aProgressDialog*/)
       
   233     {
       
   234     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogClosed call")
       
   235     TFLOGSTRING("CPhCltUssdNoteController: ProgressDialogClosed exit")
       
   236     }
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // CPhCltUssdNoteController::LoadDefaultString
       
   240 //
       
   241 // 
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 HBufC* CPhCltUssdNoteController::LoadDefaultStringL( const TDesC& aText )
       
   245     {
       
   246     TFLOGSTRING("CPhCltUssdNoteController: LoadDefaultString call")
       
   247     HBufC* newText = NULL;
       
   248     if ( iIsResolverSuccess )
       
   249         {
       
   250         newText = HbTextResolverSymbian::LoadL( aText );
       
   251         }
       
   252     else
       
   253         {
       
   254         newText = aText.AllocL();
       
   255         TFLOGSTRING("CPhCltUssdNoteController: LoadDefaultString load failed.");
       
   256         }
       
   257     TFLOGSTRING("CPhCltUssdNoteController: LoadDefaultString exit")
       
   258     return newText;
       
   259     }
       
   260 
       
   261 // End of file
       
   262