ipsservices/ipssossettings/src/ipssetuinotes.cpp
branchRCL_3
changeset 64 3533d4323edc
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     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 
       
   176     // Create dialog and execute the dialog
       
   177     CAknQueryDialog* dlg = CAknQueryDialog::NewL( aTone );
       
   178     TInt button = dlg->ExecuteLD( aDialogResource, aText );
       
   179 
       
   180     return button;
       
   181     }
       
   182 
       
   183 // ----------------------------------------------------------------------------
       
   184 // CIpsSetUiNotes::ShowNoteL
       
   185 // ----------------------------------------------------------------------------
       
   186 //
       
   187 void CIpsSetUiNotes::ShowNoteL(
       
   188     const TUint      aResource,
       
   189     const TIpsSetUiNotes& aNoteType,
       
   190     const TBool      aNoteWaiting )
       
   191     {
       
   192     FUNC_LOG;
       
   193     // Get text to be shown
       
   194     HBufC* prompt = MakeStringLC( aResource );
       
   195 
       
   196     // Show the note
       
   197     CIpsSetUiNotes::ShowNoteL( prompt->Des(), aNoteType, aNoteWaiting );
       
   198 
       
   199     CleanupStack::PopAndDestroy( prompt );
       
   200     }
       
   201 
       
   202 // ----------------------------------------------------------------------------
       
   203 // CIpsSetUiNotes::ShowNoteL
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 void CIpsSetUiNotes::ShowNoteL(
       
   207     const TDesC&      aText,
       
   208     const TIpsSetUiNotes& aNoteType,
       
   209     const TBool      aNoteWaiting )
       
   210     {
       
   211     FUNC_LOG;
       
   212     CAknResourceNoteDialog* note = NULL;
       
   213 
       
   214     // Create the note and show it
       
   215     switch( aNoteType )
       
   216         {
       
   217         // Show confirmation note
       
   218         case EIpsSetUiConfirmationNote:
       
   219             note = new ( ELeave ) CAknConfirmationNote( aNoteWaiting );
       
   220             break;
       
   221 
       
   222         // Show information note
       
   223         case EIpsSetUiInformationNote:
       
   224             note = new ( ELeave ) CAknInformationNote( aNoteWaiting );
       
   225             break;
       
   226 
       
   227         // Show error note
       
   228         case EIpsSetUiErrorNote:
       
   229             note = new ( ELeave ) CAknErrorNote( aNoteWaiting );
       
   230             break;
       
   231 
       
   232         // Show warning note
       
   233         case EIpsSetUiWarningNote:
       
   234             note = new ( ELeave ) CAknWarningNote( aNoteWaiting );
       
   235             break;
       
   236 
       
   237         // Wrong note given, leave
       
   238         default:
       
   239             User::Leave( KErrUnknown );
       
   240             break;
       
   241         }
       
   242 
       
   243     // Show the note
       
   244     note->ExecuteLD( aText );
       
   245     }
       
   246 
       
   247 /******************************************************************************
       
   248 
       
   249     Error note ui
       
   250 
       
   251 ******************************************************************************/
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CIMSSettingsNoteUi::ShowDialog()
       
   255 // ----------------------------------------------------------------------------
       
   256 //
       
   257 TIpsSetUiEventResult CIpsSetUiNotes::ShowDialog(
       
   258     const CIpsSetUiItem& aBaseItem,
       
   259     const TIpsSetUiNoteErrors aError,
       
   260     const TDesC& /* aNewText */ )
       
   261     {
       
   262     FUNC_LOG;
       
   263     TIpsSetUiEventResult result = EIpsSetUiPageEventResultApproved;
       
   264      
       
   265     // Show error note based on the id
       
   266     switch ( aBaseItem.iItemId.iUid )
       
   267         {
       
   268         case EIpsSetUiMailboxEmailAddress:
       
   269         case EIpsSetUiMailboxReplyToAddress:
       
   270             TRAP_IGNORE( result = ShowEmailAddressErrorNoteL( aError ) );
       
   271             return result;
       
   272 
       
   273         case EIpsSetUiIncomingMailServer:
       
   274         case EIpsSetUiOutgoingMailServer:
       
   275             TRAP_IGNORE( result = ShowServerErrorNoteL( aError ) );
       
   276             return result;
       
   277 
       
   278         default:
       
   279             break;
       
   280         }
       
   281    
       
   282 
       
   283     return result;
       
   284     }
       
   285 
       
   286 // ----------------------------------------------------------------------------
       
   287 // CIpsSetUiNotes::ShowEmailAddressErrorNoteL()
       
   288 // ----------------------------------------------------------------------------
       
   289 //
       
   290 TIpsSetUiEventResult CIpsSetUiNotes::ShowEmailAddressErrorNoteL(
       
   291     const TIpsSetUiNoteErrors aError )
       
   292     {
       
   293     FUNC_LOG;
       
   294     // Show notes
       
   295     switch ( aError )
       
   296         {
       
   297         // Incorrect
       
   298         case EIpsSetUiItemInvalid:
       
   299             CIpsSetUiNotes::ShowNoteL(
       
   300                 R_FSE_SETTINGS_MAIL_EMAIL_PROMPT,
       
   301                 EIpsSetUiInformationNote, ETrue );
       
   302             return EIpsSetUiPageEventResultDisapproved;
       
   303 
       
   304         default:
       
   305             break;
       
   306         }
       
   307 
       
   308     return EIpsSetUiPageEventResultApproved;
       
   309     }
       
   310 
       
   311 // ----------------------------------------------------------------------------
       
   312 // CIpsSetUiNotes::ShowServerErrorNoteL()
       
   313 // ----------------------------------------------------------------------------
       
   314 //
       
   315 TIpsSetUiEventResult CIpsSetUiNotes::ShowServerErrorNoteL(
       
   316     const TIpsSetUiNoteErrors aError )
       
   317     {
       
   318     FUNC_LOG;
       
   319     switch ( aError )
       
   320         {
       
   321         case EIpsSetUiNoError:
       
   322             return EIpsSetUiPageEventResultApproved;
       
   323 
       
   324         default:
       
   325             break;
       
   326         }
       
   327 
       
   328     CIpsSetUiNotes::ShowQueryL(
       
   329         R_FSE_SETTINGS_MAIL_SRVR_PROMPT, R_IPS_SETUI_INFORMATION_QUERY );
       
   330     return EIpsSetUiPageEventResultDisapproved;
       
   331     }
       
   332