ipsservices/ipssossettings/src/ipssetuinotes.cpp
changeset 0 8466d47a6819
child 23 dcf0eedfc1a3
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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: This file implements class CIpsSetUiNotes.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <e32base.h>
       
    21 #include <ipssossettings.rsg>
       
    22 #include <StringLoader.h>
       
    23 #include <aknnotewrappers.h>
       
    24 #include <aknclearer.h>
       
    25 
       
    26 #include "ipssetutils.h"
       
    27 #include "ipssetutilspageids.hrh"
       
    28 #include "ipssetui.h"
       
    29 #include "ipssetuiitembase.h"
       
    30 
       
    31 #include "ipssetuinotes.h"
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // CIpsSetUiNotes::CIpsSetUiNotes()
       
    37 // ----------------------------------------------------------------------------
       
    38 //
       
    39 CIpsSetUiNotes::CIpsSetUiNotes()
       
    40     {
       
    41     FUNC_LOG;
       
    42     }
       
    43 
       
    44 // ----------------------------------------------------------------------------
       
    45 // CIpsSetUiNotes::~CIpsSetUiNotes()
       
    46 // ----------------------------------------------------------------------------
       
    47 //
       
    48 CIpsSetUiNotes::~CIpsSetUiNotes()
       
    49     {
       
    50     FUNC_LOG;
       
    51     }
       
    52 
       
    53 // ----------------------------------------------------------------------------
       
    54 // CIpsSetUiNotes::ConstructL()
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 void CIpsSetUiNotes::ConstructL()
       
    58     {
       
    59     FUNC_LOG;
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // CIpsSetUiNotes::NewL()
       
    64 // ----------------------------------------------------------------------------
       
    65 //
       
    66 CIpsSetUiNotes* CIpsSetUiNotes::NewL()
       
    67     {
       
    68     FUNC_LOG;
       
    69     CIpsSetUiNotes* self = NewLC();
       
    70     CleanupStack::Pop( self );
       
    71 
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ----------------------------------------------------------------------------
       
    76 // CIpsSetUiNotes::NewLC()
       
    77 // ----------------------------------------------------------------------------
       
    78 //
       
    79 CIpsSetUiNotes* CIpsSetUiNotes::NewLC()
       
    80     {
       
    81     FUNC_LOG;
       
    82     CIpsSetUiNotes* self = new ( ELeave ) CIpsSetUiNotes();
       
    83     CleanupStack::PushL( self );
       
    84 
       
    85     return self;
       
    86     }
       
    87 
       
    88 /******************************************************************************
       
    89 
       
    90     STATIC FUNCTIONS
       
    91 
       
    92 ******************************************************************************/
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CIpsSetUiNotes::MakeStringLC()
       
    96 // ----------------------------------------------------------------------------
       
    97 //
       
    98 HBufC* CIpsSetUiNotes::MakeStringLC( const TUint aTextResource )
       
    99     {
       
   100     FUNC_LOG;
       
   101     HBufC* prompt = StringLoader::LoadL( aTextResource );
       
   102     CleanupStack::PushL( prompt );
       
   103 
       
   104     return prompt;
       
   105     }
       
   106 
       
   107 // ----------------------------------------------------------------------------
       
   108 // CIpsSetUiNotes::MakeString()
       
   109 // ----------------------------------------------------------------------------
       
   110 //
       
   111 TIpsSetUtilsTextPlain CIpsSetUiNotes::MakeString(
       
   112     const TUint aTextResource,
       
   113     const TInt aValue )
       
   114     {
       
   115     FUNC_LOG;
       
   116     TIpsSetUtilsTextPlain resourceText;
       
   117     TIpsSetUtilsTextPlain finalText;
       
   118     StringLoader::Load( resourceText, aTextResource );
       
   119     StringLoader::Format(
       
   120         finalText, resourceText, KErrNotFound, aValue );
       
   121 
       
   122     return finalText;
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // CIpsSetUiNotes::MakeString()
       
   127 // ----------------------------------------------------------------------------
       
   128 //
       
   129 TIpsSetUtilsTextPlain CIpsSetUiNotes::MakeString(
       
   130     const TUint aTextResource,
       
   131     const TDesC& aText )
       
   132     {
       
   133     FUNC_LOG;
       
   134     TIpsSetUtilsTextPlain resourceText;
       
   135     TIpsSetUtilsTextPlain finalText;
       
   136     StringLoader::Load( resourceText, aTextResource );
       
   137     StringLoader::Format(
       
   138         finalText, resourceText, KErrNotFound, aText );
       
   139 
       
   140     return finalText;
       
   141     }
       
   142 
       
   143 // ----------------------------------------------------------------------------
       
   144 // CIpsSetUiNotes::ShowQuery
       
   145 // ----------------------------------------------------------------------------
       
   146 //
       
   147 TInt CIpsSetUiNotes::ShowQueryL(
       
   148     const TUint aTextResource,
       
   149     const TInt  aDialogResource,
       
   150     const CAknQueryDialog::TTone aTone )
       
   151     {
       
   152     FUNC_LOG;
       
   153     // Get text to be shown
       
   154     HBufC* prompt = MakeStringLC( aTextResource );
       
   155 
       
   156     // Create dialog and execute the dialog
       
   157     TInt result = CIpsSetUiNotes::ShowQueryL(
       
   158         prompt->Des(), aDialogResource, aTone );
       
   159 
       
   160     CleanupStack::PopAndDestroy( prompt );
       
   161 
       
   162     return result;
       
   163     }
       
   164 
       
   165 // ----------------------------------------------------------------------------
       
   166 // CIpsSetUiNotes::ShowQuery
       
   167 // ----------------------------------------------------------------------------
       
   168 //
       
   169 TInt CIpsSetUiNotes::ShowQueryL(
       
   170     const TDesC& aText,
       
   171     const TInt  aDialogResource,
       
   172     const CAknQueryDialog::TTone aTone )
       
   173     {
       
   174     FUNC_LOG;
       
   175     CAknLocalScreenClearer* localScreenClearer =
       
   176         CAknLocalScreenClearer::NewL( EFalse );
       
   177     CleanupStack::PushL( localScreenClearer );
       
   178 
       
   179     // Create dialog and execute the dialog
       
   180     CAknQueryDialog* dlg = CAknQueryDialog::NewL( aTone );
       
   181     TInt button = dlg->ExecuteLD( aDialogResource, aText );
       
   182     CleanupStack::PopAndDestroy( localScreenClearer );
       
   183 
       
   184     return button;
       
   185     }
       
   186 
       
   187 // ----------------------------------------------------------------------------
       
   188 // CIpsSetUiNotes::ShowNoteL
       
   189 // ----------------------------------------------------------------------------
       
   190 //
       
   191 void CIpsSetUiNotes::ShowNoteL(
       
   192     const TUint      aResource,
       
   193     const TIpsSetUiNotes& aNoteType,
       
   194     const TBool      aNoteWaiting )
       
   195     {
       
   196     FUNC_LOG;
       
   197     // Get text to be shown
       
   198     HBufC* prompt = MakeStringLC( aResource );
       
   199 
       
   200     // Show the note
       
   201     CIpsSetUiNotes::ShowNoteL( prompt->Des(), aNoteType, aNoteWaiting );
       
   202 
       
   203     CleanupStack::PopAndDestroy( prompt );
       
   204     }
       
   205 
       
   206 // ----------------------------------------------------------------------------
       
   207 // CIpsSetUiNotes::ShowNoteL
       
   208 // ----------------------------------------------------------------------------
       
   209 //
       
   210 void CIpsSetUiNotes::ShowNoteL(
       
   211     const TDesC&      aText,
       
   212     const TIpsSetUiNotes& aNoteType,
       
   213     const TBool      aNoteWaiting )
       
   214     {
       
   215     FUNC_LOG;
       
   216     CAknResourceNoteDialog* note = NULL;
       
   217 
       
   218     // Create the note and show it
       
   219     switch( aNoteType )
       
   220         {
       
   221         // Show confirmation note
       
   222         case EIpsSetUiConfirmationNote:
       
   223             note = new ( ELeave ) CAknConfirmationNote( aNoteWaiting );
       
   224             break;
       
   225 
       
   226         // Show information note
       
   227         case EIpsSetUiInformationNote:
       
   228             note = new ( ELeave ) CAknInformationNote( aNoteWaiting );
       
   229             break;
       
   230 
       
   231         // Show error note
       
   232         case EIpsSetUiErrorNote:
       
   233             note = new ( ELeave ) CAknErrorNote( aNoteWaiting );
       
   234             break;
       
   235 
       
   236         // Show warning note
       
   237         case EIpsSetUiWarningNote:
       
   238             note = new ( ELeave ) CAknWarningNote( aNoteWaiting );
       
   239             break;
       
   240 
       
   241         // Wrong note given, leave
       
   242         default:
       
   243             User::Leave( KErrUnknown );
       
   244             break;
       
   245         }
       
   246 
       
   247     // Show the note
       
   248     note->ExecuteLD( aText );
       
   249     }
       
   250 
       
   251 /******************************************************************************
       
   252 
       
   253     Error note ui
       
   254 
       
   255 ******************************************************************************/
       
   256 
       
   257 // ----------------------------------------------------------------------------
       
   258 // CIMSSettingsNoteUi::ShowDialog()
       
   259 // ----------------------------------------------------------------------------
       
   260 //
       
   261 TIpsSetUiEventResult CIpsSetUiNotes::ShowDialog(
       
   262     const CIpsSetUiItem& aBaseItem,
       
   263     const TIpsSetUiNoteErrors aError,
       
   264     const TDesC& /* aNewText */ )
       
   265     {
       
   266     FUNC_LOG;
       
   267     TIpsSetUiEventResult result = EIpsSetUiPageEventResultApproved;
       
   268      
       
   269     // Show error note based on the id
       
   270     switch ( aBaseItem.iItemId.iUid )
       
   271         {
       
   272         case EIpsSetUiMailboxEmailAddress:
       
   273         case EIpsSetUiMailboxReplyToAddress:
       
   274             TRAP_IGNORE( result = ShowEmailAddressErrorNoteL( aError ) );
       
   275             return result;
       
   276 
       
   277         case EIpsSetUiIncomingMailServer:
       
   278         case EIpsSetUiOutgoingMailServer:
       
   279             TRAP_IGNORE( result = ShowServerErrorNoteL( aError ) );
       
   280             return result;
       
   281 
       
   282         default:
       
   283             break;
       
   284         }
       
   285    
       
   286 
       
   287     return result;
       
   288     }
       
   289 
       
   290 // ----------------------------------------------------------------------------
       
   291 // CIpsSetUiNotes::ShowEmailAddressErrorNoteL()
       
   292 // ----------------------------------------------------------------------------
       
   293 //
       
   294 TIpsSetUiEventResult CIpsSetUiNotes::ShowEmailAddressErrorNoteL(
       
   295     const TIpsSetUiNoteErrors aError )
       
   296     {
       
   297     FUNC_LOG;
       
   298     // Show notes
       
   299     switch ( aError )
       
   300         {
       
   301         // Incorrect
       
   302         case EIpsSetUiItemInvalid:
       
   303             CIpsSetUiNotes::ShowNoteL(
       
   304                 R_FSE_SETTINGS_MAIL_EMAIL_PROMPT,
       
   305                 EIpsSetUiInformationNote, ETrue );
       
   306             return EIpsSetUiPageEventResultDisapproved;
       
   307 
       
   308         default:
       
   309             break;
       
   310         }
       
   311 
       
   312     return EIpsSetUiPageEventResultApproved;
       
   313     }
       
   314 
       
   315 // ----------------------------------------------------------------------------
       
   316 // CIpsSetUiNotes::ShowServerErrorNoteL()
       
   317 // ----------------------------------------------------------------------------
       
   318 //
       
   319 TIpsSetUiEventResult CIpsSetUiNotes::ShowServerErrorNoteL(
       
   320     const TIpsSetUiNoteErrors aError )
       
   321     {
       
   322     FUNC_LOG;
       
   323     switch ( aError )
       
   324         {
       
   325         case EIpsSetUiNoError:
       
   326             return EIpsSetUiPageEventResultApproved;
       
   327 
       
   328         default:
       
   329             break;
       
   330         }
       
   331 
       
   332     CIpsSetUiNotes::ShowQueryL(
       
   333         R_FSE_SETTINGS_MAIL_SRVR_PROMPT, R_IPS_SETUI_INFORMATION_QUERY );
       
   334     return EIpsSetUiPageEventResultDisapproved;
       
   335     }
       
   336