wvuing/IMPSConnectionUI/UISrc/CCnUiGlobalNotificationUiFacade.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     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:  Global notification UI implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include  "CCnUiGlobalNotificationUiFacade.h"
       
    20 #include  "CnUiResourceFileName.h"
       
    21 #include  "CCnUiGlobalNoteContainer.h"
       
    22 #include  "CCnUiClientGroupUiNotifyMediator.h"
       
    23 
       
    24 #include <StringLoader.h>
       
    25 #include <IMPSConnectionUiNG.rsg>
       
    26 #include <avkon.rsg>
       
    27 
       
    28 // ================= GLOBAL FUNCTIONS ====================
       
    29 // -----------------------------------------------------------------------------
       
    30 // CreateGlobalNotificationUiFacadeL()
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 GLREF_C MCnUiGlobalNotificationUiFacade* CreateGlobalNotificationUiFacadeL()
       
    34     {
       
    35     return CCnUiGlobalNotificationUiFacade::NewL();
       
    36     }
       
    37 
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 CCnUiGlobalNotificationUiFacade* CCnUiGlobalNotificationUiFacade::NewL()
       
    41     {
       
    42     CCnUiGlobalNotificationUiFacade* self = new ( ELeave ) CCnUiGlobalNotificationUiFacade();
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL();
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 
       
    50 
       
    51 // C++ default constructor can NOT contain any code, that
       
    52 // might leave.
       
    53 //
       
    54 CCnUiGlobalNotificationUiFacade::CCnUiGlobalNotificationUiFacade()
       
    55     {
       
    56     }
       
    57 
       
    58 
       
    59 // Destructor
       
    60 CCnUiGlobalNotificationUiFacade::~CCnUiGlobalNotificationUiFacade()
       
    61     {
       
    62     iResFile.Close();
       
    63     iFs.Close();
       
    64     }
       
    65 
       
    66 
       
    67 // Symbian OS default constructor can leave.
       
    68 void CCnUiGlobalNotificationUiFacade::ConstructL()
       
    69     {
       
    70     User::LeaveIfError( iFs.Connect() );
       
    71 
       
    72     TFileName resourceFileName;
       
    73     CnUiResourceFileName::NearestForCurrentLanguage( iFs, resourceFileName  );
       
    74     iResFile.OpenL( iFs, resourceFileName );
       
    75     iResFile.ConfirmSignatureL();
       
    76     }
       
    77 
       
    78 
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CCnUiGlobalNotificationUiFacade::ShowLoginUserDataErrorL()
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CCnUiGlobalNotificationUiFacade::ShowLoginUserDataErrorL( const TDesC& aServerName )
       
    85     {
       
    86     //AA Error - dynamic global note, information note icon
       
    87     HBufC* promptText = ReadResourceWithDynTextLC( R_QTN_CHAT_INCOR_USERNAMES_NOCON, aServerName );
       
    88 
       
    89     CCnUiGlobalNoteContainer* gnc = CCnUiGlobalNoteContainer::NewLC();
       
    90     gnc->ShowWaitingNoteL( *promptText );
       
    91     CleanupStack::PopAndDestroy( 2 ); //globalNote, promptText
       
    92     }
       
    93 
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CCnUiGlobalNotificationUiFacade::ShowLoginDetailedErrorL()
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CCnUiGlobalNotificationUiFacade::ShowLoginDetailedErrorL( const TDesC& aServerName,
       
   101                                                                const TDesC& aDetErrDescription )
       
   102     {
       
   103     //AA Error - dynamic global note, information note icon + detailed note if needed
       
   104     HBufC* promptText = ReadResourceWithDynTextLC( R_QTN_CHAT_AUTOM_CON_FAILED, aServerName );
       
   105     CCnUiGlobalNoteContainer* gnc = CCnUiGlobalNoteContainer::NewLC();
       
   106 
       
   107     if ( aDetErrDescription.Length() > 0 )
       
   108         {
       
   109         gnc->ShowWaitigDetailedNoteL( *promptText, aDetErrDescription );
       
   110         }
       
   111     else
       
   112         {
       
   113         //detailed description is empty, default to system error
       
   114         //compare to CCnUiUiFacade and login / logout errors
       
   115         HBufC* defaultDetErrDesc = ReadResourceLC( R_QTN_CHAT_ERROR_GEN_ERROR );
       
   116         gnc->ShowWaitigDetailedNoteL( *promptText, *defaultDetErrDesc );
       
   117         CleanupStack::PopAndDestroy( defaultDetErrDesc ); //defaultDetErrDesc
       
   118         }
       
   119 
       
   120     CleanupStack::PopAndDestroy( 2 ); //gnc, promptText
       
   121     }
       
   122 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CCnUiGlobalNotificationUiFacade::ShowLoginDetailedErrorL()
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CCnUiGlobalNotificationUiFacade::ShowLoginDetailedErrorL( const TDesC& aServerName,
       
   129                                                                TInt aNoteTextResourceId )
       
   130     {
       
   131     //AA Error - dynamic global note, information note icon + detailed note if needed
       
   132     HBufC* promptText = ReadResourceWithDynTextLC( R_QTN_CHAT_AUTOM_CON_FAILED, aServerName );
       
   133     CCnUiGlobalNoteContainer* gnc = CCnUiGlobalNoteContainer::NewLC();
       
   134 
       
   135     if ( aNoteTextResourceId != KErrNone )
       
   136         {
       
   137         HBufC* errorText = ReadResourceLC( aNoteTextResourceId );
       
   138         gnc->ShowWaitigDetailedNoteL( *promptText, *errorText );
       
   139         CleanupStack::PopAndDestroy( errorText );
       
   140         }
       
   141     else
       
   142         {
       
   143         //detailed description is empty, default to system error
       
   144         //compare to CCnUiUiFacade and login / logout errors
       
   145         HBufC* defaultDetErrDesc = ReadResourceLC( R_QTN_CHAT_ERROR_GEN_ERROR );
       
   146         gnc->ShowWaitigDetailedNoteL( *promptText, *defaultDetErrDesc );
       
   147         CleanupStack::PopAndDestroy( defaultDetErrDesc ); //defaultDetErrDesc
       
   148         }
       
   149 
       
   150     CleanupStack::PopAndDestroy( 2 ); //gnc, promptText
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CCnUiGlobalNotificationUiFacade::CGQActiveConnectionSuppressForScheduledConnectionL()
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 TBool CCnUiGlobalNotificationUiFacade::CGQActiveConnectionScheduledCloseL(
       
   158     const TArray<TIMPSConnectionClient>& aClientsToShow )
       
   159     {
       
   160     __ASSERT_ALWAYS( aClientsToShow.Count(), User::Leave( KErrArgument ) );
       
   161 
       
   162     CCnUiClientGroupUiNotifyMediator* cgNM = CCnUiClientGroupUiNotifyMediator::NewLC();
       
   163     TBool ret = cgNM->CGQActiveConnectionScheduledCloseL( aClientsToShow );
       
   164     CleanupStack::PopAndDestroy( cgNM ); //gnc
       
   165     return ret;
       
   166     }
       
   167 
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CCnUiGlobalNotificationUiFacade::CGQActiveConnectionSuppressForScheduledConnectionL()
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 TBool CCnUiGlobalNotificationUiFacade::CGQActiveConnectionSuppressForScheduledConnectionL(
       
   174     const TDesC& aServerName,
       
   175     const TArray<TIMPSConnectionClient>& aClientsToShow )
       
   176 
       
   177     {
       
   178     __ASSERT_ALWAYS( aClientsToShow.Count(), User::Leave( KErrArgument ) );
       
   179 
       
   180     CCnUiClientGroupUiNotifyMediator* cgNM = CCnUiClientGroupUiNotifyMediator::NewLC();
       
   181     TBool ret = cgNM->CGQActiveConnectionSuppressForScheduledConnectionL(
       
   182                     aServerName, aClientsToShow );
       
   183     CleanupStack::PopAndDestroy( cgNM ); //gnc
       
   184     return ret;
       
   185     }
       
   186 
       
   187 
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CCnUiGlobalNotificationUiFacade::ReadResourceLC()
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 HBufC* CCnUiGlobalNotificationUiFacade::ReadResourceLC( TInt aNoteTextResourceId )
       
   194     {
       
   195     //Own resource reader for AA plug-in environment (no CONE facilities available)
       
   196 
       
   197     //resource texts are hold in TBUFs
       
   198     //TBUF == "A utility struct that holds one non-zero-terminated string."
       
   199     //==> no lead bytes in resource string
       
   200 
       
   201     TInt plainResourceId = 0x00000fff & aNoteTextResourceId; // Remove offset from id
       
   202     HBufC8* rawDataBuf = iResFile.AllocReadLC( plainResourceId );
       
   203 
       
   204     //raw data buffer is actually unicode text ==> treat it so
       
   205     TPtrC16 rawData( ( TUint16* ) rawDataBuf->Ptr(),
       
   206                      rawDataBuf->Length() / 2 );
       
   207 
       
   208     HBufC16* resourceData = rawData.AllocL();
       
   209     CleanupStack::PopAndDestroy( rawDataBuf ); //rawDataBuf
       
   210 
       
   211     CleanupStack::PushL( resourceData );
       
   212 
       
   213     return resourceData;
       
   214     }
       
   215 
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CCnUiGlobalNotificationUiFacade::ReadResourceWithDynTextLC()
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 HBufC* CCnUiGlobalNotificationUiFacade::ReadResourceWithDynTextLC( TInt aNoteTextResourceId,
       
   222                                                                    const TDesC& aInsertText )
       
   223     {
       
   224     //Own dynamic string loader for AA plug-in environment (no CONE facilities available)
       
   225 
       
   226     HBufC* resStringBuf = ReadResourceLC( aNoteTextResourceId );
       
   227 
       
   228     TInt reqDynLen = resStringBuf->Length() + aInsertText.Length();
       
   229     HBufC* dynStringBuf = HBufC::NewL( reqDynLen );
       
   230     TPtr dynString = dynStringBuf->Des();
       
   231     StringLoader::Format( dynString,
       
   232                           *resStringBuf,
       
   233                           -1,             //No index code in source string
       
   234                           aInsertText );
       
   235 
       
   236     CleanupStack::PopAndDestroy( resStringBuf ); //resStringBuf
       
   237     CleanupStack::PushL( dynStringBuf );
       
   238     return dynStringBuf;
       
   239     }
       
   240 
       
   241 
       
   242 
       
   243 //  End of File
       
   244 
       
   245 
       
   246