emailservices/emailserver/src/FsEmailMessageQueryDialog.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Source file for FS Email message query dialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 //<cmail>
       
    21 #include "emailtrace.h"
       
    22 #include <uikon/eiksrvui.h>   // CEikServAppUi
       
    23 //</cmail>
       
    24 #include <StringLoader.h>
       
    25 
       
    26 #include <fsmailserver.rsg>
       
    27 //<cmail>
       
    28 #include "fsmailserverconst.h"
       
    29 //</cmail>
       
    30 
       
    31 #include "FsEmailMessageQueryDialog.h"
       
    32 
       
    33 // ---------------------------------------------------------
       
    34 // CFsEmailMessageQueryDialog::CFsEmailMessageQueryDialog
       
    35 // ---------------------------------------------------------
       
    36 //
       
    37 CFsEmailMessageQueryDialog::CFsEmailMessageQueryDialog( 
       
    38         TRequestStatus& aStatus,
       
    39         TDesC& aMailboxName,
       
    40         TFsEmailNotifierSystemMessageType aMessageType )
       
    41 : CAknMessageQueryDialog( CAknQueryDialog::ENoTone ),
       
    42   iRequest( &aStatus ),
       
    43   iMessageType( aMessageType ),
       
    44   iMailboxName( aMailboxName )
       
    45     {
       
    46     FUNC_LOG;
       
    47     *iRequest = KRequestPending;
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CFsEmailMessageQueryDialog::~CFsEmailMessageQueryDialog
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 CFsEmailMessageQueryDialog::~CFsEmailMessageQueryDialog()
       
    56     {
       
    57     FUNC_LOG;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // CFsEmailMessageQueryDialog::NewL
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 CFsEmailMessageQueryDialog* CFsEmailMessageQueryDialog::NewLC( 
       
    65         TRequestStatus& aStatus,
       
    66         TDesC& aMailboxName,
       
    67         TFsEmailNotifierSystemMessageType aMessageType,
       
    68         const TDesC& aCustomMessageText )
       
    69     {
       
    70     FUNC_LOG;
       
    71     CFsEmailMessageQueryDialog* self = new( ELeave ) 
       
    72         CFsEmailMessageQueryDialog( aStatus, aMailboxName, aMessageType );
       
    73 
       
    74     self->PrepareDialogLC( aCustomMessageText );
       
    75     
       
    76     return self;
       
    77     }
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CFsEmailMessageQueryDialog::OkToExitL
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 TBool CFsEmailMessageQueryDialog::OkToExitL( TInt aButtonId )
       
    85     {
       
    86     FUNC_LOG;
       
    87     if ( CAknMessageQueryDialog::OkToExitL( aButtonId ) )
       
    88         {
       
    89         if ( aButtonId == EAknSoftkeySelect || 
       
    90              aButtonId == EAknSoftkeyOk || 
       
    91              aButtonId == EAknSoftkeyDone )
       
    92             {
       
    93 			// Ignore any errors to avoid the situation that the notifier keeps
       
    94 			// hanging in screen if the calling party is crashed etc.
       
    95             User::RequestComplete( iRequest, KErrNone );
       
    96             }
       
    97         else //if ( aButtonId == EAknSoftkeyCancel )
       
    98             {
       
    99 			// Ignore any errors to avoid the situation that the notifier keeps
       
   100 			// hanging in screen if the calling party is crashed etc.
       
   101             User::RequestComplete( iRequest, KErrCancel );
       
   102             }
       
   103         	
       
   104         return ETrue;
       
   105         }
       
   106 
       
   107     return EFalse;
       
   108     }
       
   109 
       
   110 
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Show asynchronous message query
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CFsEmailMessageQueryDialog::PrepareDialogLC( const TDesC& aCustomMessageText )
       
   118     {
       
   119     FUNC_LOG;
       
   120     PrepareLC( R_FS_MSERVER_DIALOG_MESSAGE_QUERY );
       
   121 
       
   122     if( GetResourceIdsL() )
       
   123         {
       
   124         SetMessageTextAndCbaToDialogL();
       
   125         }
       
   126     else
       
   127         {
       
   128         SetMessageTextAndCbaToDialogL( aCustomMessageText );
       
   129         }
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------
       
   133 // Get message text and CBA resource ids by input data
       
   134 // ---------------------------------------------------------
       
   135 //
       
   136 TBool CFsEmailMessageQueryDialog::GetResourceIdsL()
       
   137     {
       
   138     FUNC_LOG;
       
   139     iAddMailboxNameToText = EFalse;
       
   140     switch( iMessageType )
       
   141         {
       
   142         // Custom error messages
       
   143         case EFsEmailNotifErrCustom:
       
   144             {
       
   145             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   146             }
       
   147             return EFalse;
       
   148 
       
   149         case EFsEmailNotifErrCustomResponse:
       
   150             {
       
   151             iCbaResourceId = R_AVKON_SOFTKEYS_OK_CANCEL;
       
   152             }
       
   153             return EFalse;
       
   154 
       
   155         // No response
       
   156         case EFsEmailNotifErrAccountDisabled:
       
   157             {
       
   158             iMsgTxtResourceId = R_FS_MSERVER_TEXT_ACCOUNT_DISABLED;
       
   159             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   160             }
       
   161             break;
       
   162         
       
   163         case EFsEmailNotifErrPasswordExpired:
       
   164             {
       
   165             iMsgTxtResourceId = R_FS_MSERVER_TEXT_PASSWORD_EXPIRED;
       
   166             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   167             }
       
   168             break;
       
   169 
       
   170         case EFsEmailNotifErrDataDeleted:
       
   171             {
       
   172             iMsgTxtResourceId = R_FS_MSERVER_TEXT_DATA_DELETED;
       
   173             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   174             }
       
   175             break;
       
   176 
       
   177         case EFsEmailNotifErrLoginUnsuccesfull:
       
   178             {
       
   179             iMsgTxtResourceId = R_FS_MSERVER_TEXT_LOGIN_UNSUCCESSFUL;
       
   180             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   181             }
       
   182             break;
       
   183 
       
   184         case EFsEmailNotifErrPasswordChanged:
       
   185             {
       
   186             iMsgTxtResourceId = R_FS_MSERVER_TEXT_PASSWORD_CHANGED;
       
   187             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   188             }
       
   189             break;
       
   190 
       
   191         case EFsEmailNotifErrLoginCanceled:
       
   192             {
       
   193             iMsgTxtResourceId = R_FS_MSERVER_TEXT_AUTH_CANCELED_TRY_AGAIN;
       
   194             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   195             }
       
   196             break;
       
   197 
       
   198         case EFsEmailNotifErrServerNotAvailable:
       
   199             {
       
   200             iMsgTxtResourceId = R_FS_MSERVER_TEXT_SERVER_NOT_FOUND_TRY_AGAIN;
       
   201             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   202             }
       
   203             break;
       
   204 
       
   205         case EFsEmailNotifErrNetworkNotAvailable:
       
   206             {
       
   207             iMsgTxtResourceId = R_FS_MSERVER_TEXT_NETWORK_UNAVAILABLE_TRY_AGAIN;
       
   208             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   209             }
       
   210             break;
       
   211 
       
   212         case EFsEmailNotifErrServerBusy:
       
   213             {
       
   214             iMsgTxtResourceId = R_FS_MSERVER_TEXT_SERVER_CURRENTLY_BUSY_TRY_AGAIN;
       
   215             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   216             }
       
   217             break;
       
   218 
       
   219         case EFsEmailNotifErrUnableToConnectToServerTryAgain:
       
   220             {
       
   221             iMsgTxtResourceId = R_FS_MSERVER_TEXT_UNABLE_TO_CONNECT_TRY_AGAIN;
       
   222             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   223             }
       
   224             break;
       
   225 
       
   226         case EFsEmailNotifErrEmailAddrAndPwdDontMatch:
       
   227             {
       
   228             iMsgTxtResourceId = R_FS_MSERVER_TEXT_INVALID_EMAIL_ADDRESS_AND_PASSWORD_TRY_AGAIN;
       
   229             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   230             }
       
   231             break;
       
   232 
       
   233         case EFsEmailNotifErrInvalidEmailAddress:
       
   234             {
       
   235             iMsgTxtResourceId = R_FS_MSERVER_TEXT_INVALID_EMAIL_ADDRESS;
       
   236             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   237             }
       
   238             break;
       
   239 
       
   240         case EFsEmailNotifErrServerOffline:
       
   241             {
       
   242             iMsgTxtResourceId = R_FS_MSERVER_TEXT_SERVER_OFFLINE;
       
   243             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   244             }
       
   245             break;
       
   246 
       
   247         case EFsEmailNotifErrRoamingTurnedOn:
       
   248             {
       
   249             iMsgTxtResourceId = R_FS_MSERVER_TEXT_ROAMING_TURNED_ON;
       
   250             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   251             }
       
   252             break;
       
   253 
       
   254         case EFsEmailNotifErrRoamingCosts:
       
   255             {
       
   256             iMsgTxtResourceId = R_FS_MSERVER_TEXT_ROAMING_COSTS;
       
   257             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   258             }
       
   259             break;
       
   260 
       
   261         case EFsEmailNotifErrUnableToComplete:
       
   262             {
       
   263             iMsgTxtResourceId = R_FS_MSERVER_TEXT_UNABLE_TO_COMPLETE;
       
   264             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   265             }
       
   266             break;
       
   267 
       
   268         case EFsEmailNotifErrConnectionError:
       
   269             {
       
   270             iMsgTxtResourceId = R_FS_MSERVER_TEXT_CONNECTION_ERROR;
       
   271             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   272             }
       
   273             break;
       
   274 
       
   275         case EFsEmailNotifErrUnableToConnect:
       
   276             {
       
   277             iMsgTxtResourceId = R_FS_MSERVER_TEXT_UNABLE_TO_CONNECT;
       
   278             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   279             }
       
   280             break;
       
   281 
       
   282         case EFsEmailNotifErrMultipleSyncErrors:
       
   283             {
       
   284             iMsgTxtResourceId = R_FS_MSERVER_TEXT_MULTIPLE_SYNC_ERRORS;
       
   285             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   286             }
       
   287             break;
       
   288 
       
   289         case EFsEmailNotifErrLoginFailed:
       
   290             {
       
   291             iMsgTxtResourceId = R_FS_MSERVER_TEXT_LOGIN_FAILED;
       
   292             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   293             }
       
   294             break;
       
   295 
       
   296         case EFsEmailNotifErrServerNotFoundCheckSettings:
       
   297             {
       
   298             iMsgTxtResourceId = R_FS_MSERVER_TEXT_SERVER_CANNOT_FOUND_CHECK_SETTINGS;
       
   299             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   300             }
       
   301             break;
       
   302 
       
   303         case EFsEmailNotifErrUnableToConnectToServer:
       
   304             {
       
   305             iMsgTxtResourceId = R_FS_MSERVER_TEXT_UNABLE_TO_CONNECT_TO_SERVER;
       
   306             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   307             }
       
   308             break;
       
   309 
       
   310         case EFsEmailNotifErrDisconnected:
       
   311             {
       
   312             iMsgTxtResourceId = R_FS_MSERVER_TEXT_DISCONNECTED;
       
   313             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   314             }
       
   315             break;
       
   316 
       
   317         case EFsEmailNotifErrServerErroTryAgain:
       
   318             {
       
   319             iMsgTxtResourceId = R_FS_MSERVER_TEXT_SERVER_ERROR_TRY_AGAIN;
       
   320             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   321             }
       
   322             break;
       
   323 
       
   324         case EFsEmailNotifErrOutOfMemory:
       
   325             {
       
   326             iMsgTxtResourceId = R_FS_MSERVER_SYNCH_NOT_ENOUGH_MEMORY;
       
   327             iCbaResourceId = R_AVKON_SOFTKEYS_OK_EMPTY;
       
   328             iAddMailboxNameToText = ETrue;
       
   329             }
       
   330             break;
       
   331             
       
   332         // Response
       
   333         case EFsEmailNotifErrSynchronizationFailed:
       
   334             {
       
   335             iMsgTxtResourceId = R_FS_MSERVER_TEXT_SYNC_FAILED_TRY_AGAIN;
       
   336             iCbaResourceId = R_AVKON_SOFTKEYS_OK_CANCEL;
       
   337             }
       
   338             break;
       
   339 
       
   340         // Wait note
       
   341         case EFsEmailNotifErrAuthenticatingWaitNote:
       
   342             {
       
   343             iMsgTxtResourceId = R_FS_MSERVER_AUTHENTICATING;
       
   344             iCbaResourceId = R_AVKON_SOFTKEYS_CANCEL;
       
   345             }
       
   346             break;
       
   347 
       
   348         // Error cases
       
   349         case EFsEmailNotifErrLastNoResponse:
       
   350         default:
       
   351             {
       
   352             User::Leave( KErrArgument );
       
   353             }
       
   354             break;
       
   355         }
       
   356     return ETrue;
       
   357     }
       
   358 
       
   359 // -----------------------------------------------------------
       
   360 // Set message text and CBA buttons
       
   361 // -----------------------------------------------------------
       
   362 //
       
   363 void CFsEmailMessageQueryDialog::SetMessageTextAndCbaToDialogL()
       
   364     {
       
   365     FUNC_LOG;
       
   366     SetDialogHeadingL();
       
   367     
       
   368     HBufC* text( NULL );
       
   369     if( iAddMailboxNameToText )
       
   370         {
       
   371         text = StringLoader::LoadLC( iMsgTxtResourceId, iMailboxName );
       
   372         }
       
   373     else
       
   374         {
       
   375         text = StringLoader::LoadLC( iMsgTxtResourceId  );
       
   376         }
       
   377     SetMessageTextL( *text );
       
   378     CleanupStack::PopAndDestroy( text );
       
   379     
       
   380     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   381     cba.SetCommandSetL( iCbaResourceId );
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------
       
   385 // Set message text and CBA buttons
       
   386 // -----------------------------------------------------------
       
   387 //
       
   388 void CFsEmailMessageQueryDialog::SetMessageTextAndCbaToDialogL(
       
   389         const TDesC& aText )
       
   390     {
       
   391     FUNC_LOG;
       
   392     SetDialogHeadingL();
       
   393     
       
   394     SetMessageTextL( aText );
       
   395 
       
   396     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   397     cba.SetCommandSetL( iCbaResourceId );
       
   398     }
       
   399 
       
   400 // -----------------------------------------------------------
       
   401 // Set dialog heading text
       
   402 // -----------------------------------------------------------
       
   403 //
       
   404 void CFsEmailMessageQueryDialog::SetDialogHeadingL()
       
   405     {
       
   406     FUNC_LOG;
       
   407     HBufC* text(NULL);
       
   408     if( iMailboxName != KNullDesC )
       
   409         {
       
   410         text = StringLoader::LoadLC( R_FS_MSERVER_MAILBOX_NAME, iMailboxName );
       
   411         }
       
   412     else
       
   413         {
       
   414         text = StringLoader::LoadLC( R_FS_MSERVER_APPLICATION_NAME );
       
   415         }
       
   416 
       
   417     QueryHeading()->SetTextL( *text );
       
   418 
       
   419     CleanupStack::PopAndDestroy( text );
       
   420     }
       
   421 
       
   422 
       
   423 // End of File
       
   424