wvuing/IMPSConnectionUI/UISrc/CCnUiUiFacade.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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:  UI facade.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32std.h>
       
    20 #include <aknnotewrappers.h>
       
    21 #include <aknquerydialog.h>
       
    22 #include <aknlistquerydialog.h>
       
    23 #include <aknwaitdialog.h>
       
    24 #include <TextResolver.h>
       
    25 #include <StringLoader.h>
       
    26 #include <eikenv.h>
       
    27 #include <impserrors.h>
       
    28 #include <AknIconArray.h>
       
    29 #include <AknIconUtils.h>
       
    30 #include <gulicon.h>
       
    31 #include <PathInfo.h>
       
    32 #include <avkon.mbg>
       
    33 #include <bldvariant.hrh>
       
    34 #include <aknsskininstance.h>
       
    35 #include <aknsutils.h>
       
    36 #include <bautils.h>
       
    37 #include <fbs.h>
       
    38 
       
    39 #include <PEngWVPresenceErrors2.h>
       
    40 #include <NetConError.h>
       
    41 #include <es_sock.h>
       
    42 #include 	"VariantKeys.h"
       
    43 
       
    44 #include <IMPSConnectionUiNG.rsg>
       
    45 #include <CAVariationNG.rsg>
       
    46 
       
    47 #include <e32property.h>    // RProperty
       
    48 
       
    49 #include <AknMessageQueryDialog.h>
       
    50 #include <eikbtgpc.h>
       
    51 #include <browserlauncher.h>
       
    52 
       
    53 #include "CnUiErrors.h"
       
    54 #include "CCnUiUiFacade.h"
       
    55 #include "CnUiResourceFileName.h"
       
    56 #include "CCnUiUsernameAndPwdQuery.h"
       
    57 #include "CCommandAbsorbingControl.h"
       
    58 #include "CCnUiWaitNoteContainer.h"
       
    59 #include "CCnUiQueryContainer.h"
       
    60 #include "ccnuidomainselectionquerydialog.h"
       
    61 #include "CCnUiTermsOfUseDlg.h"
       
    62 
       
    63 #include "CnUiPanics.h"
       
    64 #include "CIMPSSharedDataFactory.h"
       
    65 #include "MIMPSSharedData.h"
       
    66 #include "impspresenceconnectionuiconstsng.h"
       
    67 
       
    68 #include "CCnOUiUsernameAndPwdQuery.h"
       
    69 #include "impswapreguiddefs.h"
       
    70 #include 	<centralrepository.h>
       
    71 #include    "CCnUiConnOpener.h"
       
    72 
       
    73 
       
    74 //CONSTANTS
       
    75 //Max CSP error code
       
    76 //It is assumed that max CSP error id would be 999
       
    77 //==>thus the top CSP error code is CSP error base - 999
       
    78 const TInt KPEngErrorWVServerResponseTop = KPEngErrorWVServerResponseBase - 999;
       
    79 const TInt KCnUiErrGPRSConnectionNotAvailable = -4167; //stated explicitly in UI spec.
       
    80 
       
    81 // Backslash unicode
       
    82 const TUint KBackSlash = 0x005C;
       
    83 
       
    84 _LIT( KTab, "\t" );
       
    85 _LIT( KDirSeparator, "\\" );
       
    86 _LIT( KRelativeBrandPath, "\\system\\data\\branding\\" );
       
    87 _LIT( KModuleId, "IMApp" );
       
    88 _LIT( KBitmapFile, "logo.mbm" );
       
    89 _LIT( KCUITOUFile, "TOU.rsc" );
       
    90 //Max length of WAP registration URL
       
    91 #define KMaxRegUrlLength 20
       
    92 
       
    93 // ================= GLOBAL FUNCTIONS ====================
       
    94 // -----------------------------------------------------------------------------
       
    95 // CreateUiFacadeL()
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 GLREF_C MCnUiUiFacade* CreateUiFacadeL()
       
    99     {
       
   100     return CCnUiUiFacade::NewL();
       
   101     }
       
   102 
       
   103 GLREF_C MCnUiUiFacade* CreateUiFacadeLC()
       
   104     {
       
   105     CCnUiUiFacade* self = CCnUiUiFacade::NewL();
       
   106     CleanupStack::PushL( self );
       
   107     return self;
       
   108     }
       
   109 
       
   110 
       
   111 // ================= MEMBER FUNCTIONS =======================
       
   112 // Two-phased constructor.
       
   113 CCnUiUiFacade* CCnUiUiFacade::NewL()
       
   114     {
       
   115     CCnUiUiFacade* self = new ( ELeave ) CCnUiUiFacade();
       
   116 
       
   117     CleanupStack::PushL( self );
       
   118     self->ConstructL();
       
   119     CleanupStack::Pop( self );
       
   120 
       
   121     return self;
       
   122     }
       
   123 
       
   124 
       
   125 // Destructor
       
   126 CCnUiUiFacade::~CCnUiUiFacade()
       
   127     {
       
   128     RemoveUsedResourceFile();
       
   129     delete iDefaultRssFileName;
       
   130     delete iCommandAbsorber;
       
   131     delete iIconArray;
       
   132     delete iSharedData;
       
   133     delete iBrLauncher;
       
   134     iRFs.Close();
       
   135     if ( iControl )
       
   136         {
       
   137         CCoeEnv::Static()->AppUi()->RemoveFromStack( iControl );
       
   138         delete iControl;
       
   139         iControl = NULL;
       
   140         }
       
   141     }
       
   142 
       
   143 
       
   144 // C++ default constructor can NOT contain any code, that
       
   145 // might leave.
       
   146 //
       
   147 CCnUiUiFacade::CCnUiUiFacade()
       
   148         : iResourceFileAdded( EFalse )
       
   149     {
       
   150     }
       
   151 
       
   152 
       
   153 // Symbian OS default constructor can leave.
       
   154 void CCnUiUiFacade::ConstructL()
       
   155     {
       
   156     iCoeEnv = CCoeEnv::Static();
       
   157     __ASSERT_ALWAYS( iCoeEnv,
       
   158                      CnUiPanicOrLeaveL( EIMPSConnUi_NoCoeEnv,
       
   159                                         KErrNotSupported ) );
       
   160 
       
   161     iCommandAbsorber = CCommandAbsorbingControl::NewL();
       
   162 
       
   163     iSharedData = CIMPSSharedDataFactory::CreateTemporaryKeyHandlerL( NULL, KBrandingUid );
       
   164     RProperty::Define( KBrandingUid,
       
   165                        KBrandingResourceKey,
       
   166                        RProperty::EByteArray,
       
   167                        KIMPSPubSubReadPolicy, KIMPSPubSubWritePolicy );
       
   168 
       
   169     RProperty::Define( KBrandingUid,
       
   170                        KBrandingConnUIResourceKey,
       
   171                        RProperty::EByteArray,
       
   172                        KIMPSPubSubReadPolicy, KIMPSPubSubWritePolicy );
       
   173 
       
   174     TFileName resourceFileName;
       
   175     CnUiResourceFileName::NearestForCurrentLanguage( iCoeEnv->FsSession(),
       
   176                                                      resourceFileName  );
       
   177     iDefaultRssFileName = resourceFileName.AllocL();
       
   178 
       
   179     // Check for branding
       
   180     resourceFileName.Zero();
       
   181     TInt err = iSharedData->GetStringKey(
       
   182                    ( TIMPSSharedKeys )KBrandingConnUIResourceKey, resourceFileName );
       
   183     if ( err != KErrNone || resourceFileName.Length() == 0 )
       
   184         {
       
   185         resourceFileName = *iDefaultRssFileName;
       
   186         }
       
   187 
       
   188     UseResourceFileL( resourceFileName );
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CCnUiUiFacade::ConnProcessUi()
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 MIMPSConnProcessUi& CCnUiUiFacade::ConnProcessUi()
       
   196     {
       
   197     return *this;
       
   198     }
       
   199 
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CCnUiUiFacade::CommandAbsorbOnLC()
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 void CCnUiUiFacade::CommandAbsorbOnLC()
       
   206     {
       
   207     iCommandAbsorber->AbsorbCommandsLC();
       
   208     }
       
   209 
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CCnUiUiFacade::FlushCommandBuffer()
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CCnUiUiFacade::FlushCommandBuffer()
       
   216     {
       
   217     iCommandAbsorber->FlushCommands();
       
   218     }
       
   219 
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CCnUiUiFacade::WaitNoteL()
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 MCnUiConnWaitNote* CCnUiUiFacade::WaitNoteL( TCnUiConnectionWaitNotes aNoteId,
       
   226                                              MCnUiWaitNoteObserver* aObserver )
       
   227     {
       
   228     TInt promptTextResourceId( 0 );
       
   229     TInt noteResourceId( 0 );
       
   230     switch ( aNoteId )
       
   231         {
       
   232         case ECnUiWaitNoteDisconnecting:
       
   233             {
       
   234             //res & type res ok
       
   235             promptTextResourceId = R_QTN_CHAT_WAIT_DISCONNECT;
       
   236             noteResourceId = R_WAIT_NOTE_BLANK;
       
   237             break;
       
   238             }
       
   239 
       
   240         case ECnUiWaitNotePlugin:
       
   241             {
       
   242             //res & type res ok
       
   243             promptTextResourceId = R_QTN_CHAT_FETCHING_CONTACT_LISTS;
       
   244             noteResourceId = R_WAIT_NOTE_BLANK;
       
   245             break;
       
   246             }
       
   247 
       
   248         default:
       
   249             {
       
   250             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   251             break;
       
   252             }
       
   253         }
       
   254 
       
   255     HBufC* prompt = StringLoader::LoadLC( promptTextResourceId, iCoeEnv );
       
   256 
       
   257     CCnUiWaitNoteContainer* wNote = CCnUiWaitNoteContainer::NewL( noteResourceId,
       
   258                                                                   *prompt,
       
   259                                                                   aObserver );
       
   260     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   261     return wNote;
       
   262     }
       
   263 
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CCnUiUiFacade::WaitNoteL()
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 MCnUiConnWaitNote* CCnUiUiFacade::WaitNoteL( TCnUiConnectionWaitNotesDynText aNoteId,
       
   270                                              const TDesC& aInsertText,
       
   271                                              MCnUiWaitNoteObserver* aObserver )
       
   272     {
       
   273     TInt promptTextResourceId( 0 );
       
   274     TInt noteResourceId( 0 );
       
   275     switch ( aNoteId )
       
   276         {
       
   277         case ECnUiWaitNoteConnectingPEC:
       
   278             {
       
   279             //res & type res ok
       
   280             promptTextResourceId = R_QTN_PEC_CON_TO_SERVER;
       
   281             noteResourceId = R_WAIT_NOTE_WITH_CANCEL;
       
   282             break;
       
   283             }
       
   284 
       
   285         case ECnUiWaitNoteConnectingChat:
       
   286             {
       
   287             //res & type res ok
       
   288             promptTextResourceId = R_QTN_CHAT_CON_TO_SERVER;
       
   289             noteResourceId = R_WAIT_NOTE_WITH_CANCEL;
       
   290             break;
       
   291             }
       
   292 
       
   293         case ECnUiWaitNoteReConnectingChat:
       
   294             {
       
   295             //res & type res ok
       
   296             promptTextResourceId = R_QTN_CHAT_SETTING_CON_TO_PEC2;
       
   297             noteResourceId = R_WAIT_NOTE_WITH_CANCEL;
       
   298             break;
       
   299             }
       
   300 
       
   301         case ECnUiWaitNoteReConnectingPEC:
       
   302             {
       
   303             //res & type res ok
       
   304             promptTextResourceId = R_QTN_CHAT_SETTING_CON_TO_CHAT2;
       
   305             noteResourceId = R_WAIT_NOTE_WITH_CANCEL;
       
   306             break;
       
   307             }
       
   308 
       
   309         default:
       
   310             {
       
   311             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   312             break;
       
   313             }
       
   314         }
       
   315 
       
   316     HBufC* prompt = StringLoader::LoadLC( promptTextResourceId, aInsertText, iCoeEnv );
       
   317     CCnUiWaitNoteContainer* wNote = NULL;
       
   318     TBool requireSignOnAnim = IntResourceValueL( RSC_CHAT_VARIATION_SHOW_SIGN_IN_ANIMATION );
       
   319     if ( aNoteId == ECnUiWaitNoteConnectingChat && requireSignOnAnim )
       
   320         {
       
   321         iControl = CCnUiSignInControl::NewL( *prompt, aObserver );
       
   322         CCoeEnv::Static()->AppUi()->AddToStackL( iControl );
       
   323         }
       
   324     else
       
   325         {
       
   326         wNote = CCnUiWaitNoteContainer::NewL( noteResourceId,
       
   327                                               *prompt,
       
   328                                               aObserver );
       
   329         }
       
   330     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   331     return wNote;
       
   332     }
       
   333 
       
   334 
       
   335 
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CCnUiUiFacade::QueryL()
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 MCnUiConnQuery* CCnUiUiFacade::QueryL( TCnUiConnAsyncQuery aQueryId,
       
   342                                        MCnUiConnQueryObserver& aObserver )
       
   343     {
       
   344     TInt promptTextResourceId( 0 );
       
   345 
       
   346     switch ( aQueryId )
       
   347         {
       
   348         case ECnUiQueryActiveConnectionScheduledClose:
       
   349             {
       
   350             //res & type res ok
       
   351             promptTextResourceId = R_QTN_CHAT_SCHEDULED_TO_BE_CLOSED;
       
   352             break;
       
   353             }
       
   354 
       
   355 
       
   356         default:
       
   357             {
       
   358             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   359             break;
       
   360             }
       
   361         }
       
   362 
       
   363     HBufC* prompt = StringLoader::LoadLC( promptTextResourceId, iCoeEnv );
       
   364     CCnUiQueryContainer* query = CCnUiQueryContainer::NewL( ENBConfirmationQuery,
       
   365                                                             *prompt,
       
   366                                                             aObserver );
       
   367     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   368     return query;
       
   369     }
       
   370 
       
   371 
       
   372 
       
   373 // -----------------------------------------------------------------------------
       
   374 // CCnUiUiFacade::QueryL()
       
   375 // -----------------------------------------------------------------------------
       
   376 //
       
   377 MCnUiConnQuery* CCnUiUiFacade::QueryL( TCnUiConnAsyncQueryDynText aQueryId,
       
   378                                        const TDesC& aInsertText,
       
   379                                        MCnUiConnQueryObserver& aObserver )
       
   380     {
       
   381     TInt promptTextResourceId( 0 );
       
   382     switch ( aQueryId )
       
   383         {
       
   384         case ECnUiQueryActiveConnectionSuppressForScheduledConnection:
       
   385             {
       
   386             //res & type res ok
       
   387             promptTextResourceId = R_QTN_CHAT_DISCON_OTHER_BECAUSE_SCHEDULING;
       
   388             break;
       
   389             }
       
   390 
       
   391         default:
       
   392             {
       
   393             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   394             break;
       
   395             }
       
   396         }
       
   397 
       
   398     HBufC* prompt = StringLoader::LoadLC( promptTextResourceId, aInsertText, iCoeEnv );
       
   399     CCnUiQueryContainer* query = CCnUiQueryContainer::NewL( ENBConfirmationQuery,
       
   400                                                             *prompt,
       
   401                                                             aObserver );
       
   402     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   403     return query;
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CCnUiUiFacade::GetIntResourceValueL
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 TInt CCnUiUiFacade::GetIntResourceValueL( TInt aResourceId )
       
   411     {
       
   412     // Show user Identity, if variated so
       
   413     TResourceReader reader;
       
   414     TInt value( KErrNone );
       
   415     CCoeEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
       
   416     value = ResourceUtils::ReadTInt32L( reader );
       
   417     CleanupStack::PopAndDestroy(); // reader
       
   418 
       
   419     return value;
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CCnUiUiFacade::ShowNoteL()
       
   424 // -----------------------------------------------------------------------------
       
   425 //
       
   426 void CCnUiUiFacade::ShowNoteL( TCnUiConnectionNotes aNoteId )
       
   427     {
       
   428     TInt resourceId( 0 );
       
   429     TCnUiConnUiNoteType noteType = EInfoNote;
       
   430     switch ( aNoteId )
       
   431         {
       
   432         case ECnUiConnectionOK:
       
   433             {
       
   434             //res & type ok
       
   435             resourceId = R_QTN_CHAT_LOGIN_OK;
       
   436             noteType = EInfoNote;
       
   437             break;
       
   438             }
       
   439 
       
   440         case ECnUiDisconnectedIM:
       
   441             {
       
   442             //res & type ok
       
   443             resourceId = R_QTN_CHAT_DISCONNECTED_CONF;
       
   444             noteType = EConfirmationNote;
       
   445             break;
       
   446             }
       
   447 
       
   448         case ECnUiDisconnectedPEC:
       
   449             {
       
   450             //res & type ok
       
   451             resourceId = R_QTN_DYC_DISCONNECTED_CONF;
       
   452             noteType = EConfirmationNote;
       
   453             break;
       
   454             }
       
   455 
       
   456         case ECnUiDisconnectedAutomaticConnection:
       
   457             {
       
   458             //res & type ok
       
   459             resourceId = R_QTN_CHAT_AUTOMATIC_CONN_ON;
       
   460             noteType = EInfoNote;
       
   461             break;
       
   462             }
       
   463 
       
   464 
       
   465         case ECnUiConnCanceled:
       
   466             {
       
   467             //res & type ok
       
   468             resourceId = R_QTN_CHAT_LOGING_CANCELED;
       
   469             noteType = EConfirmationNote;
       
   470             break;
       
   471             }
       
   472 
       
   473 
       
   474         case ECnUiConnForceLogout:
       
   475             {
       
   476             //res & type ok
       
   477             resourceId = R_QTN_CHAT_SERVER_DISCONNECTED_CLIENT;
       
   478             noteType = EInfoNote;
       
   479             break;
       
   480             }
       
   481 
       
   482 
       
   483         case ECnUiGPRSConnectionLost:
       
   484             {
       
   485             //Special case because here is used the system error text
       
   486             HBufC* systemErrorText = SystemErrorTextOrNullForCodeL( KErrNetConNoGPRSNetwork );
       
   487 
       
   488             //because supported error text are varied between releases, protect against
       
   489             //unknown text ==> note is shown with best effort
       
   490             if ( systemErrorText )
       
   491                 {
       
   492                 CleanupStack::PushL( systemErrorText );
       
   493                 //new code/////
       
   494                 if ( iControl )
       
   495                     {
       
   496                     CCoeEnv::Static()->AppUi()->RemoveFromStack( iControl );
       
   497                     delete iControl;
       
   498                     iControl = NULL;
       
   499                     }
       
   500                 ///////////////
       
   501                 DoShowNoteL( *systemErrorText, EErrorNote );
       
   502                 CleanupStack::PopAndDestroy( systemErrorText ); //systemErrorText
       
   503                 }
       
   504             return; //note is shown completely ==> return
       
   505             // no break needed because of return
       
   506             }
       
   507 
       
   508 
       
   509         default:
       
   510             {
       
   511             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   512             break;
       
   513             }
       
   514         }
       
   515     TBool requireSignOnAnim = IntResourceValueL( RSC_CHAT_VARIATION_SHOW_SIGN_IN_ANIMATION );
       
   516     if ( aNoteId == ECnUiConnectionOK && requireSignOnAnim )
       
   517         {
       
   518         iControl->PrepareForFocusGainL();
       
   519         iControl->SetFocus( ETrue );
       
   520         HBufC* prompt = iCoeEnv->AllocReadResourceLC( resourceId );
       
   521         //CEikLabel* aSignInLabel = static_cast<CEikLabel*>(iControl->ComponentControl(0));
       
   522         //aSignInLabel->SetTextL(*prompt);
       
   523         iControl->AssignSignInText( *prompt );
       
   524         iControl->HideStatus();
       
   525         iControl->StopAnimation();
       
   526         iControl->DrawNow();
       
   527         CleanupStack::PopAndDestroy( prompt ); //prompt
       
   528         }
       
   529     else
       
   530         {
       
   531         //new code/////
       
   532         if ( iControl )
       
   533             {
       
   534             CCoeEnv::Static()->AppUi()->RemoveFromStack( iControl );
       
   535             delete iControl;
       
   536             iControl = NULL;
       
   537             }
       
   538         ///////////////
       
   539         DoShowNoteL( resourceId, noteType );
       
   540         }
       
   541     }
       
   542 
       
   543 
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // CCnUiUiFacade::ShowNoteL()
       
   547 // -----------------------------------------------------------------------------
       
   548 //
       
   549 void CCnUiUiFacade::ShowNoteL( TCnUiConnectionNotesDynText aNoteId,
       
   550                                const TDesC& aInsertText )
       
   551     {
       
   552     TInt promptTextResourceId( 0 );
       
   553     TCnUiConnUiNoteType noteType = EErrorNote;
       
   554 
       
   555     switch ( aNoteId )
       
   556         {
       
   557         case ECnUiImproperPresenceId:
       
   558             {
       
   559             //res & type ok
       
   560             promptTextResourceId = R_QTN_CHAT_ERROR_WRONG_WVID;
       
   561             noteType = EErrorNote;
       
   562             break;
       
   563             }
       
   564 
       
   565         case ECnUiConnOperationAllreadyRunning:
       
   566             {
       
   567             //res & type ok
       
   568             promptTextResourceId = R_QTN_CHAT_LOGIN_ONGOING_NOTE;
       
   569             noteType = EInfoNote;
       
   570             break;
       
   571             }
       
   572 
       
   573         default:
       
   574             {
       
   575             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   576             break;
       
   577             }
       
   578         }
       
   579 
       
   580     HBufC* prompt = StringLoader::LoadLC( promptTextResourceId, aInsertText, iCoeEnv );
       
   581     DoShowNoteL( *prompt, noteType );
       
   582     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   583     }
       
   584 
       
   585 
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // CCnUiUiFacade::ShowLoginErrorNoteL()
       
   589 // -----------------------------------------------------------------------------
       
   590 //
       
   591 void CCnUiUiFacade::ShowLoginErrorNoteL( TInt aErrorCode )
       
   592     {
       
   593     //do first error code pre mapping
       
   594     if ( aErrorCode == KErrCommsLineFail )
       
   595         {
       
   596         aErrorCode = KCnUiErrGPRSConnectionNotAvailable; //GPRS connection not available
       
   597         }
       
   598 
       
   599 
       
   600     //now map the error to note
       
   601     TInt promptTextResourceId( KErrNotFound );
       
   602     TCnUiConnUiNoteType noteType = EErrorNote;
       
   603     switch ( aErrorCode )
       
   604         {
       
   605         case KErrNone:
       
   606             {
       
   607             //no error to show for KErrNone
       
   608             return;
       
   609             // no break needed because of return
       
   610             }
       
   611 
       
   612         case KErrCancel:
       
   613             {
       
   614             //res & type ok
       
   615             promptTextResourceId = R_QTN_CHAT_LOGING_CANCELED;
       
   616             noteType = EConfirmationNote;
       
   617             break;
       
   618             }
       
   619 
       
   620         case KCnUiErrorNetworkConnectionNotAllowed: //LoginFailedToOffLineMode
       
   621             {
       
   622             //res & type ok
       
   623             promptTextResourceId = R_QTN_OFFLINE_NOT_POSSIBLE;
       
   624             noteType = EErrorNote;
       
   625             break;
       
   626             }
       
   627 
       
   628         //flow trough
       
   629         case KPEngNwErrInvalidPassword:   //CSP - 409
       
   630         case KPEngNwErrUnknownUser:       //CSP - 531
       
   631         case KPEngNwErrInvalidOrUnSupportedUserProperties: //CSP - 702
       
   632             {
       
   633             //res & type ok
       
   634             promptTextResourceId = R_QTN_CHAT_LOGIN_PASSER_NOTE;
       
   635             noteType = EErrorNote;
       
   636             break;
       
   637             }
       
   638 
       
   639 
       
   640         case KPEngNwErrForbidden: //CSP - 403
       
   641             {
       
   642             //res & type ok
       
   643             promptTextResourceId = R_QTN_CHAT_LOGIN_ACCOUNT_LOST;
       
   644             noteType = EErrorNote;
       
   645             break;
       
   646             }
       
   647 
       
   648         //flow trough
       
   649         case KPEngNwErrServiceNotSupported:   //CSP - 405
       
   650         case KPEngNwErrServiceNotAgreed:      //CSP - 506
       
   651             {
       
   652             //res & type ok
       
   653             promptTextResourceId = R_QTN_CHAT_ERROR_SERVICE_ERR;
       
   654             noteType = EErrorNote;
       
   655             break;
       
   656             }
       
   657 
       
   658         //flow trough
       
   659         case KPEngNwErrServiceUnavailable:   //CSP - 503
       
   660         case KPEngNwErrMessageQueueIsFull:   //CSP - 507
       
   661             {
       
   662             //res & type ok
       
   663             promptTextResourceId = R_QTN_CHAT_ERROR_SERV_BUSY;
       
   664             noteType = EErrorNote;
       
   665             break;
       
   666             }
       
   667 
       
   668         //flow trough
       
   669         case KPEngNwErrSessionExpired:        //CSP - 600
       
   670         case KErrConnectionTerminated:        //login terminated by "red key" or from ConMan app.
       
   671         case KErrDisconnected:
       
   672         case KErrTimedOut:
       
   673         case KErrCouldNotConnect:
       
   674             {
       
   675             //res & type ok
       
   676             promptTextResourceId = R_QTN_CHAT_LOGIN_CONERROR_NOTE;
       
   677             noteType = EErrorNote;
       
   678             break;
       
   679             }
       
   680 
       
   681 
       
   682         case KPEngNwErrForcedLogout:          //CSP - 601
       
   683             {
       
   684             //res ok & type other
       
   685             promptTextResourceId = R_QTN_CHAT_SERVER_DISCONNECTED_CLIENT;
       
   686             noteType = EConfirmedErrorNote;
       
   687             break;
       
   688             }
       
   689 
       
   690         case KCnUiErrorInsufficientNWServerCapabilities:
       
   691             {
       
   692             //res & type ok
       
   693             promptTextResourceId = R_QTN_CHAT_INFO_NOT_SUP_CON;
       
   694             noteType = EConfirmedErrorNoteMSKSelectIcon;
       
   695             break;
       
   696             }
       
   697 
       
   698 
       
   699         case KPEngNwErrVersionNotSupported:   //CSP - 505
       
   700             {
       
   701             //res & type ok
       
   702             promptTextResourceId = R_QTN_CHAT_ERROR_GEN_ERROR;
       
   703             noteType = EErrorNote;
       
   704             break;
       
   705             }
       
   706 
       
   707 
       
   708         case KCnUiErrorSapMissingCompulsoryFields: //LoginMissingCompSettings
       
   709             {
       
   710             //res & type ok
       
   711             promptTextResourceId = R_QTN_CHAT_SETT_COMP_MISS;
       
   712             noteType = EErrorNote;
       
   713             break;
       
   714             }
       
   715 
       
   716 
       
   717         default:
       
   718             {
       
   719             //no any specific note mapped to error code
       
   720 
       
   721             //if error is unhandled CSP error ==> show default server error note
       
   722             if ( ( KPEngErrorWVServerResponseTop <= aErrorCode ) &&
       
   723                  ( aErrorCode <= KPEngErrorWVServerResponseBase ) )
       
   724                 {
       
   725                 promptTextResourceId = R_QTN_CHAT_ERROR_GEN_ERROR; //"Server error."
       
   726                 noteType = EErrorNote;
       
   727                 break;
       
   728                 }
       
   729 
       
   730             // error from impsengine that has not mapped into presence server error
       
   731             if ( ( KImpsGeneralError <= aErrorCode ) && ( aErrorCode <= KImpsErrorKeyIndexInvalid ) )
       
   732                 {
       
   733                 // map these to "No connection to service. Try again later."
       
   734                 promptTextResourceId = R_QTN_CHAT_LOGIN_CONERROR_NOTE;
       
   735                 noteType = EErrorNote;
       
   736                 break;
       
   737                 }
       
   738 
       
   739             //If error code is mapped to some system
       
   740             //error text, show it. Else default to own no connection error note.
       
   741             HBufC* systemErrorText = SystemErrorTextOrNullForCodeL( aErrorCode );
       
   742             if ( systemErrorText )
       
   743                 {
       
   744                 CleanupStack::PushL( systemErrorText );
       
   745                 //new code/////
       
   746                 if ( iControl )
       
   747                     {
       
   748                     CCoeEnv::Static()->AppUi()->RemoveFromStack( iControl );
       
   749                     delete iControl;
       
   750                     iControl = NULL;
       
   751                     }
       
   752                 ////////////////
       
   753                 DoShowNoteL( *systemErrorText, EErrorNote );
       
   754                 CleanupStack::PopAndDestroy( systemErrorText ); //systemErrorText
       
   755                 return;
       
   756                 }
       
   757             else
       
   758                 {
       
   759                 promptTextResourceId = R_QTN_CHAT_LOGIN_CONERROR_NOTE;  //"No connection to service. Try again later."
       
   760                 noteType = EErrorNote;
       
   761                 break;
       
   762                 }
       
   763             }
       
   764         }
       
   765 
       
   766 
       
   767     if ( promptTextResourceId != KErrNotFound )
       
   768         {
       
   769         //error mapped to some internal error string ==> show it
       
   770         // read variation flag values
       
   771         TBool requireSignOnAnim = IntResourceValueL( RSC_CHAT_VARIATION_SHOW_SIGN_IN_ANIMATION );
       
   772         if ( promptTextResourceId == R_QTN_CHAT_LOGING_CANCELED && requireSignOnAnim )
       
   773             {
       
   774             iControl->PrepareForFocusGainL();
       
   775             iControl->SetFocus( ETrue );
       
   776             HBufC* prompt = iCoeEnv->AllocReadResourceLC( promptTextResourceId );
       
   777             //CEikLabel* aSignInLabel = static_cast<CEikLabel*>(iControl->ComponentControl(0));
       
   778             //aSignInLabel->SetTextL(*prompt);
       
   779             iControl->AssignSignInText( *prompt );
       
   780             iControl->HideStatus();
       
   781             iControl->StopAnimation();
       
   782             iControl->DrawNow();
       
   783             CleanupStack::PopAndDestroy( prompt ); //prompt
       
   784             }
       
   785         else
       
   786             {
       
   787             //new code/////
       
   788             if ( iControl )
       
   789                 {
       
   790                 CCoeEnv::Static()->AppUi()->RemoveFromStack( iControl );
       
   791                 delete iControl;
       
   792                 iControl = NULL;
       
   793                 }
       
   794             ////////////////
       
   795             DoShowNoteL( promptTextResourceId, noteType );
       
   796             }
       
   797         }
       
   798     }
       
   799 
       
   800 
       
   801 // -----------------------------------------------------------------------------
       
   802 // CCnUiUiFacade::ShowLogoutErrorNoteL()
       
   803 // -----------------------------------------------------------------------------
       
   804 //
       
   805 void CCnUiUiFacade::ShowLogoutErrorNoteL( TInt aErrorCode )
       
   806     {
       
   807     //do first error code pre mapping
       
   808     if ( aErrorCode == KErrCommsLineFail )
       
   809         {
       
   810         aErrorCode = KCnUiErrGPRSConnectionNotAvailable; //GPRS connection not available
       
   811         }
       
   812 
       
   813     //now map the error to note
       
   814     TInt promptTextResourceId( KErrNotFound );
       
   815     TCnUiConnUiNoteType noteType = EErrorNote;
       
   816     switch ( aErrorCode )
       
   817         {
       
   818         case KErrNone:
       
   819             {
       
   820             //no error to show for KErrNone
       
   821             return;
       
   822             // no break needed because of return
       
   823             }
       
   824 
       
   825         //flow trough
       
   826         case KErrDisconnected:
       
   827         case KErrTimedOut:
       
   828         case KErrCouldNotConnect:
       
   829             {
       
   830             promptTextResourceId = R_QTN_CHAT_ERROR_GEN_ERROR;
       
   831             noteType = EErrorNote;
       
   832             break;
       
   833             }
       
   834 
       
   835         //flow trough
       
   836         case KPEngNwErrServiceUnavailable:   //CSP - 503
       
   837         case KPEngNwErrMessageQueueIsFull:   //CSP - 507
       
   838             {
       
   839             promptTextResourceId = R_QTN_CHAT_ERROR_SERV_BUSY;
       
   840             noteType = EErrorNote;
       
   841             break;
       
   842             }
       
   843 
       
   844         default:
       
   845             {
       
   846             //no any specific note mapped to error code
       
   847             //If error code is mapped to some system
       
   848             //error text, show it. Else default to
       
   849             //own default error note.
       
   850             HBufC* systemErrorText = SystemErrorTextOrNullForCodeL( aErrorCode );
       
   851             if ( systemErrorText )
       
   852                 {
       
   853                 CleanupStack::PushL( systemErrorText );
       
   854                 DoShowNoteL( *systemErrorText, EErrorNote );
       
   855                 CleanupStack::PopAndDestroy( systemErrorText ); //systemErrorText
       
   856                 return;
       
   857                 }
       
   858             else
       
   859                 {
       
   860                 promptTextResourceId = R_QTN_CHAT_ERROR_GEN_ERROR;
       
   861                 noteType = EErrorNote;
       
   862                 }
       
   863             break;
       
   864             }
       
   865         }
       
   866 
       
   867     if ( promptTextResourceId != KErrNotFound )
       
   868         {
       
   869         //error mapped to some internal error string ==> show it
       
   870         DoShowNoteL( promptTextResourceId, noteType );
       
   871         }
       
   872     }
       
   873 
       
   874 
       
   875 
       
   876 // -----------------------------------------------------------------------------
       
   877 // CCnUiUiFacade::ConfirmationQueryL()
       
   878 // -----------------------------------------------------------------------------
       
   879 //
       
   880 TBool CCnUiUiFacade::ConfirmationQueryL( TCnUiConnectionQueries aQueryId )
       
   881     {
       
   882     TInt resourceId( 0 );
       
   883     switch ( aQueryId )
       
   884         {
       
   885         case ECnUiCloseConnectionToNetwork:
       
   886             {
       
   887             //res & type ok
       
   888             resourceId = R_QTN_DYC_QUERY_EXIT_CONN_CLOSE;
       
   889             break;
       
   890             }
       
   891 
       
   892         default:
       
   893             {
       
   894             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   895             break;
       
   896             }
       
   897         }
       
   898 
       
   899     HBufC* prompt = StringLoader::LoadLC( resourceId, iCoeEnv );
       
   900     TBool selection = DoShowConfirmationQueryL( *prompt );
       
   901     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   902     return selection;
       
   903     }
       
   904 
       
   905 
       
   906 // -----------------------------------------------------------------------------
       
   907 // CCnUiUiFacade::ConfirmationQueryL()
       
   908 // -----------------------------------------------------------------------------
       
   909 //
       
   910 TBool CCnUiUiFacade::ConfirmationQueryL( TCnUiConnectionQueriesDynText aQueryId,
       
   911                                          const TDesC& aInsertText )
       
   912     {
       
   913     TInt resourceId( 0 );
       
   914     switch ( aQueryId )
       
   915         {
       
   916         case ECnUiDropPECLogin:
       
   917             {
       
   918             resourceId = R_QTN_CHAT_SETTING_CON_TO_CHAT;
       
   919             break;
       
   920             }
       
   921 
       
   922         case ECnUiDropIMLogin:
       
   923             {
       
   924             resourceId = R_QTN_CHAT_SETTING_CON_TO_PEC;
       
   925             break;
       
   926             }
       
   927 
       
   928         default:
       
   929             {
       
   930             CnUiPanicOrLeaveL( EIMPSConnUi_UnknownNoteID, KErrNotSupported );
       
   931             break;
       
   932             }
       
   933         }
       
   934 
       
   935 
       
   936     HBufC* prompt = StringLoader::LoadLC( resourceId, aInsertText, iCoeEnv );
       
   937     TBool selection = DoShowConfirmationQueryL( *prompt );
       
   938     CleanupStack::PopAndDestroy( prompt ); //prompt
       
   939     return selection;
       
   940     }
       
   941 
       
   942 
       
   943 // -----------------------------------------------------------------------------
       
   944 // CCnUiUiFacade::LoginQueryL()
       
   945 // -----------------------------------------------------------------------------
       
   946 //
       
   947 TBool CCnUiUiFacade::LoginQueryL( TDes& aUsername,
       
   948                                   TDes& aPassword,
       
   949                                   CIMPSSAPSettings& aSap,
       
   950                                   TCnUiLoginDataQueryMode aMode )
       
   951     {
       
   952 
       
   953 
       
   954     //Check for compulsory settings
       
   955     TInt compulsoryStatus = CCnUiConnOpener::CheckConnOpenCompulsorySettingsL( aSap );
       
   956     if ( compulsoryStatus != KErrNone )
       
   957         {
       
   958         ShowLoginErrorNoteL( KCnUiErrorSapMissingCompulsoryFields );
       
   959         return FALSE;
       
   960         }
       
   961     //
       
   962 
       
   963     // Show WAP registration query, if variated so
       
   964     TResourceReader reader;
       
   965     CCoeEnv::Static()->CreateResourceReaderLC( reader, RSC_CHAT_VARIATION_IMPSCU_SHOW_WAP_REGISTRATION_QUERY );
       
   966 
       
   967     TBool showWapRegQuery  = ResourceUtils::ReadTInt32L( reader );
       
   968     CleanupStack::PopAndDestroy(); // reader
       
   969 
       
   970 
       
   971     if ( showWapRegQuery )
       
   972         {
       
   973         // Get pointer to WAP registration settings
       
   974         CRepository* cenRep = CRepository::NewLC( KCRUidIMPSConnUI );
       
   975 
       
   976         TBool  isWAPQueryShown( EFalse );
       
   977         User::LeaveIfError( cenRep->Get( KFlagWapRegistrationDlgShown, isWAPQueryShown ) );
       
   978 
       
   979         if ( !isWAPQueryShown )
       
   980             {
       
   981             isWAPQueryShown = ETrue;
       
   982             User::LeaveIfError( cenRep->Set( KFlagWapRegistrationDlgShown, isWAPQueryShown ) );
       
   983 
       
   984             if ( ShowWAPQueryL() == EAknSoftkeyOk )
       
   985                 {
       
   986                 if ( ShowTAndCDlgL() == EAknSoftkeyOk )
       
   987                     {
       
   988                     // Open browser with the specified URL
       
   989                     HBufC16 *url = HBufC::NewLC( KMaxRegUrlLength );
       
   990                     TPtr ptr( url->Des() );
       
   991                     TInt urlLength;
       
   992 
       
   993                     if ( cenRep->Get( KWAPRegistrationURL, ptr, urlLength ) == KErrOverflow )
       
   994                         {
       
   995                         //because there could be an overflow
       
   996                         CleanupStack::PopAndDestroy( url );
       
   997 
       
   998                         url = HBufC::NewLC( urlLength );
       
   999                         ptr.Set( url->Des() );
       
  1000                         User::LeaveIfError( cenRep->Get( KWAPRegistrationURL, ptr, urlLength ) );
       
  1001                         }
       
  1002 
       
  1003                     OpenWebBrowserL( *url );
       
  1004                     CleanupStack::PopAndDestroy( url );
       
  1005                     }
       
  1006                 }
       
  1007             }
       
  1008 
       
  1009         CleanupStack::PopAndDestroy( cenRep );
       
  1010         }
       
  1011 
       
  1012 
       
  1013 
       
  1014     //check for branding
       
  1015     TInt showLoginQuery = KErrNone;
       
  1016 
       
  1017     showLoginQuery = IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_SHOW_UID_PW_QUERY ) ;
       
  1018 
       
  1019     // if username or password is empty we show the query overriding the variation
       
  1020     if ( ( aUsername.Length() == 0 ) || ( aPassword.Length() == 0 ) )
       
  1021         {
       
  1022         showLoginQuery = ETrue;
       
  1023         }
       
  1024 
       
  1025     if ( ! showLoginQuery )
       
  1026         {
       
  1027         // hide login query, assume as accepted
       
  1028         return ETrue;
       
  1029         }
       
  1030 
       
  1031     // Show domain selection query, if variated so
       
  1032     TBool domainQuery = IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_DOMAIN_SELECTION );
       
  1033     if ( aUsername.Length() == 0 && domainQuery )
       
  1034         {
       
  1035         if ( DisplayDomainSelectionQueryL( aUsername, &aSap ) == 0 )
       
  1036             {
       
  1037             // User cancelled the query
       
  1038             return EFalse;
       
  1039             }
       
  1040         if ( aUsername.Length() > 0 )
       
  1041             {
       
  1042             // User selected a domain
       
  1043             aMode = ECnUiEditPrefilledUser;
       
  1044             }
       
  1045         }
       
  1046 
       
  1047     TInt retVal( EAknSoftkeyCancel );
       
  1048 
       
  1049     if ( showWapRegQuery )
       
  1050         {
       
  1051         //  For
       
  1052         CCnOUiUsernameAndPwdQuery* query;
       
  1053         query = CCnOUiUsernameAndPwdQuery::NewL( aUsername,
       
  1054                                                  aPassword,
       
  1055                                                  aMode,
       
  1056                                                  domainQuery,
       
  1057                                                  *this );
       
  1058 
       
  1059         query->SetPredictiveTextInputPermitted( ETrue ); // T9
       
  1060 
       
  1061         //executeLD returns CEikBidCancel if user cancels the query,
       
  1062         //else the return value maps to the button ID.
       
  1063         //do here conversion from button ID's to plain TBools...
       
  1064 
       
  1065         query->PrepareLC( R_LOGIN_DATA_QUERY );
       
  1066 
       
  1067         query->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_CANCEL );
       
  1068         query->ButtonGroupContainer().DrawDeferred();
       
  1069 
       
  1070         retVal = query->RunLD();
       
  1071         }
       
  1072     else
       
  1073         {
       
  1074         CCnUiUsernameAndPwdQuery* query;
       
  1075         query = CCnUiUsernameAndPwdQuery::NewL( aUsername,
       
  1076                                                 aPassword,
       
  1077                                                 aMode,
       
  1078                                                 domainQuery,
       
  1079                                                 *this );
       
  1080         query->SetPredictiveTextInputPermitted( ETrue ); // T9
       
  1081 
       
  1082         //executeLD returns CEikBidCancel if user cancels the query,
       
  1083         //else the return value maps to the button ID.
       
  1084         //do here conversion from button ID's to plain TBools...
       
  1085         retVal = query->ExecuteLD( R_LOGIN_DATA_QUERY );
       
  1086         }
       
  1087     if ( retVal == EAknSoftkeyOk )
       
  1088         {
       
  1089         // Query accepted
       
  1090         return ETrue;
       
  1091         }
       
  1092     else if ( retVal == EAknSoftkeyExit && domainQuery )
       
  1093         {
       
  1094         // User cleared user id field, show domain selection query again
       
  1095         aUsername.Delete( 0, aUsername.Length() );
       
  1096         return LoginQueryL( aUsername, aPassword, aSap, aMode );
       
  1097         }
       
  1098 
       
  1099 
       
  1100     return EFalse;
       
  1101     }
       
  1102 
       
  1103 
       
  1104 // -----------------------------------------------------------------------------
       
  1105 // CCnUiUiFacade::ShowWAPQueryL
       
  1106 // -----------------------------------------------------------------------------
       
  1107 //
       
  1108 TInt CCnUiUiFacade::ShowWAPQueryL()
       
  1109     {
       
  1110     CAknMessageQueryDialog* msgQueryDlg = new( ELeave )CAknMessageQueryDialog( CAknMessageQueryDialog::ENoTone );
       
  1111     CleanupStack::PushL( msgQueryDlg );
       
  1112 
       
  1113     msgQueryDlg->PrepareLC( R_MESSAGE_QUERY );
       
  1114 
       
  1115     HBufC* resourceText = NULL;
       
  1116     resourceText = StringLoader::LoadLC( R_QTN_LSK_WAP_REG_ORANGE );
       
  1117     msgQueryDlg->ButtonGroupContainer().SetCommandL( 0, EAknSoftkeyOk, *resourceText );
       
  1118     CleanupStack::PopAndDestroy( resourceText );
       
  1119 
       
  1120     resourceText = StringLoader::LoadLC( R_QTN_RSK_WAP_IGNORE_ORANGE );
       
  1121     msgQueryDlg->ButtonGroupContainer().SetCommandL( 2, EAknSoftkeyCancel, *resourceText );
       
  1122     CleanupStack::PopAndDestroy( resourceText );
       
  1123 
       
  1124     resourceText = StringLoader::LoadL( R_QTN_NOTE_WAP_ORANGE );
       
  1125     msgQueryDlg->SetMessageText( *resourceText );
       
  1126 
       
  1127     resourceText = StringLoader::LoadL( R_QTN_NOTE_TITLE_WAP_ORANGE );
       
  1128     msgQueryDlg->SetHeaderText( *resourceText );
       
  1129 
       
  1130     CleanupStack::Pop( msgQueryDlg );
       
  1131 
       
  1132     TInt command = msgQueryDlg->RunLD();
       
  1133     return command;
       
  1134     }
       
  1135 
       
  1136 
       
  1137 // -----------------------------------------------------------------------------
       
  1138 // CCnUiUiFacade::ShowTAndCDlgL
       
  1139 // -----------------------------------------------------------------------------
       
  1140 //
       
  1141 TInt CCnUiUiFacade::ShowTAndCDlgL()
       
  1142     {
       
  1143     CAknMessageQueryDialog* msgQueryDlg = new( ELeave )CAknMessageQueryDialog( CAknMessageQueryDialog::ENoTone );
       
  1144     CleanupStack::PushL( msgQueryDlg );
       
  1145 
       
  1146     msgQueryDlg->PrepareLC( R_MESSAGE_QUERY );
       
  1147 
       
  1148     HBufC* resourceText = NULL;
       
  1149     resourceText = StringLoader::LoadLC( R_QTN_IM_AGREE_LSK_REGISTER );
       
  1150     msgQueryDlg->ButtonGroupContainer().SetCommandL( 0, EAknSoftkeyOk, *resourceText );
       
  1151     CleanupStack::PopAndDestroy( resourceText );
       
  1152 
       
  1153     resourceText = StringLoader::LoadLC( R_QTN_IM_REFUSE_RSK_REGISTER );
       
  1154     msgQueryDlg->ButtonGroupContainer().SetCommandL( 2, EAknSoftkeyCancel, *resourceText );
       
  1155     CleanupStack::PopAndDestroy( resourceText );
       
  1156 
       
  1157     resourceText = StringLoader::LoadL( R_QTN_NOTE_TERMS_WAP_ORANGE );
       
  1158     msgQueryDlg->SetMessageText( *resourceText );
       
  1159 
       
  1160     resourceText = StringLoader::LoadL( R_QTN_NOTE_TITLE_TERMS_WAP_ORANGE );
       
  1161     msgQueryDlg->SetHeaderText( *resourceText );
       
  1162 
       
  1163     CleanupStack::Pop( msgQueryDlg );
       
  1164 
       
  1165     TInt command = msgQueryDlg->RunLD();
       
  1166     return command;
       
  1167     }
       
  1168 
       
  1169 // -----------------------------------------------------------------------------
       
  1170 // CCnUiUiFacade::OpenWebBrowserL
       
  1171 // -----------------------------------------------------------------------------
       
  1172 //
       
  1173 void CCnUiUiFacade::OpenWebBrowserL( const TDesC& aUrl )
       
  1174     {
       
  1175     if ( !iBrLauncher )
       
  1176         {
       
  1177         iBrLauncher = CBrowserLauncher::NewL();
       
  1178         }
       
  1179 
       
  1180     //Asynchronous operation to launch the browser with aUrl
       
  1181     iBrLauncher->LaunchBrowserEmbeddedL( aUrl );
       
  1182     }
       
  1183 
       
  1184 
       
  1185 
       
  1186 // -----------------------------------------------------------------------------
       
  1187 // CCnUiUiFacade::MMCDrive
       
  1188 // -----------------------------------------------------------------------------
       
  1189 //
       
  1190 void CCnUiUiFacade::MMCDrive( TDes& aDrive ) const
       
  1191     {
       
  1192     TParsePtrC mmc( PathInfo::MemoryCardRootPath() );
       
  1193     aDrive.Zero();
       
  1194     aDrive.Append( mmc.Drive() );
       
  1195     }
       
  1196 
       
  1197 // -----------------------------------------------------------------------------
       
  1198 // CCnUiUiFacade::ConstructCompletePathAndCheck
       
  1199 // -----------------------------------------------------------------------------
       
  1200 //
       
  1201 TBool CCnUiUiFacade::ConstructCompletePathAndCheck( TDes& aResult,
       
  1202                                                     const TDesC& aModuleId,
       
  1203                                                     const TDesC& aAlternative,
       
  1204                                                     const TDesC& aFileName )
       
  1205     {
       
  1206     // Construct full path for wanted resource
       
  1207     // MMC drive letter must be here to make sure that TFindFile searches first
       
  1208     // MMC for the correct brand
       
  1209     MMCDrive( aResult );
       
  1210     aResult.Append( KRelativeBrandPath() );
       
  1211     aResult.Append( aModuleId );
       
  1212     aResult.Append( KDirSeparator );
       
  1213     aResult.Append( aAlternative );
       
  1214     aResult.Append( KDirSeparator );
       
  1215     aResult.Append( aFileName );
       
  1216 
       
  1217     // Find the actual file
       
  1218     TFindFile fileFinder( CEikonEnv::Static()->FsSession() );
       
  1219     TInt err( fileFinder.FindByDir( aFileName, aResult ) );
       
  1220 
       
  1221     // If file was found, then take the first appearance of it
       
  1222     // (order is correct aready)
       
  1223     if ( err == KErrNone )
       
  1224         {
       
  1225         aResult.Zero();
       
  1226         aResult.Append( fileFinder.File() );
       
  1227         }
       
  1228 
       
  1229 #ifdef _DEBUG
       
  1230     RDebug::Print( _L( "ConstructCompletePathAndCheck, TFindFile returned %d for %S" ), err, &aResult );
       
  1231 #endif
       
  1232 
       
  1233     // return was the file found or not
       
  1234     return err == KErrNone;
       
  1235     }
       
  1236 
       
  1237 
       
  1238 // -----------------------------------------------------------------------------
       
  1239 // CCnUiUiFacade::LoadServerIconsL()
       
  1240 // -----------------------------------------------------------------------------
       
  1241 //
       
  1242 void CCnUiUiFacade::LoadServerIconsL( MDesCArray& aServers )
       
  1243     {
       
  1244     TInt count( aServers.MdcaCount() );
       
  1245     __ASSERT_DEBUG( count > 0, User::Panic( KIMPSConnUi_PanicCat, KErrGeneral ) );
       
  1246     iIconArray = new( ELeave )CAknIconArray( count );
       
  1247 
       
  1248     // load icons
       
  1249     TBool allEmpty( ETrue );
       
  1250     HBufC* pathBuf = HBufC::NewLC( KMaxFileName );
       
  1251     TPtr path( pathBuf->Des() );
       
  1252 
       
  1253     CFbsBitmap* bitmap = NULL;
       
  1254     CFbsBitmap* mask = NULL;
       
  1255 
       
  1256     for ( TInt i( 0 ); i < count; i++ )
       
  1257         {
       
  1258         if ( !ConstructCompletePathAndCheck( path, KModuleId,
       
  1259                                              aServers.MdcaPoint( i ), KBitmapFile ) )
       
  1260             {
       
  1261             // not found, use empty
       
  1262             AknIconUtils::CreateIconLC( bitmap, mask, AknIconUtils::AvkonIconFileName(),
       
  1263                                         EMbmAvkonQgn_prop_empty, EMbmAvkonQgn_prop_empty_mask );
       
  1264             CleanupStack::Pop( 2 ); // bitmap, mask
       
  1265             // Code scanner warning neglected to put variable on cleanup stack (Id: 35)
       
  1266             // CAknIconArray::AppendL takes ownership of the icon
       
  1267             CGulIcon* gulIcon = CGulIcon::NewL( bitmap, mask ); // CSI: 35 # See above
       
  1268             iIconArray->AppendL( gulIcon );
       
  1269             }
       
  1270         else
       
  1271             {
       
  1272             // load the icon that was found
       
  1273             AknIconUtils::CreateIconLC( bitmap, mask, path, 0, 1 );
       
  1274             CleanupStack::Pop( 2 ); // bitmap, mask
       
  1275             // Code scanner warning neglected to put variable on cleanup stack (Id: 35)
       
  1276             // CAknIconArray::AppendL takes ownership of the icon
       
  1277             CGulIcon* gulIcon = CGulIcon::NewL( bitmap, mask ); // CSI: 35 # See above
       
  1278             iIconArray->AppendL( gulIcon );
       
  1279             allEmpty = EFalse;
       
  1280             }
       
  1281         }
       
  1282     CleanupStack::PopAndDestroy( pathBuf );
       
  1283 
       
  1284     if ( allEmpty )
       
  1285         {
       
  1286         // every icon is empty, delete whole array and show list without icons
       
  1287         delete iIconArray;
       
  1288         iIconArray = NULL;
       
  1289         }
       
  1290     }
       
  1291 
       
  1292 
       
  1293 
       
  1294 // -----------------------------------------------------------------------------
       
  1295 // CCnUiUiFacade::OpenResourceFileLC()
       
  1296 // !!!Notice!!!. Two variables in cleanupstack after call of this method.
       
  1297 // -----------------------------------------------------------------------------
       
  1298 //
       
  1299 void CCnUiUiFacade::OpenResourceFileLC( RResourceFile& aResourceFile )
       
  1300     {
       
  1301     TFileName resourceFileName;
       
  1302     iRFs.Close();
       
  1303     User::LeaveIfError( iRFs.Connect() );
       
  1304 
       
  1305     TInt err = iSharedData->GetStringKey( ( TIMPSSharedKeys )KBrandingResourceKey, resourceFileName );
       
  1306     if ( err || !resourceFileName.Length() )
       
  1307         {
       
  1308         CnUiResourceFileName::NearestVariationForCurrentLanguage( iRFs, resourceFileName  );
       
  1309         }
       
  1310     aResourceFile.OpenL( iRFs, resourceFileName );
       
  1311     CleanupClosePushL( aResourceFile );
       
  1312     aResourceFile.ConfirmSignatureL();
       
  1313     }
       
  1314 
       
  1315 
       
  1316 // -----------------------------------------------------------------------------
       
  1317 // CCnUiUiFacade::IntResourceValueL()
       
  1318 // -----------------------------------------------------------------------------
       
  1319 //
       
  1320 TInt CCnUiUiFacade::IntResourceValueL( TInt aResourceId )
       
  1321     {
       
  1322 
       
  1323     TInt val( 0 );
       
  1324     TInt err ( KErrNone );
       
  1325     CRepository* rep = 0;
       
  1326 
       
  1327     TRAP( err, rep = CRepository::NewL( KCRUidIMNG ) );
       
  1328 
       
  1329     if ( err == KErrNone )
       
  1330         {
       
  1331         TInt key = aResourceId + KIMCUStartVariationID;
       
  1332 
       
  1333         err = rep->Get( key, val );
       
  1334 
       
  1335         delete rep;
       
  1336         }
       
  1337 
       
  1338     if ( err != KErrNone )
       
  1339         {
       
  1340         RResourceFile resFile;
       
  1341         OpenResourceFileLC( resFile ); // Two items in cleanup stack.
       
  1342 
       
  1343         aResourceId = aResourceId + RSC_CRRSS_CHAT_VARIATION_IMPSCU_START_ID;
       
  1344 
       
  1345         // read the data to a buffer
       
  1346         TInt plainResourceId = 0x00000fff & aResourceId; // Remove offset from id
       
  1347         HBufC8* rawDataBuf = resFile.AllocReadLC( plainResourceId );
       
  1348 
       
  1349         // it's now as ascii code: \x00 for 0, \x01 for 1, etc.
       
  1350         TUint value = ( *rawDataBuf )[ 0 ];
       
  1351 
       
  1352         CleanupStack::PopAndDestroy( 2 ); // rawDataBuf, resFile
       
  1353 
       
  1354         val = value;
       
  1355 
       
  1356         }
       
  1357 
       
  1358     return val;
       
  1359 
       
  1360     }
       
  1361 
       
  1362 // -----------------------------------------------------------------------------
       
  1363 // CCnUiUiFacade::ServerToUseQueryL()
       
  1364 // -----------------------------------------------------------------------------
       
  1365 //
       
  1366 TBool CCnUiUiFacade::ServerToUseQueryL( MDesCArray& aServers,
       
  1367                                         TInt aIndexToHighlight,
       
  1368                                         TInt& aSelectedIndex )
       
  1369     {
       
  1370     if ( aServers.MdcaCount() == 0 || aServers.MdcaCount() == 1 )
       
  1371         {
       
  1372         User::Leave( KErrNotSupported );
       
  1373         }
       
  1374 
       
  1375     TRAPD( err, LoadServerIconsL( aServers ) );
       
  1376     if ( err != KErrNone )
       
  1377         {
       
  1378         // didn't manage to load bitmaps, try to show the list without them
       
  1379         delete iIconArray;
       
  1380         iIconArray = NULL;
       
  1381         }
       
  1382 
       
  1383     TInt selection( -1 );
       
  1384     TInt retVal( -1 );
       
  1385     // Code scanner warning neglected to put variable on cleanup stack (Id: 35)
       
  1386     // PrepareLC pushes the dialog into cleanupstack
       
  1387     CAknListQueryDialog* listQuery = new ( ELeave ) CAknListQueryDialog( &selection ); // CSI: 35 # See above
       
  1388 
       
  1389     if ( iIconArray )
       
  1390         {
       
  1391         // icon array exists, construct the query with icons
       
  1392         listQuery->PrepareLC( R_SERVER_TO_LOGIN_LISTQUERY_GRAPHIC );
       
  1393         listQuery->SetIconArrayL( iIconArray );
       
  1394         iIconArray = NULL; // listbox has the ownership of icon array
       
  1395 
       
  1396         // construct formatted text array
       
  1397         TInt count( aServers.MdcaCount() );
       
  1398         CDesCArray* items = new( ELeave )CDesCArrayFlat( count );
       
  1399         CleanupStack::PushL( items );
       
  1400         for ( TInt i( 0 ); i < count; i++ )
       
  1401             {
       
  1402             TPtrC item( aServers.MdcaPoint( i ) );
       
  1403 
       
  1404             // 5 is more than enough for formatted number in front of server list
       
  1405             HBufC* temp = HBufC::NewLC( item.Length() + KTab().Length() + 5 );
       
  1406             TPtr tempPtr( temp->Des() );
       
  1407             tempPtr.Num( i );
       
  1408             tempPtr.Append( KTab );
       
  1409             tempPtr.Append( item );
       
  1410 
       
  1411             items->AppendL( tempPtr );
       
  1412             CleanupStack::PopAndDestroy( temp );
       
  1413             }
       
  1414 
       
  1415         listQuery->SetItemTextArray( items );
       
  1416         listQuery->SetOwnershipType( ELbmOwnsItemArray );
       
  1417         CleanupStack::Pop( items ); // listbox model owns the item array
       
  1418         }
       
  1419     else
       
  1420         {
       
  1421         // icon array doesn't exist, construct the query without icons
       
  1422         listQuery->PrepareLC( R_SERVER_TO_LOGIN_LISTQUERY );
       
  1423 
       
  1424         listQuery->SetItemTextArray( &aServers );
       
  1425         listQuery->SetOwnershipType( ELbmDoesNotOwnItemArray ); // listbox model doesn't own the item array
       
  1426         }
       
  1427 
       
  1428     //check is the index to highlight on the range...
       
  1429     if ( ( aIndexToHighlight > 0 ) && ( aIndexToHighlight < aServers.MdcaCount() ) )
       
  1430         {
       
  1431         listQuery->ListBox()->SetCurrentItemIndex( aIndexToHighlight );
       
  1432         }
       
  1433 
       
  1434     retVal = listQuery->RunLD(); //execute the selection
       
  1435 
       
  1436 
       
  1437     // if selection made and not cancelled
       
  1438     if ( ( selection >= 0 ) && ( retVal != 0 ) )
       
  1439         {
       
  1440         aSelectedIndex = selection;
       
  1441         return ETrue;
       
  1442         }
       
  1443 
       
  1444 
       
  1445     return EFalse;
       
  1446     }
       
  1447 
       
  1448 
       
  1449 
       
  1450 // -----------------------------------------------------------------------------
       
  1451 // CCnUiUiFacade::HandleIfError()
       
  1452 // -----------------------------------------------------------------------------
       
  1453 //
       
  1454 void CCnUiUiFacade::HandleIfError( TInt aErr )
       
  1455     {
       
  1456     if ( aErr != KErrNone )
       
  1457         {
       
  1458         CEikonEnv::Static()->HandleError( aErr );
       
  1459         }
       
  1460     }
       
  1461 
       
  1462 
       
  1463 // -----------------------------------------------------------------------------
       
  1464 // CCnUiUiFacade::SwitchResourceFileL()
       
  1465 // -----------------------------------------------------------------------------
       
  1466 //
       
  1467 void CCnUiUiFacade::SwitchResourceFileL( const TDesC& aNewResourceFile )
       
  1468     {
       
  1469     UseResourceFileL( aNewResourceFile );
       
  1470     }
       
  1471 
       
  1472 // -----------------------------------------------------------------------------
       
  1473 // CCnUiUiFacade::DisplayDomainSelectionQueryL
       
  1474 // -----------------------------------------------------------------------------
       
  1475 //
       
  1476 TInt CCnUiUiFacade::DisplayDomainSelectionQueryL( TDes& aSelectedDomain,
       
  1477                                                   CIMPSSAPSettings* aSap /*= NULL*/ )
       
  1478     {
       
  1479     TInt selection( -1 );
       
  1480     TInt result( 0 );
       
  1481 
       
  1482     CDesCArray* listTexts = NULL;
       
  1483 
       
  1484     TResourceReader reader;
       
  1485     iCoeEnv->CreateResourceReaderLC( reader,
       
  1486                                      R_CHAT_VARIATION_IMPSCU_DOMAIN_SELECTION_LIST );
       
  1487 
       
  1488     // Check if there are any predefined domains
       
  1489     // Check is needed because ReadDesC16ArrayResourceL
       
  1490     // panics if there aren't any items defined in resource array
       
  1491     if ( reader.ReadInt16() > 0 )
       
  1492         {
       
  1493         listTexts = iCoeEnv->ReadDesC16ArrayResourceL(
       
  1494                         R_CHAT_VARIATION_IMPSCU_DOMAIN_SELECTION_LIST );
       
  1495         }
       
  1496     else
       
  1497         {
       
  1498         listTexts = new ( ELeave ) CDesCArrayFlat( 1 ); // 1 for granularity
       
  1499         }
       
  1500 
       
  1501     CleanupStack::PopAndDestroy(); // reader
       
  1502     CleanupStack::PushL( listTexts );
       
  1503     HBufC* lastItem = NULL;
       
  1504     lastItem = StringLoader::LoadLC( R_CHAT_LOGIN_SELECT_DOMAIN_OTHER );
       
  1505     listTexts->AppendL( lastItem->Des() );
       
  1506     CleanupStack::PopAndDestroy( ); // lastItem
       
  1507 
       
  1508     CCnUiDomainSelectionQueryDialog* dlg =
       
  1509         CCnUiDomainSelectionQueryDialog::NewL( &selection, aSap );
       
  1510     dlg->PrepareLC( R_CHAT_VARIATION_IMPSCU_DOMAIN_SELECTION_QUERY );
       
  1511     dlg->SetItemTextArray( listTexts );
       
  1512     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
  1513     result = dlg->RunLD();
       
  1514 
       
  1515     // if selection made and it's not the last item,
       
  1516     // and query is not cancelled
       
  1517     if ( ( selection >= 0 ) && ( selection < ( listTexts->Count() - 1 ) )
       
  1518          && ( result != EAknSoftkeyCancel ) )
       
  1519         {
       
  1520         aSelectedDomain = listTexts->MdcaPoint( selection );
       
  1521         }
       
  1522     CleanupStack::PopAndDestroy( listTexts );
       
  1523 
       
  1524     return result;
       
  1525     }
       
  1526 
       
  1527 // -----------------------------------------------------------------------------
       
  1528 // CCnUiUiFacade::DisplayTermsOfUseAndQueryL()
       
  1529 // -----------------------------------------------------------------------------
       
  1530 //
       
  1531 TBool CCnUiUiFacade::DisplayTermsOfUseAndQueryL()
       
  1532     {
       
  1533     TInt retVal = -1;
       
  1534 
       
  1535     // Get branded resource file name
       
  1536     TFileName resourceFileName;
       
  1537     TInt err = iSharedData->GetStringKey(
       
  1538                    ( TIMPSSharedKeys )KBrandingResourceKey, resourceFileName );
       
  1539     if ( err != KErrNone || resourceFileName.Length() == 0 )
       
  1540         {
       
  1541         // No branded resources, return
       
  1542         return ETrue;
       
  1543         }
       
  1544 
       
  1545     // Get current servers branding root
       
  1546     TChar backSlash( KBackSlash );
       
  1547     // Locate first backslash starting from the end of
       
  1548     // the path
       
  1549     TFileName touFileName;
       
  1550     TInt pos = resourceFileName.LocateReverse( backSlash );
       
  1551     if ( pos != KErrNotFound )
       
  1552         {
       
  1553         touFileName.Append( resourceFileName.Left( pos ) );
       
  1554         touFileName.Append( KDirSeparator );
       
  1555         touFileName.Append( KCUITOUFile );
       
  1556         BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), touFileName );
       
  1557         }
       
  1558     // Check that file exists
       
  1559     if ( !BaflUtils::FileExists( iCoeEnv->FsSession(), touFileName ) )
       
  1560         {
       
  1561         // No file for ToU, return
       
  1562         return ETrue;
       
  1563         }
       
  1564 
       
  1565     CCnUiTermsOfUseDlg* dlg = CCnUiTermsOfUseDlg::NewLC( touFileName );
       
  1566     retVal = dlg->RunDialogLD( R_CNUI_TERMS_OF_USE_DIALOG );
       
  1567     CleanupStack::Pop( dlg );
       
  1568 
       
  1569     if ( retVal == EAknSoftkeyCancel )
       
  1570         {
       
  1571         ShowNoteL( ECnUiConnCanceled );
       
  1572         return EFalse;
       
  1573         }
       
  1574     else
       
  1575         {
       
  1576         return ETrue;
       
  1577         }
       
  1578     }
       
  1579 
       
  1580 // -----------------------------------------------------------------------------
       
  1581 // CCnUiUiFacade::UseResourceFileL()
       
  1582 // -----------------------------------------------------------------------------
       
  1583 //
       
  1584 void CCnUiUiFacade::UseResourceFileL( const TDesC& aNewResourceFile )
       
  1585     {
       
  1586     RemoveUsedResourceFile();
       
  1587 
       
  1588     if ( aNewResourceFile.Length() == 0 )
       
  1589         {
       
  1590         //empty resource file name ==> use the default resource
       
  1591         iResourceFileOffset = iCoeEnv->AddResourceFileL( *iDefaultRssFileName );
       
  1592         }
       
  1593     else
       
  1594         {
       
  1595         // Code scanner warning not using BaflUtils::NearestLanguageFile()
       
  1596         // when loading a resource file (Id: 53) ignored because
       
  1597         // the resource file given here is from branding and NearestLanguageFile
       
  1598         // is already used before it is given here
       
  1599         iResourceFileOffset = iCoeEnv->AddResourceFileL( aNewResourceFile ); // CSI: 53 # See above
       
  1600         }
       
  1601 
       
  1602     iResourceFileAdded = ETrue;
       
  1603     }
       
  1604 
       
  1605 
       
  1606 // -----------------------------------------------------------------------------
       
  1607 // CCnUiUiFacade::ResourceFileNameL()
       
  1608 // -----------------------------------------------------------------------------
       
  1609 //
       
  1610 void CCnUiUiFacade::ResourceFileNameL( TDes& aResourceFileName )
       
  1611     {
       
  1612     if ( aResourceFileName.MaxLength() < iDefaultRssFileName->Length() )
       
  1613         {
       
  1614         User::Leave( KErrOverflow );
       
  1615         }
       
  1616 
       
  1617     aResourceFileName.Copy( *iDefaultRssFileName );
       
  1618     }
       
  1619 
       
  1620 
       
  1621 // -----------------------------------------------------------------------------
       
  1622 // CCnUiUiFacade::RemoveUsedResourceFile()
       
  1623 // -----------------------------------------------------------------------------
       
  1624 //
       
  1625 void CCnUiUiFacade::RemoveUsedResourceFile()
       
  1626     {
       
  1627     if ( iCoeEnv && iResourceFileAdded )
       
  1628         {
       
  1629         iCoeEnv->DeleteResourceFile( iResourceFileOffset );
       
  1630         }
       
  1631 
       
  1632     iResourceFileAdded = EFalse;
       
  1633     }
       
  1634 
       
  1635 
       
  1636 // -----------------------------------------------------------------------------
       
  1637 // CCnUiUiFacade::SystemErrorTextOrNullForCodeL()
       
  1638 // Private helper.
       
  1639 // -----------------------------------------------------------------------------
       
  1640 //
       
  1641 HBufC* CCnUiUiFacade::SystemErrorTextOrNullForCodeL( TInt aErrorCode )
       
  1642     {
       
  1643     HBufC* systemErrorText = NULL;
       
  1644 
       
  1645     TUint flags( 0 );
       
  1646     TInt id( 0 );
       
  1647 
       
  1648     // Resolve the error
       
  1649     // Automatic context causes there to come the "default"
       
  1650     // context title for error note, like:
       
  1651     //"Internet: Could not resolve host address."
       
  1652     CTextResolver* textResolver = CTextResolver::NewLC();
       
  1653     TPtrC systemText( textResolver->ResolveErrorString( aErrorCode, id, flags,
       
  1654                                                         CTextResolver::ECtxAutomatic ) );
       
  1655     // textresolver seems to put OOM flag on in some cases when it does not find
       
  1656     // the error text
       
  1657     // if there is OOM flag on, but NO blank or unknown error flag, then
       
  1658     // we probably are running out of memory
       
  1659     if ( ( flags & EErrorResOOMFlag ) &&
       
  1660          !( flags & ETextResolverBlankErrorFlag ) &&
       
  1661          !( flags & ETextResolverUnknownErrorFlag ) )
       
  1662         {
       
  1663         User::Leave( KErrNoMemory );
       
  1664         }
       
  1665 
       
  1666     if ( ( flags & ETextResolverBlankErrorFlag ) ||
       
  1667          ( flags & ETextResolverUnknownErrorFlag ) ||
       
  1668          ( systemText.Length() == 0 ) )
       
  1669         {
       
  1670         //Actual error is mapped to blank
       
  1671         //or it is a unknown error
       
  1672         systemErrorText = NULL;
       
  1673         }
       
  1674     else
       
  1675         {
       
  1676         //There should be some error text, use it
       
  1677         systemErrorText = systemText.AllocL();
       
  1678         }
       
  1679 
       
  1680     CleanupStack::PopAndDestroy( textResolver ); //textResolver
       
  1681     return systemErrorText;
       
  1682     }
       
  1683 
       
  1684 
       
  1685 // -----------------------------------------------------------------------------
       
  1686 // CCnUiUiFacade::DoShowNoteL()
       
  1687 // Private helper.
       
  1688 // -----------------------------------------------------------------------------
       
  1689 //
       
  1690 void CCnUiUiFacade::DoShowNoteL( TInt aNoteTextResourceId, TCnUiConnUiNoteType aNoteType )
       
  1691     {
       
  1692     HBufC* prompt = iCoeEnv->AllocReadResourceLC( aNoteTextResourceId );
       
  1693     DoShowNoteL( *prompt, aNoteType );
       
  1694     CleanupStack::PopAndDestroy( prompt ); //prompt
       
  1695     }
       
  1696 
       
  1697 
       
  1698 // -----------------------------------------------------------------------------
       
  1699 // CCnUiUiFacade::DoShowNoteL()
       
  1700 // Private helper.
       
  1701 // -----------------------------------------------------------------------------
       
  1702 //
       
  1703 void CCnUiUiFacade::DoShowNoteL( const TDesC& aNotePrompt, TCnUiConnUiNoteType aNoteType )
       
  1704     {
       
  1705     if ( aNoteType == EConfirmedErrorNote )
       
  1706         {
       
  1707         CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  1708         CleanupStack::PushL( query );
       
  1709         query->SetPromptL( aNotePrompt );
       
  1710         CleanupStack::Pop( query ); //query
       
  1711         query->ExecuteLD( R_CONFIRMED_ERROR_NOTE );
       
  1712         }
       
  1713     else if ( aNoteType == EConfirmedErrorNoteMSKSelectIcon )
       
  1714         {
       
  1715         CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  1716         CleanupStack::PushL( query );
       
  1717         query->SetPromptL( aNotePrompt );
       
  1718         CleanupStack::Pop( query ); //query
       
  1719         query->ExecuteLD( R_CONFIRMED_ERROR_NOTE_MSK );
       
  1720         }
       
  1721     else
       
  1722         {
       
  1723         CAknResourceNoteDialog* note = NULL;
       
  1724         switch ( aNoteType )
       
  1725             {
       
  1726             case EInfoNote:
       
  1727                 {
       
  1728                 note = new ( ELeave ) CAknInformationNote( ETrue );
       
  1729                 break;
       
  1730                 }
       
  1731 
       
  1732             case EConfirmationNote:
       
  1733                 {
       
  1734                 note = new ( ELeave ) CAknConfirmationNote( ETrue );
       
  1735                 break;
       
  1736                 }
       
  1737 
       
  1738             //flow through
       
  1739             case EErrorNote:
       
  1740             default:
       
  1741                 {
       
  1742                 note = new ( ELeave ) CAknErrorNote( ETrue );
       
  1743                 break;
       
  1744                 }
       
  1745             }
       
  1746 
       
  1747         note->ExecuteLD( aNotePrompt );
       
  1748         }
       
  1749     }
       
  1750 
       
  1751 
       
  1752 
       
  1753 // -----------------------------------------------------------------------------
       
  1754 // CCnUiUiFacade::DoShowConfirmationQueryL()
       
  1755 // -----------------------------------------------------------------------------
       
  1756 //
       
  1757 TBool CCnUiUiFacade::DoShowConfirmationQueryL( const TDesC& aPromptText )
       
  1758     {
       
  1759     CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  1760     CleanupStack::PushL( query );
       
  1761     query->SetPromptL( aPromptText );
       
  1762     CleanupStack::Pop( query ); //query
       
  1763     return query->ExecuteLD( R_GENERAL_QUERY );
       
  1764     }
       
  1765 
       
  1766 //  End of File